@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,20 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
|
+
export interface RichDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
4
|
+
/** The description text for a field, potentially containing markdown */
|
|
5
|
+
description: string | ReactElement;
|
|
6
|
+
/** The uiSchema object for this base component */
|
|
7
|
+
uiSchema?: UiSchema<T, S, F>;
|
|
8
|
+
/** The `registry` object */
|
|
9
|
+
registry: Registry<T, S, F>;
|
|
10
|
+
}
|
|
11
|
+
/** Renders the given `description` in the props as
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `RichDescriptionProps` for this component
|
|
14
|
+
*/
|
|
15
|
+
declare function RichDescription<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ description, registry, uiSchema }: RichDescriptionProps<T, S, F>): string | import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare namespace RichDescription {
|
|
17
|
+
var TEST_IDS: import("@rjsf/utils").TestIdShape;
|
|
18
|
+
}
|
|
19
|
+
export default RichDescription;
|
|
20
|
+
//# sourceMappingURL=RichDescription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichDescription.d.ts","sourceRoot":"","sources":["../../src/components/RichDescription.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EACL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,QAAQ,EAGT,MAAM,aAAa,CAAC;AAKrB,MAAM,WAAW,oBAAoB,CACnC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG;IAE/B,wEAAwE;IACxE,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC7B;AAED;;;GAGG;AACH,iBAAwB,eAAe,CACrC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAa,EAAE,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,oDAYxE;kBAhBuB,eAAe;;;eAAf,eAAe"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getTestIds, getUiOptions, } from '@rjsf/utils';
|
|
3
|
+
import Markdown from 'markdown-to-jsx';
|
|
4
|
+
const TEST_IDS = getTestIds();
|
|
5
|
+
/** Renders the given `description` in the props as
|
|
6
|
+
*
|
|
7
|
+
* @param props - The `RichDescriptionProps` for this component
|
|
8
|
+
*/
|
|
9
|
+
export default function RichDescription({ description, registry, uiSchema = {} }) {
|
|
10
|
+
const { globalUiOptions } = registry;
|
|
11
|
+
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
12
|
+
if (uiOptions.enableMarkdownInDescription && typeof description === 'string') {
|
|
13
|
+
return (_jsx(Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description }));
|
|
14
|
+
}
|
|
15
|
+
return description;
|
|
16
|
+
}
|
|
17
|
+
RichDescription.TEST_IDS = TEST_IDS;
|
|
@@ -153,21 +153,31 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
153
153
|
totalItems: number;
|
|
154
154
|
}): {
|
|
155
155
|
children: import("react/jsx-runtime").JSX.Element;
|
|
156
|
+
buttonsProps: {
|
|
157
|
+
idSchema: import("@rjsf/utils").FieldId & (IdSchema<T> | undefined)[];
|
|
158
|
+
disabled: boolean | undefined;
|
|
159
|
+
readonly: boolean | undefined;
|
|
160
|
+
canAdd: boolean;
|
|
161
|
+
hasCopy: boolean;
|
|
162
|
+
hasMoveUp: boolean;
|
|
163
|
+
hasMoveDown: boolean;
|
|
164
|
+
hasRemove: boolean;
|
|
165
|
+
index: number;
|
|
166
|
+
totalItems: number;
|
|
167
|
+
onAddIndexClick: (index: number) => (event: MouseEvent) => void;
|
|
168
|
+
onCopyIndexClick: (index: number) => (event: MouseEvent) => void;
|
|
169
|
+
onDropIndexClick: (index: number) => (event: MouseEvent) => void;
|
|
170
|
+
onReorderClick: (index: number, newIndex: number) => (event: MouseEvent<HTMLButtonElement>) => void;
|
|
171
|
+
registry: import("@rjsf/utils").Registry<T[], S, F>;
|
|
172
|
+
schema: S;
|
|
173
|
+
uiSchema: UiSchema<T[], S, F>;
|
|
174
|
+
};
|
|
156
175
|
className: string;
|
|
157
176
|
disabled: boolean | undefined;
|
|
158
|
-
canAdd: boolean;
|
|
159
|
-
hasCopy: boolean;
|
|
160
177
|
hasToolbar: boolean;
|
|
161
|
-
hasMoveUp: boolean;
|
|
162
|
-
hasMoveDown: boolean;
|
|
163
|
-
hasRemove: boolean;
|
|
164
178
|
index: number;
|
|
165
179
|
totalItems: number;
|
|
166
180
|
key: string;
|
|
167
|
-
onAddIndexClick: (index: number) => (event: MouseEvent<Element, globalThis.MouseEvent>) => void;
|
|
168
|
-
onCopyIndexClick: (index: number) => (event: MouseEvent<Element, globalThis.MouseEvent>) => void;
|
|
169
|
-
onDropIndexClick: (index: number) => (event: MouseEvent<Element, globalThis.MouseEvent>) => void;
|
|
170
|
-
onReorderClick: (index: number, newIndex: number) => (event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>) => void;
|
|
171
181
|
readonly: boolean | undefined;
|
|
172
182
|
registry: import("@rjsf/utils").Registry<T[], S, F>;
|
|
173
183
|
schema: S;
|
|
@@ -178,3 +188,4 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
178
188
|
* `Field` which is defined as `React.ComponentType<FieldProps<T, S, F>>`, so cast it to make `registry` happy.
|
|
179
189
|
*/
|
|
180
190
|
export default ArrayField;
|
|
191
|
+
//# sourceMappingURL=ArrayField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ArrayField.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import { getTemplate, getWidget, getUiOptions, isFixedItems, allowAdditionalItems, isCustomWidget, optionsList, TranslatableString, ITEMS_KEY, } from '@rjsf/utils';
|
|
4
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
5
|
-
import get from 'lodash/get';
|
|
6
|
-
import isObject from 'lodash/isObject';
|
|
7
|
-
import set from 'lodash/set';
|
|
4
|
+
import cloneDeep from 'lodash-es/cloneDeep.js';
|
|
5
|
+
import get from 'lodash-es/get.js';
|
|
6
|
+
import isObject from 'lodash-es/isObject.js';
|
|
7
|
+
import set from 'lodash-es/set.js';
|
|
8
8
|
import { nanoid } from 'nanoid';
|
|
9
9
|
/** Used to generate a unique ID for an element in a row */
|
|
10
10
|
function generateRowId() {
|
|
@@ -46,189 +46,6 @@ class ArrayField extends Component {
|
|
|
46
46
|
*/
|
|
47
47
|
constructor(props) {
|
|
48
48
|
super(props);
|
|
49
|
-
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
50
|
-
* that the schema is fixed and allows additional items.
|
|
51
|
-
*/
|
|
52
|
-
this._getNewFormDataRow = () => {
|
|
53
|
-
const { schema, registry } = this.props;
|
|
54
|
-
const { schemaUtils } = registry;
|
|
55
|
-
let itemSchema = schema.items;
|
|
56
|
-
if (isFixedItems(schema) && allowAdditionalItems(schema)) {
|
|
57
|
-
itemSchema = schema.additionalItems;
|
|
58
|
-
}
|
|
59
|
-
// Cast this as a T to work around schema utils being for T[] caused by the FieldProps<T[], S, F> call on the class
|
|
60
|
-
return schemaUtils.getDefaultFormState(itemSchema);
|
|
61
|
-
};
|
|
62
|
-
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
63
|
-
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
64
|
-
* keyed data
|
|
65
|
-
*
|
|
66
|
-
* @param event - The event for the click
|
|
67
|
-
*/
|
|
68
|
-
this.onAddClick = (event) => {
|
|
69
|
-
this._handleAddClick(event);
|
|
70
|
-
};
|
|
71
|
-
/** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
|
|
72
|
-
* keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
|
|
73
|
-
* form data converted from the keyed data
|
|
74
|
-
*
|
|
75
|
-
* @param index - The index at which the add button is clicked
|
|
76
|
-
*/
|
|
77
|
-
this.onAddIndexClick = (index) => {
|
|
78
|
-
return (event) => {
|
|
79
|
-
this._handleAddClick(event, index);
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
83
|
-
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
84
|
-
* form data converted from the keyed data
|
|
85
|
-
*
|
|
86
|
-
* @param index - The index at which the copy button is clicked
|
|
87
|
-
*/
|
|
88
|
-
this.onCopyIndexClick = (index) => {
|
|
89
|
-
return (event) => {
|
|
90
|
-
if (event) {
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
}
|
|
93
|
-
const { onChange, errorSchema } = this.props;
|
|
94
|
-
const { keyedFormData } = this.state;
|
|
95
|
-
// refs #195: revalidate to ensure properly reindexing errors
|
|
96
|
-
let newErrorSchema;
|
|
97
|
-
if (errorSchema) {
|
|
98
|
-
newErrorSchema = {};
|
|
99
|
-
for (const idx in errorSchema) {
|
|
100
|
-
const i = parseInt(idx);
|
|
101
|
-
if (i <= index) {
|
|
102
|
-
set(newErrorSchema, [i], errorSchema[idx]);
|
|
103
|
-
}
|
|
104
|
-
else if (i > index) {
|
|
105
|
-
set(newErrorSchema, [i + 1], errorSchema[idx]);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const newKeyedFormDataRow = {
|
|
110
|
-
key: generateRowId(),
|
|
111
|
-
item: cloneDeep(keyedFormData[index].item),
|
|
112
|
-
};
|
|
113
|
-
const newKeyedFormData = [...keyedFormData];
|
|
114
|
-
if (index !== undefined) {
|
|
115
|
-
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
newKeyedFormData.push(newKeyedFormDataRow);
|
|
119
|
-
}
|
|
120
|
-
this.setState({
|
|
121
|
-
keyedFormData: newKeyedFormData,
|
|
122
|
-
updatedKeyedFormData: true,
|
|
123
|
-
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
127
|
-
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
128
|
-
* from the keyed data
|
|
129
|
-
*
|
|
130
|
-
* @param index - The index at which the remove button is clicked
|
|
131
|
-
*/
|
|
132
|
-
this.onDropIndexClick = (index) => {
|
|
133
|
-
return (event) => {
|
|
134
|
-
if (event) {
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
}
|
|
137
|
-
const { onChange, errorSchema } = this.props;
|
|
138
|
-
const { keyedFormData } = this.state;
|
|
139
|
-
// refs #195: revalidate to ensure properly reindexing errors
|
|
140
|
-
let newErrorSchema;
|
|
141
|
-
if (errorSchema) {
|
|
142
|
-
newErrorSchema = {};
|
|
143
|
-
for (const idx in errorSchema) {
|
|
144
|
-
const i = parseInt(idx);
|
|
145
|
-
if (i < index) {
|
|
146
|
-
set(newErrorSchema, [i], errorSchema[idx]);
|
|
147
|
-
}
|
|
148
|
-
else if (i > index) {
|
|
149
|
-
set(newErrorSchema, [i - 1], errorSchema[idx]);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
|
|
154
|
-
this.setState({
|
|
155
|
-
keyedFormData: newKeyedFormData,
|
|
156
|
-
updatedKeyedFormData: true,
|
|
157
|
-
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
161
|
-
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
162
|
-
* plain form data converted from the keyed data
|
|
163
|
-
*
|
|
164
|
-
* @param index - The index of the item to move
|
|
165
|
-
* @param newIndex - The index to where the item is to be moved
|
|
166
|
-
*/
|
|
167
|
-
this.onReorderClick = (index, newIndex) => {
|
|
168
|
-
return (event) => {
|
|
169
|
-
if (event) {
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
event.currentTarget.blur();
|
|
172
|
-
}
|
|
173
|
-
const { onChange, errorSchema } = this.props;
|
|
174
|
-
let newErrorSchema;
|
|
175
|
-
if (errorSchema) {
|
|
176
|
-
newErrorSchema = {};
|
|
177
|
-
for (const idx in errorSchema) {
|
|
178
|
-
const i = parseInt(idx);
|
|
179
|
-
if (i == index) {
|
|
180
|
-
set(newErrorSchema, [newIndex], errorSchema[index]);
|
|
181
|
-
}
|
|
182
|
-
else if (i == newIndex) {
|
|
183
|
-
set(newErrorSchema, [index], errorSchema[newIndex]);
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
set(newErrorSchema, [idx], errorSchema[i]);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
const { keyedFormData } = this.state;
|
|
191
|
-
function reOrderArray() {
|
|
192
|
-
// Copy item
|
|
193
|
-
const _newKeyedFormData = keyedFormData.slice();
|
|
194
|
-
// Moves item from index to newIndex
|
|
195
|
-
_newKeyedFormData.splice(index, 1);
|
|
196
|
-
_newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
|
|
197
|
-
return _newKeyedFormData;
|
|
198
|
-
}
|
|
199
|
-
const newKeyedFormData = reOrderArray();
|
|
200
|
-
this.setState({
|
|
201
|
-
keyedFormData: newKeyedFormData,
|
|
202
|
-
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
206
|
-
* `onChange` callback with the updated form data
|
|
207
|
-
*
|
|
208
|
-
* @param index - The index of the item being changed
|
|
209
|
-
*/
|
|
210
|
-
this.onChangeForIndex = (index) => {
|
|
211
|
-
return (value, newErrorSchema, id) => {
|
|
212
|
-
const { formData, onChange, errorSchema } = this.props;
|
|
213
|
-
const arrayData = Array.isArray(formData) ? formData : [];
|
|
214
|
-
const newFormData = arrayData.map((item, i) => {
|
|
215
|
-
// We need to treat undefined items as nulls to have validation.
|
|
216
|
-
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
217
|
-
const jsonValue = typeof value === 'undefined' ? null : value;
|
|
218
|
-
return index === i ? jsonValue : item;
|
|
219
|
-
});
|
|
220
|
-
onChange(newFormData, errorSchema &&
|
|
221
|
-
errorSchema && {
|
|
222
|
-
...errorSchema,
|
|
223
|
-
[index]: newErrorSchema,
|
|
224
|
-
}, id);
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
/** Callback handler used to change the value for a checkbox */
|
|
228
|
-
this.onSelectChange = (value) => {
|
|
229
|
-
const { onChange, idSchema } = this.props;
|
|
230
|
-
onChange(value, undefined, idSchema && idSchema.$id);
|
|
231
|
-
};
|
|
232
49
|
const { formData = [] } = props;
|
|
233
50
|
const keyedFormData = generateKeyedFormData(formData);
|
|
234
51
|
this.state = {
|
|
@@ -308,6 +125,19 @@ class ArrayField extends Component {
|
|
|
308
125
|
}
|
|
309
126
|
return addable;
|
|
310
127
|
}
|
|
128
|
+
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
129
|
+
* that the schema is fixed and allows additional items.
|
|
130
|
+
*/
|
|
131
|
+
_getNewFormDataRow = () => {
|
|
132
|
+
const { schema, registry } = this.props;
|
|
133
|
+
const { schemaUtils } = registry;
|
|
134
|
+
let itemSchema = schema.items;
|
|
135
|
+
if (isFixedItems(schema) && allowAdditionalItems(schema)) {
|
|
136
|
+
itemSchema = schema.additionalItems;
|
|
137
|
+
}
|
|
138
|
+
// Cast this as a T to work around schema utils being for T[] caused by the FieldProps<T[], S, F> call on the class
|
|
139
|
+
return schemaUtils.getDefaultFormState(itemSchema);
|
|
140
|
+
};
|
|
311
141
|
/** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
|
|
312
142
|
* either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
|
|
313
143
|
* the state, and then returning `onChange()` with the plain form data converted from the keyed data
|
|
@@ -351,6 +181,176 @@ class ArrayField extends Component {
|
|
|
351
181
|
updatedKeyedFormData: true,
|
|
352
182
|
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
353
183
|
}
|
|
184
|
+
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
185
|
+
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
186
|
+
* keyed data
|
|
187
|
+
*
|
|
188
|
+
* @param event - The event for the click
|
|
189
|
+
*/
|
|
190
|
+
onAddClick = (event) => {
|
|
191
|
+
this._handleAddClick(event);
|
|
192
|
+
};
|
|
193
|
+
/** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
|
|
194
|
+
* keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
|
|
195
|
+
* form data converted from the keyed data
|
|
196
|
+
*
|
|
197
|
+
* @param index - The index at which the add button is clicked
|
|
198
|
+
*/
|
|
199
|
+
onAddIndexClick = (index) => {
|
|
200
|
+
return (event) => {
|
|
201
|
+
this._handleAddClick(event, index);
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
205
|
+
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
206
|
+
* form data converted from the keyed data
|
|
207
|
+
*
|
|
208
|
+
* @param index - The index at which the copy button is clicked
|
|
209
|
+
*/
|
|
210
|
+
onCopyIndexClick = (index) => {
|
|
211
|
+
return (event) => {
|
|
212
|
+
if (event) {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
}
|
|
215
|
+
const { onChange, errorSchema } = this.props;
|
|
216
|
+
const { keyedFormData } = this.state;
|
|
217
|
+
// refs #195: revalidate to ensure properly reindexing errors
|
|
218
|
+
let newErrorSchema;
|
|
219
|
+
if (errorSchema) {
|
|
220
|
+
newErrorSchema = {};
|
|
221
|
+
for (const idx in errorSchema) {
|
|
222
|
+
const i = parseInt(idx);
|
|
223
|
+
if (i <= index) {
|
|
224
|
+
set(newErrorSchema, [i], errorSchema[idx]);
|
|
225
|
+
}
|
|
226
|
+
else if (i > index) {
|
|
227
|
+
set(newErrorSchema, [i + 1], errorSchema[idx]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const newKeyedFormDataRow = {
|
|
232
|
+
key: generateRowId(),
|
|
233
|
+
item: cloneDeep(keyedFormData[index].item),
|
|
234
|
+
};
|
|
235
|
+
const newKeyedFormData = [...keyedFormData];
|
|
236
|
+
if (index !== undefined) {
|
|
237
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
241
|
+
}
|
|
242
|
+
this.setState({
|
|
243
|
+
keyedFormData: newKeyedFormData,
|
|
244
|
+
updatedKeyedFormData: true,
|
|
245
|
+
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
249
|
+
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
250
|
+
* from the keyed data
|
|
251
|
+
*
|
|
252
|
+
* @param index - The index at which the remove button is clicked
|
|
253
|
+
*/
|
|
254
|
+
onDropIndexClick = (index) => {
|
|
255
|
+
return (event) => {
|
|
256
|
+
if (event) {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
}
|
|
259
|
+
const { onChange, errorSchema } = this.props;
|
|
260
|
+
const { keyedFormData } = this.state;
|
|
261
|
+
// refs #195: revalidate to ensure properly reindexing errors
|
|
262
|
+
let newErrorSchema;
|
|
263
|
+
if (errorSchema) {
|
|
264
|
+
newErrorSchema = {};
|
|
265
|
+
for (const idx in errorSchema) {
|
|
266
|
+
const i = parseInt(idx);
|
|
267
|
+
if (i < index) {
|
|
268
|
+
set(newErrorSchema, [i], errorSchema[idx]);
|
|
269
|
+
}
|
|
270
|
+
else if (i > index) {
|
|
271
|
+
set(newErrorSchema, [i - 1], errorSchema[idx]);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
|
|
276
|
+
this.setState({
|
|
277
|
+
keyedFormData: newKeyedFormData,
|
|
278
|
+
updatedKeyedFormData: true,
|
|
279
|
+
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
283
|
+
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
284
|
+
* plain form data converted from the keyed data
|
|
285
|
+
*
|
|
286
|
+
* @param index - The index of the item to move
|
|
287
|
+
* @param newIndex - The index to where the item is to be moved
|
|
288
|
+
*/
|
|
289
|
+
onReorderClick = (index, newIndex) => {
|
|
290
|
+
return (event) => {
|
|
291
|
+
if (event) {
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
event.currentTarget.blur();
|
|
294
|
+
}
|
|
295
|
+
const { onChange, errorSchema } = this.props;
|
|
296
|
+
let newErrorSchema;
|
|
297
|
+
if (errorSchema) {
|
|
298
|
+
newErrorSchema = {};
|
|
299
|
+
for (const idx in errorSchema) {
|
|
300
|
+
const i = parseInt(idx);
|
|
301
|
+
if (i == index) {
|
|
302
|
+
set(newErrorSchema, [newIndex], errorSchema[index]);
|
|
303
|
+
}
|
|
304
|
+
else if (i == newIndex) {
|
|
305
|
+
set(newErrorSchema, [index], errorSchema[newIndex]);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
set(newErrorSchema, [idx], errorSchema[i]);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const { keyedFormData } = this.state;
|
|
313
|
+
function reOrderArray() {
|
|
314
|
+
// Copy item
|
|
315
|
+
const _newKeyedFormData = keyedFormData.slice();
|
|
316
|
+
// Moves item from index to newIndex
|
|
317
|
+
_newKeyedFormData.splice(index, 1);
|
|
318
|
+
_newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
|
|
319
|
+
return _newKeyedFormData;
|
|
320
|
+
}
|
|
321
|
+
const newKeyedFormData = reOrderArray();
|
|
322
|
+
this.setState({
|
|
323
|
+
keyedFormData: newKeyedFormData,
|
|
324
|
+
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
328
|
+
* `onChange` callback with the updated form data
|
|
329
|
+
*
|
|
330
|
+
* @param index - The index of the item being changed
|
|
331
|
+
*/
|
|
332
|
+
onChangeForIndex = (index) => {
|
|
333
|
+
return (value, newErrorSchema, id) => {
|
|
334
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
335
|
+
const arrayData = Array.isArray(formData) ? formData : [];
|
|
336
|
+
const newFormData = arrayData.map((item, i) => {
|
|
337
|
+
// We need to treat undefined items as nulls to have validation.
|
|
338
|
+
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
339
|
+
const jsonValue = typeof value === 'undefined' ? null : value;
|
|
340
|
+
return index === i ? jsonValue : item;
|
|
341
|
+
});
|
|
342
|
+
onChange(newFormData, errorSchema &&
|
|
343
|
+
errorSchema && {
|
|
344
|
+
...errorSchema,
|
|
345
|
+
[index]: newErrorSchema,
|
|
346
|
+
}, id);
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
/** Callback handler used to change the value for a checkbox */
|
|
350
|
+
onSelectChange = (value) => {
|
|
351
|
+
const { onChange, idSchema } = this.props;
|
|
352
|
+
onChange(value, undefined, idSchema && idSchema.$id);
|
|
353
|
+
};
|
|
354
354
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
355
355
|
*/
|
|
356
356
|
render() {
|
|
@@ -418,7 +418,7 @@ class ArrayField extends Component {
|
|
|
418
418
|
totalItems: keyedFormData.length,
|
|
419
419
|
});
|
|
420
420
|
}),
|
|
421
|
-
className: `field field-array field-array-of-${itemsSchema.type}`,
|
|
421
|
+
className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}`,
|
|
422
422
|
disabled,
|
|
423
423
|
idSchema,
|
|
424
424
|
uiSchema,
|
|
@@ -438,38 +438,35 @@ class ArrayField extends Component {
|
|
|
438
438
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
439
439
|
*/
|
|
440
440
|
renderCustomWidget() {
|
|
441
|
-
var _a;
|
|
442
441
|
const { schema, idSchema, uiSchema, disabled = false, readonly = false, autofocus = false, required = false, hideError, placeholder, onBlur, onFocus, formData: items = [], registry, rawErrors, name, } = this.props;
|
|
443
442
|
const { widgets, formContext, globalUiOptions, schemaUtils } = registry;
|
|
444
443
|
const { widget, title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
445
444
|
const Widget = getWidget(schema, widget, widgets);
|
|
446
|
-
const label =
|
|
445
|
+
const label = uiTitle ?? schema.title ?? name;
|
|
447
446
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
448
447
|
return (_jsx(Widget, { id: idSchema.$id, name: name, multiple: true, onChange: this.onSelectChange, onBlur: onBlur, onFocus: onFocus, options: options, schema: schema, uiSchema: uiSchema, registry: registry, value: items, disabled: disabled, readonly: readonly, hideError: hideError, required: required, label: label, hideLabel: !displayLabel, placeholder: placeholder, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors }));
|
|
449
448
|
}
|
|
450
449
|
/** Renders an array as a set of checkboxes
|
|
451
450
|
*/
|
|
452
451
|
renderMultiSelect() {
|
|
453
|
-
var _a;
|
|
454
452
|
const { schema, idSchema, uiSchema, formData: items = [], disabled = false, readonly = false, autofocus = false, required = false, placeholder, onBlur, onFocus, registry, rawErrors, name, } = this.props;
|
|
455
453
|
const { widgets, schemaUtils, formContext, globalUiOptions } = registry;
|
|
456
454
|
const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
457
455
|
const enumOptions = optionsList(itemsSchema, uiSchema);
|
|
458
456
|
const { widget = 'select', title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
459
457
|
const Widget = getWidget(schema, widget, widgets);
|
|
460
|
-
const label =
|
|
458
|
+
const label = uiTitle ?? schema.title ?? name;
|
|
461
459
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
462
460
|
return (_jsx(Widget, { id: idSchema.$id, name: name, multiple: true, onChange: this.onSelectChange, onBlur: onBlur, onFocus: onFocus, options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, registry: registry, value: items, disabled: disabled, readonly: readonly, required: required, label: label, hideLabel: !displayLabel, placeholder: placeholder, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors }));
|
|
463
461
|
}
|
|
464
462
|
/** Renders an array of files using the `FileWidget`
|
|
465
463
|
*/
|
|
466
464
|
renderFiles() {
|
|
467
|
-
var _a;
|
|
468
465
|
const { schema, uiSchema, idSchema, name, disabled = false, readonly = false, autofocus = false, required = false, onBlur, onFocus, registry, formData: items = [], rawErrors, } = this.props;
|
|
469
466
|
const { widgets, formContext, globalUiOptions, schemaUtils } = registry;
|
|
470
467
|
const { widget = 'files', title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
471
468
|
const Widget = getWidget(schema, widget, widgets);
|
|
472
|
-
const label =
|
|
469
|
+
const label = uiTitle ?? schema.title ?? name;
|
|
473
470
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
474
471
|
return (_jsx(Widget, { options: options, id: idSchema.$id, name: name, multiple: true, onChange: this.onSelectChange, onBlur: onBlur, onFocus: onFocus, schema: schema, uiSchema: uiSchema, value: items, disabled: disabled, readonly: readonly, required: required, registry: registry, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors, label: label, hideLabel: !displayLabel }));
|
|
475
472
|
}
|
|
@@ -496,7 +493,7 @@ class ArrayField extends Component {
|
|
|
496
493
|
const canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
497
494
|
const arrayProps = {
|
|
498
495
|
canAdd,
|
|
499
|
-
className: 'field field-array field-array-fixed-items',
|
|
496
|
+
className: 'rjsf-field rjsf-field-array rjsf-field-array-fixed-items',
|
|
500
497
|
disabled,
|
|
501
498
|
idSchema,
|
|
502
499
|
formData,
|
|
@@ -572,21 +569,31 @@ class ArrayField extends Component {
|
|
|
572
569
|
has.toolbar = Object.keys(has).some((key) => has[key]);
|
|
573
570
|
return {
|
|
574
571
|
children: (_jsx(ItemSchemaField, { name: name, title: title, index: index, schema: itemSchema, uiSchema: itemUiSchema, formData: itemData, formContext: formContext, errorSchema: itemErrorSchema, idPrefix: idPrefix, idSeparator: idSeparator, idSchema: itemIdSchema, required: this.isItemRequired(itemSchema), onChange: this.onChangeForIndex(index), onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError, autofocus: autofocus, rawErrors: rawErrors })),
|
|
575
|
-
|
|
572
|
+
buttonsProps: {
|
|
573
|
+
idSchema: itemIdSchema,
|
|
574
|
+
disabled: disabled,
|
|
575
|
+
readonly: readonly,
|
|
576
|
+
canAdd,
|
|
577
|
+
hasCopy: has.copy,
|
|
578
|
+
hasMoveUp: has.moveUp,
|
|
579
|
+
hasMoveDown: has.moveDown,
|
|
580
|
+
hasRemove: has.remove,
|
|
581
|
+
index: index,
|
|
582
|
+
totalItems: totalItems,
|
|
583
|
+
onAddIndexClick: this.onAddIndexClick,
|
|
584
|
+
onCopyIndexClick: this.onCopyIndexClick,
|
|
585
|
+
onDropIndexClick: this.onDropIndexClick,
|
|
586
|
+
onReorderClick: this.onReorderClick,
|
|
587
|
+
registry: registry,
|
|
588
|
+
schema: itemSchema,
|
|
589
|
+
uiSchema: itemUiSchema,
|
|
590
|
+
},
|
|
591
|
+
className: 'rjsf-array-item',
|
|
576
592
|
disabled,
|
|
577
|
-
canAdd,
|
|
578
|
-
hasCopy: has.copy,
|
|
579
593
|
hasToolbar: has.toolbar,
|
|
580
|
-
hasMoveUp: has.moveUp,
|
|
581
|
-
hasMoveDown: has.moveDown,
|
|
582
|
-
hasRemove: has.remove,
|
|
583
594
|
index,
|
|
584
595
|
totalItems,
|
|
585
596
|
key,
|
|
586
|
-
onAddIndexClick: this.onAddIndexClick,
|
|
587
|
-
onCopyIndexClick: this.onCopyIndexClick,
|
|
588
|
-
onDropIndexClick: this.onDropIndexClick,
|
|
589
|
-
onReorderClick: this.onReorderClick,
|
|
590
597
|
readonly,
|
|
591
598
|
registry,
|
|
592
599
|
schema: itemSchema,
|
|
@@ -598,4 +605,3 @@ class ArrayField extends Component {
|
|
|
598
605
|
* `Field` which is defined as `React.ComponentType<FieldProps<T, S, F>>`, so cast it to make `registry` happy.
|
|
599
606
|
*/
|
|
600
607
|
export default ArrayField;
|
|
601
|
-
//# sourceMappingURL=ArrayField.js.map
|
|
@@ -6,3 +6,4 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
6
6
|
*/
|
|
7
7
|
declare function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export default BooleanField;
|
|
9
|
+
//# sourceMappingURL=BooleanField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BooleanField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/BooleanField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EACV,eAAe,EAEf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAGrB;;;;GAIG;AACH,iBAAS,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACrG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA6F3B;AAED,eAAe,YAAY,CAAC"}
|