@rjsf/core 6.6.2 → 6.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/LICENSE.md +201 -0
  2. package/dist/core.umd.js +312 -252
  3. package/dist/index.cjs +947 -878
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.esm.js +741 -667
  6. package/dist/index.esm.js.map +4 -4
  7. package/lib/components/Form.d.ts +2 -2
  8. package/lib/components/Form.d.ts.map +1 -1
  9. package/lib/components/Form.js +30 -15
  10. package/lib/components/RichDescription.d.ts +1 -1
  11. package/lib/components/RichDescription.d.ts.map +1 -1
  12. package/lib/components/RichHelp.d.ts +1 -1
  13. package/lib/components/RichHelp.d.ts.map +1 -1
  14. package/lib/components/SchemaExamples.d.ts +1 -1
  15. package/lib/components/SchemaExamples.d.ts.map +1 -1
  16. package/lib/components/fields/ArrayField.d.ts +1 -1
  17. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  18. package/lib/components/fields/BooleanField.d.ts +1 -1
  19. package/lib/components/fields/BooleanField.d.ts.map +1 -1
  20. package/lib/components/fields/CyclicSchemaField.d.ts +8 -0
  21. package/lib/components/fields/CyclicSchemaField.d.ts.map +1 -0
  22. package/lib/components/fields/CyclicSchemaField.js +21 -0
  23. package/lib/components/fields/FallbackField.d.ts +1 -1
  24. package/lib/components/fields/FallbackField.d.ts.map +1 -1
  25. package/lib/components/fields/LayoutGridField.d.ts +1 -1
  26. package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
  27. package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
  28. package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
  29. package/lib/components/fields/LayoutMultiSchemaField.d.ts +1 -1
  30. package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
  31. package/lib/components/fields/MultiSchemaField.d.ts +1 -46
  32. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
  33. package/lib/components/fields/MultiSchemaField.js +111 -135
  34. package/lib/components/fields/NumberField.d.ts +1 -1
  35. package/lib/components/fields/NumberField.d.ts.map +1 -1
  36. package/lib/components/fields/NumberField.js +26 -15
  37. package/lib/components/fields/ObjectField.d.ts +1 -1
  38. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  39. package/lib/components/fields/ObjectField.js +20 -5
  40. package/lib/components/fields/OptionalDataControlsField.d.ts +1 -1
  41. package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
  42. package/lib/components/fields/SchemaField.d.ts +13 -7
  43. package/lib/components/fields/SchemaField.d.ts.map +1 -1
  44. package/lib/components/fields/SchemaField.js +37 -24
  45. package/lib/components/fields/StringField.d.ts +1 -1
  46. package/lib/components/fields/StringField.d.ts.map +1 -1
  47. package/lib/components/fields/index.d.ts.map +1 -1
  48. package/lib/components/fields/index.js +2 -0
  49. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
  50. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
  51. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +1 -1
  52. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
  53. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -1
  54. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
  55. package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
  56. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
  57. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
  58. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
  59. package/lib/components/templates/BaseInputTemplate.d.ts +1 -1
  60. package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
  61. package/lib/components/templates/BaseInputTemplate.js +2 -2
  62. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
  63. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
  64. package/lib/components/templates/ButtonTemplates/IconButton.d.ts +6 -6
  65. package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
  66. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -1
  67. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
  68. package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts +7 -0
  69. package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts.map +1 -0
  70. package/lib/components/templates/CyclicSchemaExpandTemplate.js +12 -0
  71. package/lib/components/templates/DescriptionField.d.ts +1 -1
  72. package/lib/components/templates/DescriptionField.d.ts.map +1 -1
  73. package/lib/components/templates/ErrorList.d.ts +1 -1
  74. package/lib/components/templates/ErrorList.d.ts.map +1 -1
  75. package/lib/components/templates/FallbackFieldTemplate.d.ts +1 -1
  76. package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
  77. package/lib/components/templates/FieldErrorTemplate.d.ts +1 -1
  78. package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
  79. package/lib/components/templates/FieldHelpTemplate.d.ts +1 -1
  80. package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
  81. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -1
  82. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
  83. package/lib/components/templates/FieldTemplate/Label.d.ts +1 -1
  84. package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
  85. package/lib/components/templates/GridTemplate.d.ts +1 -1
  86. package/lib/components/templates/GridTemplate.d.ts.map +1 -1
  87. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +1 -1
  88. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
  89. package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
  90. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
  91. package/lib/components/templates/OptionalDataControlsTemplate.d.ts +1 -1
  92. package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
  93. package/lib/components/templates/TitleField.d.ts +1 -1
  94. package/lib/components/templates/TitleField.d.ts.map +1 -1
  95. package/lib/components/templates/UnsupportedField.d.ts +1 -1
  96. package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
  97. package/lib/components/templates/UnsupportedField.js +1 -1
  98. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -1
  99. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
  100. package/lib/components/templates/index.d.ts.map +1 -1
  101. package/lib/components/templates/index.js +2 -0
  102. package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -1
  103. package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
  104. package/lib/components/widgets/AltDateWidget.d.ts +1 -1
  105. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
  106. package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
  107. package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
  108. package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
  109. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
  110. package/lib/components/widgets/CheckboxesWidget.js +2 -2
  111. package/lib/components/widgets/ColorWidget.d.ts +1 -1
  112. package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
  113. package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
  114. package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
  115. package/lib/components/widgets/DateWidget.d.ts +1 -1
  116. package/lib/components/widgets/DateWidget.d.ts.map +1 -1
  117. package/lib/components/widgets/EmailWidget.d.ts +1 -1
  118. package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
  119. package/lib/components/widgets/FileWidget.d.ts +1 -1
  120. package/lib/components/widgets/FileWidget.d.ts.map +1 -1
  121. package/lib/components/widgets/HiddenWidget.d.ts +1 -1
  122. package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
  123. package/lib/components/widgets/PasswordWidget.d.ts +1 -1
  124. package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
  125. package/lib/components/widgets/RadioWidget.d.ts +1 -1
  126. package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
  127. package/lib/components/widgets/RadioWidget.js +2 -2
  128. package/lib/components/widgets/RangeWidget.d.ts +1 -1
  129. package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
  130. package/lib/components/widgets/RatingWidget.d.ts +1 -1
  131. package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
  132. package/lib/components/widgets/SelectWidget.d.ts +1 -1
  133. package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
  134. package/lib/components/widgets/SelectWidget.js +9 -8
  135. package/lib/components/widgets/TextWidget.d.ts +1 -1
  136. package/lib/components/widgets/TextWidget.d.ts.map +1 -1
  137. package/lib/components/widgets/TextareaWidget.d.ts +1 -1
  138. package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
  139. package/lib/components/widgets/TextareaWidget.js +3 -3
  140. package/lib/components/widgets/TimeWidget.d.ts +1 -1
  141. package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
  142. package/lib/components/widgets/URLWidget.d.ts +1 -1
  143. package/lib/components/widgets/URLWidget.d.ts.map +1 -1
  144. package/lib/components/widgets/UpDownWidget.d.ts +1 -1
  145. package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
  146. package/lib/tsconfig.tsbuildinfo +1 -1
  147. package/package.json +28 -27
  148. package/src/components/Form.tsx +34 -15
  149. package/src/components/fields/CyclicSchemaField.tsx +40 -0
  150. package/src/components/fields/MultiSchemaField.tsx +201 -230
  151. package/src/components/fields/NumberField.tsx +30 -16
  152. package/src/components/fields/ObjectField.tsx +29 -5
  153. package/src/components/fields/SchemaField.tsx +46 -34
  154. package/src/components/fields/index.ts +2 -0
  155. package/src/components/templates/BaseInputTemplate.tsx +2 -5
  156. package/src/components/templates/CyclicSchemaExpandTemplate.tsx +31 -0
  157. package/src/components/templates/UnsupportedField.tsx +1 -1
  158. package/src/components/templates/index.ts +2 -0
  159. package/src/components/widgets/CheckboxesWidget.tsx +2 -2
  160. package/src/components/widgets/RadioWidget.tsx +2 -2
  161. package/src/components/widgets/SelectWidget.tsx +45 -30
  162. package/src/components/widgets/TextareaWidget.tsx +3 -3
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Component } from 'react';
3
- import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getTemplate, getUiOptions, getWidget, isFormDataAvailable, mergeSchemas, ONE_OF_KEY, shouldRenderOptionalField, TranslatableString, } from '@rjsf/utils';
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getTemplate, getUiOptions, getWidget, hashObject, isFormDataAvailable, mergeSchemas, ONE_OF_KEY, shouldRenderOptionalField, TranslatableString, } from '@rjsf/utils';
4
4
  import get from 'lodash-es/get.js';
5
5
  import isEmpty from 'lodash-es/isEmpty.js';
6
6
  import omit from 'lodash-es/omit.js';
@@ -9,85 +9,60 @@ import omit from 'lodash-es/omit.js';
9
9
  *
10
10
  * @param props - The `FieldProps` for this template
11
11
  */
12
- class AnyOfField extends Component {
12
+ function AnyOfField(props) {
13
+ const { name, disabled = false, errorSchema = {}, formData, fieldPathId, onBlur, onChange, onFocus, options, readonly, registry, required = false, schema, uiSchema, } = props;
14
+ const { schemaUtils } = registry;
15
+ // Hash formData by value so the memo only invalidates when data actually changes, not on every
16
+ // new object reference. hashObject(undefined) throws, so null is used as the fallback.
17
+ const formDataHash = hashObject(formData ?? null);
18
+ // retrievedOptions is purely derived from options — useMemo handles re-derivation automatically
19
+ // when options, schemaUtils, or formData's value changes, with no render-phase dispatch needed.
20
+ const retrievedOptions = useMemo(() => options.map((opt) => schemaUtils.retrieveSchema(opt, formData)),
21
+ // oxlint-disable-next-line react-hooks/exhaustive-deps -- formDataHash is the value-stable proxy for formData
22
+ [options, schemaUtils, formDataHash]);
23
+ const [selectedOption, setSelectedOption] = useState(() => {
24
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
25
+ return schemaUtils.getClosestMatchingOption(formData, retrievedOptions, 0, discriminator);
26
+ });
13
27
  /** Flag to skip the formData-change-driven option recalculation when the user just selected an option.
14
- * Set to true in the setState callback of onOptionChange (after onChange is called), consumed and reset in
15
- * componentDidUpdate. This prevents the matching-option recalculation from overriding a user's explicit choice
16
- * when getDefaultFormState populates undefined properties that make deepEquals see a false formData change.
17
- */
18
- skipNextOptionRecalculation = false;
19
- /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
20
- *
21
- * @param props - The `FieldProps` for this template
22
- */
23
- constructor(props) {
24
- super(props);
25
- const { formData, options, registry: { schemaUtils }, } = this.props;
26
- // cache the retrieved options in state in case they have $refs to save doing it later
27
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
28
- this.state = {
29
- retrievedOptions,
30
- selectedOption: this.getMatchingOption(0, formData, retrievedOptions),
31
- };
32
- }
33
- /** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
34
- * currently selected option based on the overall `formData`
35
- *
36
- * @param prevProps - The previous `FieldProps` for this template
37
- * @param prevState - The previous `AnyOfFieldState` for this template
28
+ * Set to true in onOptionChange (before onChange is called), consumed and reset in the update effect.
29
+ * This prevents the matching-option recalculation from overriding a user's explicit choice when
30
+ * getDefaultFormState populates undefined properties that make deepEquals see a false formData change.
38
31
  */
39
- componentDidUpdate(prevProps, prevState) {
40
- const { formData, options, fieldPathId } = this.props;
41
- const { selectedOption } = this.state;
42
- let newState = this.state;
43
- if (!deepEquals(prevProps.options, options)) {
44
- const { registry: { schemaUtils }, } = this.props;
45
- // re-cache the retrieved options in state in case they have $refs to save doing it later
46
- const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
47
- newState = { selectedOption, retrievedOptions };
48
- }
49
- if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
50
- if (this.skipNextOptionRecalculation) {
51
- this.skipNextOptionRecalculation = false;
32
+ const skipNextOptionRecalculation = useRef(false);
33
+ const prevFormDataRef = useRef(formData);
34
+ const prevFieldIdRef = useRef(fieldPathId.$id);
35
+ // Mirrors componentDidUpdate: re-match selectedOption when formData changes on the same field.
36
+ // Runs after every render (no deps array) to compare against prev values stored in refs.
37
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
38
+ useEffect(() => {
39
+ const prevFormData = prevFormDataRef.current;
40
+ const prevFieldId = prevFieldIdRef.current;
41
+ prevFormDataRef.current = formData;
42
+ prevFieldIdRef.current = fieldPathId.$id;
43
+ if (!deepEquals(formData, prevFormData) && fieldPathId.$id === prevFieldId) {
44
+ if (skipNextOptionRecalculation.current) {
45
+ skipNextOptionRecalculation.current = false;
46
+ return;
52
47
  }
53
- else {
54
- const { retrievedOptions } = newState;
55
- const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
56
- if (prevState && matchingOption !== selectedOption) {
57
- newState = { selectedOption: matchingOption, retrievedOptions };
58
- }
48
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
49
+ const matchingOption = schemaUtils.getClosestMatchingOption(formData, retrievedOptions, selectedOption, discriminator);
50
+ if (matchingOption !== selectedOption) {
51
+ setSelectedOption(matchingOption);
59
52
  }
60
53
  }
61
- if (newState !== this.state) {
62
- // oxlint-disable-next-line react/no-did-update-set-state -- guarded to prevent infinite loop
63
- this.setState(newState);
64
- }
65
- }
66
- /** Determines the best matching option for the given `formData` and `options`.
67
- *
68
- * @param formData - The new formData
69
- * @param options - The list of options to choose from
70
- * @return - The index of the `option` that best matches the `formData`
71
- */
72
- getMatchingOption(selectedOption, formData, options) {
73
- const { schema, registry: { schemaUtils }, } = this.props;
74
- const discriminator = getDiscriminatorFieldFromSchema(schema);
75
- const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
76
- return option;
77
- }
54
+ });
55
+ const fieldId = `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
78
56
  /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
79
57
  * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
80
58
  * the `onChange` handler.
81
59
  *
82
60
  * @param option - The new option value being selected
83
61
  */
84
- onOptionChange = (option) => {
85
- const { selectedOption, retrievedOptions } = this.state;
86
- const { disabled = false, formData, onChange, readonly = false, registry, fieldPathId } = this.props;
62
+ const onOptionChange = useCallback((option) => {
87
63
  if (disabled || readonly) {
88
64
  return;
89
65
  }
90
- const { schemaUtils } = registry;
91
66
  const intOption = option !== undefined ? parseInt(option, 10) : -1;
92
67
  if (intOption === selectedOption) {
93
68
  return;
@@ -100,79 +75,80 @@ class AnyOfField extends Component {
100
75
  // so that only the root objects themselves are created without adding undefined children properties
101
76
  newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
102
77
  }
103
- this.setState({ selectedOption: intOption }, () => {
104
- this.skipNextOptionRecalculation = true;
105
- onChange(newFormData, fieldPathId.path, undefined, this.getFieldId());
106
- });
107
- };
108
- getFieldId() {
109
- const { fieldPathId, schema } = this.props;
110
- return `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
78
+ setSelectedOption(intOption);
79
+ skipNextOptionRecalculation.current = true;
80
+ onChange(newFormData, fieldPathId.path, undefined, fieldId);
81
+ },
82
+ // setSelectedOption is stable (guaranteed by useState); skipNextOptionRecalculation is a ref
83
+ [selectedOption, retrievedOptions, disabled, readonly, schemaUtils, formData, fieldPathId, onChange, fieldId]);
84
+ const { widgets, fields, translateString, globalUiOptions } = registry;
85
+ const { SchemaField: SchemaFieldComponent } = fields;
86
+ const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
87
+ const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
88
+ const hasFormData = isFormDataAvailable(formData);
89
+ const { widget = 'select', placeholder, autofocus, autocomplete, title = schema.title, ...uiOptions } = getUiOptions(uiSchema, globalUiOptions);
90
+ const Widget = getWidget({ type: 'number' }, widget, widgets);
91
+ const rawErrors = get(errorSchema, ERRORS_KEY, []);
92
+ const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
93
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
94
+ const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
95
+ let optionSchema;
96
+ if (option) {
97
+ const { required: schemaRequired, type: schemaType } = schema;
98
+ const parentProps = {};
99
+ if (schemaRequired) {
100
+ parentProps.required = schemaRequired;
101
+ }
102
+ // Propagate the parent schema type to options that don't define their own.
103
+ // This is necessary when the parent constrains the type (e.g. { type: 'string',
104
+ // oneOf: [{ pattern: '...' }, { pattern: '...' }] }) but the option sub-schemas
105
+ // omit the type — without it, getSchemaType returns undefined and the option
106
+ // renders as FallbackField instead of the correct widget (e.g. StringField).
107
+ if (schemaType !== undefined && !('type' in option)) {
108
+ parentProps.type = schemaType;
109
+ }
110
+ // Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
111
+ optionSchema = Object.keys(parentProps).length > 0 ? mergeSchemas(parentProps, option) : option;
111
112
  }
112
- /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
113
- */
114
- render() {
115
- const { name, disabled = false, errorSchema = {}, formData, onBlur, onFocus, readonly, required = false, registry, schema, uiSchema, } = this.props;
116
- const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
117
- const { SchemaField: SchemaFieldComponent } = fields;
118
- const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
119
- const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
120
- const hasFormData = isFormDataAvailable(formData);
121
- const { selectedOption, retrievedOptions } = this.state;
122
- const { widget = 'select', placeholder, autofocus, autocomplete, title = schema.title, ...uiOptions } = getUiOptions(uiSchema, globalUiOptions);
123
- const Widget = getWidget({ type: 'number' }, widget, widgets);
124
- const rawErrors = get(errorSchema, ERRORS_KEY, []);
125
- const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
126
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
127
- const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
128
- let optionSchema;
129
- if (option) {
130
- // merge top level required field
131
- const { required: schemaRequired } = schema;
132
- // Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
133
- optionSchema = schemaRequired ? mergeSchemas({ required: schemaRequired }, option) : option;
113
+ // First we will check to see if there is an anyOf/oneOf override for the UI schema
114
+ let optionsUiSchema = [];
115
+ if (ONE_OF_KEY in schema && uiSchema && ONE_OF_KEY in uiSchema) {
116
+ if (Array.isArray(uiSchema[ONE_OF_KEY])) {
117
+ optionsUiSchema = uiSchema[ONE_OF_KEY];
134
118
  }
135
- // First we will check to see if there is an anyOf/oneOf override for the UI schema
136
- let optionsUiSchema = [];
137
- if (ONE_OF_KEY in schema && uiSchema && ONE_OF_KEY in uiSchema) {
138
- if (Array.isArray(uiSchema[ONE_OF_KEY])) {
139
- optionsUiSchema = uiSchema[ONE_OF_KEY];
140
- }
141
- else {
142
- // oxlint-disable-next-line no-console
143
- console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
144
- }
119
+ else {
120
+ // oxlint-disable-next-line no-console
121
+ console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
145
122
  }
146
- else if (ANY_OF_KEY in schema && uiSchema && ANY_OF_KEY in uiSchema) {
147
- if (Array.isArray(uiSchema[ANY_OF_KEY])) {
148
- optionsUiSchema = uiSchema[ANY_OF_KEY];
149
- }
150
- else {
151
- // oxlint-disable-next-line no-console
152
- console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
153
- }
123
+ }
124
+ else if (ANY_OF_KEY in schema && uiSchema && ANY_OF_KEY in uiSchema) {
125
+ if (Array.isArray(uiSchema[ANY_OF_KEY])) {
126
+ optionsUiSchema = uiSchema[ANY_OF_KEY];
154
127
  }
155
- // Then we pick the one that matches the selected option index, if one exists otherwise default to the main uiSchema
156
- let optionUiSchema = uiSchema;
157
- if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
158
- optionUiSchema = optionsUiSchema[selectedOption];
128
+ else {
129
+ // oxlint-disable-next-line no-console
130
+ console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
159
131
  }
160
- const translateEnum = title
161
- ? TranslatableString.TitleOptionPrefix
162
- : TranslatableString.OptionPrefix;
163
- const translateParams = title ? [title] : [];
164
- const enumOptions = retrievedOptions.map((opt, index) => {
165
- // Also see if there is an override title in the uiSchema for each option, otherwise use the title from the option
166
- const { title: uiTitle = opt.title } = getUiOptions(optionsUiSchema[index]);
167
- return {
168
- label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
169
- value: index,
170
- };
171
- });
172
- const selector = !isOptionalRender || hasFormData ? (_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, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly })) : undefined;
173
- const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(SchemaFieldComponent, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
174
- null;
175
- return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
176
132
  }
133
+ // Then we pick the one that matches the selected option index, if one exists otherwise default to the main uiSchema
134
+ let optionUiSchema = uiSchema;
135
+ if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
136
+ optionUiSchema = optionsUiSchema[selectedOption];
137
+ }
138
+ const translateEnum = title
139
+ ? TranslatableString.TitleOptionPrefix
140
+ : TranslatableString.OptionPrefix;
141
+ const translateParams = title ? [title] : [];
142
+ const enumOptions = retrievedOptions.map((opt, index) => {
143
+ const { title: uiTitle = opt.title } = getUiOptions(optionsUiSchema[index]);
144
+ return {
145
+ label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
146
+ value: index,
147
+ };
148
+ });
149
+ const selector = !isOptionalRender || hasFormData ? (_jsx(Widget, { id: fieldId, name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: 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, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly })) : undefined;
150
+ const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(SchemaFieldComponent, { ...props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
151
+ null;
152
+ return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
177
153
  }
178
154
  export default AnyOfField;
@@ -16,6 +16,6 @@ import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '
16
16
  * value cached in the state. If it matches the cached value, the cached
17
17
  * value is passed to the input instead of the formData value
18
18
  */
19
- declare function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
19
+ declare function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react").JSX.Element;
20
20
  export default NumberField;
21
21
  //# sourceMappingURL=NumberField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAerB;;;;;;;;;;;;;;;;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,2CAgD3B;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAOrB;;;;;;;;;;;;;;;;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,+BAsE3B;AAED,eAAe,WAAW,CAAC"}
@@ -1,15 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState, useCallback } from 'react';
3
- import { asNumber } from '@rjsf/utils';
4
- // Matches a string that ends in a . character, optionally followed by a sequence of
5
- // digits followed by any number of 0 characters up until the end of the line.
6
- // Ensuring that there is at least one prefixed character is important so that
7
- // you don't incorrectly match against "0".
3
+ import { asNumber, getDecimalSeparator, getUiOptions, optionsList } from '@rjsf/utils';
4
+ // Static matchers for standard '.' separator used during normalization inside handleChange
8
5
  const trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
9
- // This is used for trimming the trailing 0 and . characters without affecting
10
- // the rest of the string. Its possible to use one RegEx with groups for this
11
- // functionality, but it is fairly complex compared to simply defining two
12
- // different matchers.
13
6
  const trailingCharMatcher = /[0.]0*$/;
14
7
  /**
15
8
  * The NumberField class has some special handling for dealing with trailing
@@ -32,6 +25,8 @@ function NumberField(props) {
32
25
  const { registry, onChange, formData, value: initialValue } = props;
33
26
  const [lastValue, setLastValue] = useState(initialValue);
34
27
  const { StringField } = registry.fields;
28
+ const separator = getDecimalSeparator();
29
+ const escapedSeparator = separator === '.' ? '\\.' : separator;
35
30
  let value = formData;
36
31
  /** Handle the change from the `StringField` to properly convert to a number
37
32
  *
@@ -40,28 +35,44 @@ function NumberField(props) {
40
35
  const handleChange = useCallback((newValue, path, errorSchema, id) => {
41
36
  // Cache the original value in component state
42
37
  setLastValue(newValue);
38
+ // Convert locale separator to standard '.' first
39
+ const standardValue = typeof newValue === 'string' ? newValue.replace(separator, '.') : newValue;
43
40
  // Normalize decimals that don't start with a zero character in advance so
44
41
  // that the rest of the normalization logic is simpler
45
- const normalizedValue = `${newValue}`.startsWith('.') ? `0${newValue}` : newValue;
42
+ const normalizedValue = `${standardValue}`.startsWith('.') ? `0${standardValue}` : standardValue;
46
43
  // Check that the value is a string (this can happen if the widget used is a
47
44
  // <select>, due to an enum declaration etc) then, if the value ends in a
48
45
  // trailing decimal point or multiple zeroes, strip the trailing values
49
- const processed = typeof normalizedValue === 'string' && normalizedValue.match(trailingCharMatcherWithPrefix)
46
+ const processed = typeof normalizedValue === 'string' && trailingCharMatcherWithPrefix.exec(normalizedValue)
50
47
  ? asNumber(normalizedValue.replace(trailingCharMatcher, ''))
51
48
  : asNumber(normalizedValue);
52
49
  onChange(processed, path, errorSchema, id);
53
- }, [onChange]);
50
+ }, [onChange, separator]);
54
51
  if (typeof lastValue === 'string' && typeof value === 'number') {
55
52
  // Construct a regular expression that checks for a string that consists
56
- // of the formData value suffixed with zero or one '.' characters and zero
53
+ // of the formData value suffixed with zero or one locale separator characters and zero
57
54
  // or more '0' characters
58
- const re = new RegExp(`^(${String(value).replace('.', '\\.')})?\\.?0*$`);
55
+ const re = new RegExp(`^(${String(value).replace('.', escapedSeparator)})?${escapedSeparator}?0*$`);
59
56
  // If the cached "lastValue" is a match, use that instead of the formData
60
57
  // value to prevent the input value from changing in the UI
61
58
  if (lastValue.match(re)) {
62
59
  value = lastValue;
63
60
  }
64
61
  }
65
- return _jsx(StringField, { ...props, formData: value, onChange: handleChange });
62
+ // Format value to use the locale separator for rendering if it is a number
63
+ let displayValue = value;
64
+ if (typeof value === 'number' && separator !== '.') {
65
+ const { schema, uiSchema } = props;
66
+ const { schemaUtils } = registry;
67
+ const enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema, uiSchema) : undefined;
68
+ const defaultWidget = enumOptions ? 'select' : 'text';
69
+ const { widget = defaultWidget } = getUiOptions(uiSchema);
70
+ // Do not convert the value to a locale-specific string for radio, select,
71
+ // or hidden widgets because option matching relies on the original numeric value.
72
+ if (widget !== 'radio' && widget !== 'select' && widget !== 'hidden') {
73
+ displayValue = String(value).replace('.', separator);
74
+ }
75
+ }
76
+ return _jsx(StringField, { ...props, formData: displayValue, onChange: handleChange });
66
77
  }
67
78
  export default NumberField;
@@ -4,5 +4,5 @@ import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '
4
4
  *
5
5
  * @param props - The `FieldProps` for this template
6
6
  */
7
- export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
7
+ export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react").JSX.Element;
8
8
  //# sourceMappingURL=ObjectField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,UAAU,EACV,eAAe,EAGf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AA6LrB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACnH,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA4O3B"}
1
+ {"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,UAAU,EACV,eAAe,EAIf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAuMrB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACnH,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,+BAyP3B"}
@@ -39,6 +39,12 @@ function getDefaultValue(translateString, type) {
39
39
  return translateString(TranslatableString.NewStringDefault);
40
40
  }
41
41
  }
42
+ function isAdditionalPropertySchema(schema) {
43
+ return Boolean(schema?.[ADDITIONAL_PROPERTY_FLAG]);
44
+ }
45
+ function getAdditionalPropertyOrder(schemaProperties) {
46
+ return Object.keys(schemaProperties).filter((property) => isAdditionalPropertySchema(schemaProperties[property]));
47
+ }
42
48
  /** The `ObjectFieldProperty` component is used to render the `SchemaField` for a child property of an object
43
49
  */
44
50
  function ObjectFieldPropertyFn(props) {
@@ -103,10 +109,15 @@ export default function ObjectField(props) {
103
109
  formDataRef.current = formData;
104
110
  const schema = useMemo(() => schemaUtils.retrieveSchema(rawSchema, formData, true), [schemaUtils, rawSchema, formData]);
105
111
  const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
106
- const { properties: schemaProperties = {} } = schema;
112
+ const schemaProperties = useMemo(() => schema.properties ?? {}, [schema.properties]);
107
113
  // All the children will use childFieldPathId if present in the props, falling back to the fieldPathId
108
114
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
109
115
  const lastRenamedProperty = useRef({ previousKey: '', currentKey: undefined });
116
+ const [additionalPropertyOrder, setAdditionalPropertyOrder] = useState(() => getAdditionalPropertyOrder(schemaProperties));
117
+ const definedPropertyOrder = useMemo(() => {
118
+ const additionalPropertySet = new Set(getAdditionalPropertyOrder(schemaProperties));
119
+ return Object.keys(schemaProperties).filter((property) => !additionalPropertySet.has(property));
120
+ }, [schemaProperties]);
110
121
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
111
122
  const description = uiOptions.description ?? schema.description;
112
123
  const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
@@ -155,7 +166,7 @@ export default function ObjectField(props) {
155
166
  apSchema = schemaUtils.retrieveSchema({ [REF_KEY]: apSchema[REF_KEY] }, formData);
156
167
  type = apSchema.type;
157
168
  constValue = apSchema.const;
158
- defaultValue = apSchema.default;
169
+ defaultValue = schemaUtils.getDefaultFormState(apSchema, defaultValue);
159
170
  }
160
171
  if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
161
172
  type = 'object';
@@ -169,6 +180,7 @@ export default function ObjectField(props) {
169
180
  lastRenamedProperty.current.currentKey = newKey;
170
181
  lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
171
182
  }
183
+ setAdditionalPropertyOrder((order) => [...order, newKey]);
172
184
  onChange(newFormData, childFieldPathId.path);
173
185
  }, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
174
186
  /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
@@ -197,6 +209,7 @@ export default function ObjectField(props) {
197
209
  lastRenamedProperty.current.previousKey = oldKey;
198
210
  }
199
211
  lastRenamedProperty.current.currentKey = actualNewKey;
212
+ setAdditionalPropertyOrder((order) => order.map((property) => (property === oldKey ? actualNewKey : property)));
200
213
  onChange(renamedObj, childFieldPathId.path);
201
214
  }
202
215
  }, [onChange, childFieldPathId, getAvailableKey]);
@@ -204,6 +217,7 @@ export default function ObjectField(props) {
204
217
  * value for the path plus the key to be removed
205
218
  */
206
219
  const handleRemoveProperty = useCallback((key) => {
220
+ setAdditionalPropertyOrder((order) => order.filter((property) => property !== key));
207
221
  onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
208
222
  }, [onChange, childFieldPathId]);
209
223
  /** Returns the stable React key for a property. For the most recently renamed
@@ -219,8 +233,9 @@ export default function ObjectField(props) {
219
233
  }, []);
220
234
  if (!renderOptionalField || hasFormData) {
221
235
  try {
222
- const properties = Object.keys(schemaProperties);
223
- orderedProperties = orderProperties(properties, uiOptions.order);
236
+ const definedPropertySet = new Set(definedPropertyOrder);
237
+ const currentAdditionalProperties = additionalPropertyOrder.filter((property) => Object.hasOwn(schemaProperties, property) && !definedPropertySet.has(property));
238
+ orderedProperties = orderProperties([...definedPropertyOrder, ...currentAdditionalProperties], uiOptions.order);
224
239
  }
225
240
  catch (err) {
226
241
  return (_jsxs("div", { children: [_jsx("p", { className: 'rjsf-config-error', style: { color: 'red' }, children: _jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) }), _jsx("pre", { children: JSON.stringify(schema) })] }));
@@ -233,7 +248,7 @@ export default function ObjectField(props) {
233
248
  title: uiOptions.label === false ? '' : templateTitle,
234
249
  description: uiOptions.label === false ? undefined : description,
235
250
  properties: orderedProperties.map((propertyName) => {
236
- const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, propertyName, ADDITIONAL_PROPERTY_FLAG]);
251
+ const addedByAdditionalProperties = isAdditionalPropertySchema(schema.properties?.[propertyName]);
237
252
  const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
238
253
  const hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
239
254
  const content = (_jsx(ObjectFieldProperty, { propertyName: propertyName, required: isRequired(schema, propertyName), schema: get(schema, [PROPERTIES_KEY, propertyName], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, [propertyName]), fieldPathId: childFieldPathId, formData: get(formData, [propertyName]), handleKeyRename: handleKeyRename, handleRemoveProperty: handleRemoveProperty, addedByAdditionalProperties: addedByAdditionalProperties, onChange: onChange, onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError }, getStableKey(propertyName)));
@@ -4,5 +4,5 @@ import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '
4
4
  *
5
5
  * @param props - The `FieldProps` for this template
6
6
  */
7
- export default function OptionalDataControlsField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): "" | import("react/jsx-runtime").JSX.Element | undefined;
7
+ export default function OptionalDataControlsField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): "" | import("react").JSX.Element | undefined;
8
8
  //# sourceMappingURL=OptionalDataControlsField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionalDataControlsField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/OptionalDataControlsField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAEf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAUrB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,4DA4D3B"}
1
+ {"version":3,"file":"OptionalDataControlsField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/OptionalDataControlsField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAEf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAUrB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,gDA4D3B"}
@@ -1,11 +1,17 @@
1
- import { Component } from 'react';
2
1
  import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
- /** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
4
- * and if so, calls the `SchemaFieldRender` component with the props.
2
+ /** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
3
+ * render based on the `schema`, `uiSchema` and all the other props. It also deals with rendering the `anyOf` and
4
+ * `oneOf` fields.
5
+ *
6
+ * @param props - The `FieldProps` for this component
5
7
  */
6
- declare class SchemaField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FieldProps<T, S, F>> {
7
- shouldComponentUpdate(nextProps: Readonly<FieldProps<T, S, F>>): boolean;
8
- render(): import("react/jsx-runtime").JSX.Element;
9
- }
8
+ declare function SchemaFieldRender<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react").JSX.Element | null;
9
+ /** The `SchemaField` component wraps `SchemaFieldRender` with a custom memoization comparator that determines whether it is necessary to rerender the component based on any props changes
10
+ * using `experimental_componentUpdateStrategy`.
11
+ *
12
+ * The cast to `typeof SchemaFieldRender` preserves the generic type signature (<T, S, F>) for consumers,
13
+ * since React.memo's return type erases generic parameters.
14
+ */
15
+ declare const SchemaField: typeof SchemaFieldRender;
10
16
  export default SchemaField;
11
17
  //# sourceMappingURL=SchemaField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAKV,UAAU,EAEV,eAAe,EAEf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AA2TrB;;GAEG;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,CACpB;IACC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAS9D,MAAM;CAGP;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAKV,UAAU,EAEV,eAAe,EAGf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAgFrB;;;;;GAKG;AACH,iBAAS,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAC1G,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,sCA+O3B;AAED;;;;;GAKG;AACH,QAAA,MAAM,WAAW,EAUA,OAAO,iBAAiB,CAAC;AAE1C,eAAe,WAAW,CAAC"}