Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,38 @@ should change the heading of the (upcoming) version to include a major version b
-->
# 6.0.0-beta.22

## @rjsf/antd

- Updated most of the widgets to get `formContext` from the `registry` instead of the `props` since it will no longer be passed

## @rjsf/core

- 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
- Updated `ArrayField`, `BooleanField`, `LayoutMultiSchemaField`, `MultiSchemaField`, `ObjectField`, `SchemaField`, `StringField` and `BaseInputTemplate` to remove `formContext` from the props

## @rjsf/daisyui

- Updated the test mocks to remove `formContext` for the widget mock

## @rjsf/mui

- Updated `BaseInputTemplate` and `SelectWidget` to remove `formContext` from the props

## @rjsf/primereact

- Updated `SelectWidget` to remove `formContext` from the props

## @rjsf/shadcn

- Updated the test mocks to remove `formContext` for the widget mock and added `globalFormOptions` in the registry mock

## Dev / docs / playground
- 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
- Updated the snapshots in all of the themes accordingly
- 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
- Updated the `Sample` and `LiveSettings` types to support the `liveSettings` inside of a sample
- Updated the `Playground`'s `onSampleSelected` callback to merge any `liveSettings` in the sample on top of those already used in the playground
- Updated the `customFieldAnyOf` sample to switch `IdSchema` to `FieldPathId`

# 6.0.0-beta.21

Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/templates/BaseInputTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function BaseInputTemplate<
>(props: BaseInputTemplateProps<T, S, F>) {
const {
disabled,
formContext,
registry,
id,
onBlur,
onChange,
Expand All @@ -41,6 +41,7 @@ export default function BaseInputTemplate<
value,
type,
} = props;
const { formContext } = registry;
const inputProps = getInputProps<T, S, F>(schema, type, options, false);
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

Expand Down
17 changes: 2 additions & 15 deletions packages/antd/src/widgets/AltDateWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,8 @@ export default function AltDateWidget<
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>(props: WidgetProps<T, S, F>) {
const {
autofocus,
disabled,
formContext,
id,
onBlur,
onChange,
onFocus,
options,
readonly,
registry,
showTime,
value,
} = props;
const { translateString, widgets } = registry;
const { autofocus, disabled, id, onBlur, onChange, onFocus, options, readonly, registry, showTime, value } = props;
const { formContext, translateString, widgets } = registry;
const { SelectWidget } = widgets;
const { rowGutter = 24 } = formContext as GenericObjectType;

Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/CheckboxWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default function CheckboxWidget<
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>(props: WidgetProps<T, S, F>) {
const { autofocus, disabled, formContext, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
const { autofocus, disabled, registry, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const handleChange: NonNullable<CheckboxProps['onChange']> = ({ target }) => onChange(target.checked);
Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/CheckboxesWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default function CheckboxesWidget<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>({ autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, readonly, value }: WidgetProps<T, S, F>) {
>({ autofocus, disabled, registry, id, onBlur, onChange, onFocus, options, readonly, value }: WidgetProps<T, S, F>) {
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const { enumOptions, enumDisabled, inline, emptyValue } = options;
Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/DateTimeWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default function DateTimeWidget<
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>(props: WidgetProps<T, S, F>) {
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const handleChange = (nextValue: any) => onChange(nextValue && nextValue.toISOString());
Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/DateWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const DATE_PICKER_STYLE = {
export default function DateWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
props: WidgetProps<T, S, F>,
) {
const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const handleChange = (nextValue: any) => onChange(nextValue && nextValue.format('YYYY-MM-DD'));
Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/PasswordWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default function PasswordWidget<
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>(props: WidgetProps<T, S, F>) {
const { disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
const { disabled, registry, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const emptyValue = options.emptyValue || '';
Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/RadioWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
autofocus,
disabled,
formContext,
registry,
id,
onBlur,
onChange,
Expand All @@ -29,6 +29,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
readonly,
value,
}: WidgetProps<T, S, F>) {
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const { enumOptions, enumDisabled, emptyValue } = options;
Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/RangeWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
const {
autofocus,
disabled,
formContext,
registry,
id,
onBlur,
onChange,
Expand All @@ -31,6 +31,7 @@ export default function RangeWidget<T = any, S extends StrictRJSFSchema = RJSFSc
schema,
value,
} = props;
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const { min, max, step } = rangeSpec(schema);
Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/widgets/SelectWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function SelectWidget<
>({
autofocus,
disabled,
formContext = {} as F,
registry,
id,
multiple,
onBlur,
Expand All @@ -41,6 +41,7 @@ export default function SelectWidget<
value,
schema,
}: WidgetProps<T, S, F>) {
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const { enumOptions, enumDisabled, emptyValue } = options;
Expand Down
14 changes: 2 additions & 12 deletions packages/antd/src/widgets/TextareaWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,8 @@ export default function TextareaWidget<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any,
>({
disabled,
formContext,
id,
onBlur,
onChange,
onFocus,
options,
placeholder,
readonly,
value,
}: WidgetProps<T, S, F>) {
>({ disabled, registry, id, onBlur, onChange, onFocus, options, placeholder, readonly, value }: WidgetProps<T, S, F>) {
const { formContext } = registry;
const { readonlyAsDisabled = true } = formContext as GenericObjectType;

const handleChange = ({ target }: ChangeEvent<HTMLTextAreaElement>) =>
Expand Down
12 changes: 4 additions & 8 deletions packages/core/src/components/fields/ArrayField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
rawErrors,
name,
} = this.props;
const { widgets, formContext, globalUiOptions, schemaUtils } = registry;
const { widgets, globalUiOptions, schemaUtils } = registry;
const { widget, title: uiTitle, ...options } = getUiOptions<T[], S, F>(uiSchema, globalUiOptions);
const Widget = getWidget<T[], S, F>(schema, widget, widgets);
const label = uiTitle ?? schema.title ?? name;
Expand All @@ -622,7 +622,6 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
label={label}
hideLabel={!displayLabel}
placeholder={placeholder}
formContext={formContext}
autofocus={autofocus}
rawErrors={rawErrors}
/>
Expand All @@ -648,7 +647,7 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
rawErrors,
name,
} = this.props;
const { widgets, schemaUtils, formContext, globalUiOptions } = registry;
const { widgets, schemaUtils, globalUiOptions } = registry;
const itemsSchema = schemaUtils.retrieveSchema(schema.items as S, items);
const enumOptions = optionsList<T[], S, F>(itemsSchema, uiSchema);
const { widget = 'select', title: uiTitle, ...options } = getUiOptions<T[], S, F>(uiSchema, globalUiOptions);
Expand All @@ -674,7 +673,6 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
label={label}
hideLabel={!displayLabel}
placeholder={placeholder}
formContext={formContext}
autofocus={autofocus}
rawErrors={rawErrors}
/>
Expand All @@ -699,7 +697,7 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
formData: items = [],
rawErrors,
} = this.props;
const { widgets, formContext, globalUiOptions, schemaUtils } = registry;
const { widgets, globalUiOptions, schemaUtils } = registry;
const { widget = 'files', title: uiTitle, ...options } = getUiOptions<T[], S, F>(uiSchema, globalUiOptions);
const Widget = getWidget<T[], S, F>(schema, widget, widgets);
const label = uiTitle ?? schema.title ?? name;
Expand All @@ -720,7 +718,6 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
readonly={readonly}
required={required}
registry={registry}
formContext={formContext}
autofocus={autofocus}
rawErrors={rawErrors}
label={label}
Expand Down Expand Up @@ -889,7 +886,7 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
totalItems,
title,
} = props;
const { disabled, hideError, readonly, uiSchema, registry, formContext } = this.props;
const { disabled, hideError, readonly, uiSchema, registry } = this.props;
const {
fields: { ArraySchemaField, SchemaField },
globalUiOptions,
Expand All @@ -914,7 +911,6 @@ class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
schema={itemSchema}
uiSchema={itemUiSchema}
formData={itemData}
formContext={formContext}
errorSchema={itemErrorSchema}
fieldPathId={itemFieldPathId}
required={this.isItemRequired(itemSchema)}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/components/fields/BooleanField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
rawErrors,
} = props;
const { title: schemaTitle } = schema;
const { widgets, formContext, translateString, globalUiOptions } = registry;
const { widgets, translateString, globalUiOptions } = registry;
const {
widget = 'checkbox',
title: uiTitle,
Expand Down Expand Up @@ -114,7 +114,6 @@ function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
readonly={readonly}
hideError={hideError}
registry={registry}
formContext={formContext}
autofocus={autofocus}
rawErrors={rawErrors}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default function LayoutMultiSchemaField<
registry,
uiSchema,
schema,
formContext,
autofocus,
readonly,
required,
Expand Down Expand Up @@ -206,7 +205,6 @@ export default function LayoutMultiSchemaField<
label={(title || schema.title) ?? ''}
disabled={disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions))}
uiSchema={uiSchema}
formContext={formContext}
autofocus={autofocus}
readonly={readonly}
required={required}
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/components/fields/MultiSchemaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
name,
disabled = false,
errorSchema = {},
formContext,
formData,
onBlur,
onFocus,
Expand Down Expand Up @@ -244,7 +243,6 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
value={selectedOption >= 0 ? selectedOption : undefined}
options={{ enumOptions, ...uiOptions }}
registry={registry}
formContext={formContext}
placeholder={placeholder}
autocomplete={autocomplete}
autofocus={autofocus}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/fields/ObjectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
title,
} = this.props;

const { fields, formContext, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
const { fields, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
const { OptionalDataControlsField, SchemaField } = fields;
const schema: S = schemaUtils.retrieveSchema(rawSchema, formData, true);
const uiOptions = getUiOptions<T, S, F>(uiSchema, globalUiOptions);
Expand Down Expand Up @@ -297,7 +297,6 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
errorSchema={get(errorSchema, name)}
fieldPathId={innerFieldIdPathId}
formData={get(formData, name)}
formContext={formContext}
wasPropertyKeyModified={this.state.wasPropertyKeyModified}
onKeyChange={this.onKeyChange(name)}
onChange={this.onPropertyChange(name, addedByAdditionalProperties)}
Expand Down Expand Up @@ -325,7 +324,6 @@ class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends Fo
errorSchema,
schema,
formData,
formContext,
registry,
optionalDataControl,
className: renderOptionalField ? 'rjsf-optional-object-field' : undefined,
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/fields/SchemaField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
registry,
wasPropertyKeyModified = false,
} = props;
const { formContext, schemaUtils, globalUiOptions, fields } = registry;
const { schemaUtils, globalUiOptions, fields } = registry;
const { AnyOfField: _AnyOfField, OneOfField: _OneOfField } = fields;
const uiOptions = getUiOptions<T, S, F>(uiSchema, globalUiOptions);
const FieldTemplate = getTemplate<'FieldTemplate', T, S, F>('FieldTemplate', registry, uiOptions);
Expand Down Expand Up @@ -204,7 +204,6 @@ function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
hideError={hideError}
autofocus={autofocus}
errorSchema={fieldErrorSchema as ErrorSchema}
formContext={formContext}
rawErrors={__errors}
/>
);
Expand Down Expand Up @@ -305,7 +304,6 @@ function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
hideError={hideError}
errorSchema={errorSchema}
formData={formData}
formContext={formContext}
fieldPathId={fieldPathId}
onBlur={props.onBlur}
onChange={props.onChange}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/components/fields/StringField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function StringField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
hideError,
} = props;
const { title, format } = schema;
const { widgets, formContext, schemaUtils, globalUiOptions } = registry;
const { widgets, schemaUtils, globalUiOptions } = registry;
const enumOptions = schemaUtils.isSelect(schema) ? optionsList<T, S, F>(schema, uiSchema) : undefined;
let defaultWidget = enumOptions ? 'select' : 'text';
if (format && hasWidget<T, S, F>(schema, format, widgets)) {
Expand Down Expand Up @@ -70,7 +70,6 @@ function StringField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
required={required}
disabled={disabled}
readonly={readonly}
formContext={formContext}
autofocus={autofocus}
registry={registry}
placeholder={placeholder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default function BaseInputTemplate<
options,
schema,
uiSchema,
formContext,
registry,
rawErrors,
type,
Expand Down
Loading