@rjsf/core 6.0.0-beta.2 → 6.0.0-beta.20
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 +469 -360
- package/dist/{index.js → index.cjs} +640 -519
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +706 -566
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +66 -16
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +138 -59
- package/lib/components/fields/ArrayField.d.ts +17 -7
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +92 -59
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +7 -2
- package/lib/components/fields/LayoutGridField.d.ts +27 -25
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +83 -53
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.js +3 -3
- package/lib/components/fields/LayoutMultiSchemaField.js +6 -5
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +13 -9
- package/lib/components/fields/NullField.js +3 -3
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +3 -3
- package/lib/components/fields/ObjectField.d.ts +3 -3
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +18 -25
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +17 -17
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +7 -2
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +2 -2
- package/lib/components/templates/ArrayFieldTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
- package/lib/components/templates/FieldErrorTemplate.js +2 -2
- package/lib/components/templates/FieldHelpTemplate.js +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.js +2 -2
- package/lib/components/templates/UnsupportedField.js +3 -3
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +2 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +15 -18
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +2 -1
- package/lib/getTestRegistry.d.ts +5 -0
- package/lib/getTestRegistry.d.ts.map +1 -0
- package/lib/getTestRegistry.js +19 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -19
- package/src/components/Form.tsx +183 -73
- package/src/components/fields/ArrayField.tsx +99 -67
- package/src/components/fields/BooleanField.tsx +12 -3
- package/src/components/fields/LayoutGridField.tsx +95 -82
- package/src/components/fields/LayoutHeaderField.tsx +3 -3
- package/src/components/fields/LayoutMultiSchemaField.tsx +5 -5
- package/src/components/fields/MultiSchemaField.tsx +51 -35
- package/src/components/fields/NullField.tsx +3 -3
- package/src/components/fields/NumberField.tsx +11 -3
- package/src/components/fields/ObjectField.tsx +19 -36
- package/src/components/fields/SchemaField.tsx +24 -30
- package/src/components/fields/StringField.tsx +12 -3
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +3 -3
- package/src/components/templates/BaseInputTemplate.tsx +3 -3
- package/src/components/templates/FieldErrorTemplate.tsx +2 -2
- package/src/components/templates/FieldHelpTemplate.tsx +2 -2
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +5 -5
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +2 -0
- package/src/components/widgets/AltDateWidget.tsx +21 -23
- package/src/components/widgets/CheckboxWidget.tsx +2 -2
- package/src/components/widgets/CheckboxesWidget.tsx +3 -3
- package/src/components/widgets/RadioWidget.tsx +1 -1
- package/src/components/widgets/SelectWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +1 -1
- package/src/getDefaultRegistry.ts +10 -1
- package/src/getTestRegistry.tsx +34 -0
- package/src/index.ts +2 -1
- package/dist/index.js.map +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
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';
|
|
3
|
+
import { getTemplate, getUiOptions, orderProperties, toFieldPathId, 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
5
|
import get from 'lodash-es/get.js';
|
|
6
6
|
import has from 'lodash-es/has.js';
|
|
@@ -36,8 +36,8 @@ class ObjectField extends Component {
|
|
|
36
36
|
* @returns - The onPropertyChange callback for the `name` property
|
|
37
37
|
*/
|
|
38
38
|
onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
39
|
-
return (value, newErrorSchema, id) => {
|
|
40
|
-
const {
|
|
39
|
+
return (value, path, newErrorSchema, id) => {
|
|
40
|
+
const { onChange } = this.props;
|
|
41
41
|
if (value === undefined && addedByAdditionalProperties) {
|
|
42
42
|
// Don't set value = undefined for fields added by
|
|
43
43
|
// additionalProperties. Doing so removes them from the
|
|
@@ -48,12 +48,7 @@ class ObjectField extends Component {
|
|
|
48
48
|
// set empty values to the empty string.
|
|
49
49
|
value = '';
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
onChange(newFormData, errorSchema &&
|
|
53
|
-
errorSchema && {
|
|
54
|
-
...errorSchema,
|
|
55
|
-
[name]: newErrorSchema,
|
|
56
|
-
}, id);
|
|
51
|
+
onChange(value, path, newErrorSchema, id);
|
|
57
52
|
};
|
|
58
53
|
};
|
|
59
54
|
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
@@ -65,10 +60,11 @@ class ObjectField extends Component {
|
|
|
65
60
|
onDropPropertyClick = (key) => {
|
|
66
61
|
return (event) => {
|
|
67
62
|
event.preventDefault();
|
|
68
|
-
const { onChange, formData } = this.props;
|
|
63
|
+
const { onChange, formData, fieldPathId } = this.props;
|
|
69
64
|
const copiedFormData = { ...formData };
|
|
70
65
|
unset(copiedFormData, key);
|
|
71
|
-
|
|
66
|
+
// drop property will pass the name in `path` array
|
|
67
|
+
onChange(copiedFormData, fieldPathId.path);
|
|
72
68
|
};
|
|
73
69
|
};
|
|
74
70
|
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
@@ -95,11 +91,11 @@ class ObjectField extends Component {
|
|
|
95
91
|
* @returns - The key change callback function
|
|
96
92
|
*/
|
|
97
93
|
onKeyChange = (oldValue) => {
|
|
98
|
-
return (value
|
|
94
|
+
return (value) => {
|
|
99
95
|
if (oldValue === value) {
|
|
100
96
|
return;
|
|
101
97
|
}
|
|
102
|
-
const { formData, onChange,
|
|
98
|
+
const { formData, onChange, fieldPathId } = this.props;
|
|
103
99
|
value = this.getAvailableKey(value, formData);
|
|
104
100
|
const newFormData = {
|
|
105
101
|
...formData,
|
|
@@ -111,11 +107,7 @@ class ObjectField extends Component {
|
|
|
111
107
|
});
|
|
112
108
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
113
109
|
this.setState({ wasPropertyKeyModified: true });
|
|
114
|
-
onChange(renamedObj,
|
|
115
|
-
errorSchema && {
|
|
116
|
-
...errorSchema,
|
|
117
|
-
[value]: newErrorSchema,
|
|
118
|
-
});
|
|
110
|
+
onChange(renamedObj, fieldPathId.path);
|
|
119
111
|
};
|
|
120
112
|
};
|
|
121
113
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
@@ -150,7 +142,7 @@ class ObjectField extends Component {
|
|
|
150
142
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
151
143
|
return;
|
|
152
144
|
}
|
|
153
|
-
const { formData, onChange, registry } = this.props;
|
|
145
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
154
146
|
const newFormData = { ...formData };
|
|
155
147
|
const newKey = this.getAvailableKey('newKey', newFormData);
|
|
156
148
|
if (schema.patternProperties) {
|
|
@@ -181,13 +173,14 @@ class ObjectField extends Component {
|
|
|
181
173
|
// Cast this to make the `set` work properly
|
|
182
174
|
set(newFormData, newKey, newValue);
|
|
183
175
|
}
|
|
184
|
-
|
|
176
|
+
// add will pass the name in `path` array
|
|
177
|
+
onChange(newFormData, fieldPathId.path);
|
|
185
178
|
};
|
|
186
179
|
/** Renders the `ObjectField` from the given props
|
|
187
180
|
*/
|
|
188
181
|
render() {
|
|
189
|
-
const { schema: rawSchema, uiSchema = {}, formData, errorSchema,
|
|
190
|
-
const { fields, formContext, schemaUtils, translateString, globalUiOptions } = registry;
|
|
182
|
+
const { schema: rawSchema, uiSchema = {}, formData, errorSchema, fieldPathId, name, required = false, disabled, readonly, hideError, onBlur, onFocus, registry, title, } = this.props;
|
|
183
|
+
const { fields, formContext, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
|
|
191
184
|
const { SchemaField } = fields;
|
|
192
185
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
193
186
|
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
@@ -211,9 +204,9 @@ class ObjectField extends Component {
|
|
|
211
204
|
const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
|
|
212
205
|
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
|
|
213
206
|
const hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
|
|
214
|
-
const
|
|
207
|
+
const innerFieldIdPathId = toFieldPathId(name, globalFormOptions, fieldPathId);
|
|
215
208
|
return {
|
|
216
|
-
content: (_jsx(SchemaField, { name: name, required: this.isRequired(name), schema: get(schema, [PROPERTIES_KEY, name], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, name),
|
|
209
|
+
content: (_jsx(SchemaField, { name: name, required: this.isRequired(name), schema: get(schema, [PROPERTIES_KEY, name], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, name), fieldPathId: innerFieldIdPathId, 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)),
|
|
217
210
|
name,
|
|
218
211
|
readonly,
|
|
219
212
|
disabled,
|
|
@@ -224,7 +217,7 @@ class ObjectField extends Component {
|
|
|
224
217
|
readonly,
|
|
225
218
|
disabled,
|
|
226
219
|
required,
|
|
227
|
-
|
|
220
|
+
fieldPathId,
|
|
228
221
|
uiSchema,
|
|
229
222
|
errorSchema,
|
|
230
223
|
schema,
|
|
@@ -1 +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,
|
|
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,EAML,UAAU,EAEV,eAAe,EAMf,UAAU,EAEV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;AAkTrB;;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;IAS9D,MAAM;CAGP;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, Component } from 'react';
|
|
3
|
-
import { ADDITIONAL_PROPERTY_FLAG,
|
|
3
|
+
import { ADDITIONAL_PROPERTY_FLAG, descriptionId, getSchemaType, getTemplate, getUiOptions, ID_KEY, shouldRender, TranslatableString, UI_OPTIONS_KEY, } from '@rjsf/utils';
|
|
4
4
|
import isObject from 'lodash-es/isObject.js';
|
|
5
5
|
import omit from 'lodash-es/omit.js';
|
|
6
6
|
/** The map of component type to FieldName */
|
|
@@ -19,11 +19,11 @@ const COMPONENT_TYPES = {
|
|
|
19
19
|
*
|
|
20
20
|
* @param schema - The schema from which to obtain the type
|
|
21
21
|
* @param uiOptions - The UI Options that may affect the component decision
|
|
22
|
-
* @param
|
|
22
|
+
* @param fieldPathId - The id that is passed to the `UnsupportedFieldTemplate`
|
|
23
23
|
* @param registry - The registry from which fields and templates are obtained
|
|
24
24
|
* @returns - The `Field` component that is used to render the actual field data
|
|
25
25
|
*/
|
|
26
|
-
function getFieldComponent(schema, uiOptions,
|
|
26
|
+
function getFieldComponent(schema, uiOptions, fieldPathId, registry) {
|
|
27
27
|
const field = uiOptions.field;
|
|
28
28
|
const { fields, translateString } = registry;
|
|
29
29
|
if (typeof field === 'function') {
|
|
@@ -48,7 +48,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
48
48
|
? fields[componentName]
|
|
49
49
|
: () => {
|
|
50
50
|
const UnsupportedFieldTemplate = getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
|
|
51
|
-
return (_jsx(UnsupportedFieldTemplate, { schema: schema,
|
|
51
|
+
return (_jsx(UnsupportedFieldTemplate, { schema: schema, fieldPathId: fieldPathId, reason: translateString(TranslatableString.UnknownFieldType, [String(schema.type)]), registry: registry }));
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
/** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
|
|
@@ -58,7 +58,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
58
58
|
* @param props - The `FieldProps` for this component
|
|
59
59
|
*/
|
|
60
60
|
function SchemaFieldRender(props) {
|
|
61
|
-
const { schema: _schema,
|
|
61
|
+
const { schema: _schema, fieldPathId, uiSchema, formData, errorSchema, name, onChange, onKeyChange, onDropPropertyClick, required, registry, wasPropertyKeyModified = false, } = props;
|
|
62
62
|
const { formContext, schemaUtils, globalUiOptions } = registry;
|
|
63
63
|
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
64
64
|
const FieldTemplate = getTemplate('FieldTemplate', registry, uiOptions);
|
|
@@ -66,16 +66,15 @@ function SchemaFieldRender(props) {
|
|
|
66
66
|
const FieldHelpTemplate = getTemplate('FieldHelpTemplate', registry, uiOptions);
|
|
67
67
|
const FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, uiOptions);
|
|
68
68
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
69
|
-
const fieldId =
|
|
70
|
-
const idSchema = mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
|
|
69
|
+
const fieldId = fieldPathId[ID_KEY];
|
|
71
70
|
/** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
|
|
72
71
|
* `onChange` chain if it is not already being provided from a deeper level in the hierarchy
|
|
73
72
|
*/
|
|
74
|
-
const handleFieldComponentChange = useCallback((formData, newErrorSchema, id) => {
|
|
73
|
+
const handleFieldComponentChange = useCallback((formData, path, newErrorSchema, id) => {
|
|
75
74
|
const theId = id || fieldId;
|
|
76
|
-
return onChange(formData, newErrorSchema, theId);
|
|
75
|
+
return onChange(formData, path, newErrorSchema, theId);
|
|
77
76
|
}, [fieldId, onChange]);
|
|
78
|
-
const FieldComponent = getFieldComponent(schema, uiOptions,
|
|
77
|
+
const FieldComponent = getFieldComponent(schema, uiOptions, fieldPathId, registry);
|
|
79
78
|
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
80
79
|
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
81
80
|
const uiSchemaHideError = uiOptions.hideError;
|
|
@@ -92,8 +91,8 @@ function SchemaFieldRender(props) {
|
|
|
92
91
|
if (UI_OPTIONS_KEY in fieldUiSchema) {
|
|
93
92
|
fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], ['classNames', 'style']);
|
|
94
93
|
}
|
|
95
|
-
const field = (_jsx(FieldComponent, { ...props, onChange: handleFieldComponentChange,
|
|
96
|
-
const id =
|
|
94
|
+
const field = (_jsx(FieldComponent, { ...props, onChange: handleFieldComponentChange, fieldPathId: fieldPathId, schema: schema, uiSchema: fieldUiSchema, disabled: disabled, readonly: readonly, hideError: hideError, autofocus: autofocus, errorSchema: fieldErrorSchema, formContext: formContext, rawErrors: __errors }));
|
|
95
|
+
const id = fieldPathId[ID_KEY];
|
|
97
96
|
// If this schema has a title defined, but the user has set a new key/label, retain their input.
|
|
98
97
|
let label;
|
|
99
98
|
if (wasPropertyKeyModified) {
|
|
@@ -115,12 +114,12 @@ function SchemaFieldRender(props) {
|
|
|
115
114
|
if (uiOptions.classNames) {
|
|
116
115
|
classNames.push(uiOptions.classNames);
|
|
117
116
|
}
|
|
118
|
-
const helpComponent = (_jsx(FieldHelpTemplate, { help: help,
|
|
117
|
+
const helpComponent = (_jsx(FieldHelpTemplate, { help: help, fieldPathId: fieldPathId, schema: schema, uiSchema: uiSchema, hasErrors: !hideError && __errors && __errors.length > 0, registry: registry }));
|
|
119
118
|
/*
|
|
120
119
|
* AnyOf/OneOf errors handled by child schema
|
|
121
120
|
* unless it can be rendered as select control
|
|
122
121
|
*/
|
|
123
|
-
const errorsComponent = hideError || ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema)) ? undefined : (_jsx(FieldErrorTemplate, { errors: __errors, errorSchema: errorSchema,
|
|
122
|
+
const errorsComponent = hideError || ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema)) ? undefined : (_jsx(FieldErrorTemplate, { errors: __errors, errorSchema: errorSchema, fieldPathId: fieldPathId, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
124
123
|
const fieldProps = {
|
|
125
124
|
description: (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })),
|
|
126
125
|
rawDescription: description,
|
|
@@ -141,7 +140,6 @@ function SchemaFieldRender(props) {
|
|
|
141
140
|
displayLabel,
|
|
142
141
|
classNames: classNames.join(' ').trim(),
|
|
143
142
|
style: uiOptions.style,
|
|
144
|
-
formContext,
|
|
145
143
|
formData,
|
|
146
144
|
schema,
|
|
147
145
|
uiSchema,
|
|
@@ -150,14 +148,16 @@ function SchemaFieldRender(props) {
|
|
|
150
148
|
const _AnyOfField = registry.fields.AnyOfField;
|
|
151
149
|
const _OneOfField = registry.fields.OneOfField;
|
|
152
150
|
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,
|
|
151
|
+
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, fieldPathId: fieldPathId, 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, fieldPathId: fieldPathId, 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 }))] }) }));
|
|
154
152
|
}
|
|
155
153
|
/** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
|
|
156
154
|
* and if so, calls the `SchemaFieldRender` component with the props.
|
|
157
155
|
*/
|
|
158
156
|
class SchemaField extends Component {
|
|
159
157
|
shouldComponentUpdate(nextProps) {
|
|
160
|
-
|
|
158
|
+
const { registry: { globalFormOptions }, } = this.props;
|
|
159
|
+
const { experimental_componentUpdateStrategy = 'customDeep' } = globalFormOptions;
|
|
160
|
+
return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
|
|
161
161
|
}
|
|
162
162
|
render() {
|
|
163
163
|
return _jsx(SchemaFieldRender, { ...this.props });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StringField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,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,2CA6D3B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
2
3
|
import { getWidget, getUiOptions, optionsList, hasWidget, } from '@rjsf/utils';
|
|
3
4
|
/** The `StringField` component is used to render a schema field that represents a string type
|
|
4
5
|
*
|
|
5
6
|
* @param props - The `FieldProps` for this template
|
|
6
7
|
*/
|
|
7
8
|
function StringField(props) {
|
|
8
|
-
const { schema, name, uiSchema,
|
|
9
|
+
const { schema, name, uiSchema, fieldPathId, formData, required, disabled = false, readonly = false, autofocus = false, onChange, onBlur, onFocus, registry, rawErrors, hideError, } = props;
|
|
9
10
|
const { title, format } = schema;
|
|
10
11
|
const { widgets, formContext, schemaUtils, globalUiOptions } = registry;
|
|
11
12
|
const enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema, uiSchema) : undefined;
|
|
@@ -17,6 +18,10 @@ function StringField(props) {
|
|
|
17
18
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
18
19
|
const label = uiTitle ?? title ?? name;
|
|
19
20
|
const Widget = getWidget(schema, widget, widgets);
|
|
20
|
-
|
|
21
|
+
const onWidgetChange = useCallback((value, errorSchema, id) => {
|
|
22
|
+
// String field change passes an empty path array to the parent field which adds the appropriate path
|
|
23
|
+
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
24
|
+
}, [onChange, fieldPathId]);
|
|
25
|
+
return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: fieldPathId.$id, name: name, label: label, hideLabel: !displayLabel, hideError: hideError, value: formData, onChange: onWidgetChange, onBlur: onBlur, onFocus: onFocus, required: required, disabled: disabled, readonly: readonly, formContext: formContext, autofocus: autofocus, registry: registry, placeholder: placeholder, rawErrors: rawErrors }));
|
|
21
26
|
}
|
|
22
27
|
export default StringField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArrayFieldDescriptionProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
|
|
3
|
-
* the `
|
|
3
|
+
* the `fieldPathId`.
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `ArrayFieldDescriptionProps` for the component
|
|
6
6
|
*/
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { descriptionId, getTemplate, getUiOptions, } from '@rjsf/utils';
|
|
3
3
|
/** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
|
|
4
|
-
* the `
|
|
4
|
+
* the `fieldPathId`.
|
|
5
5
|
*
|
|
6
6
|
* @param props - The `ArrayFieldDescriptionProps` for the component
|
|
7
7
|
*/
|
|
8
8
|
export default function ArrayFieldDescriptionTemplate(props) {
|
|
9
|
-
const {
|
|
9
|
+
const { fieldPathId, description, registry, schema, uiSchema } = props;
|
|
10
10
|
const options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
11
11
|
const { label: displayLabel = true } = options;
|
|
12
12
|
if (!description || !displayLabel) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
16
|
-
return (_jsx(DescriptionFieldTemplate, { id: descriptionId(
|
|
16
|
+
return (_jsx(DescriptionFieldTemplate, { id: descriptionId(fieldPathId), description: description, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
17
17
|
}
|
|
@@ -7,11 +7,11 @@ import { buttonId, } from '@rjsf/utils';
|
|
|
7
7
|
* @param props - The `ArrayFieldItemButtonsTemplateType` props for the component
|
|
8
8
|
*/
|
|
9
9
|
export default function ArrayFieldItemButtonsTemplate(props) {
|
|
10
|
-
const { disabled, hasCopy, hasMoveDown, hasMoveUp, hasRemove,
|
|
10
|
+
const { disabled, hasCopy, hasMoveDown, hasMoveUp, hasRemove, fieldPathId, index, onCopyIndexClick, onDropIndexClick, onReorderClick, readonly, registry, uiSchema, } = props;
|
|
11
11
|
const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
|
|
12
12
|
const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
|
|
13
13
|
const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
14
14
|
const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
15
15
|
const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
16
|
-
return (_jsxs(_Fragment, { children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { id: buttonId(
|
|
16
|
+
return (_jsxs(_Fragment, { children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { id: buttonId(fieldPathId, 'moveUp'), className: 'rjsf-array-item-move-up', disabled: disabled || readonly || !hasMoveUp, onClick: onArrowUpClick, uiSchema: uiSchema, registry: registry })), (hasMoveUp || hasMoveDown) && (_jsx(MoveDownButton, { id: buttonId(fieldPathId, 'moveDown'), className: 'rjsf-array-item-move-down', disabled: disabled || readonly || !hasMoveDown, onClick: onArrowDownClick, uiSchema: uiSchema, registry: registry })), hasCopy && (_jsx(CopyButton, { id: buttonId(fieldPathId, 'copy'), className: 'rjsf-array-item-copy', disabled: disabled || readonly, onClick: onCopyClick, uiSchema: uiSchema, registry: registry })), hasRemove && (_jsx(RemoveButton, { id: buttonId(fieldPathId, 'remove'), className: 'rjsf-array-item-remove', disabled: disabled || readonly, onClick: onRemoveClick, uiSchema: uiSchema, registry: registry }))] }));
|
|
17
17
|
}
|
|
@@ -5,13 +5,13 @@ import { getTemplate, getUiOptions, buttonId, } from '@rjsf/utils';
|
|
|
5
5
|
* @param props - The `ArrayFieldItemTemplateType` props for the component
|
|
6
6
|
*/
|
|
7
7
|
export default function ArrayFieldTemplate(props) {
|
|
8
|
-
const { canAdd, className, disabled,
|
|
8
|
+
const { canAdd, className, disabled, fieldPathId, uiSchema, items, onAddClick, readonly, registry, required, schema, title, } = props;
|
|
9
9
|
const uiOptions = getUiOptions(uiSchema);
|
|
10
10
|
const ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
11
11
|
const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
12
12
|
const ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
13
13
|
// Button templates are not overridden in the uiSchema
|
|
14
14
|
const { ButtonTemplates: { AddButton }, } = registry.templates;
|
|
15
|
-
return (_jsxs("fieldset", { className: className, id:
|
|
16
|
-
items.map(({ key, ...itemProps }) => (_jsx(ArrayFieldItemTemplate, { ...itemProps }, key))) }), canAdd && (_jsx(AddButton, { id: buttonId(
|
|
15
|
+
return (_jsxs("fieldset", { className: className, id: fieldPathId.$id, children: [_jsx(ArrayFieldTitleTemplate, { fieldPathId: fieldPathId, title: uiOptions.title || title, required: required, schema: schema, uiSchema: uiSchema, registry: registry }), _jsx(ArrayFieldDescriptionTemplate, { fieldPathId: fieldPathId, description: uiOptions.description || schema.description, schema: schema, uiSchema: uiSchema, registry: registry }), _jsx("div", { className: 'row array-item-list', children: items &&
|
|
16
|
+
items.map(({ key, ...itemProps }) => (_jsx(ArrayFieldItemTemplate, { ...itemProps }, key))) }), canAdd && (_jsx(AddButton, { id: buttonId(fieldPathId, 'add'), className: 'rjsf-array-item-add', onClick: onAddClick, disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }))] }));
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArrayFieldTitleProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
3
|
-
* the `
|
|
3
|
+
* the `fieldPathId`.
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `ArrayFieldTitleProps` for the component
|
|
6
6
|
*/
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
|
|
3
3
|
/** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
|
|
4
|
-
* the `
|
|
4
|
+
* the `fieldPathId`.
|
|
5
5
|
*
|
|
6
6
|
* @param props - The `ArrayFieldTitleProps` for the component
|
|
7
7
|
*/
|
|
8
8
|
export default function ArrayFieldTitleTemplate(props) {
|
|
9
|
-
const {
|
|
9
|
+
const { fieldPathId, title, schema, uiSchema, required, registry } = props;
|
|
10
10
|
const options = getUiOptions(uiSchema, registry.globalUiOptions);
|
|
11
11
|
const { label: displayLabel = true } = options;
|
|
12
12
|
if (!title || !displayLabel) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
16
|
-
return (_jsx(TitleFieldTemplate, { id: titleId(
|
|
16
|
+
return (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry }));
|
|
17
17
|
}
|
|
@@ -5,11 +5,11 @@ import { errorId } from '@rjsf/utils';
|
|
|
5
5
|
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
6
6
|
*/
|
|
7
7
|
export default function FieldErrorTemplate(props) {
|
|
8
|
-
const { errors = [],
|
|
8
|
+
const { errors = [], fieldPathId } = props;
|
|
9
9
|
if (errors.length === 0) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
const id = errorId(
|
|
12
|
+
const id = errorId(fieldPathId);
|
|
13
13
|
return (_jsx("div", { children: _jsx("ul", { id: id, className: 'error-detail bs-callout bs-callout-info', children: errors
|
|
14
14
|
.filter((elem) => !!elem)
|
|
15
15
|
.map((error, index) => {
|
|
@@ -5,11 +5,11 @@ import { helpId } from '@rjsf/utils';
|
|
|
5
5
|
* @param props - The `FieldHelpProps` to be rendered
|
|
6
6
|
*/
|
|
7
7
|
export default function FieldHelpTemplate(props) {
|
|
8
|
-
const {
|
|
8
|
+
const { fieldPathId, help } = props;
|
|
9
9
|
if (!help) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
const id = helpId(
|
|
12
|
+
const id = helpId(fieldPathId);
|
|
13
13
|
if (typeof help === 'string') {
|
|
14
14
|
return (_jsx("p", { id: id, className: 'help-block', children: help }));
|
|
15
15
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
/** The `MultiSchemaFieldTemplate` component renders the layout for the MultiSchemaField, which supports choosing
|
|
3
|
+
* a schema from a list of schemas defined using `anyOf` or `oneOf`.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `MultiSchemaFieldTemplate` to be rendered
|
|
6
|
+
*/
|
|
7
|
+
export default function MultiSchemaFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: MultiSchemaFieldTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=MultiSchemaFieldTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSchemaFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/MultiSchemaFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE3G;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAQ9C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** The `MultiSchemaFieldTemplate` component renders the layout for the MultiSchemaField, which supports choosing
|
|
3
|
+
* a schema from a list of schemas defined using `anyOf` or `oneOf`.
|
|
4
|
+
*
|
|
5
|
+
* @param props - The `MultiSchemaFieldTemplate` to be rendered
|
|
6
|
+
*/
|
|
7
|
+
export default function MultiSchemaFieldTemplate(props) {
|
|
8
|
+
const { selector, optionSchemaField } = props;
|
|
9
|
+
return (_jsxs("div", { className: 'panel panel-default panel-body', children: [_jsx("div", { className: 'form-group', children: selector }), optionSchemaField] }));
|
|
10
|
+
}
|
|
@@ -7,11 +7,11 @@ import { canExpand, descriptionId, getTemplate, getUiOptions, titleId, buttonId,
|
|
|
7
7
|
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
8
8
|
*/
|
|
9
9
|
export default function ObjectFieldTemplate(props) {
|
|
10
|
-
const { description, disabled, formData,
|
|
10
|
+
const { description, disabled, formData, fieldPathId, onAddClick, properties, readonly, registry, required, schema, title, uiSchema, } = props;
|
|
11
11
|
const options = getUiOptions(uiSchema);
|
|
12
12
|
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
13
13
|
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
14
14
|
// Button templates are not overridden in the uiSchema
|
|
15
15
|
const { ButtonTemplates: { AddButton }, } = registry.templates;
|
|
16
|
-
return (_jsxs("fieldset", { id:
|
|
16
|
+
return (_jsxs("fieldset", { id: fieldPathId.$id, children: [title && (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry })), description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(fieldPathId), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), properties.map((prop) => prop.content), canExpand(schema, uiSchema, formData) && (_jsx(AddButton, { id: buttonId(fieldPathId, 'add'), className: 'rjsf-object-property-expand', onClick: onAddClick(schema), disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }))] }));
|
|
17
17
|
}
|
|
@@ -7,13 +7,13 @@ import Markdown from 'markdown-to-jsx';
|
|
|
7
7
|
* @param props - The `FieldProps` for this template
|
|
8
8
|
*/
|
|
9
9
|
function UnsupportedField(props) {
|
|
10
|
-
const { schema,
|
|
10
|
+
const { schema, fieldPathId, reason, registry } = props;
|
|
11
11
|
const { translateString } = registry;
|
|
12
12
|
let translateEnum = TranslatableString.UnsupportedField;
|
|
13
13
|
const translateParams = [];
|
|
14
|
-
if (
|
|
14
|
+
if (fieldPathId && fieldPathId.$id) {
|
|
15
15
|
translateEnum = TranslatableString.UnsupportedFieldWithId;
|
|
16
|
-
translateParams.push(
|
|
16
|
+
translateParams.push(fieldPathId.$id);
|
|
17
17
|
}
|
|
18
18
|
if (reason) {
|
|
19
19
|
translateEnum =
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAqB3F,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,KAAK,aAAa,CACpH,CAAC,EACD,CAAC,EACD,CAAC,CACF,CAqBA;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -11,6 +11,7 @@ import FieldTemplate from './FieldTemplate/index.js';
|
|
|
11
11
|
import FieldErrorTemplate from './FieldErrorTemplate.js';
|
|
12
12
|
import FieldHelpTemplate from './FieldHelpTemplate.js';
|
|
13
13
|
import GridTemplate from './GridTemplate.js';
|
|
14
|
+
import MultiSchemaFieldTemplate from './MultiSchemaFieldTemplate.js';
|
|
14
15
|
import ObjectFieldTemplate from './ObjectFieldTemplate.js';
|
|
15
16
|
import TitleField from './TitleField.js';
|
|
16
17
|
import UnsupportedField from './UnsupportedField.js';
|
|
@@ -30,6 +31,7 @@ function templates() {
|
|
|
30
31
|
FieldErrorTemplate,
|
|
31
32
|
FieldHelpTemplate,
|
|
32
33
|
GridTemplate,
|
|
34
|
+
MultiSchemaFieldTemplate,
|
|
33
35
|
ObjectFieldTemplate,
|
|
34
36
|
TitleFieldTemplate: TitleField,
|
|
35
37
|
UnsupportedFieldTemplate: UnsupportedField,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AltDateWidget.d.ts","sourceRoot":"","sources":["../../../src/components/widgets/AltDateWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAOL,eAAe,EACf,UAAU,EACV,gBAAgB,EAEhB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAsDrB;;GAEG;AACH,iBAAS,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACxG,IAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,SAAiB,EACjB,OAAO,EACP,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"AltDateWidget.d.ts","sourceRoot":"","sources":["../../../src/components/widgets/AltDateWidget.tsx"],"names":[],"mappings":"AACA,OAAO,EAOL,eAAe,EACf,UAAU,EACV,gBAAgB,EAEhB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAsDrB;;GAEG;AACH,iBAAS,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACxG,IAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,SAAiB,EACjB,OAAO,EACP,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsFtB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect,
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { ariaDescribedByIds, dateRangeOptions, parseDateString, toDateString, TranslatableString, getDateElementProps, } from '@rjsf/utils';
|
|
4
4
|
function readyForChange(state) {
|
|
5
5
|
return Object.values(state).every((value) => value !== -1);
|
|
@@ -14,25 +14,22 @@ function DateElement({ type, range, value, select, rootId, name, disabled, reado
|
|
|
14
14
|
*/
|
|
15
15
|
function AltDateWidget({ time = false, disabled = false, readonly = false, autofocus = false, options, id, name, registry, onBlur, onFocus, onChange, value, }) {
|
|
16
16
|
const { translateString } = registry;
|
|
17
|
-
const [
|
|
18
|
-
const [state, setState] = useReducer((state, action) => {
|
|
19
|
-
return { ...state, ...action };
|
|
20
|
-
}, parseDateString(value, time));
|
|
17
|
+
const [state, setState] = useState(parseDateString(value, time));
|
|
21
18
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
setState(parseDateString(value, time));
|
|
20
|
+
}, [time, value]);
|
|
21
|
+
const handleChange = useCallback((property, value) => {
|
|
22
|
+
const nextState = {
|
|
23
|
+
...state,
|
|
24
|
+
[property]: typeof value === 'undefined' ? -1 : value,
|
|
25
|
+
};
|
|
26
|
+
if (readyForChange(nextState)) {
|
|
27
|
+
onChange(toDateString(nextState, time));
|
|
26
28
|
}
|
|
27
|
-
else
|
|
28
|
-
|
|
29
|
-
setLastValue(value);
|
|
30
|
-
setState(parseDateString(value, time));
|
|
29
|
+
else {
|
|
30
|
+
setState(nextState);
|
|
31
31
|
}
|
|
32
|
-
}, [
|
|
33
|
-
const handleChange = useCallback((property, value) => {
|
|
34
|
-
setState({ [property]: value });
|
|
35
|
-
}, []);
|
|
32
|
+
}, [state, onChange, time]);
|
|
36
33
|
const handleSetNow = useCallback((event) => {
|
|
37
34
|
event.preventDefault();
|
|
38
35
|
if (disabled || readonly) {
|
|
@@ -40,7 +37,7 @@ function AltDateWidget({ time = false, disabled = false, readonly = false, autof
|
|
|
40
37
|
}
|
|
41
38
|
const nextState = parseDateString(new Date().toJSON(), time);
|
|
42
39
|
onChange(toDateString(nextState, time));
|
|
43
|
-
}, [disabled, readonly, time]);
|
|
40
|
+
}, [disabled, readonly, time, onChange]);
|
|
44
41
|
const handleClear = useCallback((event) => {
|
|
45
42
|
event.preventDefault();
|
|
46
43
|
if (disabled || readonly) {
|
|
@@ -8,8 +8,8 @@ import { ariaDescribedByIds, enumOptionsDeselectValue, enumOptionsIsSelected, en
|
|
|
8
8
|
*/
|
|
9
9
|
function CheckboxesWidget({ id, disabled, options: { inline = false, enumOptions, enumDisabled, emptyValue }, value, autofocus = false, readonly, onChange, onBlur, onFocus, }) {
|
|
10
10
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
11
|
-
const handleBlur = useCallback(({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onBlur, id]);
|
|
12
|
-
const handleFocus = useCallback(({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onFocus, id]);
|
|
11
|
+
const handleBlur = useCallback(({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onBlur, id, enumOptions, emptyValue]);
|
|
12
|
+
const handleFocus = useCallback(({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)), [onFocus, id, enumOptions, emptyValue]);
|
|
13
13
|
return (_jsx("div", { className: 'checkboxes', id: id, children: Array.isArray(enumOptions) &&
|
|
14
14
|
enumOptions.map((option, index) => {
|
|
15
15
|
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultRegistry.d.ts","sourceRoot":"","sources":["../src/getDefaultRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"getDefaultRegistry.d.ts","sourceRoot":"","sources":["../src/getDefaultRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAMrB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,CAU1C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { englishStringTranslator } from '@rjsf/utils';
|
|
1
|
+
import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator, } from '@rjsf/utils';
|
|
2
2
|
import fields from './components/fields/index.js';
|
|
3
3
|
import templates from './components/templates/index.js';
|
|
4
4
|
import widgets from './components/widgets/index.js';
|
|
@@ -14,5 +14,6 @@ export default function getDefaultRegistry() {
|
|
|
14
14
|
rootSchema: {},
|
|
15
15
|
formContext: {},
|
|
16
16
|
translateString: englishStringTranslator,
|
|
17
|
+
globalFormOptions: { idPrefix: DEFAULT_ID_PREFIX, idSeparator: DEFAULT_ID_SEPARATOR },
|
|
17
18
|
};
|
|
18
19
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Registry } from '@rjsf/utils';
|
|
2
|
+
/** Use for react testing library tests where we directly test the component rather than testing inside a Form
|
|
3
|
+
*/
|
|
4
|
+
export default function getTestRegistry(rootSchema: Registry['rootSchema'], fields?: Registry['fields'], templates?: Partial<Registry['templates']>, widgets?: Registry['widgets'], formContext?: Registry['formContext'], globalFormOptions?: Registry['globalFormOptions']): Registry;
|
|
5
|
+
//# sourceMappingURL=getTestRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTestRegistry.d.ts","sourceRoot":"","sources":["../src/getTestRegistry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EACT,MAAM,aAAa,CAAC;AAKrB;GACG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC,EAClC,MAAM,GAAE,QAAQ,CAAC,QAAQ,CAAM,EAC/B,SAAS,GAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAM,EAC9C,OAAO,GAAE,QAAQ,CAAC,SAAS,CAAM,EACjC,WAAW,GAAE,QAAQ,CAAC,aAAa,CAAM,EACzC,iBAAiB,GAAE,QAAQ,CAAC,mBAAmB,CAAsE,GACpH,QAAQ,CAaV"}
|