Skip to content

Commit f005ce7

Browse files
Implemented the GridTemplate for all themes
- In all themes except `@rjsf/core`: - Implemented the `GridTemplate` using the theme specific grid, adding them to the `templates` in the Registry - In `@rjsf/core` cleaned up the documentation for the already implemented `GridTemplate` - In `@rjsf/mui` switched to using the `Grid2` component instead of the deprecated `Grid` - Updated the `CHANGELOG_V6.md` accordingly
1 parent ffe154b commit f005ce7

File tree

26 files changed

+1550
-3116
lines changed

26 files changed

+1550
-3116
lines changed

CHANGELOG_v6.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ should change the heading of the (upcoming) version to include a major version b
2121

2222
- BREAKING CHANGE: Refactored `ArrayFieldItemTemplate` to use the new `ArrayFieldItemButtonsTemplate`
2323
- Updated the `ArrayFieldTemplate`, `ObjectFieldTemplate`, and `WrapIfAdditionalTemplate` to a unique id using the `buttonId()` function and adding consistent marker classes
24+
- Implemented the `GridTemplate` component, adding it to the `templates` for the theme
2425

2526
## @rjsf/chakra-ui
2627

2728
- BREAKING CHANGE: Refactored `ArrayFieldItemTemplate` to use the new `ArrayFieldItemButtonsTemplate`
2829
- Updated the `ArrayFieldTemplate`, `ObjectFieldTemplate`, and `WrapIfAdditionalTemplate` to a unique id using the `buttonId()` function and adding consistent marker classes
30+
- Implemented the `GridTemplate` component, adding it to the `templates` for the theme
2931

3032
## @rjsf/core
3133

3234
- BREAKING CHANGE: Updated `ArrayField` to provide the `buttonsProps` to the `ArrayFieldItemTemplateType`
3335
- Added `ArrayFieldItemButtonsTemplate` component as a refactor of all the common buttons code from all the `ArrayFieldItemTemplate` implementations, adding a unique id using the `buttonId()` function
3436
- Refactored `ArrayFieldItemTemplate` to use the new `ArrayFieldItemButtonsTemplate`
3537
- Updated the `ArrayFieldTemplate`, `ObjectFieldTemplate`, and `WrapIfAdditionalTemplate` to a unique id using the `buttonId()` function and adding consistent marker classes
38+
- Implemented the `GridTemplate` component, adding it to the `templates` for the theme
3639

3740
## @rjsf/fluent-ui
3841

@@ -42,16 +45,20 @@ should change the heading of the (upcoming) version to include a major version b
4245

4346
- BREAKING CHANGE: Refactored `ArrayFieldItemTemplate` to use the new `ArrayFieldItemButtonsTemplate`
4447
- Updated the `ArrayFieldTemplate`, `ObjectFieldTemplate`, and `WrapIfAdditionalTemplate` to a unique id using the `buttonId()` function and adding consistent marker classes
48+
- Implemented the `GridTemplate` component, adding it to the `templates` for the theme
4549

4650
## @rjsf/mui
4751

4852
- BREAKING CHANGE: Refactored `ArrayFieldItemTemplate` to use the new `ArrayFieldItemButtonsTemplate`
4953
- Updated the `ArrayFieldTemplate`, `ObjectFieldTemplate`, and `WrapIfAdditionalTemplate` to a unique id using the `buttonId()` function and adding consistent marker classes
54+
- Updated the theme to use `Grid2` instead of the deprecated `Grid`
55+
- Implemented the `GridTemplate` component, adding it to the `templates` for the theme
5056

5157
## @rjsf/semantic-ui
5258

5359
- BREAKING CHANGE: Refactored `ArrayFieldItemTemplate` to use the new `ArrayFieldItemButtonsTemplate`
5460
- Updated the `ArrayFieldTemplate`, `ObjectFieldTemplate`, and `WrapIfAdditionalTemplate` to a unique id using the `buttonId()` function and adding consistent marker classes
61+
- Implemented the `GridTemplate` component, adding it to the `templates` for the theme
5562

5663
## @rjsf/utils
5764

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Col, Row } from 'antd';
2+
import { GridTemplateProps } from '@rjsf/utils';
3+
4+
/** Renders a `GridTemplate` for antd, which is expecting the column sizing information coming in via the
5+
* extra props provided by the caller, which are spread directly on the `Row`/`Col`.
6+
*
7+
* @param props - The GridTemplateProps, including the extra props containing the antd grid positioning details
8+
*/
9+
export default function GridTemplate(props: GridTemplateProps) {
10+
const { children, column, ...rest } = props;
11+
if (column) {
12+
return <Col {...rest}>{children}</Col>;
13+
}
14+
return <Row {...rest}>{children}</Row>;
15+
}

packages/antd/src/templates/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ErrorList from './ErrorList';
88
import { AddButton, CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from './IconButton';
99
import FieldErrorTemplate from './FieldErrorTemplate';
1010
import FieldTemplate from './FieldTemplate';
11+
import GridTemplate from './GridTemplate';
1112
import ObjectFieldTemplate from './ObjectFieldTemplate';
1213
import SubmitButton from './SubmitButton';
1314
import TitleField from './TitleField';
@@ -34,6 +35,7 @@ export function generateTemplates<
3435
ErrorListTemplate: ErrorList,
3536
FieldErrorTemplate,
3637
FieldTemplate,
38+
GridTemplate,
3739
ObjectFieldTemplate,
3840
TitleFieldTemplate: TitleField,
3941
WrapIfAdditionalTemplate,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Grid, GridItem } from '@chakra-ui/react';
2+
import { GridTemplateProps } from '@rjsf/utils';
3+
4+
/** Renders a `GridTemplate` for chakra-ui, which is expecting the column sizing information coming in via the
5+
* extra props provided by the caller, which are spread directly on the `Grid`/`GridItem`.
6+
*
7+
* @param props - The GridTemplateProps, including the extra props containing the chakra-ui grid positioning details
8+
*/
9+
export default function GridTemplate(props: GridTemplateProps) {
10+
const { children, column, ...rest } = props;
11+
if (column) {
12+
return <GridItem {...rest}>{children}</GridItem>;
13+
}
14+
return <Grid {...rest}>{children}</Grid>;
15+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './GridTemplate';
2+
export * from './GridTemplate';

packages/chakra-ui/src/Templates/Templates.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from '../IconB
88
import FieldErrorTemplate from '../FieldErrorTemplate';
99
import FieldHelpTemplate from '../FieldHelpTemplate';
1010
import FieldTemplate from '../FieldTemplate';
11+
import GridTemplate from '../GridTemplate';
1112
import ObjectFieldTemplate from '../ObjectFieldTemplate';
1213
import SubmitButton from '../SubmitButton';
1314
import TitleField from '../TitleField';
@@ -36,6 +37,7 @@ export function generateTemplates<
3637
FieldErrorTemplate,
3738
FieldHelpTemplate,
3839
FieldTemplate,
40+
GridTemplate,
3941
ObjectFieldTemplate,
4042
TitleFieldTemplate: TitleField,
4143
WrapIfAdditionalTemplate,

packages/core/src/components/templates/GridTemplate.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { GridTemplateProps } from '@rjsf/utils';
22

3-
/** Renders a `GridTemplate` for bootstrap 3, which is expecting the column
4-
* information coming in via the `className` prop.
3+
/** Renders a `GridTemplate` for bootstrap 3, which is expecting the column information coming in via the `className`
4+
* prop. Also spreads all the other props provided by the user directly on the div.
55
*
6-
* @param props - The GridTemplateProps, including the expected className for
7-
* the bootstrap 3 grid behavior
6+
* @param props - The GridTemplateProps, including the expected className for the bootstrap 3 grid behavior
87
*/
98
export default function GridTemplate(props: GridTemplateProps) {
10-
const { children, overrides, column, className, ...rest } = props;
9+
const { children, column, className, ...rest } = props;
1110
const classNames = column ? className : `row ${className}`;
1211
return (
1312
<div className={classNames} {...rest}>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Flex } from '@fluentui/react-migration-v0-v9';
2+
import { GridTemplateProps } from '@rjsf/utils';
3+
4+
/** Renders a `GridTemplate` for fluentui-rc, which is expecting the column sizing information coming in via the
5+
* extra props provided by the caller, which are spread directly on the `Flex`.
6+
*
7+
* @param props - The GridTemplateProps, including the extra props containing the fluentui-rc grid positioning details
8+
*/
9+
export default function GridTemplate(props: GridTemplateProps) {
10+
const { children, column, ...rest } = props;
11+
return <Flex {...rest}>{children}</Flex>;
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './GridTemplate';
2+
export * from './GridTemplate';

packages/fluentui-rc/src/Templates/Templates.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from '../IconB
88
import FieldErrorTemplate from '../FieldErrorTemplate';
99
import FieldHelpTemplate from '../FieldHelpTemplate';
1010
import FieldTemplate from '../FieldTemplate';
11+
import GridTemplate from '../GridTemplate';
1112
import ObjectFieldTemplate from '../ObjectFieldTemplate';
1213
import SubmitButton from '../SubmitButton';
1314
import TitleField from '../TitleField';
@@ -36,6 +37,7 @@ export function generateTemplates<
3637
FieldErrorTemplate,
3738
FieldHelpTemplate,
3839
FieldTemplate,
40+
GridTemplate,
3941
ObjectFieldTemplate,
4042
TitleFieldTemplate: TitleField,
4143
WrapIfAdditionalTemplate,

0 commit comments

Comments
 (0)