@rjsf/utils 5.2.1 → 5.3.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/index.d.ts +48 -21
- package/dist/utils.cjs.development.js +22 -9
- package/dist/utils.cjs.development.js.map +1 -1
- package/dist/utils.cjs.production.min.js +1 -1
- package/dist/utils.cjs.production.min.js.map +1 -1
- package/dist/utils.esm.js +22 -10
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.umd.development.js +22 -9
- package/dist/utils.umd.development.js.map +1 -1
- package/dist/utils.umd.production.min.js +1 -1
- package/dist/utils.umd.production.min.js.map +1 -1
- package/package.json +7 -7
|
@@ -176,17 +176,22 @@
|
|
|
176
176
|
var UI_FIELD_KEY = 'ui:field';
|
|
177
177
|
var UI_WIDGET_KEY = 'ui:widget';
|
|
178
178
|
var UI_OPTIONS_KEY = 'ui:options';
|
|
179
|
+
var UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
|
|
179
180
|
|
|
180
181
|
/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
|
|
181
|
-
* stripped off.
|
|
182
|
+
* stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
|
|
182
183
|
*
|
|
183
184
|
* @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
|
|
184
|
-
* @
|
|
185
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
186
|
+
* @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
|
|
185
187
|
*/
|
|
186
|
-
function getUiOptions(uiSchema) {
|
|
188
|
+
function getUiOptions(uiSchema, globalOptions) {
|
|
187
189
|
if (uiSchema === void 0) {
|
|
188
190
|
uiSchema = {};
|
|
189
191
|
}
|
|
192
|
+
if (globalOptions === void 0) {
|
|
193
|
+
globalOptions = {};
|
|
194
|
+
}
|
|
190
195
|
return Object.keys(uiSchema).filter(function (key) {
|
|
191
196
|
return key.indexOf('ui:') === 0;
|
|
192
197
|
}).reduce(function (options, key) {
|
|
@@ -200,7 +205,7 @@
|
|
|
200
205
|
return _extends({}, options, value);
|
|
201
206
|
}
|
|
202
207
|
return _extends({}, options, (_extends2 = {}, _extends2[key.substring(3)] = value, _extends2));
|
|
203
|
-
}, {});
|
|
208
|
+
}, _extends({}, globalOptions));
|
|
204
209
|
}
|
|
205
210
|
|
|
206
211
|
/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
|
|
@@ -1265,7 +1270,7 @@
|
|
|
1265
1270
|
}
|
|
1266
1271
|
return (
|
|
1267
1272
|
// TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
|
|
1268
|
-
// https://react-jsonschema-form
|
|
1273
|
+
// https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
|
|
1269
1274
|
'widget' in getUiOptions(uiSchema) && getUiOptions(uiSchema)['widget'] !== 'hidden'
|
|
1270
1275
|
);
|
|
1271
1276
|
}
|
|
@@ -1299,13 +1304,14 @@
|
|
|
1299
1304
|
* @param schema - The schema for which the display label flag is desired
|
|
1300
1305
|
* @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
|
|
1301
1306
|
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1307
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
1302
1308
|
* @returns - True if the label should be displayed or false if it should not
|
|
1303
1309
|
*/
|
|
1304
|
-
function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
|
|
1310
|
+
function getDisplayLabel(validator, schema, uiSchema, rootSchema, globalOptions) {
|
|
1305
1311
|
if (uiSchema === void 0) {
|
|
1306
1312
|
uiSchema = {};
|
|
1307
1313
|
}
|
|
1308
|
-
var uiOptions = getUiOptions(uiSchema);
|
|
1314
|
+
var uiOptions = getUiOptions(uiSchema, globalOptions);
|
|
1309
1315
|
var _uiOptions$label = uiOptions.label,
|
|
1310
1316
|
label = _uiOptions$label === void 0 ? true : _uiOptions$label;
|
|
1311
1317
|
var displayLabel = !!label;
|
|
@@ -1666,10 +1672,11 @@
|
|
|
1666
1672
|
*
|
|
1667
1673
|
* @param schema - The schema for which the display label flag is desired
|
|
1668
1674
|
* @param [uiSchema] - The UI schema from which to derive potentially displayable information
|
|
1675
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
1669
1676
|
* @returns - True if the label should be displayed or false if it should not
|
|
1670
1677
|
*/;
|
|
1671
|
-
_proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema) {
|
|
1672
|
-
return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
|
|
1678
|
+
_proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema, globalOptions) {
|
|
1679
|
+
return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
|
|
1673
1680
|
}
|
|
1674
1681
|
/** Determines which of the given `options` provided most closely matches the `formData`.
|
|
1675
1682
|
* Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
|
|
@@ -2274,6 +2281,7 @@
|
|
|
2274
2281
|
'date-time': 'DateTimeWidget',
|
|
2275
2282
|
'alt-date': 'AltDateWidget',
|
|
2276
2283
|
'alt-datetime': 'AltDateTimeWidget',
|
|
2284
|
+
time: 'TimeWidget',
|
|
2277
2285
|
color: 'ColorWidget',
|
|
2278
2286
|
file: 'FileWidget'
|
|
2279
2287
|
},
|
|
@@ -2743,6 +2751,8 @@
|
|
|
2743
2751
|
TranslatableString["AddButton"] = "Add";
|
|
2744
2752
|
/** Add button title, used by AddButton */
|
|
2745
2753
|
TranslatableString["AddItemButton"] = "Add Item";
|
|
2754
|
+
/** Copy button title, used by IconButton */
|
|
2755
|
+
TranslatableString["CopyButton"] = "Copy";
|
|
2746
2756
|
/** Move down button title, used by IconButton */
|
|
2747
2757
|
TranslatableString["MoveDownButton"] = "Move down";
|
|
2748
2758
|
/** Move up button title, used by IconButton */
|
|
@@ -2771,6 +2781,8 @@
|
|
|
2771
2781
|
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
2772
2782
|
TranslatableString["KeyLabel"] = "%1 Key";
|
|
2773
2783
|
// Strings with replaceable parameters AND/OR that support markdown and html
|
|
2784
|
+
/** Invalid object field configuration as provided by the ObjectField */
|
|
2785
|
+
TranslatableString["InvalidObjectField"] = "Invalid \"%1\" object field configuration: <em>%2</em>.";
|
|
2774
2786
|
/** Unsupported field schema, used by UnsupportedField */
|
|
2775
2787
|
TranslatableString["UnsupportedField"] = "Unsupported field schema.";
|
|
2776
2788
|
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
|
|
@@ -2808,6 +2820,7 @@
|
|
|
2808
2820
|
exports.RJSF_ADDITONAL_PROPERTIES_FLAG = RJSF_ADDITONAL_PROPERTIES_FLAG;
|
|
2809
2821
|
exports.SUBMIT_BTN_OPTIONS_KEY = SUBMIT_BTN_OPTIONS_KEY;
|
|
2810
2822
|
exports.UI_FIELD_KEY = UI_FIELD_KEY;
|
|
2823
|
+
exports.UI_GLOBAL_OPTIONS_KEY = UI_GLOBAL_OPTIONS_KEY;
|
|
2811
2824
|
exports.UI_OPTIONS_KEY = UI_OPTIONS_KEY;
|
|
2812
2825
|
exports.UI_WIDGET_KEY = UI_WIDGET_KEY;
|
|
2813
2826
|
exports.allowAdditionalItems = allowAdditionalItems;
|