@rjsf/utils 6.4.2 → 6.5.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.
Files changed (40) hide show
  1. package/dist/index.cjs +198 -84
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/utils.esm.js +198 -84
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +185 -80
  6. package/lib/enumOptionSelectedValue.d.ts +15 -0
  7. package/lib/enumOptionSelectedValue.js +28 -0
  8. package/lib/enumOptionSelectedValue.js.map +1 -0
  9. package/lib/enumOptionValueDecoder.d.ts +17 -0
  10. package/lib/enumOptionValueDecoder.js +53 -0
  11. package/lib/enumOptionValueDecoder.js.map +1 -0
  12. package/lib/enumOptionValueEncoder.d.ts +15 -0
  13. package/lib/enumOptionValueEncoder.js +27 -0
  14. package/lib/enumOptionValueEncoder.js.map +1 -0
  15. package/lib/getInputProps.js +9 -0
  16. package/lib/getInputProps.js.map +1 -1
  17. package/lib/getOptionValueFormat.d.ts +16 -0
  18. package/lib/getOptionValueFormat.js +17 -0
  19. package/lib/getOptionValueFormat.js.map +1 -0
  20. package/lib/index.d.ts +7 -2
  21. package/lib/index.js +7 -2
  22. package/lib/index.js.map +1 -1
  23. package/lib/removeOptionalEmptyObjects.d.ts +17 -0
  24. package/lib/removeOptionalEmptyObjects.js +108 -0
  25. package/lib/removeOptionalEmptyObjects.js.map +1 -0
  26. package/lib/resolveUiSchema.d.ts +5 -19
  27. package/lib/resolveUiSchema.js +49 -95
  28. package/lib/resolveUiSchema.js.map +1 -1
  29. package/lib/tsconfig.tsbuildinfo +1 -1
  30. package/lib/types.d.ts +27 -1
  31. package/package.json +4 -4
  32. package/src/enumOptionSelectedValue.ts +39 -0
  33. package/src/enumOptionValueDecoder.ts +64 -0
  34. package/src/enumOptionValueEncoder.ts +33 -0
  35. package/src/getInputProps.ts +10 -0
  36. package/src/getOptionValueFormat.ts +17 -0
  37. package/src/index.ts +11 -2
  38. package/src/removeOptionalEmptyObjects.ts +127 -0
  39. package/src/resolveUiSchema.ts +55 -122
  40. package/src/types.ts +28 -1
package/lib/index.js CHANGED
@@ -8,6 +8,9 @@ import dateRangeOptions from './dateRangeOptions.js';
8
8
  import deepEquals from './deepEquals.js';
9
9
  import shallowEquals from './shallowEquals.js';
10
10
  import englishStringTranslator from './englishStringTranslator.js';
11
+ import enumOptionSelectedValue from './enumOptionSelectedValue.js';
12
+ import enumOptionValueDecoder from './enumOptionValueDecoder.js';
13
+ import enumOptionValueEncoder from './enumOptionValueEncoder.js';
11
14
  import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
12
15
  import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
13
16
  import enumOptionsIsSelected from './enumOptionsIsSelected.js';
@@ -20,6 +23,7 @@ import getDateElementProps from './getDateElementProps.js';
20
23
  import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.js';
21
24
  import getInputProps from './getInputProps.js';
22
25
  import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator.js';
26
+ import getOptionValueFormat from './getOptionValueFormat.js';
23
27
  import getSchemaType from './getSchemaType.js';
24
28
  import getSubmitButtonOptions from './getSubmitButtonOptions.js';
25
29
  import getTemplate from './getTemplate.js';
@@ -43,12 +47,13 @@ import mergeDefaultsWithFormData from './mergeDefaultsWithFormData.js';
43
47
  import mergeObjects from './mergeObjects.js';
44
48
  import mergeSchemas from './mergeSchemas.js';
45
49
  import optionsList from './optionsList.js';
50
+ import removeOptionalEmptyObjects from './removeOptionalEmptyObjects.js';
46
51
  import orderProperties from './orderProperties.js';
47
52
  import pad from './pad.js';
48
53
  import parseDateString from './parseDateString.js';
49
54
  import rangeSpec from './rangeSpec.js';
50
55
  import replaceStringParameters from './replaceStringParameters.js';
51
- import resolveUiSchema, { expandUiSchemaDefinitions } from './resolveUiSchema.js';
56
+ import resolveUiSchema from './resolveUiSchema.js';
52
57
  import schemaRequiresTrueValue from './schemaRequiresTrueValue.js';
53
58
  import shouldRender from './shouldRender.js';
54
59
  import shouldRenderOptionalField from './shouldRenderOptionalField.js';
@@ -70,5 +75,5 @@ export * from './enums.js';
70
75
  export * from './constants.js';
71
76
  export * from './parser/index.js';
72
77
  export * from './schema/index.js';
73
- export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElement, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isFormDataAvailable, isObject, isRootSchema, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionalControlsId, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, resolveUiSchema, expandUiSchemaDefinitions, schemaRequiresTrueValue, shallowEquals, shouldRender, shouldRenderOptionalField, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toFieldPathId, unwrapErrorHandler, useAltDateWidgetProps, useDeepCompareMemo, useFileWidgetProps, utcToLocal, validationDataMerge, withIdRefPrefix, bracketNameGenerator, dotNotationNameGenerator, };
78
+ export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElement, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionSelectedValue, enumOptionValueDecoder, enumOptionValueEncoder, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getOptionValueFormat, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isFormDataAvailable, isObject, isRootSchema, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionalControlsId, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, removeOptionalEmptyObjects, replaceStringParameters, resolveUiSchema, schemaRequiresTrueValue, shallowEquals, shouldRender, shouldRenderOptionalField, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toFieldPathId, unwrapErrorHandler, useAltDateWidgetProps, useDeepCompareMemo, useFileWidgetProps, utcToLocal, validationDataMerge, withIdRefPrefix, bracketNameGenerator, dotNotationNameGenerator, };
74
79
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;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AAU,CAAC;AAYzB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,EAC/B,aAAa,EACb,oCAAoC,EACpC,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,EACN,UAAU,EACV,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,eAAe,EACf,GAAG,EACH,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,GACzB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACp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AU,EACV,UAAU,EACV,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,eAAe,EACf,GAAG,EACH,eAAe,EACf,SAAS,EACT,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,wBAAwB,GACzB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from './types.js';
2
+ /** Recursively removes optional objects from the `formData` that are empty (i.e., all their fields
3
+ * are undefined, null, empty strings, or themselves empty optional objects). This solves the problem
4
+ * where interacting with fields inside an optional object "activates" it permanently, making the
5
+ * form unsubmittable when the optional object has required inner fields.
6
+ *
7
+ * An object property is considered "optional" when it is NOT listed in its parent schema's `required`
8
+ * array.
9
+ *
10
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
11
+ * @param schema - The JSON schema describing the `formData`
12
+ * @param [rootSchema] - The root schema, used primarily to look up `$ref`s
13
+ * @param [formData] - The current form data to prune
14
+ * @returns - A new copy of `formData` with empty optional objects removed, or `undefined` if the
15
+ * entire formData was pruned
16
+ */
17
+ export default function removeOptionalEmptyObjects<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, rootSchema?: S, formData?: T): T | undefined;
@@ -0,0 +1,108 @@
1
+ import isNil from 'lodash-es/isNil.js';
2
+ import isObject from './isObject.js';
3
+ import retrieveSchema from './schema/retrieveSchema.js';
4
+ /** Determines whether a value is considered "empty" for the purposes of optional object pruning.
5
+ * A value is empty if it is `undefined`, `null`, an empty string, or an object where all own
6
+ * properties are themselves empty.
7
+ *
8
+ * @param value - The value to check
9
+ * @returns True if the value is considered empty
10
+ */
11
+ function isValueEmpty(value) {
12
+ if (isNil(value) || value === '') {
13
+ return true;
14
+ }
15
+ if (Array.isArray(value)) {
16
+ // An empty array is considered empty; a non-empty array is not
17
+ return value.length === 0;
18
+ }
19
+ if (isObject(value)) {
20
+ const obj = value;
21
+ const keys = Object.keys(obj);
22
+ return keys.every((key) => isValueEmpty(obj[key]));
23
+ }
24
+ return false;
25
+ }
26
+ /** Recursively removes optional objects from the `formData` that are empty (i.e., all their fields
27
+ * are undefined, null, empty strings, or themselves empty optional objects). This solves the problem
28
+ * where interacting with fields inside an optional object "activates" it permanently, making the
29
+ * form unsubmittable when the optional object has required inner fields.
30
+ *
31
+ * An object property is considered "optional" when it is NOT listed in its parent schema's `required`
32
+ * array.
33
+ *
34
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
35
+ * @param schema - The JSON schema describing the `formData`
36
+ * @param [rootSchema] - The root schema, used primarily to look up `$ref`s
37
+ * @param [formData] - The current form data to prune
38
+ * @returns - A new copy of `formData` with empty optional objects removed, or `undefined` if the
39
+ * entire formData was pruned
40
+ */
41
+ export default function removeOptionalEmptyObjects(validator, schema, rootSchema, formData) {
42
+ if (!isObject(schema)) {
43
+ return formData;
44
+ }
45
+ const resolvedSchema = retrieveSchema(validator, schema, rootSchema, formData);
46
+ if (Array.isArray(formData)) {
47
+ const itemsSchema = resolvedSchema.items;
48
+ if (!itemsSchema) {
49
+ return formData;
50
+ }
51
+ let hasChanges = false;
52
+ const mapped = formData.map((item, index) => {
53
+ let itemSchema = itemsSchema;
54
+ if (Array.isArray(itemsSchema)) {
55
+ itemSchema = itemsSchema[index] || resolvedSchema.additionalItems || {};
56
+ }
57
+ const cleaned = removeOptionalEmptyObjects(validator, itemSchema, rootSchema, item);
58
+ if (cleaned !== item) {
59
+ hasChanges = true;
60
+ }
61
+ return cleaned === undefined ? {} : cleaned;
62
+ });
63
+ // Although T is an array type here, we still need to cast it back to T since TS
64
+ // doesn't narrow the generic T automatically
65
+ return hasChanges ? mapped : formData;
66
+ }
67
+ const { properties, required: requiredFields = [] } = resolvedSchema;
68
+ if (!isObject(formData) || !properties) {
69
+ return formData;
70
+ }
71
+ const result = {};
72
+ const data = formData;
73
+ let hasAnyValue = false;
74
+ for (const key of Object.keys(data)) {
75
+ const value = data[key];
76
+ const propertySchema = (properties[key] || {});
77
+ const isRequired = requiredFields.includes(key);
78
+ const isObj = isObject(value);
79
+ const isArr = Array.isArray(value);
80
+ if ((isObj || isArr) && properties[key]) {
81
+ // Recursively process nested objects and arrays
82
+ const cleaned = removeOptionalEmptyObjects(validator, propertySchema, rootSchema, value);
83
+ if (!isRequired && isValueEmpty(cleaned)) {
84
+ // This is an optional property and the cleaned result is empty — omit it
85
+ continue;
86
+ }
87
+ result[key] = cleaned;
88
+ hasAnyValue = true;
89
+ }
90
+ else if (!isRequired && isValueEmpty(value) && properties[key]) {
91
+ // Optional scalar property that is empty — omit it
92
+ continue;
93
+ }
94
+ else {
95
+ result[key] = value;
96
+ if (!isValueEmpty(value)) {
97
+ hasAnyValue = true;
98
+ }
99
+ }
100
+ }
101
+ // If the entire object ended up empty after pruning, return undefined so that the
102
+ // caller (which may itself be a recursive call) can decide whether to keep or drop it
103
+ if (!hasAnyValue && Object.keys(result).length === 0) {
104
+ return undefined;
105
+ }
106
+ return result;
107
+ }
108
+ //# sourceMappingURL=removeOptionalEmptyObjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeOptionalEmptyObjects.js","sourceRoot":"","sources":["../src/removeOptionalEmptyObjects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,cAAc,MAAM,yBAAyB,CAAC;AAErD;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,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nC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxC,gDAAgD;YAChD,MAAM,OAAO,GAAG,0BAA0B,CAAU,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,KAAU,CAAC,CAAC;YAEvG,IAAI,CAAC,UAAU,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,yEAAyE;gBACzE,SAAS;YACX,CAAC;YAED,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;YACtB,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,IAAI,CAAC,UAAU,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACjE,mDAAmD;YACnD,SAAS;QACX,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,WAAW,GAAG,IAAI,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,kFAAkF;IAClF,sFAAsF;IACtF,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
@@ -1,30 +1,16 @@
1
1
  import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.js';
2
- /** Expands `ui:definitions` into the uiSchema by walking the schema tree and finding all `$ref`s.
3
- * Called once at form initialization to pre-expand definitions into the uiSchema structure.
4
- *
5
- * For recursive schemas, expansion stops at recursion points to avoid infinite loops.
6
- * Runtime resolution via `resolveUiSchema` handles these cases using registry definitions.
7
- *
8
- * @param currentSchema - The current schema node being processed
9
- * @param uiSchema - The uiSchema at the current path
10
- * @param registry - The registry containing rootSchema and uiSchemaDefinitions
11
- * @param visited - Set of $refs already visited (to detect recursion)
12
- * @returns - The expanded uiSchema with definitions merged in
13
- */
14
- export declare function expandUiSchemaDefinitions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(currentSchema: S, uiSchema: UiSchema<T, S, F>, registry: Registry<T, S, F>, visited?: Set<string>): UiSchema<T, S, F>;
15
2
  /** Resolves the uiSchema for a given schema, considering `ui:definitions` stored in the registry.
16
3
  *
17
- * This function is called at runtime for each field. It handles recursive schemas where the
18
- * pre-expansion in `expandUiSchemaDefinitions` couldn't go deeper.
19
- *
20
- * When the schema contains a `$ref`, this function looks up the corresponding uiSchema definition
21
- * from `registry.uiSchemaDefinitions` and merges it with any local uiSchema overrides.
4
+ * Called at runtime for each field. When the schema contains a `$ref`, looks up the corresponding
5
+ * uiSchema definition from `registry.uiSchemaDefinitions` and merges it with local overrides.
6
+ * For schemas with `oneOf`/`anyOf` branches, also populates `uiSchema[keyword][i]` for branches
7
+ * whose `$ref` matches a definition, so `MultiSchemaField` can read dropdown option titles.
22
8
  *
23
9
  * Resolution order (later sources override earlier):
24
10
  * 1. `ui:definitions[$ref]` - base definition from registry
25
11
  * 2. `localUiSchema` - local overrides at current path
26
12
  *
27
- * @param schema - The JSON schema (may still contain `$ref` for recursive schemas)
13
+ * @param schema - The JSON schema (may contain `$ref` or `RJSF_REF_KEY`)
28
14
  * @param localUiSchema - The uiSchema at the current path (local overrides)
29
15
  * @param registry - The registry containing `uiSchemaDefinitions`
30
16
  * @returns - The resolved uiSchema with definitions merged in
@@ -1,82 +1,65 @@
1
- import { ADDITIONAL_PROPERTIES_KEY, ALL_OF_KEY, ANY_OF_KEY, ITEMS_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, RJSF_REF_KEY, } from './constants.js';
1
+ import isEmpty from 'lodash-es/isEmpty.js';
2
+ import { ANY_OF_KEY, ONE_OF_KEY, REF_KEY, RJSF_REF_KEY } from './constants.js';
2
3
  import findSchemaDefinition from './findSchemaDefinition.js';
3
- import isObject from './isObject.js';
4
4
  import mergeObjects from './mergeObjects.js';
5
- // Keywords where child schemas map to uiSchema at the SAME key
6
- const SAME_KEY_KEYWORDS = [ITEMS_KEY, ADDITIONAL_PROPERTIES_KEY];
7
- // Keywords where child schemas are in an array, each mapping to uiSchema[keyword][i]
8
- const ARRAY_KEYWORDS = [ONE_OF_KEY, ANY_OF_KEY, ALL_OF_KEY];
9
- /** Expands `ui:definitions` into the uiSchema by walking the schema tree and finding all `$ref`s.
10
- * Called once at form initialization to pre-expand definitions into the uiSchema structure.
5
+ /** Resolves the uiSchema for a given schema, considering `ui:definitions` stored in the registry.
6
+ *
7
+ * Called at runtime for each field. When the schema contains a `$ref`, looks up the corresponding
8
+ * uiSchema definition from `registry.uiSchemaDefinitions` and merges it with local overrides.
9
+ * For schemas with `oneOf`/`anyOf` branches, also populates `uiSchema[keyword][i]` for branches
10
+ * whose `$ref` matches a definition, so `MultiSchemaField` can read dropdown option titles.
11
11
  *
12
- * For recursive schemas, expansion stops at recursion points to avoid infinite loops.
13
- * Runtime resolution via `resolveUiSchema` handles these cases using registry definitions.
12
+ * Resolution order (later sources override earlier):
13
+ * 1. `ui:definitions[$ref]` - base definition from registry
14
+ * 2. `localUiSchema` - local overrides at current path
14
15
  *
15
- * @param currentSchema - The current schema node being processed
16
- * @param uiSchema - The uiSchema at the current path
17
- * @param registry - The registry containing rootSchema and uiSchemaDefinitions
18
- * @param visited - Set of $refs already visited (to detect recursion)
19
- * @returns - The expanded uiSchema with definitions merged in
16
+ * @param schema - The JSON schema (may contain `$ref` or `RJSF_REF_KEY`)
17
+ * @param localUiSchema - The uiSchema at the current path (local overrides)
18
+ * @param registry - The registry containing `uiSchemaDefinitions`
19
+ * @returns - The resolved uiSchema with definitions merged in
20
20
  */
21
- export function expandUiSchemaDefinitions(currentSchema, uiSchema, registry, visited = new Set()) {
22
- const { rootSchema, uiSchemaDefinitions: definitions } = registry;
23
- let result = { ...uiSchema };
24
- let resolvedSchema = currentSchema;
25
- const ref = currentSchema[REF_KEY];
26
- const isRecursive = ref && visited.has(ref);
27
- if (ref) {
28
- visited.add(ref);
29
- if (definitions && ref in definitions) {
30
- result = mergeObjects(definitions[ref], result);
31
- }
32
- if (isRecursive) {
33
- return result;
34
- }
35
- try {
36
- resolvedSchema = findSchemaDefinition(ref, rootSchema);
37
- }
38
- catch (_a) {
39
- resolvedSchema = currentSchema;
40
- }
21
+ export default function resolveUiSchema(schema, localUiSchema, registry) {
22
+ var _a, _b;
23
+ const ref = ((_a = schema[RJSF_REF_KEY]) !== null && _a !== void 0 ? _a : schema[REF_KEY]);
24
+ const definitions = registry.uiSchemaDefinitions;
25
+ const definitionUiSchema = ref && definitions ? definitions[ref] : undefined;
26
+ let result;
27
+ if (!definitionUiSchema) {
28
+ result = localUiSchema || {};
41
29
  }
42
- // Process properties (each property maps to uiSchema[propName] - flattened)
43
- const properties = resolvedSchema[PROPERTIES_KEY];
44
- if (properties && isObject(properties)) {
45
- for (const [propName, propSchema] of Object.entries(properties)) {
46
- const propUiSchema = (result[propName] || {});
47
- const expanded = expandUiSchemaDefinitions(propSchema, propUiSchema, registry, new Set(visited));
48
- if (Object.keys(expanded).length > 0) {
49
- result[propName] = expanded;
50
- }
51
- }
30
+ else if (!localUiSchema || isEmpty(localUiSchema)) {
31
+ result = { ...definitionUiSchema };
52
32
  }
53
- // Process keywords where child maps to same key in uiSchema (items, additionalProperties)
54
- for (const keyword of SAME_KEY_KEYWORDS) {
55
- const subSchema = resolvedSchema[keyword];
56
- if (subSchema && isObject(subSchema) && !Array.isArray(subSchema)) {
57
- const currentUiSchema = result[keyword];
58
- if (typeof currentUiSchema !== 'function') {
59
- const subUiSchema = (currentUiSchema || {});
60
- const expanded = expandUiSchemaDefinitions(subSchema, subUiSchema, registry, new Set(visited));
61
- if (Object.keys(expanded).length > 0) {
62
- result[keyword] = expanded;
63
- }
33
+ else {
34
+ result = mergeObjects(definitionUiSchema, localUiSchema);
35
+ }
36
+ // Walk oneOf/anyOf branches to populate uiSchema[keyword][i] so MultiSchemaField
37
+ // can read dropdown option titles at the parent level.
38
+ if (definitions) {
39
+ let resolvedSchema = schema;
40
+ if (ref && schema[REF_KEY] && !schema[RJSF_REF_KEY]) {
41
+ try {
42
+ resolvedSchema = findSchemaDefinition(ref, registry.rootSchema);
43
+ }
44
+ catch (e) {
45
+ console.warn('could not resolve $ref in resolveUiSchema:\n', e);
46
+ return result;
64
47
  }
65
48
  }
66
- }
67
- // Process array keywords (oneOf, anyOf, allOf) - each option maps to uiSchema[keyword][i]
68
- for (const keyword of ARRAY_KEYWORDS) {
69
- const schemaOptions = resolvedSchema[keyword];
70
- if (Array.isArray(schemaOptions) && schemaOptions.length > 0) {
49
+ for (const keyword of [ONE_OF_KEY, ANY_OF_KEY]) {
50
+ const schemaOptions = resolvedSchema[keyword];
51
+ if (!Array.isArray(schemaOptions) || schemaOptions.length === 0) {
52
+ continue;
53
+ }
71
54
  const currentUiSchemaArray = result[keyword];
72
55
  const uiSchemaArray = Array.isArray(currentUiSchemaArray) ? [...currentUiSchemaArray] : [];
73
56
  let hasExpanded = false;
74
57
  for (let i = 0; i < schemaOptions.length; i++) {
75
- const optionSchema = schemaOptions[i];
76
- const optionUiSchema = (uiSchemaArray[i] || {});
77
- const expanded = expandUiSchemaDefinitions(optionSchema, optionUiSchema, registry, new Set(visited));
78
- if (Object.keys(expanded).length > 0) {
79
- uiSchemaArray[i] = expanded;
58
+ const option = schemaOptions[i];
59
+ const optionRef = ((_b = option === null || option === void 0 ? void 0 : option[RJSF_REF_KEY]) !== null && _b !== void 0 ? _b : option === null || option === void 0 ? void 0 : option[REF_KEY]);
60
+ if (optionRef && optionRef in definitions) {
61
+ const optionUiSchema = (uiSchemaArray[i] || {});
62
+ uiSchemaArray[i] = mergeObjects(definitions[optionRef], optionUiSchema);
80
63
  hasExpanded = true;
81
64
  }
82
65
  }
@@ -87,33 +70,4 @@ export function expandUiSchemaDefinitions(currentSchema, uiSchema, registry, vis
87
70
  }
88
71
  return result;
89
72
  }
90
- /** Resolves the uiSchema for a given schema, considering `ui:definitions` stored in the registry.
91
- *
92
- * This function is called at runtime for each field. It handles recursive schemas where the
93
- * pre-expansion in `expandUiSchemaDefinitions` couldn't go deeper.
94
- *
95
- * When the schema contains a `$ref`, this function looks up the corresponding uiSchema definition
96
- * from `registry.uiSchemaDefinitions` and merges it with any local uiSchema overrides.
97
- *
98
- * Resolution order (later sources override earlier):
99
- * 1. `ui:definitions[$ref]` - base definition from registry
100
- * 2. `localUiSchema` - local overrides at current path
101
- *
102
- * @param schema - The JSON schema (may still contain `$ref` for recursive schemas)
103
- * @param localUiSchema - The uiSchema at the current path (local overrides)
104
- * @param registry - The registry containing `uiSchemaDefinitions`
105
- * @returns - The resolved uiSchema with definitions merged in
106
- */
107
- export default function resolveUiSchema(schema, localUiSchema, registry) {
108
- var _a, _b;
109
- const ref = ((_a = schema[RJSF_REF_KEY]) !== null && _a !== void 0 ? _a : schema[REF_KEY]);
110
- const definitionUiSchema = ref ? (_b = registry.uiSchemaDefinitions) === null || _b === void 0 ? void 0 : _b[ref] : undefined;
111
- if (!definitionUiSchema) {
112
- return localUiSchema || {};
113
- }
114
- if (!localUiSchema || Object.keys(localUiSchema).length === 0) {
115
- return { ...definitionUiSchema };
116
- }
117
- return mergeObjects(definitionUiSchema, localUiSchema);
118
- }
119
73
  //# sourceMappingURL=resolveUiSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveUiSchema.js","sourceRoot":"","sources":["../src/resolveUiSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACd,OAAO,EACP,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAG1C,+D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