@rjsf/core 6.0.0-beta.9 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/core.umd.js +2042 -1987
- package/dist/index.cjs +4909 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +2509 -2389
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +137 -34
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +318 -173
- package/lib/components/fields/ArrayField.d.ts +2 -187
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +526 -492
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +8 -3
- package/lib/components/fields/FallbackField.d.ts +7 -0
- package/lib/components/fields/FallbackField.d.ts.map +1 -0
- package/lib/components/fields/FallbackField.js +72 -0
- package/lib/components/fields/LayoutGridField.d.ts +109 -186
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +426 -426
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.js +3 -3
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +6 -6
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +16 -10
- package/lib/components/fields/NullField.js +3 -3
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +3 -3
- package/lib/components/fields/ObjectField.d.ts +2 -68
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +163 -163
- package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
- package/lib/components/fields/OptionalDataControlsField.js +43 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +52 -30
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +8 -3
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +4 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +3 -8
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +3 -3
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +4 -5
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
- package/lib/components/templates/BaseInputTemplate.js +2 -2
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js +2 -2
- package/lib/components/templates/FallbackFieldTemplate.d.ts +7 -0
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/FallbackFieldTemplate.js +12 -0
- package/lib/components/templates/FieldErrorTemplate.js +2 -2
- package/lib/components/templates/FieldHelpTemplate.js +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +3 -2
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
- package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/TitleField.js +2 -2
- package/lib/components/templates/UnsupportedField.js +3 -3
- package/lib/components/templates/WrapIfAdditionalTemplate.js +2 -2
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +6 -0
- package/lib/components/widgets/AltDateWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +5 -46
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxWidget.js +2 -2
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +4 -4
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.js +7 -87
- package/lib/components/widgets/HiddenWidget.d.ts +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/HiddenWidget.js +2 -2
- package/lib/components/widgets/RadioWidget.d.ts +1 -1
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +2 -2
- package/lib/components/widgets/RatingWidget.d.ts +1 -1
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.js +2 -2
- package/lib/components/widgets/SelectWidget.d.ts +1 -1
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +2 -2
- package/lib/components/widgets/TextareaWidget.d.ts +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +2 -2
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +6 -1
- package/lib/getTestRegistry.d.ts +5 -0
- package/lib/getTestRegistry.d.ts.map +1 -0
- package/lib/getTestRegistry.js +23 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -20
- package/src/components/Form.tsx +468 -206
- package/src/components/fields/ArrayField.tsx +871 -723
- package/src/components/fields/BooleanField.tsx +14 -5
- package/src/components/fields/FallbackField.tsx +157 -0
- package/src/components/fields/LayoutGridField.tsx +626 -603
- package/src/components/fields/LayoutHeaderField.tsx +3 -3
- package/src/components/fields/LayoutMultiSchemaField.tsx +9 -10
- package/src/components/fields/MultiSchemaField.tsx +57 -36
- package/src/components/fields/NullField.tsx +3 -3
- package/src/components/fields/NumberField.tsx +11 -3
- package/src/components/fields/ObjectField.tsx +308 -239
- package/src/components/fields/OptionalDataControlsField.tsx +84 -0
- package/src/components/fields/SchemaField.tsx +75 -94
- package/src/components/fields/StringField.tsx +14 -5
- package/src/components/fields/index.ts +4 -0
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +16 -21
- package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldTemplate.tsx +11 -18
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
- package/src/components/templates/BaseInputTemplate.tsx +5 -5
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
- package/src/components/templates/FallbackFieldTemplate.tsx +28 -0
- package/src/components/templates/FieldErrorTemplate.tsx +2 -2
- package/src/components/templates/FieldHelpTemplate.tsx +2 -2
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +12 -7
- package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
- package/src/components/templates/TitleField.tsx +6 -1
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +5 -5
- package/src/components/templates/index.ts +6 -0
- package/src/components/widgets/AltDateWidget.tsx +8 -126
- package/src/components/widgets/CheckboxWidget.tsx +4 -3
- package/src/components/widgets/CheckboxesWidget.tsx +5 -4
- package/src/components/widgets/FileWidget.tsx +11 -102
- package/src/components/widgets/HiddenWidget.tsx +2 -1
- package/src/components/widgets/RadioWidget.tsx +3 -2
- package/src/components/widgets/RatingWidget.tsx +2 -1
- package/src/components/widgets/SelectWidget.tsx +3 -2
- package/src/components/widgets/TextareaWidget.tsx +3 -2
- package/src/getDefaultRegistry.ts +14 -1
- package/src/getTestRegistry.tsx +38 -0
- package/src/index.ts +2 -1
- package/dist/index.js +0 -4834
- package/dist/index.js.map +0 -7
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
TemplatesType,
|
|
10
10
|
} from '@rjsf/utils';
|
|
11
11
|
|
|
12
|
-
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `
|
|
12
|
+
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
|
|
13
13
|
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
14
14
|
* - If there is a title in the `uiSchema`, it is displayed
|
|
15
15
|
* - Else, if there is an explicit `title` passed in the props, it is displayed
|
|
@@ -23,7 +23,7 @@ export default function LayoutHeaderField<
|
|
|
23
23
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
24
24
|
F extends FormContextType = any,
|
|
25
25
|
>(props: FieldProps<T, S, F>) {
|
|
26
|
-
const {
|
|
26
|
+
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
27
27
|
const options = getUiOptions<T, S, F>(uiSchema, registry.globalUiOptions);
|
|
28
28
|
const { title: uiTitle } = options;
|
|
29
29
|
const { title: schemaTitle } = schema;
|
|
@@ -38,7 +38,7 @@ export default function LayoutHeaderField<
|
|
|
38
38
|
);
|
|
39
39
|
return (
|
|
40
40
|
<TitleFieldTemplate
|
|
41
|
-
id={titleId
|
|
41
|
+
id={titleId(fieldPathId)}
|
|
42
42
|
title={fieldTitle}
|
|
43
43
|
required={required}
|
|
44
44
|
schema={schema}
|
|
@@ -96,7 +96,7 @@ export default function LayoutMultiSchemaField<
|
|
|
96
96
|
baseType,
|
|
97
97
|
disabled = false,
|
|
98
98
|
formData,
|
|
99
|
-
|
|
99
|
+
fieldPathId,
|
|
100
100
|
onBlur,
|
|
101
101
|
onChange,
|
|
102
102
|
options,
|
|
@@ -104,7 +104,6 @@ export default function LayoutMultiSchemaField<
|
|
|
104
104
|
registry,
|
|
105
105
|
uiSchema,
|
|
106
106
|
schema,
|
|
107
|
-
formContext,
|
|
108
107
|
autofocus,
|
|
109
108
|
readonly,
|
|
110
109
|
required,
|
|
@@ -113,7 +112,7 @@ export default function LayoutMultiSchemaField<
|
|
|
113
112
|
} = props;
|
|
114
113
|
const { widgets, schemaUtils, globalUiOptions } = registry;
|
|
115
114
|
const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData)!);
|
|
116
|
-
const id = get(
|
|
115
|
+
const id = get(fieldPathId, ID_KEY);
|
|
117
116
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
118
117
|
const FieldErrorTemplate = getTemplate<'FieldErrorTemplate', T, S, F>('FieldErrorTemplate', registry, options);
|
|
119
118
|
const FieldTemplate = getTemplate<'FieldTemplate', T, S, F>('FieldTemplate', registry, options);
|
|
@@ -171,16 +170,16 @@ export default function LayoutMultiSchemaField<
|
|
|
171
170
|
if (newFormData) {
|
|
172
171
|
set(newFormData, selectorField, opt);
|
|
173
172
|
}
|
|
174
|
-
|
|
173
|
+
// Pass the component name in the path
|
|
174
|
+
onChange(newFormData, fieldPathId.path, undefined, id);
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
// filtering the options based on the type of widget because `selectField` does not recognize the `convertOther` prop
|
|
178
178
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
179
179
|
const errors =
|
|
180
180
|
!hideFieldError && rawErrors.length > 0 ? (
|
|
181
|
-
<FieldErrorTemplate
|
|
181
|
+
<FieldErrorTemplate fieldPathId={fieldPathId} schema={schema} errors={rawErrors} registry={registry} />
|
|
182
182
|
) : undefined;
|
|
183
|
-
const ignored = (value: string) => noop;
|
|
184
183
|
|
|
185
184
|
return (
|
|
186
185
|
<FieldTemplate
|
|
@@ -189,15 +188,15 @@ export default function LayoutMultiSchemaField<
|
|
|
189
188
|
label={(title || schema.title) ?? ''}
|
|
190
189
|
disabled={disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions))}
|
|
191
190
|
uiSchema={uiSchema}
|
|
192
|
-
formContext={formContext}
|
|
193
191
|
required={required}
|
|
194
192
|
readonly={!!readonly}
|
|
195
193
|
registry={registry}
|
|
196
194
|
displayLabel={displayLabel}
|
|
197
195
|
errors={errors}
|
|
198
196
|
onChange={onChange}
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
onKeyRename={noop}
|
|
198
|
+
onKeyRenameBlur={noop}
|
|
199
|
+
onRemoveProperty={noop}
|
|
201
200
|
>
|
|
202
201
|
<Widget
|
|
203
202
|
id={id}
|
|
@@ -206,7 +205,6 @@ export default function LayoutMultiSchemaField<
|
|
|
206
205
|
label={(title || schema.title) ?? ''}
|
|
207
206
|
disabled={disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions))}
|
|
208
207
|
uiSchema={uiSchema}
|
|
209
|
-
formContext={formContext}
|
|
210
208
|
autofocus={autofocus}
|
|
211
209
|
readonly={readonly}
|
|
212
210
|
required={required}
|
|
@@ -222,6 +220,7 @@ export default function LayoutMultiSchemaField<
|
|
|
222
220
|
onFocus={onFocus}
|
|
223
221
|
value={selectedOption}
|
|
224
222
|
options={widgetOptions}
|
|
223
|
+
htmlName={fieldPathId.name}
|
|
225
224
|
/>
|
|
226
225
|
</FieldTemplate>
|
|
227
226
|
);
|
|
@@ -9,11 +9,14 @@ import {
|
|
|
9
9
|
FieldProps,
|
|
10
10
|
FormContextType,
|
|
11
11
|
getDiscriminatorFieldFromSchema,
|
|
12
|
+
getTemplate,
|
|
12
13
|
getUiOptions,
|
|
13
14
|
getWidget,
|
|
15
|
+
isFormDataAvailable,
|
|
14
16
|
mergeSchemas,
|
|
15
17
|
ONE_OF_KEY,
|
|
16
18
|
RJSFSchema,
|
|
19
|
+
shouldRenderOptionalField,
|
|
17
20
|
StrictRJSFSchema,
|
|
18
21
|
TranslatableString,
|
|
19
22
|
UiSchema,
|
|
@@ -64,7 +67,7 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
|
|
|
64
67
|
* @param prevState - The previous `AnyOfFieldState` for this template
|
|
65
68
|
*/
|
|
66
69
|
componentDidUpdate(prevProps: Readonly<FieldProps<T, S, F>>, prevState: Readonly<AnyOfFieldState>) {
|
|
67
|
-
const { formData, options,
|
|
70
|
+
const { formData, options, fieldPathId } = this.props;
|
|
68
71
|
const { selectedOption } = this.state;
|
|
69
72
|
let newState = this.state;
|
|
70
73
|
if (!deepEquals(prevProps.options, options)) {
|
|
@@ -75,7 +78,7 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
|
|
|
75
78
|
const retrievedOptions = options.map((opt: S) => schemaUtils.retrieveSchema(opt, formData));
|
|
76
79
|
newState = { selectedOption, retrievedOptions };
|
|
77
80
|
}
|
|
78
|
-
if (!deepEquals(formData, prevProps.formData) &&
|
|
81
|
+
if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
79
82
|
const { retrievedOptions } = newState;
|
|
80
83
|
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
81
84
|
|
|
@@ -113,7 +116,7 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
|
|
|
113
116
|
*/
|
|
114
117
|
onOptionChange = (option?: string) => {
|
|
115
118
|
const { selectedOption, retrievedOptions } = this.state;
|
|
116
|
-
const { formData, onChange, registry } = this.props;
|
|
119
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
117
120
|
const { schemaUtils } = registry;
|
|
118
121
|
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
119
122
|
if (intOption === selectedOption) {
|
|
@@ -130,13 +133,13 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
|
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
this.setState({ selectedOption: intOption }, () => {
|
|
133
|
-
onChange(newFormData, undefined, this.getFieldId());
|
|
136
|
+
onChange(newFormData, fieldPathId.path, undefined, this.getFieldId());
|
|
134
137
|
});
|
|
135
138
|
};
|
|
136
139
|
|
|
137
140
|
getFieldId() {
|
|
138
|
-
const {
|
|
139
|
-
return `${
|
|
141
|
+
const { fieldPathId, schema } = this.props;
|
|
142
|
+
return `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
@@ -146,10 +149,11 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
|
|
|
146
149
|
name,
|
|
147
150
|
disabled = false,
|
|
148
151
|
errorSchema = {},
|
|
149
|
-
|
|
152
|
+
formData,
|
|
150
153
|
onBlur,
|
|
151
154
|
onFocus,
|
|
152
155
|
readonly,
|
|
156
|
+
required = false,
|
|
153
157
|
registry,
|
|
154
158
|
schema,
|
|
155
159
|
uiSchema,
|
|
@@ -157,6 +161,14 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
|
|
|
157
161
|
|
|
158
162
|
const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
|
|
159
163
|
const { SchemaField: _SchemaField } = fields;
|
|
164
|
+
const MultiSchemaFieldTemplate = getTemplate<'MultiSchemaFieldTemplate', T, S, F>(
|
|
165
|
+
'MultiSchemaFieldTemplate',
|
|
166
|
+
registry,
|
|
167
|
+
globalUiOptions,
|
|
168
|
+
);
|
|
169
|
+
const isOptionalRender = shouldRenderOptionalField<T, S, F>(registry, schema, required, uiSchema);
|
|
170
|
+
const hasFormData = isFormDataAvailable<T>(formData);
|
|
171
|
+
|
|
160
172
|
const { selectedOption, retrievedOptions } = this.state;
|
|
161
173
|
const {
|
|
162
174
|
widget = 'select',
|
|
@@ -215,36 +227,45 @@ class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends For
|
|
|
215
227
|
};
|
|
216
228
|
});
|
|
217
229
|
|
|
230
|
+
const selector =
|
|
231
|
+
!isOptionalRender || hasFormData ? (
|
|
232
|
+
<Widget
|
|
233
|
+
id={this.getFieldId()}
|
|
234
|
+
name={`${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`}
|
|
235
|
+
schema={{ type: 'number', default: 0 } as S}
|
|
236
|
+
onChange={this.onOptionChange}
|
|
237
|
+
onBlur={onBlur}
|
|
238
|
+
onFocus={onFocus}
|
|
239
|
+
disabled={disabled || isEmpty(enumOptions)}
|
|
240
|
+
multiple={false}
|
|
241
|
+
rawErrors={rawErrors}
|
|
242
|
+
errorSchema={fieldErrorSchema}
|
|
243
|
+
value={selectedOption >= 0 ? selectedOption : undefined}
|
|
244
|
+
options={{ enumOptions, ...uiOptions }}
|
|
245
|
+
registry={registry}
|
|
246
|
+
placeholder={placeholder}
|
|
247
|
+
autocomplete={autocomplete}
|
|
248
|
+
autofocus={autofocus}
|
|
249
|
+
label={title ?? name}
|
|
250
|
+
hideLabel={!displayLabel}
|
|
251
|
+
readonly={readonly}
|
|
252
|
+
/>
|
|
253
|
+
) : undefined;
|
|
254
|
+
|
|
255
|
+
const optionsSchemaField =
|
|
256
|
+
(optionSchema && optionSchema.type !== 'null' && (
|
|
257
|
+
<_SchemaField {...this.props} schema={optionSchema} uiSchema={optionUiSchema} />
|
|
258
|
+
)) ||
|
|
259
|
+
null;
|
|
260
|
+
|
|
218
261
|
return (
|
|
219
|
-
<
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
onBlur={onBlur}
|
|
227
|
-
onFocus={onFocus}
|
|
228
|
-
disabled={disabled || isEmpty(enumOptions)}
|
|
229
|
-
multiple={false}
|
|
230
|
-
rawErrors={rawErrors}
|
|
231
|
-
errorSchema={fieldErrorSchema}
|
|
232
|
-
value={selectedOption >= 0 ? selectedOption : undefined}
|
|
233
|
-
options={{ enumOptions, ...uiOptions }}
|
|
234
|
-
registry={registry}
|
|
235
|
-
formContext={formContext}
|
|
236
|
-
placeholder={placeholder}
|
|
237
|
-
autocomplete={autocomplete}
|
|
238
|
-
autofocus={autofocus}
|
|
239
|
-
label={title ?? name}
|
|
240
|
-
hideLabel={!displayLabel}
|
|
241
|
-
readonly={readonly}
|
|
242
|
-
/>
|
|
243
|
-
</div>
|
|
244
|
-
{optionSchema && optionSchema.type !== 'null' && (
|
|
245
|
-
<_SchemaField {...this.props} schema={optionSchema} uiSchema={optionUiSchema} />
|
|
246
|
-
)}
|
|
247
|
-
</div>
|
|
262
|
+
<MultiSchemaFieldTemplate
|
|
263
|
+
schema={schema}
|
|
264
|
+
registry={registry}
|
|
265
|
+
uiSchema={uiSchema}
|
|
266
|
+
selector={selector}
|
|
267
|
+
optionSchemaField={optionsSchemaField}
|
|
268
|
+
/>
|
|
248
269
|
);
|
|
249
270
|
}
|
|
250
271
|
}
|
|
@@ -9,12 +9,12 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
9
9
|
function NullField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
10
10
|
props: FieldProps<T, S, F>,
|
|
11
11
|
) {
|
|
12
|
-
const { formData, onChange } = props;
|
|
12
|
+
const { formData, onChange, fieldPathId } = props;
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (formData === undefined) {
|
|
15
|
-
onChange(null as unknown as T);
|
|
15
|
+
onChange(null as unknown as T, fieldPathId.path);
|
|
16
16
|
}
|
|
17
|
-
}, [formData, onChange]);
|
|
17
|
+
}, [fieldPathId, formData, onChange]);
|
|
18
18
|
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { useState, useCallback } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
asNumber,
|
|
4
|
+
ErrorSchema,
|
|
5
|
+
FieldPathList,
|
|
6
|
+
FieldProps,
|
|
7
|
+
FormContextType,
|
|
8
|
+
RJSFSchema,
|
|
9
|
+
StrictRJSFSchema,
|
|
10
|
+
} from '@rjsf/utils';
|
|
3
11
|
|
|
4
12
|
// Matches a string that ends in a . character, optionally followed by a sequence of
|
|
5
13
|
// digits followed by any number of 0 characters up until the end of the line.
|
|
@@ -44,7 +52,7 @@ function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
44
52
|
* @param value - The current value for the change occurring
|
|
45
53
|
*/
|
|
46
54
|
const handleChange = useCallback(
|
|
47
|
-
(value: FieldProps<T, S, F>['value'], errorSchema?: ErrorSchema<T>, id?: string) => {
|
|
55
|
+
(value: FieldProps<T, S, F>['value'], path: FieldPathList, errorSchema?: ErrorSchema<T>, id?: string) => {
|
|
48
56
|
// Cache the original value in component state
|
|
49
57
|
setLastValue(value);
|
|
50
58
|
|
|
@@ -62,7 +70,7 @@ function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
62
70
|
? asNumber(value.replace(trailingCharMatcher, ''))
|
|
63
71
|
: asNumber(value);
|
|
64
72
|
|
|
65
|
-
onChange(processed as unknown as T, errorSchema, id);
|
|
73
|
+
onChange(processed as unknown as T, path, errorSchema, id);
|
|
66
74
|
},
|
|
67
75
|
[onChange],
|
|
68
76
|
);
|