Skip to content

Commit 90446a3

Browse files
Feature - replaced IdSchema with FieldPathId (#4787)
* Feature - replaced IdSchema with FieldPathId In order to support an upcoming feature as well as eliminate a performance issue, `IdSchema` was replace with `FieldPathId` - In @rjsf/utils: - Added new `FieldPathList` and `FieldPathId` types and `DEFAULT_ID_PREFIX` and `DEFAULT_ID_SEPARATOR` to `constants.ts` - Added the new `toFieldPathId()` function to generate `FieldPathId`s, exporting it from the library - BREAKING CHANGES - Removed the `IdSchema` type, replacing `idSchema: IdSchema<T>` in all types with `fieldPathId: FieldPathId` - Updated the `idGenerators` to replace `id: IdSchema<T> | string` with `id: FieldPathId | string` removing the need for the `<T = any>` generic on the functions - Removed the `toIdSchema()` function in the `schema` directory - Updated the `SchemaUtilsType` and `createSchemaUtils()` to remove the `toIdSchema()` function - Deleted the `ui:rootFieldId` from the `UiSchema` since `idPrefix` does the same exact thing - Updated the tests accordingly - In `@rjsf/antd`, `@rjsf/chakra-ui`, `@rjsf/fluent-ui`, `@rjsf/mantine`, `@rjsf/mui`, `@rjsf/primereact`, `@rjsf/react-bootstrap`, `@rjsf/semantic-ui` and `@rjsf/shadcn`: - BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions - In @rjsf/core: - BREAKING CHANGES - Updated all of the fields, templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions - `ObjectField` and `ArrayField` to use `toFieldPathId` instead of `toIdSchema()` to generate the `fieldPathId`s of all its children - Updated the `onChange` handling of fields to make `path` required and either pass it straight through, or use the `fieldPathId.path` instead of using an empty array or appending path information - Updated `Form` to use `toFieldPathId()` to generate `fieldPathId` instead of `idSchema`, always providing the `idPrefix` and `idSeparator` in the `globalFormOptions` and make the `path: FieldPathList` required - Updated `LayoutGridField` to remove the `IdSchema` related code in favor of `FieldPathId` code - Also exported the `getTestRegistry()` function from the main `index.ts` to assist developers in creating `registry` object for tests - Updated all of the test to deal with the `idSchema` -> `fieldPathId` changes - In @rjsf/daisyui: - BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions - Also fixed the `FieldTemplate` to extract the `description` element so that it was not spread onto the `div`, fixing the snapshots - In @rjsf/validator-ajv8: - Updated the test to no longer try to test the delete `toIdSchema` function - In docs: - Updated `custom-templates.md`, `custom-widgets-fields.md` and `layout-grid.md` to change the `idSchema` documentation to `fieldPathId` - Updated `uiSchema.md` to remove the `ui:rootFieldId` documentation - Updated `utility-functions.md` delete `toIdSchema()`, add `toFieldPathId()` and to remove the `<T>` from the id generator functions - Updated `v6.x upgrade guide.md` to document all the breaking changes made in this release - Updated the `CHANGELOG.md` accordingly * - Updated docs to mention `getTestRegistry()` * - Responded to most of the reviewer feedback * - Fixed tests * - Switched `rootFieldId` to be deprecated * - Fixed documentation * - Moved `semantic-ui` deprecation warning into its own section
1 parent 1d774ea commit 90446a3

File tree

201 files changed

+1143
-464356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+1143
-464356
lines changed

CHANGELOG.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,82 @@ it according to semantic versioning. For example, if your PR adds a breaking cha
1515
should change the heading of the (upcoming) version to include a major version bump.
1616
1717
-->
18+
# 6.0.0-beta-20
19+
20+
## @rjsf/antd
21+
22+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
23+
24+
## @rjsf/chakra-ui
25+
26+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
27+
28+
## @rjsf/core
29+
30+
- BREAKING CHANGES
31+
- Updated all of the fields, templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
32+
- `ObjectField` and `ArrayField` to use `toFieldPathId` instead of `toIdSchema()` to generate the `fieldPathId`s of all its children
33+
- Updated the `onChange` handling of fields to make `path` required and either pass it straight through, or use the `fieldPathId.path` instead of using an empty array or appending path information
34+
- Updated `Form` to use `toFieldPathId()` to generate `fieldPathId` instead of `idSchema`, always providing the `idPrefix` and `idSeparator` in the `globalFormOptions` and make the `path: FieldPathList` required
35+
- Updated `LayoutGridField` to remove the `IdSchema` related code in favor of `FieldPathId` code
36+
- Also exported the `getTestRegistry()` function from the main `index.ts` to assist developers in creating `registry` object for tests
37+
- Updated all of the test to deal with the `idSchema` -> `fieldPathId` changes
38+
39+
## @rjsf/daisyui
40+
41+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
42+
- Also fixed the `FieldTemplate` to extract the `description` element so that it was not spread onto the `div`, fixing the snapshots
43+
44+
## @rjsf/fluent-ui
45+
46+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
47+
48+
## @rjsf/mantine
49+
50+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
51+
52+
## @rjsf/mui
53+
54+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
55+
56+
## @rjsf/primereact
57+
58+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
59+
60+
## @rjsf/react-bootstrap
61+
62+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
63+
64+
## @rjsf/semantic-ui
65+
66+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
67+
68+
## @rjsf/shadcn
69+
70+
- BREAKING CHANGES - Updated all of the templates and widgets to change `idSchema` to `fieldPathId` or to remove the `<T>` off of the idGenerator functions
71+
72+
## @rjsf/utils
73+
74+
- Added new `FieldPathList` and `FieldPathId` types and `DEFAULT_ID_PREFIX` and `DEFAULT_ID_SEPARATOR` to `constants.ts`
75+
- Added the new `toFieldPathId()` function to generate `FieldPathId`s, exporting it from the library
76+
- Deprecated the `ui:rootFieldId` in the `UiSchema` since `idPrefix` does the same exact thing
77+
- BREAKING CHANGES
78+
- Removed the `IdSchema` type, replacing `idSchema: IdSchema<T>` in all types with `fieldPathId: FieldPathId`
79+
- Updated the `idGenerators` to replace `id: IdSchema<T> | string` with `id: FieldPathId | string` removing the need for the `<T = any>` generic on the functions
80+
- Removed the `toIdSchema()` function in the `schema` directory
81+
- Updated the `SchemaUtilsType` and `createSchemaUtils()` to remove the `toIdSchema()` function
82+
83+
## @rjsf/validator-ajv8
84+
85+
- Updated the test to no longer try to test the delete `toIdSchema` function
86+
87+
## Dev / docs / playground
88+
89+
- Updated `custom-templates.md`, `custom-widgets-fields.md` and `layout-grid.md` to change the `idSchema` documentation to `fieldPathId`
90+
- Updated `uiSchema.md` to mark the `ui:rootFieldId` as deprecated in the documentation
91+
- Updated `utility-functions.md` delete `toIdSchema()`, add `toFieldPathId()` and to remove the `<T>` from the id generator functions
92+
- Updated `v6.x upgrade guide.md` to document all the breaking changes, new functions and deprecations made in `6.0.0-beta.20`
93+
1894
# 6.0.0-beta.19
1995

2096
## @rjsf/core

packages/antd/src/templates/ArrayFieldTemplate/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function ArrayFieldTemplate<
3030
canAdd,
3131
className,
3232
disabled,
33-
idSchema,
33+
fieldPathId,
3434
items,
3535
onAddClick,
3636
readonly,
@@ -73,12 +73,12 @@ export default function ArrayFieldTemplate<
7373
);
7474

7575
return (
76-
<fieldset className={className} id={idSchema.$id}>
76+
<fieldset className={className} id={fieldPathId.$id}>
7777
<Row gutter={rowGutter}>
7878
{(uiOptions.title || title) && (
7979
<Col className={labelColClassName} span={24}>
8080
<ArrayFieldTitleTemplate
81-
idSchema={idSchema}
81+
fieldPathId={fieldPathId}
8282
required={required}
8383
title={uiOptions.title || title}
8484
schema={schema}
@@ -91,7 +91,7 @@ export default function ArrayFieldTemplate<
9191
<Col span={24} style={DESCRIPTION_COL_STYLE}>
9292
<ArrayFieldDescriptionTemplate
9393
description={uiOptions.description || schema.description}
94-
idSchema={idSchema}
94+
fieldPathId={fieldPathId}
9595
schema={schema}
9696
uiSchema={uiSchema}
9797
registry={registry}
@@ -110,7 +110,7 @@ export default function ArrayFieldTemplate<
110110
<Row gutter={rowGutter} justify='end'>
111111
<Col flex='192px'>
112112
<AddButton
113-
id={buttonId<T>(idSchema, 'add')}
113+
id={buttonId(fieldPathId, 'add')}
114114
className='rjsf-array-item-add'
115115
disabled={disabled || readonly}
116116
onClick={onAddClick}

packages/antd/src/templates/BaseInputTemplate/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ export default function BaseInputTemplate<
6565
onFocus={!readonly ? handleFocus : undefined}
6666
placeholder={placeholder}
6767
style={INPUT_STYLE}
68-
list={schema.examples ? examplesId<T>(id) : undefined}
68+
list={schema.examples ? examplesId(id) : undefined}
6969
{...inputProps}
7070
value={value}
71-
aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
71+
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
7272
/>
7373
) : (
7474
<Input
@@ -80,18 +80,18 @@ export default function BaseInputTemplate<
8080
onFocus={!readonly ? handleFocus : undefined}
8181
placeholder={placeholder}
8282
style={INPUT_STYLE}
83-
list={schema.examples ? examplesId<T>(id) : undefined}
83+
list={schema.examples ? examplesId(id) : undefined}
8484
{...inputProps}
8585
value={value}
86-
aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
86+
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
8787
/>
8888
);
8989

9090
return (
9191
<>
9292
{input}
9393
{Array.isArray(schema.examples) && (
94-
<datalist id={examplesId<T>(id)}>
94+
<datalist id={examplesId(id)}>
9595
{(schema.examples as string[])
9696
.concat(schema.default && !schema.examples.includes(schema.default) ? ([schema.default] as string[]) : [])
9797
.map((example) => {

packages/antd/src/templates/FieldErrorTemplate/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export default function FieldErrorTemplate<
99
S extends StrictRJSFSchema = RJSFSchema,
1010
F extends FormContextType = any,
1111
>(props: FieldErrorProps<T, S, F>) {
12-
const { errors = [], idSchema } = props;
12+
const { errors = [], fieldPathId } = props;
1313
if (errors.length === 0) {
1414
return null;
1515
}
16-
const id = errorId<T>(idSchema);
16+
const id = errorId(fieldPathId);
1717

1818
return (
1919
<div id={id}>

packages/antd/src/templates/ObjectFieldTemplate/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default function ObjectFieldTemplate<
3939
description,
4040
disabled,
4141
formData,
42-
idSchema,
42+
fieldPathId,
4343
onAddClick,
4444
properties,
4545
readonly,
@@ -115,12 +115,12 @@ export default function ObjectFieldTemplate<
115115
);
116116

117117
return (
118-
<fieldset id={idSchema.$id}>
118+
<fieldset id={fieldPathId.$id}>
119119
<Row gutter={rowGutter}>
120120
{title && (
121121
<Col className={labelColClassName} span={24}>
122122
<TitleFieldTemplate
123-
id={titleId<T>(idSchema)}
123+
id={titleId(fieldPathId)}
124124
title={title}
125125
required={required}
126126
schema={schema}
@@ -132,7 +132,7 @@ export default function ObjectFieldTemplate<
132132
{description && (
133133
<Col span={24} style={DESCRIPTION_COL_STYLE}>
134134
<DescriptionFieldTemplate
135-
id={descriptionId<T>(idSchema)}
135+
id={descriptionId(fieldPathId)}
136136
description={description}
137137
schema={schema}
138138
uiSchema={uiSchema}
@@ -154,7 +154,7 @@ export default function ObjectFieldTemplate<
154154
<Row gutter={rowGutter} justify='end'>
155155
<Col flex='192px'>
156156
<AddButton
157-
id={buttonId<T>(idSchema, 'add')}
157+
id={buttonId(fieldPathId, 'add')}
158158
className='rjsf-object-property-expand'
159159
disabled={disabled || readonly}
160160
onClick={onAddClick(schema)}

packages/antd/src/templates/WrapIfAdditionalTemplate/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default function WrapIfAdditionalTemplate<
109109
</Col>
110110
<Col flex='192px'>
111111
<RemoveButton
112-
id={buttonId<T>(id, 'remove')}
112+
id={buttonId(id, 'remove')}
113113
className='rjsf-object-property-remove'
114114
disabled={disabled || readonly}
115115
onClick={onDropPropertyClick(label)}

packages/antd/src/widgets/AltDateWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default function AltDateWidget<
107107
value={elemProps.value}
108108
registry={registry}
109109
label=''
110-
aria-describedby={ariaDescribedByIds<T>(id)}
110+
aria-describedby={ariaDescribedByIds(id)}
111111
/>
112112
);
113113

packages/antd/src/widgets/CheckboxWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default function CheckboxWidget<
4444
name={id}
4545
onChange={!readonly ? handleChange : undefined}
4646
{...extraProps}
47-
aria-describedby={ariaDescribedByIds<T>(id)}
47+
aria-describedby={ariaDescribedByIds(id)}
4848
>
4949
{labelValue(label, hideLabel, '')}
5050
</Checkbox>

packages/antd/src/widgets/CheckboxesWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function CheckboxesWidget<
5252
onChange={!readonly ? handleChange : undefined}
5353
value={selectedIndexes}
5454
{...extraProps}
55-
aria-describedby={ariaDescribedByIds<T>(id)}
55+
aria-describedby={ariaDescribedByIds(id)}
5656
>
5757
{Array.isArray(enumOptions) &&
5858
enumOptions.map((option, i) => (

packages/antd/src/widgets/DateTimeWidget/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function DateTimeWidget<
4848
showTime
4949
style={DATE_PICKER_STYLE}
5050
value={value && dayjs(value)}
51-
aria-describedby={ariaDescribedByIds<T>(id)}
51+
aria-describedby={ariaDescribedByIds(id)}
5252
/>
5353
);
5454
}

0 commit comments

Comments
 (0)