@rjsf/core 5.0.2 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs.development.js +73 -31
- 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 +72 -31
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +76 -35
- 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/dist/index.d.ts +10 -0
- package/package.json +8 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/omit'), require('lodash-es/has'), require('lodash-es/unset')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/omit', 'lodash-es/has', 'lodash-es/unset'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.React, global.utils, global.get, global.isEmpty, global._pick, global.isObject, global.set, global.nanoid, global.omit, global.has, global.unset));
|
|
5
|
-
})(this, (function (exports, React, utils, get, isEmpty, _pick, isObject, set, nanoid, omit, has, unset) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash-es/get'), require('lodash-es/isEmpty'), require('lodash-es/pick'), require('lodash-es/toPath'), require('lodash-es/isObject'), require('lodash-es/set'), require('nanoid'), require('lodash-es/omit'), require('lodash-es/has'), require('lodash-es/unset')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash-es/get', 'lodash-es/isEmpty', 'lodash-es/pick', 'lodash-es/toPath', 'lodash-es/isObject', 'lodash-es/set', 'nanoid', 'lodash-es/omit', 'lodash-es/has', 'lodash-es/unset'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.React, global.utils, global.get, global.isEmpty, global._pick, global._toPath, global.isObject, global.set, global.nanoid, global.omit, global.has, global.unset));
|
|
5
|
+
})(this, (function (exports, React, utils, get, isEmpty, _pick, _toPath, isObject, set, nanoid, omit, has, unset) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
11
11
|
var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
|
|
12
12
|
var _pick__default = /*#__PURE__*/_interopDefaultLegacy(_pick);
|
|
13
|
+
var _toPath__default = /*#__PURE__*/_interopDefaultLegacy(_toPath);
|
|
13
14
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
14
15
|
var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
|
|
15
16
|
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
@@ -2633,6 +2634,7 @@
|
|
|
2633
2634
|
className: "list-inline"
|
|
2634
2635
|
}, dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
2635
2636
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2637
|
+
className: "list-inline-item",
|
|
2636
2638
|
key: i
|
|
2637
2639
|
}, /*#__PURE__*/React__default["default"].createElement(DateElement, _extends({
|
|
2638
2640
|
rootId: id,
|
|
@@ -2645,11 +2647,15 @@
|
|
|
2645
2647
|
onFocus: onFocus,
|
|
2646
2648
|
autofocus: autofocus && i === 0
|
|
2647
2649
|
})));
|
|
2648
|
-
}), (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /*#__PURE__*/React__default["default"].createElement("li",
|
|
2650
|
+
}), (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2651
|
+
className: "list-inline-item"
|
|
2652
|
+
}, /*#__PURE__*/React__default["default"].createElement("a", {
|
|
2649
2653
|
href: "#",
|
|
2650
2654
|
className: "btn btn-info btn-now",
|
|
2651
2655
|
onClick: handleSetNow
|
|
2652
|
-
}, "Now")), (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /*#__PURE__*/React__default["default"].createElement("li",
|
|
2656
|
+
}, "Now")), (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2657
|
+
className: "list-inline-item"
|
|
2658
|
+
}, /*#__PURE__*/React__default["default"].createElement("a", {
|
|
2653
2659
|
href: "#",
|
|
2654
2660
|
className: "btn btn-warning btn-clear",
|
|
2655
2661
|
onClick: handleClear
|
|
@@ -3522,7 +3528,7 @@
|
|
|
3522
3528
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(props.validator, rootSchema)) {
|
|
3523
3529
|
schemaUtils = utils.createSchemaUtils(props.validator, rootSchema);
|
|
3524
3530
|
}
|
|
3525
|
-
var formData = schemaUtils.getDefaultFormState(schema, inputFormData
|
|
3531
|
+
var formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3526
3532
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3527
3533
|
var getCurrentErrors = function getCurrentErrors() {
|
|
3528
3534
|
if (props.noValidate) {
|
|
@@ -3662,15 +3668,47 @@
|
|
|
3662
3668
|
this.formElement.current.requestSubmit();
|
|
3663
3669
|
}
|
|
3664
3670
|
}
|
|
3671
|
+
/** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
|
|
3672
|
+
* field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
|
|
3673
|
+
* id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
|
|
3674
|
+
*
|
|
3675
|
+
* @param error - The error on which to focus
|
|
3676
|
+
*/;
|
|
3677
|
+
_proto.focusOnError = function focusOnError(error) {
|
|
3678
|
+
var _this$props4 = this.props,
|
|
3679
|
+
_this$props4$idPrefix = _this$props4.idPrefix,
|
|
3680
|
+
idPrefix = _this$props4$idPrefix === void 0 ? "root" : _this$props4$idPrefix,
|
|
3681
|
+
_this$props4$idSepara = _this$props4.idSeparator,
|
|
3682
|
+
idSeparator = _this$props4$idSepara === void 0 ? "_" : _this$props4$idSepara;
|
|
3683
|
+
var property = error.property;
|
|
3684
|
+
var path = _toPath__default["default"](property);
|
|
3685
|
+
if (path[0] === "") {
|
|
3686
|
+
// Most of the time the `.foo` property results in the first element being empty, so replace it with the idPrefix
|
|
3687
|
+
path[0] = idPrefix;
|
|
3688
|
+
} else {
|
|
3689
|
+
// Otherwise insert the idPrefix into the first location using unshift
|
|
3690
|
+
path.unshift(idPrefix);
|
|
3691
|
+
}
|
|
3692
|
+
var elementId = path.join(idSeparator);
|
|
3693
|
+
var field = this.formElement.current.elements[elementId];
|
|
3694
|
+
if (!field) {
|
|
3695
|
+
// if not an exact match, try finding an input starting with the element id (like radio buttons or checkboxes)
|
|
3696
|
+
field = this.formElement.current.querySelector("input[id^=" + elementId);
|
|
3697
|
+
}
|
|
3698
|
+
if (field) {
|
|
3699
|
+
field.focus();
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3665
3702
|
/** Programmatically validate the form. If `onError` is provided, then it will be called with the list of errors the
|
|
3666
3703
|
* same way as would happen on form submission.
|
|
3667
3704
|
*
|
|
3668
3705
|
* @returns - True if the form is valid, false otherwise.
|
|
3669
3706
|
*/;
|
|
3670
3707
|
_proto.validateForm = function validateForm() {
|
|
3671
|
-
var _this$
|
|
3672
|
-
extraErrors = _this$
|
|
3673
|
-
|
|
3708
|
+
var _this$props5 = this.props,
|
|
3709
|
+
extraErrors = _this$props5.extraErrors,
|
|
3710
|
+
focusOnFirstError = _this$props5.focusOnFirstError,
|
|
3711
|
+
onError = _this$props5.onError;
|
|
3674
3712
|
var formData = this.state.formData;
|
|
3675
3713
|
var schemaUtils = this.state.schemaUtils;
|
|
3676
3714
|
var schemaValidation = this.validate(formData);
|
|
@@ -3684,6 +3722,9 @@
|
|
|
3684
3722
|
errorSchema = merged.errorSchema;
|
|
3685
3723
|
errors = merged.errors;
|
|
3686
3724
|
}
|
|
3725
|
+
if (focusOnFirstError) {
|
|
3726
|
+
this.focusOnError(schemaValidation.errors[0]);
|
|
3727
|
+
}
|
|
3687
3728
|
this.setState({
|
|
3688
3729
|
errors: errors,
|
|
3689
3730
|
errorSchema: errorSchema,
|
|
@@ -3704,31 +3745,31 @@
|
|
|
3704
3745
|
* needed along with the submit button or any children of the form.
|
|
3705
3746
|
*/;
|
|
3706
3747
|
_proto.render = function render() {
|
|
3707
|
-
var _this$
|
|
3708
|
-
children = _this$
|
|
3709
|
-
id = _this$
|
|
3710
|
-
idPrefix = _this$
|
|
3711
|
-
idSeparator = _this$
|
|
3712
|
-
_this$
|
|
3713
|
-
className = _this$
|
|
3714
|
-
tagName = _this$
|
|
3715
|
-
name = _this$
|
|
3716
|
-
method = _this$
|
|
3717
|
-
target = _this$
|
|
3718
|
-
action = _this$
|
|
3719
|
-
autoComplete = _this$
|
|
3720
|
-
enctype = _this$
|
|
3721
|
-
acceptcharset = _this$
|
|
3722
|
-
_this$
|
|
3723
|
-
noHtml5Validate = _this$
|
|
3724
|
-
_this$
|
|
3725
|
-
disabled = _this$
|
|
3726
|
-
_this$
|
|
3727
|
-
readonly = _this$
|
|
3728
|
-
formContext = _this$
|
|
3729
|
-
_this$
|
|
3730
|
-
showErrorList = _this$
|
|
3731
|
-
_internalFormWrapper = _this$
|
|
3748
|
+
var _this$props6 = this.props,
|
|
3749
|
+
children = _this$props6.children,
|
|
3750
|
+
id = _this$props6.id,
|
|
3751
|
+
idPrefix = _this$props6.idPrefix,
|
|
3752
|
+
idSeparator = _this$props6.idSeparator,
|
|
3753
|
+
_this$props6$classNam = _this$props6.className,
|
|
3754
|
+
className = _this$props6$classNam === void 0 ? "" : _this$props6$classNam,
|
|
3755
|
+
tagName = _this$props6.tagName,
|
|
3756
|
+
name = _this$props6.name,
|
|
3757
|
+
method = _this$props6.method,
|
|
3758
|
+
target = _this$props6.target,
|
|
3759
|
+
action = _this$props6.action,
|
|
3760
|
+
autoComplete = _this$props6.autoComplete,
|
|
3761
|
+
enctype = _this$props6.enctype,
|
|
3762
|
+
acceptcharset = _this$props6.acceptcharset,
|
|
3763
|
+
_this$props6$noHtml5V = _this$props6.noHtml5Validate,
|
|
3764
|
+
noHtml5Validate = _this$props6$noHtml5V === void 0 ? false : _this$props6$noHtml5V,
|
|
3765
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
3766
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
3767
|
+
_this$props6$readonly = _this$props6.readonly,
|
|
3768
|
+
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
3769
|
+
formContext = _this$props6.formContext,
|
|
3770
|
+
_this$props6$showErro = _this$props6.showErrorList,
|
|
3771
|
+
showErrorList = _this$props6$showErro === void 0 ? "top" : _this$props6$showErro,
|
|
3772
|
+
_internalFormWrapper = _this$props6._internalFormWrapper;
|
|
3732
3773
|
var _this$state4 = this.state,
|
|
3733
3774
|
schema = _this$state4.schema,
|
|
3734
3775
|
uiSchema = _this$state4.uiSchema,
|