@rjsf/core 6.0.0-beta.2 → 6.0.0-beta.20
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 +469 -360
- package/dist/{index.js → index.cjs} +640 -519
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +706 -566
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +66 -16
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +138 -59
- package/lib/components/fields/ArrayField.d.ts +17 -7
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +92 -59
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +7 -2
- package/lib/components/fields/LayoutGridField.d.ts +27 -25
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +83 -53
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.js +3 -3
- package/lib/components/fields/LayoutMultiSchemaField.js +6 -5
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +13 -9
- 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 +3 -3
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +18 -25
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +17 -17
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +7 -2
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +2 -2
- package/lib/components/templates/ArrayFieldTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
- 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.js +2 -2
- package/lib/components/templates/UnsupportedField.js +3 -3
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +2 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +15 -18
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +2 -1
- package/lib/getTestRegistry.d.ts +5 -0
- package/lib/getTestRegistry.d.ts.map +1 -0
- package/lib/getTestRegistry.js +19 -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 +18 -19
- package/src/components/Form.tsx +183 -73
- package/src/components/fields/ArrayField.tsx +99 -67
- package/src/components/fields/BooleanField.tsx +12 -3
- package/src/components/fields/LayoutGridField.tsx +95 -82
- package/src/components/fields/LayoutHeaderField.tsx +3 -3
- package/src/components/fields/LayoutMultiSchemaField.tsx +5 -5
- package/src/components/fields/MultiSchemaField.tsx +51 -35
- package/src/components/fields/NullField.tsx +3 -3
- package/src/components/fields/NumberField.tsx +11 -3
- package/src/components/fields/ObjectField.tsx +19 -36
- package/src/components/fields/SchemaField.tsx +24 -30
- package/src/components/fields/StringField.tsx +12 -3
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +3 -3
- package/src/components/templates/BaseInputTemplate.tsx +3 -3
- 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 +5 -5
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +2 -0
- package/src/components/widgets/AltDateWidget.tsx +21 -23
- package/src/components/widgets/CheckboxWidget.tsx +2 -2
- package/src/components/widgets/CheckboxesWidget.tsx +3 -3
- package/src/components/widgets/RadioWidget.tsx +1 -1
- package/src/components/widgets/SelectWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +1 -1
- package/src/getDefaultRegistry.ts +10 -1
- package/src/getTestRegistry.tsx +34 -0
- package/src/index.ts +2 -1
- package/dist/index.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElement as _createElement } from "react";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { PureComponent } from 'react';
|
|
4
|
-
import { ANY_OF_KEY, getDiscriminatorFieldFromSchema, getTemplate, getTestIds, getUiOptions, hashObject, ID_KEY, lookupFromFormContext,
|
|
4
|
+
import { ANY_OF_KEY, getDiscriminatorFieldFromSchema, getTemplate, getTestIds, getUiOptions, hashObject, ID_KEY, lookupFromFormContext, ONE_OF_KEY, PROPERTIES_KEY, READONLY_KEY, toFieldPathId, UI_OPTIONS_KEY, UI_GLOBAL_OPTIONS_KEY, ITEMS_KEY, } from '@rjsf/utils';
|
|
5
5
|
import cloneDeep from 'lodash-es/cloneDeep.js';
|
|
6
6
|
import each from 'lodash-es/each.js';
|
|
7
7
|
import flatten from 'lodash-es/flatten.js';
|
|
@@ -16,6 +16,7 @@ import isObject from 'lodash-es/isObject.js';
|
|
|
16
16
|
import isPlainObject from 'lodash-es/isPlainObject.js';
|
|
17
17
|
import isString from 'lodash-es/isString.js';
|
|
18
18
|
import isUndefined from 'lodash-es/isUndefined.js';
|
|
19
|
+
import last from 'lodash-es/last.js';
|
|
19
20
|
import set from 'lodash-es/set.js';
|
|
20
21
|
/** The enumeration of the three different Layout GridTemplate type values
|
|
21
22
|
*/
|
|
@@ -43,9 +44,6 @@ export const LAYOUT_GRID_UI_OPTION = 'layoutGrid';
|
|
|
43
44
|
/** The constant representing the main layout grid schema option name in the `uiSchema`
|
|
44
45
|
*/
|
|
45
46
|
export const LAYOUT_GRID_OPTION = `ui:${LAYOUT_GRID_UI_OPTION}`;
|
|
46
|
-
/** The constant representing the global UI Options object potentially contained within the `uiSchema`
|
|
47
|
-
*/
|
|
48
|
-
export const UI_GLOBAL_OPTIONS = 'ui:global_options';
|
|
49
47
|
/** Returns either the `value` if it is non-nullish or the fallback
|
|
50
48
|
*
|
|
51
49
|
* @param [value] - The potential value to return if it is non-nullish
|
|
@@ -55,6 +53,14 @@ export const UI_GLOBAL_OPTIONS = 'ui:global_options';
|
|
|
55
53
|
function getNonNullishValue(value, fallback) {
|
|
56
54
|
return value ?? fallback;
|
|
57
55
|
}
|
|
56
|
+
/** Detects if a `str` is made up entirely of numeric characters
|
|
57
|
+
*
|
|
58
|
+
* @param str - The string to check to see if it is a numeric index
|
|
59
|
+
* @return - True if the string consists entirely of numeric characters
|
|
60
|
+
*/
|
|
61
|
+
function isNumericIndex(str) {
|
|
62
|
+
return /^\d+?$/.test(str); // Matches positive integers
|
|
63
|
+
}
|
|
58
64
|
/** The `LayoutGridField` will render a schema, uiSchema and formData combination out into a GridTemplate in the shape
|
|
59
65
|
* described in the uiSchema. To define the grid to use to render the elements within a field in the schema, provide in
|
|
60
66
|
* the uiSchema for that field the object contained under a `ui:layoutGrid` element. E.g. (as a JSON object):
|
|
@@ -297,7 +303,7 @@ export default class LayoutGridField extends PureComponent {
|
|
|
297
303
|
* @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
|
|
298
304
|
*/
|
|
299
305
|
static computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
300
|
-
const globalUiOptions = get(uiSchema, [
|
|
306
|
+
const globalUiOptions = get(uiSchema, [UI_GLOBAL_OPTIONS_KEY], {});
|
|
301
307
|
const localUiSchema = get(uiSchema, field);
|
|
302
308
|
const localUiOptions = { ...get(localUiSchema, [UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
|
|
303
309
|
const fieldUiSchema = { ...localUiSchema };
|
|
@@ -306,7 +312,7 @@ export default class LayoutGridField extends PureComponent {
|
|
|
306
312
|
}
|
|
307
313
|
if (!isEmpty(globalUiOptions)) {
|
|
308
314
|
// pass the global uiOptions down to the field uiSchema so that they can be applied to all nested fields
|
|
309
|
-
set(fieldUiSchema, [
|
|
315
|
+
set(fieldUiSchema, [UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
|
|
310
316
|
}
|
|
311
317
|
let { readonly: uiReadonly } = getUiOptions(fieldUiSchema);
|
|
312
318
|
if (forceReadonly === true || (isUndefined(uiReadonly) && schemaReadonly === true)) {
|
|
@@ -384,37 +390,59 @@ export default class LayoutGridField extends PureComponent {
|
|
|
384
390
|
}
|
|
385
391
|
return { children: children, gridProps };
|
|
386
392
|
}
|
|
387
|
-
/**
|
|
388
|
-
*
|
|
393
|
+
/** Computes the `rawSchema` and `fieldPathId` for a `schema` and a `potentialIndex`. If the `schema` is of type array,
|
|
394
|
+
* has an `ITEMS_KEY` element and `potentialIndex` represents a numeric value, the element at `ITEMS_KEY` is checked
|
|
395
|
+
* to see if it is an array. If it is AND the `potentialIndex`th element is available, it is used as the `rawSchema`,
|
|
396
|
+
* otherwise the last value of the element is used. If it is not, then the element is used as the `rawSchema`. In
|
|
397
|
+
* either case, an `fieldPathId` is computed for the array index. If the `schema` does not represent an array or the
|
|
398
|
+
* `potentialIndex` is not a numeric value, then `rawSchema` is returned as undefined and given `fieldPathId` is returned
|
|
399
|
+
* as is.
|
|
389
400
|
*
|
|
390
|
-
* @param
|
|
391
|
-
* @param
|
|
392
|
-
* @param
|
|
393
|
-
* @
|
|
394
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
395
|
-
* @returns - The generated `idSchema` for the `schema`
|
|
401
|
+
* @param schema - The schema to generate the fieldPathId for
|
|
402
|
+
* @param fieldPathId - The FieldPathId for the schema
|
|
403
|
+
* @param potentialIndex - A string containing a potential index
|
|
404
|
+
* @returns - An object containing the `rawSchema` and `fieldPathId` of an array item, otherwise an undefined `rawSchema`
|
|
396
405
|
*/
|
|
397
|
-
static
|
|
398
|
-
|
|
399
|
-
|
|
406
|
+
static computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
407
|
+
let rawSchema;
|
|
408
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === 'array' && has(schema, ITEMS_KEY)) {
|
|
409
|
+
const index = Number(potentialIndex);
|
|
410
|
+
const items = schema[ITEMS_KEY];
|
|
411
|
+
if (Array.isArray(items)) {
|
|
412
|
+
if (index > items.length) {
|
|
413
|
+
rawSchema = last(items);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
rawSchema = items[index];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
rawSchema = items;
|
|
421
|
+
}
|
|
422
|
+
fieldPathId = {
|
|
423
|
+
[ID_KEY]: fieldPathId[ID_KEY],
|
|
424
|
+
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index],
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
return { rawSchema, fieldPathId };
|
|
400
428
|
}
|
|
401
429
|
/** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
|
|
402
430
|
* the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
|
|
403
431
|
* element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
|
|
404
432
|
* `options`.
|
|
405
433
|
*
|
|
406
|
-
* @param
|
|
434
|
+
* @param registry - The registry
|
|
407
435
|
* @param dottedPath - The dotted-path to the field for which to get the schema
|
|
408
436
|
* @param initialSchema - The initial schema to start the search from
|
|
409
437
|
* @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
|
|
410
|
-
* @param
|
|
411
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
438
|
+
* @param initialFieldIdPath - The initial fieldPathId to start the search from
|
|
412
439
|
* @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
|
|
413
440
|
* info if a oneOf/anyOf
|
|
414
441
|
*/
|
|
415
|
-
static getSchemaDetailsForField(
|
|
442
|
+
static getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
443
|
+
const { schemaUtils, globalFormOptions } = registry;
|
|
416
444
|
let rawSchema = initialSchema;
|
|
417
|
-
let
|
|
445
|
+
let fieldPathId = initialFieldIdPath;
|
|
418
446
|
const parts = dottedPath.split('.');
|
|
419
447
|
const leafPath = parts.pop(); // pop off the last element in the list as the leaf
|
|
420
448
|
let schema = schemaUtils.retrieveSchema(rawSchema, formData); // always returns an object
|
|
@@ -423,20 +451,20 @@ export default class LayoutGridField extends PureComponent {
|
|
|
423
451
|
// For all the remaining path parts
|
|
424
452
|
parts.forEach((part) => {
|
|
425
453
|
// dive into the properties of the current schema (when it exists) and get the schema for the next part
|
|
454
|
+
fieldPathId = toFieldPathId(part, globalFormOptions, fieldPathId);
|
|
426
455
|
if (has(schema, PROPERTIES_KEY)) {
|
|
427
456
|
rawSchema = get(schema, [PROPERTIES_KEY, part], {});
|
|
428
|
-
idSchema = get(idSchema, part, {});
|
|
429
457
|
}
|
|
430
458
|
else if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
431
459
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
432
460
|
// When the schema represents a oneOf/anyOf, find the selected schema for it and grab the inner part
|
|
433
461
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
434
|
-
const selectedIdSchema = LayoutGridField.getIdSchema(schemaUtils, idSchema, formData, selectedSchema, idSeparator);
|
|
435
462
|
rawSchema = get(selectedSchema, [PROPERTIES_KEY, part], {});
|
|
436
|
-
idSchema = get(selectedIdSchema, part, {});
|
|
437
463
|
}
|
|
438
464
|
else {
|
|
439
|
-
|
|
465
|
+
const result = LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, part);
|
|
466
|
+
rawSchema = result.rawSchema ?? {};
|
|
467
|
+
fieldPathId = result.fieldPathId;
|
|
440
468
|
}
|
|
441
469
|
// Now drill into the innerData for the part, returning an empty object by default if it doesn't exist
|
|
442
470
|
innerData = get(innerData, part, {});
|
|
@@ -456,16 +484,20 @@ export default class LayoutGridField extends PureComponent {
|
|
|
456
484
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
457
485
|
// Grab the selected schema for the oneOf/anyOf value for the leafPath using the innerData
|
|
458
486
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
459
|
-
// Generate the idSchema for the oneOf/anyOf value then merge with the existing `idSchema`
|
|
460
|
-
const rawIdSchema = LayoutGridField.getIdSchema(schemaUtils, idSchema, formData, schema, idSeparator);
|
|
461
|
-
idSchema = mergeObjects(rawIdSchema, idSchema);
|
|
462
487
|
}
|
|
488
|
+
fieldPathId = toFieldPathId(leafPath, globalFormOptions, fieldPathId);
|
|
463
489
|
isRequired = schema !== undefined && Array.isArray(schema.required) && includes(schema.required, leafPath);
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
490
|
+
const result = LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
|
|
491
|
+
if (result.rawSchema) {
|
|
492
|
+
schema = result.rawSchema;
|
|
493
|
+
fieldPathId = result.fieldPathId;
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
// Now grab the schema from the leafPath of the current schema properties
|
|
497
|
+
schema = get(schema, [PROPERTIES_KEY, leafPath]);
|
|
498
|
+
// Resolve any `$ref`s for the current schema
|
|
499
|
+
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
500
|
+
}
|
|
469
501
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
470
502
|
if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
471
503
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
@@ -474,7 +506,7 @@ export default class LayoutGridField extends PureComponent {
|
|
|
474
506
|
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
475
507
|
}
|
|
476
508
|
}
|
|
477
|
-
return { schema, isRequired, isReadonly, optionsInfo,
|
|
509
|
+
return { schema, isRequired, isReadonly, optionsInfo, fieldPathId };
|
|
478
510
|
}
|
|
479
511
|
/** Gets the custom render component from the `render`, by either determining that it is either already a function or
|
|
480
512
|
* it is a non-function value that can be used to look up the function in the registry. If no function can be found,
|
|
@@ -511,7 +543,7 @@ export default class LayoutGridField extends PureComponent {
|
|
|
511
543
|
name = gridSchema ?? '';
|
|
512
544
|
}
|
|
513
545
|
else {
|
|
514
|
-
const { name: innerName, render, ...innerProps } = gridSchema;
|
|
546
|
+
const { name: innerName = '', render, ...innerProps } = gridSchema;
|
|
515
547
|
name = innerName;
|
|
516
548
|
uiProps = innerProps;
|
|
517
549
|
if (!isEmpty(uiProps)) {
|
|
@@ -545,19 +577,17 @@ export default class LayoutGridField extends PureComponent {
|
|
|
545
577
|
* elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
|
|
546
578
|
*
|
|
547
579
|
* @param dottedPath - The dotted-path to the field for which to generate the onChange handler
|
|
548
|
-
* @returns - The `onChange` handling function for the `dottedPath` field
|
|
580
|
+
* @returns - The `onChange` handling function for the `dottedPath` field of the `schemaType` type
|
|
549
581
|
*/
|
|
550
582
|
onFieldChange = (dottedPath) => {
|
|
551
|
-
return (value, errSchema, id) => {
|
|
552
|
-
const { onChange, errorSchema
|
|
553
|
-
const newFormData = cloneDeep(formData || {});
|
|
583
|
+
return (value, path, errSchema, id) => {
|
|
584
|
+
const { onChange, errorSchema } = this.props;
|
|
554
585
|
let newErrorSchema = errorSchema;
|
|
555
586
|
if (errSchema && errorSchema) {
|
|
556
587
|
newErrorSchema = cloneDeep(errorSchema);
|
|
557
588
|
set(newErrorSchema, dottedPath, errSchema);
|
|
558
589
|
}
|
|
559
|
-
|
|
560
|
-
onChange(newFormData, newErrorSchema, id);
|
|
590
|
+
onChange(value, path, newErrorSchema, id);
|
|
561
591
|
};
|
|
562
592
|
};
|
|
563
593
|
/** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
|
|
@@ -620,20 +650,20 @@ export default class LayoutGridField extends PureComponent {
|
|
|
620
650
|
const GridTemplate = getTemplate('GridTemplate', registry, uiOptions);
|
|
621
651
|
return (_jsx(GridTemplate, { ...gridProps, "data-testid": LayoutGridField.TEST_IDS.row, children: this.renderChildren(children) }));
|
|
622
652
|
}
|
|
623
|
-
/** Iterates through all the `
|
|
653
|
+
/** Iterates through all the `childrenLayoutGrfieldPathId`, rendering a nested `LayoutGridField` for each item in the
|
|
624
654
|
* list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
|
|
625
655
|
* `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
|
|
626
|
-
* `
|
|
656
|
+
* `childrenLayoutGrfieldPathId` is passed as `layoutGridSchema`.
|
|
627
657
|
*
|
|
628
|
-
* @param
|
|
658
|
+
* @param childrenLayoutGrfieldPathId - The list of strings or objects that represents the configurations for the
|
|
629
659
|
* children fields
|
|
630
660
|
* @returns - The nested `LayoutGridField`s
|
|
631
661
|
*/
|
|
632
|
-
renderChildren(
|
|
662
|
+
renderChildren(childrenLayoutGrfieldPathId) {
|
|
633
663
|
const { registry, schema: rawSchema, formData } = this.props;
|
|
634
664
|
const { schemaUtils } = registry;
|
|
635
665
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
636
|
-
return
|
|
666
|
+
return childrenLayoutGrfieldPathId.map((layoutGridSchema) => (_createElement(LayoutGridField, { ...this.props, key: `layoutGrid-${hashObject(layoutGridSchema)}`, schema: schema, layoutGridSchema: layoutGridSchema })));
|
|
637
667
|
}
|
|
638
668
|
/** Renders the field described by `gridSchema`. If `gridSchema` is not an object, then is will be assumed
|
|
639
669
|
* to be the dotted-path to the field in the schema. Otherwise, we extract the `name`, and optional `render` and all
|
|
@@ -641,7 +671,7 @@ export default class LayoutGridField extends PureComponent {
|
|
|
641
671
|
* specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
|
|
642
672
|
* and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
|
|
643
673
|
* schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
|
|
644
|
-
* `uiSchema`, `errorSchema`, `
|
|
674
|
+
* `uiSchema`, `errorSchema`, `fieldPathId` and `formData` drilled down to the dotted-path field, spreading any other
|
|
645
675
|
* props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
|
|
646
676
|
* then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
|
|
647
677
|
* schema was located, but a custom render component was found, then it will be rendered with many of the non-event
|
|
@@ -651,16 +681,16 @@ export default class LayoutGridField extends PureComponent {
|
|
|
651
681
|
* @returns - One of `LayoutMultiSchemaField`, `SchemaField`, a custom render component or null, depending
|
|
652
682
|
*/
|
|
653
683
|
renderField(gridSchema) {
|
|
654
|
-
const { schema: initialSchema, uiSchema, errorSchema,
|
|
684
|
+
const { schema: initialSchema, uiSchema, errorSchema, fieldPathId, onBlur, onFocus, formData, readonly, registry, layoutGridSchema, // Used to pull this out of otherProps since we don't want to pass it through
|
|
655
685
|
...otherProps } = this.props;
|
|
656
|
-
const { fields
|
|
686
|
+
const { fields } = registry;
|
|
657
687
|
const { SchemaField, LayoutMultiSchemaField } = fields;
|
|
658
688
|
const uiComponentProps = LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema);
|
|
659
689
|
if (uiComponentProps.rendered) {
|
|
660
690
|
return uiComponentProps.rendered;
|
|
661
691
|
}
|
|
662
692
|
const { name, UIComponent, uiProps } = uiComponentProps;
|
|
663
|
-
const { schema, isRequired, isReadonly, optionsInfo,
|
|
693
|
+
const { schema, isRequired, isReadonly, optionsInfo, fieldPathId: fieldIdSchema, } = LayoutGridField.getSchemaDetailsForField(registry, name, initialSchema, formData, fieldPathId);
|
|
664
694
|
if (schema) {
|
|
665
695
|
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField : SchemaField;
|
|
666
696
|
// Call this function to get the appropriate UISchema, which will always have its `readonly` state matching the
|
|
@@ -671,10 +701,10 @@ export default class LayoutGridField extends PureComponent {
|
|
|
671
701
|
const { fieldUiSchema, uiReadonly } = LayoutGridField.computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
672
702
|
return (_jsx(Field, { "data-testid": optionsInfo?.hasDiscriminator
|
|
673
703
|
? LayoutGridField.TEST_IDS.layoutMultiSchemaField
|
|
674
|
-
: LayoutGridField.TEST_IDS.field, ...otherProps, name: name, required: isRequired, readonly: uiReadonly, schema: schema, uiSchema: fieldUiSchema, errorSchema: get(errorSchema, name),
|
|
704
|
+
: LayoutGridField.TEST_IDS.field, ...otherProps, name: name, required: isRequired, readonly: uiReadonly, schema: schema, uiSchema: fieldUiSchema, errorSchema: get(errorSchema, name), fieldPathId: fieldIdSchema, formData: get(formData, name), onChange: this.onFieldChange(name), onBlur: onBlur, onFocus: onFocus, options: optionsInfo?.options, registry: registry }));
|
|
675
705
|
}
|
|
676
706
|
if (UIComponent) {
|
|
677
|
-
return (_jsx(UIComponent, { "data-testid": LayoutGridField.TEST_IDS.uiComponent, ...otherProps, name: name, required: isRequired, formData: formData, readOnly: !!isReadonly || readonly, errorSchema: errorSchema, uiSchema: uiSchema, schema: initialSchema,
|
|
707
|
+
return (_jsx(UIComponent, { "data-testid": LayoutGridField.TEST_IDS.uiComponent, ...otherProps, name: name, required: isRequired, formData: formData, readOnly: !!isReadonly || readonly, errorSchema: errorSchema, uiSchema: uiSchema, schema: initialSchema, fieldPathId: fieldPathId, onBlur: onBlur, onFocus: onFocus, registry: registry, ...uiProps }));
|
|
678
708
|
}
|
|
679
709
|
return null;
|
|
680
710
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
-
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `
|
|
2
|
+
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
|
|
3
3
|
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
4
4
|
* - If there is a title in the `uiSchema`, it is displayed
|
|
5
5
|
* - Else, if there is an explicit `title` passed in the props, it is displayed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
|
|
3
|
-
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `
|
|
3
|
+
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
|
|
4
4
|
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
5
5
|
* - If there is a title in the `uiSchema`, it is displayed
|
|
6
6
|
* - Else, if there is an explicit `title` passed in the props, it is displayed
|
|
@@ -10,7 +10,7 @@ import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
|
|
|
10
10
|
* @param props - The `LayoutHeaderField` for the component
|
|
11
11
|
*/
|
|
12
12
|
export default function LayoutHeaderField(props) {
|
|
13
|
-
const {
|
|
13
|
+
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
14
14
|
const options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
15
15
|
const { title: uiTitle } = options;
|
|
16
16
|
const { title: schemaTitle } = schema;
|
|
@@ -19,5 +19,5 @@ export default function LayoutHeaderField(props) {
|
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
22
|
-
return (_jsx(TitleFieldTemplate, { id: titleId(
|
|
22
|
+
return (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: fieldTitle, required: required, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
23
23
|
}
|
|
@@ -55,10 +55,10 @@ export function computeEnumOptions(schema, options, schemaUtils, uiSchema, formD
|
|
|
55
55
|
* is active. If no `selectorField` is specified, then an error is thrown.
|
|
56
56
|
*/
|
|
57
57
|
export default function LayoutMultiSchemaField(props) {
|
|
58
|
-
const { name, baseType, disabled = false, formData,
|
|
58
|
+
const { name, baseType, disabled = false, formData, fieldPathId, onBlur, onChange, options, onFocus, registry, uiSchema, schema, formContext, autofocus, readonly, required, errorSchema, hideError = false, } = props;
|
|
59
59
|
const { widgets, schemaUtils, globalUiOptions } = registry;
|
|
60
60
|
const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
61
|
-
const id = get(
|
|
61
|
+
const id = get(fieldPathId, ID_KEY);
|
|
62
62
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
63
63
|
const FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, options);
|
|
64
64
|
const FieldTemplate = getTemplate('FieldTemplate', registry, options);
|
|
@@ -104,11 +104,12 @@ export default function LayoutMultiSchemaField(props) {
|
|
|
104
104
|
if (newFormData) {
|
|
105
105
|
set(newFormData, selectorField, opt);
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
// Pass the component name in the path
|
|
108
|
+
onChange(newFormData, fieldPathId.path, undefined, id);
|
|
108
109
|
};
|
|
109
110
|
// filtering the options based on the type of widget because `selectField` does not recognize the `convertOther` prop
|
|
110
111
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
111
|
-
const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, {
|
|
112
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, { fieldPathId: fieldPathId, schema: schema, errors: rawErrors, registry: registry })) : undefined;
|
|
112
113
|
const ignored = (value) => noop;
|
|
113
|
-
return (_jsx(FieldTemplate, { id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema,
|
|
114
|
+
return (_jsx(FieldTemplate, { id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, required: required, readonly: !!readonly, registry: registry, displayLabel: displayLabel, errors: errors, onChange: onChange, onDropPropertyClick: ignored, onKeyChange: ignored, children: _jsx(Widget, { id: id, name: name, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, formContext: formContext, autofocus: autofocus, readonly: readonly, required: required, registry: registry, multiple: false, rawErrors: rawErrors, hideError: hideFieldError, hideLabel: !displayLabel, errorSchema: fieldErrorSchema, placeholder: placeholder, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, value: selectedOption, options: widgetOptions }) }));
|
|
114
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAIL,UAAU,EACV,eAAe,
|
|
1
|
+
{"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAIL,UAAU,EACV,eAAe,EAOf,UAAU,EACV,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAErB,4DAA4D;AAC5D,KAAK,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,IAAI;IAC9D,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,CAAC,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,cAAM,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACnH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,eAAe,CAAC,CAAC,CAAC,CACnB;IACC;;;OAGG;gBACS,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAiBtC;;;;;OAKG;IACH,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC;IAyBjG;;;;;OAKG;IACH,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;IAW/E;;;;;OAKG;IACH,cAAc,GAAI,SAAS,MAAM,UAqB/B;IAEF,UAAU;IAKV;OACG;IACH,MAAM;CAyHP;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import get from 'lodash-es/get.js';
|
|
4
4
|
import isEmpty from 'lodash-es/isEmpty.js';
|
|
5
5
|
import omit from 'lodash-es/omit.js';
|
|
6
|
-
import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getUiOptions, getWidget, mergeSchemas, ONE_OF_KEY, TranslatableString, } from '@rjsf/utils';
|
|
6
|
+
import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getTemplate, getUiOptions, getWidget, mergeSchemas, ONE_OF_KEY, TranslatableString, } from '@rjsf/utils';
|
|
7
7
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
8
8
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
9
9
|
*
|
|
@@ -31,7 +31,7 @@ class AnyOfField extends Component {
|
|
|
31
31
|
* @param prevState - The previous `AnyOfFieldState` for this template
|
|
32
32
|
*/
|
|
33
33
|
componentDidUpdate(prevProps, prevState) {
|
|
34
|
-
const { formData, options,
|
|
34
|
+
const { formData, options, fieldPathId } = this.props;
|
|
35
35
|
const { selectedOption } = this.state;
|
|
36
36
|
let newState = this.state;
|
|
37
37
|
if (!deepEquals(prevProps.options, options)) {
|
|
@@ -40,7 +40,7 @@ class AnyOfField extends Component {
|
|
|
40
40
|
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
41
41
|
newState = { selectedOption, retrievedOptions };
|
|
42
42
|
}
|
|
43
|
-
if (!deepEquals(formData, prevProps.formData) &&
|
|
43
|
+
if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
44
44
|
const { retrievedOptions } = newState;
|
|
45
45
|
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
46
46
|
if (prevState && matchingOption !== selectedOption) {
|
|
@@ -71,7 +71,7 @@ class AnyOfField extends Component {
|
|
|
71
71
|
*/
|
|
72
72
|
onOptionChange = (option) => {
|
|
73
73
|
const { selectedOption, retrievedOptions } = this.state;
|
|
74
|
-
const { formData, onChange, registry } = this.props;
|
|
74
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
75
75
|
const { schemaUtils } = registry;
|
|
76
76
|
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
77
77
|
if (intOption === selectedOption) {
|
|
@@ -86,12 +86,12 @@ class AnyOfField extends Component {
|
|
|
86
86
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
87
87
|
}
|
|
88
88
|
this.setState({ selectedOption: intOption }, () => {
|
|
89
|
-
onChange(newFormData, undefined, this.getFieldId());
|
|
89
|
+
onChange(newFormData, fieldPathId.path, undefined, this.getFieldId());
|
|
90
90
|
});
|
|
91
91
|
};
|
|
92
92
|
getFieldId() {
|
|
93
|
-
const {
|
|
94
|
-
return `${
|
|
93
|
+
const { fieldPathId, schema } = this.props;
|
|
94
|
+
return `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
|
|
95
95
|
}
|
|
96
96
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
97
97
|
*/
|
|
@@ -99,6 +99,7 @@ class AnyOfField extends Component {
|
|
|
99
99
|
const { name, disabled = false, errorSchema = {}, formContext, onBlur, onFocus, readonly, registry, schema, uiSchema, } = this.props;
|
|
100
100
|
const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
|
|
101
101
|
const { SchemaField: _SchemaField } = fields;
|
|
102
|
+
const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
|
|
102
103
|
const { selectedOption, retrievedOptions } = this.state;
|
|
103
104
|
const { widget = 'select', placeholder, autofocus, autocomplete, title = schema.title, ...uiOptions } = getUiOptions(uiSchema, globalUiOptions);
|
|
104
105
|
const Widget = getWidget({ type: 'number' }, widget, widgets);
|
|
@@ -148,7 +149,10 @@ class AnyOfField extends Component {
|
|
|
148
149
|
value: index,
|
|
149
150
|
};
|
|
150
151
|
});
|
|
151
|
-
|
|
152
|
+
const selector = (_jsx(Widget, { id: this.getFieldId(), name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: this.onOptionChange, onBlur: onBlur, onFocus: onFocus, disabled: disabled || isEmpty(enumOptions), multiple: false, rawErrors: rawErrors, errorSchema: fieldErrorSchema, value: selectedOption >= 0 ? selectedOption : undefined, options: { enumOptions, ...uiOptions }, registry: registry, formContext: formContext, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly }));
|
|
153
|
+
const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
|
|
154
|
+
null;
|
|
155
|
+
return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
export default AnyOfField;
|
|
@@ -5,12 +5,12 @@ import { useEffect } from 'react';
|
|
|
5
5
|
* @param props - The `FieldProps` for this template
|
|
6
6
|
*/
|
|
7
7
|
function NullField(props) {
|
|
8
|
-
const { formData, onChange } = props;
|
|
8
|
+
const { name, formData, onChange } = props;
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
if (formData === undefined) {
|
|
11
|
-
onChange(null);
|
|
11
|
+
onChange(null, [name]);
|
|
12
12
|
}
|
|
13
|
-
}, [formData, onChange]);
|
|
13
|
+
}, [name, formData, onChange]);
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
export default NullField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAcrB;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkD3B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback } from 'react';
|
|
3
|
-
import { asNumber } from '@rjsf/utils';
|
|
3
|
+
import { asNumber, } from '@rjsf/utils';
|
|
4
4
|
// Matches a string that ends in a . character, optionally followed by a sequence of
|
|
5
5
|
// digits followed by any number of 0 characters up until the end of the line.
|
|
6
6
|
// Ensuring that there is at least one prefixed character is important so that
|
|
@@ -37,7 +37,7 @@ function NumberField(props) {
|
|
|
37
37
|
*
|
|
38
38
|
* @param value - The current value for the change occurring
|
|
39
39
|
*/
|
|
40
|
-
const handleChange = useCallback((value, errorSchema, id) => {
|
|
40
|
+
const handleChange = useCallback((value, path, errorSchema, id) => {
|
|
41
41
|
// Cache the original value in component state
|
|
42
42
|
setLastValue(value);
|
|
43
43
|
// Normalize decimals that don't start with a zero character in advance so
|
|
@@ -51,7 +51,7 @@ function NumberField(props) {
|
|
|
51
51
|
const processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix)
|
|
52
52
|
? asNumber(value.replace(trailingCharMatcher, ''))
|
|
53
53
|
: asNumber(value);
|
|
54
|
-
onChange(processed, errorSchema, id);
|
|
54
|
+
onChange(processed, path, errorSchema, id);
|
|
55
55
|
}, [onChange]);
|
|
56
56
|
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
57
57
|
// Construct a regular expression that checks for a string that consists
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { ErrorSchema, FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { ErrorSchema, FieldPathList, FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
/** Type used for the state of the `ObjectField` component */
|
|
4
4
|
type ObjectFieldState = {
|
|
5
5
|
/** Flag indicating whether an additional property key was modified */
|
|
@@ -32,7 +32,7 @@ declare class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
32
32
|
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
33
33
|
* @returns - The onPropertyChange callback for the `name` property
|
|
34
34
|
*/
|
|
35
|
-
onPropertyChange: (name: string, addedByAdditionalProperties?: boolean) => (value: T | undefined, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
|
|
35
|
+
onPropertyChange: (name: string, addedByAdditionalProperties?: boolean) => (value: T | undefined, path: FieldPathList, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
|
|
36
36
|
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
37
37
|
* and calls the `onChange` callback with it
|
|
38
38
|
*
|
|
@@ -54,7 +54,7 @@ declare class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
54
54
|
* @param oldValue - The old value of a field
|
|
55
55
|
* @returns - The key change callback function
|
|
56
56
|
*/
|
|
57
|
-
onKeyChange: (oldValue: any) => (value: any
|
|
57
|
+
onKeyChange: (oldValue: any) => (value: any) => void;
|
|
58
58
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
59
59
|
*
|
|
60
60
|
* @param type - The type of the new additional schema property
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAKL,WAAW,EACX,aAAa,EACb,UAAU,EACV,eAAe,EAEf,UAAU,EACV,gBAAgB,EAOjB,MAAM,aAAa,CAAC;AAQrB,6DAA6D;AAC7D,KAAK,gBAAgB,GAAG;IACtB,sEAAsE;IACtE,sBAAsB,EAAE,OAAO,CAAC;IAChC,uCAAuC;IACvC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,cAAM,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACpH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,gBAAgB,CACjB;IACC,+BAA+B;IAC/B,KAAK;;;MAGH;IAEF;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM;IAKvB;;;;;;;OAOG;IACH,gBAAgB,GAAI,MAAM,MAAM,EAAE,qCAAmC,MAC3D,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,aAAa,EAAE,iBAAiB,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,UAc/F;IAEF;;;;;OAKG;IACH,mBAAmB,GAAI,KAAK,MAAM,MACxB,OAAO,SAAS,UAQxB;IAEF;;;;;;OAMG;IACH,eAAe,GAAI,cAAc,MAAM,EAAE,WAAW,CAAC,YAUnD;IAEF;;;;;OAKG;IACH,WAAW,GAAI,UAAU,GAAG,MAClB,OAAO,GAAG,UAqBlB;IAEF;;;OAGG;IACH,eAAe,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC;IAsBzC;;;;OAIG;IACH,cAAc,GAAI,QAAQ,CAAC,gBAsCzB;IAEF;OACG;IACH,MAAM;CAmGP;AAED,eAAe,WAAW,CAAC"}
|