Skip to content

Commit 374d440

Browse files
Chore remove unnecessary formContext from all interfaces but Registry (#4743)
1 parent 64342e1 commit 374d440

File tree

29 files changed

+96
-78
lines changed

29 files changed

+96
-78
lines changed

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@ 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.16
19+
20+
## @rjsf/antd
21+
22+
- Updated the `ArrayFieldTemplate`, `FieldTemplate` and `ObjectFieldTemplate` to get `formContext` from the `registry`
23+
24+
## @rjsf/core
25+
26+
- Updated `ArrayField`, `Form`, `LayoutMultiSchemaField` and `SchemaField` to stop passing `formContext`
27+
28+
## @rjsf/daisyui
29+
30+
- Updated `FieldTemplate` to remove `formContext` as it is never used
31+
32+
## @rjsf/semantic-ui
33+
34+
- Updated the `ArrayFieldTemplate`, `BaseInputTemplate`, `CheckboxWidget`, `FieldTemplate`, `RadioWidget`, `RangeSelect`, `SelectWidget`, `TextareaWidget` and `ObjectFieldTemplate` to get `formContext` from the `registry`
35+
36+
## @rjsf/utils
37+
38+
- BREAKING CHANGE: Removed `formContext` from the following interfaces because it is available on `registry`:
39+
- `ErrorListProps`, `FieldProps`, `FieldTemplateProps`, `ArrayFieldTemplateProps` and `WidgetProps`
40+
41+
## Dev / docs / playground
42+
43+
- Updated the documentation to remove `formContext` from the interface documentation, adding a BREAKING CHANGE notification in the `v6.x upgrade guide`
44+
1845
# 6.0.0-beta.15
1946

2047
## @rjsf/chakra-ui

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export default function ArrayFieldTemplate<
3030
canAdd,
3131
className,
3232
disabled,
33-
formContext,
3433
idSchema,
3534
items,
3635
onAddClick,
@@ -57,6 +56,7 @@ export default function ArrayFieldTemplate<
5756
registry,
5857
uiOptions,
5958
);
59+
const { formContext } = registry;
6060
// Button templates are not overridden in the uiSchema
6161
const {
6262
ButtonTemplates: { AddButton },

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export default function FieldTemplate<
3030
disabled,
3131
displayLabel,
3232
errors,
33-
formContext,
3433
help,
3534
hidden,
3635
id,
@@ -46,6 +45,7 @@ export default function FieldTemplate<
4645
schema,
4746
uiSchema,
4847
} = props;
48+
const { formContext } = registry;
4949
const {
5050
colon,
5151
labelCol = VERTICAL_LABEL_COL,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export default function ObjectFieldTemplate<
3838
const {
3939
description,
4040
disabled,
41-
formContext,
4241
formData,
4342
idSchema,
4443
onAddClick,
@@ -57,6 +56,7 @@ export default function ObjectFieldTemplate<
5756
registry,
5857
uiOptions,
5958
);
59+
const { formContext } = registry;
6060
// Button templates are not overridden in the uiSchema
6161
const {
6262
ButtonTemplates: { AddButton },

packages/core/src/components/Form.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@ export default class Form<
597597
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
598598
renderErrors(registry: Registry<T, S, F>) {
599599
const { errors, errorSchema, schema, uiSchema } = this.state;
600-
const { formContext } = this.props;
601600
const options = getUiOptions<T, S, F>(uiSchema);
602601
const ErrorListTemplate = getTemplate<'ErrorListTemplate', T, S, F>('ErrorListTemplate', registry, options);
603602

@@ -608,7 +607,6 @@ export default class Form<
608607
errorSchema={errorSchema || {}}
609608
schema={schema}
610609
uiSchema={uiSchema}
611-
formContext={formContext}
612610
registry={registry}
613611
/>
614612
);
@@ -1117,7 +1115,6 @@ export default class Form<
11171115
noHtml5Validate = false,
11181116
disabled,
11191117
readonly,
1120-
formContext,
11211118
showErrorList = 'top',
11221119
_internalFormWrapper,
11231120
} = this.props;
@@ -1163,7 +1160,6 @@ export default class Form<
11631160
idSchema={idSchema}
11641161
idPrefix={idPrefix}
11651162
idSeparator={idSeparator}
1166-
formContext={formContext}
11671163
formData={formData}
11681164
onChange={this.onChange}
11691165
onBlur={this.onBlur}

packages/core/src/components/fields/ArrayField.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
566566
required,
567567
schema,
568568
title: fieldTitle,
569-
formContext,
570569
formData,
571570
rawErrors,
572571
registry,
@@ -832,7 +831,6 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
832831
schema,
833832
uiSchema,
834833
title: fieldTitle,
835-
formContext,
836834
errorSchema,
837835
rawErrors,
838836
};

packages/core/src/components/fields/LayoutMultiSchemaField.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ export default function LayoutMultiSchemaField<
190190
label={(title || schema.title) ?? ''}
191191
disabled={disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions))}
192192
uiSchema={uiSchema}
193-
formContext={formContext}
194193
required={required}
195194
readonly={!!readonly}
196195
registry={registry}

packages/core/src/components/fields/SchemaField.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
263263
displayLabel,
264264
classNames: classNames.join(' ').trim(),
265265
style: uiOptions.style,
266-
formContext,
267266
formData,
268267
schema,
269268
uiSchema,

packages/core/test/ArrayField.test.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,7 +2988,10 @@ describe('ArrayField', () => {
29882988
root_1: 'root_1-id',
29892989
};
29902990
function CustomSchemaField(props) {
2991-
const { formContext, idSchema } = props;
2991+
const {
2992+
registry: { formContext },
2993+
idSchema,
2994+
} = props;
29922995
return (
29932996
<>
29942997
<code id={formContext[idSchema.$id]}>Ha</code>
@@ -3015,7 +3018,10 @@ describe('ArrayField', () => {
30153018
root_1: 'root_1-id',
30163019
};
30173020
function CustomSchemaField(props) {
3018-
const { formContext, idSchema } = props;
3021+
const {
3022+
registry: { formContext },
3023+
idSchema,
3024+
} = props;
30193025
return (
30203026
<>
30213027
<code id={formContext[idSchema.$id]}>Ha</code>

packages/core/test/FormContext.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('FormContext', () => {
5858
});
5959

6060
it('should be passed to TemplateField', () => {
61-
function CustomTemplateField({ formContext }) {
61+
function CustomTemplateField({ registry: { formContext } }) {
6262
return <div id={formContext.foo} />;
6363
}
6464

@@ -79,7 +79,7 @@ describe('FormContext', () => {
7979
});
8080

8181
it('should be passed to ArrayTemplateField', () => {
82-
function CustomArrayTemplateField({ formContext }) {
82+
function CustomArrayTemplateField({ registry: { formContext } }) {
8383
return <div id={formContext.foo} />;
8484
}
8585

0 commit comments

Comments
 (0)