@rjsf/core 6.6.0 → 6.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.umd.js +454 -373
- package/dist/index.cjs +416 -334
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +418 -415
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts +14 -11
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +97 -62
- package/lib/components/RichDescription.d.ts +2 -2
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.d.ts +2 -2
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/SchemaExamples.d.ts +1 -1
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/SchemaExamples.js +1 -3
- package/lib/components/fields/ArrayField.d.ts +1 -1
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +87 -88
- package/lib/components/fields/BooleanField.d.ts +1 -1
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -5
- package/lib/components/fields/FallbackField.d.ts +1 -1
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/FallbackField.js +2 -2
- package/lib/components/fields/LayoutGridField.d.ts +7 -9
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +5 -4
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
- package/lib/components/fields/LayoutHeaderField.js +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/LayoutMultiSchemaField.js +4 -1
- package/lib/components/fields/MultiSchemaField.d.ts +9 -3
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +27 -9
- package/lib/components/fields/NullField.d.ts +1 -1
- package/lib/components/fields/NullField.d.ts.map +1 -1
- 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 +7 -9
- 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 +27 -25
- 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 +1 -1
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +7 -7
- package/lib/components/fields/StringField.d.ts +1 -1
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +2 -5
- package/lib/components/fields/index.d.ts +1 -1
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +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/ArrayFieldItemButtonsTemplate.js +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/ArrayFieldItemTemplate.js +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/ArrayFieldTemplate.js +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/ArrayFieldTitleTemplate.js +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 +7 -6
- 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 +14 -7
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js +14 -6
- 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/ButtonTemplates/index.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
- 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/ErrorList.js +2 -4
- 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/FieldErrorTemplate.js +1 -3
- 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/FieldTemplate.js +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts +2 -2
- 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/ObjectFieldTemplate.js +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/OptionalDataControlsTemplate.js +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/WrapIfAdditionalTemplate.js +1 -1
- package/lib/components/templates/index.d.ts +1 -1
- package/lib/components/templates/index.d.ts.map +1 -1
- 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/AltDateWidget.js +2 -2
- 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/DateTimeWidget.js +2 -2
- 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/FileWidget.js +6 -4
- 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/RatingWidget.js +15 -15
- 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 +4 -4
- 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 +2 -2
- 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/components/widgets/index.d.ts +1 -1
- package/lib/components/widgets/index.d.ts.map +1 -1
- package/lib/getDefaultRegistry.d.ts +1 -1
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +1 -1
- package/lib/getTestRegistry.d.ts +1 -1
- package/lib/getTestRegistry.d.ts.map +1 -1
- package/lib/getTestRegistry.js +1 -1
- package/lib/index.d.ts +10 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +3 -3
- package/lib/withTheme.d.ts.map +1 -1
- package/lib/withTheme.js +6 -6
- package/package.json +6 -7
- package/src/components/Form.tsx +164 -97
- package/src/components/RichDescription.tsx +3 -10
- package/src/components/RichHelp.tsx +3 -10
- package/src/components/SchemaExamples.tsx +6 -4
- package/src/components/fields/ArrayField.tsx +122 -108
- package/src/components/fields/BooleanField.tsx +4 -9
- package/src/components/fields/FallbackField.tsx +4 -8
- package/src/components/fields/LayoutGridField.tsx +21 -19
- package/src/components/fields/LayoutHeaderField.tsx +2 -10
- package/src/components/fields/LayoutMultiSchemaField.tsx +15 -10
- package/src/components/fields/MultiSchemaField.tsx +29 -16
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +8 -10
- package/src/components/fields/ObjectField.tsx +48 -39
- package/src/components/fields/OptionalDataControlsField.tsx +6 -4
- package/src/components/fields/SchemaField.tsx +22 -19
- package/src/components/fields/StringField.tsx +4 -15
- package/src/components/fields/index.ts +1 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +2 -7
- package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -9
- package/src/components/templates/ArrayFieldTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -10
- package/src/components/templates/BaseInputTemplate.tsx +15 -19
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/IconButton.tsx +16 -7
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/DescriptionField.tsx +1 -1
- package/src/components/templates/ErrorList.tsx +8 -15
- package/src/components/templates/FallbackFieldTemplate.tsx +2 -1
- package/src/components/templates/FieldErrorTemplate.tsx +8 -8
- package/src/components/templates/FieldHelpTemplate.tsx +2 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/components/templates/FieldTemplate/Label.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +1 -1
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/components/templates/ObjectFieldTemplate.tsx +2 -7
- package/src/components/templates/OptionalDataControlsTemplate.tsx +3 -2
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +3 -2
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/templates/index.ts +1 -1
- package/src/components/widgets/AltDateTimeWidget.tsx +1 -1
- package/src/components/widgets/AltDateWidget.tsx +7 -13
- package/src/components/widgets/CheckboxWidget.tsx +3 -5
- package/src/components/widgets/CheckboxesWidget.tsx +6 -8
- package/src/components/widgets/ColorWidget.tsx +2 -1
- package/src/components/widgets/DateTimeWidget.tsx +3 -10
- package/src/components/widgets/DateWidget.tsx +2 -1
- package/src/components/widgets/EmailWidget.tsx +2 -1
- package/src/components/widgets/FileWidget.tsx +9 -8
- package/src/components/widgets/HiddenWidget.tsx +1 -1
- package/src/components/widgets/PasswordWidget.tsx +2 -1
- package/src/components/widgets/RadioWidget.tsx +6 -8
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +48 -47
- package/src/components/widgets/SelectWidget.tsx +12 -10
- package/src/components/widgets/TextWidget.tsx +2 -1
- package/src/components/widgets/TextareaWidget.tsx +7 -4
- package/src/components/widgets/TimeWidget.tsx +2 -1
- package/src/components/widgets/URLWidget.tsx +2 -1
- package/src/components/widgets/UpDownWidget.tsx +2 -1
- package/src/components/widgets/index.ts +1 -1
- package/src/getDefaultRegistry.ts +2 -9
- package/src/getTestRegistry.tsx +2 -7
- package/src/index.ts +10 -5
- package/src/withTheme.tsx +14 -9
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
/** Type used for the state of the `AnyOfField` component */
|
|
4
|
-
|
|
4
|
+
interface AnyOfFieldState<S extends StrictRJSFSchema = RJSFSchema> {
|
|
5
5
|
/** The currently selected option */
|
|
6
6
|
selectedOption: number;
|
|
7
7
|
/** The option schemas after retrieving all $refs */
|
|
8
8
|
retrievedOptions: S[];
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
11
11
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
12
12
|
*
|
|
13
13
|
* @param props - The `FieldProps` for this template
|
|
14
14
|
*/
|
|
15
15
|
declare class AnyOfField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FieldProps<T, S, F>, AnyOfFieldState<S>> {
|
|
16
|
+
/** Flag to skip the formData-change-driven option recalculation when the user just selected an option.
|
|
17
|
+
* Set to true in the setState callback of onOptionChange (after onChange is called), consumed and reset in
|
|
18
|
+
* componentDidUpdate. This prevents the matching-option recalculation from overriding a user's explicit choice
|
|
19
|
+
* when getDefaultFormState populates undefined properties that make deepEquals see a false formData change.
|
|
20
|
+
*/
|
|
21
|
+
private skipNextOptionRecalculation;
|
|
16
22
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
17
23
|
*
|
|
18
24
|
* @param props - The `FieldProps` for this template
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAY,MAAM,aAAa,CAAC;AAmBvG,4DAA4D;AAC5D,UAAU,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU;IAC/D,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,CAAC,EAAE,CAAC;CACvB;AAED;;;;GAIG;AACH,cAAM,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACnH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,eAAe,CAAC,CAAC,CAAC,CACnB;IACC;;;;OAIG;IACH,OAAO,CAAC,2BAA2B,CAAS;IAC5C;;;OAGG;gBACS,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAiBtC;;;;;OAKG;IACH,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC;IA8BjG;;;;;OAKG;IACH,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;IAW/E;;;;;OAKG;IACH,cAAc,GAAI,SAAS,MAAM,UAyB/B;IAEF,UAAU;IAKV;OACG;IACH,MAAM;CA8HP;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -10,6 +10,12 @@ import omit from 'lodash-es/omit.js';
|
|
|
10
10
|
* @param props - The `FieldProps` for this template
|
|
11
11
|
*/
|
|
12
12
|
class AnyOfField extends Component {
|
|
13
|
+
/** 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;
|
|
13
19
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
14
20
|
*
|
|
15
21
|
* @param props - The `FieldProps` for this template
|
|
@@ -41,13 +47,19 @@ class AnyOfField extends Component {
|
|
|
41
47
|
newState = { selectedOption, retrievedOptions };
|
|
42
48
|
}
|
|
43
49
|
if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
if (this.skipNextOptionRecalculation) {
|
|
51
|
+
this.skipNextOptionRecalculation = false;
|
|
52
|
+
}
|
|
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
59
|
}
|
|
49
60
|
}
|
|
50
61
|
if (newState !== this.state) {
|
|
62
|
+
// oxlint-disable-next-line react/no-did-update-set-state -- guarded to prevent infinite loop
|
|
51
63
|
this.setState(newState);
|
|
52
64
|
}
|
|
53
65
|
}
|
|
@@ -71,7 +83,10 @@ class AnyOfField extends Component {
|
|
|
71
83
|
*/
|
|
72
84
|
onOptionChange = (option) => {
|
|
73
85
|
const { selectedOption, retrievedOptions } = this.state;
|
|
74
|
-
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
86
|
+
const { disabled = false, formData, onChange, readonly = false, registry, fieldPathId } = this.props;
|
|
87
|
+
if (disabled || readonly) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
75
90
|
const { schemaUtils } = registry;
|
|
76
91
|
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
77
92
|
if (intOption === selectedOption) {
|
|
@@ -86,6 +101,7 @@ class AnyOfField extends Component {
|
|
|
86
101
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
87
102
|
}
|
|
88
103
|
this.setState({ selectedOption: intOption }, () => {
|
|
104
|
+
this.skipNextOptionRecalculation = true;
|
|
89
105
|
onChange(newFormData, fieldPathId.path, undefined, this.getFieldId());
|
|
90
106
|
});
|
|
91
107
|
};
|
|
@@ -98,7 +114,7 @@ class AnyOfField extends Component {
|
|
|
98
114
|
render() {
|
|
99
115
|
const { name, disabled = false, errorSchema = {}, formData, onBlur, onFocus, readonly, required = false, registry, schema, uiSchema, } = this.props;
|
|
100
116
|
const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
|
|
101
|
-
const { SchemaField:
|
|
117
|
+
const { SchemaField: SchemaFieldComponent } = fields;
|
|
102
118
|
const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
|
|
103
119
|
const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
104
120
|
const hasFormData = isFormDataAvailable(formData);
|
|
@@ -112,9 +128,9 @@ class AnyOfField extends Component {
|
|
|
112
128
|
let optionSchema;
|
|
113
129
|
if (option) {
|
|
114
130
|
// merge top level required field
|
|
115
|
-
const { required } = schema;
|
|
131
|
+
const { required: schemaRequired } = schema;
|
|
116
132
|
// Merge in all the non-oneOf/anyOf properties and also skip the special ADDITIONAL_PROPERTY_FLAG property
|
|
117
|
-
optionSchema =
|
|
133
|
+
optionSchema = schemaRequired ? mergeSchemas({ required: schemaRequired }, option) : option;
|
|
118
134
|
}
|
|
119
135
|
// First we will check to see if there is an anyOf/oneOf override for the UI schema
|
|
120
136
|
let optionsUiSchema = [];
|
|
@@ -123,6 +139,7 @@ class AnyOfField extends Component {
|
|
|
123
139
|
optionsUiSchema = uiSchema[ONE_OF_KEY];
|
|
124
140
|
}
|
|
125
141
|
else {
|
|
142
|
+
// oxlint-disable-next-line no-console
|
|
126
143
|
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
127
144
|
}
|
|
128
145
|
}
|
|
@@ -131,6 +148,7 @@ class AnyOfField extends Component {
|
|
|
131
148
|
optionsUiSchema = uiSchema[ANY_OF_KEY];
|
|
132
149
|
}
|
|
133
150
|
else {
|
|
151
|
+
// oxlint-disable-next-line no-console
|
|
134
152
|
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
135
153
|
}
|
|
136
154
|
}
|
|
@@ -152,7 +170,7 @@ class AnyOfField extends Component {
|
|
|
152
170
|
};
|
|
153
171
|
});
|
|
154
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;
|
|
155
|
-
const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(
|
|
173
|
+
const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(SchemaFieldComponent, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
|
|
156
174
|
null;
|
|
157
175
|
return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
|
|
158
176
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `NullField` component is used to render a field in the schema is null. It also ensures that the `formData` is
|
|
3
3
|
* also set to null if it has no value.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NullField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NullField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"NullField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NullField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE7F;;;;GAIG;AACH,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,QAU3B;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/**
|
|
3
3
|
* The NumberField class has some special handling for dealing with trailing
|
|
4
4
|
* decimal points and/or zeroes. This logic is designed to allow trailing values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,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,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback } from 'react';
|
|
3
|
-
import { asNumber
|
|
3
|
+
import { asNumber } from '@rjsf/utils';
|
|
4
4
|
// Matches a string that ends in a . character, optionally followed by a sequence of
|
|
5
5
|
// digits followed by any number of 0 characters up until the end of the line.
|
|
6
6
|
// Ensuring that there is at least one prefixed character is important so that
|
|
@@ -37,20 +37,18 @@ function NumberField(props) {
|
|
|
37
37
|
*
|
|
38
38
|
* @param value - The current value for the change occurring
|
|
39
39
|
*/
|
|
40
|
-
const handleChange = useCallback((
|
|
40
|
+
const handleChange = useCallback((newValue, path, errorSchema, id) => {
|
|
41
41
|
// Cache the original value in component state
|
|
42
|
-
setLastValue(
|
|
42
|
+
setLastValue(newValue);
|
|
43
43
|
// Normalize decimals that don't start with a zero character in advance so
|
|
44
44
|
// that the rest of the normalization logic is simpler
|
|
45
|
-
|
|
46
|
-
value = `0${value}`;
|
|
47
|
-
}
|
|
45
|
+
const normalizedValue = `${newValue}`.startsWith('.') ? `0${newValue}` : newValue;
|
|
48
46
|
// Check that the value is a string (this can happen if the widget used is a
|
|
49
47
|
// <select>, due to an enum declaration etc) then, if the value ends in a
|
|
50
48
|
// trailing decimal point or multiple zeroes, strip the trailing values
|
|
51
|
-
const processed = typeof
|
|
52
|
-
? asNumber(
|
|
53
|
-
: asNumber(
|
|
49
|
+
const processed = typeof normalizedValue === 'string' && normalizedValue.match(trailingCharMatcherWithPrefix)
|
|
50
|
+
? asNumber(normalizedValue.replace(trailingCharMatcher, ''))
|
|
51
|
+
: asNumber(normalizedValue);
|
|
54
52
|
onChange(processed, path, errorSchema, id);
|
|
55
53
|
}, [onChange]);
|
|
56
54
|
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
|
|
3
3
|
* additional property key was modified and what it was modified to
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"
|
|
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,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { ADDITIONAL_PROPERTY_FLAG, ANY_OF_KEY, getTemplate, getUiOptions, isFormDataAvailable, orderProperties, shouldRenderOptionalField, toFieldPathId, useDeepCompareMemo, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, TranslatableString, } from '@rjsf/utils';
|
|
4
4
|
import get from 'lodash-es/get.js';
|
|
5
5
|
import has from 'lodash-es/has.js';
|
|
6
6
|
import isObject from 'lodash-es/isObject.js';
|
|
7
7
|
import set from 'lodash-es/set.js';
|
|
8
|
-
import { Markdown } from 'markdown-to-jsx';
|
|
8
|
+
import { Markdown } from 'markdown-to-jsx/react';
|
|
9
9
|
import { ADDITIONAL_PROPERTY_KEY_REMOVE } from '../constants.js';
|
|
10
10
|
/** Returns a flag indicating whether the `name` field is required in the object schema
|
|
11
11
|
*
|
|
@@ -14,7 +14,7 @@ import { ADDITIONAL_PROPERTY_KEY_REMOVE } from '../constants.js';
|
|
|
14
14
|
* @returns - True if the field `name` is required, false otherwise
|
|
15
15
|
*/
|
|
16
16
|
function isRequired(schema, name) {
|
|
17
|
-
return Array.isArray(schema.required) && schema.required.
|
|
17
|
+
return Array.isArray(schema.required) && schema.required.includes(name);
|
|
18
18
|
}
|
|
19
19
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
20
20
|
*
|
|
@@ -41,7 +41,7 @@ function getDefaultValue(translateString, type) {
|
|
|
41
41
|
}
|
|
42
42
|
/** The `ObjectFieldProperty` component is used to render the `SchemaField` for a child property of an object
|
|
43
43
|
*/
|
|
44
|
-
function
|
|
44
|
+
function ObjectFieldPropertyFn(props) {
|
|
45
45
|
const { fieldPathId, schema, registry, uiSchema, errorSchema, formData, onChange, onBlur, onFocus, disabled, readonly, required, hideError, propertyName, handleKeyRename, handleRemoveProperty, addedByAdditionalProperties, } = props;
|
|
46
46
|
const [wasPropertyKeyModified, setWasPropertyKeyModified] = useState(false);
|
|
47
47
|
const { globalFormOptions, fields } = registry;
|
|
@@ -56,14 +56,15 @@ function ObjectFieldProperty(props) {
|
|
|
56
56
|
* @returns - The onPropertyChange callback for the `name` property
|
|
57
57
|
*/
|
|
58
58
|
const onPropertyChange = useCallback((value, path, newErrorSchema, id) => {
|
|
59
|
+
// Don't set value = undefined for fields added by additionalProperties. Doing so removes them from the
|
|
60
|
+
// formData, which causes them to completely disappear (including the input field for the property name). Unlike
|
|
61
|
+
// fields which are "mandated" by the schema, these fields can be set to undefined by clicking a "delete field"
|
|
62
|
+
// button, so set empty values to the empty string.
|
|
63
|
+
let normalizedValue = value;
|
|
59
64
|
if (value === undefined && addedByAdditionalProperties) {
|
|
60
|
-
|
|
61
|
-
// formData, which causes them to completely disappear (including the input field for the property name). Unlike
|
|
62
|
-
// fields which are "mandated" by the schema, these fields can be set to undefined by clicking a "delete field"
|
|
63
|
-
// button, so set empty values to the empty string.
|
|
64
|
-
value = '';
|
|
65
|
+
normalizedValue = '';
|
|
65
66
|
}
|
|
66
|
-
onChange(
|
|
67
|
+
onChange(normalizedValue, path, newErrorSchema, id);
|
|
67
68
|
}, [onChange, addedByAdditionalProperties]);
|
|
68
69
|
/** The key change event handler; Called when the key associated with a field is changed for an additionalProperty.
|
|
69
70
|
* simply returns a function that call the `handleKeyChange()` event with the value
|
|
@@ -88,6 +89,7 @@ function ObjectFieldProperty(props) {
|
|
|
88
89
|
}, [propertyName, handleRemoveProperty]);
|
|
89
90
|
return (_jsx(SchemaField, { name: propertyName, required: required, schema: schema, uiSchema: uiSchema, errorSchema: errorSchema, fieldPathId: innerFieldIdPathId, formData: formData, wasPropertyKeyModified: wasPropertyKeyModified, onKeyRename: onKeyRename, onKeyRenameBlur: onKeyRenameBlur, onRemoveProperty: onRemoveProperty, onChange: onPropertyChange, onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError }));
|
|
90
91
|
}
|
|
92
|
+
const ObjectFieldProperty = memo(ObjectFieldPropertyFn);
|
|
91
93
|
/** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
|
|
92
94
|
* additional property key was modified and what it was modified to
|
|
93
95
|
*
|
|
@@ -99,8 +101,8 @@ export default function ObjectField(props) {
|
|
|
99
101
|
const { OptionalDataControlsField } = fields;
|
|
100
102
|
const formDataRef = useRef(formData);
|
|
101
103
|
formDataRef.current = formData;
|
|
102
|
-
const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
|
|
103
|
-
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
104
|
+
const schema = useMemo(() => schemaUtils.retrieveSchema(rawSchema, formData, true), [schemaUtils, rawSchema, formData]);
|
|
105
|
+
const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
104
106
|
const { properties: schemaProperties = {} } = schema;
|
|
105
107
|
// All the children will use childFieldPathId if present in the props, falling back to the fieldPathId
|
|
106
108
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
@@ -117,12 +119,13 @@ export default function ObjectField(props) {
|
|
|
117
119
|
* @param [formData] - The form data in which to check if the desired key already exists
|
|
118
120
|
* @returns - The name of the next available key from `preferredKey`
|
|
119
121
|
*/
|
|
120
|
-
const getAvailableKey = useCallback((preferredKey,
|
|
122
|
+
const getAvailableKey = useCallback((preferredKey, existingFormData) => {
|
|
121
123
|
const { duplicateKeySuffixSeparator = '-' } = getUiOptions(uiSchema, globalUiOptions);
|
|
122
124
|
let index = 0;
|
|
123
125
|
let newKey = preferredKey;
|
|
124
|
-
while (has(
|
|
125
|
-
|
|
126
|
+
while (has(existingFormData, newKey)) {
|
|
127
|
+
index += 1;
|
|
128
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
126
129
|
}
|
|
127
130
|
return newKey;
|
|
128
131
|
}, [uiSchema, globalUiOptions]);
|
|
@@ -133,7 +136,6 @@ export default function ObjectField(props) {
|
|
|
133
136
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
134
137
|
return;
|
|
135
138
|
}
|
|
136
|
-
const { translateString } = registry;
|
|
137
139
|
const newFormData = { ...formData };
|
|
138
140
|
const newKey = getAvailableKey('newKey', newFormData);
|
|
139
141
|
if (schema.patternProperties) {
|
|
@@ -150,7 +152,6 @@ export default function ObjectField(props) {
|
|
|
150
152
|
defaultValue = schema.additionalProperties.default;
|
|
151
153
|
let apSchema = schema.additionalProperties;
|
|
152
154
|
if (REF_KEY in apSchema) {
|
|
153
|
-
const { schemaUtils } = registry;
|
|
154
155
|
apSchema = schemaUtils.retrieveSchema({ [REF_KEY]: apSchema[REF_KEY] }, formData);
|
|
155
156
|
type = apSchema.type;
|
|
156
157
|
constValue = apSchema.const;
|
|
@@ -169,7 +170,7 @@ export default function ObjectField(props) {
|
|
|
169
170
|
lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
|
|
170
171
|
}
|
|
171
172
|
onChange(newFormData, childFieldPathId.path);
|
|
172
|
-
}, [formData, onChange,
|
|
173
|
+
}, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
|
|
173
174
|
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
174
175
|
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
175
176
|
*
|
|
@@ -186,8 +187,9 @@ export default function ObjectField(props) {
|
|
|
186
187
|
};
|
|
187
188
|
const newKeys = { [oldKey]: actualNewKey };
|
|
188
189
|
const keyValues = Object.keys(newFormData).map((key) => {
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
// `Object.hasOwn` so a falsy rename target (e.g. `""`) isn't dropped.
|
|
191
|
+
const mappedKey = Object.hasOwn(newKeys, key) ? newKeys[key] : key;
|
|
192
|
+
return { [mappedKey]: newFormData[key] };
|
|
191
193
|
});
|
|
192
194
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
193
195
|
formDataRef.current = renamedObj;
|
|
@@ -230,14 +232,14 @@ export default function ObjectField(props) {
|
|
|
230
232
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
231
233
|
title: uiOptions.label === false ? '' : templateTitle,
|
|
232
234
|
description: uiOptions.label === false ? undefined : description,
|
|
233
|
-
properties: orderedProperties.map((
|
|
234
|
-
const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY,
|
|
235
|
-
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[
|
|
235
|
+
properties: orderedProperties.map((propertyName) => {
|
|
236
|
+
const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, propertyName, ADDITIONAL_PROPERTY_FLAG]);
|
|
237
|
+
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
|
|
236
238
|
const hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
237
|
-
const content = (_jsx(ObjectFieldProperty, { propertyName:
|
|
239
|
+
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)));
|
|
238
240
|
return {
|
|
239
241
|
content,
|
|
240
|
-
name,
|
|
242
|
+
name: propertyName,
|
|
241
243
|
readonly,
|
|
242
244
|
disabled,
|
|
243
245
|
required,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `OptionalDataControlsField` component is used to render the optional data controls for the field associated
|
|
3
3
|
* with the given props.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionalDataControlsField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/OptionalDataControlsField.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
3
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
4
4
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
5
5
|
*/
|
|
@@ -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":"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"}
|
|
@@ -23,7 +23,7 @@ const COMPONENT_TYPES = {
|
|
|
23
23
|
* @returns - The `Field` component that is used to render the actual field data
|
|
24
24
|
*/
|
|
25
25
|
function getFieldComponent(schema, uiOptions, registry) {
|
|
26
|
-
const field = uiOptions
|
|
26
|
+
const { field } = uiOptions;
|
|
27
27
|
const { fields } = registry;
|
|
28
28
|
if (typeof field === 'function') {
|
|
29
29
|
return field;
|
|
@@ -43,7 +43,7 @@ function getFieldComponent(schema, uiOptions, registry) {
|
|
|
43
43
|
if (!componentName && (schema.anyOf || schema.oneOf)) {
|
|
44
44
|
return () => null;
|
|
45
45
|
}
|
|
46
|
-
return componentName in fields ? fields[componentName] : fields
|
|
46
|
+
return componentName in fields ? fields[componentName] : fields.FallbackField;
|
|
47
47
|
}
|
|
48
48
|
/** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
|
|
49
49
|
* render based on the `schema`, `uiSchema` and all the other props. It also deals with rendering the `anyOf` and
|
|
@@ -66,9 +66,9 @@ function SchemaFieldRender(props) {
|
|
|
66
66
|
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
67
67
|
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
68
68
|
*/
|
|
69
|
-
const handleFieldComponentChange = useCallback((
|
|
69
|
+
const handleFieldComponentChange = useCallback((newFormData, path, newErrorSchema, id) => {
|
|
70
70
|
const theId = id || fieldId;
|
|
71
|
-
return onChange(
|
|
71
|
+
return onChange(newFormData, path, newErrorSchema, theId);
|
|
72
72
|
}, [fieldId, onChange]);
|
|
73
73
|
const FieldComponent = getFieldComponent(schema, uiOptions, registry);
|
|
74
74
|
const isDeprecated = Boolean(schema.deprecated);
|
|
@@ -95,11 +95,11 @@ function SchemaFieldRender(props) {
|
|
|
95
95
|
if ((ANY_OF_KEY in schema || ONE_OF_KEY in schema) && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema)) {
|
|
96
96
|
if (schema[ANY_OF_KEY]) {
|
|
97
97
|
XxxOfField = _AnyOfField;
|
|
98
|
-
XxxOfOptions = schema[ANY_OF_KEY].map((
|
|
98
|
+
XxxOfOptions = schema[ANY_OF_KEY].map((xxxOfSchema) => schemaUtils.retrieveSchema(isObject(xxxOfSchema) ? xxxOfSchema : {}, formData));
|
|
99
99
|
}
|
|
100
100
|
else if (schema[ONE_OF_KEY]) {
|
|
101
101
|
XxxOfField = _OneOfField;
|
|
102
|
-
XxxOfOptions = schema[ONE_OF_KEY].map((
|
|
102
|
+
XxxOfOptions = schema[ONE_OF_KEY].map((xxxOfSchema) => schemaUtils.retrieveSchema(isObject(xxxOfSchema) ? xxxOfSchema : {}, formData));
|
|
103
103
|
}
|
|
104
104
|
// When the anyOf/oneOf is an optional data control render AND it does not have form data, hide the label
|
|
105
105
|
const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
@@ -135,7 +135,7 @@ function SchemaFieldRender(props) {
|
|
|
135
135
|
label = registry.translateString(TranslatableString.DeprecatedLabel, [label]);
|
|
136
136
|
}
|
|
137
137
|
const description = uiOptions.description || props.schema.description || schema.description || '';
|
|
138
|
-
const help = uiOptions
|
|
138
|
+
const { help } = uiOptions;
|
|
139
139
|
const hidden = uiOptions.widget === 'hidden' || deprecatedHandling === 'hide';
|
|
140
140
|
const classNames = ['rjsf-field', `rjsf-field-${getSchemaType(schema)}`];
|
|
141
141
|
if (!hideError && __errors && __errors.length > 0) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
3
3
|
*
|
|
4
4
|
* @param props - The `FieldProps` for this template
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"StringField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAe,MAAM,aAAa,CAAC;AAG1G;;;GAGG;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,2CA4D3B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { getWidget, getUiOptions, optionsList, hasWidget
|
|
3
|
+
import { getWidget, getUiOptions, optionsList, hasWidget } from '@rjsf/utils';
|
|
4
4
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
5
5
|
*
|
|
6
6
|
* @param props - The `FieldProps` for this template
|
|
@@ -18,10 +18,7 @@ function StringField(props) {
|
|
|
18
18
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
19
19
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
20
20
|
const Widget = getWidget(schema, widget, widgets);
|
|
21
|
-
const onWidgetChange = useCallback((value, errorSchema, id) =>
|
|
22
|
-
// String field change passes an empty path array to the parent field which adds the appropriate path
|
|
23
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
24
|
-
}, [onChange, fieldPathId]);
|
|
21
|
+
const onWidgetChange = useCallback((value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id), [onChange, fieldPathId]);
|
|
25
22
|
return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: fieldPathId.$id, name: name, label: label, hideLabel: !displayLabel, hideError: hideError, value: formData, onChange: onWidgetChange, onBlur: onBlur, onFocus: onFocus, required: required, disabled: disabled, readonly: readonly, autofocus: autofocus, registry: registry, placeholder: placeholder, rawErrors: rawErrors, htmlName: fieldPathId.name }));
|
|
26
23
|
}
|
|
27
24
|
export default StringField;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RegistryFieldsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RegistryFieldsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
declare function fields<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(): RegistryFieldsType<T, S, F>;
|
|
3
3
|
export default fields;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAgB5G,iBAAS,MAAM,CACb,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAkB/B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayFieldDescriptionProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ArrayFieldDescriptionProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
|
|
3
3
|
* the `fieldPathId`.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayFieldDescriptionTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldDescriptionTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ArrayFieldDescriptionTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldDescriptionTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG7G;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,6BAA6B,CACnD,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,0BAA0B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDAqB3C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { descriptionId, getTemplate, getUiOptions
|
|
2
|
+
import { descriptionId, getTemplate, getUiOptions } from '@rjsf/utils';
|
|
3
3
|
/** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
|
|
4
4
|
* the `fieldPathId`.
|
|
5
5
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayFieldItemButtonsTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ArrayFieldItemButtonsTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldTemplateItemButtons` component is the template used to render the buttons associate3d with items of
|
|
3
3
|
* an array.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayFieldItemButtonsTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldItemButtonsTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ArrayFieldItemButtonsTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldItemButtonsTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGrH;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,6BAA6B,CACnD,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,kCAAkC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA8DnD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { buttonId
|
|
2
|
+
import { buttonId } from '@rjsf/utils';
|
|
3
3
|
/** The `ArrayFieldTemplateItemButtons` component is the template used to render the buttons associate3d with items of
|
|
4
4
|
* an array.
|
|
5
5
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
3
3
|
*
|
|
4
4
|
* @param props - The `ArrayFieldItemTemplateProps` props for the component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayFieldItemTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldItemTemplate.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"ArrayFieldItemTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldItemTemplate.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9G;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,2BAA2B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA6B5C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getTemplate, getUiOptions
|
|
2
|
+
import { getTemplate, getUiOptions } from '@rjsf/utils';
|
|
3
3
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `ArrayFieldItemTemplateProps` props for the component
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
3
3
|
*
|
|
4
4
|
* @param props - The `ArrayFieldTemplateProps` props for the component
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ArrayFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG1G;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAgExC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getTemplate, getUiOptions, buttonId
|
|
2
|
+
import { getTemplate, getUiOptions, buttonId } from '@rjsf/utils';
|
|
3
3
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `ArrayFieldTemplateProps` props for the component
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayFieldTitleProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ArrayFieldTitleProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
3
3
|
* the `fieldPathId`.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayFieldTitleTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTitleTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ArrayFieldTitleTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTitleTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAiB,MAAM,aAAa,CAAC;AAGtH;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDAuBrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getTemplate, getUiOptions, titleId
|
|
2
|
+
import { getTemplate, getUiOptions, titleId } from '@rjsf/utils';
|
|
3
3
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
4
4
|
* the `fieldPathId`.
|
|
5
5
|
*
|