Skip to content

Commit db40580

Browse files
Chore: cleaned up unnecessary formContext and IdSchema (rjsf-team#4805)
1 parent 277f397 commit db40580

File tree

29 files changed

+71
-79
lines changed

29 files changed

+71
-79
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,38 @@ should change the heading of the (upcoming) version to include a major version b
1717
-->
1818
# 6.0.0-beta.22
1919

20+
## @rjsf/antd
21+
22+
- Updated most of the widgets to get `formContext` from the `registry` instead of the `props` since it will no longer be passed
23+
2024
## @rjsf/core
2125

2226
- Updated `MultiSchemaField` and `SchemaField` to properly display `anyOf`/`oneOf` optional data fields by hiding the label and selector control when it is an optional field AND there is no form data
27+
- Updated `ArrayField`, `BooleanField`, `LayoutMultiSchemaField`, `MultiSchemaField`, `ObjectField`, `SchemaField`, `StringField` and `BaseInputTemplate` to remove `formContext` from the props
28+
29+
## @rjsf/daisyui
30+
31+
- Updated the test mocks to remove `formContext` for the widget mock
32+
33+
## @rjsf/mui
34+
35+
- Updated `BaseInputTemplate` and `SelectWidget` to remove `formContext` from the props
36+
37+
## @rjsf/primereact
38+
39+
- Updated `SelectWidget` to remove `formContext` from the props
40+
41+
## @rjsf/shadcn
42+
43+
- Updated the test mocks to remove `formContext` for the widget mock and added `globalFormOptions` in the registry mock
2344

2445
## Dev / docs / playground
2546
- Updated the `formTests.tsx` snapshots to add an `anyOf` of all arrays with different item types and removed the disabling of the optional data controls feature for the optional object with oneOfs
2647
- Updated the snapshots in all of the themes accordingly
2748
- Updated the playground to make the same changes as `formTests.tsx` in the `optionalDataControls.ts` sample, moving the `experimental_defaultFormStateBehavior` inside of a `liveSettings` block
2849
- Updated the `Sample` and `LiveSettings` types to support the `liveSettings` inside of a sample
2950
- Updated the `Playground`'s `onSampleSelected` callback to merge any `liveSettings` in the sample on top of those already used in the playground
51+
- Updated the `customFieldAnyOf` sample to switch `IdSchema` to `FieldPathId`
3052

3153
# 6.0.0-beta.21
3254

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function BaseInputTemplate<
2828
>(props: BaseInputTemplateProps<T, S, F>) {
2929
const {
3030
disabled,
31-
formContext,
31+
registry,
3232
id,
3333
onBlur,
3434
onChange,
@@ -41,6 +41,7 @@ export default function BaseInputTemplate<
4141
value,
4242
type,
4343
} = props;
44+
const { formContext } = registry;
4445
const inputProps = getInputProps<T, S, F>(schema, type, options, false);
4546
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
4647

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,8 @@ export default function AltDateWidget<
3434
S extends StrictRJSFSchema = RJSFSchema,
3535
F extends FormContextType = any,
3636
>(props: WidgetProps<T, S, F>) {
37-
const {
38-
autofocus,
39-
disabled,
40-
formContext,
41-
id,
42-
onBlur,
43-
onChange,
44-
onFocus,
45-
options,
46-
readonly,
47-
registry,
48-
showTime,
49-
value,
50-
} = props;
51-
const { translateString, widgets } = registry;
37+
const { autofocus, disabled, id, onBlur, onChange, onFocus, options, readonly, registry, showTime, value } = props;
38+
const { formContext, translateString, widgets } = registry;
5239
const { SelectWidget } = widgets;
5340
const { rowGutter = 24 } = formContext as GenericObjectType;
5441

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export default function CheckboxWidget<
2020
S extends StrictRJSFSchema = RJSFSchema,
2121
F extends FormContextType = any,
2222
>(props: WidgetProps<T, S, F>) {
23-
const { autofocus, disabled, formContext, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
23+
const { autofocus, disabled, registry, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
24+
const { formContext } = registry;
2425
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
2526

2627
const handleChange: NonNullable<CheckboxProps['onChange']> = ({ target }) => onChange(target.checked);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export default function CheckboxesWidget<
2121
T = any,
2222
S extends StrictRJSFSchema = RJSFSchema,
2323
F extends FormContextType = any,
24-
>({ autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, readonly, value }: WidgetProps<T, S, F>) {
24+
>({ autofocus, disabled, registry, id, onBlur, onChange, onFocus, options, readonly, value }: WidgetProps<T, S, F>) {
25+
const { formContext } = registry;
2526
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
2627

2728
const { enumOptions, enumDisabled, inline, emptyValue } = options;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export default function DateTimeWidget<
2424
S extends StrictRJSFSchema = RJSFSchema,
2525
F extends FormContextType = any,
2626
>(props: WidgetProps<T, S, F>) {
27-
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
27+
const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
28+
const { formContext } = registry;
2829
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
2930

3031
const handleChange = (nextValue: any) => onChange(nextValue && nextValue.toISOString());

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const DATE_PICKER_STYLE = {
2222
export default function DateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
2323
props: WidgetProps<T, S, F>,
2424
) {
25-
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
25+
const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
26+
const { formContext } = registry;
2627
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
2728

2829
const handleChange = (nextValue: any) => onChange(nextValue && nextValue.format('YYYY-MM-DD'));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export default function PasswordWidget<
1818
S extends StrictRJSFSchema = RJSFSchema,
1919
F extends FormContextType = any,
2020
>(props: WidgetProps<T, S, F>) {
21-
const { disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
21+
const { disabled, registry, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
22+
const { formContext } = registry;
2223
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
2324

2425
const emptyValue = options.emptyValue || '';

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
2121
autofocus,
2222
disabled,
23-
formContext,
23+
registry,
2424
id,
2525
onBlur,
2626
onChange,
@@ -29,6 +29,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
2929
readonly,
3030
value,
3131
}: WidgetProps<T, S, F>) {
32+
const { formContext } = registry;
3233
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
3334

3435
const { enumOptions, enumDisabled, emptyValue } = options;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
2020
const {
2121
autofocus,
2222
disabled,
23-
formContext,
23+
registry,
2424
id,
2525
onBlur,
2626
onChange,
@@ -31,6 +31,7 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
3131
schema,
3232
value,
3333
} = props;
34+
const { formContext } = registry;
3435
const { readonlyAsDisabled = true } = formContext as GenericObjectType;
3536

3637
const { min, max, step } = rangeSpec(schema);

0 commit comments

Comments
 (0)