@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
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getWidget, getUiOptions, optionsList, TranslatableString, } from '@rjsf/utils';
|
|
3
|
-
import isObject from 'lodash/isObject';
|
|
3
|
+
import isObject from 'lodash-es/isObject.js';
|
|
4
4
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
5
5
|
* two boolean values based on the various alternatives in the schema.
|
|
6
6
|
*
|
|
7
7
|
* @param props - The `FieldProps` for this template
|
|
8
8
|
*/
|
|
9
9
|
function BooleanField(props) {
|
|
10
|
-
var _a, _b, _c;
|
|
11
10
|
const { schema, name, uiSchema, idSchema, formData, registry, required, disabled, readonly, hideError, autofocus, title, onChange, onFocus, onBlur, rawErrors, } = props;
|
|
12
11
|
const { title: schemaTitle } = schema;
|
|
13
12
|
const { widgets, formContext, translateString, globalUiOptions } = registry;
|
|
14
13
|
const { widget = 'checkbox', title: uiTitle,
|
|
15
14
|
// Unlike the other fields, don't use `getDisplayLabel()` since it always returns false for the boolean type
|
|
16
|
-
label: displayLabel = true, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
15
|
+
label: displayLabel = true, enumNames, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
17
16
|
const Widget = getWidget(schema, widget, widgets);
|
|
18
17
|
const yes = translateString(TranslatableString.YesLabel);
|
|
19
18
|
const no = translateString(TranslatableString.NoLabel);
|
|
20
19
|
let enumOptions;
|
|
21
|
-
const label =
|
|
20
|
+
const label = uiTitle ?? schemaTitle ?? title ?? name;
|
|
22
21
|
if (Array.isArray(schema.oneOf)) {
|
|
23
22
|
enumOptions = optionsList({
|
|
24
23
|
oneOf: schema.oneOf
|
|
@@ -35,10 +34,8 @@ function BooleanField(props) {
|
|
|
35
34
|
}, uiSchema);
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const enums = (_c = schema.enum) !== null && _c !== void 0 ? _c : [true, false];
|
|
41
|
-
if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every((v) => typeof v === 'boolean')) {
|
|
37
|
+
const enums = schema.enum ?? [true, false];
|
|
38
|
+
if (!enumNames && enums.length === 2 && enums.every((v) => typeof v === 'boolean')) {
|
|
42
39
|
enumOptions = [
|
|
43
40
|
{
|
|
44
41
|
value: enums[0],
|
|
@@ -51,14 +48,9 @@ function BooleanField(props) {
|
|
|
51
48
|
];
|
|
52
49
|
}
|
|
53
50
|
else {
|
|
54
|
-
enumOptions = optionsList({
|
|
55
|
-
enum: enums,
|
|
56
|
-
// NOTE: enumNames is deprecated, but still supported for now.
|
|
57
|
-
enumNames: schemaWithEnumNames.enumNames,
|
|
58
|
-
}, uiSchema);
|
|
51
|
+
enumOptions = optionsList({ enum: enums }, uiSchema);
|
|
59
52
|
}
|
|
60
53
|
}
|
|
61
54
|
return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: idSchema.$id, name: name, onChange: onChange, onFocus: onFocus, onBlur: onBlur, label: label, hideLabel: !displayLabel, value: formData, required: required, disabled: disabled, readonly: readonly, hideError: hideError, registry: registry, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors }));
|
|
62
55
|
}
|
|
63
56
|
export default BooleanField;
|
|
64
|
-
//# sourceMappingURL=BooleanField.js.map
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
import { ComponentType, PureComponent, ReactNode } from 'react';
|
|
2
|
+
import { ErrorSchema, FieldProps, FormContextType, GenericObjectType, IdSchema, RJSFSchema, Registry, SchemaUtilsType, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
|
+
/** The enumeration of the three different Layout GridTemplate type values
|
|
4
|
+
*/
|
|
5
|
+
export declare enum GridType {
|
|
6
|
+
ROW = "ui:row",
|
|
7
|
+
COLUMN = "ui:col",
|
|
8
|
+
COLUMNS = "ui:columns",
|
|
9
|
+
CONDITION = "ui:condition"
|
|
10
|
+
}
|
|
11
|
+
/** The enumeration of the different operators within a condition
|
|
12
|
+
*/
|
|
13
|
+
export declare enum Operators {
|
|
14
|
+
ALL = "all",
|
|
15
|
+
SOME = "some",
|
|
16
|
+
NONE = "none"
|
|
17
|
+
}
|
|
18
|
+
/** Type used to represent an object that contains anything */
|
|
19
|
+
type ConfigObject = Record<string, any>;
|
|
20
|
+
export interface GridProps extends GenericObjectType {
|
|
21
|
+
/** The optional operator to use when comparing a field's value with the expected value for `GridType.CONDITION`
|
|
22
|
+
*/
|
|
23
|
+
operator?: Operators;
|
|
24
|
+
/** The optional name of the field from which to get the value for `GridType.CONDITION`
|
|
25
|
+
*/
|
|
26
|
+
field?: string;
|
|
27
|
+
/** The optional expected value against which to compare the field's value using the `operator`
|
|
28
|
+
*/
|
|
29
|
+
value?: unknown;
|
|
30
|
+
}
|
|
31
|
+
export type GridSchemaType = {
|
|
32
|
+
[gridType in GridType]?: object;
|
|
33
|
+
};
|
|
34
|
+
/** The types which comprise the possibilities for the `layoutGridSchema` prop
|
|
35
|
+
*/
|
|
36
|
+
export type LayoutGridSchemaType = GridSchemaType | ConfigObject | string;
|
|
37
|
+
export interface LayoutGridFieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends FieldProps<T, S, F> {
|
|
38
|
+
/** Optional string or object used to describe the current level of the `LayoutGridField`
|
|
39
|
+
*/
|
|
40
|
+
layoutGridSchema?: LayoutGridSchemaType;
|
|
41
|
+
}
|
|
42
|
+
/** The regular expression that is used to detect whether a string contains a lookup key
|
|
43
|
+
*/
|
|
44
|
+
export declare const LOOKUP_REGEX: RegExp;
|
|
45
|
+
/** The constant representing the main layout grid schema option name in the `uiSchema`
|
|
46
|
+
*/
|
|
47
|
+
export declare const LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
48
|
+
/** The constant representing the main layout grid schema option name in the `uiSchema`
|
|
49
|
+
*/
|
|
50
|
+
export declare const LAYOUT_GRID_OPTION = "ui:layoutGrid";
|
|
51
|
+
/** The constant representing the global UI Options object potentially contained within the `uiSchema`
|
|
52
|
+
*/
|
|
53
|
+
export declare const UI_GLOBAL_OPTIONS = "ui:global_options";
|
|
54
|
+
/** Type used to return options list and whether it has a discriminator */
|
|
55
|
+
type OneOfOptionsInfoType<S extends StrictRJSFSchema = RJSFSchema> = {
|
|
56
|
+
options: S[];
|
|
57
|
+
hasDiscriminator: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** Type used to represent a React-based rendering component */
|
|
60
|
+
type RenderComponent = ComponentType<any>;
|
|
61
|
+
/** Type used to determine what are the UIComponent and props from the grid schema */
|
|
62
|
+
type UIComponentPropsType = {
|
|
63
|
+
/** The name of the component */
|
|
64
|
+
name: string;
|
|
65
|
+
/** The render component if specified */
|
|
66
|
+
UIComponent: RenderComponent | null;
|
|
67
|
+
/** Any uiProps associated with the render component */
|
|
68
|
+
uiProps: ConfigObject;
|
|
69
|
+
/** The special case where the component is immediately rendered */
|
|
70
|
+
rendered: ReactNode;
|
|
71
|
+
};
|
|
72
|
+
/** The `LayoutGridField` will render a schema, uiSchema and formData combination out into a GridTemplate in the shape
|
|
73
|
+
* described in the uiSchema. To define the grid to use to render the elements within a field in the schema, provide in
|
|
74
|
+
* the uiSchema for that field the object contained under a `ui:layoutGrid` element. E.g. (as a JSON object):
|
|
75
|
+
*
|
|
76
|
+
* ```
|
|
77
|
+
* {
|
|
78
|
+
* "field1" : {
|
|
79
|
+
* "ui:field": "LayoutGridField",
|
|
80
|
+
* "ui:layoutGrid": {
|
|
81
|
+
* "ui:row": { ... }
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* The outermost level of a `LayoutGridField` is the `ui:row` that defines the nested rows, columns, and/or condition
|
|
88
|
+
* elements (i.e. "grid elements") in the grid. This definition is either a simple "grid elements" OR an object with
|
|
89
|
+
* native `GridTemplate` implementation specific props and a `children` array of "grid elements". E.g. (as JSON objects):
|
|
90
|
+
*
|
|
91
|
+
* Simple `ui:row` definition, without additional `GridTemplate` props:
|
|
92
|
+
* ```
|
|
93
|
+
* "ui:row": [
|
|
94
|
+
* { "ui:row"|"ui:col"|"ui:columns"|"ui:condition": ... },
|
|
95
|
+
* ...
|
|
96
|
+
* ]
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* Complex `ui:row` definition, with additional `GridTemplate` (this example uses @mui/material/Grid2 native props):
|
|
100
|
+
* ```
|
|
101
|
+
* "ui:row": {
|
|
102
|
+
* "spacing": 2,
|
|
103
|
+
* "size": { md": 4 },
|
|
104
|
+
* "alignContent": "flex-start",
|
|
105
|
+
* "className": "GridRow",
|
|
106
|
+
* "children": [
|
|
107
|
+
* { "ui:row"|"ui:col"|"ui:columns"|"ui:condition": ... },
|
|
108
|
+
* ...
|
|
109
|
+
* ]
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* NOTE: Special note about the native `className` prop values. All className values will automatically be looked up in
|
|
114
|
+
* the `formContext.lookupMap` in case they have been defined using a CSS-in-JS approach. In other words, from the
|
|
115
|
+
* example above, if the `Form` was constructed with a `lookupMap` set to `{ GridRow: cssInJs.GridRowClass }`
|
|
116
|
+
* then when rendered, the native `GridTemplate` will get the `className` with the value from
|
|
117
|
+
* `cssInJs.GridRowClass`. This automatic lookup will happen for any of the "grid elements" when rendering with
|
|
118
|
+
* `GridTemplate` props. If multiple className values are present, for example:
|
|
119
|
+
* `{ className: 'GridRow GridColumn' }`, the classNames are split apart, looked up individually, and joined
|
|
120
|
+
* together to form one className with the values from `cssInJs.GridRowClass` and `cssInJs.GridColumnClass`.
|
|
121
|
+
*
|
|
122
|
+
* The `ui:col` grid element is used to specify the list of columns within a grid row. A `ui:col` element can take on
|
|
123
|
+
* several forms: 1) a simple list of dotted-path field names within the root field; 2) a list of objects containing the
|
|
124
|
+
* dotted-path field `name` any other props that are gathered into `ui:options` for the field; 3) a list with a one-off
|
|
125
|
+
* `render` functional component with or without a non-field `name` identifier and any other to-be-spread props; and
|
|
126
|
+
* 4) an object with native `GridTemplate` implementation specific props and a `children` array with 1) or 2) or even a
|
|
127
|
+
* nested `ui:row` or a `ui:condition` containing a `ui:row` (although this should be used carefully). E.g.
|
|
128
|
+
* (as JSON objects):
|
|
129
|
+
*
|
|
130
|
+
* Simple `ui:col` definition, without additional `GridTemplate` props and form 1 only children:
|
|
131
|
+
* ```
|
|
132
|
+
* "ui:col": ["innerField", "inner.grandChild", ...]
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* Complicated `ui:col` definition, without additional `GridTemplate` props and form 2 only children:
|
|
136
|
+
* ```
|
|
137
|
+
* "ui:col": [
|
|
138
|
+
* { "name": "innerField", "fullWidth": true },
|
|
139
|
+
* { "name": "inner.grandChild", "convertOther": true },
|
|
140
|
+
* ...
|
|
141
|
+
* ]
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* More complicated `ui:col` definition, without additional `GridTemplate` props and form 2 children, one being a
|
|
145
|
+
* one-off `render` functional component without a non-field `name` identifier
|
|
146
|
+
* ```
|
|
147
|
+
* "ui:col": [
|
|
148
|
+
* "innerField",
|
|
149
|
+
* {
|
|
150
|
+
* "render": "WizardNavButton",
|
|
151
|
+
* "isNext": true,
|
|
152
|
+
* "size": "large"
|
|
153
|
+
* }
|
|
154
|
+
* ]
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* Most complicated `ui:col` definition, additional `GridTemplate` props and form 1, 2 and 3 children (this example
|
|
158
|
+
* uses @mui/material/Grid2 native props):
|
|
159
|
+
* ```
|
|
160
|
+
* "ui:col": {
|
|
161
|
+
* "size": { "md": 4 },
|
|
162
|
+
* "className": "GridColumn",
|
|
163
|
+
* "children": [
|
|
164
|
+
* "innerField",
|
|
165
|
+
* { "name": "inner.grandChild", "convertOther": true },
|
|
166
|
+
* { "name": "customRender", "render": "CustomRender", toSpread: "prop-value" }
|
|
167
|
+
* { "ui:row|ui:condition": ... }
|
|
168
|
+
* ...
|
|
169
|
+
* ]
|
|
170
|
+
* }
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* NOTE: If a `name` prop does not exist or its value does not match any field in a schema, then it is assumed to be a
|
|
174
|
+
* custom `render` component. If the `render` prop does not exist, a null render will occur. If `render` is a
|
|
175
|
+
* string, its value will be looked up in the `formContext.lookupMap` first before defaulting to a null render.
|
|
176
|
+
*
|
|
177
|
+
* The `ui:columns` grid element is syntactic sugar to specify a set of `ui:col` columns that all share the same set of
|
|
178
|
+
* native `GridTemplate` props. In other words rather than writing the following configuration that renders a
|
|
179
|
+
* `<GridTemplate>` element with 3 `<GridTemplate column className="GridColumn col-md-4">` nodes and 2
|
|
180
|
+
* `<GridTemplate column className="col-md-6">` nodes within it (one for each of the fields contained in the `children`
|
|
181
|
+
* list):
|
|
182
|
+
*
|
|
183
|
+
* ```
|
|
184
|
+
* "ui:row": {
|
|
185
|
+
* "children": [
|
|
186
|
+
* {
|
|
187
|
+
* "ui:col": {
|
|
188
|
+
* "className": "GridColumn col-md-4",
|
|
189
|
+
* "children": ["innerField"],
|
|
190
|
+
* }
|
|
191
|
+
* },
|
|
192
|
+
* {
|
|
193
|
+
* "ui:col": {
|
|
194
|
+
* "className": "GridColumn col-md-4",
|
|
195
|
+
* "children": ["inner.grandChild"],
|
|
196
|
+
* }
|
|
197
|
+
* },
|
|
198
|
+
* {
|
|
199
|
+
* "ui:col": {
|
|
200
|
+
* "className": "GridColumn col-md-4",
|
|
201
|
+
* "children": [{ "name": "inner.grandChild2" }],
|
|
202
|
+
* }
|
|
203
|
+
* },
|
|
204
|
+
* {
|
|
205
|
+
* "ui:col": {
|
|
206
|
+
* "className": "col-md-6",
|
|
207
|
+
* "children": ["innerField2"],
|
|
208
|
+
* }
|
|
209
|
+
* },
|
|
210
|
+
* {
|
|
211
|
+
* "ui:col": {
|
|
212
|
+
* "className": "col-md-6",
|
|
213
|
+
* "children": ["inner.grandChild3"],
|
|
214
|
+
* }
|
|
215
|
+
* },
|
|
216
|
+
|
|
217
|
+
* ]
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* One can write this instead:
|
|
222
|
+
* ```
|
|
223
|
+
* "ui:row": {
|
|
224
|
+
* "children": [
|
|
225
|
+
* {
|
|
226
|
+
* "ui:columns": {
|
|
227
|
+
* "className": "GridColumn col-md-4",
|
|
228
|
+
* "children": ["innerField", "inner.grandChild", { "name": "inner.grandChild2", "convertOther": true }],
|
|
229
|
+
* }
|
|
230
|
+
* },
|
|
231
|
+
* {
|
|
232
|
+
* "ui:columns": {
|
|
233
|
+
* "className": "col-md-6",
|
|
234
|
+
* "children": ["innerField2", "inner.grandChild3"],
|
|
235
|
+
* }
|
|
236
|
+
* }
|
|
237
|
+
* ]
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*
|
|
241
|
+
* NOTE: This syntax differs from
|
|
242
|
+
* `"ui:col": { "className": "col-md-6", "children": ["innerField2", "inner.grandChild3"] }` in that
|
|
243
|
+
* the `ui:col` will render the two children fields inside a single `<GridTemplate "className": "col-md-6",>`
|
|
244
|
+
* element.
|
|
245
|
+
*
|
|
246
|
+
* The final grid element, `ui:condition`, allows for conditionally displaying "grid elements" within a row based on the
|
|
247
|
+
* current value of a field as it relates to a (list of) hard-coded value(s). There are four elements that make up a
|
|
248
|
+
* `ui:condition`: 1) the dotted-path `field` name within the root field that makes up the left-side of the condition;
|
|
249
|
+
* 2) the hard-coded `value` (single or list) that makes up the right-side of the condition; 3) the `operator` that
|
|
250
|
+
* controls how the left and right sides of the condition are compared; and 4) the `children` array that defines the
|
|
251
|
+
* "grid elements" to display if the condition passes.
|
|
252
|
+
*
|
|
253
|
+
* A `ui:condition` uses one of three `operators` when deciding if a condition passes: 1) The `all` operator will pass
|
|
254
|
+
* when the right-side and left-side contains all the same value(s); 2) the `some` operator will pass when the
|
|
255
|
+
* right-side and left-side contain as least one value in common; 3) the `none` operator will pass when the right-side
|
|
256
|
+
* and left-side do not contain any values in common. E.g. (as JSON objects):
|
|
257
|
+
*
|
|
258
|
+
* Here is how to render an if-then-else for `field2` which is an enum that has 3 known values and supports allowing
|
|
259
|
+
* any other value:
|
|
260
|
+
* ```
|
|
261
|
+
* "ui:row": [
|
|
262
|
+
* {
|
|
263
|
+
* "ui:condition": {
|
|
264
|
+
* "field": "field2",
|
|
265
|
+
* "operator": "all",
|
|
266
|
+
* "value": "value1",
|
|
267
|
+
* "children": [
|
|
268
|
+
* { "ui:row": [...] },
|
|
269
|
+
* ],
|
|
270
|
+
* }
|
|
271
|
+
* },
|
|
272
|
+
* {
|
|
273
|
+
* "ui:condition": {
|
|
274
|
+
* "field": "field2",
|
|
275
|
+
* "operator": "some",
|
|
276
|
+
* "value": ["value2", "value3"],
|
|
277
|
+
* "children": [
|
|
278
|
+
* { "ui:row": [...] },
|
|
279
|
+
* ],
|
|
280
|
+
* }
|
|
281
|
+
* },
|
|
282
|
+
* {
|
|
283
|
+
* "ui:condition": {
|
|
284
|
+
* "field": "field2",
|
|
285
|
+
* "operator": "none",
|
|
286
|
+
* "value": ["value1", "value2", "value3"],
|
|
287
|
+
* "children": [
|
|
288
|
+
* { "ui:row": [...] },
|
|
289
|
+
* ],
|
|
290
|
+
* }
|
|
291
|
+
* }
|
|
292
|
+
* ]
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
export default class LayoutGridField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends PureComponent<LayoutGridFieldProps<T, S, F>> {
|
|
296
|
+
static defaultProps: {
|
|
297
|
+
layoutGridSchema: undefined;
|
|
298
|
+
};
|
|
299
|
+
static TEST_IDS: import("@rjsf/utils").TestIdShape;
|
|
300
|
+
/** Computes the uiSchema for the field with `name` from the `uiProps` and `uiSchema` provided. The field UI Schema
|
|
301
|
+
* will always contain a copy of the global options from the `uiSchema` (so they can be passed down) as well as
|
|
302
|
+
* copying them into the local ui options. When the `forceReadonly` flag is true, then the field UI Schema is
|
|
303
|
+
* updated to make "readonly" be true. When the `schemaReadonly` flag is true AND the field UI Schema does NOT have
|
|
304
|
+
* the flag already provided, then we also make "readonly" true. We always make sure to return the final value of the
|
|
305
|
+
* field UI Schema's "readonly" flag as `uiReadonly` along with the `fieldUiSchema` in the return value.
|
|
306
|
+
*
|
|
307
|
+
* @param field - The name of the field to pull the existing UI Schema for
|
|
308
|
+
* @param uiProps - Any props that should be put into the field's uiSchema
|
|
309
|
+
* @param [uiSchema] - The optional UI Schema from which to get the UI schema for the field
|
|
310
|
+
* @param [schemaReadonly] - Optional flag indicating whether the schema indicates the field is readonly
|
|
311
|
+
* @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
|
|
312
|
+
*/
|
|
313
|
+
static computeFieldUiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(field: string, uiProps: ConfigObject, uiSchema?: UiSchema<T, S, F>, schemaReadonly?: boolean, forceReadonly?: boolean): {
|
|
314
|
+
fieldUiSchema: any;
|
|
315
|
+
uiReadonly: boolean | undefined;
|
|
316
|
+
};
|
|
317
|
+
/** Given an `operator`, `datum` and `value` determines whether this condition is considered matching. Matching
|
|
318
|
+
* depends on the `operator`. The `datum` and `value` are converted into arrays if they aren't already and then the
|
|
319
|
+
* contents of the two arrays are compared using the `operator`. When `operator` is All, then the two arrays must be
|
|
320
|
+
* equal to match. When `operator` is SOME then the intersection of the two arrays must have at least one value in
|
|
321
|
+
* common to match. When `operator` is NONE then the intersection of the two arrays must not have any values in common
|
|
322
|
+
* to match.
|
|
323
|
+
*
|
|
324
|
+
* @param [operator] - The optional operator for the condition
|
|
325
|
+
* @param [datum] - The optional datum for the condition, this can be an item or a list of items of type unknown
|
|
326
|
+
* @param [value='$0m3tH1nG Un3xP3cT3d'] The optional value for the condition, defaulting to a highly unlikely value
|
|
327
|
+
* to avoid comparing two undefined elements when `value` was forgotten in the condition definition.
|
|
328
|
+
* This can be an item or a list of items of type unknown
|
|
329
|
+
* @returns - True if the condition matches, false otherwise
|
|
330
|
+
*/
|
|
331
|
+
static conditionMatches(operator?: Operators, datum?: unknown, value?: unknown): boolean;
|
|
332
|
+
/** From within the `layoutGridSchema` finds the `children` and any extra `gridProps` from the object keyed by
|
|
333
|
+
* `schemaKey`. If the `children` contains extra `gridProps` and those props contain a `className` string, try to
|
|
334
|
+
* lookup whether that `className` has a replacement value in the `registry` using the `FORM_CONTEXT_LOOKUP_BASE`.
|
|
335
|
+
* When the `className` value contains multiple classNames separated by a space, the lookup will look for a
|
|
336
|
+
* replacement value for each `className` and combine them into one.
|
|
337
|
+
*
|
|
338
|
+
* @param layoutGridSchema - The GridSchemaType instance from which to obtain the `schemaKey` children and extra props
|
|
339
|
+
* @param schemaKey - A `GridType` value, used to get the children and extra props from within the `layoutGridSchema`
|
|
340
|
+
* @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
|
|
341
|
+
* @returns - An object containing the list of `LayoutGridSchemaType` `children` and any extra `gridProps`
|
|
342
|
+
* @throws - A `TypeError` when the `children` is not an array
|
|
343
|
+
*/
|
|
344
|
+
static findChildrenAndProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(layoutGridSchema: GridSchemaType, schemaKey: GridType, registry: Registry<T, S, F>): {
|
|
345
|
+
children: LayoutGridSchemaType[];
|
|
346
|
+
gridProps: GridProps;
|
|
347
|
+
};
|
|
348
|
+
/** Generates an idSchema for the `schema` using `@rjsf`'s `toIdSchema` util, passing the `baseIdSchema`'s `$id` value
|
|
349
|
+
* as the id prefix.
|
|
350
|
+
*
|
|
351
|
+
* @param schemaUtils - The `SchemaUtilsType` used to call `toIdSchema`
|
|
352
|
+
* @param schema - The schema to generate the idSchema for
|
|
353
|
+
* @param baseIdSchema - The IdSchema for the base
|
|
354
|
+
* @param formData - The formData to pass the `toIdSchema`
|
|
355
|
+
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
356
|
+
* @returns - The generated `idSchema` for the `schema`
|
|
357
|
+
*/
|
|
358
|
+
static getIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schemaUtils: SchemaUtilsType<T, S, F>, baseIdSchema: IdSchema<T>, formData: FieldProps['formData'], schema?: S, idSeparator?: string): FieldProps<T, S, F>['idSchema'];
|
|
359
|
+
/** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
|
|
360
|
+
* the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
|
|
361
|
+
* element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
|
|
362
|
+
* `options`.
|
|
363
|
+
*
|
|
364
|
+
* @param schemaUtils - The `SchemaUtilsType` used to call `retrieveSchema`
|
|
365
|
+
* @param dottedPath - The dotted-path to the field for which to get the schema
|
|
366
|
+
* @param initialSchema - The initial schema to start the search from
|
|
367
|
+
* @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
|
|
368
|
+
* @param initialIdSchema - The initial idSchema to start the search from
|
|
369
|
+
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
370
|
+
* @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
|
|
371
|
+
* info if a oneOf/anyOf
|
|
372
|
+
*/
|
|
373
|
+
static getSchemaDetailsForField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schemaUtils: SchemaUtilsType<T, S, F>, dottedPath: string, initialSchema: S, formData: FieldProps<T, S, F>['formData'], initialIdSchema: IdSchema<T>, idSeparator?: string): {
|
|
374
|
+
schema?: S;
|
|
375
|
+
isRequired: boolean;
|
|
376
|
+
isReadonly?: boolean;
|
|
377
|
+
optionsInfo?: OneOfOptionsInfoType<S>;
|
|
378
|
+
idSchema: IdSchema<T>;
|
|
379
|
+
};
|
|
380
|
+
/** Gets the custom render component from the `render`, by either determining that it is either already a function or
|
|
381
|
+
* it is a non-function value that can be used to look up the function in the registry. If no function can be found,
|
|
382
|
+
* null is returned.
|
|
383
|
+
*
|
|
384
|
+
* @param render - The potential render function or lookup name to one
|
|
385
|
+
* @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
|
|
386
|
+
* @returns - Either a render function if available, or null if not
|
|
387
|
+
*/
|
|
388
|
+
static getCustomRenderComponent<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(render: string | RenderComponent, registry: Registry<T, S, F>): RenderComponent | null;
|
|
389
|
+
/** Extract the `name`, and optional `render` and all other props from the `gridSchema`. We look up the `render` to
|
|
390
|
+
* see if can be resolved to a UIComponent. If `name` does not exist and there is an optional `render` UIComponent, we
|
|
391
|
+
* set the `rendered` component with only specified props for that component in the object.
|
|
392
|
+
*
|
|
393
|
+
* @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
|
|
394
|
+
* @param gridSchema - The string or object that represents the configuration for the grid field
|
|
395
|
+
* @returns - The UIComponentPropsType computed from the gridSchema
|
|
396
|
+
*/
|
|
397
|
+
static computeUIComponentPropsFromGridSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(registry: Registry<T, S, F>, gridSchema?: string | ConfigObject): UIComponentPropsType;
|
|
398
|
+
/** Constructs an `LayoutGridField` with the given `props`
|
|
399
|
+
*
|
|
400
|
+
* @param props - The `LayoutGridField` for this template
|
|
401
|
+
*/
|
|
402
|
+
constructor(props: LayoutGridFieldProps<T, S, F>);
|
|
403
|
+
/** Generates an `onChange` handler for the field associated with the `dottedPath`. This handler will clone and update
|
|
404
|
+
* the `formData` with the new `value` and the `errorSchema` if an `errSchema` is provided. After updating those two
|
|
405
|
+
* elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
|
|
406
|
+
*
|
|
407
|
+
* @param dottedPath - The dotted-path to the field for which to generate the onChange handler
|
|
408
|
+
* @returns - The `onChange` handling function for the `dottedPath` field
|
|
409
|
+
*/
|
|
410
|
+
onFieldChange: (dottedPath: string) => (value: unknown, errSchema?: ErrorSchema<T>, id?: string) => void;
|
|
411
|
+
/** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
|
|
412
|
+
* `GridType.CONDITION` is separated into the `children` and other `gridProps`. The `gridProps` are used to extract
|
|
413
|
+
* the `operator`, `field` and `value` of the condition. If the condition matches, then all of the `children` are
|
|
414
|
+
* rendered, otherwise null is returned.
|
|
415
|
+
*
|
|
416
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
417
|
+
* @returns - The rendered the children for the `GridType.CONDITION` or null
|
|
418
|
+
*/
|
|
419
|
+
renderCondition(layoutGridSchema: GridSchemaType): import("react/jsx-runtime").JSX.Element[] | null;
|
|
420
|
+
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMN` is separated
|
|
421
|
+
* into the `children` and other `gridProps`. The `gridProps` will be spread onto the outer `GridTemplate`. Inside
|
|
422
|
+
* the `GridTemplate` all the `children` are rendered.
|
|
423
|
+
*
|
|
424
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
425
|
+
* @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMN`
|
|
426
|
+
*/
|
|
427
|
+
renderCol(layoutGridSchema: GridSchemaType): import("react/jsx-runtime").JSX.Element;
|
|
428
|
+
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMNS` is separated
|
|
429
|
+
* into the `children` and other `gridProps`. The `children` is iterated on and `gridProps` will be spread onto the
|
|
430
|
+
* outer `GridTemplate`. Each child will have their own rendered `GridTemplate`.
|
|
431
|
+
*
|
|
432
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
433
|
+
* @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMNS`
|
|
434
|
+
*/
|
|
435
|
+
renderColumns(layoutGridSchema: GridSchemaType): import("react/jsx-runtime").JSX.Element[];
|
|
436
|
+
/** Renders a material-ui `GridTemplate` as a container. The
|
|
437
|
+
* `layoutGridSchema` for the `GridType.ROW` is separated into the `children` and other `gridProps`. The `gridProps`
|
|
438
|
+
* will be spread onto the outer `GridTemplate`. Inside of the `GridTemplate` all of the `children` are rendered.
|
|
439
|
+
*
|
|
440
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
441
|
+
* @returns - The rendered `GridTemplate` containing the children for the `GridType.ROW`
|
|
442
|
+
*/
|
|
443
|
+
renderRow(layoutGridSchema: GridSchemaType): import("react/jsx-runtime").JSX.Element;
|
|
444
|
+
/** Iterates through all the `childrenLayoutGridSchema`, rendering a nested `LayoutGridField` for each item in the
|
|
445
|
+
* list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
|
|
446
|
+
* `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
|
|
447
|
+
* `childrenLayoutGridSchema` is passed as `layoutGridSchema`.
|
|
448
|
+
*
|
|
449
|
+
* @param childrenLayoutGridSchema - The list of strings or objects that represents the configurations for the
|
|
450
|
+
* children fields
|
|
451
|
+
* @returns - The nested `LayoutGridField`s
|
|
452
|
+
*/
|
|
453
|
+
renderChildren(childrenLayoutGridSchema: LayoutGridSchemaType[]): import("react/jsx-runtime").JSX.Element[];
|
|
454
|
+
/** Renders the field described by `gridSchema`. If `gridSchema` is not an object, then is will be assumed
|
|
455
|
+
* to be the dotted-path to the field in the schema. Otherwise, we extract the `name`, and optional `render` and all
|
|
456
|
+
* other props. If `name` does not exist and there is an optional `render`, we return the `render` component with only
|
|
457
|
+
* specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
|
|
458
|
+
* and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
|
|
459
|
+
* schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
|
|
460
|
+
* `uiSchema`, `errorSchema`, `idSchema` and `formData` drilled down to the dotted-path field, spreading any other
|
|
461
|
+
* props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
|
|
462
|
+
* then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
|
|
463
|
+
* schema was located, but a custom render component was found, then it will be rendered with many of the non-event
|
|
464
|
+
* handling props. If none of the previous render paths are valid, then a null is returned.
|
|
465
|
+
*
|
|
466
|
+
* @param gridSchema - The string or object that represents the configuration for the grid field
|
|
467
|
+
* @returns - One of `LayoutMultiSchemaField`, `SchemaField`, a custom render component or null, depending
|
|
468
|
+
*/
|
|
469
|
+
renderField(gridSchema?: ConfigObject | string): string | number | true | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null;
|
|
470
|
+
/** Renders the `LayoutGridField`. If there isn't a `layoutGridSchema` prop defined, then try pulling it out of the
|
|
471
|
+
* `uiSchema` via `ui:LayoutGridField`. If `layoutGridSchema` is an object, then check to see if any of the properties
|
|
472
|
+
* match one of the `GridType`s. If so, call the appropriate render function for the type. Otherwise, just call the
|
|
473
|
+
* generic `renderField()` function with the `layoutGridSchema`.
|
|
474
|
+
*
|
|
475
|
+
* @returns - the rendered `LayoutGridField`
|
|
476
|
+
*/
|
|
477
|
+
render(): string | number | true | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[] | null;
|
|
478
|
+
}
|
|
479
|
+
export {};
|
|
480
|
+
//# sourceMappingURL=LayoutGridField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LayoutGridField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutGridField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAEL,WAAW,EACX,UAAU,EACV,eAAe,EACf,iBAAiB,EAOjB,QAAQ,EAMR,UAAU,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,EAEhB,QAAQ,EACT,MAAM,aAAa,CAAC;AAiBrB;GACG;AACH,oBAAY,QAAQ;IAClB,GAAG,WAAW;IACd,MAAM,WAAW;IACjB,OAAO,eAAe;IACtB,SAAS,iBAAiB;CAC3B;AAED;GACG;AACH,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,8DAA8D;AAC9D,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExC,MAAM,WAAW,SAAU,SAAQ,iBAAiB;IAClD;OACG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;OACG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;OACG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,cAAc,GAAG;KAG1B,QAAQ,IAAI,QAAQ,CAAC,CAAC,EAAE,MAAM;CAChC,CAAC;AAEF;GACG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,YAAY,GAAG,MAAM,CAAC;AAE1E,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,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