@rjsf/core 6.7.1 → 6.10.0
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/dist/core.umd.js +199 -155
- package/dist/index.cjs +195 -193
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +225 -201
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts +3 -2
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +62 -45
- package/lib/components/Form.js.map +1 -0
- package/lib/components/RichDescription.js +1 -0
- package/lib/components/RichDescription.js.map +1 -0
- package/lib/components/RichHelp.js +1 -0
- package/lib/components/RichHelp.js.map +1 -0
- package/lib/components/SchemaExamples.js +1 -0
- package/lib/components/SchemaExamples.js.map +1 -0
- package/lib/components/constants.js +1 -0
- package/lib/components/constants.js.map +1 -0
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +16 -17
- package/lib/components/fields/ArrayField.js.map +1 -0
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -2
- package/lib/components/fields/BooleanField.js.map +1 -0
- package/lib/components/fields/CyclicSchemaField.js +1 -0
- package/lib/components/fields/CyclicSchemaField.js.map +1 -0
- package/lib/components/fields/FallbackField.js +1 -0
- package/lib/components/fields/FallbackField.js.map +1 -0
- package/lib/components/fields/LayoutGridField.d.ts +61 -1
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +50 -63
- package/lib/components/fields/LayoutGridField.js.map +1 -0
- package/lib/components/fields/LayoutHeaderField.js +1 -0
- package/lib/components/fields/LayoutHeaderField.js.map +1 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +14 -18
- package/lib/components/fields/LayoutMultiSchemaField.js.map +1 -0
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +6 -7
- package/lib/components/fields/MultiSchemaField.js.map +1 -0
- package/lib/components/fields/NullField.js +1 -0
- package/lib/components/fields/NullField.js.map +1 -0
- package/lib/components/fields/NumberField.js +1 -0
- package/lib/components/fields/NumberField.js.map +1 -0
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +20 -25
- package/lib/components/fields/ObjectField.js.map +1 -0
- package/lib/components/fields/OptionalDataControlsField.js +1 -0
- package/lib/components/fields/OptionalDataControlsField.js.map +1 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +5 -5
- package/lib/components/fields/SchemaField.js.map +1 -0
- package/lib/components/fields/StringField.js +1 -0
- package/lib/components/fields/StringField.js.map +1 -0
- package/lib/components/fields/index.js +15 -14
- package/lib/components/fields/index.js.map +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js.map +1 -0
- package/lib/components/templates/BaseInputTemplate.js +3 -2
- package/lib/components/templates/BaseInputTemplate.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js +2 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/index.js +4 -3
- package/lib/components/templates/ButtonTemplates/index.js.map +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js.map +1 -0
- package/lib/components/templates/DescriptionField.js +2 -1
- package/lib/components/templates/DescriptionField.js.map +1 -0
- package/lib/components/templates/ErrorList.js +1 -0
- package/lib/components/templates/ErrorList.js.map +1 -0
- package/lib/components/templates/FallbackFieldTemplate.js +1 -0
- package/lib/components/templates/FallbackFieldTemplate.js.map +1 -0
- package/lib/components/templates/FieldErrorTemplate.js +1 -0
- package/lib/components/templates/FieldErrorTemplate.js.map +1 -0
- package/lib/components/templates/FieldHelpTemplate.js +2 -1
- package/lib/components/templates/FieldHelpTemplate.js.map +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +2 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/components/templates/FieldTemplate/Label.js +1 -0
- package/lib/components/templates/FieldTemplate/Label.js.map +1 -0
- package/lib/components/templates/FieldTemplate/index.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/index.js +2 -1
- package/lib/components/templates/FieldTemplate/index.js.map +1 -0
- package/lib/components/templates/GridTemplate.js +1 -0
- package/lib/components/templates/GridTemplate.js.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js.map +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js.map +1 -0
- package/lib/components/templates/OptionalDataControlsTemplate.js +2 -1
- package/lib/components/templates/OptionalDataControlsTemplate.js.map +1 -0
- package/lib/components/templates/TitleField.js +1 -0
- package/lib/components/templates/TitleField.js.map +1 -0
- package/lib/components/templates/UnsupportedField.js +1 -0
- package/lib/components/templates/UnsupportedField.js.map +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js +2 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/components/templates/index.js +22 -21
- package/lib/components/templates/index.js.map +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js.map +1 -0
- package/lib/components/widgets/AltDateWidget.js +1 -0
- package/lib/components/widgets/AltDateWidget.js.map +1 -0
- 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 +4 -3
- package/lib/components/widgets/CheckboxWidget.js.map +1 -0
- package/lib/components/widgets/CheckboxesWidget.js +1 -0
- package/lib/components/widgets/CheckboxesWidget.js.map +1 -0
- package/lib/components/widgets/ColorWidget.js +1 -0
- package/lib/components/widgets/ColorWidget.js.map +1 -0
- package/lib/components/widgets/DateTimeWidget.js +1 -0
- package/lib/components/widgets/DateTimeWidget.js.map +1 -0
- package/lib/components/widgets/DateWidget.js +1 -0
- package/lib/components/widgets/DateWidget.js.map +1 -0
- package/lib/components/widgets/EmailWidget.js +1 -0
- package/lib/components/widgets/EmailWidget.js.map +1 -0
- package/lib/components/widgets/FileWidget.js +1 -0
- package/lib/components/widgets/FileWidget.js.map +1 -0
- package/lib/components/widgets/HiddenWidget.js +1 -0
- package/lib/components/widgets/HiddenWidget.js.map +1 -0
- package/lib/components/widgets/PasswordWidget.js +1 -0
- package/lib/components/widgets/PasswordWidget.js.map +1 -0
- package/lib/components/widgets/RadioWidget.js +1 -0
- package/lib/components/widgets/RadioWidget.js.map +1 -0
- package/lib/components/widgets/RangeWidget.js +1 -0
- package/lib/components/widgets/RangeWidget.js.map +1 -0
- 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 -1
- package/lib/components/widgets/RatingWidget.js.map +1 -0
- package/lib/components/widgets/SelectWidget.js +1 -0
- package/lib/components/widgets/SelectWidget.js.map +1 -0
- package/lib/components/widgets/TextWidget.js +1 -0
- package/lib/components/widgets/TextWidget.js.map +1 -0
- package/lib/components/widgets/TextareaWidget.js +1 -0
- package/lib/components/widgets/TextareaWidget.js.map +1 -0
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/TimeWidget.js +16 -3
- package/lib/components/widgets/TimeWidget.js.map +1 -0
- package/lib/components/widgets/URLWidget.js +1 -0
- package/lib/components/widgets/URLWidget.js.map +1 -0
- package/lib/components/widgets/UpDownWidget.js +1 -0
- package/lib/components/widgets/UpDownWidget.js.map +1 -0
- package/lib/components/widgets/index.js +21 -20
- package/lib/components/widgets/index.js.map +1 -0
- package/lib/getDefaultRegistry.js +4 -3
- package/lib/getDefaultRegistry.js.map +1 -0
- package/lib/getTestRegistry.js +2 -1
- package/lib/getTestRegistry.js.map +1 -0
- package/lib/index.d.ts +12 -12
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -7
- package/lib/index.js.map +1 -0
- package/lib/withTheme.d.ts +1 -1
- package/lib/withTheme.d.ts.map +1 -1
- package/lib/withTheme.js +2 -1
- package/lib/withTheme.js.map +1 -0
- package/package.json +13 -18
- package/src/components/Form.tsx +68 -47
- package/src/components/fields/ArrayField.tsx +17 -19
- package/src/components/fields/BooleanField.tsx +1 -2
- package/src/components/fields/LayoutGridField.tsx +57 -65
- package/src/components/fields/LayoutMultiSchemaField.tsx +18 -18
- package/src/components/fields/MultiSchemaField.tsx +6 -8
- package/src/components/fields/ObjectField.tsx +26 -27
- package/src/components/fields/SchemaField.tsx +13 -4
- package/src/components/fields/index.ts +14 -14
- package/src/components/templates/BaseInputTemplate.tsx +2 -2
- package/src/components/templates/ButtonTemplates/AddButton.tsx +1 -1
- package/src/components/templates/ButtonTemplates/index.ts +3 -3
- package/src/components/templates/DescriptionField.tsx +1 -1
- package/src/components/templates/FieldHelpTemplate.tsx +1 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +1 -1
- package/src/components/templates/FieldTemplate/index.ts +1 -1
- package/src/components/templates/OptionalDataControlsTemplate.tsx +1 -1
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +21 -21
- package/src/components/widgets/CheckboxWidget.tsx +9 -2
- package/src/components/widgets/RatingWidget.tsx +0 -1
- package/src/components/widgets/TimeWidget.tsx +18 -3
- package/src/components/widgets/index.ts +20 -20
- package/src/getDefaultRegistry.ts +3 -3
- package/src/getTestRegistry.tsx +1 -1
- package/src/index.ts +12 -12
- package/src/withTheme.tsx +2 -2
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/src/tsconfig.json +0 -30
|
@@ -10,13 +10,19 @@ import type {
|
|
|
10
10
|
UiSchema,
|
|
11
11
|
} from '@rjsf/utils';
|
|
12
12
|
import {
|
|
13
|
+
getByPath,
|
|
14
|
+
toPath,
|
|
13
15
|
ANY_OF_KEY,
|
|
16
|
+
deepEquals,
|
|
14
17
|
getDiscriminatorFieldFromSchema,
|
|
15
18
|
getTemplate,
|
|
16
19
|
getTestIds,
|
|
20
|
+
getPropertySchema,
|
|
17
21
|
getUiOptions,
|
|
18
22
|
hashObject,
|
|
19
23
|
ID_KEY,
|
|
24
|
+
isObject,
|
|
25
|
+
isPlainObject,
|
|
20
26
|
lookupFromFormContext,
|
|
21
27
|
ONE_OF_KEY,
|
|
22
28
|
PROPERTIES_KEY,
|
|
@@ -27,21 +33,6 @@ import {
|
|
|
27
33
|
ITEMS_KEY,
|
|
28
34
|
useDeepCompareMemo,
|
|
29
35
|
} from '@rjsf/utils';
|
|
30
|
-
import each from 'lodash/each';
|
|
31
|
-
import flatten from 'lodash/flatten';
|
|
32
|
-
import get from 'lodash/get';
|
|
33
|
-
import has from 'lodash/has';
|
|
34
|
-
import includes from 'lodash/includes';
|
|
35
|
-
import intersection from 'lodash/intersection';
|
|
36
|
-
import isEmpty from 'lodash/isEmpty';
|
|
37
|
-
import isEqual from 'lodash/isEqual';
|
|
38
|
-
import isFunction from 'lodash/isFunction';
|
|
39
|
-
import isObject from 'lodash/isObject';
|
|
40
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
41
|
-
import isString from 'lodash/isString';
|
|
42
|
-
import isUndefined from 'lodash/isUndefined';
|
|
43
|
-
import last from 'lodash/last';
|
|
44
|
-
import set from 'lodash/set';
|
|
45
36
|
|
|
46
37
|
/** The enumeration of the three different Layout GridTemplate type values
|
|
47
38
|
*/
|
|
@@ -165,28 +156,29 @@ export function computeFieldUiSchema<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
165
156
|
schemaReadonly?: boolean,
|
|
166
157
|
forceReadonly?: boolean,
|
|
167
158
|
) {
|
|
168
|
-
const globalUiOptions =
|
|
169
|
-
const localUiSchema =
|
|
170
|
-
const localUiOptions = { ...
|
|
159
|
+
const globalUiOptions = uiSchema?.[UI_GLOBAL_OPTIONS_KEY] ?? {};
|
|
160
|
+
const localUiSchema = getByPath<UiSchema<T, S, F> | undefined>(uiSchema, toPath(field));
|
|
161
|
+
const localUiOptions = { ...(localUiSchema?.[UI_OPTIONS_KEY] ?? {}), ...uiProps, ...globalUiOptions };
|
|
171
162
|
const fieldUiSchema = { ...localUiSchema };
|
|
172
|
-
if (
|
|
173
|
-
|
|
163
|
+
if (Object.keys(localUiOptions).length > 0) {
|
|
164
|
+
fieldUiSchema[UI_OPTIONS_KEY] = localUiOptions;
|
|
174
165
|
}
|
|
175
|
-
if (
|
|
166
|
+
if (Object.keys(globalUiOptions).length > 0) {
|
|
176
167
|
// pass the global uiOptions down to the field uiSchema so that they can be applied to all nested fields
|
|
177
|
-
|
|
168
|
+
fieldUiSchema[UI_GLOBAL_OPTIONS_KEY] = globalUiOptions;
|
|
178
169
|
}
|
|
179
170
|
let { readonly: uiReadonly } = getUiOptions<T, S, F>(fieldUiSchema);
|
|
180
|
-
if (forceReadonly === true || (
|
|
171
|
+
if (forceReadonly === true || (uiReadonly === undefined && schemaReadonly === true)) {
|
|
181
172
|
// If we are forcing all widgets to be readonly, OR the schema indicates it is readonly AND the uiSchema does not
|
|
182
173
|
// have an overriding value, then update the uiSchema to set readonly to true. Doing this will
|
|
183
174
|
uiReadonly = true;
|
|
184
|
-
|
|
175
|
+
const fieldUiOptions = fieldUiSchema[UI_OPTIONS_KEY];
|
|
176
|
+
if (fieldUiOptions && READONLY_KEY in fieldUiOptions) {
|
|
185
177
|
// If the local options has the key value provided in it, then set that one to true
|
|
186
|
-
|
|
178
|
+
fieldUiOptions[READONLY_KEY] = true;
|
|
187
179
|
} else {
|
|
188
180
|
// otherwise set the `ui:` version
|
|
189
|
-
|
|
181
|
+
fieldUiSchema[`ui:${READONLY_KEY}`] = true;
|
|
190
182
|
}
|
|
191
183
|
}
|
|
192
184
|
return { fieldUiSchema, uiReadonly };
|
|
@@ -211,15 +203,15 @@ export function conditionMatches(
|
|
|
211
203
|
datum?: unknown,
|
|
212
204
|
value: unknown = '$0m3tH1nG Un3xP3cT3d',
|
|
213
205
|
): boolean {
|
|
214
|
-
const data =
|
|
215
|
-
const values =
|
|
206
|
+
const data = [datum].flat().sort();
|
|
207
|
+
const values = [value].flat().sort();
|
|
216
208
|
switch (operator) {
|
|
217
209
|
case Operators.ALL:
|
|
218
|
-
return
|
|
210
|
+
return deepEquals(data, values);
|
|
219
211
|
case Operators.SOME:
|
|
220
|
-
return
|
|
212
|
+
return data.some((entry) => values.includes(entry));
|
|
221
213
|
case Operators.NONE:
|
|
222
|
-
return
|
|
214
|
+
return !data.some((entry) => values.includes(entry));
|
|
223
215
|
default:
|
|
224
216
|
return false;
|
|
225
217
|
}
|
|
@@ -284,12 +276,12 @@ export function computeArraySchemasIfPresent<S extends StrictRJSFSchema = RJSFSc
|
|
|
284
276
|
} {
|
|
285
277
|
let rawSchema: S | undefined;
|
|
286
278
|
let resultPathId = fieldPathId;
|
|
287
|
-
if (isNumericIndex(potentialIndex) && schema && schema?.type === 'array' &&
|
|
279
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === 'array' && ITEMS_KEY in schema) {
|
|
288
280
|
const index = Number(potentialIndex);
|
|
289
281
|
const items = schema[ITEMS_KEY];
|
|
290
282
|
if (Array.isArray(items)) {
|
|
291
283
|
if (index > items.length) {
|
|
292
|
-
rawSchema =
|
|
284
|
+
rawSchema = items.at(-1) as S;
|
|
293
285
|
} else {
|
|
294
286
|
rawSchema = items[index] as S;
|
|
295
287
|
}
|
|
@@ -347,20 +339,21 @@ export function getSchemaDetailsForField<
|
|
|
347
339
|
parts.forEach((part) => {
|
|
348
340
|
// dive into the properties of the current schema (when it exists) and get the schema for the next part
|
|
349
341
|
fieldPathId = toFieldPathId(part, globalFormOptions, fieldPathId);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
342
|
+
const schemaProperties = schema?.[PROPERTIES_KEY];
|
|
343
|
+
if (schemaProperties) {
|
|
344
|
+
rawSchema = (schemaProperties[part] ?? {}) as S;
|
|
345
|
+
} else if (schema && (ONE_OF_KEY in schema || ANY_OF_KEY in schema)) {
|
|
346
|
+
const xxx = ONE_OF_KEY in schema ? ONE_OF_KEY : ANY_OF_KEY;
|
|
354
347
|
// When the schema represents a oneOf/anyOf, find the selected schema for it and grab the inner part
|
|
355
348
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
356
|
-
rawSchema =
|
|
349
|
+
rawSchema = getPropertySchema<S>(selectedSchema, part);
|
|
357
350
|
} else {
|
|
358
351
|
const result = computeArraySchemasIfPresent<S>(schema, fieldPathId, part);
|
|
359
352
|
rawSchema = result.rawSchema ?? ({} as S);
|
|
360
353
|
fieldPathId = result.fieldPathId;
|
|
361
354
|
}
|
|
362
355
|
// Now drill into the innerData for the part, returning an empty object by default if it doesn't exist
|
|
363
|
-
innerData =
|
|
356
|
+
innerData = getByPath<T>(innerData, part, {} as T);
|
|
364
357
|
// Resolve any `$ref`s for the current rawSchema
|
|
365
358
|
schema = schemaUtils.retrieveSchema(rawSchema, innerData);
|
|
366
359
|
isReadonly = getNonNullishValue(schema.readOnly, isReadonly);
|
|
@@ -369,31 +362,31 @@ export function getSchemaDetailsForField<
|
|
|
369
362
|
let optionsInfo: OneOfOptionsInfoType<S> | undefined;
|
|
370
363
|
let isRequired = false;
|
|
371
364
|
// retrieveSchema will return an empty schema in the worst case scenario, convert it to undefined
|
|
372
|
-
if (
|
|
365
|
+
if (!schema || Object.keys(schema).length === 0) {
|
|
373
366
|
schema = undefined;
|
|
374
367
|
}
|
|
375
368
|
if (schema && leafPath) {
|
|
376
369
|
// When we have both a schema and a leafPath...
|
|
377
|
-
if (schema && (
|
|
378
|
-
const xxx =
|
|
370
|
+
if (schema && (ONE_OF_KEY in schema || ANY_OF_KEY in schema)) {
|
|
371
|
+
const xxx = ONE_OF_KEY in schema ? ONE_OF_KEY : ANY_OF_KEY;
|
|
379
372
|
// Grab the selected schema for the oneOf/anyOf value for the leafPath using the innerData
|
|
380
373
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
381
374
|
}
|
|
382
375
|
fieldPathId = toFieldPathId(leafPath, globalFormOptions, fieldPathId);
|
|
383
|
-
isRequired = schema !== undefined && Array.isArray(schema.required) &&
|
|
376
|
+
isRequired = schema !== undefined && Array.isArray(schema.required) && schema.required.includes(leafPath);
|
|
384
377
|
const result = computeArraySchemasIfPresent<S>(schema, fieldPathId, leafPath);
|
|
385
378
|
if (result.rawSchema) {
|
|
386
379
|
schema = result.rawSchema;
|
|
387
380
|
fieldPathId = result.fieldPathId;
|
|
388
381
|
} else {
|
|
389
382
|
// Now grab the schema from the leafPath of the current schema properties
|
|
390
|
-
schema =
|
|
383
|
+
schema = schema?.[PROPERTIES_KEY]?.[leafPath] as S | undefined;
|
|
391
384
|
// Resolve any `$ref`s for the current schema
|
|
392
385
|
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
393
386
|
}
|
|
394
387
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
395
|
-
if (schema && (
|
|
396
|
-
const xxx =
|
|
388
|
+
if (schema && (ONE_OF_KEY in schema || ANY_OF_KEY in schema)) {
|
|
389
|
+
const xxx = ONE_OF_KEY in schema ? ONE_OF_KEY : ANY_OF_KEY;
|
|
397
390
|
// Set the options if we have a schema with a oneOf/anyOf
|
|
398
391
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
399
392
|
optionsInfo = { options: schema[xxx] as S[], hasDiscriminator: !!discriminator };
|
|
@@ -416,11 +409,11 @@ export function getCustomRenderComponent<
|
|
|
416
409
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
417
410
|
F extends FormContextType = any,
|
|
418
411
|
>(render: string | RenderComponent, registry: Registry<T, S, F>): RenderComponent | null {
|
|
419
|
-
let customRenderer = render;
|
|
420
|
-
if (
|
|
421
|
-
customRenderer = lookupFromFormContext<T, S, F>(registry, customRenderer);
|
|
412
|
+
let customRenderer: string | RenderComponent | undefined = render;
|
|
413
|
+
if (typeof customRenderer === 'string') {
|
|
414
|
+
customRenderer = lookupFromFormContext<T, S, F, string | RenderComponent | undefined>(registry, customRenderer);
|
|
422
415
|
}
|
|
423
|
-
if (
|
|
416
|
+
if (typeof customRenderer === 'function') {
|
|
424
417
|
return customRenderer;
|
|
425
418
|
}
|
|
426
419
|
return null;
|
|
@@ -443,24 +436,22 @@ export function computeUIComponentPropsFromGridSchema<
|
|
|
443
436
|
let UIComponent: RenderComponent | null = null;
|
|
444
437
|
let uiProps: ConfigObject = {};
|
|
445
438
|
let rendered: ReactNode | undefined;
|
|
446
|
-
if (
|
|
439
|
+
if (typeof gridSchema === 'string' || gridSchema === undefined) {
|
|
447
440
|
name = gridSchema ?? '';
|
|
448
441
|
} else {
|
|
449
442
|
const { name: innerName = '', render, ...innerProps } = gridSchema;
|
|
450
443
|
name = innerName;
|
|
451
444
|
uiProps = innerProps;
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
uiProps[key] = lookupFromFormContext(registry, lookupName, lookupName);
|
|
460
|
-
}
|
|
445
|
+
// Transform any `$lookup=` in the uiProps props with the appropriate value
|
|
446
|
+
Object.entries(uiProps).forEach(([key, prop]) => {
|
|
447
|
+
if (typeof prop === 'string') {
|
|
448
|
+
const match: string[] | null = LOOKUP_REGEX.exec(prop);
|
|
449
|
+
if (Array.isArray(match) && match.length > 1) {
|
|
450
|
+
const lookupName = match[1];
|
|
451
|
+
uiProps[key] = lookupFromFormContext(registry, lookupName, lookupName);
|
|
461
452
|
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
453
|
+
}
|
|
454
|
+
});
|
|
464
455
|
UIComponent = getCustomRenderComponent<T, S, F>(render, registry);
|
|
465
456
|
if (!innerName && UIComponent) {
|
|
466
457
|
rendered = <UIComponent {...innerProps} data-testid={LAYOUT_GRID_FIELD_TEST_IDS.uiComponent} />;
|
|
@@ -533,7 +524,7 @@ function LayoutGridCondition<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
533
524
|
const { formData, registry } = layoutGridFieldProps;
|
|
534
525
|
const { children, gridProps } = findChildrenAndProps<T, S, F>(layoutGridSchema, GridType.CONDITION, registry);
|
|
535
526
|
const { operator, field = '', value } = gridProps;
|
|
536
|
-
const fieldData =
|
|
527
|
+
const fieldData = getByPath(formData, toPath(field), null);
|
|
537
528
|
if (conditionMatches(operator, fieldData, value)) {
|
|
538
529
|
return <LayoutGridFieldChildren {...layoutGridFieldProps} childrenLayoutGridSchemaId={children} />;
|
|
539
530
|
}
|
|
@@ -683,6 +674,7 @@ function LayoutGridFieldComponent<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
683
674
|
// the `Form` via the prop passed to `LayoutGridField` we need to make sure the uiSchema always has a true value
|
|
684
675
|
// when it is needed
|
|
685
676
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema<T, S, F>(name, uiProps, uiSchema, isReadonly, readonly);
|
|
677
|
+
const namePath = toPath(name);
|
|
686
678
|
|
|
687
679
|
return (
|
|
688
680
|
<Field
|
|
@@ -697,9 +689,9 @@ function LayoutGridFieldComponent<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
697
689
|
readonly={uiReadonly}
|
|
698
690
|
schema={schema}
|
|
699
691
|
uiSchema={fieldUiSchema}
|
|
700
|
-
errorSchema={
|
|
692
|
+
errorSchema={getByPath(errorSchema, namePath)}
|
|
701
693
|
fieldPathId={memoFieldPathId}
|
|
702
|
-
formData={
|
|
694
|
+
formData={getByPath(formData, namePath)}
|
|
703
695
|
onChange={onChange}
|
|
704
696
|
onBlur={onBlur}
|
|
705
697
|
onFocus={onFocus}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
import type {
|
|
3
3
|
EnumOptionsType,
|
|
4
|
+
ErrorSchema,
|
|
4
5
|
FieldProps,
|
|
5
6
|
FormContextType,
|
|
6
7
|
RJSFSchema,
|
|
@@ -9,6 +10,8 @@ import type {
|
|
|
9
10
|
UiSchema,
|
|
10
11
|
} from '@rjsf/utils';
|
|
11
12
|
import {
|
|
13
|
+
getByPath,
|
|
14
|
+
setByPath,
|
|
12
15
|
ANY_OF_KEY,
|
|
13
16
|
CONST_KEY,
|
|
14
17
|
DEFAULT_KEY,
|
|
@@ -20,15 +23,11 @@ import {
|
|
|
20
23
|
optionsList,
|
|
21
24
|
PROPERTIES_KEY,
|
|
22
25
|
getTemplate,
|
|
26
|
+
getPropertySchema,
|
|
23
27
|
getUiOptions,
|
|
24
28
|
getWidget,
|
|
29
|
+
noop,
|
|
25
30
|
} from '@rjsf/utils';
|
|
26
|
-
import get from 'lodash/get';
|
|
27
|
-
import has from 'lodash/has';
|
|
28
|
-
import isEmpty from 'lodash/isEmpty';
|
|
29
|
-
import noop from 'lodash/noop';
|
|
30
|
-
import omit from 'lodash/omit';
|
|
31
|
-
import set from 'lodash/set';
|
|
32
31
|
|
|
33
32
|
/** Gets the selected option from the list of `options`, using the `selectorField` to search inside each `option` for
|
|
34
33
|
* the `properties[selectorField].default(or const)` that matches the given `value`.
|
|
@@ -45,8 +44,8 @@ export function getSelectedOption<S extends StrictRJSFSchema = RJSFSchema>(
|
|
|
45
44
|
const defaultValue = '!@#!@$@#$!@$#';
|
|
46
45
|
const schemaOptions: S[] = options.map(({ schema }) => schema!);
|
|
47
46
|
return schemaOptions.find((option) => {
|
|
48
|
-
const selector =
|
|
49
|
-
const result =
|
|
47
|
+
const selector = option[PROPERTIES_KEY]?.[selectorField];
|
|
48
|
+
const result = getByPath(selector, DEFAULT_KEY, getByPath(selector, CONST_KEY, defaultValue));
|
|
50
49
|
return result === value;
|
|
51
50
|
});
|
|
52
51
|
}
|
|
@@ -70,9 +69,9 @@ export function computeEnumOptions<T = any, S extends StrictRJSFSchema = RJSFSch
|
|
|
70
69
|
): EnumOptionsType<S>[] {
|
|
71
70
|
const realOptions = options.map((opt: S) => schemaUtils.retrieveSchema(opt, formData));
|
|
72
71
|
let tempSchema = schema;
|
|
73
|
-
if (
|
|
72
|
+
if (ONE_OF_KEY in schema) {
|
|
74
73
|
tempSchema = { ...schema, [ONE_OF_KEY]: realOptions };
|
|
75
|
-
} else if (
|
|
74
|
+
} else if (ANY_OF_KEY in schema) {
|
|
76
75
|
tempSchema = { ...schema, [ANY_OF_KEY]: realOptions };
|
|
77
76
|
}
|
|
78
77
|
const enumOptions = optionsList<T, S, F>(tempSchema, uiSchema);
|
|
@@ -114,7 +113,7 @@ export default function LayoutMultiSchemaField<
|
|
|
114
113
|
} = props;
|
|
115
114
|
const { widgets, schemaUtils, globalUiOptions } = registry;
|
|
116
115
|
const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
117
|
-
const id =
|
|
116
|
+
const id = fieldPathId[ID_KEY];
|
|
118
117
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
119
118
|
const FieldErrorTemplate = getTemplate<'FieldErrorTemplate', T, S, F>('FieldErrorTemplate', registry, options);
|
|
120
119
|
const FieldTemplate = getTemplate<'FieldTemplate', T, S, F>('FieldTemplate', registry, options);
|
|
@@ -139,8 +138,8 @@ export default function LayoutMultiSchemaField<
|
|
|
139
138
|
if (!selectorField) {
|
|
140
139
|
throw new Error('No selector field provided for the LayoutMultiSchemaField');
|
|
141
140
|
}
|
|
142
|
-
const selectedOption =
|
|
143
|
-
let optionSchema
|
|
141
|
+
const selectedOption = getByPath(formData, selectorField);
|
|
142
|
+
let optionSchema = getPropertySchema<S>(enumOptions[0]?.schema, selectorField);
|
|
144
143
|
const option = getSelectedOption<S>(enumOptions, selectorField, selectedOption);
|
|
145
144
|
// If the subschema doesn't declare a type, infer the type from the parent schema
|
|
146
145
|
optionSchema = optionSchema?.type ? optionSchema : ({ ...optionSchema, type: option?.type || baseType } as S);
|
|
@@ -150,8 +149,9 @@ export default function LayoutMultiSchemaField<
|
|
|
150
149
|
// Set hideError to the value provided in the uiSchema, otherwise stick with the prop to propagate to children
|
|
151
150
|
const hideFieldError = uiSchemaHideError === undefined ? hideError : Boolean(uiSchemaHideError);
|
|
152
151
|
|
|
153
|
-
const rawErrors =
|
|
154
|
-
const fieldErrorSchema =
|
|
152
|
+
const rawErrors = errorSchema?.[ERRORS_KEY] ?? [];
|
|
153
|
+
const fieldErrorSchema = { ...errorSchema } as ErrorSchema<T>;
|
|
154
|
+
delete fieldErrorSchema[ERRORS_KEY];
|
|
155
155
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
156
156
|
|
|
157
157
|
/** Callback function that updates the selected option and adjusts the form data based on the structure of the new
|
|
@@ -173,7 +173,7 @@ export default function LayoutMultiSchemaField<
|
|
|
173
173
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren') as T;
|
|
174
174
|
}
|
|
175
175
|
if (newFormData) {
|
|
176
|
-
|
|
176
|
+
setByPath(newFormData, selectorField, opt);
|
|
177
177
|
}
|
|
178
178
|
// Pass the component name in the path
|
|
179
179
|
onChange(newFormData, fieldPathId.path, undefined, id);
|
|
@@ -192,7 +192,7 @@ export default function LayoutMultiSchemaField<
|
|
|
192
192
|
id={id}
|
|
193
193
|
schema={schema}
|
|
194
194
|
label={(title || schema.title) ?? ''}
|
|
195
|
-
disabled={disabled || (Array.isArray(enumOptions) &&
|
|
195
|
+
disabled={disabled || (Array.isArray(enumOptions) && enumOptions.length === 0)}
|
|
196
196
|
uiSchema={uiSchema}
|
|
197
197
|
required={required}
|
|
198
198
|
readonly={!!readonly}
|
|
@@ -209,7 +209,7 @@ export default function LayoutMultiSchemaField<
|
|
|
209
209
|
name={name}
|
|
210
210
|
schema={schema}
|
|
211
211
|
label={(title || schema.title) ?? ''}
|
|
212
|
-
disabled={disabled || (Array.isArray(enumOptions) &&
|
|
212
|
+
disabled={disabled || (Array.isArray(enumOptions) && enumOptions.length === 0)}
|
|
213
213
|
uiSchema={uiSchema}
|
|
214
214
|
autofocus={autofocus}
|
|
215
215
|
readonly={readonly}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
2
|
+
import type { ErrorSchema, FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
3
|
import {
|
|
4
4
|
ANY_OF_KEY,
|
|
5
5
|
deepEquals,
|
|
@@ -15,9 +15,6 @@ import {
|
|
|
15
15
|
shouldRenderOptionalField,
|
|
16
16
|
TranslatableString,
|
|
17
17
|
} from '@rjsf/utils';
|
|
18
|
-
import get from 'lodash/get';
|
|
19
|
-
import isEmpty from 'lodash/isEmpty';
|
|
20
|
-
import omit from 'lodash/omit';
|
|
21
18
|
|
|
22
19
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
23
20
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
@@ -30,7 +27,7 @@ function AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
30
27
|
const {
|
|
31
28
|
name,
|
|
32
29
|
disabled = false,
|
|
33
|
-
errorSchema
|
|
30
|
+
errorSchema,
|
|
34
31
|
formData,
|
|
35
32
|
fieldPathId,
|
|
36
33
|
onBlur,
|
|
@@ -152,8 +149,9 @@ function AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
152
149
|
...uiOptions
|
|
153
150
|
} = getUiOptions<T, S, F>(uiSchema, globalUiOptions);
|
|
154
151
|
const Widget = getWidget<T, S, F>({ type: 'number' }, widget, widgets);
|
|
155
|
-
const rawErrors =
|
|
156
|
-
const fieldErrorSchema =
|
|
152
|
+
const rawErrors = errorSchema?.[ERRORS_KEY] ?? [];
|
|
153
|
+
const fieldErrorSchema = { ...errorSchema } as ErrorSchema<T>;
|
|
154
|
+
delete fieldErrorSchema[ERRORS_KEY];
|
|
157
155
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
158
156
|
|
|
159
157
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
@@ -221,7 +219,7 @@ function AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
221
219
|
onChange={onOptionChange}
|
|
222
220
|
onBlur={onBlur}
|
|
223
221
|
onFocus={onFocus}
|
|
224
|
-
disabled={disabled ||
|
|
222
|
+
disabled={disabled || enumOptions.length === 0}
|
|
225
223
|
multiple={false}
|
|
226
224
|
rawErrors={rawErrors}
|
|
227
225
|
errorSchema={fieldErrorSchema}
|
|
@@ -13,9 +13,14 @@ import type {
|
|
|
13
13
|
StrictRJSFSchema,
|
|
14
14
|
} from '@rjsf/utils';
|
|
15
15
|
import {
|
|
16
|
+
getByPath,
|
|
17
|
+
hasByPath,
|
|
18
|
+
setByPath,
|
|
16
19
|
ADDITIONAL_PROPERTY_FLAG,
|
|
17
20
|
ANY_OF_KEY,
|
|
21
|
+
deepEquals,
|
|
18
22
|
getTemplate,
|
|
23
|
+
getPropertySchema,
|
|
19
24
|
getUiOptions,
|
|
20
25
|
isFormDataAvailable,
|
|
21
26
|
orderProperties,
|
|
@@ -23,17 +28,13 @@ import {
|
|
|
23
28
|
toFieldPathId,
|
|
24
29
|
useDeepCompareMemo,
|
|
25
30
|
ONE_OF_KEY,
|
|
26
|
-
PROPERTIES_KEY,
|
|
27
31
|
REF_KEY,
|
|
32
|
+
isObject,
|
|
28
33
|
TranslatableString,
|
|
29
34
|
} from '@rjsf/utils';
|
|
30
|
-
import get from 'lodash/get';
|
|
31
|
-
import has from 'lodash/has';
|
|
32
|
-
import isObject from 'lodash/isObject';
|
|
33
|
-
import set from 'lodash/set';
|
|
34
35
|
import { Markdown } from 'markdown-to-jsx/react';
|
|
35
36
|
|
|
36
|
-
import { ADDITIONAL_PROPERTY_KEY_REMOVE } from '../constants';
|
|
37
|
+
import { ADDITIONAL_PROPERTY_KEY_REMOVE } from '../constants.ts';
|
|
37
38
|
|
|
38
39
|
/** Returns a flag indicating whether the `name` field is required in the object schema
|
|
39
40
|
*
|
|
@@ -129,27 +130,27 @@ function ObjectFieldPropertyFn<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
129
130
|
toFieldPathId(propertyName, globalFormOptions, fieldPathId.path),
|
|
130
131
|
);
|
|
131
132
|
|
|
132
|
-
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* @param name - The name of the property
|
|
137
|
-
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
138
|
-
* @returns - The onPropertyChange callback for the `name` property
|
|
133
|
+
/** The `onChange` handler installed on this property's `SchemaField`. Handles the special case where the user
|
|
134
|
+
* clears a value at this property's own path when it was added as an additional property, coercing `undefined`
|
|
135
|
+
* to the empty string so the property's key input survives. Every other change, including any change to a
|
|
136
|
+
* descendant of this property, is forwarded to `onChange()` untouched.
|
|
139
137
|
*/
|
|
140
138
|
const onPropertyChange = useCallback(
|
|
141
139
|
(value: T | undefined, path: FieldPathList, newErrorSchema?: ErrorSchema<T>, id?: string) => {
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
140
|
+
// An `additionalProperties` value lives at this property's own path, so clearing its widget to `undefined`
|
|
141
|
+
// would drop the key from the formData and take the key input with it. Coerce that one case to the empty
|
|
142
|
+
// string.
|
|
143
|
+
// A descendant's path is this property's path plus at least one segment, so comparing to this
|
|
144
|
+
// property's own path (rather than merely its length) tells apart "this property changed" from "a
|
|
145
|
+
// descendant changed"; a cleared descendant must stay `undefined` so it is omitted from the formData
|
|
146
|
+
// exactly like a cleared property declared in `properties` (#5222).
|
|
146
147
|
let normalizedValue = value;
|
|
147
|
-
if (value === undefined && addedByAdditionalProperties) {
|
|
148
|
+
if (value === undefined && addedByAdditionalProperties && deepEquals(path, innerFieldIdPathId.path)) {
|
|
148
149
|
normalizedValue = '' as unknown as T;
|
|
149
150
|
}
|
|
150
151
|
onChange(normalizedValue, path, newErrorSchema, id);
|
|
151
152
|
},
|
|
152
|
-
[onChange, addedByAdditionalProperties],
|
|
153
|
+
[onChange, addedByAdditionalProperties, innerFieldIdPathId],
|
|
153
154
|
);
|
|
154
155
|
|
|
155
156
|
/** The key change event handler; Called when the key associated with a field is changed for an additionalProperty.
|
|
@@ -275,7 +276,7 @@ export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
275
276
|
|
|
276
277
|
let index = 0;
|
|
277
278
|
let newKey = preferredKey;
|
|
278
|
-
while (
|
|
279
|
+
while (hasByPath(existingFormData, newKey)) {
|
|
279
280
|
index += 1;
|
|
280
281
|
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
281
282
|
}
|
|
@@ -294,8 +295,7 @@ export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
294
295
|
const newFormData = { ...formData } as T;
|
|
295
296
|
const newKey = getAvailableKey('newKey', newFormData);
|
|
296
297
|
if (schema.patternProperties) {
|
|
297
|
-
|
|
298
|
-
set(newFormData as GenericObjectType, newKey, null);
|
|
298
|
+
setByPath(newFormData, newKey, null);
|
|
299
299
|
} else {
|
|
300
300
|
let type: RJSFSchema['type'] = undefined;
|
|
301
301
|
let constValue: RJSFSchema['const'] = undefined;
|
|
@@ -317,8 +317,7 @@ export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
const newValue = constValue ?? defaultValue ?? getDefaultValue<T, S, F>(translateString, type);
|
|
320
|
-
|
|
321
|
-
set(newFormData as GenericObjectType, newKey, newValue);
|
|
320
|
+
setByPath(newFormData, newKey, newValue);
|
|
322
321
|
}
|
|
323
322
|
|
|
324
323
|
if (lastRenamedProperty.current.previousKey === newKey) {
|
|
@@ -426,11 +425,11 @@ export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
426
425
|
key={getStableKey(propertyName)}
|
|
427
426
|
propertyName={propertyName}
|
|
428
427
|
required={isRequired<S>(schema, propertyName)}
|
|
429
|
-
schema={
|
|
428
|
+
schema={getPropertySchema<S>(schema, propertyName)}
|
|
430
429
|
uiSchema={fieldUiSchema}
|
|
431
|
-
errorSchema={
|
|
430
|
+
errorSchema={getByPath(errorSchema, propertyName)}
|
|
432
431
|
fieldPathId={childFieldPathId}
|
|
433
|
-
formData={
|
|
432
|
+
formData={getByPath(formData, propertyName)}
|
|
434
433
|
handleKeyRename={handleKeyRename}
|
|
435
434
|
handleRemoveProperty={handleRemoveProperty}
|
|
436
435
|
addedByAdditionalProperties={addedByAdditionalProperties}
|
|
@@ -30,11 +30,10 @@ import {
|
|
|
30
30
|
shallowEquals,
|
|
31
31
|
shouldRenderOptionalField,
|
|
32
32
|
toFieldPathId,
|
|
33
|
+
isObject,
|
|
33
34
|
TranslatableString,
|
|
34
35
|
UI_OPTIONS_KEY,
|
|
35
36
|
} from '@rjsf/utils';
|
|
36
|
-
import isObject from 'lodash/isObject';
|
|
37
|
-
import omit from 'lodash/omit';
|
|
38
37
|
|
|
39
38
|
/** The map of component type to FieldName */
|
|
40
39
|
const COMPONENT_TYPES: Record<string, string> = {
|
|
@@ -202,9 +201,19 @@ function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
202
201
|
|
|
203
202
|
const { __errors, ...fieldErrorSchema } = errorSchema || {};
|
|
204
203
|
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
205
|
-
const
|
|
204
|
+
const {
|
|
205
|
+
'ui:classNames': consumedUiClassNames,
|
|
206
|
+
classNames: consumedClassNames,
|
|
207
|
+
'ui:style': consumedUiStyle,
|
|
208
|
+
...fieldUiSchema
|
|
209
|
+
} = uiSchema;
|
|
206
210
|
if (UI_OPTIONS_KEY in fieldUiSchema) {
|
|
207
|
-
|
|
211
|
+
const {
|
|
212
|
+
classNames: consumedOptionClassNames,
|
|
213
|
+
style: consumedOptionStyle,
|
|
214
|
+
...fieldUiOptions
|
|
215
|
+
} = fieldUiSchema[UI_OPTIONS_KEY]!;
|
|
216
|
+
fieldUiSchema[UI_OPTIONS_KEY] = fieldUiOptions;
|
|
208
217
|
}
|
|
209
218
|
|
|
210
219
|
const field = (
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { Field, FormContextType, RegistryFieldsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
|
-
import ArrayField from './ArrayField';
|
|
4
|
-
import BooleanField from './BooleanField';
|
|
5
|
-
import CyclicSchemaField from './CyclicSchemaField';
|
|
6
|
-
import FallbackField from './FallbackField';
|
|
7
|
-
import LayoutGridField from './LayoutGridField';
|
|
8
|
-
import LayoutHeaderField from './LayoutHeaderField';
|
|
9
|
-
import LayoutMultiSchemaField from './LayoutMultiSchemaField';
|
|
10
|
-
import MultiSchemaField from './MultiSchemaField';
|
|
11
|
-
import NullField from './NullField';
|
|
12
|
-
import NumberField from './NumberField';
|
|
13
|
-
import ObjectField from './ObjectField';
|
|
14
|
-
import OptionalDataControlsField from './OptionalDataControlsField';
|
|
15
|
-
import SchemaField from './SchemaField';
|
|
16
|
-
import StringField from './StringField';
|
|
3
|
+
import ArrayField from './ArrayField.tsx';
|
|
4
|
+
import BooleanField from './BooleanField.tsx';
|
|
5
|
+
import CyclicSchemaField from './CyclicSchemaField.tsx';
|
|
6
|
+
import FallbackField from './FallbackField.tsx';
|
|
7
|
+
import LayoutGridField from './LayoutGridField.tsx';
|
|
8
|
+
import LayoutHeaderField from './LayoutHeaderField.tsx';
|
|
9
|
+
import LayoutMultiSchemaField from './LayoutMultiSchemaField.tsx';
|
|
10
|
+
import MultiSchemaField from './MultiSchemaField.tsx';
|
|
11
|
+
import NullField from './NullField.tsx';
|
|
12
|
+
import NumberField from './NumberField.tsx';
|
|
13
|
+
import ObjectField from './ObjectField.tsx';
|
|
14
|
+
import OptionalDataControlsField from './OptionalDataControlsField.tsx';
|
|
15
|
+
import SchemaField from './SchemaField.tsx';
|
|
16
|
+
import StringField from './StringField.tsx';
|
|
17
17
|
|
|
18
18
|
function fields<
|
|
19
19
|
T = any,
|
|
@@ -3,7 +3,7 @@ import { useCallback } from 'react';
|
|
|
3
3
|
import type { BaseInputTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
4
|
import { ariaDescribedByIds, examplesId, getInputProps } from '@rjsf/utils';
|
|
5
5
|
|
|
6
|
-
import SchemaExamples from '../SchemaExamples';
|
|
6
|
+
import SchemaExamples from '../SchemaExamples.tsx';
|
|
7
7
|
|
|
8
8
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
9
9
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
@@ -73,7 +73,7 @@ export default function BaseInputTemplate<
|
|
|
73
73
|
(e: MouseEvent) => {
|
|
74
74
|
e.preventDefault();
|
|
75
75
|
e.stopPropagation();
|
|
76
|
-
onChange(options.emptyValue
|
|
76
|
+
onChange(options.emptyValue);
|
|
77
77
|
},
|
|
78
78
|
[onChange, options.emptyValue],
|
|
79
79
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
import { TranslatableString } from '@rjsf/utils';
|
|
3
3
|
|
|
4
|
-
import IconButton from './IconButton';
|
|
4
|
+
import IconButton from './IconButton.tsx';
|
|
5
5
|
|
|
6
6
|
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
7
7
|
*/
|