@rjsf/core 5.4.0 → 5.5.1
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.cjs.development.js +158 -49
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +159 -50
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +158 -49
- package/dist/core.umd.development.js.map +1 -1
- package/dist/core.umd.production.min.js +1 -1
- package/dist/core.umd.production.min.js.map +1 -1
- package/package.json +13 -12
|
@@ -133,6 +133,9 @@
|
|
|
133
133
|
function ArrayField(props) {
|
|
134
134
|
var _this;
|
|
135
135
|
_this = _Component.call(this, props) || this;
|
|
136
|
+
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
137
|
+
* that the schema is fixed and allows additional items.
|
|
138
|
+
*/
|
|
136
139
|
_this._getNewFormDataRow = function () {
|
|
137
140
|
var _this$props = _this.props,
|
|
138
141
|
schema = _this$props.schema,
|
|
@@ -145,14 +148,32 @@
|
|
|
145
148
|
// Cast this as a T to work around schema utils being for T[] caused by the FieldProps<T[], S, F> call on the class
|
|
146
149
|
return schemaUtils.getDefaultFormState(itemSchema);
|
|
147
150
|
};
|
|
151
|
+
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
152
|
+
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
153
|
+
* keyed data
|
|
154
|
+
*
|
|
155
|
+
* @param event - The event for the click
|
|
156
|
+
*/
|
|
148
157
|
_this.onAddClick = function (event) {
|
|
149
158
|
_this._handleAddClick(event);
|
|
150
159
|
};
|
|
160
|
+
/** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
|
|
161
|
+
* keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
|
|
162
|
+
* form data converted from the keyed data
|
|
163
|
+
*
|
|
164
|
+
* @param index - The index at which the add button is clicked
|
|
165
|
+
*/
|
|
151
166
|
_this.onAddIndexClick = function (index) {
|
|
152
167
|
return function (event) {
|
|
153
168
|
_this._handleAddClick(event, index);
|
|
154
169
|
};
|
|
155
170
|
};
|
|
171
|
+
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
172
|
+
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
173
|
+
* form data converted from the keyed data
|
|
174
|
+
*
|
|
175
|
+
* @param index - The index at which the copy button is clicked
|
|
176
|
+
*/
|
|
156
177
|
_this.onCopyIndexClick = function (index) {
|
|
157
178
|
return function (event) {
|
|
158
179
|
if (event) {
|
|
@@ -178,6 +199,12 @@
|
|
|
178
199
|
});
|
|
179
200
|
};
|
|
180
201
|
};
|
|
202
|
+
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
203
|
+
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
204
|
+
* from the keyed data
|
|
205
|
+
*
|
|
206
|
+
* @param index - The index at which the remove button is clicked
|
|
207
|
+
*/
|
|
181
208
|
_this.onDropIndexClick = function (index) {
|
|
182
209
|
return function (event) {
|
|
183
210
|
if (event) {
|
|
@@ -211,6 +238,13 @@
|
|
|
211
238
|
});
|
|
212
239
|
};
|
|
213
240
|
};
|
|
241
|
+
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
242
|
+
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
243
|
+
* plain form data converted from the keyed data
|
|
244
|
+
*
|
|
245
|
+
* @param index - The index of the item to move
|
|
246
|
+
* @param newIndex - The index to where the item is to be moved
|
|
247
|
+
*/
|
|
214
248
|
_this.onReorderClick = function (index, newIndex) {
|
|
215
249
|
return function (event) {
|
|
216
250
|
if (event) {
|
|
@@ -251,6 +285,11 @@
|
|
|
251
285
|
});
|
|
252
286
|
};
|
|
253
287
|
};
|
|
288
|
+
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
289
|
+
* `onChange` callback with the updated form data
|
|
290
|
+
*
|
|
291
|
+
* @param index - The index of the item being changed
|
|
292
|
+
*/
|
|
254
293
|
_this.onChangeForIndex = function (index) {
|
|
255
294
|
return function (value, newErrorSchema, id) {
|
|
256
295
|
var _extends2;
|
|
@@ -268,6 +307,7 @@
|
|
|
268
307
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends2 = {}, _extends2[index] = newErrorSchema, _extends2)), id);
|
|
269
308
|
};
|
|
270
309
|
};
|
|
310
|
+
/** Callback handler used to change the value for a checkbox */
|
|
271
311
|
_this.onSelectChange = function (value) {
|
|
272
312
|
var _this$props5 = _this.props,
|
|
273
313
|
onChange = _this$props5.onChange,
|
|
@@ -351,10 +391,7 @@
|
|
|
351
391
|
}
|
|
352
392
|
}
|
|
353
393
|
return addable;
|
|
354
|
-
}
|
|
355
|
-
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
356
|
-
* that the schema is fixed and allows additional items.
|
|
357
|
-
*/;
|
|
394
|
+
};
|
|
358
395
|
/** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
|
|
359
396
|
* either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
|
|
360
397
|
* the state, and then returning `onChange()` with the plain form data converted from the keyed data
|
|
@@ -384,13 +421,7 @@
|
|
|
384
421
|
}, function () {
|
|
385
422
|
return onChange(keyedToPlainFormData(newKeyedFormData));
|
|
386
423
|
});
|
|
387
|
-
}
|
|
388
|
-
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
389
|
-
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
390
|
-
* keyed data
|
|
391
|
-
*
|
|
392
|
-
* @param event - The event for the click
|
|
393
|
-
*/;
|
|
424
|
+
};
|
|
394
425
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
395
426
|
*/
|
|
396
427
|
_proto.render = function render() {
|
|
@@ -1011,6 +1042,12 @@
|
|
|
1011
1042
|
function AnyOfField(props) {
|
|
1012
1043
|
var _this;
|
|
1013
1044
|
_this = _Component.call(this, props) || this;
|
|
1045
|
+
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
1046
|
+
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
1047
|
+
* the `onChange` handler.
|
|
1048
|
+
*
|
|
1049
|
+
* @param option - The new option value being selected
|
|
1050
|
+
*/
|
|
1014
1051
|
_this.onOptionChange = function (option) {
|
|
1015
1052
|
var _this$state = _this.state,
|
|
1016
1053
|
selectedOption = _this$state.selectedOption,
|
|
@@ -1106,13 +1143,7 @@
|
|
|
1106
1143
|
// If the form data matches none of the options, use the currently selected
|
|
1107
1144
|
// option, assuming it's available; otherwise use the first option
|
|
1108
1145
|
return selectedOption || 0;
|
|
1109
|
-
}
|
|
1110
|
-
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
1111
|
-
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
1112
|
-
* the `onChange` handler.
|
|
1113
|
-
*
|
|
1114
|
-
* @param option - The new option value being selected
|
|
1115
|
-
*/;
|
|
1146
|
+
};
|
|
1116
1147
|
_proto.getFieldId = function getFieldId() {
|
|
1117
1148
|
var _this$props4 = this.props,
|
|
1118
1149
|
idSchema = _this$props4.idSchema,
|
|
@@ -1299,10 +1330,19 @@
|
|
|
1299
1330
|
args[_key] = arguments[_key];
|
|
1300
1331
|
}
|
|
1301
1332
|
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
1333
|
+
/** Set up the initial state */
|
|
1302
1334
|
_this.state = {
|
|
1303
1335
|
wasPropertyKeyModified: false,
|
|
1304
1336
|
additionalProperties: {}
|
|
1305
1337
|
};
|
|
1338
|
+
/** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
|
|
1339
|
+
* to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
|
|
1340
|
+
* formData.
|
|
1341
|
+
*
|
|
1342
|
+
* @param name - The name of the property
|
|
1343
|
+
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
1344
|
+
* @returns - The onPropertyChange callback for the `name` property
|
|
1345
|
+
*/
|
|
1306
1346
|
_this.onPropertyChange = function (name, addedByAdditionalProperties) {
|
|
1307
1347
|
if (addedByAdditionalProperties === void 0) {
|
|
1308
1348
|
addedByAdditionalProperties = false;
|
|
@@ -1327,6 +1367,12 @@
|
|
|
1327
1367
|
onChange(newFormData, errorSchema && errorSchema && _extends({}, errorSchema, (_extends3 = {}, _extends3[name] = newErrorSchema, _extends3)), id);
|
|
1328
1368
|
};
|
|
1329
1369
|
};
|
|
1370
|
+
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
1371
|
+
* and calls the `onChange` callback with it
|
|
1372
|
+
*
|
|
1373
|
+
* @param key - The key for which the drop callback is desired
|
|
1374
|
+
* @returns - The drop property click callback
|
|
1375
|
+
*/
|
|
1330
1376
|
_this.onDropPropertyClick = function (key) {
|
|
1331
1377
|
return function (event) {
|
|
1332
1378
|
event.preventDefault();
|
|
@@ -1338,6 +1384,13 @@
|
|
|
1338
1384
|
onChange(copiedFormData);
|
|
1339
1385
|
};
|
|
1340
1386
|
};
|
|
1387
|
+
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
1388
|
+
* that is already not assigned is found.
|
|
1389
|
+
*
|
|
1390
|
+
* @param preferredKey - The preferred name of a new key
|
|
1391
|
+
* @param [formData] - The form data in which to check if the desired key already exists
|
|
1392
|
+
* @returns - The name of the next available key from `preferredKey`
|
|
1393
|
+
*/
|
|
1341
1394
|
_this.getAvailableKey = function (preferredKey, formData) {
|
|
1342
1395
|
var _this$props3 = _this.props,
|
|
1343
1396
|
uiSchema = _this$props3.uiSchema,
|
|
@@ -1352,6 +1405,12 @@
|
|
|
1352
1405
|
}
|
|
1353
1406
|
return newKey;
|
|
1354
1407
|
};
|
|
1408
|
+
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
1409
|
+
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
1410
|
+
*
|
|
1411
|
+
* @param oldValue - The old value of a field
|
|
1412
|
+
* @returns - The key change callback function
|
|
1413
|
+
*/
|
|
1355
1414
|
_this.onKeyChange = function (oldValue) {
|
|
1356
1415
|
return function (value, newErrorSchema) {
|
|
1357
1416
|
var _newKeys, _extends4;
|
|
@@ -1377,6 +1436,11 @@
|
|
|
1377
1436
|
onChange(renamedObj, errorSchema && errorSchema && _extends({}, errorSchema, (_extends4 = {}, _extends4[value] = newErrorSchema, _extends4)));
|
|
1378
1437
|
};
|
|
1379
1438
|
};
|
|
1439
|
+
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
1440
|
+
* default data for that field has been added to the formData.
|
|
1441
|
+
*
|
|
1442
|
+
* @param schema - The schema element to which the new property is being added
|
|
1443
|
+
*/
|
|
1380
1444
|
_this.handleAddClick = function (schema) {
|
|
1381
1445
|
return function () {
|
|
1382
1446
|
if (!schema.additionalProperties) {
|
|
@@ -1419,15 +1483,7 @@
|
|
|
1419
1483
|
_proto.isRequired = function isRequired(name) {
|
|
1420
1484
|
var schema = this.props.schema;
|
|
1421
1485
|
return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
|
|
1422
|
-
}
|
|
1423
|
-
/** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
|
|
1424
|
-
* to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
|
|
1425
|
-
* formData.
|
|
1426
|
-
*
|
|
1427
|
-
* @param name - The name of the property
|
|
1428
|
-
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
1429
|
-
* @returns - The onPropertyChange callback for the `name` property
|
|
1430
|
-
*/;
|
|
1486
|
+
};
|
|
1431
1487
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
1432
1488
|
*
|
|
1433
1489
|
* @param type - The type of the new additional schema property
|
|
@@ -1450,12 +1506,7 @@
|
|
|
1450
1506
|
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
1451
1507
|
return translateString(utils.TranslatableString.NewStringDefault);
|
|
1452
1508
|
}
|
|
1453
|
-
}
|
|
1454
|
-
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
1455
|
-
* default data for that field has been added to the formData.
|
|
1456
|
-
*
|
|
1457
|
-
* @param schema - The schema element to which the new property is being added
|
|
1458
|
-
*/;
|
|
1509
|
+
};
|
|
1459
1510
|
/** Renders the `ObjectField` from the given props
|
|
1460
1511
|
*/
|
|
1461
1512
|
_proto.render = function render() {
|
|
@@ -1559,6 +1610,7 @@
|
|
|
1559
1610
|
required: required,
|
|
1560
1611
|
idSchema: idSchema,
|
|
1561
1612
|
uiSchema: uiSchema,
|
|
1613
|
+
errorSchema: errorSchema,
|
|
1562
1614
|
schema: schema,
|
|
1563
1615
|
formData: formData,
|
|
1564
1616
|
formContext: formContext,
|
|
@@ -2123,7 +2175,7 @@
|
|
|
2123
2175
|
});
|
|
2124
2176
|
}
|
|
2125
2177
|
|
|
2126
|
-
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type"];
|
|
2178
|
+
var _excluded$3 = ["id", "name", "value", "readonly", "disabled", "autofocus", "onBlur", "onFocus", "onChange", "onChangeOverride", "options", "schema", "uiSchema", "formContext", "registry", "rawErrors", "type", "hideLabel", "hideError"];
|
|
2127
2179
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
2128
2180
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
2129
2181
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -2211,7 +2263,7 @@
|
|
|
2211
2263
|
children: jsxRuntime.jsx("button", _extends({
|
|
2212
2264
|
type: 'submit'
|
|
2213
2265
|
}, submitButtonProps, {
|
|
2214
|
-
className: "btn btn-info " + submitButtonProps.className,
|
|
2266
|
+
className: "btn btn-info " + (submitButtonProps.className || ''),
|
|
2215
2267
|
children: submitText
|
|
2216
2268
|
}))
|
|
2217
2269
|
});
|
|
@@ -3197,6 +3249,7 @@
|
|
|
3197
3249
|
function FileWidget(props) {
|
|
3198
3250
|
var disabled = props.disabled,
|
|
3199
3251
|
readonly = props.readonly,
|
|
3252
|
+
required = props.required,
|
|
3200
3253
|
multiple = props.multiple,
|
|
3201
3254
|
onChange = props.onChange,
|
|
3202
3255
|
value = props.value,
|
|
@@ -3229,6 +3282,7 @@
|
|
|
3229
3282
|
children: [jsxRuntime.jsx(BaseInputTemplate, _extends({}, props, {
|
|
3230
3283
|
disabled: disabled || readonly,
|
|
3231
3284
|
type: 'file',
|
|
3285
|
+
required: value ? false : required,
|
|
3232
3286
|
onChangeOverride: handleChange,
|
|
3233
3287
|
value: '',
|
|
3234
3288
|
accept: options.accept ? String(options.accept) : undefined
|
|
@@ -3286,8 +3340,6 @@
|
|
|
3286
3340
|
onFocus = _ref.onFocus,
|
|
3287
3341
|
onChange = _ref.onChange,
|
|
3288
3342
|
id = _ref.id;
|
|
3289
|
-
// Generating a unique field name to identify this set of radio buttons
|
|
3290
|
-
var name = Math.random().toString();
|
|
3291
3343
|
var enumOptions = options.enumOptions,
|
|
3292
3344
|
enumDisabled = options.enumDisabled,
|
|
3293
3345
|
inline = options.inline,
|
|
@@ -3315,7 +3367,7 @@
|
|
|
3315
3367
|
type: 'radio',
|
|
3316
3368
|
id: utils.optionId(id, i),
|
|
3317
3369
|
checked: checked,
|
|
3318
|
-
name:
|
|
3370
|
+
name: id,
|
|
3319
3371
|
required: required,
|
|
3320
3372
|
value: String(i),
|
|
3321
3373
|
disabled: disabled || itemDisabled || readonly,
|
|
@@ -3588,10 +3640,6 @@
|
|
|
3588
3640
|
/** The `Form` component renders the outer form and all the fields defined in the `schema` */
|
|
3589
3641
|
var Form = /*#__PURE__*/function (_Component) {
|
|
3590
3642
|
_inheritsLoose(Form, _Component);
|
|
3591
|
-
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
3592
|
-
* provide any possible type here
|
|
3593
|
-
*/
|
|
3594
|
-
|
|
3595
3643
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
3596
3644
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
3597
3645
|
* state construction.
|
|
@@ -3601,7 +3649,15 @@
|
|
|
3601
3649
|
function Form(props) {
|
|
3602
3650
|
var _this;
|
|
3603
3651
|
_this = _Component.call(this, props) || this;
|
|
3652
|
+
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
3653
|
+
* provide any possible type here
|
|
3654
|
+
*/
|
|
3604
3655
|
_this.formElement = void 0;
|
|
3656
|
+
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
3657
|
+
*
|
|
3658
|
+
* @param formData - The data for the `Form`
|
|
3659
|
+
* @param fields - The fields to keep while filtering
|
|
3660
|
+
*/
|
|
3605
3661
|
_this.getUsedFormData = function (formData, fields) {
|
|
3606
3662
|
// For the case of a single input form
|
|
3607
3663
|
if (fields.length === 0 && typeof formData !== 'object') {
|
|
@@ -3616,6 +3672,11 @@
|
|
|
3616
3672
|
}
|
|
3617
3673
|
return data;
|
|
3618
3674
|
};
|
|
3675
|
+
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
3676
|
+
*
|
|
3677
|
+
* @param pathSchema - The `PathSchema` object for the form
|
|
3678
|
+
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
3679
|
+
*/
|
|
3619
3680
|
_this.getFieldNames = function (pathSchema, formData) {
|
|
3620
3681
|
var getAllPaths = function getAllPaths(_obj, acc, paths) {
|
|
3621
3682
|
if (acc === void 0) {
|
|
@@ -3650,6 +3711,17 @@
|
|
|
3650
3711
|
};
|
|
3651
3712
|
return getAllPaths(pathSchema);
|
|
3652
3713
|
};
|
|
3714
|
+
/** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
|
|
3715
|
+
* `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
|
|
3716
|
+
* then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filterer to remove any extra data not
|
|
3717
|
+
* in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
|
|
3718
|
+
* updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
|
|
3719
|
+
* callback will be called if specified with the updated state.
|
|
3720
|
+
*
|
|
3721
|
+
* @param formData - The new form data from a change to a field
|
|
3722
|
+
* @param newErrorSchema - The new `ErrorSchema` based on the field change
|
|
3723
|
+
* @param id - The id of the field that caused the change
|
|
3724
|
+
*/
|
|
3653
3725
|
_this.onChange = function (formData, newErrorSchema, id) {
|
|
3654
3726
|
var _this$props = _this.props,
|
|
3655
3727
|
extraErrors = _this$props.extraErrors,
|
|
@@ -3710,6 +3782,12 @@
|
|
|
3710
3782
|
return onChange && onChange(_extends({}, _this.state, state), id);
|
|
3711
3783
|
});
|
|
3712
3784
|
};
|
|
3785
|
+
/**
|
|
3786
|
+
* Callback function to handle reset form data.
|
|
3787
|
+
* - Reset all fields with default values.
|
|
3788
|
+
* - Reset validations and errors
|
|
3789
|
+
*
|
|
3790
|
+
*/
|
|
3713
3791
|
_this.reset = function () {
|
|
3714
3792
|
var onChange = _this.props.onChange;
|
|
3715
3793
|
var newState = _this.getStateFromProps(_this.props, undefined);
|
|
@@ -3725,18 +3803,38 @@
|
|
|
3725
3803
|
return onChange && onChange(_extends({}, _this.state, state));
|
|
3726
3804
|
});
|
|
3727
3805
|
};
|
|
3806
|
+
/** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
|
|
3807
|
+
* was provided.
|
|
3808
|
+
*
|
|
3809
|
+
* @param id - The unique `id` of the field that was blurred
|
|
3810
|
+
* @param data - The data associated with the field that was blurred
|
|
3811
|
+
*/
|
|
3728
3812
|
_this.onBlur = function (id, data) {
|
|
3729
3813
|
var onBlur = _this.props.onBlur;
|
|
3730
3814
|
if (onBlur) {
|
|
3731
3815
|
onBlur(id, data);
|
|
3732
3816
|
}
|
|
3733
3817
|
};
|
|
3818
|
+
/** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
|
|
3819
|
+
* was provided.
|
|
3820
|
+
*
|
|
3821
|
+
* @param id - The unique `id` of the field that was focused
|
|
3822
|
+
* @param data - The data associated with the field that was focused
|
|
3823
|
+
*/
|
|
3734
3824
|
_this.onFocus = function (id, data) {
|
|
3735
3825
|
var onFocus = _this.props.onFocus;
|
|
3736
3826
|
if (onFocus) {
|
|
3737
3827
|
onFocus(id, data);
|
|
3738
3828
|
}
|
|
3739
3829
|
};
|
|
3830
|
+
/** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
|
|
3831
|
+
* happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
|
|
3832
|
+
* `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
|
|
3833
|
+
* via the `onError()` callback unless validation is disabled. Finally it will add in any `extraErrors` and then call
|
|
3834
|
+
* back the `onSubmit` callback if it was provided.
|
|
3835
|
+
*
|
|
3836
|
+
* @param event - The submit HTML form event
|
|
3837
|
+
*/
|
|
3740
3838
|
_this.onSubmit = function (event) {
|
|
3741
3839
|
event.preventDefault();
|
|
3742
3840
|
if (event.target !== event.currentTarget) {
|
|
@@ -3929,12 +4027,7 @@
|
|
|
3929
4027
|
});
|
|
3930
4028
|
}
|
|
3931
4029
|
return null;
|
|
3932
|
-
}
|
|
3933
|
-
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
3934
|
-
*
|
|
3935
|
-
* @param formData - The data for the `Form`
|
|
3936
|
-
* @param fields - The fields to keep while filtering
|
|
3937
|
-
*/;
|
|
4030
|
+
};
|
|
3938
4031
|
/** Returns the registry for the form */
|
|
3939
4032
|
_proto.getRegistry = function getRegistry() {
|
|
3940
4033
|
var _this$props$templates;
|
|
@@ -3998,6 +4091,10 @@
|
|
|
3998
4091
|
// if not an exact match, try finding an input starting with the element id (like radio buttons or checkboxes)
|
|
3999
4092
|
field = this.formElement.current.querySelector("input[id^=" + elementId);
|
|
4000
4093
|
}
|
|
4094
|
+
if (field.length) {
|
|
4095
|
+
// If we got a list with length > 0
|
|
4096
|
+
field = field[0];
|
|
4097
|
+
}
|
|
4001
4098
|
if (field) {
|
|
4002
4099
|
field.focus();
|
|
4003
4100
|
}
|
|
@@ -4048,6 +4145,7 @@
|
|
|
4048
4145
|
* needed along with the submit button or any children of the form.
|
|
4049
4146
|
*/;
|
|
4050
4147
|
_proto.render = function render() {
|
|
4148
|
+
var _UI_OPTIONS_KEY, _submitUiSchema;
|
|
4051
4149
|
var _this$props7 = this.props,
|
|
4052
4150
|
children = _this$props7.children,
|
|
4053
4151
|
id = _this$props7.id,
|
|
@@ -4087,6 +4185,17 @@
|
|
|
4087
4185
|
// NOTE, the `as` prop is native to `semantic-ui` and is emulated in the `material-ui` theme
|
|
4088
4186
|
var as = _internalFormWrapper ? tagName : undefined;
|
|
4089
4187
|
var FormTag = _internalFormWrapper || tagName || 'form';
|
|
4188
|
+
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
4189
|
+
_getUiOptions$SUBMIT_ = _getUiOptions[utils.SUBMIT_BTN_OPTIONS_KEY],
|
|
4190
|
+
submitOptions = _getUiOptions$SUBMIT_ === void 0 ? {} : _getUiOptions$SUBMIT_;
|
|
4191
|
+
if (disabled) {
|
|
4192
|
+
submitOptions = _extends({}, submitOptions, {
|
|
4193
|
+
props: _extends({}, submitOptions.props, {
|
|
4194
|
+
disabled: true
|
|
4195
|
+
})
|
|
4196
|
+
});
|
|
4197
|
+
}
|
|
4198
|
+
var submitUiSchema = (_submitUiSchema = {}, _submitUiSchema[utils.UI_OPTIONS_KEY] = (_UI_OPTIONS_KEY = {}, _UI_OPTIONS_KEY[utils.SUBMIT_BTN_OPTIONS_KEY] = submitOptions, _UI_OPTIONS_KEY), _submitUiSchema);
|
|
4090
4199
|
return jsxRuntime.jsxs(FormTag, {
|
|
4091
4200
|
className: className ? className : 'rjsf',
|
|
4092
4201
|
id: id,
|
|
@@ -4118,7 +4227,7 @@
|
|
|
4118
4227
|
disabled: disabled,
|
|
4119
4228
|
readonly: readonly
|
|
4120
4229
|
}), children ? children : jsxRuntime.jsx(SubmitButton, {
|
|
4121
|
-
uiSchema:
|
|
4230
|
+
uiSchema: submitUiSchema,
|
|
4122
4231
|
registry: registry
|
|
4123
4232
|
}), showErrorList === 'bottom' && this.renderErrors(registry)]
|
|
4124
4233
|
});
|