@rjsf/core 6.0.0-alpha.0 → 6.0.0-beta.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 +1680 -809
- package/dist/index.esm.js +2166 -1198
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +2221 -1299
- package/dist/index.js.map +4 -4
- package/lib/components/Form.d.ts +22 -9
- package/lib/components/Form.d.ts.map +1 -0
- package/lib/components/Form.js +368 -312
- package/lib/components/RichDescription.d.ts +20 -0
- package/lib/components/RichDescription.d.ts.map +1 -0
- package/lib/components/RichDescription.js +17 -0
- package/lib/components/fields/ArrayField.d.ts +20 -9
- package/lib/components/fields/ArrayField.d.ts.map +1 -0
- package/lib/components/fields/ArrayField.js +212 -206
- package/lib/components/fields/BooleanField.d.ts +1 -0
- package/lib/components/fields/BooleanField.d.ts.map +1 -0
- package/lib/components/fields/BooleanField.js +6 -14
- package/lib/components/fields/LayoutGridField.d.ts +480 -0
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -0
- package/lib/components/fields/LayoutGridField.js +711 -0
- package/lib/components/fields/LayoutHeaderField.d.ts +12 -0
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -0
- package/lib/components/fields/LayoutHeaderField.js +23 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +28 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -0
- package/lib/components/fields/LayoutMultiSchemaField.js +114 -0
- package/lib/components/fields/MultiSchemaField.d.ts +1 -0
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -0
- package/lib/components/fields/MultiSchemaField.js +31 -31
- package/lib/components/fields/NullField.d.ts +1 -0
- package/lib/components/fields/NullField.d.ts.map +1 -0
- package/lib/components/fields/NullField.js +0 -1
- package/lib/components/fields/NumberField.d.ts +1 -0
- package/lib/components/fields/NumberField.d.ts.map +1 -0
- package/lib/components/fields/NumberField.js +2 -3
- package/lib/components/fields/ObjectField.d.ts +1 -0
- package/lib/components/fields/ObjectField.d.ts.map +1 -0
- package/lib/components/fields/ObjectField.js +146 -141
- package/lib/components/fields/SchemaField.d.ts +1 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -0
- package/lib/components/fields/SchemaField.js +10 -20
- package/lib/components/fields/StringField.d.ts +1 -0
- package/lib/components/fields/StringField.d.ts.map +1 -0
- package/lib/components/fields/StringField.js +1 -3
- package/lib/components/fields/index.d.ts +1 -0
- package/lib/components/fields/index.d.ts.map +1 -0
- package/lib/components/fields/index.js +14 -9
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +0 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +8 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +17 -0
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +4 -3
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js +7 -6
- package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js +3 -4
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js +0 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -0
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -0
- package/lib/components/templates/BaseInputTemplate.js +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js +1 -2
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js +4 -5
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +0 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/index.js +3 -4
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.d.ts.map +1 -0
- package/lib/components/templates/DescriptionField.js +3 -8
- package/lib/components/templates/ErrorList.d.ts +1 -0
- package/lib/components/templates/ErrorList.d.ts.map +1 -0
- package/lib/components/templates/ErrorList.js +0 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -0
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldErrorTemplate.js +0 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -0
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldHelpTemplate.js +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -2
- package/lib/components/templates/FieldTemplate/Label.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/Label.js +0 -1
- package/lib/components/templates/FieldTemplate/index.d.ts +2 -1
- package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/index.js +1 -2
- package/lib/components/templates/GridTemplate.d.ts +8 -0
- package/lib/components/templates/GridTemplate.d.ts.map +1 -0
- package/lib/components/templates/GridTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js +2 -3
- package/lib/components/templates/TitleField.d.ts +1 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -0
- package/lib/components/templates/TitleField.js +0 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -0
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -0
- package/lib/components/templates/UnsupportedField.js +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js +10 -6
- package/lib/components/templates/index.d.ts +1 -0
- package/lib/components/templates/index.d.ts.map +1 -0
- package/lib/components/templates/index.js +19 -16
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js +0 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateWidget.js +0 -1
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxWidget.js +2 -4
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxesWidget.js +0 -1
- package/lib/components/widgets/ColorWidget.d.ts +1 -0
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -0
- package/lib/components/widgets/ColorWidget.js +0 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateTimeWidget.js +0 -1
- package/lib/components/widgets/DateWidget.d.ts +1 -0
- package/lib/components/widgets/DateWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateWidget.js +0 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -0
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -0
- package/lib/components/widgets/EmailWidget.js +0 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -0
- package/lib/components/widgets/FileWidget.d.ts.map +1 -0
- package/lib/components/widgets/FileWidget.js +3 -5
- package/lib/components/widgets/HiddenWidget.d.ts +1 -0
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -0
- package/lib/components/widgets/HiddenWidget.js +0 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -0
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -0
- package/lib/components/widgets/PasswordWidget.js +0 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -0
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -0
- package/lib/components/widgets/RadioWidget.js +3 -4
- package/lib/components/widgets/RangeWidget.d.ts +1 -0
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -0
- package/lib/components/widgets/RangeWidget.js +0 -1
- package/lib/components/widgets/RatingWidget.d.ts +15 -0
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -0
- package/lib/components/widgets/RatingWidget.js +63 -0
- package/lib/components/widgets/SelectWidget.d.ts +1 -0
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -0
- package/lib/components/widgets/SelectWidget.js +4 -5
- package/lib/components/widgets/TextWidget.d.ts +1 -0
- package/lib/components/widgets/TextWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextWidget.js +0 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -0
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextareaWidget.js +0 -1
- package/lib/components/widgets/TimeWidget.d.ts +1 -0
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/TimeWidget.js +0 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -0
- package/lib/components/widgets/URLWidget.d.ts.map +1 -0
- package/lib/components/widgets/URLWidget.js +0 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -0
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -0
- package/lib/components/widgets/UpDownWidget.js +0 -1
- package/lib/components/widgets/index.d.ts +1 -0
- package/lib/components/widgets/index.d.ts.map +1 -0
- package/lib/components/widgets/index.js +21 -20
- package/lib/getDefaultRegistry.d.ts +1 -0
- package/lib/getDefaultRegistry.d.ts.map +1 -0
- package/lib/getDefaultRegistry.js +3 -4
- package/lib/index.d.ts +7 -5
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +2 -1
- package/lib/withTheme.d.ts.map +1 -0
- package/lib/withTheme.js +7 -8
- package/package.json +46 -37
- package/src/components/Form.tsx +127 -41
- package/src/components/RichDescription.tsx +50 -0
- package/src/components/fields/ArrayField.tsx +34 -24
- package/src/components/fields/BooleanField.tsx +6 -14
- package/src/components/fields/LayoutGridField.tsx +967 -0
- package/src/components/fields/LayoutHeaderField.tsx +49 -0
- package/src/components/fields/LayoutMultiSchemaField.tsx +228 -0
- package/src/components/fields/MultiSchemaField.tsx +9 -4
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +5 -5
- package/src/components/fields/ObjectField.tsx +32 -24
- package/src/components/fields/SchemaField.tsx +17 -30
- package/src/components/fields/StringField.tsx +2 -2
- package/src/components/fields/index.ts +7 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -2
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +85 -0
- package/src/components/templates/ArrayFieldItemTemplate.tsx +18 -57
- package/src/components/templates/ArrayFieldTemplate.tsx +10 -8
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -2
- package/src/components/templates/BaseInputTemplate.tsx +4 -4
- package/src/components/templates/ButtonTemplates/IconButton.tsx +9 -36
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +1 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/DescriptionField.tsx +9 -15
- package/src/components/templates/FieldErrorTemplate.tsx +1 -1
- package/src/components/templates/FieldHelpTemplate.tsx +1 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +15 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +5 -3
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +1 -1
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +14 -4
- package/src/components/templates/index.ts +4 -0
- package/src/components/widgets/AltDateWidget.tsx +9 -6
- package/src/components/widgets/CheckboxWidget.tsx +5 -5
- package/src/components/widgets/CheckboxesWidget.tsx +2 -2
- package/src/components/widgets/ColorWidget.tsx +1 -1
- package/src/components/widgets/DateTimeWidget.tsx +1 -1
- package/src/components/widgets/DateWidget.tsx +1 -1
- package/src/components/widgets/EmailWidget.tsx +1 -1
- package/src/components/widgets/FileWidget.tsx +5 -5
- package/src/components/widgets/PasswordWidget.tsx +1 -1
- package/src/components/widgets/RadioWidget.tsx +3 -3
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +129 -0
- package/src/components/widgets/SelectWidget.tsx +4 -3
- package/src/components/widgets/TextWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +3 -3
- package/src/components/widgets/TimeWidget.tsx +1 -1
- package/src/components/widgets/URLWidget.tsx +1 -1
- package/src/components/widgets/UpDownWidget.tsx +1 -1
- package/src/components/widgets/index.ts +3 -1
- package/src/getDefaultRegistry.ts +1 -1
- package/src/index.ts +3 -2
- package/src/tsconfig.json +14 -6
- package/src/withTheme.tsx +4 -3
- package/LICENSE.md +0 -201
- package/lib/components/Form.js.map +0 -1
- package/lib/components/fields/ArrayField.js.map +0 -1
- package/lib/components/fields/BooleanField.js.map +0 -1
- package/lib/components/fields/MultiSchemaField.js.map +0 -1
- package/lib/components/fields/NullField.js.map +0 -1
- package/lib/components/fields/NumberField.js.map +0 -1
- package/lib/components/fields/ObjectField.js.map +0 -1
- package/lib/components/fields/SchemaField.js.map +0 -1
- package/lib/components/fields/StringField.js.map +0 -1
- package/lib/components/fields/index.js.map +0 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js.map +0 -1
- package/lib/components/templates/BaseInputTemplate.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/index.js.map +0 -1
- package/lib/components/templates/DescriptionField.js.map +0 -1
- package/lib/components/templates/ErrorList.js.map +0 -1
- package/lib/components/templates/FieldErrorTemplate.js.map +0 -1
- package/lib/components/templates/FieldHelpTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/Label.js.map +0 -1
- package/lib/components/templates/FieldTemplate/index.js.map +0 -1
- package/lib/components/templates/ObjectFieldTemplate.js.map +0 -1
- package/lib/components/templates/TitleField.js.map +0 -1
- package/lib/components/templates/UnsupportedField.js.map +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +0 -1
- package/lib/components/templates/index.js.map +0 -1
- package/lib/components/widgets/AltDateTimeWidget.js.map +0 -1
- package/lib/components/widgets/AltDateWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxesWidget.js.map +0 -1
- package/lib/components/widgets/ColorWidget.js.map +0 -1
- package/lib/components/widgets/DateTimeWidget.js.map +0 -1
- package/lib/components/widgets/DateWidget.js.map +0 -1
- package/lib/components/widgets/EmailWidget.js.map +0 -1
- package/lib/components/widgets/FileWidget.js.map +0 -1
- package/lib/components/widgets/HiddenWidget.js.map +0 -1
- package/lib/components/widgets/PasswordWidget.js.map +0 -1
- package/lib/components/widgets/RadioWidget.js.map +0 -1
- package/lib/components/widgets/RangeWidget.js.map +0 -1
- package/lib/components/widgets/SelectWidget.js.map +0 -1
- package/lib/components/widgets/TextWidget.js.map +0 -1
- package/lib/components/widgets/TextareaWidget.js.map +0 -1
- package/lib/components/widgets/TimeWidget.js.map +0 -1
- package/lib/components/widgets/URLWidget.js.map +0 -1
- package/lib/components/widgets/UpDownWidget.js.map +0 -1
- package/lib/components/widgets/index.js.map +0 -1
- package/lib/getDefaultRegistry.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/withTheme.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `idSchema`
|
|
3
|
+
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
4
|
+
* - If there is a title in the `uiSchema`, it is displayed
|
|
5
|
+
* - Else, if there is an explicit `title` passed in the props, it is displayed
|
|
6
|
+
* - Otherwise, if there is a title in the `schema`, it is displayed
|
|
7
|
+
* - Finally, the `name` prop is displayed as the title
|
|
8
|
+
*
|
|
9
|
+
* @param props - The `LayoutHeaderField` for the component
|
|
10
|
+
*/
|
|
11
|
+
export default function LayoutHeaderField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
//# sourceMappingURL=LayoutHeaderField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LayoutHeaderField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutHeaderField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,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,kDAwB3B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
|
|
3
|
+
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `idSchema`
|
|
4
|
+
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
5
|
+
* - If there is a title in the `uiSchema`, it is displayed
|
|
6
|
+
* - Else, if there is an explicit `title` passed in the props, it is displayed
|
|
7
|
+
* - Otherwise, if there is a title in the `schema`, it is displayed
|
|
8
|
+
* - Finally, the `name` prop is displayed as the title
|
|
9
|
+
*
|
|
10
|
+
* @param props - The `LayoutHeaderField` for the component
|
|
11
|
+
*/
|
|
12
|
+
export default function LayoutHeaderField(props) {
|
|
13
|
+
const { idSchema, title, schema, uiSchema, required, registry, name } = props;
|
|
14
|
+
const options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
15
|
+
const { title: uiTitle } = options;
|
|
16
|
+
const { title: schemaTitle } = schema;
|
|
17
|
+
const fieldTitle = uiTitle || title || schemaTitle || name;
|
|
18
|
+
if (!fieldTitle) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
22
|
+
return (_jsx(TitleFieldTemplate, { id: titleId(idSchema), title: fieldTitle, required: required, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EnumOptionsType, FieldProps, FormContextType, RJSFSchema, SchemaUtilsType, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
2
|
+
/** Gets the selected option from the list of `options`, using the `selectorField` to search inside each `option` for
|
|
3
|
+
* the `properties[selectorField].default(or const)` that matches the given `value`.
|
|
4
|
+
*
|
|
5
|
+
* @param options - The list of schemas each representing a choice in the `oneOf`
|
|
6
|
+
* @param selectorField - The name of the field that is common in all of the schemas that represents the selector field
|
|
7
|
+
* @param value - The current value of the selector field from the data
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSelectedOption<S extends StrictRJSFSchema = RJSFSchema>(options: EnumOptionsType<S>[], selectorField: string, value: unknown): S | undefined;
|
|
10
|
+
/** Computes the `enumOptions` array from the schema and options.
|
|
11
|
+
*
|
|
12
|
+
* @param schema - The schema that contains the `options`
|
|
13
|
+
* @param options - The options from the `schema`
|
|
14
|
+
* @param schemaUtils - The SchemaUtilsType object used to call retrieveSchema,
|
|
15
|
+
* @param [uiSchema] - The optional uiSchema for the schema
|
|
16
|
+
* @param [formData] - The optional formData associated with the schema
|
|
17
|
+
* @returns - The list of enumOptions for the `schema` and `options`
|
|
18
|
+
* @throws - Error when no enum options were computed
|
|
19
|
+
*/
|
|
20
|
+
export declare function computeEnumOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: S, options: S[], schemaUtils: SchemaUtilsType<T, S, F>, uiSchema?: UiSchema<T, S, F>, formData?: T): EnumOptionsType<S>[];
|
|
21
|
+
/** The `LayoutMultiSchemaField` is an adaptation of the `MultiSchemaField` but changed considerably to only
|
|
22
|
+
* support `anyOf`/`oneOf` fields that are being displayed in a `LayoutGridField` where the field selection is shown as
|
|
23
|
+
* a radio group by default. It expects that a `selectorField` is provided (either directly via the `discriminator`
|
|
24
|
+
* field or indirectly via `ui:optionsSchemaSelector` in the `uiSchema`) to help determine which `anyOf`/`oneOf` schema
|
|
25
|
+
* is active. If no `selectorField` is specified, then an error is thrown.
|
|
26
|
+
*/
|
|
27
|
+
export default function LayoutMultiSchemaField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
//# sourceMappingURL=LayoutMultiSchemaField.d.ts.map
|
|
@@ -0,0 +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,2CAuI3B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, ERRORS_KEY, getDiscriminatorFieldFromSchema, hashObject, ID_KEY, ONE_OF_KEY, optionsList, PROPERTIES_KEY, getTemplate, getUiOptions, getWidget, } from '@rjsf/utils';
|
|
4
|
+
import get from 'lodash-es/get.js';
|
|
5
|
+
import has from 'lodash-es/has.js';
|
|
6
|
+
import isEmpty from 'lodash-es/isEmpty.js';
|
|
7
|
+
import noop from 'lodash-es/noop.js';
|
|
8
|
+
import omit from 'lodash-es/omit.js';
|
|
9
|
+
import set from 'lodash-es/set.js';
|
|
10
|
+
/** Gets the selected option from the list of `options`, using the `selectorField` to search inside each `option` for
|
|
11
|
+
* the `properties[selectorField].default(or const)` that matches the given `value`.
|
|
12
|
+
*
|
|
13
|
+
* @param options - The list of schemas each representing a choice in the `oneOf`
|
|
14
|
+
* @param selectorField - The name of the field that is common in all of the schemas that represents the selector field
|
|
15
|
+
* @param value - The current value of the selector field from the data
|
|
16
|
+
*/
|
|
17
|
+
export function getSelectedOption(options, selectorField, value) {
|
|
18
|
+
const defaultValue = '!@#!@$@#$!@$#';
|
|
19
|
+
const schemaOptions = options.map(({ schema }) => schema);
|
|
20
|
+
return schemaOptions.find((option) => {
|
|
21
|
+
const selector = get(option, [PROPERTIES_KEY, selectorField]);
|
|
22
|
+
const result = get(selector, DEFAULT_KEY, get(selector, CONST_KEY, defaultValue));
|
|
23
|
+
return result === value;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Computes the `enumOptions` array from the schema and options.
|
|
27
|
+
*
|
|
28
|
+
* @param schema - The schema that contains the `options`
|
|
29
|
+
* @param options - The options from the `schema`
|
|
30
|
+
* @param schemaUtils - The SchemaUtilsType object used to call retrieveSchema,
|
|
31
|
+
* @param [uiSchema] - The optional uiSchema for the schema
|
|
32
|
+
* @param [formData] - The optional formData associated with the schema
|
|
33
|
+
* @returns - The list of enumOptions for the `schema` and `options`
|
|
34
|
+
* @throws - Error when no enum options were computed
|
|
35
|
+
*/
|
|
36
|
+
export function computeEnumOptions(schema, options, schemaUtils, uiSchema, formData) {
|
|
37
|
+
const realOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
38
|
+
let tempSchema = schema;
|
|
39
|
+
if (has(schema, ONE_OF_KEY)) {
|
|
40
|
+
tempSchema = { ...schema, [ONE_OF_KEY]: realOptions };
|
|
41
|
+
}
|
|
42
|
+
else if (has(schema, ANY_OF_KEY)) {
|
|
43
|
+
tempSchema = { ...schema, [ANY_OF_KEY]: realOptions };
|
|
44
|
+
}
|
|
45
|
+
const enumOptions = optionsList(tempSchema, uiSchema);
|
|
46
|
+
if (!enumOptions) {
|
|
47
|
+
throw new Error(`No enumOptions were computed from the schema ${JSON.stringify(tempSchema)}`);
|
|
48
|
+
}
|
|
49
|
+
return enumOptions;
|
|
50
|
+
}
|
|
51
|
+
/** The `LayoutMultiSchemaField` is an adaptation of the `MultiSchemaField` but changed considerably to only
|
|
52
|
+
* support `anyOf`/`oneOf` fields that are being displayed in a `LayoutGridField` where the field selection is shown as
|
|
53
|
+
* a radio group by default. It expects that a `selectorField` is provided (either directly via the `discriminator`
|
|
54
|
+
* field or indirectly via `ui:optionsSchemaSelector` in the `uiSchema`) to help determine which `anyOf`/`oneOf` schema
|
|
55
|
+
* is active. If no `selectorField` is specified, then an error is thrown.
|
|
56
|
+
*/
|
|
57
|
+
export default function LayoutMultiSchemaField(props) {
|
|
58
|
+
const { name, baseType, disabled = false, formData, idSchema, onBlur, onChange, options, onFocus, registry, uiSchema, schema, formContext, autofocus, readonly, required, errorSchema, hideError = false, } = props;
|
|
59
|
+
const { widgets, schemaUtils, globalUiOptions } = registry;
|
|
60
|
+
const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
61
|
+
const id = get(idSchema, ID_KEY);
|
|
62
|
+
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
63
|
+
const FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, options);
|
|
64
|
+
const FieldTemplate = getTemplate('FieldTemplate', registry, options);
|
|
65
|
+
const schemaHash = hashObject(schema);
|
|
66
|
+
const optionsHash = hashObject(options);
|
|
67
|
+
const uiSchemaHash = uiSchema ? hashObject(uiSchema) : '';
|
|
68
|
+
const formDataHash = formData ? hashObject(formData) : '';
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
71
|
+
// We are using hashes in place of the dependencies
|
|
72
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
|
+
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
74
|
+
const { widget = discriminator ? 'radio' : 'select', title = '', placeholder = '', optionsSchemaSelector: selectorField = discriminator, hideError: uiSchemaHideError, ...uiOptions } = getUiOptions(uiSchema);
|
|
75
|
+
if (!selectorField) {
|
|
76
|
+
throw new Error('No selector field provided for the LayoutMultiSchemaField');
|
|
77
|
+
}
|
|
78
|
+
const selectedOption = get(formData, selectorField);
|
|
79
|
+
let optionSchema = get(enumOptions[0]?.schema, [PROPERTIES_KEY, selectorField], {});
|
|
80
|
+
const option = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
81
|
+
// If the subschema doesn't declare a type, infer the type from the parent schema
|
|
82
|
+
optionSchema = optionSchema?.type ? optionSchema : { ...optionSchema, type: option?.type || baseType };
|
|
83
|
+
const Widget = getWidget(optionSchema, widget, widgets);
|
|
84
|
+
// The following code was copied from `@rjsf`'s `SchemaField`
|
|
85
|
+
// Set hideError to the value provided in the uiSchema, otherwise stick with the prop to propagate to children
|
|
86
|
+
const hideFieldError = uiSchemaHideError === undefined ? hideError : Boolean(uiSchemaHideError);
|
|
87
|
+
const rawErrors = get(errorSchema, [ERRORS_KEY], []);
|
|
88
|
+
const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
|
|
89
|
+
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
90
|
+
/** Callback function that updates the selected option and adjusts the form data based on the structure of the new
|
|
91
|
+
* option, calling the `onChange` callback with the adjusted formData.
|
|
92
|
+
*
|
|
93
|
+
* @param opt - If the option is undefined, we are going to clear the selection otherwise we
|
|
94
|
+
* will use it as the index of the new option to select
|
|
95
|
+
*/
|
|
96
|
+
const onOptionChange = (opt) => {
|
|
97
|
+
const newOption = getSelectedOption(enumOptions, selectorField, opt);
|
|
98
|
+
const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
99
|
+
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
100
|
+
if (newFormData && newOption) {
|
|
101
|
+
// Call getDefaultFormState to make sure defaults are populated on change.
|
|
102
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
103
|
+
}
|
|
104
|
+
if (newFormData) {
|
|
105
|
+
set(newFormData, selectorField, opt);
|
|
106
|
+
}
|
|
107
|
+
onChange(newFormData, undefined, id);
|
|
108
|
+
};
|
|
109
|
+
// filtering the options based on the type of widget because `selectField` does not recognize the `convertOther` prop
|
|
110
|
+
const widgetOptions = { enumOptions, ...uiOptions };
|
|
111
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, { idSchema: idSchema, schema: schema, errors: rawErrors, registry: registry })) : undefined;
|
|
112
|
+
const ignored = (value) => noop;
|
|
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 }) }));
|
|
114
|
+
}
|
|
@@ -0,0 +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,EAMf,UAAU,EACV,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;CA0GP;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
|
-
import get from 'lodash/get';
|
|
4
|
-
import isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import omit from 'lodash/omit';
|
|
3
|
+
import get from 'lodash-es/get.js';
|
|
4
|
+
import isEmpty from 'lodash-es/isEmpty.js';
|
|
5
|
+
import omit from 'lodash-es/omit.js';
|
|
6
6
|
import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getUiOptions, getWidget, mergeSchemas, ONE_OF_KEY, 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`.
|
|
@@ -16,31 +16,6 @@ class AnyOfField extends Component {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(props) {
|
|
18
18
|
super(props);
|
|
19
|
-
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
20
|
-
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
21
|
-
* the `onChange` handler.
|
|
22
|
-
*
|
|
23
|
-
* @param option - The new option value being selected
|
|
24
|
-
*/
|
|
25
|
-
this.onOptionChange = (option) => {
|
|
26
|
-
const { selectedOption, retrievedOptions } = this.state;
|
|
27
|
-
const { formData, onChange, registry } = this.props;
|
|
28
|
-
const { schemaUtils } = registry;
|
|
29
|
-
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
30
|
-
if (intOption === selectedOption) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const newOption = intOption >= 0 ? retrievedOptions[intOption] : undefined;
|
|
34
|
-
const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : undefined;
|
|
35
|
-
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
36
|
-
if (newFormData && newOption) {
|
|
37
|
-
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
38
|
-
// so that only the root objects themselves are created without adding undefined children properties
|
|
39
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
40
|
-
}
|
|
41
|
-
onChange(newFormData, undefined, this.getFieldId());
|
|
42
|
-
this.setState({ selectedOption: intOption });
|
|
43
|
-
};
|
|
44
19
|
const { formData, options, registry: { schemaUtils }, } = this.props;
|
|
45
20
|
// cache the retrieved options in state in case they have $refs to save doing it later
|
|
46
21
|
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
@@ -88,6 +63,32 @@ class AnyOfField extends Component {
|
|
|
88
63
|
const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
89
64
|
return option;
|
|
90
65
|
}
|
|
66
|
+
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
67
|
+
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
68
|
+
* the `onChange` handler.
|
|
69
|
+
*
|
|
70
|
+
* @param option - The new option value being selected
|
|
71
|
+
*/
|
|
72
|
+
onOptionChange = (option) => {
|
|
73
|
+
const { selectedOption, retrievedOptions } = this.state;
|
|
74
|
+
const { formData, onChange, registry } = this.props;
|
|
75
|
+
const { schemaUtils } = registry;
|
|
76
|
+
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
77
|
+
if (intOption === selectedOption) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const newOption = intOption >= 0 ? retrievedOptions[intOption] : undefined;
|
|
81
|
+
const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : undefined;
|
|
82
|
+
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
83
|
+
if (newOption) {
|
|
84
|
+
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
85
|
+
// so that only the root objects themselves are created without adding undefined children properties
|
|
86
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
87
|
+
}
|
|
88
|
+
this.setState({ selectedOption: intOption }, () => {
|
|
89
|
+
onChange(newFormData, undefined, this.getFieldId());
|
|
90
|
+
});
|
|
91
|
+
};
|
|
91
92
|
getFieldId() {
|
|
92
93
|
const { idSchema, schema } = this.props;
|
|
93
94
|
return `${idSchema.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
|
|
@@ -95,7 +96,7 @@ class AnyOfField extends Component {
|
|
|
95
96
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
96
97
|
*/
|
|
97
98
|
render() {
|
|
98
|
-
const { name, disabled = false, errorSchema = {}, formContext, onBlur, onFocus, registry, schema, uiSchema, } = this.props;
|
|
99
|
+
const { name, disabled = false, errorSchema = {}, formContext, onBlur, onFocus, readonly, registry, schema, uiSchema, } = this.props;
|
|
99
100
|
const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
|
|
100
101
|
const { SchemaField: _SchemaField } = fields;
|
|
101
102
|
const { selectedOption, retrievedOptions } = this.state;
|
|
@@ -147,8 +148,7 @@ class AnyOfField extends Component {
|
|
|
147
148
|
value: index,
|
|
148
149
|
};
|
|
149
150
|
});
|
|
150
|
-
return (_jsxs("div", { className: 'panel panel-default panel-body', children: [_jsx("div", { className: 'form-group', children: _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, formContext: formContext, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title
|
|
151
|
+
return (_jsxs("div", { className: 'panel panel-default panel-body', children: [_jsx("div", { className: 'form-group', children: _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, formContext: formContext, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly }) }), optionSchema && optionSchema.type !== 'null' && (_jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))] }));
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
export default AnyOfField;
|
|
154
|
-
//# sourceMappingURL=MultiSchemaField.js.map
|
|
@@ -6,3 +6,4 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
6
6
|
*/
|
|
7
7
|
declare function NullField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): null;
|
|
8
8
|
export default NullField;
|
|
9
|
+
//# sourceMappingURL=NullField.d.ts.map
|
|
@@ -0,0 +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;AAExF;;;;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"}
|
|
@@ -18,3 +18,4 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
18
18
|
*/
|
|
19
19
|
declare function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export default NumberField;
|
|
21
|
+
//# sourceMappingURL=NumberField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAyB,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAc/G;;;;;;;;;;;;;;;;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"}
|
|
@@ -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) => {
|
|
40
|
+
const handleChange = useCallback((value, 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);
|
|
54
|
+
onChange(processed, 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
|
|
@@ -67,4 +67,3 @@ function NumberField(props) {
|
|
|
67
67
|
return _jsx(StringField, { ...props, formData: value, onChange: handleChange });
|
|
68
68
|
}
|
|
69
69
|
export default NumberField;
|
|
70
|
-
//# sourceMappingURL=NumberField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAIL,WAAW,EACX,UAAU,EACV,eAAe,EAGf,UAAU,EACV,gBAAgB,EAOjB,MAAM,aAAa,CAAC;AAQrB,6DAA6D;AAC7D,KAAK,gBAAgB,GAAG;IACtB,sEAAsE;IACtE,sBAAsB,EAAE,OAAO,CAAC;IAChC,uCAAuC;IACvC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;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,EACnB,gBAAgB,CACjB;IACC,+BAA+B;IAC/B,KAAK;;;MAGH;IAEF;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM;IAKvB;;;;;;;OAOG;IACH,gBAAgB,GAAI,MAAM,MAAM,EAAE,qCAAmC,MAC3D,OAAO,CAAC,GAAG,SAAS,EAAE,iBAAiB,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,UAuB1E;IAEF;;;;;OAKG;IACH,mBAAmB,GAAI,KAAK,MAAM,MACxB,OAAO,SAAS,UAOxB;IAEF;;;;;;OAMG;IACH,eAAe,GAAI,cAAc,MAAM,EAAE,WAAW,CAAC,YAUnD;IAEF;;;;;OAKG;IACH,WAAW,GAAI,UAAU,GAAG,MAClB,OAAO,GAAG,EAAE,gBAAgB,WAAW,CAAC,CAAC,CAAC,UA4BlD;IAEF;;;OAGG;IACH,eAAe,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC;IAsBzC;;;;OAIG;IACH,cAAc,GAAI,QAAQ,CAAC,gBAqCzB;IAEF;OACG;IACH,MAAM;CAuGP;AAED,eAAe,WAAW,CAAC"}
|