@rjsf/core 5.24.4 → 5.24.7
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 +602 -601
- package/dist/index.esm.js +602 -601
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +602 -601
- package/dist/index.js.map +2 -2
- package/lib/components/Form.d.ts +1 -0
- package/lib/components/Form.d.ts.map +1 -0
- package/lib/components/Form.js +293 -293
- package/lib/components/fields/ArrayField.d.ts +1 -0
- package/lib/components/fields/ArrayField.d.ts.map +1 -0
- package/lib/components/fields/ArrayField.js +190 -194
- package/lib/components/fields/BooleanField.d.ts +1 -0
- package/lib/components/fields/BooleanField.d.ts.map +1 -0
- package/lib/components/fields/BooleanField.js +3 -5
- package/lib/components/fields/MultiSchemaField.d.ts +1 -0
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -0
- package/lib/components/fields/MultiSchemaField.js +30 -31
- package/lib/components/fields/NullField.d.ts +1 -0
- package/lib/components/fields/NullField.d.ts.map +1 -0
- package/lib/components/fields/NullField.js +0 -1
- package/lib/components/fields/NumberField.d.ts +1 -0
- package/lib/components/fields/NumberField.d.ts.map +1 -0
- package/lib/components/fields/NumberField.js +0 -1
- package/lib/components/fields/ObjectField.d.ts +1 -0
- package/lib/components/fields/ObjectField.d.ts.map +1 -0
- package/lib/components/fields/ObjectField.js +139 -145
- package/lib/components/fields/SchemaField.d.ts +1 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -0
- package/lib/components/fields/SchemaField.js +7 -9
- package/lib/components/fields/StringField.d.ts +1 -0
- package/lib/components/fields/StringField.d.ts.map +1 -0
- package/lib/components/fields/StringField.js +1 -3
- package/lib/components/fields/index.d.ts +1 -0
- package/lib/components/fields/index.d.ts.map +1 -0
- package/lib/components/fields/index.js +8 -9
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +0 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js +0 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js +0 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js +0 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -0
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -0
- package/lib/components/templates/BaseInputTemplate.js +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js +1 -2
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js +0 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +0 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/index.js +3 -4
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.d.ts.map +1 -0
- package/lib/components/templates/DescriptionField.js +0 -1
- package/lib/components/templates/ErrorList.d.ts +1 -0
- package/lib/components/templates/ErrorList.d.ts.map +1 -0
- package/lib/components/templates/ErrorList.js +0 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -0
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldErrorTemplate.js +0 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -0
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldHelpTemplate.js +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -2
- package/lib/components/templates/FieldTemplate/Label.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/Label.js +0 -1
- package/lib/components/templates/FieldTemplate/index.d.ts +2 -1
- package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/index.js +1 -2
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js +0 -1
- package/lib/components/templates/TitleField.d.ts +1 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -0
- package/lib/components/templates/TitleField.js +0 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -0
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -0
- package/lib/components/templates/UnsupportedField.js +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -2
- package/lib/components/templates/index.d.ts +1 -0
- package/lib/components/templates/index.d.ts.map +1 -0
- package/lib/components/templates/index.js +15 -16
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js +0 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateWidget.js +0 -1
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxWidget.js +1 -3
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxesWidget.js +0 -1
- package/lib/components/widgets/ColorWidget.d.ts +1 -0
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -0
- package/lib/components/widgets/ColorWidget.js +0 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateTimeWidget.js +0 -1
- package/lib/components/widgets/DateWidget.d.ts +1 -0
- package/lib/components/widgets/DateWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateWidget.js +0 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -0
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -0
- package/lib/components/widgets/EmailWidget.js +0 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -0
- package/lib/components/widgets/FileWidget.d.ts.map +1 -0
- package/lib/components/widgets/FileWidget.js +1 -3
- package/lib/components/widgets/HiddenWidget.d.ts +1 -0
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -0
- package/lib/components/widgets/HiddenWidget.js +0 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -0
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -0
- package/lib/components/widgets/PasswordWidget.js +0 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -0
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -0
- package/lib/components/widgets/RadioWidget.js +0 -1
- package/lib/components/widgets/RangeWidget.d.ts +1 -0
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -0
- package/lib/components/widgets/RangeWidget.js +0 -1
- package/lib/components/widgets/SelectWidget.d.ts +1 -0
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -0
- package/lib/components/widgets/SelectWidget.js +0 -1
- package/lib/components/widgets/TextWidget.d.ts +1 -0
- package/lib/components/widgets/TextWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextWidget.js +0 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -0
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextareaWidget.js +0 -1
- package/lib/components/widgets/TimeWidget.d.ts +1 -0
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/TimeWidget.js +0 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -0
- package/lib/components/widgets/URLWidget.d.ts.map +1 -0
- package/lib/components/widgets/URLWidget.js +0 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -0
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -0
- package/lib/components/widgets/UpDownWidget.js +0 -1
- package/lib/components/widgets/index.d.ts +1 -0
- package/lib/components/widgets/index.d.ts.map +1 -0
- package/lib/components/widgets/index.js +19 -20
- package/lib/getDefaultRegistry.d.ts +1 -0
- package/lib/getDefaultRegistry.d.ts.map +1 -0
- package/lib/getDefaultRegistry.js +3 -4
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +3 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +2 -1
- package/lib/withTheme.d.ts.map +1 -0
- package/lib/withTheme.js +6 -8
- package/package.json +31 -9
- package/src/tsconfig.json +14 -3
- package/lib/components/Form.js.map +0 -1
- package/lib/components/fields/ArrayField.js.map +0 -1
- package/lib/components/fields/BooleanField.js.map +0 -1
- package/lib/components/fields/MultiSchemaField.js.map +0 -1
- package/lib/components/fields/NullField.js.map +0 -1
- package/lib/components/fields/NumberField.js.map +0 -1
- package/lib/components/fields/ObjectField.js.map +0 -1
- package/lib/components/fields/SchemaField.js.map +0 -1
- package/lib/components/fields/StringField.js.map +0 -1
- package/lib/components/fields/index.js.map +0 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js.map +0 -1
- package/lib/components/templates/BaseInputTemplate.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/index.js.map +0 -1
- package/lib/components/templates/DescriptionField.js.map +0 -1
- package/lib/components/templates/ErrorList.js.map +0 -1
- package/lib/components/templates/FieldErrorTemplate.js.map +0 -1
- package/lib/components/templates/FieldHelpTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/Label.js.map +0 -1
- package/lib/components/templates/FieldTemplate/index.js.map +0 -1
- package/lib/components/templates/ObjectFieldTemplate.js.map +0 -1
- package/lib/components/templates/TitleField.js.map +0 -1
- package/lib/components/templates/UnsupportedField.js.map +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +0 -1
- package/lib/components/templates/index.js.map +0 -1
- package/lib/components/widgets/AltDateTimeWidget.js.map +0 -1
- package/lib/components/widgets/AltDateWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxesWidget.js.map +0 -1
- package/lib/components/widgets/ColorWidget.js.map +0 -1
- package/lib/components/widgets/DateTimeWidget.js.map +0 -1
- package/lib/components/widgets/DateWidget.js.map +0 -1
- package/lib/components/widgets/EmailWidget.js.map +0 -1
- package/lib/components/widgets/FileWidget.js.map +0 -1
- package/lib/components/widgets/HiddenWidget.js.map +0 -1
- package/lib/components/widgets/PasswordWidget.js.map +0 -1
- package/lib/components/widgets/RadioWidget.js.map +0 -1
- package/lib/components/widgets/RangeWidget.js.map +0 -1
- package/lib/components/widgets/SelectWidget.js.map +0 -1
- package/lib/components/widgets/TextWidget.js.map +0 -1
- package/lib/components/widgets/TextareaWidget.js.map +0 -1
- package/lib/components/widgets/TimeWidget.js.map +0 -1
- package/lib/components/widgets/URLWidget.js.map +0 -1
- package/lib/components/widgets/UpDownWidget.js.map +0 -1
- package/lib/components/widgets/index.js.map +0 -1
- package/lib/getDefaultRegistry.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/withTheme.js.map +0 -1
|
@@ -178,3 +178,4 @@ declare class ArrayField<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
178
178
|
* `Field` which is defined as `React.ComponentType<FieldProps<T, S, F>>`, so cast it to make `registry` happy.
|
|
179
179
|
*/
|
|
180
180
|
export default ArrayField;
|
|
181
|
+
//# sourceMappingURL=ArrayField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ArrayField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EASL,WAAW,EACX,UAAU,EACV,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EAEhB,QAAQ,EAET,MAAM,aAAa,CAAC;AAOrB,mEAAmE;AACnE,KAAK,iBAAiB,CAAC,CAAC,IAAI;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC;AAErD,4DAA4D;AAC5D,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,mCAAmC;IACnC,aAAa,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,0EAA0E;IAC1E,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC;AAm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U,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
3
|
import { getTemplate, getWidget, getUiOptions, isFixedItems, allowAdditionalItems, isCustomWidget, optionsList, TranslatableString, ITEMS_KEY, } from '@rjsf/utils';
|
|
4
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
5
|
-
import get from 'lodash/get';
|
|
6
|
-
import isObject from 'lodash/isObject';
|
|
7
|
-
import set from 'lodash/set';
|
|
4
|
+
import cloneDeep from 'lodash-es/cloneDeep.js';
|
|
5
|
+
import get from 'lodash-es/get.js';
|
|
6
|
+
import isObject from 'lodash-es/isObject.js';
|
|
7
|
+
import set from 'lodash-es/set.js';
|
|
8
8
|
import { nanoid } from 'nanoid';
|
|
9
9
|
/** Used to generate a unique ID for an element in a row */
|
|
10
10
|
function generateRowId() {
|
|
@@ -46,189 +46,6 @@ class ArrayField extends Component {
|
|
|
46
46
|
*/
|
|
47
47
|
constructor(props) {
|
|
48
48
|
super(props);
|
|
49
|
-
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
50
|
-
* that the schema is fixed and allows additional items.
|
|
51
|
-
*/
|
|
52
|
-
this._getNewFormDataRow = () => {
|
|
53
|
-
const { schema, registry } = this.props;
|
|
54
|
-
const { schemaUtils } = registry;
|
|
55
|
-
let itemSchema = schema.items;
|
|
56
|
-
if (isFixedItems(schema) && allowAdditionalItems(schema)) {
|
|
57
|
-
itemSchema = schema.additionalItems;
|
|
58
|
-
}
|
|
59
|
-
// Cast this as a T to work around schema utils being for T[] caused by the FieldProps<T[], S, F> call on the class
|
|
60
|
-
return schemaUtils.getDefaultFormState(itemSchema);
|
|
61
|
-
};
|
|
62
|
-
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
63
|
-
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
64
|
-
* keyed data
|
|
65
|
-
*
|
|
66
|
-
* @param event - The event for the click
|
|
67
|
-
*/
|
|
68
|
-
this.onAddClick = (event) => {
|
|
69
|
-
this._handleAddClick(event);
|
|
70
|
-
};
|
|
71
|
-
/** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
|
|
72
|
-
* keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
|
|
73
|
-
* form data converted from the keyed data
|
|
74
|
-
*
|
|
75
|
-
* @param index - The index at which the add button is clicked
|
|
76
|
-
*/
|
|
77
|
-
this.onAddIndexClick = (index) => {
|
|
78
|
-
return (event) => {
|
|
79
|
-
this._handleAddClick(event, index);
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
83
|
-
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
84
|
-
* form data converted from the keyed data
|
|
85
|
-
*
|
|
86
|
-
* @param index - The index at which the copy button is clicked
|
|
87
|
-
*/
|
|
88
|
-
this.onCopyIndexClick = (index) => {
|
|
89
|
-
return (event) => {
|
|
90
|
-
if (event) {
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
}
|
|
93
|
-
const { onChange, errorSchema } = this.props;
|
|
94
|
-
const { keyedFormData } = this.state;
|
|
95
|
-
// refs #195: revalidate to ensure properly reindexing errors
|
|
96
|
-
let newErrorSchema;
|
|
97
|
-
if (errorSchema) {
|
|
98
|
-
newErrorSchema = {};
|
|
99
|
-
for (const idx in errorSchema) {
|
|
100
|
-
const i = parseInt(idx);
|
|
101
|
-
if (i <= index) {
|
|
102
|
-
set(newErrorSchema, [i], errorSchema[idx]);
|
|
103
|
-
}
|
|
104
|
-
else if (i > index) {
|
|
105
|
-
set(newErrorSchema, [i + 1], errorSchema[idx]);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const newKeyedFormDataRow = {
|
|
110
|
-
key: generateRowId(),
|
|
111
|
-
item: cloneDeep(keyedFormData[index].item),
|
|
112
|
-
};
|
|
113
|
-
const newKeyedFormData = [...keyedFormData];
|
|
114
|
-
if (index !== undefined) {
|
|
115
|
-
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
newKeyedFormData.push(newKeyedFormDataRow);
|
|
119
|
-
}
|
|
120
|
-
this.setState({
|
|
121
|
-
keyedFormData: newKeyedFormData,
|
|
122
|
-
updatedKeyedFormData: true,
|
|
123
|
-
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
127
|
-
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
128
|
-
* from the keyed data
|
|
129
|
-
*
|
|
130
|
-
* @param index - The index at which the remove button is clicked
|
|
131
|
-
*/
|
|
132
|
-
this.onDropIndexClick = (index) => {
|
|
133
|
-
return (event) => {
|
|
134
|
-
if (event) {
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
}
|
|
137
|
-
const { onChange, errorSchema } = this.props;
|
|
138
|
-
const { keyedFormData } = this.state;
|
|
139
|
-
// refs #195: revalidate to ensure properly reindexing errors
|
|
140
|
-
let newErrorSchema;
|
|
141
|
-
if (errorSchema) {
|
|
142
|
-
newErrorSchema = {};
|
|
143
|
-
for (const idx in errorSchema) {
|
|
144
|
-
const i = parseInt(idx);
|
|
145
|
-
if (i < index) {
|
|
146
|
-
set(newErrorSchema, [i], errorSchema[idx]);
|
|
147
|
-
}
|
|
148
|
-
else if (i > index) {
|
|
149
|
-
set(newErrorSchema, [i - 1], errorSchema[idx]);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
|
|
154
|
-
this.setState({
|
|
155
|
-
keyedFormData: newKeyedFormData,
|
|
156
|
-
updatedKeyedFormData: true,
|
|
157
|
-
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
161
|
-
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
162
|
-
* plain form data converted from the keyed data
|
|
163
|
-
*
|
|
164
|
-
* @param index - The index of the item to move
|
|
165
|
-
* @param newIndex - The index to where the item is to be moved
|
|
166
|
-
*/
|
|
167
|
-
this.onReorderClick = (index, newIndex) => {
|
|
168
|
-
return (event) => {
|
|
169
|
-
if (event) {
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
event.currentTarget.blur();
|
|
172
|
-
}
|
|
173
|
-
const { onChange, errorSchema } = this.props;
|
|
174
|
-
let newErrorSchema;
|
|
175
|
-
if (errorSchema) {
|
|
176
|
-
newErrorSchema = {};
|
|
177
|
-
for (const idx in errorSchema) {
|
|
178
|
-
const i = parseInt(idx);
|
|
179
|
-
if (i == index) {
|
|
180
|
-
set(newErrorSchema, [newIndex], errorSchema[index]);
|
|
181
|
-
}
|
|
182
|
-
else if (i == newIndex) {
|
|
183
|
-
set(newErrorSchema, [index], errorSchema[newIndex]);
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
set(newErrorSchema, [idx], errorSchema[i]);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
const { keyedFormData } = this.state;
|
|
191
|
-
function reOrderArray() {
|
|
192
|
-
// Copy item
|
|
193
|
-
const _newKeyedFormData = keyedFormData.slice();
|
|
194
|
-
// Moves item from index to newIndex
|
|
195
|
-
_newKeyedFormData.splice(index, 1);
|
|
196
|
-
_newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
|
|
197
|
-
return _newKeyedFormData;
|
|
198
|
-
}
|
|
199
|
-
const newKeyedFormData = reOrderArray();
|
|
200
|
-
this.setState({
|
|
201
|
-
keyedFormData: newKeyedFormData,
|
|
202
|
-
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
206
|
-
* `onChange` callback with the updated form data
|
|
207
|
-
*
|
|
208
|
-
* @param index - The index of the item being changed
|
|
209
|
-
*/
|
|
210
|
-
this.onChangeForIndex = (index) => {
|
|
211
|
-
return (value, newErrorSchema, id) => {
|
|
212
|
-
const { formData, onChange, errorSchema } = this.props;
|
|
213
|
-
const arrayData = Array.isArray(formData) ? formData : [];
|
|
214
|
-
const newFormData = arrayData.map((item, i) => {
|
|
215
|
-
// We need to treat undefined items as nulls to have validation.
|
|
216
|
-
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
217
|
-
const jsonValue = typeof value === 'undefined' ? null : value;
|
|
218
|
-
return index === i ? jsonValue : item;
|
|
219
|
-
});
|
|
220
|
-
onChange(newFormData, errorSchema &&
|
|
221
|
-
errorSchema && {
|
|
222
|
-
...errorSchema,
|
|
223
|
-
[index]: newErrorSchema,
|
|
224
|
-
}, id);
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
/** Callback handler used to change the value for a checkbox */
|
|
228
|
-
this.onSelectChange = (value) => {
|
|
229
|
-
const { onChange, idSchema } = this.props;
|
|
230
|
-
onChange(value, undefined, idSchema && idSchema.$id);
|
|
231
|
-
};
|
|
232
49
|
const { formData = [] } = props;
|
|
233
50
|
const keyedFormData = generateKeyedFormData(formData);
|
|
234
51
|
this.state = {
|
|
@@ -308,6 +125,19 @@ class ArrayField extends Component {
|
|
|
308
125
|
}
|
|
309
126
|
return addable;
|
|
310
127
|
}
|
|
128
|
+
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
129
|
+
* that the schema is fixed and allows additional items.
|
|
130
|
+
*/
|
|
131
|
+
_getNewFormDataRow = () => {
|
|
132
|
+
const { schema, registry } = this.props;
|
|
133
|
+
const { schemaUtils } = registry;
|
|
134
|
+
let itemSchema = schema.items;
|
|
135
|
+
if (isFixedItems(schema) && allowAdditionalItems(schema)) {
|
|
136
|
+
itemSchema = schema.additionalItems;
|
|
137
|
+
}
|
|
138
|
+
// Cast this as a T to work around schema utils being for T[] caused by the FieldProps<T[], S, F> call on the class
|
|
139
|
+
return schemaUtils.getDefaultFormState(itemSchema);
|
|
140
|
+
};
|
|
311
141
|
/** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
|
|
312
142
|
* either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
|
|
313
143
|
* the state, and then returning `onChange()` with the plain form data converted from the keyed data
|
|
@@ -351,6 +181,176 @@ class ArrayField extends Component {
|
|
|
351
181
|
updatedKeyedFormData: true,
|
|
352
182
|
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
353
183
|
}
|
|
184
|
+
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
185
|
+
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
186
|
+
* keyed data
|
|
187
|
+
*
|
|
188
|
+
* @param event - The event for the click
|
|
189
|
+
*/
|
|
190
|
+
onAddClick = (event) => {
|
|
191
|
+
this._handleAddClick(event);
|
|
192
|
+
};
|
|
193
|
+
/** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
|
|
194
|
+
* keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
|
|
195
|
+
* form data converted from the keyed data
|
|
196
|
+
*
|
|
197
|
+
* @param index - The index at which the add button is clicked
|
|
198
|
+
*/
|
|
199
|
+
onAddIndexClick = (index) => {
|
|
200
|
+
return (event) => {
|
|
201
|
+
this._handleAddClick(event, index);
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
205
|
+
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
206
|
+
* form data converted from the keyed data
|
|
207
|
+
*
|
|
208
|
+
* @param index - The index at which the copy button is clicked
|
|
209
|
+
*/
|
|
210
|
+
onCopyIndexClick = (index) => {
|
|
211
|
+
return (event) => {
|
|
212
|
+
if (event) {
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
}
|
|
215
|
+
const { onChange, errorSchema } = this.props;
|
|
216
|
+
const { keyedFormData } = this.state;
|
|
217
|
+
// refs #195: revalidate to ensure properly reindexing errors
|
|
218
|
+
let newErrorSchema;
|
|
219
|
+
if (errorSchema) {
|
|
220
|
+
newErrorSchema = {};
|
|
221
|
+
for (const idx in errorSchema) {
|
|
222
|
+
const i = parseInt(idx);
|
|
223
|
+
if (i <= index) {
|
|
224
|
+
set(newErrorSchema, [i], errorSchema[idx]);
|
|
225
|
+
}
|
|
226
|
+
else if (i > index) {
|
|
227
|
+
set(newErrorSchema, [i + 1], errorSchema[idx]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const newKeyedFormDataRow = {
|
|
232
|
+
key: generateRowId(),
|
|
233
|
+
item: cloneDeep(keyedFormData[index].item),
|
|
234
|
+
};
|
|
235
|
+
const newKeyedFormData = [...keyedFormData];
|
|
236
|
+
if (index !== undefined) {
|
|
237
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
241
|
+
}
|
|
242
|
+
this.setState({
|
|
243
|
+
keyedFormData: newKeyedFormData,
|
|
244
|
+
updatedKeyedFormData: true,
|
|
245
|
+
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
249
|
+
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
250
|
+
* from the keyed data
|
|
251
|
+
*
|
|
252
|
+
* @param index - The index at which the remove button is clicked
|
|
253
|
+
*/
|
|
254
|
+
onDropIndexClick = (index) => {
|
|
255
|
+
return (event) => {
|
|
256
|
+
if (event) {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
}
|
|
259
|
+
const { onChange, errorSchema } = this.props;
|
|
260
|
+
const { keyedFormData } = this.state;
|
|
261
|
+
// refs #195: revalidate to ensure properly reindexing errors
|
|
262
|
+
let newErrorSchema;
|
|
263
|
+
if (errorSchema) {
|
|
264
|
+
newErrorSchema = {};
|
|
265
|
+
for (const idx in errorSchema) {
|
|
266
|
+
const i = parseInt(idx);
|
|
267
|
+
if (i < index) {
|
|
268
|
+
set(newErrorSchema, [i], errorSchema[idx]);
|
|
269
|
+
}
|
|
270
|
+
else if (i > index) {
|
|
271
|
+
set(newErrorSchema, [i - 1], errorSchema[idx]);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
|
|
276
|
+
this.setState({
|
|
277
|
+
keyedFormData: newKeyedFormData,
|
|
278
|
+
updatedKeyedFormData: true,
|
|
279
|
+
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
283
|
+
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
284
|
+
* plain form data converted from the keyed data
|
|
285
|
+
*
|
|
286
|
+
* @param index - The index of the item to move
|
|
287
|
+
* @param newIndex - The index to where the item is to be moved
|
|
288
|
+
*/
|
|
289
|
+
onReorderClick = (index, newIndex) => {
|
|
290
|
+
return (event) => {
|
|
291
|
+
if (event) {
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
event.currentTarget.blur();
|
|
294
|
+
}
|
|
295
|
+
const { onChange, errorSchema } = this.props;
|
|
296
|
+
let newErrorSchema;
|
|
297
|
+
if (errorSchema) {
|
|
298
|
+
newErrorSchema = {};
|
|
299
|
+
for (const idx in errorSchema) {
|
|
300
|
+
const i = parseInt(idx);
|
|
301
|
+
if (i == index) {
|
|
302
|
+
set(newErrorSchema, [newIndex], errorSchema[index]);
|
|
303
|
+
}
|
|
304
|
+
else if (i == newIndex) {
|
|
305
|
+
set(newErrorSchema, [index], errorSchema[newIndex]);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
set(newErrorSchema, [idx], errorSchema[i]);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const { keyedFormData } = this.state;
|
|
313
|
+
function reOrderArray() {
|
|
314
|
+
// Copy item
|
|
315
|
+
const _newKeyedFormData = keyedFormData.slice();
|
|
316
|
+
// Moves item from index to newIndex
|
|
317
|
+
_newKeyedFormData.splice(index, 1);
|
|
318
|
+
_newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
|
|
319
|
+
return _newKeyedFormData;
|
|
320
|
+
}
|
|
321
|
+
const newKeyedFormData = reOrderArray();
|
|
322
|
+
this.setState({
|
|
323
|
+
keyedFormData: newKeyedFormData,
|
|
324
|
+
}, () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema));
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
328
|
+
* `onChange` callback with the updated form data
|
|
329
|
+
*
|
|
330
|
+
* @param index - The index of the item being changed
|
|
331
|
+
*/
|
|
332
|
+
onChangeForIndex = (index) => {
|
|
333
|
+
return (value, newErrorSchema, id) => {
|
|
334
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
335
|
+
const arrayData = Array.isArray(formData) ? formData : [];
|
|
336
|
+
const newFormData = arrayData.map((item, i) => {
|
|
337
|
+
// We need to treat undefined items as nulls to have validation.
|
|
338
|
+
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
339
|
+
const jsonValue = typeof value === 'undefined' ? null : value;
|
|
340
|
+
return index === i ? jsonValue : item;
|
|
341
|
+
});
|
|
342
|
+
onChange(newFormData, errorSchema &&
|
|
343
|
+
errorSchema && {
|
|
344
|
+
...errorSchema,
|
|
345
|
+
[index]: newErrorSchema,
|
|
346
|
+
}, id);
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
/** Callback handler used to change the value for a checkbox */
|
|
350
|
+
onSelectChange = (value) => {
|
|
351
|
+
const { onChange, idSchema } = this.props;
|
|
352
|
+
onChange(value, undefined, idSchema && idSchema.$id);
|
|
353
|
+
};
|
|
354
354
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
355
355
|
*/
|
|
356
356
|
render() {
|
|
@@ -438,38 +438,35 @@ class ArrayField extends Component {
|
|
|
438
438
|
/** Renders an array using the custom widget provided by the user in the `uiSchema`
|
|
439
439
|
*/
|
|
440
440
|
renderCustomWidget() {
|
|
441
|
-
var _a;
|
|
442
441
|
const { schema, idSchema, uiSchema, disabled = false, readonly = false, autofocus = false, required = false, hideError, placeholder, onBlur, onFocus, formData: items = [], registry, rawErrors, name, } = this.props;
|
|
443
442
|
const { widgets, formContext, globalUiOptions, schemaUtils } = registry;
|
|
444
443
|
const { widget, title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
445
444
|
const Widget = getWidget(schema, widget, widgets);
|
|
446
|
-
const label =
|
|
445
|
+
const label = uiTitle ?? schema.title ?? name;
|
|
447
446
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
448
447
|
return (_jsx(Widget, { id: idSchema.$id, name: name, multiple: true, onChange: this.onSelectChange, onBlur: onBlur, onFocus: onFocus, options: options, schema: schema, uiSchema: uiSchema, registry: registry, value: items, disabled: disabled, readonly: readonly, hideError: hideError, required: required, label: label, hideLabel: !displayLabel, placeholder: placeholder, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors }));
|
|
449
448
|
}
|
|
450
449
|
/** Renders an array as a set of checkboxes
|
|
451
450
|
*/
|
|
452
451
|
renderMultiSelect() {
|
|
453
|
-
var _a;
|
|
454
452
|
const { schema, idSchema, uiSchema, formData: items = [], disabled = false, readonly = false, autofocus = false, required = false, placeholder, onBlur, onFocus, registry, rawErrors, name, } = this.props;
|
|
455
453
|
const { widgets, schemaUtils, formContext, globalUiOptions } = registry;
|
|
456
454
|
const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
457
455
|
const enumOptions = optionsList(itemsSchema, uiSchema);
|
|
458
456
|
const { widget = 'select', title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
459
457
|
const Widget = getWidget(schema, widget, widgets);
|
|
460
|
-
const label =
|
|
458
|
+
const label = uiTitle ?? schema.title ?? name;
|
|
461
459
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
462
460
|
return (_jsx(Widget, { id: idSchema.$id, name: name, multiple: true, onChange: this.onSelectChange, onBlur: onBlur, onFocus: onFocus, options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, registry: registry, value: items, disabled: disabled, readonly: readonly, required: required, label: label, hideLabel: !displayLabel, placeholder: placeholder, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors }));
|
|
463
461
|
}
|
|
464
462
|
/** Renders an array of files using the `FileWidget`
|
|
465
463
|
*/
|
|
466
464
|
renderFiles() {
|
|
467
|
-
var _a;
|
|
468
465
|
const { schema, uiSchema, idSchema, name, disabled = false, readonly = false, autofocus = false, required = false, onBlur, onFocus, registry, formData: items = [], rawErrors, } = this.props;
|
|
469
466
|
const { widgets, formContext, globalUiOptions, schemaUtils } = registry;
|
|
470
467
|
const { widget = 'files', title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
471
468
|
const Widget = getWidget(schema, widget, widgets);
|
|
472
|
-
const label =
|
|
469
|
+
const label = uiTitle ?? schema.title ?? name;
|
|
473
470
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
474
471
|
return (_jsx(Widget, { options: options, id: idSchema.$id, name: name, multiple: true, onChange: this.onSelectChange, onBlur: onBlur, onFocus: onFocus, schema: schema, uiSchema: uiSchema, value: items, disabled: disabled, readonly: readonly, required: required, registry: registry, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors, label: label, hideLabel: !displayLabel }));
|
|
475
472
|
}
|
|
@@ -598,4 +595,3 @@ class ArrayField extends Component {
|
|
|
598
595
|
* `Field` which is defined as `React.ComponentType<FieldProps<T, S, F>>`, so cast it to make `registry` happy.
|
|
599
596
|
*/
|
|
600
597
|
export default ArrayField;
|
|
601
|
-
//# sourceMappingURL=ArrayField.js.map
|
|
@@ -6,3 +6,4 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
6
6
|
*/
|
|
7
7
|
declare function BooleanField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export default BooleanField;
|
|
9
|
+
//# sourceMappingURL=BooleanField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BooleanField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/BooleanField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EACV,eAAe,EAEf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAGrB;;;;GAIG;AACH,iBAAS,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACrG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAqG3B;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getWidget, getUiOptions, optionsList, TranslatableString, } from '@rjsf/utils';
|
|
3
|
-
import isObject from 'lodash/isObject';
|
|
3
|
+
import isObject from 'lodash-es/isObject.js';
|
|
4
4
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
5
5
|
* two boolean values based on the various alternatives in the schema.
|
|
6
6
|
*
|
|
7
7
|
* @param props - The `FieldProps` for this template
|
|
8
8
|
*/
|
|
9
9
|
function BooleanField(props) {
|
|
10
|
-
var _a, _b, _c;
|
|
11
10
|
const { schema, name, uiSchema, idSchema, formData, registry, required, disabled, readonly, hideError, autofocus, title, onChange, onFocus, onBlur, rawErrors, } = props;
|
|
12
11
|
const { title: schemaTitle } = schema;
|
|
13
12
|
const { widgets, formContext, translateString, globalUiOptions } = registry;
|
|
@@ -18,7 +17,7 @@ function BooleanField(props) {
|
|
|
18
17
|
const yes = translateString(TranslatableString.YesLabel);
|
|
19
18
|
const no = translateString(TranslatableString.NoLabel);
|
|
20
19
|
let enumOptions;
|
|
21
|
-
const label =
|
|
20
|
+
const label = uiTitle ?? schemaTitle ?? title ?? name;
|
|
22
21
|
if (Array.isArray(schema.oneOf)) {
|
|
23
22
|
enumOptions = optionsList({
|
|
24
23
|
oneOf: schema.oneOf
|
|
@@ -37,7 +36,7 @@ function BooleanField(props) {
|
|
|
37
36
|
else {
|
|
38
37
|
// We deprecated enumNames in v5. It's intentionally omitted from RSJFSchema type, so we need to cast here.
|
|
39
38
|
const schemaWithEnumNames = schema;
|
|
40
|
-
const enums =
|
|
39
|
+
const enums = schema.enum ?? [true, false];
|
|
41
40
|
if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every((v) => typeof v === 'boolean')) {
|
|
42
41
|
enumOptions = [
|
|
43
42
|
{
|
|
@@ -61,4 +60,3 @@ function BooleanField(props) {
|
|
|
61
60
|
return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: idSchema.$id, name: name, onChange: onChange, onFocus: onFocus, onBlur: onBlur, label: label, hideLabel: !displayLabel, value: formData, required: required, disabled: disabled, readonly: readonly, hideError: hideError, registry: registry, formContext: formContext, autofocus: autofocus, rawErrors: rawErrors }));
|
|
62
61
|
}
|
|
63
62
|
export default BooleanField;
|
|
64
|
-
//# sourceMappingURL=BooleanField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAIL,UAAU,EACV,eAAe,EAMf,UAAU,EACV,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAErB,4DAA4D;AAC5D,KAAK,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,IAAI;IAC9D,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,CAAC,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,cAAM,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACnH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,eAAe,CAAC,CAAC,CAAC,CACnB;IACC;;;OAGG;gBACS,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAiBtC;;;;;OAKG;IACH,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC;IAyBjG;;;;;OAKG;IACH,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;IAW/E;;;;;OAKG;IACH,cAAc,YAAa,MAAM,UAqB/B;IAEF,UAAU;IAKV;OACG;IACH,MAAM;CAwGP;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
|
-
import get from 'lodash/get';
|
|
4
|
-
import isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import omit from 'lodash/omit';
|
|
3
|
+
import get from 'lodash-es/get.js';
|
|
4
|
+
import isEmpty from 'lodash-es/isEmpty.js';
|
|
5
|
+
import omit from 'lodash-es/omit.js';
|
|
6
6
|
import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getUiOptions, getWidget, mergeSchemas, ONE_OF_KEY, TranslatableString, } from '@rjsf/utils';
|
|
7
7
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
8
8
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
@@ -16,32 +16,6 @@ class AnyOfField extends Component {
|
|
|
16
16
|
*/
|
|
17
17
|
constructor(props) {
|
|
18
18
|
super(props);
|
|
19
|
-
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
20
|
-
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
21
|
-
* the `onChange` handler.
|
|
22
|
-
*
|
|
23
|
-
* @param option - The new option value being selected
|
|
24
|
-
*/
|
|
25
|
-
this.onOptionChange = (option) => {
|
|
26
|
-
const { selectedOption, retrievedOptions } = this.state;
|
|
27
|
-
const { formData, onChange, registry } = this.props;
|
|
28
|
-
const { schemaUtils } = registry;
|
|
29
|
-
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
30
|
-
if (intOption === selectedOption) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const newOption = intOption >= 0 ? retrievedOptions[intOption] : undefined;
|
|
34
|
-
const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : undefined;
|
|
35
|
-
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
36
|
-
if (newOption) {
|
|
37
|
-
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
38
|
-
// so that only the root objects themselves are created without adding undefined children properties
|
|
39
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
40
|
-
}
|
|
41
|
-
this.setState({ selectedOption: intOption }, () => {
|
|
42
|
-
onChange(newFormData, undefined, this.getFieldId());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
19
|
const { formData, options, registry: { schemaUtils }, } = this.props;
|
|
46
20
|
// cache the retrieved options in state in case they have $refs to save doing it later
|
|
47
21
|
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
@@ -89,6 +63,32 @@ class AnyOfField extends Component {
|
|
|
89
63
|
const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
90
64
|
return option;
|
|
91
65
|
}
|
|
66
|
+
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
67
|
+
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
68
|
+
* the `onChange` handler.
|
|
69
|
+
*
|
|
70
|
+
* @param option - The new option value being selected
|
|
71
|
+
*/
|
|
72
|
+
onOptionChange = (option) => {
|
|
73
|
+
const { selectedOption, retrievedOptions } = this.state;
|
|
74
|
+
const { formData, onChange, registry } = this.props;
|
|
75
|
+
const { schemaUtils } = registry;
|
|
76
|
+
const intOption = option !== undefined ? parseInt(option, 10) : -1;
|
|
77
|
+
if (intOption === selectedOption) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const newOption = intOption >= 0 ? retrievedOptions[intOption] : undefined;
|
|
81
|
+
const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : undefined;
|
|
82
|
+
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
83
|
+
if (newOption) {
|
|
84
|
+
// Call getDefaultFormState to make sure defaults are populated on change. Pass "excludeObjectChildren"
|
|
85
|
+
// so that only the root objects themselves are created without adding undefined children properties
|
|
86
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
|
|
87
|
+
}
|
|
88
|
+
this.setState({ selectedOption: intOption }, () => {
|
|
89
|
+
onChange(newFormData, undefined, this.getFieldId());
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
92
|
getFieldId() {
|
|
93
93
|
const { idSchema, schema } = this.props;
|
|
94
94
|
return `${idSchema.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
|
|
@@ -148,8 +148,7 @@ class AnyOfField extends Component {
|
|
|
148
148
|
value: index,
|
|
149
149
|
};
|
|
150
150
|
});
|
|
151
|
-
return (_jsxs("div", { className: 'panel panel-default panel-body', children: [_jsx("div", { className: 'form-group', children: _jsx(Widget, { id: this.getFieldId(), name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: this.onOptionChange, onBlur: onBlur, onFocus: onFocus, disabled: disabled || isEmpty(enumOptions), multiple: false, rawErrors: rawErrors, errorSchema: fieldErrorSchema, value: selectedOption >= 0 ? selectedOption : undefined, options: { enumOptions, ...uiOptions }, registry: registry, formContext: formContext, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title
|
|
151
|
+
return (_jsxs("div", { className: 'panel panel-default panel-body', children: [_jsx("div", { className: 'form-group', children: _jsx(Widget, { id: this.getFieldId(), name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: this.onOptionChange, onBlur: onBlur, onFocus: onFocus, disabled: disabled || isEmpty(enumOptions), multiple: false, rawErrors: rawErrors, errorSchema: fieldErrorSchema, value: selectedOption >= 0 ? selectedOption : undefined, options: { enumOptions, ...uiOptions }, registry: registry, formContext: formContext, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly }) }), optionSchema && _jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema })] }));
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
export default AnyOfField;
|
|
155
|
-
//# sourceMappingURL=MultiSchemaField.js.map
|
|
@@ -6,3 +6,4 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
6
6
|
*/
|
|
7
7
|
declare function NullField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): null;
|
|
8
8
|
export default NullField;
|
|
9
|
+
//# sourceMappingURL=NullField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NullField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NullField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExF;;;;GAIG;AACH,iBAAS,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,QAU3B;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -18,3 +18,4 @@ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf
|
|
|
18
18
|
*/
|
|
19
19
|
declare function NumberField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export default NumberField;
|
|
21
|
+
//# sourceMappingURL=NumberField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":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