@rjsf/core 5.11.2 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.umd.js +3464 -0
- package/dist/index.esm.js +3814 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +3714 -5
- package/dist/index.js.map +7 -0
- package/{dist/index.d.ts → lib/components/Form.d.ts} +321 -337
- package/lib/components/Form.js +474 -0
- package/lib/components/Form.js.map +1 -0
- package/lib/components/fields/ArrayField.d.ts +179 -0
- package/lib/components/fields/ArrayField.js +568 -0
- package/lib/components/fields/ArrayField.js.map +1 -0
- package/lib/components/fields/BooleanField.d.ts +9 -0
- package/lib/components/fields/BooleanField.js +62 -0
- package/lib/components/fields/BooleanField.js.map +1 -0
- package/lib/components/fields/MultiSchemaField.d.ts +47 -0
- package/lib/components/fields/MultiSchemaField.js +129 -0
- package/lib/components/fields/MultiSchemaField.js.map +1 -0
- package/lib/components/fields/NullField.d.ts +8 -0
- package/lib/components/fields/NullField.js +17 -0
- package/lib/components/fields/NullField.js.map +1 -0
- package/lib/components/fields/NumberField.d.ts +21 -0
- package/lib/components/fields/NumberField.js +70 -0
- package/lib/components/fields/NumberField.js.map +1 -0
- package/lib/components/fields/ObjectField.d.ts +73 -0
- package/lib/components/fields/ObjectField.js +222 -0
- package/lib/components/fields/ObjectField.js.map +1 -0
- package/lib/components/fields/SchemaField.d.ts +10 -0
- package/lib/components/fields/SchemaField.js +172 -0
- package/lib/components/fields/SchemaField.js.map +1 -0
- package/lib/components/fields/StringField.d.ts +8 -0
- package/lib/components/fields/StringField.js +25 -0
- package/lib/components/fields/StringField.js.map +1 -0
- package/lib/components/fields/index.d.ts +3 -0
- package/lib/components/fields/index.js +24 -0
- package/lib/components/fields/index.js.map +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +8 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +18 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +7 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js +20 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldTemplate.d.ts +7 -0
- package/lib/components/templates/ArrayFieldTemplate.js +22 -0
- package/lib/components/templates/ArrayFieldTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +8 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js +18 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js.map +1 -0
- package/lib/components/templates/BaseInputTemplate.d.ts +9 -0
- package/lib/components/templates/BaseInputTemplate.js +39 -0
- package/lib/components/templates/BaseInputTemplate.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +5 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js +10 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +7 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js +24 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +5 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +12 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/index.d.ts +3 -0
- package/lib/components/templates/ButtonTemplates/index.js +15 -0
- package/lib/components/templates/ButtonTemplates/index.js.map +1 -0
- package/lib/components/templates/DescriptionField.d.ts +7 -0
- package/lib/components/templates/DescriptionField.js +18 -0
- package/lib/components/templates/DescriptionField.js.map +1 -0
- package/lib/components/templates/ErrorList.d.ts +7 -0
- package/lib/components/templates/ErrorList.js +13 -0
- package/lib/components/templates/ErrorList.js.map +1 -0
- package/lib/components/templates/FieldErrorTemplate.d.ts +7 -0
- package/lib/components/templates/FieldErrorTemplate.js +19 -0
- package/lib/components/templates/FieldErrorTemplate.js.map +1 -0
- package/lib/components/templates/FieldHelpTemplate.d.ts +7 -0
- package/lib/components/templates/FieldHelpTemplate.js +18 -0
- package/lib/components/templates/FieldHelpTemplate.js.map +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +8 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +18 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/components/templates/FieldTemplate/Label.d.ts +14 -0
- package/lib/components/templates/FieldTemplate/Label.js +14 -0
- package/lib/components/templates/FieldTemplate/Label.js.map +1 -0
- package/lib/components/templates/FieldTemplate/index.d.ts +2 -0
- package/lib/components/templates/FieldTemplate/index.js +3 -0
- package/lib/components/templates/FieldTemplate/index.js.map +1 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +9 -0
- package/lib/components/templates/ObjectFieldTemplate.js +18 -0
- package/lib/components/templates/ObjectFieldTemplate.js.map +1 -0
- package/lib/components/templates/TitleField.d.ts +7 -0
- package/lib/components/templates/TitleField.js +11 -0
- package/lib/components/templates/TitleField.js.map +1 -0
- package/lib/components/templates/UnsupportedField.d.ts +9 -0
- package/lib/components/templates/UnsupportedField.js +28 -0
- package/lib/components/templates/UnsupportedField.js.map +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +8 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js +21 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/components/templates/index.d.ts +3 -0
- package/lib/components/templates/index.js +36 -0
- package/lib/components/templates/index.js.map +1 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts +9 -0
- package/lib/components/widgets/AltDateTimeWidget.js +14 -0
- package/lib/components/widgets/AltDateTimeWidget.js.map +1 -0
- package/lib/components/widgets/AltDateWidget.d.ts +7 -0
- package/lib/components/widgets/AltDateWidget.js +77 -0
- package/lib/components/widgets/AltDateWidget.js.map +1 -0
- package/lib/components/widgets/CheckboxWidget.d.ts +9 -0
- package/lib/components/widgets/CheckboxWidget.js +23 -0
- package/lib/components/widgets/CheckboxWidget.js.map +1 -0
- package/lib/components/widgets/CheckboxesWidget.d.ts +9 -0
- package/lib/components/widgets/CheckboxesWidget.js +31 -0
- package/lib/components/widgets/CheckboxesWidget.js.map +1 -0
- package/lib/components/widgets/ColorWidget.d.ts +8 -0
- package/lib/components/widgets/ColorWidget.js +13 -0
- package/lib/components/widgets/ColorWidget.js.map +1 -0
- package/lib/components/widgets/DateTimeWidget.d.ts +8 -0
- package/lib/components/widgets/DateTimeWidget.js +13 -0
- package/lib/components/widgets/DateTimeWidget.js.map +1 -0
- package/lib/components/widgets/DateWidget.d.ts +8 -0
- package/lib/components/widgets/DateWidget.js +15 -0
- package/lib/components/widgets/DateWidget.js.map +1 -0
- package/lib/components/widgets/EmailWidget.d.ts +7 -0
- package/lib/components/widgets/EmailWidget.js +12 -0
- package/lib/components/widgets/EmailWidget.js.map +1 -0
- package/lib/components/widgets/FileWidget.d.ts +8 -0
- package/lib/components/widgets/FileWidget.js +105 -0
- package/lib/components/widgets/FileWidget.js.map +1 -0
- package/lib/components/widgets/HiddenWidget.d.ts +9 -0
- package/lib/components/widgets/HiddenWidget.js +11 -0
- package/lib/components/widgets/HiddenWidget.js.map +1 -0
- package/lib/components/widgets/PasswordWidget.d.ts +7 -0
- package/lib/components/widgets/PasswordWidget.js +12 -0
- package/lib/components/widgets/PasswordWidget.js.map +1 -0
- package/lib/components/widgets/RadioWidget.d.ts +9 -0
- package/lib/components/widgets/RadioWidget.js +24 -0
- package/lib/components/widgets/RadioWidget.js.map +1 -0
- package/lib/components/widgets/RangeWidget.d.ts +8 -0
- package/lib/components/widgets/RangeWidget.js +11 -0
- package/lib/components/widgets/RangeWidget.js.map +1 -0
- package/lib/components/widgets/SelectWidget.d.ts +9 -0
- package/lib/components/widgets/SelectWidget.js +41 -0
- package/lib/components/widgets/SelectWidget.js.map +1 -0
- package/lib/components/widgets/TextWidget.d.ts +7 -0
- package/lib/components/widgets/TextWidget.js +12 -0
- package/lib/components/widgets/TextWidget.js.map +1 -0
- package/lib/components/widgets/TextareaWidget.d.ts +14 -0
- package/lib/components/widgets/TextareaWidget.js +19 -0
- package/lib/components/widgets/TextareaWidget.js.map +1 -0
- package/lib/components/widgets/TimeWidget.d.ts +8 -0
- package/lib/components/widgets/TimeWidget.js +15 -0
- package/lib/components/widgets/TimeWidget.js.map +1 -0
- package/lib/components/widgets/URLWidget.d.ts +7 -0
- package/lib/components/widgets/URLWidget.js +12 -0
- package/lib/components/widgets/URLWidget.js.map +1 -0
- package/lib/components/widgets/UpDownWidget.d.ts +7 -0
- package/lib/components/widgets/UpDownWidget.js +12 -0
- package/lib/components/widgets/UpDownWidget.js.map +1 -0
- package/lib/components/widgets/index.d.ts +3 -0
- package/lib/components/widgets/index.js +44 -0
- package/lib/components/widgets/index.js.map +1 -0
- package/lib/getDefaultRegistry.d.ts +6 -0
- package/lib/getDefaultRegistry.js +19 -0
- package/lib/getDefaultRegistry.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/withTheme.d.ts +9 -0
- package/lib/withTheme.js +16 -0
- package/lib/withTheme.js.map +1 -0
- package/package.json +23 -16
- package/src/components/Form.tsx +853 -0
- package/src/components/fields/ArrayField.tsx +875 -0
- package/src/components/fields/BooleanField.tsx +114 -0
- package/src/components/fields/MultiSchemaField.tsx +221 -0
- package/src/components/fields/NullField.tsx +22 -0
- package/src/components/fields/NumberField.tsx +86 -0
- package/src/components/fields/ObjectField.tsx +331 -0
- package/src/components/fields/SchemaField.tsx +360 -0
- package/src/components/fields/StringField.tsx +71 -0
- package/src/components/fields/index.ts +31 -0
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +41 -0
- package/src/components/templates/ArrayFieldItemTemplate.tsx +90 -0
- package/src/components/templates/ArrayFieldTemplate.tsx +88 -0
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +43 -0
- package/src/components/templates/BaseInputTemplate.tsx +102 -0
- package/src/components/templates/ButtonTemplates/AddButton.tsx +29 -0
- package/src/components/templates/ButtonTemplates/IconButton.tsx +77 -0
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +21 -0
- package/src/components/templates/ButtonTemplates/index.ts +22 -0
- package/src/components/templates/DescriptionField.tsx +29 -0
- package/src/components/templates/ErrorList.tsx +35 -0
- package/src/components/templates/FieldErrorTemplate.tsx +33 -0
- package/src/components/templates/FieldHelpTemplate.tsx +29 -0
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +41 -0
- package/src/components/templates/FieldTemplate/Label.tsx +27 -0
- package/src/components/templates/FieldTemplate/index.ts +3 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +83 -0
- package/src/components/templates/TitleField.tsx +19 -0
- package/src/components/templates/UnsupportedField.tsx +37 -0
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +80 -0
- package/src/components/templates/index.ts +43 -0
- package/src/components/widgets/AltDateTimeWidget.tsx +16 -0
- package/src/components/widgets/AltDateWidget.tsx +198 -0
- package/src/components/widgets/CheckboxWidget.tsx +92 -0
- package/src/components/widgets/CheckboxesWidget.tsx +92 -0
- package/src/components/widgets/ColorWidget.tsx +14 -0
- package/src/components/widgets/DateTimeWidget.tsx +31 -0
- package/src/components/widgets/DateWidget.tsx +17 -0
- package/src/components/widgets/EmailWidget.tsx +13 -0
- package/src/components/widgets/FileWidget.tsx +178 -0
- package/src/components/widgets/HiddenWidget.tsx +15 -0
- package/src/components/widgets/PasswordWidget.tsx +15 -0
- package/src/components/widgets/RadioWidget.tsx +88 -0
- package/src/components/widgets/RangeWidget.tsx +23 -0
- package/src/components/widgets/SelectWidget.tsx +100 -0
- package/src/components/widgets/TextWidget.tsx +13 -0
- package/src/components/widgets/TextareaWidget.tsx +61 -0
- package/src/components/widgets/TimeWidget.tsx +17 -0
- package/src/components/widgets/URLWidget.tsx +13 -0
- package/src/components/widgets/UpDownWidget.tsx +13 -0
- package/src/components/widgets/index.ts +51 -0
- package/src/getDefaultRegistry.ts +24 -0
- package/src/index.ts +8 -0
- package/src/withTheme.tsx +42 -0
- package/dist/core.cjs.development.js +0 -4403
- package/dist/core.cjs.development.js.map +0 -1
- package/dist/core.cjs.production.min.js +0 -2
- package/dist/core.cjs.production.min.js.map +0 -1
- package/dist/core.esm.js +0 -4383
- package/dist/core.esm.js.map +0 -1
- package/dist/core.umd.development.js +0 -4393
- package/dist/core.umd.development.js.map +0 -1
- package/dist/core.umd.production.min.js +0 -2
- package/dist/core.umd.production.min.js.map +0 -1
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
import { getTemplate, getUiOptions, orderProperties, TranslatableString, ADDITIONAL_PROPERTY_FLAG, PROPERTIES_KEY, REF_KEY, ANY_OF_KEY, ONE_OF_KEY, } from '@rjsf/utils';
|
|
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';
|
|
10
|
+
/** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
|
|
11
|
+
* additional property key was modified and what it was modified to
|
|
12
|
+
*
|
|
13
|
+
* @param props - The `FieldProps` for this template
|
|
14
|
+
*/
|
|
15
|
+
class ObjectField extends Component {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
/** Set up the initial state */
|
|
19
|
+
this.state = {
|
|
20
|
+
wasPropertyKeyModified: false,
|
|
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 = Object.assign(Object.assign({}, formData), { [name]: value });
|
|
45
|
+
onChange(newFormData, errorSchema &&
|
|
46
|
+
errorSchema && Object.assign(Object.assign({}, errorSchema), { [name]: newErrorSchema }), id);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
50
|
+
* and calls the `onChange` callback with it
|
|
51
|
+
*
|
|
52
|
+
* @param key - The key for which the drop callback is desired
|
|
53
|
+
* @returns - The drop property click callback
|
|
54
|
+
*/
|
|
55
|
+
this.onDropPropertyClick = (key) => {
|
|
56
|
+
return (event) => {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
const { onChange, formData } = this.props;
|
|
59
|
+
const copiedFormData = Object.assign({}, formData);
|
|
60
|
+
unset(copiedFormData, key);
|
|
61
|
+
onChange(copiedFormData);
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
65
|
+
* that is already not assigned is found.
|
|
66
|
+
*
|
|
67
|
+
* @param preferredKey - The preferred name of a new key
|
|
68
|
+
* @param [formData] - The form data in which to check if the desired key already exists
|
|
69
|
+
* @returns - The name of the next available key from `preferredKey`
|
|
70
|
+
*/
|
|
71
|
+
this.getAvailableKey = (preferredKey, formData) => {
|
|
72
|
+
const { uiSchema, registry } = this.props;
|
|
73
|
+
const { duplicateKeySuffixSeparator = '-' } = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
74
|
+
let index = 0;
|
|
75
|
+
let newKey = preferredKey;
|
|
76
|
+
while (has(formData, newKey)) {
|
|
77
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
|
|
78
|
+
}
|
|
79
|
+
return newKey;
|
|
80
|
+
};
|
|
81
|
+
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
82
|
+
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
83
|
+
*
|
|
84
|
+
* @param oldValue - The old value of a field
|
|
85
|
+
* @returns - The key change callback function
|
|
86
|
+
*/
|
|
87
|
+
this.onKeyChange = (oldValue) => {
|
|
88
|
+
return (value, newErrorSchema) => {
|
|
89
|
+
if (oldValue === value) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
93
|
+
value = this.getAvailableKey(value, formData);
|
|
94
|
+
const newFormData = Object.assign({}, formData);
|
|
95
|
+
const newKeys = { [oldValue]: value };
|
|
96
|
+
const keyValues = Object.keys(newFormData).map((key) => {
|
|
97
|
+
const newKey = newKeys[key] || key;
|
|
98
|
+
return { [newKey]: newFormData[key] };
|
|
99
|
+
});
|
|
100
|
+
const renamedObj = Object.assign({}, ...keyValues);
|
|
101
|
+
this.setState({ wasPropertyKeyModified: true });
|
|
102
|
+
onChange(renamedObj, errorSchema &&
|
|
103
|
+
errorSchema && Object.assign(Object.assign({}, errorSchema), { [value]: newErrorSchema }));
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
107
|
+
* default data for that field has been added to the formData.
|
|
108
|
+
*
|
|
109
|
+
* @param schema - The schema element to which the new property is being added
|
|
110
|
+
*/
|
|
111
|
+
this.handleAddClick = (schema) => () => {
|
|
112
|
+
if (!schema.additionalProperties) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const { formData, onChange, registry } = this.props;
|
|
116
|
+
const newFormData = Object.assign({}, formData);
|
|
117
|
+
let type = undefined;
|
|
118
|
+
if (isObject(schema.additionalProperties)) {
|
|
119
|
+
type = schema.additionalProperties.type;
|
|
120
|
+
let apSchema = schema.additionalProperties;
|
|
121
|
+
if (REF_KEY in apSchema) {
|
|
122
|
+
const { schemaUtils } = registry;
|
|
123
|
+
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
|
|
124
|
+
type = apSchema.type;
|
|
125
|
+
}
|
|
126
|
+
if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
|
|
127
|
+
type = 'object';
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const newKey = this.getAvailableKey('newKey', newFormData);
|
|
131
|
+
// Cast this to make the `set` work properly
|
|
132
|
+
set(newFormData, newKey, this.getDefaultValue(type));
|
|
133
|
+
onChange(newFormData);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** Returns a flag indicating whether the `name` field is required in the object schema
|
|
137
|
+
*
|
|
138
|
+
* @param name - The name of the field to check for required-ness
|
|
139
|
+
* @returns - True if the field `name` is required, false otherwise
|
|
140
|
+
*/
|
|
141
|
+
isRequired(name) {
|
|
142
|
+
const { schema } = this.props;
|
|
143
|
+
return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
|
|
144
|
+
}
|
|
145
|
+
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
146
|
+
*
|
|
147
|
+
* @param type - The type of the new additional schema property
|
|
148
|
+
*/
|
|
149
|
+
getDefaultValue(type) {
|
|
150
|
+
const { registry: { translateString }, } = this.props;
|
|
151
|
+
switch (type) {
|
|
152
|
+
case 'array':
|
|
153
|
+
return [];
|
|
154
|
+
case 'boolean':
|
|
155
|
+
return false;
|
|
156
|
+
case 'null':
|
|
157
|
+
return null;
|
|
158
|
+
case 'number':
|
|
159
|
+
return 0;
|
|
160
|
+
case 'object':
|
|
161
|
+
return {};
|
|
162
|
+
case 'string':
|
|
163
|
+
default:
|
|
164
|
+
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
165
|
+
return translateString(TranslatableString.NewStringDefault);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** Renders the `ObjectField` from the given props
|
|
169
|
+
*/
|
|
170
|
+
render() {
|
|
171
|
+
var _a, _b, _c;
|
|
172
|
+
const { schema: rawSchema, uiSchema = {}, formData, errorSchema, idSchema, name, required = false, disabled = false, readonly = false, hideError, idPrefix, idSeparator, onBlur, onFocus, registry, } = this.props;
|
|
173
|
+
const { fields, formContext, schemaUtils, translateString, globalUiOptions } = registry;
|
|
174
|
+
const { SchemaField } = fields;
|
|
175
|
+
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
176
|
+
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
177
|
+
const { properties: schemaProperties = {} } = schema;
|
|
178
|
+
const title = (_b = (_a = uiOptions.title) !== null && _a !== void 0 ? _a : schema.title) !== null && _b !== void 0 ? _b : name;
|
|
179
|
+
const description = (_c = uiOptions.description) !== null && _c !== void 0 ? _c : schema.description;
|
|
180
|
+
let orderedProperties;
|
|
181
|
+
try {
|
|
182
|
+
const properties = Object.keys(schemaProperties);
|
|
183
|
+
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
return (_jsxs("div", { children: [_jsx("p", Object.assign({ className: 'config-error', style: { color: 'red' } }, { children: _jsx(Markdown, { children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) })), _jsx("pre", { children: JSON.stringify(schema) })] }));
|
|
187
|
+
}
|
|
188
|
+
const Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
|
|
189
|
+
const templateProps = {
|
|
190
|
+
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
191
|
+
title: uiOptions.label === false ? '' : title,
|
|
192
|
+
description: uiOptions.label === false ? undefined : description,
|
|
193
|
+
properties: orderedProperties.map((name) => {
|
|
194
|
+
const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
|
|
195
|
+
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
196
|
+
const hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
197
|
+
const fieldIdSchema = get(idSchema, [name], {});
|
|
198
|
+
return {
|
|
199
|
+
content: (_jsx(SchemaField, { name: name, required: this.isRequired(name), schema: get(schema, [PROPERTIES_KEY, name], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, name), idSchema: fieldIdSchema, idPrefix: idPrefix, idSeparator: idSeparator, formData: get(formData, name), formContext: formContext, wasPropertyKeyModified: this.state.wasPropertyKeyModified, onKeyChange: this.onKeyChange(name), onChange: this.onPropertyChange(name, addedByAdditionalProperties), onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError, onDropPropertyClick: this.onDropPropertyClick }, name)),
|
|
200
|
+
name,
|
|
201
|
+
readonly,
|
|
202
|
+
disabled,
|
|
203
|
+
required,
|
|
204
|
+
hidden,
|
|
205
|
+
};
|
|
206
|
+
}),
|
|
207
|
+
readonly,
|
|
208
|
+
disabled,
|
|
209
|
+
required,
|
|
210
|
+
idSchema,
|
|
211
|
+
uiSchema,
|
|
212
|
+
errorSchema,
|
|
213
|
+
schema,
|
|
214
|
+
formData,
|
|
215
|
+
formContext,
|
|
216
|
+
registry,
|
|
217
|
+
};
|
|
218
|
+
return _jsx(Template, Object.assign({}, templateProps, { onAddClick: this.handleAddClick }));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
export default ObjectField;
|
|
222
|
+
//# sourceMappingURL=ObjectField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectField.js","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EAQf,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,OAAO,EACP,UAAU,EACV,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,KAAK,MAAM,cAAc,CAAC;AAUjC;;;;GAIG;AACH,MAAM,WAA+F,SAAQ,SAG5G;IAHD;;QAIE,+BAA+B;QAC/B,UAAK,GAAG;YACN,sBAAsB,EAAE,KAAK;YAC7B,oBAAoB,EAAE,EAAE;SACzB,CAAC;QAYF;;;;;;;WAOG;QACH,qBAAgB,GAAG,CAAC,IAAY,EAAE,2BAA2B,GAAG,KAAK,EAAE,EAAE;YACvE,OAAO,CAAC,KAAoB,EAAE,cAA+B,EAAE,EAAW,EAAE,EAAE;gBAC5E,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;gBACvD,IAAI,KAAK,KAAK,SAAS,IAAI,2BAA2B,EAAE;oBACtD,kDAAkD;oBAClD,uDAAuD;oBACvD,sDAAsD;oBACtD,4DAA4D;oBAC5D,8DAA8D;oBAC9D,8DAA8D;oBAC9D,wCAAwC;oBACxC,KAAK,GA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AI,CAAC,cAAc,IAAI,CAAC;IAC1E,CAAC;CACF;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
4
|
+
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
5
|
+
*/
|
|
6
|
+
declare class SchemaField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FieldProps<T, S, F>> {
|
|
7
|
+
shouldComponentUpdate(nextProps: Readonly<FieldProps<T, S, F>>): boolean;
|
|
8
|
+
render(): JSX.Element;
|
|
9
|
+
}
|
|
10
|
+
export default SchemaField;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, Component } from 'react';
|
|
4
|
+
import { ADDITIONAL_PROPERTY_FLAG, deepEquals, descriptionId, getSchemaType, getTemplate, getUiOptions, ID_KEY, mergeObjects, TranslatableString, UI_OPTIONS_KEY, } from '@rjsf/utils';
|
|
5
|
+
import isObject from 'lodash/isObject';
|
|
6
|
+
import omit from 'lodash/omit';
|
|
7
|
+
import Markdown from 'markdown-to-jsx';
|
|
8
|
+
/** The map of component type to FieldName */
|
|
9
|
+
const COMPONENT_TYPES = {
|
|
10
|
+
array: 'ArrayField',
|
|
11
|
+
boolean: 'BooleanField',
|
|
12
|
+
integer: 'NumberField',
|
|
13
|
+
number: 'NumberField',
|
|
14
|
+
object: 'ObjectField',
|
|
15
|
+
string: 'StringField',
|
|
16
|
+
null: 'NullField',
|
|
17
|
+
};
|
|
18
|
+
/** Computes and returns which `Field` implementation to return in order to render the field represented by the
|
|
19
|
+
* `schema`. The `uiOptions` are used to alter what potential `Field` implementation is actually returned. If no
|
|
20
|
+
* appropriate `Field` implementation can be found then a wrapper around `UnsupportedFieldTemplate` is used.
|
|
21
|
+
*
|
|
22
|
+
* @param schema - The schema from which to obtain the type
|
|
23
|
+
* @param uiOptions - The UI Options that may affect the component decision
|
|
24
|
+
* @param idSchema - The id that is passed to the `UnsupportedFieldTemplate`
|
|
25
|
+
* @param registry - The registry from which fields and templates are obtained
|
|
26
|
+
* @returns - The `Field` component that is used to render the actual field data
|
|
27
|
+
*/
|
|
28
|
+
function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
29
|
+
const field = uiOptions.field;
|
|
30
|
+
const { fields, translateString } = registry;
|
|
31
|
+
if (typeof field === 'function') {
|
|
32
|
+
return field;
|
|
33
|
+
}
|
|
34
|
+
if (typeof field === 'string' && field in fields) {
|
|
35
|
+
return fields[field];
|
|
36
|
+
}
|
|
37
|
+
const schemaType = getSchemaType(schema);
|
|
38
|
+
const type = Array.isArray(schemaType) ? schemaType[0] : schemaType || '';
|
|
39
|
+
const schemaId = schema.$id;
|
|
40
|
+
let componentName = COMPONENT_TYPES[type];
|
|
41
|
+
if (schemaId && schemaId in fields) {
|
|
42
|
+
componentName = schemaId;
|
|
43
|
+
}
|
|
44
|
+
// If the type is not defined and the schema uses 'anyOf' or 'oneOf', don't
|
|
45
|
+
// render a field and let the MultiSchemaField component handle the form display
|
|
46
|
+
if (!componentName && (schema.anyOf || schema.oneOf)) {
|
|
47
|
+
return () => null;
|
|
48
|
+
}
|
|
49
|
+
return componentName in fields
|
|
50
|
+
? fields[componentName]
|
|
51
|
+
: () => {
|
|
52
|
+
const UnsupportedFieldTemplate = getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
53
|
+
return (_jsx(UnsupportedFieldTemplate, { schema: schema, idSchema: idSchema, reason: translateString(TranslatableString.UnknownFieldType, [String(schema.type)]), registry: registry }));
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
|
|
57
|
+
* render based on the `schema`, `uiSchema` and all the other props. It also deals with rendering the `anyOf` and
|
|
58
|
+
* `oneOf` fields.
|
|
59
|
+
*
|
|
60
|
+
* @param props - The `FieldProps` for this component
|
|
61
|
+
*/
|
|
62
|
+
function SchemaFieldRender(props) {
|
|
63
|
+
const { schema: _schema, idSchema: _idSchema, uiSchema, formData, errorSchema, idPrefix, idSeparator, name, onChange, onKeyChange, onDropPropertyClick, required, registry, wasPropertyKeyModified = false, } = props;
|
|
64
|
+
const { formContext, schemaUtils, globalUiOptions } = registry;
|
|
65
|
+
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
66
|
+
const FieldTemplate = getTemplate('FieldTemplate', registry, uiOptions);
|
|
67
|
+
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
68
|
+
const FieldHelpTemplate = getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
69
|
+
const FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, uiOptions);
|
|
70
|
+
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
71
|
+
const fieldId = _idSchema[ID_KEY];
|
|
72
|
+
const idSchema = mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
|
|
73
|
+
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
74
|
+
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
75
|
+
*/
|
|
76
|
+
const handleFieldComponentChange = useCallback((formData, newErrorSchema, id) => {
|
|
77
|
+
const theId = id || fieldId;
|
|
78
|
+
return onChange(formData, newErrorSchema, theId);
|
|
79
|
+
}, [fieldId, onChange]);
|
|
80
|
+
const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
|
|
81
|
+
const disabled = Boolean(props.disabled || uiOptions.disabled);
|
|
82
|
+
const readonly = Boolean(props.readonly || uiOptions.readonly || props.schema.readOnly || schema.readOnly);
|
|
83
|
+
const uiSchemaHideError = uiOptions.hideError;
|
|
84
|
+
// Set hideError to the value provided in the uiSchema, otherwise stick with the prop to propagate to children
|
|
85
|
+
const hideError = uiSchemaHideError === undefined ? props.hideError : Boolean(uiSchemaHideError);
|
|
86
|
+
const autofocus = Boolean(props.autofocus || uiOptions.autofocus);
|
|
87
|
+
if (Object.keys(schema).length === 0) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
91
|
+
const _a = errorSchema || {}, { __errors } = _a, fieldErrorSchema = __rest(_a, ["__errors"]);
|
|
92
|
+
// See #439: uiSchema: Don't pass consumed class names or style to child components
|
|
93
|
+
const fieldUiSchema = omit(uiSchema, ['ui:classNames', 'classNames', 'ui:style']);
|
|
94
|
+
if (UI_OPTIONS_KEY in fieldUiSchema) {
|
|
95
|
+
fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], ['classNames', 'style']);
|
|
96
|
+
}
|
|
97
|
+
const field = (_jsx(FieldComponent, Object.assign({}, props, { onChange: handleFieldComponentChange, idSchema: idSchema, schema: schema, uiSchema: fieldUiSchema, disabled: disabled, readonly: readonly, hideError: hideError, autofocus: autofocus, errorSchema: fieldErrorSchema, formContext: formContext, rawErrors: __errors })));
|
|
98
|
+
const id = idSchema[ID_KEY];
|
|
99
|
+
// If this schema has a title defined, but the user has set a new key/label, retain their input.
|
|
100
|
+
let label;
|
|
101
|
+
if (wasPropertyKeyModified) {
|
|
102
|
+
label = name;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
label = ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
|
|
106
|
+
}
|
|
107
|
+
const description = uiOptions.description || props.schema.description || schema.description || '';
|
|
108
|
+
const richDescription = uiOptions.enableMarkdownInDescription ? _jsx(Markdown, { children: description }) : description;
|
|
109
|
+
const help = uiOptions.help;
|
|
110
|
+
const hidden = uiOptions.widget === 'hidden';
|
|
111
|
+
const classNames = ['form-group', 'field', `field-${getSchemaType(schema)}`];
|
|
112
|
+
if (!hideError && __errors && __errors.length > 0) {
|
|
113
|
+
classNames.push('field-error has-error has-danger');
|
|
114
|
+
}
|
|
115
|
+
if (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.classNames) {
|
|
116
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
117
|
+
console.warn("'uiSchema.classNames' is deprecated and may be removed in a major release; Use 'ui:classNames' instead.");
|
|
118
|
+
}
|
|
119
|
+
classNames.push(uiSchema.classNames);
|
|
120
|
+
}
|
|
121
|
+
if (uiOptions.classNames) {
|
|
122
|
+
classNames.push(uiOptions.classNames);
|
|
123
|
+
}
|
|
124
|
+
const helpComponent = (_jsx(FieldHelpTemplate, { help: help, idSchema: idSchema, schema: schema, uiSchema: uiSchema, hasErrors: !hideError && __errors && __errors.length > 0, registry: registry }));
|
|
125
|
+
/*
|
|
126
|
+
* AnyOf/OneOf errors handled by child schema
|
|
127
|
+
*/
|
|
128
|
+
const errorsComponent = hideError || schema.anyOf || schema.oneOf ? undefined : (_jsx(FieldErrorTemplate, { errors: __errors, errorSchema: errorSchema, idSchema: idSchema, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
129
|
+
const fieldProps = {
|
|
130
|
+
description: (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: richDescription, schema: schema, uiSchema: uiSchema, registry: registry })),
|
|
131
|
+
rawDescription: description,
|
|
132
|
+
help: helpComponent,
|
|
133
|
+
rawHelp: typeof help === 'string' ? help : undefined,
|
|
134
|
+
errors: errorsComponent,
|
|
135
|
+
rawErrors: hideError ? undefined : __errors,
|
|
136
|
+
id,
|
|
137
|
+
label,
|
|
138
|
+
hidden,
|
|
139
|
+
onChange,
|
|
140
|
+
onKeyChange,
|
|
141
|
+
onDropPropertyClick,
|
|
142
|
+
required,
|
|
143
|
+
disabled,
|
|
144
|
+
readonly,
|
|
145
|
+
hideError,
|
|
146
|
+
displayLabel,
|
|
147
|
+
classNames: classNames.join(' ').trim(),
|
|
148
|
+
style: uiOptions.style,
|
|
149
|
+
formContext,
|
|
150
|
+
formData,
|
|
151
|
+
schema,
|
|
152
|
+
uiSchema,
|
|
153
|
+
registry,
|
|
154
|
+
};
|
|
155
|
+
const _AnyOfField = registry.fields.AnyOfField;
|
|
156
|
+
const _OneOfField = registry.fields.OneOfField;
|
|
157
|
+
const isReplacingAnyOrOneOf = (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:field']) && (uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema['ui:fieldReplacesAnyOrOneOf']) === true;
|
|
158
|
+
return (_jsx(FieldTemplate, Object.assign({}, 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 }))] }) })));
|
|
159
|
+
}
|
|
160
|
+
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
161
|
+
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
162
|
+
*/
|
|
163
|
+
class SchemaField extends Component {
|
|
164
|
+
shouldComponentUpdate(nextProps) {
|
|
165
|
+
return !deepEquals(this.props, nextProps);
|
|
166
|
+
}
|
|
167
|
+
render() {
|
|
168
|
+
return _jsx(SchemaFieldRender, Object.assign({}, this.props));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export default SchemaField;
|
|
172
|
+
//# sourceMappingURL=SchemaField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaField.js","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,aAAa,EAKb,aAAa,EACb,WAAW,EACX,YAAY,EACZ,MAAM,EAEN,YAAY,EAIZ,kBAAkB,EAClB,cAAc,GAEf,MAAM,aAAa,CAAC;AACrB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,6CAA6C;AAC7C,MAAM,eAAe,GAA8B;IACjD,KAAK,EAAE,YAAY;IACnB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,aAAa;IACtB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,IAAI,EAAE,WAAW;CAClB,CAAC;AAEF;;;;;;;;;GASG;AACH,SAAS,iBAAiB,CACxB,MAAS,EACT,SAAiC,EACjC,QAAqB,EACrB,QAA2B;IAE3B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;IAC9B,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC;IAC7C,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC/B,OAAO,KAAK,CAAC;KACd;IACD,IAAI,OAA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Q,SAE5G;IACC,qBAAqB,CAAC,SAAwC;QAC5D,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM;QACJ,OAAO,KAAC,iBAAiB,oBAAc,IAAI,CAAC,KAAK,EAAI,CAAC;IACxD,CAAC;CACF;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
/** The `StringField` component is used to render a schema field that represents a string type
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `FieldProps` for this template
|
|
6
|
+
*/
|
|
7
|
+
declare function StringField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): JSX.Element;
|
|
8
|
+
export default StringField;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { getWidget, getUiOptions, optionsList, hasWidget, } from '@rjsf/utils';
|
|
4
|
+
/** The `StringField` component is used to render a schema field that represents a string type
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `FieldProps` for this template
|
|
7
|
+
*/
|
|
8
|
+
function StringField(props) {
|
|
9
|
+
var _a;
|
|
10
|
+
const { schema, name, uiSchema, idSchema, formData, required, disabled = false, readonly = false, autofocus = false, onChange, onBlur, onFocus, registry, rawErrors, } = props;
|
|
11
|
+
const { title, format } = schema;
|
|
12
|
+
const { widgets, formContext, schemaUtils, globalUiOptions } = registry;
|
|
13
|
+
const enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema) : undefined;
|
|
14
|
+
let defaultWidget = enumOptions ? 'select' : 'text';
|
|
15
|
+
if (format && hasWidget(schema, format, widgets)) {
|
|
16
|
+
defaultWidget = format;
|
|
17
|
+
}
|
|
18
|
+
const _b = getUiOptions(uiSchema), { widget = defaultWidget, placeholder = '', title: uiTitle } = _b, options = __rest(_b, ["widget", "placeholder", "title"]);
|
|
19
|
+
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
20
|
+
const label = (_a = uiTitle !== null && uiTitle !== void 0 ? uiTitle : title) !== null && _a !== void 0 ? _a : name;
|
|
21
|
+
const Widget = getWidget(schema, widget, widgets);
|
|
22
|
+
return (_jsx(Widget, { options: Object.assign(Object.assign({}, options), { enumOptions }), schema: schema, uiSchema: uiSchema, id: idSchema.$id, name: name, label: label, hideLabel: !displayLabel, value: formData, onChange: onChange, onBlur: onBlur, onFocus: onFocus, required: required, disabled: disabled, readonly: readonly, formContext: formContext, autofocus: autofocus, registry: registry, placeholder: placeholder, rawErrors: rawErrors }));
|
|
23
|
+
}
|
|
24
|
+
export default StringField;
|
|
25
|
+
//# sourceMappingURL=StringField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringField.js","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,GAKV,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,SAAS,WAAW,CAClB,KAA0B;;IAE1B,MAAM,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,KAAK,EACjB,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,GACV,GAAG,KAAK,CAAC;IACV,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACjC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC;IACxE,MAAM,WAAW,GAAG,WAAW,CAAC,QA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,EACxB,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;AACJ,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ArrayField from './ArrayField';
|
|
2
|
+
import BooleanField from './BooleanField';
|
|
3
|
+
import MultiSchemaField from './MultiSchemaField';
|
|
4
|
+
import NumberField from './NumberField';
|
|
5
|
+
import ObjectField from './ObjectField';
|
|
6
|
+
import SchemaField from './SchemaField';
|
|
7
|
+
import StringField from './StringField';
|
|
8
|
+
import NullField from './NullField';
|
|
9
|
+
function fields() {
|
|
10
|
+
return {
|
|
11
|
+
AnyOfField: MultiSchemaField,
|
|
12
|
+
ArrayField: ArrayField,
|
|
13
|
+
// ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
|
|
14
|
+
BooleanField,
|
|
15
|
+
NumberField,
|
|
16
|
+
ObjectField,
|
|
17
|
+
OneOfField: MultiSchemaField,
|
|
18
|
+
SchemaField,
|
|
19
|
+
StringField,
|
|
20
|
+
NullField,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export default fields;
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/fields/index.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,SAAS,MAAM;IAKb,OAAO;QACL,UAAU,EAAE,gBAAgB;QAC5B,UAAU,EAAE,UAAuC;QACnD,qGAAqG;QACrG,YAAY;QACZ,WAAW;QACX,WAAW;QACX,UAAU,EAAE,gBAAgB;QAC5B,WAAW;QACX,WAAW;QACX,SAAS;KACV,CAAC;AACJ,CAAC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ArrayFieldDescriptionProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
/** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
|
|
4
|
+
* the `idSchema`.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `ArrayFieldDescriptionProps` for the component
|
|
7
|
+
*/
|
|
8
|
+
export default function ArrayFieldDescriptionTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldDescriptionProps<T, S, F>): JSX.Element | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { descriptionId, getTemplate, getUiOptions, } from '@rjsf/utils';
|
|
3
|
+
/** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
|
|
4
|
+
* the `idSchema`.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `ArrayFieldDescriptionProps` for the component
|
|
7
|
+
*/
|
|
8
|
+
export default function ArrayFieldDescriptionTemplate(props) {
|
|
9
|
+
const { idSchema, description, registry, schema, uiSchema } = props;
|
|
10
|
+
const options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
11
|
+
const { label: displayLabel = true } = options;
|
|
12
|
+
if (!description || !displayLabel) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
16
|
+
return (_jsx(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ArrayFieldDescriptionTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayFieldDescriptionTemplate.js","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldDescriptionTemplate.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,GAKb,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,6BAA6B,CAInD,KAA0C;IAC1C,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACpE,MAAM,OAAO,GAAG,YAAY,CAAU,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC1E,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC/C,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,EAAE;QACjC,OAAO,IAAI,CAAC;KACb;IACD,MAAM,wBAAwB,GAAG,WAAW,CAC1C,0BAA0B,EAC1B,QAAQ,EACR,OAAO,CACR,CAAC;IACF,OAAO,CACL,KAAC,wBAAwB,IACvB,EAAE,EAAE,aAAa,CAAI,QAAQ,CAAC,EAC9B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ArrayFieldTemplateItemType, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
6
|
+
*/
|
|
7
|
+
export default function ArrayFieldItemTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldTemplateItemType<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
3
|
+
*
|
|
4
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
5
|
+
*/
|
|
6
|
+
export default function ArrayFieldItemTemplate(props) {
|
|
7
|
+
const { children, className, disabled, hasToolbar, hasMoveDown, hasMoveUp, hasRemove, hasCopy, index, onCopyIndexClick, onDropIndexClick, onReorderClick, readonly, registry, uiSchema, } = props;
|
|
8
|
+
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
|
|
9
|
+
const btnStyle = {
|
|
10
|
+
flex: 1,
|
|
11
|
+
paddingLeft: 6,
|
|
12
|
+
paddingRight: 6,
|
|
13
|
+
fontWeight: 'bold',
|
|
14
|
+
};
|
|
15
|
+
return (_jsxs("div", Object.assign({ className: className }, { children: [_jsx("div", Object.assign({ className: hasToolbar ? 'col-xs-9' : 'col-xs-12' }, { children: children })), hasToolbar && (_jsx("div", Object.assign({ className: 'col-xs-3 array-item-toolbox' }, { children: _jsxs("div", Object.assign({ className: 'btn-group', style: {
|
|
16
|
+
display: 'flex',
|
|
17
|
+
justifyContent: 'space-around',
|
|
18
|
+
} }, { children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { style: btnStyle, disabled: disabled || readonly || !hasMoveUp, onClick: onReorderClick(index, index - 1), uiSchema: uiSchema, registry: registry })), (hasMoveUp || hasMoveDown) && (_jsx(MoveDownButton, { style: btnStyle, disabled: disabled || readonly || !hasMoveDown, onClick: onReorderClick(index, index + 1), uiSchema: uiSchema, registry: registry })), hasCopy && (_jsx(CopyButton, { style: btnStyle, disabled: disabled || readonly, onClick: onCopyIndexClick(index), uiSchema: uiSchema, registry: registry })), hasRemove && (_jsx(RemoveButton, { style: btnStyle, disabled: disabled || readonly, onClick: onDropIndexClick(index), uiSchema: uiSchema, registry: registry }))] })) })))] })));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ArrayFieldItemTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayFieldItemTemplate.js","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldItemTemplate.tsx"],"names":[],"mappings":";AAGA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAI5C,KAA0C;IAC1C,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,GAAG,KAAK,CAAC;IACV,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,eAAe,CAAC;IACtG,MAAM,QAAQ,GAAkB;QAC9B,IAAI,EAAE,CAAC;QACP,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,MAAM;KACnB,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,iBACvB,4BAAK,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,gBAAG,QAAQ,IAAO,EACtE,UAAU,IAAI,CACb,4BAAK,SAAS,EAAC,6BAA6B,gBAC1C,6BACE,SAAS,EAAC,WAAW,EACrB,KAAK,EAAE;wBACL,OAAO,EAAE,MAAM;wBACf,cAAc,EAAE,cAAc;qBAC/B,iBAEA,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAC7B,KAAC,YAAY,IACX,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,QAAQ,IAAI,QAAQ,IAAI,CAAC,SAAS,EAC5C,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,EACzC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,EACA,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAC7B,KAAC,cAAc,IACb,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,QAAQ,IAAI,QAAQ,IAAI,CAAC,WAAW,EAC9C,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,EACzC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,EACA,OAAO,IAAI,CACV,KAAC,UAAU,IACT,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,QAAQ,IAAI,QAAQ,EAC9B,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAChC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,EACA,SAAS,IAAI,CACZ,KAAC,YAAY,IACX,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,QAAQ,IAAI,QAAQ,EAC9B,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAChC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,CACH,KACG,IACF,CACP,KACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
6
|
+
*/
|
|
7
|
+
export default function ArrayFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldTemplateProps<T, S, F>): JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getTemplate, getUiOptions, } from '@rjsf/utils';
|
|
4
|
+
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
7
|
+
*/
|
|
8
|
+
export default function ArrayFieldTemplate(props) {
|
|
9
|
+
const { canAdd, className, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title, } = props;
|
|
10
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
11
|
+
const ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
12
|
+
const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
13
|
+
const ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
14
|
+
// Button templates are not overridden in the uiSchema
|
|
15
|
+
const { ButtonTemplates: { AddButton }, } = registry.templates;
|
|
16
|
+
return (_jsxs("fieldset", Object.assign({ className: className, id: idSchema.$id }, { children: [_jsx(ArrayFieldTitleTemplate, { idSchema: idSchema, title: uiOptions.title || title, required: required, schema: schema, uiSchema: uiSchema, registry: registry }), _jsx(ArrayFieldDescriptionTemplate, { idSchema: idSchema, description: uiOptions.description || schema.description, schema: schema, uiSchema: uiSchema, registry: registry }), _jsx("div", Object.assign({ className: 'row array-item-list' }, { children: items &&
|
|
17
|
+
items.map((_a) => {
|
|
18
|
+
var { key } = _a, itemProps = __rest(_a, ["key"]);
|
|
19
|
+
return (_jsx(ArrayFieldItemTemplate, Object.assign({}, itemProps), key));
|
|
20
|
+
}) })), canAdd && (_jsx(AddButton, { className: 'array-item-add', onClick: onAddClick, disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }))] })));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ArrayFieldTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayFieldTemplate.js","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTemplate.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,WAAW,EACX,YAAY,GAMb,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAIxC,KAAuC;IACvC,MAAM,EACJ,MAAM,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,GACN,GAAG,KAAK,CAAC;IACV,MAAM,SAAS,GAAG,YAAY,CAAU,QAAQ,CAAC,CAAC;IAClD,MAAM,6BAA6B,GAAG,WAAW,CAC/C,+BAA+B,EAC/B,QAAQ,EACR,SAAS,CACV,CAAC;IACF,MAAM,sBAAsB,GAAG,WAAW,CACxC,wBAAwB,EACxB,QAAQ,EACR,SAAS,CACV,CAAC;IACF,MAAM,uBAAuB,GAAG,WAAW,CACzC,yBAAyB,EACzB,QAAQ,EACR,SAAS,CACV,CAAC;IACF,sDAAsD;IACtD,MAAM,EACJ,eAAe,EAAE,EAAE,SAAS,EAAE,GAC/B,GAAG,QAAQ,CAAC,SAAS,CAAC;IACvB,OAAO,CACL,kCAAU,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,CAAC,GAAG,iBAC9C,KAAC,uBAAuB,IACtB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,KAAK,EAC/B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,EACF,KAAC,6BAA6B,IAC5B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,SAAS,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