@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
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ declare enum TranslatableString {
|
|
|
27
27
|
AddButton = "Add",
|
|
28
28
|
/** Add button title, used by AddButton */
|
|
29
29
|
AddItemButton = "Add Item",
|
|
30
|
+
/** Copy button title, used by IconButton */
|
|
31
|
+
CopyButton = "Copy",
|
|
30
32
|
/** Move down button title, used by IconButton */
|
|
31
33
|
MoveDownButton = "Move down",
|
|
32
34
|
/** Move up button title, used by IconButton */
|
|
@@ -53,6 +55,8 @@ declare enum TranslatableString {
|
|
|
53
55
|
TitleOptionPrefix = "%1 option %2",
|
|
54
56
|
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
55
57
|
KeyLabel = "%1 Key",
|
|
58
|
+
/** Invalid object field configuration as provided by the ObjectField */
|
|
59
|
+
InvalidObjectField = "Invalid \"%1\" object field configuration: <em>%2</em>.",
|
|
56
60
|
/** Unsupported field schema, used by UnsupportedField */
|
|
57
61
|
UnsupportedField = "Unsupported field schema.",
|
|
58
62
|
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
|
|
@@ -269,6 +273,8 @@ interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
|
|
|
269
273
|
SubmitButton: ComponentType<SubmitButtonProps<T, S, F>>;
|
|
270
274
|
/** The template to use for the Add button used for AdditionalProperties and Array items */
|
|
271
275
|
AddButton: ComponentType<IconButtonProps<T, S, F>>;
|
|
276
|
+
/** The template to use for the Copy button used for Array items */
|
|
277
|
+
CopyButton: ComponentType<IconButtonProps<T, S, F>>;
|
|
272
278
|
/** The template to use for the Move Down button used for Array items */
|
|
273
279
|
MoveDownButton: ComponentType<IconButtonProps<T, S, F>>;
|
|
274
280
|
/** The template to use for the Move Up button used for Array items */
|
|
@@ -277,6 +283,25 @@ interface TemplatesType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
|
|
|
277
283
|
RemoveButton: ComponentType<IconButtonProps<T, S, F>>;
|
|
278
284
|
};
|
|
279
285
|
}
|
|
286
|
+
/** The set of UiSchema options that can be set globally and used as fallbacks at an individual template, field or
|
|
287
|
+
* widget level when no field-level value of the option is provided.
|
|
288
|
+
*/
|
|
289
|
+
type GlobalUISchemaOptions = {
|
|
290
|
+
/** Flag, if set to `false`, new items cannot be added to array fields, unless overridden (defaults to true) */
|
|
291
|
+
addable?: boolean;
|
|
292
|
+
/** Flag, if set to `true`, array items can be copied (defaults to false) */
|
|
293
|
+
copyable?: boolean;
|
|
294
|
+
/** Flag, if set to `false`, array items cannot be ordered (defaults to true) */
|
|
295
|
+
orderable?: boolean;
|
|
296
|
+
/** Flag, if set to `false`, array items will not be removable (defaults to true) */
|
|
297
|
+
removable?: boolean;
|
|
298
|
+
/** Field labels are rendered by default. Labels may be omitted by setting the `label` option to `false` */
|
|
299
|
+
label?: boolean;
|
|
300
|
+
/** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
|
|
301
|
+
* This option allows you to change the separator between the original key name and the integer. Default is "-"
|
|
302
|
+
*/
|
|
303
|
+
duplicateKeySuffixSeparator?: string;
|
|
304
|
+
};
|
|
280
305
|
/** The object containing the registered core, theme and custom fields and widgets as well as the root schema, form
|
|
281
306
|
* context, schema utils and templates.
|
|
282
307
|
*/
|
|
@@ -303,6 +328,8 @@ interface Registry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
303
328
|
schemaUtils: SchemaUtilsType<T, S>;
|
|
304
329
|
/** The string translation function to use when displaying any of the RJSF strings in templates, fields or widgets */
|
|
305
330
|
translateString: (stringKey: TranslatableString, params?: string[]) => string;
|
|
331
|
+
/** The optional global UI Options that are available for all templates, fields and widgets to access */
|
|
332
|
+
globalUiOptions?: GlobalUISchemaOptions;
|
|
306
333
|
}
|
|
307
334
|
/** The properties that are passed to a Field implementation */
|
|
308
335
|
interface FieldProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends GenericObjectType, Pick<HTMLAttributes<HTMLElement>, Exclude<keyof HTMLAttributes<HTMLElement>, 'onBlur' | 'onFocus' | 'onChange'>> {
|
|
@@ -473,6 +500,8 @@ type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema
|
|
|
473
500
|
disabled: boolean;
|
|
474
501
|
/** A boolean value stating whether new items can be added to the array */
|
|
475
502
|
canAdd: boolean;
|
|
503
|
+
/** A boolean value stating whether the array item can be copied, assumed false if missing */
|
|
504
|
+
hasCopy: boolean;
|
|
476
505
|
/** A boolean value stating whether the array item can be moved down */
|
|
477
506
|
hasMoveDown: boolean;
|
|
478
507
|
/** A boolean value stating whether the array item can be moved up */
|
|
@@ -487,6 +516,8 @@ type ArrayFieldTemplateItemType<T = any, S extends StrictRJSFSchema = RJSFSchema
|
|
|
487
516
|
totalItems: number;
|
|
488
517
|
/** Returns a function that adds a new item at `index` */
|
|
489
518
|
onAddIndexClick: (index: number) => (event?: any) => void;
|
|
519
|
+
/** Returns a function that copies the item at `index` into the position at `index + 1` */
|
|
520
|
+
onCopyIndexClick: (index: number) => (event?: any) => void;
|
|
490
521
|
/** Returns a function that removes the item at `index` */
|
|
491
522
|
onDropIndexClick: (index: number) => (event?: any) => void;
|
|
492
523
|
/** Returns a function that swaps the items at `index` with `newIndex` */
|
|
@@ -696,7 +727,7 @@ type MakeUIType<Type> = {
|
|
|
696
727
|
/** This type represents all the known supported options in the `ui:options` property, kept separate in order to
|
|
697
728
|
* remap the keys. It also contains all the properties, optionally, of `TemplatesType` except "ButtonTemplates"
|
|
698
729
|
*/
|
|
699
|
-
type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & {
|
|
730
|
+
type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & GlobalUISchemaOptions & {
|
|
700
731
|
/** Any classnames that the user wants to be applied to a field in the ui */
|
|
701
732
|
classNames?: string;
|
|
702
733
|
/** Any custom style that the user wants to apply to a field in the ui, applied on the same element as classNames */
|
|
@@ -727,18 +758,10 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
727
758
|
readonly?: boolean;
|
|
728
759
|
/** This property allows you to reorder the properties that are shown for a particular object */
|
|
729
760
|
order?: string[];
|
|
730
|
-
/** Flag, if set to `false`, will mark array fields as NOT being able to be added to (defaults to true) */
|
|
731
|
-
addable?: boolean;
|
|
732
|
-
/** Flag, if set to `false`, will mark array fields as NOT being able to be ordered (defaults to true) */
|
|
733
|
-
orderable?: boolean;
|
|
734
|
-
/** Flag, if set to `false`, will mark array fields as NOT being able to be removed (defaults to true) */
|
|
735
|
-
removable?: boolean;
|
|
736
761
|
/** Flag, if set to `true`, will mark a list of checkboxes as displayed all on one line instead of one per row */
|
|
737
762
|
inline?: boolean;
|
|
738
763
|
/** Used to change the input type (for example, `tel` or `email`) for an <input> */
|
|
739
764
|
inputType?: string;
|
|
740
|
-
/** Field labels are rendered by default. Labels may be omitted by setting the `label` option to `false` */
|
|
741
|
-
label?: boolean;
|
|
742
765
|
/** Provides a means to set the initial height of a textarea widget */
|
|
743
766
|
rows?: number;
|
|
744
767
|
/** If submitButtonOptions is provided it should match the `UISchemaSubmitButtonOptions` type */
|
|
@@ -747,10 +770,6 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
747
770
|
* to look up an implementation from the `widgets` list or an actual one-off widget implementation itself
|
|
748
771
|
*/
|
|
749
772
|
widget?: Widget<T, S, F> | string;
|
|
750
|
-
/** When using `additionalProperties`, key collision is prevented by appending a unique integer to the duplicate key.
|
|
751
|
-
* This option allows you to change the separator between the original key name and the integer. Default is "-"
|
|
752
|
-
*/
|
|
753
|
-
duplicateKeySuffixSeparator?: string;
|
|
754
773
|
};
|
|
755
774
|
/** The type that represents the Options potentially provided by `ui:options` */
|
|
756
775
|
type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = UIOptionsBaseType<T, S, F> & {
|
|
@@ -761,7 +780,11 @@ type UIOptionsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
761
780
|
* starting with `ui:`.
|
|
762
781
|
*/
|
|
763
782
|
type UiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = GenericObjectType & MakeUIType<UIOptionsBaseType<T, S, F>> & {
|
|
764
|
-
/**
|
|
783
|
+
/** The set of Globally relevant UI Schema options that are read from the root-level UiSchema and stored in the
|
|
784
|
+
* Registry for use everywhere.
|
|
785
|
+
*/
|
|
786
|
+
'ui:globalOptions'?: GlobalUISchemaOptions;
|
|
787
|
+
/** Allows the form to generate a unique prefix for the `Form`'s root prefix */
|
|
765
788
|
'ui:rootFieldId'?: string;
|
|
766
789
|
/** Allows RJSF to override the default field implementation by specifying either the name of a field that is used
|
|
767
790
|
* to look up an implementation from the `fields` list or an actual one-off `Field` component implementation itself
|
|
@@ -871,9 +894,10 @@ interface SchemaUtilsType<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
871
894
|
*
|
|
872
895
|
* @param schema - The schema for which the display label flag is desired
|
|
873
896
|
* @param [uiSchema] - The UI schema from which to derive potentially displayable information
|
|
897
|
+
* @param [globalOptions={}] - The Global UI Schema from which to get any fallback `xxx` options
|
|
874
898
|
* @returns - True if the label should be displayed or false if it should not
|
|
875
899
|
*/
|
|
876
|
-
getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F
|
|
900
|
+
getDisplayLabel(schema: S, uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions): boolean;
|
|
877
901
|
/** Determines which of the given `options` provided most closely matches the `formData`.
|
|
878
902
|
* Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
|
|
879
903
|
*
|
|
@@ -1218,12 +1242,13 @@ declare function getSubmitButtonOptions<T = any, S extends StrictRJSFSchema = RJ
|
|
|
1218
1242
|
declare function getTemplate<Name extends keyof TemplatesType<T, S, F>, T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(name: Name, registry: Registry<T, S, F>, uiOptions?: UIOptionsType<T, S, F>): TemplatesType<T, S, F>[Name];
|
|
1219
1243
|
|
|
1220
1244
|
/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
|
|
1221
|
-
* stripped off.
|
|
1245
|
+
* stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
|
|
1222
1246
|
*
|
|
1223
1247
|
* @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
|
|
1224
|
-
* @
|
|
1248
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
1249
|
+
* @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
|
|
1225
1250
|
*/
|
|
1226
|
-
declare function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F
|
|
1251
|
+
declare function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>, globalOptions?: GlobalUISchemaOptions): UIOptionsType<T, S, F>;
|
|
1227
1252
|
|
|
1228
1253
|
/** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
|
|
1229
1254
|
* React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
|
|
@@ -1507,7 +1532,8 @@ declare const REF_KEY = "$ref";
|
|
|
1507
1532
|
declare const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
|
|
1508
1533
|
declare const UI_FIELD_KEY = "ui:field";
|
|
1509
1534
|
declare const UI_WIDGET_KEY = "ui:widget";
|
|
1510
|
-
declare const UI_OPTIONS_KEY = "ui:options";
|
|
1535
|
+
declare const UI_OPTIONS_KEY = "ui:options";
|
|
1536
|
+
declare const UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
|
|
1511
1537
|
|
|
1512
1538
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
1513
1539
|
* computed to have defaults provided in the `schema`.
|
|
@@ -1530,9 +1556,10 @@ declare function getDefaultFormState<T = any, S extends StrictRJSFSchema = RJSFS
|
|
|
1530
1556
|
* @param schema - The schema for which the display label flag is desired
|
|
1531
1557
|
* @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
|
|
1532
1558
|
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1559
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
1533
1560
|
* @returns - True if the label should be displayed or false if it should not
|
|
1534
1561
|
*/
|
|
1535
|
-
declare function getDisplayLabel<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S): boolean;
|
|
1562
|
+
declare function getDisplayLabel<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, uiSchema?: UiSchema<T, S, F>, rootSchema?: S, globalOptions?: GlobalUISchemaOptions): boolean;
|
|
1536
1563
|
|
|
1537
1564
|
/** Determines which of the given `options` provided most closely matches the `formData`. Using
|
|
1538
1565
|
* `getFirstMatchingOption()` to match two schemas that differ only by the readOnly, default or const value of a field
|
|
@@ -1704,4 +1731,4 @@ declare function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
1704
1731
|
*/
|
|
1705
1732
|
declare function toPathSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, schema: S, name?: string, rootSchema?: S, formData?: T): PathSchema<T>;
|
|
1706
1733
|
|
|
1707
|
-
export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, ArrayFieldDescriptionProps, ArrayFieldTemplateItemType, ArrayFieldTemplateProps, ArrayFieldTitleProps, BaseInputTemplateProps, CONST_KEY, CustomValidator, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, DateObject, DescriptionFieldProps, ENUM_KEY, ERRORS_KEY, EnumOptionsType, ErrorListProps, ErrorSchema, ErrorSchemaBuilder, ErrorTransformer, Field, FieldError, FieldErrorProps, FieldErrors, FieldHelpProps, FieldId, FieldPath, FieldProps, FieldTemplateProps, FieldValidation, FormContextType, FormValidation, GenericObjectType, ID_KEY, ITEMS_KEY, IconButtonProps, IdSchema, InputPropsType, NAME_KEY, ONE_OF_KEY, ObjectFieldTemplatePropertyType, ObjectFieldTemplateProps, PROPERTIES_KEY, PathSchema, REF_KEY, REQUIRED_KEY, RJSFSchema, RJSFValidationError, RJSF_ADDITONAL_PROPERTIES_FLAG, RangeSpecType, Registry, RegistryFieldsType, RegistryWidgetsType, SUBMIT_BTN_OPTIONS_KEY, SchemaUtilsType, StrictRJSFSchema, SubmitButtonProps, TemplatesType, TitleFieldProps, TranslatableString, UIOptionsType, UISchemaSubmitButtonOptions, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, UiSchema, UnsupportedFieldProps, ValidationData, ValidatorType, Widget, WidgetProps, WrapIfAdditionalTemplateProps, 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 };
|
|
1734
|
+
export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, ArrayFieldDescriptionProps, ArrayFieldTemplateItemType, ArrayFieldTemplateProps, ArrayFieldTitleProps, BaseInputTemplateProps, CONST_KEY, CustomValidator, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, DateObject, DescriptionFieldProps, ENUM_KEY, ERRORS_KEY, EnumOptionsType, ErrorListProps, ErrorSchema, ErrorSchemaBuilder, ErrorTransformer, Field, FieldError, FieldErrorProps, FieldErrors, FieldHelpProps, FieldId, FieldPath, FieldProps, FieldTemplateProps, FieldValidation, FormContextType, FormValidation, GenericObjectType, GlobalUISchemaOptions, ID_KEY, ITEMS_KEY, IconButtonProps, IdSchema, InputPropsType, NAME_KEY, ONE_OF_KEY, ObjectFieldTemplatePropertyType, ObjectFieldTemplateProps, PROPERTIES_KEY, PathSchema, REF_KEY, REQUIRED_KEY, RJSFSchema, RJSFValidationError, RJSF_ADDITONAL_PROPERTIES_FLAG, RangeSpecType, Registry, RegistryFieldsType, RegistryWidgetsType, SUBMIT_BTN_OPTIONS_KEY, SchemaUtilsType, StrictRJSFSchema, SubmitButtonProps, TemplatesType, TitleFieldProps, TranslatableString, UIOptionsType, UISchemaSubmitButtonOptions, UI_FIELD_KEY, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, UiSchema, UnsupportedFieldProps, ValidationData, ValidatorType, Widget, WidgetProps, WrapIfAdditionalTemplateProps, 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 };
|
|
@@ -193,17 +193,22 @@ var RJSF_ADDITONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
|
|
|
193
193
|
var UI_FIELD_KEY = 'ui:field';
|
|
194
194
|
var UI_WIDGET_KEY = 'ui:widget';
|
|
195
195
|
var UI_OPTIONS_KEY = 'ui:options';
|
|
196
|
+
var UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
|
|
196
197
|
|
|
197
198
|
/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
|
|
198
|
-
* stripped off.
|
|
199
|
+
* stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
|
|
199
200
|
*
|
|
200
201
|
* @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
|
|
201
|
-
* @
|
|
202
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
203
|
+
* @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
|
|
202
204
|
*/
|
|
203
|
-
function getUiOptions(uiSchema) {
|
|
205
|
+
function getUiOptions(uiSchema, globalOptions) {
|
|
204
206
|
if (uiSchema === void 0) {
|
|
205
207
|
uiSchema = {};
|
|
206
208
|
}
|
|
209
|
+
if (globalOptions === void 0) {
|
|
210
|
+
globalOptions = {};
|
|
211
|
+
}
|
|
207
212
|
return Object.keys(uiSchema).filter(function (key) {
|
|
208
213
|
return key.indexOf('ui:') === 0;
|
|
209
214
|
}).reduce(function (options, key) {
|
|
@@ -217,7 +222,7 @@ function getUiOptions(uiSchema) {
|
|
|
217
222
|
return _extends({}, options, value);
|
|
218
223
|
}
|
|
219
224
|
return _extends({}, options, (_extends2 = {}, _extends2[key.substring(3)] = value, _extends2));
|
|
220
|
-
}, {});
|
|
225
|
+
}, _extends({}, globalOptions));
|
|
221
226
|
}
|
|
222
227
|
|
|
223
228
|
/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
|
|
@@ -1282,7 +1287,7 @@ function isCustomWidget(uiSchema) {
|
|
|
1282
1287
|
}
|
|
1283
1288
|
return (
|
|
1284
1289
|
// TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
|
|
1285
|
-
// https://react-jsonschema-form
|
|
1290
|
+
// https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
|
|
1286
1291
|
'widget' in getUiOptions(uiSchema) && getUiOptions(uiSchema)['widget'] !== 'hidden'
|
|
1287
1292
|
);
|
|
1288
1293
|
}
|
|
@@ -1316,13 +1321,14 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
|
|
|
1316
1321
|
* @param schema - The schema for which the display label flag is desired
|
|
1317
1322
|
* @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
|
|
1318
1323
|
* @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
|
|
1324
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
1319
1325
|
* @returns - True if the label should be displayed or false if it should not
|
|
1320
1326
|
*/
|
|
1321
|
-
function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
|
|
1327
|
+
function getDisplayLabel(validator, schema, uiSchema, rootSchema, globalOptions) {
|
|
1322
1328
|
if (uiSchema === void 0) {
|
|
1323
1329
|
uiSchema = {};
|
|
1324
1330
|
}
|
|
1325
|
-
var uiOptions = getUiOptions(uiSchema);
|
|
1331
|
+
var uiOptions = getUiOptions(uiSchema, globalOptions);
|
|
1326
1332
|
var _uiOptions$label = uiOptions.label,
|
|
1327
1333
|
label = _uiOptions$label === void 0 ? true : _uiOptions$label;
|
|
1328
1334
|
var displayLabel = !!label;
|
|
@@ -1683,10 +1689,11 @@ var SchemaUtils = /*#__PURE__*/function () {
|
|
|
1683
1689
|
*
|
|
1684
1690
|
* @param schema - The schema for which the display label flag is desired
|
|
1685
1691
|
* @param [uiSchema] - The UI schema from which to derive potentially displayable information
|
|
1692
|
+
* @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
|
|
1686
1693
|
* @returns - True if the label should be displayed or false if it should not
|
|
1687
1694
|
*/;
|
|
1688
|
-
_proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema) {
|
|
1689
|
-
return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
|
|
1695
|
+
_proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema, globalOptions) {
|
|
1696
|
+
return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
|
|
1690
1697
|
}
|
|
1691
1698
|
/** Determines which of the given `options` provided most closely matches the `formData`.
|
|
1692
1699
|
* Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
|
|
@@ -2291,6 +2298,7 @@ var widgetMap = {
|
|
|
2291
2298
|
'date-time': 'DateTimeWidget',
|
|
2292
2299
|
'alt-date': 'AltDateWidget',
|
|
2293
2300
|
'alt-datetime': 'AltDateTimeWidget',
|
|
2301
|
+
time: 'TimeWidget',
|
|
2294
2302
|
color: 'ColorWidget',
|
|
2295
2303
|
file: 'FileWidget'
|
|
2296
2304
|
},
|
|
@@ -2760,6 +2768,8 @@ exports.TranslatableString = void 0;
|
|
|
2760
2768
|
TranslatableString["AddButton"] = "Add";
|
|
2761
2769
|
/** Add button title, used by AddButton */
|
|
2762
2770
|
TranslatableString["AddItemButton"] = "Add Item";
|
|
2771
|
+
/** Copy button title, used by IconButton */
|
|
2772
|
+
TranslatableString["CopyButton"] = "Copy";
|
|
2763
2773
|
/** Move down button title, used by IconButton */
|
|
2764
2774
|
TranslatableString["MoveDownButton"] = "Move down";
|
|
2765
2775
|
/** Move up button title, used by IconButton */
|
|
@@ -2788,6 +2798,8 @@ exports.TranslatableString = void 0;
|
|
|
2788
2798
|
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
2789
2799
|
TranslatableString["KeyLabel"] = "%1 Key";
|
|
2790
2800
|
// Strings with replaceable parameters AND/OR that support markdown and html
|
|
2801
|
+
/** Invalid object field configuration as provided by the ObjectField */
|
|
2802
|
+
TranslatableString["InvalidObjectField"] = "Invalid \"%1\" object field configuration: <em>%2</em>.";
|
|
2791
2803
|
/** Unsupported field schema, used by UnsupportedField */
|
|
2792
2804
|
TranslatableString["UnsupportedField"] = "Unsupported field schema.";
|
|
2793
2805
|
/** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
|
|
@@ -2825,6 +2837,7 @@ exports.REQUIRED_KEY = REQUIRED_KEY;
|
|
|
2825
2837
|
exports.RJSF_ADDITONAL_PROPERTIES_FLAG = RJSF_ADDITONAL_PROPERTIES_FLAG;
|
|
2826
2838
|
exports.SUBMIT_BTN_OPTIONS_KEY = SUBMIT_BTN_OPTIONS_KEY;
|
|
2827
2839
|
exports.UI_FIELD_KEY = UI_FIELD_KEY;
|
|
2840
|
+
exports.UI_GLOBAL_OPTIONS_KEY = UI_GLOBAL_OPTIONS_KEY;
|
|
2828
2841
|
exports.UI_OPTIONS_KEY = UI_OPTIONS_KEY;
|
|
2829
2842
|
exports.UI_WIDGET_KEY = UI_WIDGET_KEY;
|
|
2830
2843
|
exports.allowAdditionalItems = allowAdditionalItems;
|