@rjsf/core 6.0.0-beta.9 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/core.umd.js +2042 -1987
- package/dist/index.cjs +4909 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +2509 -2389
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +137 -34
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +318 -173
- package/lib/components/fields/ArrayField.d.ts +2 -187
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +526 -492
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +8 -3
- package/lib/components/fields/FallbackField.d.ts +7 -0
- package/lib/components/fields/FallbackField.d.ts.map +1 -0
- package/lib/components/fields/FallbackField.js +72 -0
- package/lib/components/fields/LayoutGridField.d.ts +109 -186
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +426 -426
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.js +3 -3
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +6 -6
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +16 -10
- package/lib/components/fields/NullField.js +3 -3
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +3 -3
- package/lib/components/fields/ObjectField.d.ts +2 -68
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +163 -163
- package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
- package/lib/components/fields/OptionalDataControlsField.js +43 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +52 -30
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +8 -3
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +4 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +3 -8
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +3 -3
- 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 +4 -5
- 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 +3 -3
- 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/AddButton.js +2 -2
- package/lib/components/templates/FallbackFieldTemplate.d.ts +7 -0
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/FallbackFieldTemplate.js +12 -0
- package/lib/components/templates/FieldErrorTemplate.js +2 -2
- package/lib/components/templates/FieldHelpTemplate.js +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +3 -2
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
- package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/TitleField.js +2 -2
- package/lib/components/templates/UnsupportedField.js +3 -3
- package/lib/components/templates/WrapIfAdditionalTemplate.js +2 -2
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +6 -0
- 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 +5 -46
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxWidget.js +2 -2
- 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 +4 -4
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.js +7 -87
- package/lib/components/widgets/HiddenWidget.d.ts +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/HiddenWidget.js +2 -2
- 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/RatingWidget.d.ts +1 -1
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.js +2 -2
- 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 +2 -2
- 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/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +6 -1
- package/lib/getTestRegistry.d.ts +5 -0
- package/lib/getTestRegistry.d.ts.map +1 -0
- package/lib/getTestRegistry.js +23 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -20
- package/src/components/Form.tsx +468 -206
- package/src/components/fields/ArrayField.tsx +871 -723
- package/src/components/fields/BooleanField.tsx +14 -5
- package/src/components/fields/FallbackField.tsx +157 -0
- package/src/components/fields/LayoutGridField.tsx +626 -603
- package/src/components/fields/LayoutHeaderField.tsx +3 -3
- package/src/components/fields/LayoutMultiSchemaField.tsx +9 -10
- package/src/components/fields/MultiSchemaField.tsx +57 -36
- package/src/components/fields/NullField.tsx +3 -3
- package/src/components/fields/NumberField.tsx +11 -3
- package/src/components/fields/ObjectField.tsx +308 -239
- package/src/components/fields/OptionalDataControlsField.tsx +84 -0
- package/src/components/fields/SchemaField.tsx +75 -94
- package/src/components/fields/StringField.tsx +14 -5
- package/src/components/fields/index.ts +4 -0
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +16 -21
- package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldTemplate.tsx +11 -18
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
- package/src/components/templates/BaseInputTemplate.tsx +5 -5
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
- package/src/components/templates/FallbackFieldTemplate.tsx +28 -0
- package/src/components/templates/FieldErrorTemplate.tsx +2 -2
- package/src/components/templates/FieldHelpTemplate.tsx +2 -2
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +12 -7
- package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
- package/src/components/templates/TitleField.tsx +6 -1
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +5 -5
- package/src/components/templates/index.ts +6 -0
- package/src/components/widgets/AltDateWidget.tsx +8 -126
- package/src/components/widgets/CheckboxWidget.tsx +4 -3
- package/src/components/widgets/CheckboxesWidget.tsx +5 -4
- package/src/components/widgets/FileWidget.tsx +11 -102
- package/src/components/widgets/HiddenWidget.tsx +2 -1
- package/src/components/widgets/RadioWidget.tsx +3 -2
- package/src/components/widgets/RatingWidget.tsx +2 -1
- package/src/components/widgets/SelectWidget.tsx +3 -2
- package/src/components/widgets/TextareaWidget.tsx +3 -2
- package/src/getDefaultRegistry.ts +14 -1
- package/src/getTestRegistry.tsx +38 -0
- package/src/index.ts +2 -1
- package/dist/index.js +0 -4834
- package/dist/index.js.map +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
-
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `
|
|
2
|
+
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
|
|
3
3
|
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
4
4
|
* - If there is a title in the `uiSchema`, it is displayed
|
|
5
5
|
* - Else, if there is an explicit `title` passed in the props, it is displayed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
|
|
3
|
-
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `
|
|
3
|
+
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
|
|
4
4
|
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
5
5
|
* - If there is a title in the `uiSchema`, it is displayed
|
|
6
6
|
* - Else, if there is an explicit `title` passed in the props, it is displayed
|
|
@@ -10,7 +10,7 @@ import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
|
|
|
10
10
|
* @param props - The `LayoutHeaderField` for the component
|
|
11
11
|
*/
|
|
12
12
|
export default function LayoutHeaderField(props) {
|
|
13
|
-
const {
|
|
13
|
+
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
14
14
|
const options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
15
15
|
const { title: uiTitle } = options;
|
|
16
16
|
const { title: schemaTitle } = schema;
|
|
@@ -19,5 +19,5 @@ export default function LayoutHeaderField(props) {
|
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
22
|
-
return (_jsx(TitleFieldTemplate, { id: titleId(
|
|
22
|
+
return (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: fieldTitle, required: required, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,eAAe,EAEf,UAAU,EACV,eAAe,EAOf,UAAU,EAIV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,aAAa,CAAC;AAQrB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,GACb,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,GACX,eAAe,CAAC,CAAC,CAAC,EAAE,CAatB;AAED;;;;;GAKG;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,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,eAAe,EAEf,UAAU,EACV,eAAe,EAOf,UAAU,EAIV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,aAAa,CAAC;AAQrB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,GACb,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,GACX,eAAe,CAAC,CAAC,CAAC,EAAE,CAatB;AAED;;;;;GAKG;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,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsI3B"}
|
|
@@ -55,10 +55,10 @@ export function computeEnumOptions(schema, options, schemaUtils, uiSchema, formD
|
|
|
55
55
|
* is active. If no `selectorField` is specified, then an error is thrown.
|
|
56
56
|
*/
|
|
57
57
|
export default function LayoutMultiSchemaField(props) {
|
|
58
|
-
const { name, baseType, disabled = false, formData,
|
|
58
|
+
const { name, baseType, disabled = false, formData, fieldPathId, onBlur, onChange, options, onFocus, registry, uiSchema, schema, autofocus, readonly, required, errorSchema, hideError = false, } = props;
|
|
59
59
|
const { widgets, schemaUtils, globalUiOptions } = registry;
|
|
60
60
|
const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
61
|
-
const id = get(
|
|
61
|
+
const id = get(fieldPathId, ID_KEY);
|
|
62
62
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
63
63
|
const FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, options);
|
|
64
64
|
const FieldTemplate = getTemplate('FieldTemplate', registry, options);
|
|
@@ -104,11 +104,11 @@ export default function LayoutMultiSchemaField(props) {
|
|
|
104
104
|
if (newFormData) {
|
|
105
105
|
set(newFormData, selectorField, opt);
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
// Pass the component name in the path
|
|
108
|
+
onChange(newFormData, fieldPathId.path, undefined, id);
|
|
108
109
|
};
|
|
109
110
|
// filtering the options based on the type of widget because `selectField` does not recognize the `convertOther` prop
|
|
110
111
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
111
|
-
const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, {
|
|
112
|
-
|
|
113
|
-
return (_jsx(FieldTemplate, { id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, formContext: formContext, required: required, readonly: !!readonly, registry: registry, displayLabel: displayLabel, errors: errors, onChange: onChange, onDropPropertyClick: ignored, onKeyChange: ignored, children: _jsx(Widget, { id: id, name: name, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, formContext: formContext, autofocus: autofocus, readonly: readonly, required: required, registry: registry, multiple: false, rawErrors: rawErrors, hideError: hideFieldError, hideLabel: !displayLabel, errorSchema: fieldErrorSchema, placeholder: placeholder, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, value: selectedOption, options: widgetOptions }) }));
|
|
112
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, { fieldPathId: fieldPathId, schema: schema, errors: rawErrors, registry: registry })) : undefined;
|
|
113
|
+
return (_jsx(FieldTemplate, { id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, required: required, readonly: !!readonly, registry: registry, displayLabel: displayLabel, errors: errors, onChange: onChange, onKeyRename: noop, onKeyRenameBlur: noop, onRemoveProperty: noop, children: _jsx(Widget, { id: id, name: name, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, autofocus: autofocus, readonly: readonly, required: required, registry: registry, multiple: false, rawErrors: rawErrors, hideError: hideFieldError, hideLabel: !displayLabel, errorSchema: fieldErrorSchema, placeholder: placeholder, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, value: selectedOption, options: widgetOptions, htmlName: fieldPathId.name }) }));
|
|
114
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAIL,UAAU,EACV,eAAe,
|
|
1
|
+
{"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAIL,UAAU,EACV,eAAe,EAQf,UAAU,EAEV,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAErB,4DAA4D;AAC5D,KAAK,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,IAAI;IAC9D,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,CAAC,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,cAAM,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACnH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,eAAe,CAAC,CAAC,CAAC,CACnB;IACC;;;OAGG;gBACS,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAiBtC;;;;;OAKG;IACH,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC;IAyBjG;;;;;OAKG;IACH,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;IAW/E;;;;;OAKG;IACH,cAAc,GAAI,SAAS,MAAM,UAqB/B;IAEF,UAAU;IAKV;OACG;IACH,MAAM;CA4HP;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import get from 'lodash-es/get.js';
|
|
4
4
|
import isEmpty from 'lodash-es/isEmpty.js';
|
|
5
5
|
import omit from 'lodash-es/omit.js';
|
|
6
|
-
import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getUiOptions, getWidget, mergeSchemas, ONE_OF_KEY, TranslatableString, } from '@rjsf/utils';
|
|
6
|
+
import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getTemplate, getUiOptions, getWidget, isFormDataAvailable, mergeSchemas, ONE_OF_KEY, shouldRenderOptionalField, TranslatableString, } from '@rjsf/utils';
|
|
7
7
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
8
8
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
9
9
|
*
|
|
@@ -31,7 +31,7 @@ class AnyOfField extends Component {
|
|
|
31
31
|
* @param prevState - The previous `AnyOfFieldState` for this template
|
|
32
32
|
*/
|
|
33
33
|
componentDidUpdate(prevProps, prevState) {
|
|
34
|
-
const { formData, options,
|
|
34
|
+
const { formData, options, fieldPathId } = this.props;
|
|
35
35
|
const { selectedOption } = this.state;
|
|
36
36
|
let newState = this.state;
|
|
37
37
|
if (!deepEquals(prevProps.options, options)) {
|
|
@@ -40,7 +40,7 @@ class AnyOfField extends Component {
|
|
|
40
40
|
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
41
41
|
newState = { selectedOption, retrievedOptions };
|
|
42
42
|
}
|
|
43
|
-
if (!deepEquals(formData, prevProps.formData) &&
|
|
43
|
+
if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
44
44
|
const { retrievedOptions } = newState;
|
|
45
45
|
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
46
46
|
if (prevState && matchingOption !== selectedOption) {
|
|
@@ -71,7 +71,7 @@ class AnyOfField extends Component {
|
|
|
71
71
|
*/
|
|
72
72
|
onOptionChange = (option) => {
|
|
73
73
|
const { selectedOption, retrievedOptions } = this.state;
|
|
74
|
-
const { formData, onChange, registry } = this.props;
|
|
74
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
75
75
|
const { schemaUtils } = registry;
|
|
76
76
|
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
77
77
|
if (intOption === selectedOption) {
|
|
@@ -86,19 +86,22 @@ class AnyOfField extends Component {
|
|
|
86
86
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
87
87
|
}
|
|
88
88
|
this.setState({ selectedOption: intOption }, () => {
|
|
89
|
-
onChange(newFormData, undefined, this.getFieldId());
|
|
89
|
+
onChange(newFormData, fieldPathId.path, undefined, this.getFieldId());
|
|
90
90
|
});
|
|
91
91
|
};
|
|
92
92
|
getFieldId() {
|
|
93
|
-
const {
|
|
94
|
-
return `${
|
|
93
|
+
const { fieldPathId, schema } = this.props;
|
|
94
|
+
return `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
|
|
95
95
|
}
|
|
96
96
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
97
97
|
*/
|
|
98
98
|
render() {
|
|
99
|
-
const { name, disabled = false, errorSchema = {},
|
|
99
|
+
const { name, disabled = false, errorSchema = {}, formData, onBlur, onFocus, readonly, required = false, registry, schema, uiSchema, } = this.props;
|
|
100
100
|
const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
|
|
101
101
|
const { SchemaField: _SchemaField } = fields;
|
|
102
|
+
const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
|
|
103
|
+
const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
104
|
+
const hasFormData = isFormDataAvailable(formData);
|
|
102
105
|
const { selectedOption, retrievedOptions } = this.state;
|
|
103
106
|
const { widget = 'select', placeholder, autofocus, autocomplete, title = schema.title, ...uiOptions } = getUiOptions(uiSchema, globalUiOptions);
|
|
104
107
|
const Widget = getWidget({ type: 'number' }, widget, widgets);
|
|
@@ -148,7 +151,10 @@ class AnyOfField extends Component {
|
|
|
148
151
|
value: index,
|
|
149
152
|
};
|
|
150
153
|
});
|
|
151
|
-
|
|
154
|
+
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(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
|
|
156
|
+
null;
|
|
157
|
+
return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
160
|
export default AnyOfField;
|
|
@@ -5,12 +5,12 @@ import { useEffect } from 'react';
|
|
|
5
5
|
* @param props - The `FieldProps` for this template
|
|
6
6
|
*/
|
|
7
7
|
function NullField(props) {
|
|
8
|
-
const { formData, onChange } = props;
|
|
8
|
+
const { formData, onChange, fieldPathId } = props;
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
if (formData === undefined) {
|
|
11
|
-
onChange(null);
|
|
11
|
+
onChange(null, fieldPathId.path);
|
|
12
12
|
}
|
|
13
|
-
}, [formData, onChange]);
|
|
13
|
+
}, [fieldPathId, formData, onChange]);
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
export default NullField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAcrB;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkD3B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useCallback } from 'react';
|
|
3
|
-
import { asNumber } from '@rjsf/utils';
|
|
3
|
+
import { asNumber, } from '@rjsf/utils';
|
|
4
4
|
// Matches a string that ends in a . character, optionally followed by a sequence of
|
|
5
5
|
// digits followed by any number of 0 characters up until the end of the line.
|
|
6
6
|
// Ensuring that there is at least one prefixed character is important so that
|
|
@@ -37,7 +37,7 @@ function NumberField(props) {
|
|
|
37
37
|
*
|
|
38
38
|
* @param value - The current value for the change occurring
|
|
39
39
|
*/
|
|
40
|
-
const handleChange = useCallback((value, errorSchema, id) => {
|
|
40
|
+
const handleChange = useCallback((value, path, errorSchema, id) => {
|
|
41
41
|
// Cache the original value in component state
|
|
42
42
|
setLastValue(value);
|
|
43
43
|
// Normalize decimals that don't start with a zero character in advance so
|
|
@@ -51,7 +51,7 @@ function NumberField(props) {
|
|
|
51
51
|
const processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix)
|
|
52
52
|
? asNumber(value.replace(trailingCharMatcher, ''))
|
|
53
53
|
: asNumber(value);
|
|
54
|
-
onChange(processed, errorSchema, id);
|
|
54
|
+
onChange(processed, path, errorSchema, id);
|
|
55
55
|
}, [onChange]);
|
|
56
56
|
if (typeof lastValue === 'string' && typeof value === 'number') {
|
|
57
57
|
// Construct a regular expression that checks for a string that consists
|
|
@@ -1,74 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ErrorSchema, FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
-
/** Type used for the state of the `ObjectField` component */
|
|
4
|
-
type ObjectFieldState = {
|
|
5
|
-
/** Flag indicating whether an additional property key was modified */
|
|
6
|
-
wasPropertyKeyModified: boolean;
|
|
7
|
-
/** The set of additional properties */
|
|
8
|
-
additionalProperties: object;
|
|
9
|
-
};
|
|
1
|
+
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
10
2
|
/** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
|
|
11
3
|
* additional property key was modified and what it was modified to
|
|
12
4
|
*
|
|
13
5
|
* @param props - The `FieldProps` for this template
|
|
14
6
|
*/
|
|
15
|
-
|
|
16
|
-
/** Set up the initial state */
|
|
17
|
-
state: {
|
|
18
|
-
wasPropertyKeyModified: boolean;
|
|
19
|
-
additionalProperties: {};
|
|
20
|
-
};
|
|
21
|
-
/** Returns a flag indicating whether the `name` field is required in the object schema
|
|
22
|
-
*
|
|
23
|
-
* @param name - The name of the field to check for required-ness
|
|
24
|
-
* @returns - True if the field `name` is required, false otherwise
|
|
25
|
-
*/
|
|
26
|
-
isRequired(name: string): boolean;
|
|
27
|
-
/** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
|
|
28
|
-
* to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
|
|
29
|
-
* formData.
|
|
30
|
-
*
|
|
31
|
-
* @param name - The name of the property
|
|
32
|
-
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
33
|
-
* @returns - The onPropertyChange callback for the `name` property
|
|
34
|
-
*/
|
|
35
|
-
onPropertyChange: (name: string, addedByAdditionalProperties?: boolean) => (value: T | undefined, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
|
|
36
|
-
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
37
|
-
* and calls the `onChange` callback with it
|
|
38
|
-
*
|
|
39
|
-
* @param key - The key for which the drop callback is desired
|
|
40
|
-
* @returns - The drop property click callback
|
|
41
|
-
*/
|
|
42
|
-
onDropPropertyClick: (key: string) => (event: DragEvent) => void;
|
|
43
|
-
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
44
|
-
* that is already not assigned is found.
|
|
45
|
-
*
|
|
46
|
-
* @param preferredKey - The preferred name of a new key
|
|
47
|
-
* @param [formData] - The form data in which to check if the desired key already exists
|
|
48
|
-
* @returns - The name of the next available key from `preferredKey`
|
|
49
|
-
*/
|
|
50
|
-
getAvailableKey: (preferredKey: string, formData?: T) => string;
|
|
51
|
-
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
52
|
-
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
53
|
-
*
|
|
54
|
-
* @param oldValue - The old value of a field
|
|
55
|
-
* @returns - The key change callback function
|
|
56
|
-
*/
|
|
57
|
-
onKeyChange: (oldValue: any) => (value: any, newErrorSchema: ErrorSchema<T>) => void;
|
|
58
|
-
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
59
|
-
*
|
|
60
|
-
* @param type - The type of the new additional schema property
|
|
61
|
-
*/
|
|
62
|
-
getDefaultValue(type?: RJSFSchema['type']): {} | null;
|
|
63
|
-
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
64
|
-
* default data for that field has been added to the formData.
|
|
65
|
-
*
|
|
66
|
-
* @param schema - The schema element to which the new property is being added
|
|
67
|
-
*/
|
|
68
|
-
handleAddClick: (schema: S) => () => void;
|
|
69
|
-
/** Renders the `ObjectField` from the given props
|
|
70
|
-
*/
|
|
71
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
72
|
-
}
|
|
73
|
-
export default ObjectField;
|
|
7
|
+
export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
74
8
|
//# sourceMappingURL=ObjectField.d.ts.map
|
|
@@ -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":"AACA,OAAO,EAcL,UAAU,EACV,eAAe,EAMf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAuKrB;;;;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,2CAqN3B"}
|