@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.
- package/LICENSE.md +201 -0
- package/dist/core.umd.js +312 -252
- package/dist/index.cjs +947 -878
- package/dist/index.cjs.map +4 -4
- package/dist/index.esm.js +741 -667
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +2 -2
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +30 -15
- package/lib/components/RichDescription.d.ts +1 -1
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichHelp.d.ts +1 -1
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/SchemaExamples.d.ts +1 -1
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.d.ts +1 -1
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.d.ts +1 -1
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/CyclicSchemaField.d.ts +8 -0
- package/lib/components/fields/CyclicSchemaField.d.ts.map +1 -0
- package/lib/components/fields/CyclicSchemaField.js +21 -0
- package/lib/components/fields/FallbackField.d.ts +1 -1
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.d.ts +1 -1
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.d.ts +1 -46
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +111 -135
- package/lib/components/fields/NumberField.d.ts +1 -1
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +26 -15
- package/lib/components/fields/ObjectField.d.ts +1 -1
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +20 -5
- package/lib/components/fields/OptionalDataControlsField.d.ts +1 -1
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +13 -7
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +37 -24
- package/lib/components/fields/StringField.d.ts +1 -1
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +2 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +2 -2
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +6 -6
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts +7 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts.map +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js +12 -0
- package/lib/components/templates/DescriptionField.d.ts +1 -1
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +1 -1
- package/lib/components/templates/ErrorList.d.ts.map +1 -1
- package/lib/components/templates/FallbackFieldTemplate.d.ts +1 -1
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +1 -1
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
- package/lib/components/templates/TitleField.d.ts +1 -1
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -1
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +2 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/components/widgets/ColorWidget.d.ts +1 -1
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateWidget.d.ts +1 -1
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -1
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -1
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -1
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +2 -2
- package/lib/components/widgets/RangeWidget.d.ts +1 -1
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +1 -1
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.d.ts +1 -1
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +9 -8
- package/lib/components/widgets/TextWidget.d.ts +1 -1
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +3 -3
- package/lib/components/widgets/TimeWidget.d.ts +1 -1
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -1
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -27
- package/src/components/Form.tsx +34 -15
- package/src/components/fields/CyclicSchemaField.tsx +40 -0
- package/src/components/fields/MultiSchemaField.tsx +201 -230
- package/src/components/fields/NumberField.tsx +30 -16
- package/src/components/fields/ObjectField.tsx +29 -5
- package/src/components/fields/SchemaField.tsx +46 -34
- package/src/components/fields/index.ts +2 -0
- package/src/components/templates/BaseInputTemplate.tsx +2 -5
- package/src/components/templates/CyclicSchemaExpandTemplate.tsx +31 -0
- package/src/components/templates/UnsupportedField.tsx +1 -1
- package/src/components/templates/index.ts +2 -0
- package/src/components/widgets/CheckboxesWidget.tsx +2 -2
- package/src/components/widgets/RadioWidget.tsx +2 -2
- package/src/components/widgets/SelectWidget.tsx +45 -30
- package/src/components/widgets/TextareaWidget.tsx +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
62
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
|
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;
|
|
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
|
-
//
|
|
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 = `${
|
|
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' &&
|
|
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
|
|
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('.',
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
223
|
-
|
|
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 =
|
|
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
|
|
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,
|
|
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 `
|
|
4
|
-
*
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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":"
|
|
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"}
|