@rjsf/utils 5.3.1 → 5.5.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 +28 -4
- package/dist/utils.cjs.development.js +7 -0
- 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 +7 -1
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.umd.development.js +7 -0
- 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 +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { ReactElement, ComponentType, HTMLAttributes, StyleHTMLAttributes, ReactNode, ChangeEvent, ButtonHTMLAttributes } from 'react';
|
|
2
3
|
import * as json_schema from 'json-schema';
|
|
3
4
|
import { JSONSchema7 } from 'json-schema';
|
|
4
5
|
|
|
@@ -41,6 +42,8 @@ declare enum TranslatableString {
|
|
|
41
42
|
ClearLabel = "Clear",
|
|
42
43
|
/** Aria date label, used by DateWidget */
|
|
43
44
|
AriaDateLabel = "Select a date",
|
|
45
|
+
/** File preview label, used by FileWidget */
|
|
46
|
+
PreviewLabel = "Preview",
|
|
44
47
|
/** Decrement button aria label, used by UpDownWidget */
|
|
45
48
|
DecrementAriaLabel = "Decrease value by 1",
|
|
46
49
|
/** Increment button aria label, used by UpDownWidget */
|
|
@@ -605,6 +608,8 @@ type ObjectFieldTemplateProps<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
605
608
|
uiSchema?: UiSchema<T, S, F>;
|
|
606
609
|
/** An object containing the id for this object & ids for its properties */
|
|
607
610
|
idSchema: IdSchema<T>;
|
|
611
|
+
/** The optional validation errors in the form of an `ErrorSchema` */
|
|
612
|
+
errorSchema?: ErrorSchema<T>;
|
|
608
613
|
/** The form data for the object */
|
|
609
614
|
formData?: T;
|
|
610
615
|
/** The `formContext` object that was passed to Form */
|
|
@@ -662,6 +667,10 @@ interface WidgetProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
|
|
662
667
|
onFocus: (id: string, value: any) => void;
|
|
663
668
|
/** The computed label for this widget, as a string */
|
|
664
669
|
label: string;
|
|
670
|
+
/** A boolean value, if true, will cause the label to be hidden. This is useful for nested fields where you don't want
|
|
671
|
+
* to clutter the UI. Customized via `label` in the `UiSchema`
|
|
672
|
+
*/
|
|
673
|
+
hideLabel?: boolean;
|
|
665
674
|
/** A boolean value stating if the widget can accept multiple values */
|
|
666
675
|
multiple?: boolean;
|
|
667
676
|
/** An array of strings listing all generated error messages from encountered errors for this widget */
|
|
@@ -758,6 +767,8 @@ type UIOptionsBaseType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exten
|
|
|
758
767
|
readonly?: boolean;
|
|
759
768
|
/** This property allows you to reorder the properties that are shown for a particular object */
|
|
760
769
|
order?: string[];
|
|
770
|
+
/** Flag, if set to `true`, will cause the `FileWidget` to show a preview (with download for non-image files) */
|
|
771
|
+
filePreview?: boolean;
|
|
761
772
|
/** Flag, if set to `true`, will mark a list of checkboxes as displayed all on one line instead of one per row */
|
|
762
773
|
inline?: boolean;
|
|
763
774
|
/** Used to change the input type (for example, `tel` or `email`) for an <input> */
|
|
@@ -850,7 +861,7 @@ interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
|
|
|
850
861
|
/** Runs the pure validation of the `schema` and `formData` without any of the RJSF functionality. Provided for use
|
|
851
862
|
* by the playground. Returns the `errors` from the validation
|
|
852
863
|
*
|
|
853
|
-
* @param schema - The schema against which to validate the form data
|
|
864
|
+
* @param schema - The schema against which to validate the form data
|
|
854
865
|
* @param formData - The form data to validate
|
|
855
866
|
*/
|
|
856
867
|
rawValidation<Result = any>(schema: S, formData?: T): {
|
|
@@ -1359,6 +1370,19 @@ declare function isFixedItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S
|
|
|
1359
1370
|
*/
|
|
1360
1371
|
declare function isObject(thing: any): boolean;
|
|
1361
1372
|
|
|
1373
|
+
/** Helper function that will return the value to use for a widget `label` based on `hideLabel`. The `fallback` is used
|
|
1374
|
+
* as the return value from the function when `hideLabel` is true. Due to the implementation of theme components, it
|
|
1375
|
+
* may be necessary to return something other than `undefined` to cause the theme component to not render a label. Some
|
|
1376
|
+
* themes require may `false` and others may require and empty string.
|
|
1377
|
+
*
|
|
1378
|
+
* @param [label] - The label string or component to render when not hidden
|
|
1379
|
+
* @param [hideLabel] - Flag, if true, will cause the label to be hidden
|
|
1380
|
+
* @param [fallback] - One of 3 values, `undefined` (the default), `false` or an empty string
|
|
1381
|
+
* @returns - `fallback` if `hideLabel` is true, otherwise `label`
|
|
1382
|
+
*/
|
|
1383
|
+
declare function labelValue(label?: string | ReactElement, hideLabel?: boolean, fallback?: ''): undefined | string;
|
|
1384
|
+
declare function labelValue(label?: string | ReactElement, hideLabel?: boolean, fallback?: false | ''): string | false | ReactElement<any, string | react.JSXElementConstructor<any>> | undefined;
|
|
1385
|
+
|
|
1362
1386
|
/** Converts a local Date string into a UTC date string
|
|
1363
1387
|
*
|
|
1364
1388
|
* @param dateString - The string representation of a date as accepted by the `Date()` constructor
|
|
@@ -1479,7 +1503,7 @@ declare function schemaRequiresTrueValue<S extends StrictRJSFSchema = RJSFSchema
|
|
|
1479
1503
|
* @param nextState - The next set of state against which to check
|
|
1480
1504
|
* @returns - True if the component should be re-rendered, false otherwise
|
|
1481
1505
|
*/
|
|
1482
|
-
declare function shouldRender(component:
|
|
1506
|
+
declare function shouldRender(component: react__default.Component, nextProps: any, nextState: any): boolean;
|
|
1483
1507
|
|
|
1484
1508
|
/** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise
|
|
1485
1509
|
* throws an error.
|
|
@@ -1731,4 +1755,4 @@ declare function toIdSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
1731
1755
|
*/
|
|
1732
1756
|
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>;
|
|
1733
1757
|
|
|
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 };
|
|
1758
|
+
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, labelValue, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
|
|
@@ -2484,6 +2484,10 @@ function optionId(id, optionIndex) {
|
|
|
2484
2484
|
return id + "-" + optionIndex;
|
|
2485
2485
|
}
|
|
2486
2486
|
|
|
2487
|
+
function labelValue(label, hideLabel, fallback) {
|
|
2488
|
+
return hideLabel ? fallback : label;
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2487
2491
|
/** Converts a local Date string into a UTC date string
|
|
2488
2492
|
*
|
|
2489
2493
|
* @param dateString - The string representation of a date as accepted by the `Date()` constructor
|
|
@@ -2782,6 +2786,8 @@ exports.TranslatableString = void 0;
|
|
|
2782
2786
|
TranslatableString["ClearLabel"] = "Clear";
|
|
2783
2787
|
/** Aria date label, used by DateWidget */
|
|
2784
2788
|
TranslatableString["AriaDateLabel"] = "Select a date";
|
|
2789
|
+
/** File preview label, used by FileWidget */
|
|
2790
|
+
TranslatableString["PreviewLabel"] = "Preview";
|
|
2785
2791
|
/** Decrement button aria label, used by UpDownWidget */
|
|
2786
2792
|
TranslatableString["DecrementAriaLabel"] = "Decrease value by 1";
|
|
2787
2793
|
/** Increment button aria label, used by UpDownWidget */
|
|
@@ -2878,6 +2884,7 @@ exports.isFixedItems = isFixedItems;
|
|
|
2878
2884
|
exports.isMultiSelect = isMultiSelect;
|
|
2879
2885
|
exports.isObject = isObject;
|
|
2880
2886
|
exports.isSelect = isSelect;
|
|
2887
|
+
exports.labelValue = labelValue;
|
|
2881
2888
|
exports.localToUTC = localToUTC;
|
|
2882
2889
|
exports.mergeDefaultsWithFormData = mergeDefaultsWithFormData;
|
|
2883
2890
|
exports.mergeObjects = mergeObjects;
|