@rjsf/utils 5.2.1 → 5.3.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/utils.esm.js CHANGED
@@ -170,17 +170,22 @@ var RJSF_ADDITONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
170
170
  var UI_FIELD_KEY = 'ui:field';
171
171
  var UI_WIDGET_KEY = 'ui:widget';
172
172
  var UI_OPTIONS_KEY = 'ui:options';
173
+ var UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
173
174
 
174
175
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
175
- * stripped off.
176
+ * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
176
177
  *
177
178
  * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
178
- * @returns - An object containing all the `ui:xxx` options with the stripped off
179
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
180
+ * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
179
181
  */
180
- function getUiOptions(uiSchema) {
182
+ function getUiOptions(uiSchema, globalOptions) {
181
183
  if (uiSchema === void 0) {
182
184
  uiSchema = {};
183
185
  }
186
+ if (globalOptions === void 0) {
187
+ globalOptions = {};
188
+ }
184
189
  return Object.keys(uiSchema).filter(function (key) {
185
190
  return key.indexOf('ui:') === 0;
186
191
  }).reduce(function (options, key) {
@@ -194,7 +199,7 @@ function getUiOptions(uiSchema) {
194
199
  return _extends({}, options, value);
195
200
  }
196
201
  return _extends({}, options, (_extends2 = {}, _extends2[key.substring(3)] = value, _extends2));
197
- }, {});
202
+ }, _extends({}, globalOptions));
198
203
  }
199
204
 
200
205
  /** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
@@ -1259,7 +1264,7 @@ function isCustomWidget(uiSchema) {
1259
1264
  }
1260
1265
  return (
1261
1266
  // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1262
- // https://react-jsonschema-form.readthedocs.io/en/latest/usage/widgets/#hidden-widgets
1267
+ // https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
1263
1268
  'widget' in getUiOptions(uiSchema) && getUiOptions(uiSchema)['widget'] !== 'hidden'
1264
1269
  );
1265
1270
  }
@@ -1293,13 +1298,14 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1293
1298
  * @param schema - The schema for which the display label flag is desired
1294
1299
  * @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
1295
1300
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1301
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1296
1302
  * @returns - True if the label should be displayed or false if it should not
1297
1303
  */
1298
- function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
1304
+ function getDisplayLabel(validator, schema, uiSchema, rootSchema, globalOptions) {
1299
1305
  if (uiSchema === void 0) {
1300
1306
  uiSchema = {};
1301
1307
  }
1302
- var uiOptions = getUiOptions(uiSchema);
1308
+ var uiOptions = getUiOptions(uiSchema, globalOptions);
1303
1309
  var _uiOptions$label = uiOptions.label,
1304
1310
  label = _uiOptions$label === void 0 ? true : _uiOptions$label;
1305
1311
  var displayLabel = !!label;
@@ -1660,10 +1666,11 @@ var SchemaUtils = /*#__PURE__*/function () {
1660
1666
  *
1661
1667
  * @param schema - The schema for which the display label flag is desired
1662
1668
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
1669
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1663
1670
  * @returns - True if the label should be displayed or false if it should not
1664
1671
  */;
1665
- _proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema) {
1666
- return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
1672
+ _proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema, globalOptions) {
1673
+ return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
1667
1674
  }
1668
1675
  /** Determines which of the given `options` provided most closely matches the `formData`.
1669
1676
  * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
@@ -2268,6 +2275,7 @@ var widgetMap = {
2268
2275
  'date-time': 'DateTimeWidget',
2269
2276
  'alt-date': 'AltDateWidget',
2270
2277
  'alt-datetime': 'AltDateTimeWidget',
2278
+ time: 'TimeWidget',
2271
2279
  color: 'ColorWidget',
2272
2280
  file: 'FileWidget'
2273
2281
  },
@@ -2737,6 +2745,8 @@ var TranslatableString;
2737
2745
  TranslatableString["AddButton"] = "Add";
2738
2746
  /** Add button title, used by AddButton */
2739
2747
  TranslatableString["AddItemButton"] = "Add Item";
2748
+ /** Copy button title, used by IconButton */
2749
+ TranslatableString["CopyButton"] = "Copy";
2740
2750
  /** Move down button title, used by IconButton */
2741
2751
  TranslatableString["MoveDownButton"] = "Move down";
2742
2752
  /** Move up button title, used by IconButton */
@@ -2765,6 +2775,8 @@ var TranslatableString;
2765
2775
  /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
2766
2776
  TranslatableString["KeyLabel"] = "%1 Key";
2767
2777
  // Strings with replaceable parameters AND/OR that support markdown and html
2778
+ /** Invalid object field configuration as provided by the ObjectField */
2779
+ TranslatableString["InvalidObjectField"] = "Invalid \"%1\" object field configuration: <em>%2</em>.";
2768
2780
  /** Unsupported field schema, used by UnsupportedField */
2769
2781
  TranslatableString["UnsupportedField"] = "Unsupported field schema.";
2770
2782
  /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
@@ -2781,5 +2793,5 @@ var TranslatableString;
2781
2793
  TranslatableString["FilesInfo"] = "<strong>%1</strong> (%2, %3 bytes)";
2782
2794
  })(TranslatableString || (TranslatableString = {}));
2783
2795
 
2784
- export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, ERRORS_KEY, ErrorSchemaBuilder, ID_KEY, ITEMS_KEY, NAME_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, REQUIRED_KEY, RJSF_ADDITONAL_PROPERTIES_FLAG, SUBMIT_BTN_OPTIONS_KEY, TranslatableString, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, findSchemaDefinition, getClosestMatchingOption, getDefaultFormState, getDisplayLabel, getFirstMatchingOption, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, helpId, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
2796
+ export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, ERRORS_KEY, ErrorSchemaBuilder, ID_KEY, ITEMS_KEY, NAME_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, REQUIRED_KEY, RJSF_ADDITONAL_PROPERTIES_FLAG, SUBMIT_BTN_OPTIONS_KEY, TranslatableString, UI_FIELD_KEY, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, findSchemaDefinition, getClosestMatchingOption, getDefaultFormState, getDisplayLabel, getFirstMatchingOption, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, helpId, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
2785
2797
  //# sourceMappingURL=utils.esm.js.map