@rjsf/utils 5.11.2 → 5.12.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.js +2544 -5
- package/dist/index.js.map +7 -0
- package/dist/utils.esm.js +1228 -2113
- package/dist/utils.esm.js.map +7 -1
- package/dist/utils.umd.js +2414 -0
- package/lib/ErrorSchemaBuilder.d.ts +60 -0
- package/lib/ErrorSchemaBuilder.js +103 -0
- package/lib/ErrorSchemaBuilder.js.map +1 -0
- package/lib/allowAdditionalItems.d.ts +8 -0
- package/lib/allowAdditionalItems.js +14 -0
- package/lib/allowAdditionalItems.js.map +1 -0
- package/lib/asNumber.d.ts +10 -0
- package/lib/asNumber.js +36 -0
- package/lib/asNumber.js.map +1 -0
- package/lib/canExpand.d.ts +11 -0
- package/lib/canExpand.js +26 -0
- package/lib/canExpand.js.map +1 -0
- package/lib/constants.d.ts +31 -0
- package/lib/constants.js +32 -0
- package/lib/constants.js.map +1 -0
- package/lib/createErrorHandler.d.ts +7 -0
- package/lib/createErrorHandler.js +31 -0
- package/lib/createErrorHandler.js.map +1 -0
- package/lib/createSchemaUtils.d.ts +10 -0
- package/lib/createSchemaUtils.js +207 -0
- package/lib/createSchemaUtils.js.map +1 -0
- package/lib/dataURItoBlob.d.ts +16 -0
- package/lib/dataURItoBlob.js +43 -0
- package/lib/dataURItoBlob.js.map +1 -0
- package/lib/deepEquals.d.ts +8 -0
- package/lib/deepEquals.js +19 -0
- package/lib/deepEquals.js.map +1 -0
- package/lib/englishStringTranslator.d.ts +10 -0
- package/lib/englishStringTranslator.js +13 -0
- package/lib/englishStringTranslator.js.map +1 -0
- package/lib/enumOptionsDeselectValue.d.ts +14 -0
- package/lib/enumOptionsDeselectValue.js +22 -0
- package/lib/enumOptionsDeselectValue.js.map +1 -0
- package/lib/enumOptionsIndexForValue.d.ts +13 -0
- package/lib/enumOptionsIndexForValue.js +22 -0
- package/lib/enumOptionsIndexForValue.js.map +1 -0
- package/lib/enumOptionsIsSelected.d.ts +8 -0
- package/lib/enumOptionsIsSelected.js +14 -0
- package/lib/enumOptionsIsSelected.js.map +1 -0
- package/lib/enumOptionsSelectValue.d.ts +10 -0
- package/lib/enumOptionsSelectValue.js +23 -0
- package/lib/enumOptionsSelectValue.js.map +1 -0
- package/lib/enumOptionsValueForIndex.d.ts +13 -0
- package/lib/enumOptionsValueForIndex.js +21 -0
- package/lib/enumOptionsValueForIndex.js.map +1 -0
- package/lib/enums.d.ts +72 -0
- package/lib/enums.js +76 -0
- package/lib/enums.js.map +1 -0
- package/lib/findSchemaDefinition.d.ts +20 -0
- package/lib/findSchemaDefinition.js +49 -0
- package/lib/findSchemaDefinition.js.map +1 -0
- package/lib/getDiscriminatorFieldFromSchema.d.ts +8 -0
- package/lib/getDiscriminatorFieldFromSchema.js +20 -0
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -0
- package/lib/getInputProps.d.ts +10 -0
- package/lib/getInputProps.js +41 -0
- package/lib/getInputProps.js.map +1 -0
- package/lib/getSchemaType.d.ts +13 -0
- package/lib/getSchemaType.js +29 -0
- package/lib/getSchemaType.js.map +1 -0
- package/lib/getSubmitButtonOptions.d.ts +10 -0
- package/lib/getSubmitButtonOptions.js +25 -0
- package/lib/getSubmitButtonOptions.js.map +1 -0
- package/lib/getTemplate.d.ts +10 -0
- package/lib/getTemplate.js +19 -0
- package/lib/getTemplate.js.map +1 -0
- package/lib/getUiOptions.d.ts +9 -0
- package/lib/getUiOptions.js +25 -0
- package/lib/getUiOptions.js.map +1 -0
- package/lib/getWidget.d.ts +13 -0
- package/lib/getWidget.js +118 -0
- package/lib/getWidget.js.map +1 -0
- package/lib/guessType.d.ts +7 -0
- package/lib/guessType.js +29 -0
- package/lib/guessType.js.map +1 -0
- package/lib/hasWidget.d.ts +10 -0
- package/lib/hasWidget.js +23 -0
- package/lib/hasWidget.js.map +1 -0
- package/lib/hashForSchema.d.ts +8 -0
- package/lib/hashForSchema.js +29 -0
- package/lib/hashForSchema.js.map +1 -0
- package/lib/idGenerators.d.ts +47 -0
- package/lib/idGenerators.js +73 -0
- package/lib/idGenerators.js.map +1 -0
- package/lib/index.d.ts +57 -0
- package/lib/index.js +58 -0
- package/lib/index.js.map +1 -0
- package/lib/isConstant.d.ts +8 -0
- package/lib/isConstant.js +11 -0
- package/lib/isConstant.js.map +1 -0
- package/lib/isCustomWidget.d.ts +7 -0
- package/lib/isCustomWidget.js +13 -0
- package/lib/isCustomWidget.js.map +1 -0
- package/lib/isFixedItems.d.ts +8 -0
- package/lib/isFixedItems.js +11 -0
- package/lib/isFixedItems.js.map +1 -0
- package/lib/isObject.d.ts +7 -0
- package/lib/isObject.js +16 -0
- package/lib/isObject.js.map +1 -0
- package/lib/labelValue.d.ts +13 -0
- package/lib/labelValue.js +4 -0
- package/lib/labelValue.js.map +1 -0
- package/lib/localToUTC.d.ts +6 -0
- package/lib/localToUTC.js +9 -0
- package/lib/localToUTC.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.d.ts +17 -0
- package/lib/mergeDefaultsWithFormData.js +43 -0
- package/lib/mergeDefaultsWithFormData.js.map +1 -0
- package/lib/mergeObjects.d.ts +11 -0
- package/lib/mergeObjects.js +35 -0
- package/lib/mergeObjects.js.map +1 -0
- package/lib/mergeSchemas.d.ts +10 -0
- package/lib/mergeSchemas.js +35 -0
- package/lib/mergeSchemas.js.map +1 -0
- package/lib/optionsList.d.ts +10 -0
- package/lib/optionsList.js +36 -0
- package/lib/optionsList.js.map +1 -0
- package/lib/orderProperties.d.ts +11 -0
- package/lib/orderProperties.js +38 -0
- package/lib/orderProperties.js.map +1 -0
- package/lib/pad.d.ts +7 -0
- package/lib/pad.js +14 -0
- package/lib/pad.js.map +1 -0
- package/lib/parseDateString.d.ts +9 -0
- package/lib/parseDateString.js +32 -0
- package/lib/parseDateString.js.map +1 -0
- package/lib/parser/ParserValidator.d.ts +70 -0
- package/lib/parser/ParserValidator.js +93 -0
- package/lib/parser/ParserValidator.js.map +1 -0
- package/lib/parser/index.d.ts +4 -0
- package/lib/parser/index.js +3 -0
- package/lib/parser/index.js.map +1 -0
- package/lib/parser/schemaParser.d.ts +9 -0
- package/lib/parser/schemaParser.js +48 -0
- package/lib/parser/schemaParser.js.map +1 -0
- package/lib/rangeSpec.d.ts +9 -0
- package/lib/rangeSpec.js +20 -0
- package/lib/rangeSpec.js.map +1 -0
- package/lib/replaceStringParameters.d.ts +9 -0
- package/lib/replaceStringParameters.js +23 -0
- package/lib/replaceStringParameters.js.map +1 -0
- package/lib/schema/getClosestMatchingOption.d.ts +49 -0
- package/lib/schema/getClosestMatchingOption.js +154 -0
- package/lib/schema/getClosestMatchingOption.js.map +1 -0
- package/lib/schema/getDefaultFormState.d.ts +66 -0
- package/lib/schema/getDefaultFormState.js +351 -0
- package/lib/schema/getDefaultFormState.js.map +1 -0
- package/lib/schema/getDisplayLabel.d.ts +12 -0
- package/lib/schema/getDisplayLabel.js +39 -0
- package/lib/schema/getDisplayLabel.js.map +1 -0
- package/lib/schema/getFirstMatchingOption.d.ts +13 -0
- package/lib/schema/getFirstMatchingOption.js +16 -0
- package/lib/schema/getFirstMatchingOption.js.map +1 -0
- package/lib/schema/getMatchingOption.d.ts +14 -0
- package/lib/schema/getMatchingOption.js +80 -0
- package/lib/schema/getMatchingOption.js.map +1 -0
- package/lib/schema/index.d.ts +14 -0
- package/lib/schema/index.js +15 -0
- package/lib/schema/index.js.map +1 -0
- package/lib/schema/isFilesArray.d.ts +10 -0
- package/lib/schema/isFilesArray.js +21 -0
- package/lib/schema/isFilesArray.js.map +1 -0
- package/lib/schema/isMultiSelect.d.ts +9 -0
- package/lib/schema/isMultiSelect.js +15 -0
- package/lib/schema/isMultiSelect.js.map +1 -0
- package/lib/schema/isSelect.d.ts +9 -0
- package/lib/schema/isSelect.js +21 -0
- package/lib/schema/isSelect.js.map +1 -0
- package/lib/schema/mergeValidationData.d.ts +14 -0
- package/lib/schema/mergeValidationData.js +28 -0
- package/lib/schema/mergeValidationData.js.map +1 -0
- package/lib/schema/retrieveSchema.d.ts +170 -0
- package/lib/schema/retrieveSchema.js +437 -0
- package/lib/schema/retrieveSchema.js.map +1 -0
- package/lib/schema/sanitizeDataForNewSchema.d.ts +49 -0
- package/lib/schema/sanitizeDataForNewSchema.js +173 -0
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -0
- package/lib/schema/toIdSchema.d.ts +13 -0
- package/lib/schema/toIdSchema.js +59 -0
- package/lib/schema/toIdSchema.js.map +1 -0
- package/lib/schema/toPathSchema.d.ts +11 -0
- package/lib/schema/toPathSchema.js +68 -0
- package/lib/schema/toPathSchema.js.map +1 -0
- package/lib/schemaRequiresTrueValue.d.ts +11 -0
- package/lib/schemaRequiresTrueValue.js +34 -0
- package/lib/schemaRequiresTrueValue.js.map +1 -0
- package/lib/shouldRender.d.ts +10 -0
- package/lib/shouldRender.js +14 -0
- package/lib/shouldRender.js.map +1 -0
- package/lib/toConstant.d.ts +9 -0
- package/lib/toConstant.js +18 -0
- package/lib/toConstant.js.map +1 -0
- package/lib/toDateString.d.ts +9 -0
- package/lib/toDateString.js +14 -0
- package/lib/toDateString.js.map +1 -0
- package/lib/toErrorList.d.ts +8 -0
- package/lib/toErrorList.js +34 -0
- package/lib/toErrorList.js.map +1 -0
- package/lib/toErrorSchema.d.ts +21 -0
- package/lib/toErrorSchema.js +41 -0
- package/lib/toErrorSchema.js.map +1 -0
- package/lib/types.d.ts +982 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/unwrapErrorHandler.d.ts +7 -0
- package/lib/unwrapErrorHandler.js +21 -0
- package/lib/unwrapErrorHandler.js.map +1 -0
- package/lib/utcToLocal.d.ts +6 -0
- package/lib/utcToLocal.js +26 -0
- package/lib/utcToLocal.js.map +1 -0
- package/lib/validationDataMerge.d.ts +11 -0
- package/lib/validationDataMerge.js +26 -0
- package/lib/validationDataMerge.js.map +1 -0
- package/lib/withIdRefPrefix.d.ts +8 -0
- package/lib/withIdRefPrefix.js +47 -0
- package/lib/withIdRefPrefix.js.map +1 -0
- package/package.json +20 -13
- package/src/ErrorSchemaBuilder.ts +112 -0
- package/src/allowAdditionalItems.ts +15 -0
- package/src/asNumber.ts +38 -0
- package/src/canExpand.ts +31 -0
- package/src/constants.ts +31 -0
- package/src/createErrorHandler.ts +33 -0
- package/src/createSchemaUtils.ts +298 -0
- package/src/dataURItoBlob.ts +42 -0
- package/src/deepEquals.ts +19 -0
- package/src/englishStringTranslator.ts +14 -0
- package/src/enumOptionsDeselectValue.ts +28 -0
- package/src/enumOptionsIndexForValue.ts +27 -0
- package/src/enumOptionsIsSelected.ts +19 -0
- package/src/enumOptionsSelectValue.ts +28 -0
- package/src/enumOptionsValueForIndex.ts +26 -0
- package/src/enums.ts +74 -0
- package/src/findSchemaDefinition.ts +54 -0
- package/src/getDiscriminatorFieldFromSchema.ts +21 -0
- package/src/getInputProps.ts +55 -0
- package/src/getSchemaType.ts +37 -0
- package/src/getSubmitButtonOptions.ts +32 -0
- package/src/getTemplate.ts +26 -0
- package/src/getUiOptions.ts +32 -0
- package/src/getWidget.tsx +133 -0
- package/src/guessType.ts +28 -0
- package/src/hasWidget.ts +27 -0
- package/src/hashForSchema.ts +31 -0
- package/src/idGenerators.ts +81 -0
- package/src/index.ts +118 -0
- package/src/isConstant.ts +12 -0
- package/src/isCustomWidget.ts +19 -0
- package/src/isFixedItems.ts +12 -0
- package/src/isObject.ts +15 -0
- package/src/labelValue.ts +16 -0
- package/src/localToUTC.ts +8 -0
- package/src/mergeDefaultsWithFormData.ts +53 -0
- package/src/mergeObjects.ts +39 -0
- package/src/mergeSchemas.ts +38 -0
- package/src/optionsList.ts +41 -0
- package/src/orderProperties.ts +44 -0
- package/src/pad.ts +13 -0
- package/src/parseDateString.ts +33 -0
- package/src/parser/ParserValidator.ts +132 -0
- package/src/parser/index.ts +6 -0
- package/src/parser/schemaParser.ts +60 -0
- package/src/rangeSpec.ts +22 -0
- package/src/replaceStringParameters.ts +22 -0
- package/src/schema/getClosestMatchingOption.ts +191 -0
- package/src/schema/getDefaultFormState.ts +447 -0
- package/src/schema/getDisplayLabel.ts +59 -0
- package/src/schema/getFirstMatchingOption.ts +27 -0
- package/src/schema/getMatchingOption.ts +95 -0
- package/src/schema/index.ts +29 -0
- package/src/schema/isFilesArray.ts +27 -0
- package/src/schema/isMultiSelect.ts +21 -0
- package/src/schema/isSelect.ts +26 -0
- package/src/schema/mergeValidationData.ts +38 -0
- package/src/schema/retrieveSchema.ts +614 -0
- package/src/schema/sanitizeDataForNewSchema.ts +197 -0
- package/src/schema/toIdSchema.ts +105 -0
- package/src/schema/toPathSchema.ts +121 -0
- package/src/schemaRequiresTrueValue.ts +40 -0
- package/src/shouldRender.ts +16 -0
- package/src/toConstant.ts +19 -0
- package/src/toDateString.ts +15 -0
- package/src/toErrorList.ts +41 -0
- package/src/toErrorSchema.ts +43 -0
- package/src/types.ts +1139 -0
- package/src/unwrapErrorHandler.ts +25 -0
- package/src/utcToLocal.ts +30 -0
- package/src/validationDataMerge.ts +31 -0
- package/src/withIdRefPrefix.ts +49 -0
- package/dist/index.d.ts +0 -1911
- package/dist/utils.cjs.development.js +0 -3522
- package/dist/utils.cjs.development.js.map +0 -1
- package/dist/utils.cjs.production.min.js +0 -2
- package/dist/utils.cjs.production.min.js.map +0 -1
- package/dist/utils.umd.development.js +0 -3504
- package/dist/utils.umd.development.js.map +0 -1
- package/dist/utils.umd.production.min.js +0 -2
- package/dist/utils.umd.production.min.js.map +0 -1
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import allowAdditionalItems from './allowAdditionalItems';
|
|
2
|
+
import asNumber from './asNumber';
|
|
3
|
+
import canExpand from './canExpand';
|
|
4
|
+
import createErrorHandler from './createErrorHandler';
|
|
5
|
+
import createSchemaUtils from './createSchemaUtils';
|
|
6
|
+
import dataURItoBlob from './dataURItoBlob';
|
|
7
|
+
import deepEquals from './deepEquals';
|
|
8
|
+
import englishStringTranslator from './englishStringTranslator';
|
|
9
|
+
import enumOptionsDeselectValue from './enumOptionsDeselectValue';
|
|
10
|
+
import enumOptionsIndexForValue from './enumOptionsIndexForValue';
|
|
11
|
+
import enumOptionsIsSelected from './enumOptionsIsSelected';
|
|
12
|
+
import enumOptionsSelectValue from './enumOptionsSelectValue';
|
|
13
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
14
|
+
import ErrorSchemaBuilder from './ErrorSchemaBuilder';
|
|
15
|
+
import findSchemaDefinition from './findSchemaDefinition';
|
|
16
|
+
import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';
|
|
17
|
+
import getInputProps from './getInputProps';
|
|
18
|
+
import getSchemaType from './getSchemaType';
|
|
19
|
+
import getSubmitButtonOptions from './getSubmitButtonOptions';
|
|
20
|
+
import getTemplate from './getTemplate';
|
|
21
|
+
import getUiOptions from './getUiOptions';
|
|
22
|
+
import getWidget from './getWidget';
|
|
23
|
+
import guessType from './guessType';
|
|
24
|
+
import hashForSchema from './hashForSchema';
|
|
25
|
+
import hasWidget from './hasWidget';
|
|
26
|
+
import { ariaDescribedByIds, descriptionId, errorId, examplesId, helpId, optionId, titleId } from './idGenerators';
|
|
27
|
+
import isConstant from './isConstant';
|
|
28
|
+
import isCustomWidget from './isCustomWidget';
|
|
29
|
+
import isFixedItems from './isFixedItems';
|
|
30
|
+
import isObject from './isObject';
|
|
31
|
+
import labelValue from './labelValue';
|
|
32
|
+
import localToUTC from './localToUTC';
|
|
33
|
+
import mergeDefaultsWithFormData from './mergeDefaultsWithFormData';
|
|
34
|
+
import mergeObjects from './mergeObjects';
|
|
35
|
+
import mergeSchemas from './mergeSchemas';
|
|
36
|
+
import optionsList from './optionsList';
|
|
37
|
+
import orderProperties from './orderProperties';
|
|
38
|
+
import pad from './pad';
|
|
39
|
+
import parseDateString from './parseDateString';
|
|
40
|
+
import rangeSpec from './rangeSpec';
|
|
41
|
+
import replaceStringParameters from './replaceStringParameters';
|
|
42
|
+
import schemaRequiresTrueValue from './schemaRequiresTrueValue';
|
|
43
|
+
import shouldRender from './shouldRender';
|
|
44
|
+
import toConstant from './toConstant';
|
|
45
|
+
import toDateString from './toDateString';
|
|
46
|
+
import toErrorList from './toErrorList';
|
|
47
|
+
import toErrorSchema from './toErrorSchema';
|
|
48
|
+
import unwrapErrorHandler from './unwrapErrorHandler';
|
|
49
|
+
import utcToLocal from './utcToLocal';
|
|
50
|
+
import validationDataMerge from './validationDataMerge';
|
|
51
|
+
import withIdRefPrefix from './withIdRefPrefix';
|
|
52
|
+
export * from './types';
|
|
53
|
+
export * from './enums';
|
|
54
|
+
export * from './constants';
|
|
55
|
+
export * from './parser';
|
|
56
|
+
export * from './schema';
|
|
57
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getDiscriminatorFieldFromSchema, getInputProps, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import allowAdditionalItems from './allowAdditionalItems';
|
|
2
|
+
import asNumber from './asNumber';
|
|
3
|
+
import canExpand from './canExpand';
|
|
4
|
+
import createErrorHandler from './createErrorHandler';
|
|
5
|
+
import createSchemaUtils from './createSchemaUtils';
|
|
6
|
+
import dataURItoBlob from './dataURItoBlob';
|
|
7
|
+
import deepEquals from './deepEquals';
|
|
8
|
+
import englishStringTranslator from './englishStringTranslator';
|
|
9
|
+
import enumOptionsDeselectValue from './enumOptionsDeselectValue';
|
|
10
|
+
import enumOptionsIndexForValue from './enumOptionsIndexForValue';
|
|
11
|
+
import enumOptionsIsSelected from './enumOptionsIsSelected';
|
|
12
|
+
import enumOptionsSelectValue from './enumOptionsSelectValue';
|
|
13
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
14
|
+
import ErrorSchemaBuilder from './ErrorSchemaBuilder';
|
|
15
|
+
import findSchemaDefinition from './findSchemaDefinition';
|
|
16
|
+
import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';
|
|
17
|
+
import getInputProps from './getInputProps';
|
|
18
|
+
import getSchemaType from './getSchemaType';
|
|
19
|
+
import getSubmitButtonOptions from './getSubmitButtonOptions';
|
|
20
|
+
import getTemplate from './getTemplate';
|
|
21
|
+
import getUiOptions from './getUiOptions';
|
|
22
|
+
import getWidget from './getWidget';
|
|
23
|
+
import guessType from './guessType';
|
|
24
|
+
import hashForSchema from './hashForSchema';
|
|
25
|
+
import hasWidget from './hasWidget';
|
|
26
|
+
import { ariaDescribedByIds, descriptionId, errorId, examplesId, helpId, optionId, titleId } from './idGenerators';
|
|
27
|
+
import isConstant from './isConstant';
|
|
28
|
+
import isCustomWidget from './isCustomWidget';
|
|
29
|
+
import isFixedItems from './isFixedItems';
|
|
30
|
+
import isObject from './isObject';
|
|
31
|
+
import labelValue from './labelValue';
|
|
32
|
+
import localToUTC from './localToUTC';
|
|
33
|
+
import mergeDefaultsWithFormData from './mergeDefaultsWithFormData';
|
|
34
|
+
import mergeObjects from './mergeObjects';
|
|
35
|
+
import mergeSchemas from './mergeSchemas';
|
|
36
|
+
import optionsList from './optionsList';
|
|
37
|
+
import orderProperties from './orderProperties';
|
|
38
|
+
import pad from './pad';
|
|
39
|
+
import parseDateString from './parseDateString';
|
|
40
|
+
import rangeSpec from './rangeSpec';
|
|
41
|
+
import replaceStringParameters from './replaceStringParameters';
|
|
42
|
+
import schemaRequiresTrueValue from './schemaRequiresTrueValue';
|
|
43
|
+
import shouldRender from './shouldRender';
|
|
44
|
+
import toConstant from './toConstant';
|
|
45
|
+
import toDateString from './toDateString';
|
|
46
|
+
import toErrorList from './toErrorList';
|
|
47
|
+
import toErrorSchema from './toErrorSchema';
|
|
48
|
+
import unwrapErrorHandler from './unwrapErrorHandler';
|
|
49
|
+
import utcToLocal from './utcToLocal';
|
|
50
|
+
import validationDataMerge from './validationDataMerge';
|
|
51
|
+
import withIdRefPrefix from './withIdRefPrefix';
|
|
52
|
+
export * from './types';
|
|
53
|
+
export * from './enums';
|
|
54
|
+
export * from './constants';
|
|
55
|
+
export * from './parser';
|
|
56
|
+
export * from './schema';
|
|
57
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getDiscriminatorFieldFromSchema, getInputProps, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAA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tB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,MAAM,EACN,UAAU,EACV,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,eAAe,EACf,GAAG,EACH,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,eAAe,GAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RJSFSchema, StrictRJSFSchema } from './types';
|
|
2
|
+
/** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
|
|
3
|
+
* an `enum` array with a single value or there is a `const` defined.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema for a field
|
|
6
|
+
* @returns - True if the `schema` has a single constant value, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export default function isConstant<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CONST_KEY } from './constants';
|
|
2
|
+
/** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
|
|
3
|
+
* an `enum` array with a single value or there is a `const` defined.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema for a field
|
|
6
|
+
* @returns - True if the `schema` has a single constant value, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export default function isConstant(schema) {
|
|
9
|
+
return (Array.isArray(schema.enum) && schema.enum.length === 1) || CONST_KEY in schema;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=isConstant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isConstant.js","sourceRoot":"","sources":["../src/isConstant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAA0C,MAAS;IACnF,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,SAAS,IAAI,MAAM,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';
|
|
2
|
+
/** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
|
|
3
|
+
*
|
|
4
|
+
* @param uiSchema - The UI Schema from which to detect if it is customized
|
|
5
|
+
* @returns - True if the `uiSchema` describes a custom widget, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export default function isCustomWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(uiSchema?: UiSchema<T, S, F>): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import getUiOptions from './getUiOptions';
|
|
2
|
+
/** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
|
|
3
|
+
*
|
|
4
|
+
* @param uiSchema - The UI Schema from which to detect if it is customized
|
|
5
|
+
* @returns - True if the `uiSchema` describes a custom widget, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export default function isCustomWidget(uiSchema = {}) {
|
|
8
|
+
return (
|
|
9
|
+
// TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
|
|
10
|
+
// https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
|
|
11
|
+
'widget' in getUiOptions(uiSchema) && getUiOptions(uiSchema)['widget'] !== 'hidden');
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=isCustomWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isCustomWidget.js","sourceRoot":"","sources":["../src/isCustomWidget.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAG1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAIpC,WAA8B,EAAE;IAChC,OAAO;IACL,sGAAsG;IACtG,uFAAuF;IACvF,QAAQ,IAAI,YAAY,CAAU,QAAQ,CAAC,IAAI,YAAY,CAAU,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,QAAQ,CACtG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RJSFSchema, StrictRJSFSchema } from './types';
|
|
2
|
+
/** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array
|
|
3
|
+
* that only contains objects.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema in which to check for fixed items
|
|
6
|
+
* @returns - True if there are fixed items in the schema, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export default function isFixedItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import isObject from './isObject';
|
|
2
|
+
/** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array
|
|
3
|
+
* that only contains objects.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The schema in which to check for fixed items
|
|
6
|
+
* @returns - True if there are fixed items in the schema, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export default function isFixedItems(schema) {
|
|
9
|
+
return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every((item) => isObject(item));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=isFixedItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isFixedItems.js","sourceRoot":"","sources":["../src/isFixedItems.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAA0C,MAAS;IACrF,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
|
|
2
|
+
* the type `object` but is NOT null, an array or a File.
|
|
3
|
+
*
|
|
4
|
+
* @param thing - The thing to check to see whether it is an object
|
|
5
|
+
* @returns - True if it is a non-null, non-array, non-File object
|
|
6
|
+
*/
|
|
7
|
+
export default function isObject(thing: any): boolean;
|
package/lib/isObject.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
|
|
2
|
+
* the type `object` but is NOT null, an array or a File.
|
|
3
|
+
*
|
|
4
|
+
* @param thing - The thing to check to see whether it is an object
|
|
5
|
+
* @returns - True if it is a non-null, non-array, non-File object
|
|
6
|
+
*/
|
|
7
|
+
export default function isObject(thing) {
|
|
8
|
+
if (typeof File !== 'undefined' && thing instanceof File) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (typeof Date !== 'undefined' && thing instanceof Date) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return typeof thing === 'object' && thing !== null && !Array.isArray(thing);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=isObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isObject.js","sourceRoot":"","sources":["../src/isObject.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAU;IACzC,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,KAAK,YAAY,IAAI,EAAE;QACxD,OAAO,KAAK,CAAC;KACd;IACD,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,KAAK,YAAY,IAAI,EAAE;QACxD,OAAO,KAAK,CAAC;KACd;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
/** Helper function that will return the value to use for a widget `label` based on `hideLabel`. The `fallback` is used
|
|
3
|
+
* as the return value from the function when `hideLabel` is true. Due to the implementation of theme components, it
|
|
4
|
+
* may be necessary to return something other than `undefined` to cause the theme component to not render a label. Some
|
|
5
|
+
* themes require may `false` and others may require an empty string.
|
|
6
|
+
*
|
|
7
|
+
* @param [label] - The label string or component to render when not hidden
|
|
8
|
+
* @param [hideLabel] - Flag, if true, will cause the label to be hidden
|
|
9
|
+
* @param [fallback] - One of 3 values, `undefined` (the default), `false` or an empty string
|
|
10
|
+
* @returns - `fallback` if `hideLabel` is true, otherwise `label`
|
|
11
|
+
*/
|
|
12
|
+
export declare function labelValue(label?: string | ReactElement, hideLabel?: boolean, fallback?: ''): undefined | string;
|
|
13
|
+
export default function labelValue(label?: string | ReactElement, hideLabel?: boolean, fallback?: false | ''): string | false | ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labelValue.js","sourceRoot":"","sources":["../src/labelValue.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAA6B,EAAE,SAAmB,EAAE,QAAqB;IAC1G,OAAO,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Converts a local Date string into a UTC date string
|
|
2
|
+
*
|
|
3
|
+
* @param dateString - The string representation of a date as accepted by the `Date()` constructor
|
|
4
|
+
* @returns - A UTC date string if `dateString` is truthy, otherwise undefined
|
|
5
|
+
*/
|
|
6
|
+
export default function localToUTC(dateString: string): string | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Converts a local Date string into a UTC date string
|
|
2
|
+
*
|
|
3
|
+
* @param dateString - The string representation of a date as accepted by the `Date()` constructor
|
|
4
|
+
* @returns - A UTC date string if `dateString` is truthy, otherwise undefined
|
|
5
|
+
*/
|
|
6
|
+
export default function localToUTC(dateString) {
|
|
7
|
+
return dateString ? new Date(dateString).toJSON() : undefined;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=localToUTC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localToUTC.js","sourceRoot":"","sources":["../src/localToUTC.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,UAAkB;IACnD,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Merges the `defaults` object of type `T` into the `formData` of type `T`
|
|
2
|
+
*
|
|
3
|
+
* When merging defaults and form data, we want to merge in this specific way:
|
|
4
|
+
* - objects are deeply merged
|
|
5
|
+
* - arrays are merged in such a way that:
|
|
6
|
+
* - when the array is set in form data, only array entries set in form data
|
|
7
|
+
* are deeply merged; additional entries from the defaults are ignored unless `mergeExtraArrayDefaults` is true, in
|
|
8
|
+
* which case the extras are appended onto the end of the form data
|
|
9
|
+
* - when the array is not set in form data, the default is copied over
|
|
10
|
+
* - scalars are overwritten/set by form data
|
|
11
|
+
*
|
|
12
|
+
* @param [defaults] - The defaults to merge
|
|
13
|
+
* @param [formData] - The form data into which the defaults will be merged
|
|
14
|
+
* @param [mergeExtraArrayDefaults=false] - If true, any additional default array entries are appended onto the formData
|
|
15
|
+
* @returns - The resulting merged form data with defaults
|
|
16
|
+
*/
|
|
17
|
+
export default function mergeDefaultsWithFormData<T = any>(defaults?: T, formData?: T, mergeExtraArrayDefaults?: boolean): T | undefined;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import isObject from './isObject';
|
|
3
|
+
/** Merges the `defaults` object of type `T` into the `formData` of type `T`
|
|
4
|
+
*
|
|
5
|
+
* When merging defaults and form data, we want to merge in this specific way:
|
|
6
|
+
* - objects are deeply merged
|
|
7
|
+
* - arrays are merged in such a way that:
|
|
8
|
+
* - when the array is set in form data, only array entries set in form data
|
|
9
|
+
* are deeply merged; additional entries from the defaults are ignored unless `mergeExtraArrayDefaults` is true, in
|
|
10
|
+
* which case the extras are appended onto the end of the form data
|
|
11
|
+
* - when the array is not set in form data, the default is copied over
|
|
12
|
+
* - scalars are overwritten/set by form data
|
|
13
|
+
*
|
|
14
|
+
* @param [defaults] - The defaults to merge
|
|
15
|
+
* @param [formData] - The form data into which the defaults will be merged
|
|
16
|
+
* @param [mergeExtraArrayDefaults=false] - If true, any additional default array entries are appended onto the formData
|
|
17
|
+
* @returns - The resulting merged form data with defaults
|
|
18
|
+
*/
|
|
19
|
+
export default function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults = false) {
|
|
20
|
+
if (Array.isArray(formData)) {
|
|
21
|
+
const defaultsArray = Array.isArray(defaults) ? defaults : [];
|
|
22
|
+
const mapped = formData.map((value, idx) => {
|
|
23
|
+
if (defaultsArray[idx]) {
|
|
24
|
+
return mergeDefaultsWithFormData(defaultsArray[idx], value, mergeExtraArrayDefaults);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
});
|
|
28
|
+
// Merge any extra defaults when mergeExtraArrayDefaults is true
|
|
29
|
+
if (mergeExtraArrayDefaults && mapped.length < defaultsArray.length) {
|
|
30
|
+
mapped.push(...defaultsArray.slice(mapped.length));
|
|
31
|
+
}
|
|
32
|
+
return mapped;
|
|
33
|
+
}
|
|
34
|
+
if (isObject(formData)) {
|
|
35
|
+
const acc = Object.assign({}, defaults); // Prevent mutation of source object.
|
|
36
|
+
return Object.keys(formData).reduce((acc, key) => {
|
|
37
|
+
acc[key] = mergeDefaultsWithFormData(defaults ? get(defaults, key) : {}, get(formData, key), mergeExtraArrayDefaults);
|
|
38
|
+
return acc;
|
|
39
|
+
}, acc);
|
|
40
|
+
}
|
|
41
|
+
return formData;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=mergeDefaultsWithFormData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeDefaultsWithFormData.js","sourceRoot":"","sources":["../src/mergeDefaultsWithFormData.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,QAAY,EACZ,QAAY,EACZ,uBAAuB,GAAG,KAAK;IAE/B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACzC,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE;gBACtB,OAAO,yBAAyB,CAAM,aAAa,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC;aAC3F;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,gEAAgE;QAChE,IAAI,uBAAuB,IAAI,MAAM,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE;YACnE,MAAM,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;SACpD;QACD,OAAO,MAAsB,CAAC;KAC/B;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACtB,MAAM,GAAG,GAA8B,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,qCAAqC;QACzG,OAAO,MAAM,CAAC,IAAI,CAAC,QAA6B,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACpE,GAAG,CAAC,GAAc,CAAC,GAAG,yBAAyB,CAC7C,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAClC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,EAClB,uBAAuB,CACxB,CAAC;YACF,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,GAAG,CAAC,CAAC;KACT;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GenericObjectType } from './types';
|
|
2
|
+
/** Recursively merge deeply nested objects.
|
|
3
|
+
*
|
|
4
|
+
* @param obj1 - The first object to merge
|
|
5
|
+
* @param obj2 - The second object to merge
|
|
6
|
+
* @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated. Use
|
|
7
|
+
* "preventDuplicates" to merge arrays in a manner that prevents any duplicate entries from being merged.
|
|
8
|
+
* NOTE: Uses shallow comparison for the duplicate checking.
|
|
9
|
+
* @returns - A new object that is the merge of the two given objects
|
|
10
|
+
*/
|
|
11
|
+
export default function mergeObjects(obj1: GenericObjectType, obj2: GenericObjectType, concatArrays?: boolean | 'preventDuplicates'): GenericObjectType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import isObject from './isObject';
|
|
2
|
+
/** Recursively merge deeply nested objects.
|
|
3
|
+
*
|
|
4
|
+
* @param obj1 - The first object to merge
|
|
5
|
+
* @param obj2 - The second object to merge
|
|
6
|
+
* @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated. Use
|
|
7
|
+
* "preventDuplicates" to merge arrays in a manner that prevents any duplicate entries from being merged.
|
|
8
|
+
* NOTE: Uses shallow comparison for the duplicate checking.
|
|
9
|
+
* @returns - A new object that is the merge of the two given objects
|
|
10
|
+
*/
|
|
11
|
+
export default function mergeObjects(obj1, obj2, concatArrays = false) {
|
|
12
|
+
return Object.keys(obj2).reduce((acc, key) => {
|
|
13
|
+
const left = obj1 ? obj1[key] : {}, right = obj2[key];
|
|
14
|
+
if (obj1 && key in obj1 && isObject(right)) {
|
|
15
|
+
acc[key] = mergeObjects(left, right, concatArrays);
|
|
16
|
+
}
|
|
17
|
+
else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
|
|
18
|
+
let toMerge = right;
|
|
19
|
+
if (concatArrays === 'preventDuplicates') {
|
|
20
|
+
toMerge = right.reduce((result, value) => {
|
|
21
|
+
if (!left.includes(value)) {
|
|
22
|
+
result.push(value);
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}, []);
|
|
26
|
+
}
|
|
27
|
+
acc[key] = left.concat(toMerge);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
acc[key] = right;
|
|
31
|
+
}
|
|
32
|
+
return acc;
|
|
33
|
+
}, Object.assign({}, obj1)); // Prevent mutation of source object.
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=mergeObjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeObjects.js","sourceRoot":"","sources":["../src/mergeObjects.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAuB,E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|
|
2
|
+
/** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
|
|
3
|
+
* `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include
|
|
4
|
+
* duplicate values.
|
|
5
|
+
*
|
|
6
|
+
* @param obj1 - The first schema object to merge
|
|
7
|
+
* @param obj2 - The second schema object to merge
|
|
8
|
+
* @returns - The merged schema object
|
|
9
|
+
*/
|
|
10
|
+
export default function mergeSchemas(obj1: GenericObjectType, obj2: GenericObjectType): GenericObjectType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import union from 'lodash/union';
|
|
2
|
+
import { REQUIRED_KEY } from './constants';
|
|
3
|
+
import getSchemaType from './getSchemaType';
|
|
4
|
+
import isObject from './isObject';
|
|
5
|
+
/** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
|
|
6
|
+
* `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include
|
|
7
|
+
* duplicate values.
|
|
8
|
+
*
|
|
9
|
+
* @param obj1 - The first schema object to merge
|
|
10
|
+
* @param obj2 - The second schema object to merge
|
|
11
|
+
* @returns - The merged schema object
|
|
12
|
+
*/
|
|
13
|
+
export default function mergeSchemas(obj1, obj2) {
|
|
14
|
+
const acc = Object.assign({}, obj1); // Prevent mutation of source object.
|
|
15
|
+
return Object.keys(obj2).reduce((acc, key) => {
|
|
16
|
+
const left = obj1 ? obj1[key] : {}, right = obj2[key];
|
|
17
|
+
if (obj1 && key in obj1 && isObject(right)) {
|
|
18
|
+
acc[key] = mergeSchemas(left, right);
|
|
19
|
+
}
|
|
20
|
+
else if (obj1 &&
|
|
21
|
+
obj2 &&
|
|
22
|
+
(getSchemaType(obj1) === 'object' || getSchemaType(obj2) === 'object') &&
|
|
23
|
+
key === REQUIRED_KEY &&
|
|
24
|
+
Array.isArray(left) &&
|
|
25
|
+
Array.isArray(right)) {
|
|
26
|
+
// Don't include duplicate values when merging 'required' fields.
|
|
27
|
+
acc[key] = union(left, right);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
acc[key] = right;
|
|
31
|
+
}
|
|
32
|
+
return acc;
|
|
33
|
+
}, acc);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=mergeSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeSchemas.js","sourceRoot":"","sources":["../src/mergeSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAuB,EAAE,IAAuB;IACnF,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,qCAAqC;IAC1E,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAChC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC1C,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACtC;aAAM,IACL,IAAI;YACJ,IAAI;YACJ,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC;YACtE,GAAG,KAAK,YAAY;YACpB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YACnB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EACpB;YACA,iEAAiE;YACjE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAC/B;aAAM;YACL,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SAClB;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RJSFSchema, EnumOptionsType, StrictRJSFSchema } from './types';
|
|
2
|
+
/** Gets the list of options from the schema. If the schema has an enum list, then those enum values are returned. The
|
|
3
|
+
* labels for the options will be extracted from the non-standard, RJSF-deprecated `enumNames` if it exists, otherwise
|
|
4
|
+
* the label will be the same as the `value`. If the schema has a `oneOf` or `anyOf`, then the value is the list of
|
|
5
|
+
* `const` values from the schema and the label is either the `schema.title` or the value.
|
|
6
|
+
*
|
|
7
|
+
* @param schema - The schema from which to extract the options list
|
|
8
|
+
* @returns - The list of options from the schema
|
|
9
|
+
*/
|
|
10
|
+
export default function optionsList<S extends StrictRJSFSchema = RJSFSchema>(schema: S): EnumOptionsType<S>[] | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import toConstant from './toConstant';
|
|
2
|
+
/** Gets the list of options from the schema. If the schema has an enum list, then those enum values are returned. The
|
|
3
|
+
* labels for the options will be extracted from the non-standard, RJSF-deprecated `enumNames` if it exists, otherwise
|
|
4
|
+
* the label will be the same as the `value`. If the schema has a `oneOf` or `anyOf`, then the value is the list of
|
|
5
|
+
* `const` values from the schema and the label is either the `schema.title` or the value.
|
|
6
|
+
*
|
|
7
|
+
* @param schema - The schema from which to extract the options list
|
|
8
|
+
* @returns - The list of options from the schema
|
|
9
|
+
*/
|
|
10
|
+
export default function optionsList(schema) {
|
|
11
|
+
// enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
|
|
12
|
+
// Cast the type to include enumNames so the feature still works.
|
|
13
|
+
const schemaWithEnumNames = schema;
|
|
14
|
+
if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== 'production') {
|
|
15
|
+
console.warn('The enumNames property is deprecated and may be removed in a future major release.');
|
|
16
|
+
}
|
|
17
|
+
if (schema.enum) {
|
|
18
|
+
return schema.enum.map((value, i) => {
|
|
19
|
+
const label = (schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i]) || String(value);
|
|
20
|
+
return { label, value };
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const altSchemas = schema.oneOf || schema.anyOf;
|
|
24
|
+
return (altSchemas &&
|
|
25
|
+
altSchemas.map((aSchemaDef) => {
|
|
26
|
+
const aSchema = aSchemaDef;
|
|
27
|
+
const value = toConstant(aSchema);
|
|
28
|
+
const label = aSchema.title || String(value);
|
|
29
|
+
return {
|
|
30
|
+
schema: aSchema,
|
|
31
|
+
label,
|
|
32
|
+
value,
|
|
33
|
+
};
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=optionsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionsList.js","sourceRoot":"","sources":["../src/optionsList.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAGtC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,MAAS;IAET,wFAAwF;IACxF,iEAAiE;IACjE,MAAM,mBAAmB,GAAG,MAAsC,CAAC;IACnE,IAAI,mBAAmB,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QAC1E,OAAO,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;KACpG;IACD,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAClC,MAAM,KAAK,GAAG,CAAC,mBAAmB,CAAC,SAAS,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;YACnG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC1B,CAAC,CAAC,CAAC;KACJ;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;IAChD,OAAO,CACL,UAAU;QACV,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAC5B,MAAM,OAAO,GAAG,UAAe,CAAC;YAChC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7C,OAAO;gBACL,MAAM,EAAE,OAAO;gBACf,KAAK;gBACL,KAAK;aACN,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.
|
|
2
|
+
* If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per
|
|
3
|
+
* the `order` list. If `order` contains a '*' then any `properties` that are not mentioned explicity in `order` will be
|
|
4
|
+
* places in the location of the `*`.
|
|
5
|
+
*
|
|
6
|
+
* @param properties - The list of property keys to be ordered
|
|
7
|
+
* @param order - An array of property keys to be ordered first, with an optional '*' property
|
|
8
|
+
* @returns - A list with the `properties` ordered
|
|
9
|
+
* @throws - Error when the properties cannot be ordered correctly
|
|
10
|
+
*/
|
|
11
|
+
export default function orderProperties(properties: string[], order?: string[]): string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.
|
|
2
|
+
* If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per
|
|
3
|
+
* the `order` list. If `order` contains a '*' then any `properties` that are not mentioned explicity in `order` will be
|
|
4
|
+
* places in the location of the `*`.
|
|
5
|
+
*
|
|
6
|
+
* @param properties - The list of property keys to be ordered
|
|
7
|
+
* @param order - An array of property keys to be ordered first, with an optional '*' property
|
|
8
|
+
* @returns - A list with the `properties` ordered
|
|
9
|
+
* @throws - Error when the properties cannot be ordered correctly
|
|
10
|
+
*/
|
|
11
|
+
export default function orderProperties(properties, order) {
|
|
12
|
+
if (!Array.isArray(order)) {
|
|
13
|
+
return properties;
|
|
14
|
+
}
|
|
15
|
+
const arrayToHash = (arr) => arr.reduce((prev, curr) => {
|
|
16
|
+
prev[curr] = true;
|
|
17
|
+
return prev;
|
|
18
|
+
}, {});
|
|
19
|
+
const errorPropList = (arr) => arr.length > 1 ? `properties '${arr.join("', '")}'` : `property '${arr[0]}'`;
|
|
20
|
+
const propertyHash = arrayToHash(properties);
|
|
21
|
+
const orderFiltered = order.filter((prop) => prop === '*' || propertyHash[prop]);
|
|
22
|
+
const orderHash = arrayToHash(orderFiltered);
|
|
23
|
+
const rest = properties.filter((prop) => !orderHash[prop]);
|
|
24
|
+
const restIndex = orderFiltered.indexOf('*');
|
|
25
|
+
if (restIndex === -1) {
|
|
26
|
+
if (rest.length) {
|
|
27
|
+
throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);
|
|
28
|
+
}
|
|
29
|
+
return orderFiltered;
|
|
30
|
+
}
|
|
31
|
+
if (restIndex !== orderFiltered.lastIndexOf('*')) {
|
|
32
|
+
throw new Error('uiSchema order list contains more than one wildcard item');
|
|
33
|
+
}
|
|
34
|
+
const complete = [...orderFiltered];
|
|
35
|
+
complete.splice(restIndex, 1, ...rest);
|
|
36
|
+
return complete;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=orderProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderProperties.js","sourceRoot":"","sources":["../src/orderProperties.ts"],"names":[],"mappings":"AAEA;;;;;;;;;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AAS,KAAK,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QAChD,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;KAC7E;IAED,MAAM,QAAQ,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/lib/pad.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Returns a string representation of the `num` that is padded with leading "0"s if necessary
|
|
2
|
+
*
|
|
3
|
+
* @param num - The number to pad
|
|
4
|
+
* @param width - The width of the string at which no lead padding is necessary
|
|
5
|
+
* @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
|
|
6
|
+
*/
|
|
7
|
+
export default function pad(num: number, width: number): string;
|
package/lib/pad.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Returns a string representation of the `num` that is padded with leading "0"s if necessary
|
|
2
|
+
*
|
|
3
|
+
* @param num - The number to pad
|
|
4
|
+
* @param width - The width of the string at which no lead padding is necessary
|
|
5
|
+
* @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
|
|
6
|
+
*/
|
|
7
|
+
export default function pad(num, width) {
|
|
8
|
+
let s = String(num);
|
|
9
|
+
while (s.length < width) {
|
|
10
|
+
s = '0' + s;
|
|
11
|
+
}
|
|
12
|
+
return s;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=pad.js.map
|
package/lib/pad.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pad.js","sourceRoot":"","sources":["../src/pad.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CAAC,GAAW,EAAE,KAAa;IACpD,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC,MAAM,GAAG,KAAK,EAAE;QACvB,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;KACb;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DateObject } from './types';
|
|
2
|
+
/** Parses the `dateString` into a `DateObject`, including the time information when `includeTime` is true
|
|
3
|
+
*
|
|
4
|
+
* @param dateString - The date string to parse into a DateObject
|
|
5
|
+
* @param [includeTime=true] - Optional flag, if false, will not include the time data into the object
|
|
6
|
+
* @returns - The date string converted to a `DateObject`
|
|
7
|
+
* @throws - Error when the date cannot be parsed from the string
|
|
8
|
+
*/
|
|
9
|
+
export default function parseDateString(dateString?: string, includeTime?: boolean): DateObject;
|