@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
|
@@ -2,148 +2,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import { getTemplate, getUiOptions, orderProperties, TranslatableString, ADDITIONAL_PROPERTY_FLAG, PROPERTIES_KEY, REF_KEY, ANY_OF_KEY, ONE_OF_KEY, } from '@rjsf/utils';
|
|
4
4
|
import Markdown from 'markdown-to-jsx';
|
|
5
|
-
import get from 'lodash/get';
|
|
6
|
-
import has from 'lodash/has';
|
|
7
|
-
import isObject from 'lodash/isObject';
|
|
8
|
-
import set from 'lodash/set';
|
|
9
|
-
import unset from 'lodash/unset';
|
|
5
|
+
import get from 'lodash-es/get.js';
|
|
6
|
+
import has from 'lodash-es/has.js';
|
|
7
|
+
import isObject from 'lodash-es/isObject.js';
|
|
8
|
+
import set from 'lodash-es/set.js';
|
|
9
|
+
import unset from 'lodash-es/unset.js';
|
|
10
10
|
/** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
|
|
11
11
|
* additional property key was modified and what it was modified to
|
|
12
12
|
*
|
|
13
13
|
* @param props - The `FieldProps` for this template
|
|
14
14
|
*/
|
|
15
15
|
class ObjectField extends Component {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
additionalProperties: {},
|
|
22
|
-
};
|
|
23
|
-
/** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
|
|
24
|
-
* to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
|
|
25
|
-
* formData.
|
|
26
|
-
*
|
|
27
|
-
* @param name - The name of the property
|
|
28
|
-
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
29
|
-
* @returns - The onPropertyChange callback for the `name` property
|
|
30
|
-
*/
|
|
31
|
-
this.onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
32
|
-
return (value, newErrorSchema, id) => {
|
|
33
|
-
const { formData, onChange, errorSchema } = this.props;
|
|
34
|
-
if (value === undefined && addedByAdditionalProperties) {
|
|
35
|
-
// Don't set value = undefined for fields added by
|
|
36
|
-
// additionalProperties. Doing so removes them from the
|
|
37
|
-
// formData, which causes them to completely disappear
|
|
38
|
-
// (including the input field for the property name). Unlike
|
|
39
|
-
// fields which are "mandated" by the schema, these fields can
|
|
40
|
-
// be set to undefined by clicking a "delete field" button, so
|
|
41
|
-
// set empty values to the empty string.
|
|
42
|
-
value = '';
|
|
43
|
-
}
|
|
44
|
-
const newFormData = { ...formData, [name]: value };
|
|
45
|
-
onChange(newFormData, errorSchema &&
|
|
46
|
-
errorSchema && {
|
|
47
|
-
...errorSchema,
|
|
48
|
-
[name]: newErrorSchema,
|
|
49
|
-
}, id);
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
53
|
-
* and calls the `onChange` callback with it
|
|
54
|
-
*
|
|
55
|
-
* @param key - The key for which the drop callback is desired
|
|
56
|
-
* @returns - The drop property click callback
|
|
57
|
-
*/
|
|
58
|
-
this.onDropPropertyClick = (key) => {
|
|
59
|
-
return (event) => {
|
|
60
|
-
event.preventDefault();
|
|
61
|
-
const { onChange, formData } = this.props;
|
|
62
|
-
const copiedFormData = { ...formData };
|
|
63
|
-
unset(copiedFormData, key);
|
|
64
|
-
onChange(copiedFormData);
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
68
|
-
* that is already not assigned is found.
|
|
69
|
-
*
|
|
70
|
-
* @param preferredKey - The preferred name of a new key
|
|
71
|
-
* @param [formData] - The form data in which to check if the desired key already exists
|
|
72
|
-
* @returns - The name of the next available key from `preferredKey`
|
|
73
|
-
*/
|
|
74
|
-
this.getAvailableKey = (preferredKey, formData) => {
|
|
75
|
-
const { uiSchema, registry } = this.props;
|
|
76
|
-
const { duplicateKeySuffixSeparator = '-' } = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
77
|
-
let index = 0;
|
|
78
|
-
let newKey = preferredKey;
|
|
79
|
-
while (has(formData, newKey)) {
|
|
80
|
-
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
|
|
81
|
-
}
|
|
82
|
-
return newKey;
|
|
83
|
-
};
|
|
84
|
-
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
85
|
-
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
86
|
-
*
|
|
87
|
-
* @param oldValue - The old value of a field
|
|
88
|
-
* @returns - The key change callback function
|
|
89
|
-
*/
|
|
90
|
-
this.onKeyChange = (oldValue) => {
|
|
91
|
-
return (value, newErrorSchema) => {
|
|
92
|
-
if (oldValue === value) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const { formData, onChange, errorSchema } = this.props;
|
|
96
|
-
value = this.getAvailableKey(value, formData);
|
|
97
|
-
const newFormData = {
|
|
98
|
-
...formData,
|
|
99
|
-
};
|
|
100
|
-
const newKeys = { [oldValue]: value };
|
|
101
|
-
const keyValues = Object.keys(newFormData).map((key) => {
|
|
102
|
-
const newKey = newKeys[key] || key;
|
|
103
|
-
return { [newKey]: newFormData[key] };
|
|
104
|
-
});
|
|
105
|
-
const renamedObj = Object.assign({}, ...keyValues);
|
|
106
|
-
this.setState({ wasPropertyKeyModified: true });
|
|
107
|
-
onChange(renamedObj, errorSchema &&
|
|
108
|
-
errorSchema && {
|
|
109
|
-
...errorSchema,
|
|
110
|
-
[value]: newErrorSchema,
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
115
|
-
* default data for that field has been added to the formData.
|
|
116
|
-
*
|
|
117
|
-
* @param schema - The schema element to which the new property is being added
|
|
118
|
-
*/
|
|
119
|
-
this.handleAddClick = (schema) => () => {
|
|
120
|
-
if (!schema.additionalProperties) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const { formData, onChange, registry } = this.props;
|
|
124
|
-
const newFormData = { ...formData };
|
|
125
|
-
let type = undefined;
|
|
126
|
-
let defaultValue = undefined;
|
|
127
|
-
if (isObject(schema.additionalProperties)) {
|
|
128
|
-
type = schema.additionalProperties.type;
|
|
129
|
-
defaultValue = schema.additionalProperties.default;
|
|
130
|
-
let apSchema = schema.additionalProperties;
|
|
131
|
-
if (REF_KEY in apSchema) {
|
|
132
|
-
const { schemaUtils } = registry;
|
|
133
|
-
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
|
|
134
|
-
type = apSchema.type;
|
|
135
|
-
defaultValue = apSchema.default;
|
|
136
|
-
}
|
|
137
|
-
if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
|
|
138
|
-
type = 'object';
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const newKey = this.getAvailableKey('newKey', newFormData);
|
|
142
|
-
// Cast this to make the `set` work properly
|
|
143
|
-
set(newFormData, newKey, defaultValue !== null && defaultValue !== void 0 ? defaultValue : this.getDefaultValue(type));
|
|
144
|
-
onChange(newFormData);
|
|
145
|
-
};
|
|
146
|
-
}
|
|
16
|
+
/** Set up the initial state */
|
|
17
|
+
state = {
|
|
18
|
+
wasPropertyKeyModified: false,
|
|
19
|
+
additionalProperties: {},
|
|
20
|
+
};
|
|
147
21
|
/** Returns a flag indicating whether the `name` field is required in the object schema
|
|
148
22
|
*
|
|
149
23
|
* @param name - The name of the field to check for required-ness
|
|
@@ -153,6 +27,97 @@ class ObjectField extends Component {
|
|
|
153
27
|
const { schema } = this.props;
|
|
154
28
|
return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
|
|
155
29
|
}
|
|
30
|
+
/** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
|
|
31
|
+
* to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
|
|
32
|
+
* formData.
|
|
33
|
+
*
|
|
34
|
+
* @param name - The name of the property
|
|
35
|
+
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
36
|
+
* @returns - The onPropertyChange callback for the `name` property
|
|
37
|
+
*/
|
|
38
|
+
onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
39
|
+
return (value, newErrorSchema, id) => {
|
|
40
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
41
|
+
if (value === undefined && addedByAdditionalProperties) {
|
|
42
|
+
// Don't set value = undefined for fields added by
|
|
43
|
+
// additionalProperties. Doing so removes them from the
|
|
44
|
+
// formData, which causes them to completely disappear
|
|
45
|
+
// (including the input field for the property name). Unlike
|
|
46
|
+
// fields which are "mandated" by the schema, these fields can
|
|
47
|
+
// be set to undefined by clicking a "delete field" button, so
|
|
48
|
+
// set empty values to the empty string.
|
|
49
|
+
value = '';
|
|
50
|
+
}
|
|
51
|
+
const newFormData = { ...formData, [name]: value };
|
|
52
|
+
onChange(newFormData, errorSchema &&
|
|
53
|
+
errorSchema && {
|
|
54
|
+
...errorSchema,
|
|
55
|
+
[name]: newErrorSchema,
|
|
56
|
+
}, id);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
60
|
+
* and calls the `onChange` callback with it
|
|
61
|
+
*
|
|
62
|
+
* @param key - The key for which the drop callback is desired
|
|
63
|
+
* @returns - The drop property click callback
|
|
64
|
+
*/
|
|
65
|
+
onDropPropertyClick = (key) => {
|
|
66
|
+
return (event) => {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
const { onChange, formData } = this.props;
|
|
69
|
+
const copiedFormData = { ...formData };
|
|
70
|
+
unset(copiedFormData, key);
|
|
71
|
+
onChange(copiedFormData);
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
75
|
+
* that is already not assigned is found.
|
|
76
|
+
*
|
|
77
|
+
* @param preferredKey - The preferred name of a new key
|
|
78
|
+
* @param [formData] - The form data in which to check if the desired key already exists
|
|
79
|
+
* @returns - The name of the next available key from `preferredKey`
|
|
80
|
+
*/
|
|
81
|
+
getAvailableKey = (preferredKey, formData) => {
|
|
82
|
+
const { uiSchema, registry } = this.props;
|
|
83
|
+
const { duplicateKeySuffixSeparator = '-' } = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
84
|
+
let index = 0;
|
|
85
|
+
let newKey = preferredKey;
|
|
86
|
+
while (has(formData, newKey)) {
|
|
87
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
|
|
88
|
+
}
|
|
89
|
+
return newKey;
|
|
90
|
+
};
|
|
91
|
+
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
92
|
+
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
93
|
+
*
|
|
94
|
+
* @param oldValue - The old value of a field
|
|
95
|
+
* @returns - The key change callback function
|
|
96
|
+
*/
|
|
97
|
+
onKeyChange = (oldValue) => {
|
|
98
|
+
return (value, newErrorSchema) => {
|
|
99
|
+
if (oldValue === value) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
103
|
+
value = this.getAvailableKey(value, formData);
|
|
104
|
+
const newFormData = {
|
|
105
|
+
...formData,
|
|
106
|
+
};
|
|
107
|
+
const newKeys = { [oldValue]: value };
|
|
108
|
+
const keyValues = Object.keys(newFormData).map((key) => {
|
|
109
|
+
const newKey = newKeys[key] || key;
|
|
110
|
+
return { [newKey]: newFormData[key] };
|
|
111
|
+
});
|
|
112
|
+
const renamedObj = Object.assign({}, ...keyValues);
|
|
113
|
+
this.setState({ wasPropertyKeyModified: true });
|
|
114
|
+
onChange(renamedObj, errorSchema &&
|
|
115
|
+
errorSchema && {
|
|
116
|
+
...errorSchema,
|
|
117
|
+
[value]: newErrorSchema,
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
};
|
|
156
121
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
157
122
|
*
|
|
158
123
|
* @param type - The type of the new additional schema property
|
|
@@ -176,25 +141,66 @@ class ObjectField extends Component {
|
|
|
176
141
|
return translateString(TranslatableString.NewStringDefault);
|
|
177
142
|
}
|
|
178
143
|
}
|
|
144
|
+
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
145
|
+
* default data for that field has been added to the formData.
|
|
146
|
+
*
|
|
147
|
+
* @param schema - The schema element to which the new property is being added
|
|
148
|
+
*/
|
|
149
|
+
handleAddClick = (schema) => () => {
|
|
150
|
+
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const { formData, onChange, registry } = this.props;
|
|
154
|
+
const newFormData = { ...formData };
|
|
155
|
+
const newKey = this.getAvailableKey('newKey', newFormData);
|
|
156
|
+
if (schema.patternProperties) {
|
|
157
|
+
// Cast this to make the `set` work properly
|
|
158
|
+
set(newFormData, newKey, null);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
let type = undefined;
|
|
162
|
+
let constValue = undefined;
|
|
163
|
+
let defaultValue = undefined;
|
|
164
|
+
if (isObject(schema.additionalProperties)) {
|
|
165
|
+
type = schema.additionalProperties.type;
|
|
166
|
+
constValue = schema.additionalProperties.const;
|
|
167
|
+
defaultValue = schema.additionalProperties.default;
|
|
168
|
+
let apSchema = schema.additionalProperties;
|
|
169
|
+
if (REF_KEY in apSchema) {
|
|
170
|
+
const { schemaUtils } = registry;
|
|
171
|
+
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
|
|
172
|
+
type = apSchema.type;
|
|
173
|
+
constValue = apSchema.const;
|
|
174
|
+
defaultValue = apSchema.default;
|
|
175
|
+
}
|
|
176
|
+
if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
|
|
177
|
+
type = 'object';
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
|
|
181
|
+
// Cast this to make the `set` work properly
|
|
182
|
+
set(newFormData, newKey, newValue);
|
|
183
|
+
}
|
|
184
|
+
onChange(newFormData);
|
|
185
|
+
};
|
|
179
186
|
/** Renders the `ObjectField` from the given props
|
|
180
187
|
*/
|
|
181
188
|
render() {
|
|
182
|
-
var _a, _b, _c, _d;
|
|
183
189
|
const { schema: rawSchema, uiSchema = {}, formData, errorSchema, idSchema, name, required = false, disabled, readonly, hideError, idPrefix, idSeparator, onBlur, onFocus, registry, title, } = this.props;
|
|
184
190
|
const { fields, formContext, schemaUtils, translateString, globalUiOptions } = registry;
|
|
185
191
|
const { SchemaField } = fields;
|
|
186
192
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
187
193
|
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
188
194
|
const { properties: schemaProperties = {} } = schema;
|
|
189
|
-
const templateTitle =
|
|
190
|
-
const description =
|
|
195
|
+
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
196
|
+
const description = uiOptions.description ?? schema.description;
|
|
191
197
|
let orderedProperties;
|
|
192
198
|
try {
|
|
193
199
|
const properties = Object.keys(schemaProperties);
|
|
194
200
|
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
195
201
|
}
|
|
196
202
|
catch (err) {
|
|
197
|
-
return (_jsxs("div", { children: [_jsx("p", { className: 'config-error', style: { color: 'red' }, children: _jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) }), _jsx("pre", { children: JSON.stringify(schema) })] }));
|
|
203
|
+
return (_jsxs("div", { children: [_jsx("p", { className: 'rjsf-config-error', style: { color: 'red' }, children: _jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) }), _jsx("pre", { children: JSON.stringify(schema) })] }));
|
|
198
204
|
}
|
|
199
205
|
const Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
200
206
|
const templateProps = {
|
|
@@ -230,4 +236,3 @@ class ObjectField extends Component {
|
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
238
|
export default ObjectField;
|
|
233
|
-
//# sourceMappingURL=ObjectField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAiB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAKL,UAAU,EAEV,eAAe,EAQf,UAAU,EACV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;AA6TrB;;GAEG;AACH,cAAM,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACpH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CACpB;IACC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9D,MAAM;CAGP;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, Component } from 'react';
|
|
3
3
|
import { ADDITIONAL_PROPERTY_FLAG, deepEquals, descriptionId, getSchemaType, getTemplate, getUiOptions, ID_KEY, mergeObjects, TranslatableString, UI_OPTIONS_KEY, } from '@rjsf/utils';
|
|
4
|
-
import isObject from 'lodash/isObject';
|
|
5
|
-
import omit from 'lodash/omit';
|
|
6
|
-
import Markdown from 'markdown-to-jsx';
|
|
4
|
+
import isObject from 'lodash-es/isObject.js';
|
|
5
|
+
import omit from 'lodash-es/omit.js';
|
|
7
6
|
/** The map of component type to FieldName */
|
|
8
7
|
const COMPONENT_TYPES = {
|
|
9
8
|
array: 'ArrayField',
|
|
@@ -59,7 +58,6 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
59
58
|
* @param props - The `FieldProps` for this component
|
|
60
59
|
*/
|
|
61
60
|
function SchemaFieldRender(props) {
|
|
62
|
-
var _a, _b, _c;
|
|
63
61
|
const { schema: _schema, idSchema: _idSchema, uiSchema, formData, errorSchema, idPrefix, idSeparator, name, onChange, onKeyChange, onDropPropertyClick, required, registry, wasPropertyKeyModified = false, } = props;
|
|
64
62
|
const { formContext, schemaUtils, globalUiOptions } = registry;
|
|
65
63
|
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
@@ -78,12 +76,12 @@ function SchemaFieldRender(props) {
|
|
|
78
76
|
return onChange(formData, newErrorSchema, theId);
|
|
79
77
|
}, [fieldId, onChange]);
|
|
80
78
|
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
81
|
-
const disabled = Boolean(
|
|
82
|
-
const readonly = Boolean(
|
|
79
|
+
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
80
|
+
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
83
81
|
const uiSchemaHideError = uiOptions.hideError;
|
|
84
82
|
// Set hideError to the value provided in the uiSchema, otherwise stick with the prop to propagate to children
|
|
85
83
|
const hideError = uiSchemaHideError === undefined ? props.hideError : Boolean(uiSchemaHideError);
|
|
86
|
-
const autofocus = Boolean(
|
|
84
|
+
const autofocus = Boolean(uiOptions.autofocus ?? props.autofocus);
|
|
87
85
|
if (Object.keys(schema).length === 0) {
|
|
88
86
|
return null;
|
|
89
87
|
}
|
|
@@ -108,18 +106,11 @@ function SchemaFieldRender(props) {
|
|
|
108
106
|
: uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
109
107
|
}
|
|
110
108
|
const description = uiOptions.description || props.schema.description || schema.description || '';
|
|
111
|
-
const richDescription = uiOptions.enableMarkdownInDescription ? (_jsx(Markdown, { options: { disableParsingRawHTML: true }, children: description })) : (description);
|
|
112
109
|
const help = uiOptions.help;
|
|
113
110
|
const hidden = uiOptions.widget === 'hidden';
|
|
114
|
-
const classNames = ['
|
|
111
|
+
const classNames = ['rjsf-field', `rjsf-field-${getSchemaType(schema)}`];
|
|
115
112
|
if (!hideError && __errors && __errors.length > 0) {
|
|
116
|
-
classNames.push('field-error
|
|
117
|
-
}
|
|
118
|
-
if (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.classNames) {
|
|
119
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
120
|
-
console.warn("'uiSchema.classNames' is deprecated and may be removed in a major release; Use 'ui:classNames' instead.");
|
|
121
|
-
}
|
|
122
|
-
classNames.push(uiSchema.classNames);
|
|
113
|
+
classNames.push('rjsf-field-error');
|
|
123
114
|
}
|
|
124
115
|
if (uiOptions.classNames) {
|
|
125
116
|
classNames.push(uiOptions.classNames);
|
|
@@ -131,7 +122,7 @@ function SchemaFieldRender(props) {
|
|
|
131
122
|
*/
|
|
132
123
|
const errorsComponent = hideError || ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema)) ? undefined : (_jsx(FieldErrorTemplate, { errors: __errors, errorSchema: errorSchema, idSchema: idSchema, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
133
124
|
const fieldProps = {
|
|
134
|
-
description: (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description:
|
|
125
|
+
description: (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })),
|
|
135
126
|
rawDescription: description,
|
|
136
127
|
help: helpComponent,
|
|
137
128
|
rawHelp: typeof help === 'string' ? help : undefined,
|
|
@@ -158,8 +149,8 @@ function SchemaFieldRender(props) {
|
|
|
158
149
|
};
|
|
159
150
|
const _AnyOfField = registry.fields.AnyOfField;
|
|
160
151
|
const _OneOfField = registry.fields.OneOfField;
|
|
161
|
-
const isReplacingAnyOrOneOf =
|
|
162
|
-
return (_jsx(FieldTemplate, { ...fieldProps, children: _jsxs(_Fragment, { children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_AnyOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, idPrefix: idPrefix, idSchema: idSchema, idSeparator: idSeparator, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.anyOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, schema: schema, uiSchema: uiSchema })), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_OneOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, idPrefix: idPrefix, idSchema: idSchema, idSeparator: idSeparator, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.oneOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, schema: schema, uiSchema: uiSchema }))] }) }));
|
|
152
|
+
const isReplacingAnyOrOneOf = uiSchema?.['ui:field'] && uiSchema?.['ui:fieldReplacesAnyOrOneOf'] === true;
|
|
153
|
+
return (_jsx(FieldTemplate, { ...fieldProps, children: _jsxs(_Fragment, { children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_AnyOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, idPrefix: idPrefix, idSchema: idSchema, idSeparator: idSeparator, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.anyOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, required: required, schema: schema, uiSchema: uiSchema })), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_OneOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, idPrefix: idPrefix, idSchema: idSchema, idSeparator: idSeparator, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.oneOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, required: required, schema: schema, uiSchema: uiSchema }))] }) }));
|
|
163
154
|
}
|
|
164
155
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
165
156
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
@@ -173,4 +164,3 @@ class SchemaField extends Component {
|
|
|
173
164
|
}
|
|
174
165
|
}
|
|
175
166
|
export default SchemaField;
|
|
176
|
-
//# sourceMappingURL=SchemaField.js.map
|
|
@@ -5,3 +5,4 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
5
5
|
*/
|
|
6
6
|
declare function StringField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default StringField;
|
|
8
|
+
//# sourceMappingURL=StringField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,iBAAS,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsD3B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -5,7 +5,6 @@ import { getWidget, getUiOptions, optionsList, hasWidget, } from '@rjsf/utils';
|
|
|
5
5
|
* @param props - The `FieldProps` for this template
|
|
6
6
|
*/
|
|
7
7
|
function StringField(props) {
|
|
8
|
-
var _a;
|
|
9
8
|
const { schema, name, uiSchema, idSchema, formData, required, disabled = false, readonly = false, autofocus = false, onChange, onBlur, onFocus, registry, rawErrors, hideError, } = props;
|
|
10
9
|
const { title, format } = schema;
|
|
11
10
|
const { widgets, formContext, schemaUtils, globalUiOptions } = registry;
|
|
@@ -16,9 +15,8 @@ function StringField(props) {
|
|
|
16
15
|
}
|
|
17
16
|
const { widget = defaultWidget, placeholder = '', title: uiTitle, ...options } = getUiOptions(uiSchema);
|
|
18
17
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
19
|
-
const label =
|
|
18
|
+
const label = uiTitle ?? title ?? name;
|
|
20
19
|
const Widget = getWidget(schema, widget, widgets);
|
|
21
20
|
return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: idSchema.$id, name: name, label: label, hideLabel: !displayLabel, hideError: hideError, value: formData, onChange: onChange, onBlur: onBlur, onFocus: onFocus, required: required, disabled: disabled, readonly: readonly, formContext: formContext, autofocus: autofocus, registry: registry, placeholder: placeholder, rawErrors: rawErrors }));
|
|
22
21
|
}
|
|
23
22
|
export default StringField;
|
|
24
|
-
//# sourceMappingURL=StringField.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { FormContextType, RegistryFieldsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
declare function fields<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(): RegistryFieldsType<T, S, F>;
|
|
3
3
|
export default fields;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAcvG,iBAAS,MAAM,CACb,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAgB/B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import ArrayField from './ArrayField';
|
|
2
|
-
import BooleanField from './BooleanField';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import ArrayField from './ArrayField.js';
|
|
2
|
+
import BooleanField from './BooleanField.js';
|
|
3
|
+
import LayoutGridField from './LayoutGridField.js';
|
|
4
|
+
import LayoutHeaderField from './LayoutHeaderField.js';
|
|
5
|
+
import LayoutMultiSchemaField from './LayoutMultiSchemaField.js';
|
|
6
|
+
import MultiSchemaField from './MultiSchemaField.js';
|
|
7
|
+
import NumberField from './NumberField.js';
|
|
8
|
+
import ObjectField from './ObjectField.js';
|
|
9
|
+
import SchemaField from './SchemaField.js';
|
|
10
|
+
import StringField from './StringField.js';
|
|
11
|
+
import NullField from './NullField.js';
|
|
9
12
|
function fields() {
|
|
10
13
|
return {
|
|
11
14
|
AnyOfField: MultiSchemaField,
|
|
12
15
|
ArrayField: ArrayField,
|
|
13
16
|
// ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
|
|
14
17
|
BooleanField,
|
|
18
|
+
LayoutGridField,
|
|
19
|
+
LayoutHeaderField,
|
|
20
|
+
LayoutMultiSchemaField,
|
|
15
21
|
NumberField,
|
|
16
22
|
ObjectField,
|
|
17
23
|
OneOfField: MultiSchemaField,
|
|
@@ -21,4 +27,3 @@ function fields() {
|
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
29
|
export default fields;
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -5,3 +5,4 @@ import { ArrayFieldDescriptionProps, FormContextType, RJSFSchema, StrictRJSFSche
|
|
|
5
5
|
* @param props - The `ArrayFieldDescriptionProps` for the component
|
|
6
6
|
*/
|
|
7
7
|
export default function ArrayFieldDescriptionTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldDescriptionProps<T, S, F>): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=ArrayFieldDescriptionTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayFieldDescriptionTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldDescriptionTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,0BAA0B,EAC1B,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,6BAA6B,CACnD,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,0BAA0B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDAqB3C"}
|
|
@@ -15,4 +15,3 @@ export default function ArrayFieldDescriptionTemplate(props) {
|
|
|
15
15
|
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
16
16
|
return (_jsx(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=ArrayFieldDescriptionTemplate.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ArrayFieldItemButtonsTemplateType, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
/** The `ArrayFieldTemplateItemButtons` component is the template used to render the buttons associate3d with items of
|
|
3
|
+
* an array.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `ArrayFieldItemButtonsTemplateType` props for the component
|
|
6
|
+
*/
|
|
7
|
+
export default function ArrayFieldItemButtonsTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldItemButtonsTemplateType<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ArrayFieldItemButtonsTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayFieldItemButtonsTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldItemButtonsTemplate.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EAEjC,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,6BAA6B,CACnD,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,iCAAiC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkElD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { buttonId, } from '@rjsf/utils';
|
|
4
|
+
/** The `ArrayFieldTemplateItemButtons` component is the template used to render the buttons associate3d with items of
|
|
5
|
+
* an array.
|
|
6
|
+
*
|
|
7
|
+
* @param props - The `ArrayFieldItemButtonsTemplateType` props for the component
|
|
8
|
+
*/
|
|
9
|
+
export default function ArrayFieldItemButtonsTemplate(props) {
|
|
10
|
+
const { disabled, hasCopy, hasMoveDown, hasMoveUp, hasRemove, idSchema, index, onCopyIndexClick, onDropIndexClick, onReorderClick, readonly, registry, uiSchema, } = props;
|
|
11
|
+
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
|
|
12
|
+
const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
|
|
13
|
+
const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
14
|
+
const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
15
|
+
const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
16
|
+
return (_jsxs(_Fragment, { children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { id: buttonId(idSchema, 'moveUp'), className: 'rjsf-array-item-move-up', disabled: disabled || readonly || !hasMoveUp, onClick: onArrowUpClick, uiSchema: uiSchema, registry: registry })), (hasMoveUp || hasMoveDown) && (_jsx(MoveDownButton, { id: buttonId(idSchema, 'moveDown'), className: 'rjsf-array-item-move-down', disabled: disabled || readonly || !hasMoveDown, onClick: onArrowDownClick, uiSchema: uiSchema, registry: registry })), hasCopy && (_jsx(CopyButton, { id: buttonId(idSchema, 'copy'), className: 'rjsf-array-item-copy', disabled: disabled || readonly, onClick: onCopyClick, uiSchema: uiSchema, registry: registry })), hasRemove && (_jsx(RemoveButton, { id: buttonId(idSchema, 'remove'), className: 'rjsf-array-item-remove', disabled: disabled || readonly, onClick: onRemoveClick, uiSchema: uiSchema, registry: registry }))] }));
|
|
17
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArrayFieldItemTemplateType, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
3
3
|
*
|
|
4
|
-
* @param props - The `
|
|
4
|
+
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
5
5
|
*/
|
|
6
|
-
export default function ArrayFieldItemTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props:
|
|
6
|
+
export default function ArrayFieldItemTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldItemTemplateType<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=ArrayFieldItemTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayFieldItemTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldItemTemplate.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,eAAe,EAGf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,0BAA0B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAgC3C"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getTemplate, getUiOptions, } from '@rjsf/utils';
|
|
2
3
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
3
4
|
*
|
|
4
|
-
* @param props - The `
|
|
5
|
+
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
5
6
|
*/
|
|
6
7
|
export default function ArrayFieldItemTemplate(props) {
|
|
7
|
-
const { children, className,
|
|
8
|
-
const
|
|
8
|
+
const { children, className, buttonsProps, hasToolbar, registry, uiSchema } = props;
|
|
9
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
10
|
+
const ArrayFieldItemButtonsTemplate = getTemplate('ArrayFieldItemButtonsTemplate', registry, uiOptions);
|
|
9
11
|
const btnStyle = {
|
|
10
12
|
flex: 1,
|
|
11
13
|
paddingLeft: 6,
|
|
12
14
|
paddingRight: 6,
|
|
13
15
|
fontWeight: 'bold',
|
|
14
16
|
};
|
|
15
|
-
return (_jsxs("div", { className: className, children: [_jsx("div", { className: hasToolbar ? 'col-xs-9' : 'col-xs-12', children: children }), hasToolbar && (_jsx("div", { className: 'col-xs-3 array-item-toolbox', children:
|
|
17
|
+
return (_jsxs("div", { className: className, children: [_jsx("div", { className: hasToolbar ? 'col-xs-9' : 'col-xs-12', children: children }), hasToolbar && (_jsx("div", { className: 'col-xs-3 array-item-toolbox', children: _jsx("div", { className: 'btn-group', style: {
|
|
16
18
|
display: 'flex',
|
|
17
19
|
justifyContent: 'space-around',
|
|
18
|
-
}, children:
|
|
20
|
+
}, children: _jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps, style: btnStyle }) }) }))] }));
|
|
19
21
|
}
|
|
20
|
-
//# sourceMappingURL=ArrayFieldItemTemplate.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
3
3
|
*
|
|
4
|
-
* @param props - The `
|
|
4
|
+
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
5
5
|
*/
|
|
6
6
|
export default function ArrayFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=ArrayFieldTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EAEvB,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsExC"}
|