@rjsf/core 5.0.2 → 5.2.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 +151 -70
- 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 +150 -71
- package/dist/core.esm.js.map +1 -1
- package/dist/core.umd.development.js +153 -74
- 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 +17 -1
- package/package.json +9 -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'), require('markdown-to-jsx')) :
|
|
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', 'markdown-to-jsx'], 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, global.Markdown));
|
|
5
|
+
})(this, (function (exports, React, utils, get, isEmpty, _pick, _toPath, isObject, set, nanoid, omit, has, unset, Markdown) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -10,11 +10,13 @@
|
|
|
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);
|
|
16
17
|
var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
|
|
17
18
|
var unset__default = /*#__PURE__*/_interopDefaultLegacy(unset);
|
|
19
|
+
var Markdown__default = /*#__PURE__*/_interopDefaultLegacy(Markdown);
|
|
18
20
|
|
|
19
21
|
function _defineProperties(target, props) {
|
|
20
22
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -194,7 +196,7 @@
|
|
|
194
196
|
onChange = _this$props3.onChange,
|
|
195
197
|
errorSchema = _this$props3.errorSchema;
|
|
196
198
|
var newErrorSchema;
|
|
197
|
-
if (
|
|
199
|
+
if (errorSchema) {
|
|
198
200
|
newErrorSchema = {};
|
|
199
201
|
for (var idx in errorSchema) {
|
|
200
202
|
var i = parseInt(idx);
|
|
@@ -371,14 +373,15 @@
|
|
|
371
373
|
uiSchema = _this$props7.uiSchema,
|
|
372
374
|
idSchema = _this$props7.idSchema,
|
|
373
375
|
registry = _this$props7.registry;
|
|
374
|
-
var schemaUtils = registry.schemaUtils
|
|
376
|
+
var schemaUtils = registry.schemaUtils,
|
|
377
|
+
translateString = registry.translateString;
|
|
375
378
|
if (!(utils.ITEMS_KEY in schema)) {
|
|
376
379
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
377
380
|
var UnsupportedFieldTemplate = utils.getTemplate("UnsupportedFieldTemplate", registry, uiOptions);
|
|
378
381
|
return /*#__PURE__*/React__default["default"].createElement(UnsupportedFieldTemplate, {
|
|
379
382
|
schema: schema,
|
|
380
383
|
idSchema: idSchema,
|
|
381
|
-
reason:
|
|
384
|
+
reason: translateString(utils.TranslatableString.MissingItems),
|
|
382
385
|
registry: registry
|
|
383
386
|
});
|
|
384
387
|
}
|
|
@@ -835,8 +838,11 @@
|
|
|
835
838
|
_createClass(ArrayField, [{
|
|
836
839
|
key: "itemTitle",
|
|
837
840
|
get: function get() {
|
|
838
|
-
var
|
|
839
|
-
|
|
841
|
+
var _this$props14 = this.props,
|
|
842
|
+
schema = _this$props14.schema,
|
|
843
|
+
registry = _this$props14.registry;
|
|
844
|
+
var translateString = registry.translateString;
|
|
845
|
+
return get__default["default"](schema, [utils.ITEMS_KEY, "title"], get__default["default"](schema, [utils.ITEMS_KEY, "description"], translateString(utils.TranslatableString.ArrayItemTitle)));
|
|
840
846
|
}
|
|
841
847
|
}]);
|
|
842
848
|
return ArrayField;
|
|
@@ -865,19 +871,22 @@
|
|
|
865
871
|
rawErrors = props.rawErrors;
|
|
866
872
|
var title = schema.title;
|
|
867
873
|
var widgets = registry.widgets,
|
|
868
|
-
formContext = registry.formContext
|
|
874
|
+
formContext = registry.formContext,
|
|
875
|
+
translateString = registry.translateString;
|
|
869
876
|
var _getUiOptions = utils.getUiOptions(uiSchema),
|
|
870
877
|
_getUiOptions$widget = _getUiOptions.widget,
|
|
871
878
|
widget = _getUiOptions$widget === void 0 ? "checkbox" : _getUiOptions$widget,
|
|
872
879
|
options = _objectWithoutPropertiesLoose(_getUiOptions, _excluded$8);
|
|
873
880
|
var Widget = utils.getWidget(schema, widget, widgets);
|
|
881
|
+
var yes = translateString(utils.TranslatableString.YesLabel);
|
|
882
|
+
var no = translateString(utils.TranslatableString.NoLabel);
|
|
874
883
|
var enumOptions;
|
|
875
884
|
if (Array.isArray(schema.oneOf)) {
|
|
876
885
|
enumOptions = utils.optionsList({
|
|
877
886
|
oneOf: schema.oneOf.map(function (option) {
|
|
878
887
|
if (isObject__default["default"](option)) {
|
|
879
888
|
return _extends({}, option, {
|
|
880
|
-
title: option.title || (option["const"] === true ?
|
|
889
|
+
title: option.title || (option["const"] === true ? yes : no)
|
|
881
890
|
});
|
|
882
891
|
}
|
|
883
892
|
return undefined;
|
|
@@ -895,10 +904,10 @@
|
|
|
895
904
|
})) {
|
|
896
905
|
enumOptions = [{
|
|
897
906
|
value: enums[0],
|
|
898
|
-
label: enums[0] ?
|
|
907
|
+
label: enums[0] ? yes : no
|
|
899
908
|
}, {
|
|
900
909
|
value: enums[1],
|
|
901
|
-
label: enums[1] ?
|
|
910
|
+
label: enums[1] ? yes : no
|
|
902
911
|
}];
|
|
903
912
|
} else {
|
|
904
913
|
enumOptions = utils.optionsList({
|
|
@@ -931,9 +940,6 @@
|
|
|
931
940
|
}
|
|
932
941
|
|
|
933
942
|
var _excluded$7 = ["widget", "placeholder", "autofocus", "autocomplete", "title"];
|
|
934
|
-
/** The prefix used when a oneOf option does not have a title
|
|
935
|
-
*/
|
|
936
|
-
var UNKNOWN_OPTION_PREFIX = "Option";
|
|
937
943
|
/** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
|
|
938
944
|
* the currently selected option and cleans up any irrelevant data in `formData`.
|
|
939
945
|
*
|
|
@@ -1072,7 +1078,8 @@
|
|
|
1072
1078
|
schema = _this$props5.schema,
|
|
1073
1079
|
uiSchema = _this$props5.uiSchema;
|
|
1074
1080
|
var widgets = registry.widgets,
|
|
1075
|
-
fields = registry.fields
|
|
1081
|
+
fields = registry.fields,
|
|
1082
|
+
translateString = registry.translateString;
|
|
1076
1083
|
var _SchemaField = fields.SchemaField;
|
|
1077
1084
|
var _this$state2 = this.state,
|
|
1078
1085
|
selectedOption = _this$state2.selectedOption,
|
|
@@ -1100,10 +1107,11 @@
|
|
|
1100
1107
|
type: baseType
|
|
1101
1108
|
});
|
|
1102
1109
|
}
|
|
1103
|
-
var
|
|
1110
|
+
var translateEnum = title ? utils.TranslatableString.TitleOptionPrefix : utils.TranslatableString.OptionPrefix;
|
|
1111
|
+
var translateParams = title ? [title] : [];
|
|
1104
1112
|
var enumOptions = retrievedOptions.map(function (opt, index) {
|
|
1105
1113
|
return {
|
|
1106
|
-
label: opt.title ||
|
|
1114
|
+
label: opt.title || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1107
1115
|
value: index
|
|
1108
1116
|
};
|
|
1109
1117
|
});
|
|
@@ -1358,9 +1366,8 @@
|
|
|
1358
1366
|
* @param type - The type of the new additional schema property
|
|
1359
1367
|
*/
|
|
1360
1368
|
_proto.getDefaultValue = function getDefaultValue(type) {
|
|
1369
|
+
var translateString = this.props.registry.translateString;
|
|
1361
1370
|
switch (type) {
|
|
1362
|
-
case "string":
|
|
1363
|
-
return "New Value";
|
|
1364
1371
|
case "array":
|
|
1365
1372
|
return [];
|
|
1366
1373
|
case "boolean":
|
|
@@ -1371,9 +1378,10 @@
|
|
|
1371
1378
|
return 0;
|
|
1372
1379
|
case "object":
|
|
1373
1380
|
return {};
|
|
1381
|
+
case "string":
|
|
1374
1382
|
default:
|
|
1375
1383
|
// We don't have a datatype for some reason (perhaps additionalProperties was true)
|
|
1376
|
-
return
|
|
1384
|
+
return translateString(utils.TranslatableString.NewStringDefault);
|
|
1377
1385
|
}
|
|
1378
1386
|
}
|
|
1379
1387
|
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
@@ -1507,7 +1515,8 @@
|
|
|
1507
1515
|
*/
|
|
1508
1516
|
function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
1509
1517
|
var field = uiOptions.field;
|
|
1510
|
-
var fields = registry.fields
|
|
1518
|
+
var fields = registry.fields,
|
|
1519
|
+
translateString = registry.translateString;
|
|
1511
1520
|
if (typeof field === "function") {
|
|
1512
1521
|
return field;
|
|
1513
1522
|
}
|
|
@@ -1529,7 +1538,7 @@
|
|
|
1529
1538
|
return /*#__PURE__*/React__default["default"].createElement(UnsupportedFieldTemplate, {
|
|
1530
1539
|
schema: schema,
|
|
1531
1540
|
idSchema: idSchema,
|
|
1532
|
-
reason:
|
|
1541
|
+
reason: translateString(utils.TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
1533
1542
|
registry: registry
|
|
1534
1543
|
});
|
|
1535
1544
|
};
|
|
@@ -2114,24 +2123,27 @@
|
|
|
2114
2123
|
}));
|
|
2115
2124
|
}
|
|
2116
2125
|
function MoveDownButton(props) {
|
|
2126
|
+
var translateString = props.registry.translateString;
|
|
2117
2127
|
return /*#__PURE__*/React__default["default"].createElement(IconButton, _extends({
|
|
2118
|
-
title:
|
|
2128
|
+
title: translateString(utils.TranslatableString.MoveDownButton),
|
|
2119
2129
|
className: "array-item-move-down"
|
|
2120
2130
|
}, props, {
|
|
2121
2131
|
icon: "arrow-down"
|
|
2122
2132
|
}));
|
|
2123
2133
|
}
|
|
2124
2134
|
function MoveUpButton(props) {
|
|
2135
|
+
var translateString = props.registry.translateString;
|
|
2125
2136
|
return /*#__PURE__*/React__default["default"].createElement(IconButton, _extends({
|
|
2126
|
-
title:
|
|
2137
|
+
title: translateString(utils.TranslatableString.MoveUpButton),
|
|
2127
2138
|
className: "array-item-move-up"
|
|
2128
2139
|
}, props, {
|
|
2129
2140
|
icon: "arrow-up"
|
|
2130
2141
|
}));
|
|
2131
2142
|
}
|
|
2132
2143
|
function RemoveButton(props) {
|
|
2144
|
+
var translateString = props.registry.translateString;
|
|
2133
2145
|
return /*#__PURE__*/React__default["default"].createElement(IconButton, _extends({
|
|
2134
|
-
title:
|
|
2146
|
+
title: translateString(utils.TranslatableString.RemoveButton),
|
|
2135
2147
|
className: "array-item-remove"
|
|
2136
2148
|
}, props, {
|
|
2137
2149
|
iconType: "danger",
|
|
@@ -2146,6 +2158,7 @@
|
|
|
2146
2158
|
onClick = _ref.onClick,
|
|
2147
2159
|
disabled = _ref.disabled,
|
|
2148
2160
|
registry = _ref.registry;
|
|
2161
|
+
var translateString = registry.translateString;
|
|
2149
2162
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2150
2163
|
className: "row"
|
|
2151
2164
|
}, /*#__PURE__*/React__default["default"].createElement("p", {
|
|
@@ -2154,7 +2167,7 @@
|
|
|
2154
2167
|
iconType: "info",
|
|
2155
2168
|
icon: "plus",
|
|
2156
2169
|
className: "btn-add col-xs-12",
|
|
2157
|
-
title:
|
|
2170
|
+
title: translateString(utils.TranslatableString.AddButton),
|
|
2158
2171
|
onClick: onClick,
|
|
2159
2172
|
disabled: disabled,
|
|
2160
2173
|
registry: registry
|
|
@@ -2199,14 +2212,16 @@
|
|
|
2199
2212
|
* @param props - The `ErrorListProps` for this component
|
|
2200
2213
|
*/
|
|
2201
2214
|
function ErrorList(_ref) {
|
|
2202
|
-
var errors = _ref.errors
|
|
2215
|
+
var errors = _ref.errors,
|
|
2216
|
+
registry = _ref.registry;
|
|
2217
|
+
var translateString = registry.translateString;
|
|
2203
2218
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2204
2219
|
className: "panel panel-danger errors"
|
|
2205
2220
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2206
2221
|
className: "panel-heading"
|
|
2207
2222
|
}, /*#__PURE__*/React__default["default"].createElement("h3", {
|
|
2208
2223
|
className: "panel-title"
|
|
2209
|
-
},
|
|
2224
|
+
}, translateString(utils.TranslatableString.ErrorsLabel))), /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
2210
2225
|
className: "list-group"
|
|
2211
2226
|
}, errors.map(function (error, i) {
|
|
2212
2227
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
@@ -2389,10 +2404,22 @@
|
|
|
2389
2404
|
function UnsupportedField(props) {
|
|
2390
2405
|
var schema = props.schema,
|
|
2391
2406
|
idSchema = props.idSchema,
|
|
2392
|
-
reason = props.reason
|
|
2407
|
+
reason = props.reason,
|
|
2408
|
+
registry = props.registry;
|
|
2409
|
+
var translateString = registry.translateString;
|
|
2410
|
+
var translateEnum = utils.TranslatableString.UnsupportedField;
|
|
2411
|
+
var translateParams = [];
|
|
2412
|
+
if (idSchema && idSchema.$id) {
|
|
2413
|
+
translateEnum = utils.TranslatableString.UnsupportedFieldWithId;
|
|
2414
|
+
translateParams.push(idSchema.$id);
|
|
2415
|
+
}
|
|
2416
|
+
if (reason) {
|
|
2417
|
+
translateEnum = translateEnum === utils.TranslatableString.UnsupportedField ? utils.TranslatableString.UnsupportedFieldWithReason : utils.TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
2418
|
+
translateParams.push(reason);
|
|
2419
|
+
}
|
|
2393
2420
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2394
2421
|
className: "unsupported-field"
|
|
2395
|
-
}, /*#__PURE__*/React__default["default"].createElement("p", null,
|
|
2422
|
+
}, /*#__PURE__*/React__default["default"].createElement("p", null, /*#__PURE__*/React__default["default"].createElement(Markdown__default["default"], null, translateString(translateEnum, translateParams))), schema && /*#__PURE__*/React__default["default"].createElement("pre", null, JSON.stringify(schema, null, 2)));
|
|
2396
2423
|
}
|
|
2397
2424
|
|
|
2398
2425
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -2414,9 +2441,11 @@
|
|
|
2414
2441
|
children = props.children,
|
|
2415
2442
|
uiSchema = props.uiSchema,
|
|
2416
2443
|
registry = props.registry;
|
|
2444
|
+
var templates = registry.templates,
|
|
2445
|
+
translateString = registry.translateString;
|
|
2417
2446
|
// Button templates are not overridden in the uiSchema
|
|
2418
|
-
var RemoveButton =
|
|
2419
|
-
var keyLabel = label
|
|
2447
|
+
var RemoveButton = templates.ButtonTemplates.RemoveButton;
|
|
2448
|
+
var keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
2420
2449
|
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
2421
2450
|
if (!additional) {
|
|
2422
2451
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -2593,6 +2622,7 @@
|
|
|
2593
2622
|
onFocus = _ref2.onFocus,
|
|
2594
2623
|
onChange = _ref2.onChange,
|
|
2595
2624
|
value = _ref2.value;
|
|
2625
|
+
var translateString = registry.translateString;
|
|
2596
2626
|
var _useReducer = React.useReducer(function (state, action) {
|
|
2597
2627
|
return _extends({}, state, action);
|
|
2598
2628
|
}, utils.parseDateString(value, time)),
|
|
@@ -2633,6 +2663,7 @@
|
|
|
2633
2663
|
className: "list-inline"
|
|
2634
2664
|
}, dateElementProps(state, time, options.yearsRange).map(function (elemProps, i) {
|
|
2635
2665
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2666
|
+
className: "list-inline-item",
|
|
2636
2667
|
key: i
|
|
2637
2668
|
}, /*#__PURE__*/React__default["default"].createElement(DateElement, _extends({
|
|
2638
2669
|
rootId: id,
|
|
@@ -2645,15 +2676,19 @@
|
|
|
2645
2676
|
onFocus: onFocus,
|
|
2646
2677
|
autofocus: autofocus && i === 0
|
|
2647
2678
|
})));
|
|
2648
|
-
}), (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /*#__PURE__*/React__default["default"].createElement("li",
|
|
2679
|
+
}), (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2680
|
+
className: "list-inline-item"
|
|
2681
|
+
}, /*#__PURE__*/React__default["default"].createElement("a", {
|
|
2649
2682
|
href: "#",
|
|
2650
2683
|
className: "btn btn-info btn-now",
|
|
2651
2684
|
onClick: handleSetNow
|
|
2652
|
-
},
|
|
2685
|
+
}, translateString(utils.TranslatableString.NowLabel))), (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2686
|
+
className: "list-inline-item"
|
|
2687
|
+
}, /*#__PURE__*/React__default["default"].createElement("a", {
|
|
2653
2688
|
href: "#",
|
|
2654
2689
|
className: "btn btn-warning btn-clear",
|
|
2655
2690
|
onClick: handleClear
|
|
2656
|
-
},
|
|
2691
|
+
}, translateString(utils.TranslatableString.ClearLabel))));
|
|
2657
2692
|
}
|
|
2658
2693
|
|
|
2659
2694
|
var _excluded$1 = ["time"];
|
|
@@ -2906,10 +2941,12 @@
|
|
|
2906
2941
|
return Promise.all(Array.from(files).map(processFile));
|
|
2907
2942
|
}
|
|
2908
2943
|
function FilesInfo(_ref) {
|
|
2909
|
-
var filesInfo = _ref.filesInfo
|
|
2944
|
+
var filesInfo = _ref.filesInfo,
|
|
2945
|
+
registry = _ref.registry;
|
|
2910
2946
|
if (filesInfo.length === 0) {
|
|
2911
2947
|
return null;
|
|
2912
2948
|
}
|
|
2949
|
+
var translateString = registry.translateString;
|
|
2913
2950
|
return /*#__PURE__*/React__default["default"].createElement("ul", {
|
|
2914
2951
|
className: "file-info"
|
|
2915
2952
|
}, filesInfo.map(function (fileInfo, key) {
|
|
@@ -2918,7 +2955,7 @@
|
|
|
2918
2955
|
type = fileInfo.type;
|
|
2919
2956
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
2920
2957
|
key: key
|
|
2921
|
-
}, /*#__PURE__*/React__default["default"].createElement("
|
|
2958
|
+
}, /*#__PURE__*/React__default["default"].createElement(Markdown__default["default"], null, translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)])));
|
|
2922
2959
|
}));
|
|
2923
2960
|
}
|
|
2924
2961
|
function extractFileInfo(dataURLs) {
|
|
@@ -2948,7 +2985,8 @@
|
|
|
2948
2985
|
value = _ref2.value,
|
|
2949
2986
|
_ref2$autofocus = _ref2.autofocus,
|
|
2950
2987
|
autofocus = _ref2$autofocus === void 0 ? false : _ref2$autofocus,
|
|
2951
|
-
options = _ref2.options
|
|
2988
|
+
options = _ref2.options,
|
|
2989
|
+
registry = _ref2.registry;
|
|
2952
2990
|
var extractedFilesInfo = React.useMemo(function () {
|
|
2953
2991
|
return Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value]);
|
|
2954
2992
|
}, [value]);
|
|
@@ -2983,7 +3021,8 @@
|
|
|
2983
3021
|
accept: options.accept ? String(options.accept) : undefined,
|
|
2984
3022
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
2985
3023
|
})), /*#__PURE__*/React__default["default"].createElement(FilesInfo, {
|
|
2986
|
-
filesInfo: filesInfo
|
|
3024
|
+
filesInfo: filesInfo,
|
|
3025
|
+
registry: registry
|
|
2987
3026
|
}));
|
|
2988
3027
|
}
|
|
2989
3028
|
|
|
@@ -3295,7 +3334,8 @@
|
|
|
3295
3334
|
templates: templates(),
|
|
3296
3335
|
widgets: widgets(),
|
|
3297
3336
|
rootSchema: {},
|
|
3298
|
-
formContext: {}
|
|
3337
|
+
formContext: {},
|
|
3338
|
+
translateString: utils.englishStringTranslator
|
|
3299
3339
|
};
|
|
3300
3340
|
}
|
|
3301
3341
|
|
|
@@ -3522,7 +3562,7 @@
|
|
|
3522
3562
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(props.validator, rootSchema)) {
|
|
3523
3563
|
schemaUtils = utils.createSchemaUtils(props.validator, rootSchema);
|
|
3524
3564
|
}
|
|
3525
|
-
var formData = schemaUtils.getDefaultFormState(schema, inputFormData
|
|
3565
|
+
var formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3526
3566
|
var retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3527
3567
|
var getCurrentErrors = function getCurrentErrors() {
|
|
3528
3568
|
if (props.noValidate) {
|
|
@@ -3623,7 +3663,8 @@
|
|
|
3623
3663
|
errorSchema: errorSchema || {},
|
|
3624
3664
|
schema: schema,
|
|
3625
3665
|
uiSchema: uiSchema,
|
|
3626
|
-
formContext: formContext
|
|
3666
|
+
formContext: formContext,
|
|
3667
|
+
registry: registry
|
|
3627
3668
|
});
|
|
3628
3669
|
}
|
|
3629
3670
|
return null;
|
|
@@ -3636,12 +3677,14 @@
|
|
|
3636
3677
|
/** Returns the registry for the form */
|
|
3637
3678
|
_proto.getRegistry = function getRegistry() {
|
|
3638
3679
|
var _this$props$templates;
|
|
3680
|
+
var customTranslateString = this.props.translateString;
|
|
3639
3681
|
var schemaUtils = this.state.schemaUtils;
|
|
3640
3682
|
var _getDefaultRegistry = getDefaultRegistry(),
|
|
3641
3683
|
fields = _getDefaultRegistry.fields,
|
|
3642
3684
|
templates = _getDefaultRegistry.templates,
|
|
3643
3685
|
widgets = _getDefaultRegistry.widgets,
|
|
3644
|
-
formContext = _getDefaultRegistry.formContext
|
|
3686
|
+
formContext = _getDefaultRegistry.formContext,
|
|
3687
|
+
translateString = _getDefaultRegistry.translateString;
|
|
3645
3688
|
return {
|
|
3646
3689
|
fields: _extends({}, fields, this.props.fields),
|
|
3647
3690
|
templates: _extends({}, templates, this.props.templates, {
|
|
@@ -3650,7 +3693,8 @@
|
|
|
3650
3693
|
widgets: _extends({}, widgets, this.props.widgets),
|
|
3651
3694
|
rootSchema: this.props.schema,
|
|
3652
3695
|
formContext: this.props.formContext || formContext,
|
|
3653
|
-
schemaUtils: schemaUtils
|
|
3696
|
+
schemaUtils: schemaUtils,
|
|
3697
|
+
translateString: customTranslateString || translateString
|
|
3654
3698
|
};
|
|
3655
3699
|
}
|
|
3656
3700
|
/** Provides a function that can be used to programmatically submit the `Form` */;
|
|
@@ -3662,15 +3706,47 @@
|
|
|
3662
3706
|
this.formElement.current.requestSubmit();
|
|
3663
3707
|
}
|
|
3664
3708
|
}
|
|
3709
|
+
/** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
|
|
3710
|
+
* field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
|
|
3711
|
+
* id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
|
|
3712
|
+
*
|
|
3713
|
+
* @param error - The error on which to focus
|
|
3714
|
+
*/;
|
|
3715
|
+
_proto.focusOnError = function focusOnError(error) {
|
|
3716
|
+
var _this$props4 = this.props,
|
|
3717
|
+
_this$props4$idPrefix = _this$props4.idPrefix,
|
|
3718
|
+
idPrefix = _this$props4$idPrefix === void 0 ? "root" : _this$props4$idPrefix,
|
|
3719
|
+
_this$props4$idSepara = _this$props4.idSeparator,
|
|
3720
|
+
idSeparator = _this$props4$idSepara === void 0 ? "_" : _this$props4$idSepara;
|
|
3721
|
+
var property = error.property;
|
|
3722
|
+
var path = _toPath__default["default"](property);
|
|
3723
|
+
if (path[0] === "") {
|
|
3724
|
+
// Most of the time the `.foo` property results in the first element being empty, so replace it with the idPrefix
|
|
3725
|
+
path[0] = idPrefix;
|
|
3726
|
+
} else {
|
|
3727
|
+
// Otherwise insert the idPrefix into the first location using unshift
|
|
3728
|
+
path.unshift(idPrefix);
|
|
3729
|
+
}
|
|
3730
|
+
var elementId = path.join(idSeparator);
|
|
3731
|
+
var field = this.formElement.current.elements[elementId];
|
|
3732
|
+
if (!field) {
|
|
3733
|
+
// if not an exact match, try finding an input starting with the element id (like radio buttons or checkboxes)
|
|
3734
|
+
field = this.formElement.current.querySelector("input[id^=" + elementId);
|
|
3735
|
+
}
|
|
3736
|
+
if (field) {
|
|
3737
|
+
field.focus();
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3665
3740
|
/** Programmatically validate the form. If `onError` is provided, then it will be called with the list of errors the
|
|
3666
3741
|
* same way as would happen on form submission.
|
|
3667
3742
|
*
|
|
3668
3743
|
* @returns - True if the form is valid, false otherwise.
|
|
3669
3744
|
*/;
|
|
3670
3745
|
_proto.validateForm = function validateForm() {
|
|
3671
|
-
var _this$
|
|
3672
|
-
extraErrors = _this$
|
|
3673
|
-
|
|
3746
|
+
var _this$props5 = this.props,
|
|
3747
|
+
extraErrors = _this$props5.extraErrors,
|
|
3748
|
+
focusOnFirstError = _this$props5.focusOnFirstError,
|
|
3749
|
+
onError = _this$props5.onError;
|
|
3674
3750
|
var formData = this.state.formData;
|
|
3675
3751
|
var schemaUtils = this.state.schemaUtils;
|
|
3676
3752
|
var schemaValidation = this.validate(formData);
|
|
@@ -3684,6 +3760,9 @@
|
|
|
3684
3760
|
errorSchema = merged.errorSchema;
|
|
3685
3761
|
errors = merged.errors;
|
|
3686
3762
|
}
|
|
3763
|
+
if (focusOnFirstError) {
|
|
3764
|
+
this.focusOnError(schemaValidation.errors[0]);
|
|
3765
|
+
}
|
|
3687
3766
|
this.setState({
|
|
3688
3767
|
errors: errors,
|
|
3689
3768
|
errorSchema: errorSchema,
|
|
@@ -3704,31 +3783,31 @@
|
|
|
3704
3783
|
* needed along with the submit button or any children of the form.
|
|
3705
3784
|
*/;
|
|
3706
3785
|
_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$
|
|
3786
|
+
var _this$props6 = this.props,
|
|
3787
|
+
children = _this$props6.children,
|
|
3788
|
+
id = _this$props6.id,
|
|
3789
|
+
idPrefix = _this$props6.idPrefix,
|
|
3790
|
+
idSeparator = _this$props6.idSeparator,
|
|
3791
|
+
_this$props6$classNam = _this$props6.className,
|
|
3792
|
+
className = _this$props6$classNam === void 0 ? "" : _this$props6$classNam,
|
|
3793
|
+
tagName = _this$props6.tagName,
|
|
3794
|
+
name = _this$props6.name,
|
|
3795
|
+
method = _this$props6.method,
|
|
3796
|
+
target = _this$props6.target,
|
|
3797
|
+
action = _this$props6.action,
|
|
3798
|
+
autoComplete = _this$props6.autoComplete,
|
|
3799
|
+
enctype = _this$props6.enctype,
|
|
3800
|
+
acceptcharset = _this$props6.acceptcharset,
|
|
3801
|
+
_this$props6$noHtml5V = _this$props6.noHtml5Validate,
|
|
3802
|
+
noHtml5Validate = _this$props6$noHtml5V === void 0 ? false : _this$props6$noHtml5V,
|
|
3803
|
+
_this$props6$disabled = _this$props6.disabled,
|
|
3804
|
+
disabled = _this$props6$disabled === void 0 ? false : _this$props6$disabled,
|
|
3805
|
+
_this$props6$readonly = _this$props6.readonly,
|
|
3806
|
+
readonly = _this$props6$readonly === void 0 ? false : _this$props6$readonly,
|
|
3807
|
+
formContext = _this$props6.formContext,
|
|
3808
|
+
_this$props6$showErro = _this$props6.showErrorList,
|
|
3809
|
+
showErrorList = _this$props6$showErro === void 0 ? "top" : _this$props6$showErro,
|
|
3810
|
+
_internalFormWrapper = _this$props6._internalFormWrapper;
|
|
3732
3811
|
var _this$state4 = this.state,
|
|
3733
3812
|
schema = _this$state4.schema,
|
|
3734
3813
|
uiSchema = _this$state4.uiSchema,
|