@rjsf/utils 6.0.0-alpha.0 → 6.0.0-beta.2
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 +1340 -639
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +1316 -615
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +1262 -589
- package/lib/ErrorSchemaBuilder.d.ts +8 -4
- package/lib/ErrorSchemaBuilder.js +10 -8
- package/lib/ErrorSchemaBuilder.js.map +1 -1
- package/lib/allowAdditionalItems.d.ts +1 -1
- package/lib/allowAdditionalItems.js +1 -1
- package/lib/allowAdditionalItems.js.map +1 -1
- package/lib/asNumber.js.map +1 -1
- package/lib/canExpand.d.ts +1 -1
- package/lib/canExpand.js +2 -2
- package/lib/canExpand.js.map +1 -1
- package/lib/constIsAjvDataReference.d.ts +9 -0
- package/lib/constIsAjvDataReference.js +15 -0
- package/lib/constIsAjvDataReference.js.map +1 -0
- package/lib/constants.d.ts +15 -3
- package/lib/constants.js +15 -3
- package/lib/constants.js.map +1 -1
- package/lib/createErrorHandler.d.ts +1 -1
- package/lib/createErrorHandler.js +2 -2
- package/lib/createErrorHandler.js.map +1 -1
- package/lib/createSchemaUtils.d.ts +3 -2
- package/lib/createSchemaUtils.js +56 -46
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/dataURItoBlob.js.map +1 -1
- package/lib/dateRangeOptions.d.ts +1 -1
- package/lib/dateRangeOptions.js +1 -1
- package/lib/dateRangeOptions.js.map +1 -1
- package/lib/deepEquals.js +1 -1
- package/lib/deepEquals.js.map +1 -1
- package/lib/englishStringTranslator.d.ts +1 -1
- package/lib/englishStringTranslator.js +1 -1
- package/lib/enumOptionsDeselectValue.d.ts +1 -1
- package/lib/enumOptionsDeselectValue.js +4 -4
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIndexForValue.d.ts +1 -1
- package/lib/enumOptionsIndexForValue.js +1 -1
- package/lib/enumOptionsIndexForValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.d.ts +1 -1
- package/lib/enumOptionsIsSelected.js +3 -3
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/enumOptionsSelectValue.d.ts +1 -1
- package/lib/enumOptionsSelectValue.js +2 -2
- package/lib/enumOptionsSelectValue.js.map +1 -1
- package/lib/enumOptionsValueForIndex.d.ts +1 -1
- package/lib/enumOptionsValueForIndex.js.map +1 -1
- package/lib/enums.d.ts +2 -0
- package/lib/enums.js +2 -0
- package/lib/enums.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +5 -3
- package/lib/findSchemaDefinition.js +53 -11
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getChangedFields.d.ts +17 -0
- package/lib/getChangedFields.js +42 -0
- package/lib/getChangedFields.js.map +1 -0
- package/lib/getDateElementProps.d.ts +1 -1
- package/lib/getDateElementProps.js.map +1 -1
- package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
- package/lib/getDiscriminatorFieldFromSchema.js +4 -3
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
- package/lib/getInputProps.d.ts +1 -1
- package/lib/getInputProps.js +4 -1
- package/lib/getInputProps.js.map +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.js +2 -2
- package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
- package/lib/getSchemaType.d.ts +2 -1
- package/lib/getSchemaType.js +3 -2
- package/lib/getSchemaType.js.map +1 -1
- package/lib/getSubmitButtonOptions.d.ts +1 -1
- package/lib/getSubmitButtonOptions.js +2 -2
- package/lib/getSubmitButtonOptions.js.map +1 -1
- package/lib/getTemplate.d.ts +1 -1
- package/lib/getTemplate.js +9 -0
- package/lib/getTemplate.js.map +1 -1
- package/lib/getTestIds.d.ts +17 -0
- package/lib/getTestIds.js +34 -0
- package/lib/getTestIds.js.map +1 -0
- package/lib/getUiOptions.d.ts +1 -1
- package/lib/getUiOptions.js +2 -2
- package/lib/getUiOptions.js.map +1 -1
- package/lib/getWidget.d.ts +1 -1
- package/lib/getWidget.js +3 -3
- package/lib/getWidget.js.map +1 -1
- package/lib/guessType.d.ts +1 -1
- package/lib/guessType.js.map +1 -1
- package/lib/hasWidget.d.ts +1 -1
- package/lib/hasWidget.js +1 -1
- package/lib/hasWidget.js.map +1 -1
- package/lib/hashForSchema.d.ts +23 -1
- package/lib/hashForSchema.js +24 -6
- package/lib/hashForSchema.js.map +1 -1
- package/lib/idGenerators.d.ts +8 -1
- package/lib/idGenerators.js +11 -2
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +63 -60
- package/lib/index.js +63 -60
- package/lib/index.js.map +1 -1
- package/lib/isConstant.d.ts +1 -1
- package/lib/isConstant.js +1 -1
- package/lib/isCustomWidget.d.ts +1 -1
- package/lib/isCustomWidget.js +1 -1
- package/lib/isFixedItems.d.ts +1 -1
- package/lib/isFixedItems.js +1 -1
- package/lib/isObject.d.ts +2 -2
- package/lib/isObject.js +11 -4
- package/lib/isObject.js.map +1 -1
- package/lib/lookupFromFormContext.d.ts +11 -0
- package/lib/lookupFromFormContext.js +20 -0
- package/lib/lookupFromFormContext.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.d.ts +8 -2
- package/lib/mergeDefaultsWithFormData.js +39 -10
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/mergeObjects.d.ts +1 -1
- package/lib/mergeObjects.js +1 -1
- package/lib/mergeObjects.js.map +1 -1
- package/lib/mergeSchemas.d.ts +1 -1
- package/lib/mergeSchemas.js +4 -4
- package/lib/mergeSchemas.js.map +1 -1
- package/lib/optionsList.d.ts +9 -7
- package/lib/optionsList.js +30 -19
- package/lib/optionsList.js.map +1 -1
- package/lib/orderProperties.js.map +1 -1
- package/lib/pad.js.map +1 -1
- package/lib/parseDateString.d.ts +1 -1
- package/lib/parseDateString.js +1 -1
- package/lib/parseDateString.js.map +1 -1
- package/lib/parser/ParserValidator.d.ts +1 -1
- package/lib/parser/ParserValidator.js +6 -6
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/index.d.ts +2 -2
- package/lib/parser/index.js +1 -1
- package/lib/parser/schemaParser.d.ts +2 -2
- package/lib/parser/schemaParser.js +6 -6
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/rangeSpec.d.ts +2 -2
- package/lib/rangeSpec.js.map +1 -1
- package/lib/replaceStringParameters.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +19 -0
- package/lib/schema/findFieldInSchema.js +61 -0
- package/lib/schema/findFieldInSchema.js.map +1 -0
- package/lib/schema/findSelectedOptionInXxxOf.d.ts +16 -0
- package/lib/schema/findSelectedOptionInXxxOf.js +34 -0
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -0
- package/lib/schema/getClosestMatchingOption.d.ts +5 -3
- package/lib/schema/getClosestMatchingOption.js +28 -20
- package/lib/schema/getClosestMatchingOption.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +60 -13
- package/lib/schema/getDefaultFormState.js +309 -166
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.d.ts +3 -2
- package/lib/schema/getDisplayLabel.js +10 -9
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/getFirstMatchingOption.d.ts +1 -1
- package/lib/schema/getFirstMatchingOption.js +70 -2
- package/lib/schema/getFirstMatchingOption.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +14 -0
- package/lib/schema/getFromSchema.js +39 -0
- package/lib/schema/getFromSchema.js.map +1 -0
- package/lib/schema/index.d.ts +15 -14
- package/lib/schema/index.js +15 -14
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/isFilesArray.d.ts +3 -2
- package/lib/schema/isFilesArray.js +5 -4
- package/lib/schema/isFilesArray.js.map +1 -1
- package/lib/schema/isMultiSelect.d.ts +3 -2
- package/lib/schema/isMultiSelect.js +4 -3
- package/lib/schema/isMultiSelect.js.map +1 -1
- package/lib/schema/isSelect.d.ts +3 -2
- package/lib/schema/isSelect.js +5 -4
- package/lib/schema/isSelect.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +30 -12
- package/lib/schema/retrieveSchema.js +153 -70
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
- package/lib/schema/sanitizeDataForNewSchema.js +12 -11
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
- package/lib/schema/toIdSchema.d.ts +3 -2
- package/lib/schema/toIdSchema.js +30 -27
- package/lib/schema/toIdSchema.js.map +1 -1
- package/lib/schema/toPathSchema.d.ts +3 -2
- package/lib/schema/toPathSchema.js +22 -20
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/schemaRequiresTrueValue.d.ts +1 -1
- package/lib/schemaRequiresTrueValue.js.map +1 -1
- package/lib/shouldRender.js +1 -1
- package/lib/toConstant.d.ts +1 -1
- package/lib/toConstant.js +1 -1
- package/lib/toConstant.js.map +1 -1
- package/lib/toDateString.d.ts +1 -1
- package/lib/toErrorList.d.ts +1 -1
- package/lib/toErrorList.js +2 -2
- package/lib/toErrorList.js.map +1 -1
- package/lib/toErrorSchema.d.ts +1 -1
- package/lib/toErrorSchema.js +2 -2
- package/lib/toErrorSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +165 -139
- package/lib/unwrapErrorHandler.d.ts +1 -1
- package/lib/unwrapErrorHandler.js +1 -1
- package/lib/unwrapErrorHandler.js.map +1 -1
- package/lib/utcToLocal.js +1 -1
- package/lib/utcToLocal.js.map +1 -1
- package/lib/validationDataMerge.d.ts +1 -1
- package/lib/validationDataMerge.js +3 -3
- package/lib/validationDataMerge.js.map +1 -1
- package/lib/withIdRefPrefix.d.ts +1 -1
- package/lib/withIdRefPrefix.js +2 -2
- package/lib/withIdRefPrefix.js.map +1 -1
- package/package.json +37 -26
- package/src/ErrorSchemaBuilder.ts +15 -8
- package/src/canExpand.ts +2 -2
- package/src/constIsAjvDataReference.ts +17 -0
- package/src/constants.ts +17 -3
- package/src/createSchemaUtils.ts +140 -50
- package/src/dataURItoBlob.ts +1 -1
- package/src/dateRangeOptions.ts +1 -1
- package/src/enumOptionsDeselectValue.ts +4 -5
- package/src/enumOptionsIndexForValue.ts +1 -1
- package/src/enumOptionsIsSelected.ts +4 -5
- package/src/enumOptionsSelectValue.ts +1 -1
- package/src/enumOptionsValueForIndex.ts +1 -1
- package/src/enums.ts +2 -0
- package/src/findSchemaDefinition.ts +54 -10
- package/src/getChangedFields.ts +40 -0
- package/src/getDateElementProps.ts +2 -2
- package/src/getDiscriminatorFieldFromSchema.ts +2 -1
- package/src/getInputProps.ts +6 -2
- package/src/getOptionMatchingSimpleDiscriminator.ts +2 -2
- package/src/getSchemaType.ts +3 -2
- package/src/getSubmitButtonOptions.ts +1 -1
- package/src/getTemplate.ts +12 -1
- package/src/getTestIds.ts +40 -0
- package/src/getUiOptions.ts +2 -2
- package/src/getWidget.tsx +2 -2
- package/src/hasWidget.ts +1 -1
- package/src/hashForSchema.ts +26 -6
- package/src/idGenerators.ts +10 -0
- package/src/index.ts +21 -2
- package/src/isCustomWidget.ts +1 -1
- package/src/isObject.ts +12 -5
- package/src/labelValue.ts +2 -2
- package/src/lookupFromFormContext.ts +26 -0
- package/src/mergeDefaultsWithFormData.ts +54 -9
- package/src/mergeObjects.ts +24 -21
- package/src/optionsList.ts +31 -22
- package/src/parser/ParserValidator.ts +5 -5
- package/src/parser/schemaParser.ts +6 -6
- package/src/schema/findFieldInSchema.ts +138 -0
- package/src/schema/findSelectedOptionInXxxOf.ts +53 -0
- package/src/schema/getClosestMatchingOption.ts +38 -11
- package/src/schema/getDefaultFormState.ts +453 -191
- package/src/schema/getDisplayLabel.ts +7 -4
- package/src/schema/getFirstMatchingOption.ts +79 -4
- package/src/schema/getFromSchema.ts +100 -0
- package/src/schema/index.ts +6 -4
- package/src/schema/isFilesArray.ts +18 -3
- package/src/schema/isMultiSelect.ts +10 -4
- package/src/schema/isSelect.ts +5 -3
- package/src/schema/retrieveSchema.ts +268 -78
- package/src/schema/sanitizeDataForNewSchema.ts +52 -11
- package/src/schema/toIdSchema.ts +69 -43
- package/src/schema/toPathSchema.ts +49 -16
- package/src/toErrorList.ts +2 -2
- package/src/types.ts +271 -181
- package/src/validationDataMerge.ts +1 -1
- package/src/withIdRefPrefix.ts +1 -1
- package/LICENSE.md +0 -201
- package/lib/schema/getMatchingOption.d.ts +0 -14
- package/lib/schema/getMatchingOption.js +0 -85
- package/lib/schema/getMatchingOption.js.map +0 -1
- package/lib/schema/mergeValidationData.d.ts +0 -14
- package/lib/schema/mergeValidationData.js +0 -28
- package/lib/schema/mergeValidationData.js.map +0 -1
- package/src/schema/getMatchingOption.ts +0 -103
- package/src/schema/mergeValidationData.ts +0 -38
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
|
|
3
3
|
* a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
|
|
4
4
|
* a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex.js';
|
|
2
|
+
import deepEquals from './deepEquals.js';
|
|
3
3
|
/** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
|
|
4
4
|
* a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
|
|
5
5
|
* a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined
|
|
@@ -15,8 +15,8 @@ import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
|
15
15
|
export default function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
16
16
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
17
17
|
if (Array.isArray(selected)) {
|
|
18
|
-
return selected.filter((v) => !
|
|
18
|
+
return selected.filter((v) => !deepEquals(v, value));
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return deepEquals(value, selected) ? undefined : selected;
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=enumOptionsDeselectValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumOptionsDeselectValue.js","sourceRoot":"","sources":["../src/enumOptionsDeselectValue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enumOptionsDeselectValue.js","sourceRoot":"","sources":["../src/enumOptionsDeselectValue.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,UAA2B,EAC3B,QAAsE,EACtE,iBAAuC,EAAE;IAEzC,MAAM,KAAK,GAAG,wBAAwB,CAAI,UAAU,EAAE,cAAc,CAAC,CAAC;IACtE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
|
|
3
3
|
* `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
|
|
4
4
|
* stored in an array. If `multiple` is true, that array is returned, otherwise the first element in the array is
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import enumOptionsIsSelected from './enumOptionsIsSelected';
|
|
1
|
+
import enumOptionsIsSelected from './enumOptionsIsSelected.js';
|
|
2
2
|
/** Returns the index(es) of the options in `allEnumOptions` whose value(s) match the ones in `value`. All the
|
|
3
3
|
* `enumOptions` are filtered based on whether they are a "selected" `value` and the index of each selected one is then
|
|
4
4
|
* stored in an array. If `multiple` is true, that array is returned, otherwise the first element in the array is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumOptionsIndexForValue.js","sourceRoot":"","sources":["../src/enumOptionsIndexForValue.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,KAAkE,EAClE,iBAAuC,EAAE,EACzC,QAAQ,GAAG,KAAK;IAEhB,MAAM,eAAe,GAAa,cAAc;SAC7C,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SAC1F,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,WAAW,CAAa,CAAC;IAC3D,IAAI,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"enumOptionsIndexForValue.js","sourceRoot":"","sources":["../src/enumOptionsIndexForValue.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,KAAkE,EAClE,iBAAuC,EAAE,EACzC,QAAQ,GAAG,KAAK;IAEhB,MAAM,eAAe,GAAa,cAAc;SAC7C,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SAC1F,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,WAAW,CAAa,CAAC;IAC3D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Determines whether the given `value` is (one of) the `selected` value(s).
|
|
3
3
|
*
|
|
4
4
|
* @param value - The value being checked to see if it is selected
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import deepEquals from './deepEquals.js';
|
|
2
2
|
/** Determines whether the given `value` is (one of) the `selected` value(s).
|
|
3
3
|
*
|
|
4
4
|
* @param value - The value being checked to see if it is selected
|
|
@@ -7,8 +7,8 @@ import isEqual from 'lodash/isEqual';
|
|
|
7
7
|
*/
|
|
8
8
|
export default function enumOptionsIsSelected(value, selected) {
|
|
9
9
|
if (Array.isArray(selected)) {
|
|
10
|
-
return selected.some((sel) =>
|
|
10
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return deepEquals(selected, value);
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=enumOptionsIsSelected.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumOptionsIsSelected.js","sourceRoot":"","sources":["../src/enumOptionsIsSelected.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enumOptionsIsSelected.js","sourceRoot":"","sources":["../src/enumOptionsIsSelected.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,KAAkC,EAClC,QAAqE;IAErE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
|
|
3
3
|
* `allEnumOptions`
|
|
4
4
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
2
|
-
import isNil from 'lodash/isNil';
|
|
1
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex.js';
|
|
2
|
+
import isNil from 'lodash-es/isNil.js';
|
|
3
3
|
/** Add the enum option value at the `valueIndex` to the list of `selected` values in the proper order as defined by
|
|
4
4
|
* `allEnumOptions`
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumOptionsSelectValue.js","sourceRoot":"","sources":["../src/enumOptionsSelectValue.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,UAA2B,EAC3B,QAAuC,EACvC,iBAAuC,EAAE;IAEzC,MAAM,KAAK,GAAG,wBAAwB,CAAI,UAAU,EAAE,cAAc,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"enumOptionsSelectValue.js","sourceRoot":"","sources":["../src/enumOptionsSelectValue.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,UAA2B,EAC3B,QAAuC,EACvC,iBAAuC,EAAE;IAEzC,MAAM,KAAK,GAAG,wBAAwB,CAAI,UAAU,EAAE,cAAc,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9E,4EAA4E;QAC5E,8EAA8E;QAC9E,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { EnumOptionsType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
|
|
3
3
|
* array AND the index is not valid for `allEnumOptions`, `emptyValue` is returned. If `valueIndex` is an array, AND it
|
|
4
4
|
* contains an invalid index, the returned array will have the resulting undefined values filtered out, leaving only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumOptionsValueForIndex.js","sourceRoot":"","sources":["../src/enumOptionsValueForIndex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,UAAoD,EACpD,iBAAuC,EAAE,EACzC,UAAwC;IAExC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"enumOptionsValueForIndex.js","sourceRoot":"","sources":["../src/enumOptionsValueForIndex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,UAAoD,EACpD,iBAAuC,EAAE,EACzC,UAAwC;IAExC,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,CACL,UAAU;aACP,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;YAChE,gGAAgG;aAC/F,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,UAAU,CAAC,CACvC,CAAC;IACJ,CAAC;IACD,uFAAuF;IACvF,MAAM,KAAK,GAAG,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;AAC5C,CAAC"}
|
package/lib/enums.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare enum TranslatableString {
|
|
|
9
9
|
ArrayItemTitle = "Item",
|
|
10
10
|
/** Missing items reason, used by ArrayField */
|
|
11
11
|
MissingItems = "Missing items definition",
|
|
12
|
+
/** Empty array message, used by ArrayField */
|
|
13
|
+
EmptyArray = "No items yet. Use the button below to add some.",
|
|
12
14
|
/** Yes label, used by BooleanField */
|
|
13
15
|
YesLabel = "Yes",
|
|
14
16
|
/** No label, used by BooleanField */
|
package/lib/enums.js
CHANGED
|
@@ -10,6 +10,8 @@ export var TranslatableString;
|
|
|
10
10
|
TranslatableString["ArrayItemTitle"] = "Item";
|
|
11
11
|
/** Missing items reason, used by ArrayField */
|
|
12
12
|
TranslatableString["MissingItems"] = "Missing items definition";
|
|
13
|
+
/** Empty array message, used by ArrayField */
|
|
14
|
+
TranslatableString["EmptyArray"] = "No items yet. Use the button below to add some.";
|
|
13
15
|
/** Yes label, used by BooleanField */
|
|
14
16
|
TranslatableString["YesLabel"] = "Yes";
|
|
15
17
|
/** No label, used by BooleanField */
|
package/lib/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"enums.js","sourceR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AkB,QA4E7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
|
|
3
3
|
* location, the `object` minus the `key: value` and in the second location the `value`.
|
|
4
4
|
*
|
|
@@ -16,10 +16,11 @@ export declare function splitKeyElementFromObject(key: string, object: GenericOb
|
|
|
16
16
|
* @param $ref - The ref string for which the schema definition is desired
|
|
17
17
|
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
18
18
|
* @param recurseList - List of $refs already resolved to prevent recursion
|
|
19
|
+
* @param baseURI - The base URI to be used for resolving relative references
|
|
19
20
|
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
20
21
|
* @throws - Error indicating that no schema for that reference could be resolved
|
|
21
22
|
*/
|
|
22
|
-
export declare function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFSchema>($ref?: string, rootSchema?: S, recurseList?: string[]): S;
|
|
23
|
+
export declare function findSchemaDefinitionRecursive<S extends StrictRJSFSchema = RJSFSchema>($ref?: string, rootSchema?: S, recurseList?: string[], baseURI?: string | undefined): S;
|
|
23
24
|
/** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
|
|
24
25
|
* path provided by that reference. If `#` is not the first character of the reference, the path does not exist in
|
|
25
26
|
* the schema, or the reference resolves circularly back to itself, then throw an Error. Otherwise return the
|
|
@@ -27,7 +28,8 @@ export declare function findSchemaDefinitionRecursive<S extends StrictRJSFSchema
|
|
|
27
28
|
*
|
|
28
29
|
* @param $ref - The ref string for which the schema definition is desired
|
|
29
30
|
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
31
|
+
* @param [baseURI=rootSchema['$id']] - The base URI to be used for resolving relative references
|
|
30
32
|
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
31
33
|
* @throws - Error indicating that no schema for that reference could be resolved
|
|
32
34
|
*/
|
|
33
|
-
export default function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>($ref?: string, rootSchema?: S): S;
|
|
35
|
+
export default function findSchemaDefinition<S extends StrictRJSFSchema = RJSFSchema>($ref?: string, rootSchema?: S, baseURI?: string | undefined): S;
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import jsonpointer from 'jsonpointer';
|
|
2
|
-
import omit from 'lodash/omit';
|
|
3
|
-
import { REF_KEY } from './constants';
|
|
2
|
+
import omit from 'lodash-es/omit.js';
|
|
3
|
+
import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, REF_KEY, SCHEMA_KEY } from './constants.js';
|
|
4
|
+
import isObject from 'lodash-es/isObject.js';
|
|
5
|
+
import isEmpty from 'lodash-es/isEmpty.js';
|
|
6
|
+
import UriResolver from 'fast-uri';
|
|
7
|
+
/** Looks for the `$id` pointed by `ref` in the schema definitions embedded in
|
|
8
|
+
* a JSON Schema bundle
|
|
9
|
+
*
|
|
10
|
+
* @param schema - The schema wherein `ref` should be searched
|
|
11
|
+
* @param ref - The `$id` of the reference to search for
|
|
12
|
+
* @returns - The schema matching the reference, or `undefined` if no match is found
|
|
13
|
+
*/
|
|
14
|
+
function findEmbeddedSchemaRecursive(schema, ref) {
|
|
15
|
+
if (ID_KEY in schema && UriResolver.equal(schema[ID_KEY], ref)) {
|
|
16
|
+
return schema;
|
|
17
|
+
}
|
|
18
|
+
for (const subSchema of Object.values(schema)) {
|
|
19
|
+
if (isObject(subSchema)) {
|
|
20
|
+
const result = findEmbeddedSchemaRecursive(subSchema, ref);
|
|
21
|
+
if (result !== undefined) {
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
4
28
|
/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
|
|
5
29
|
* location, the `object` minus the `key: value` and in the second location the `value`.
|
|
6
30
|
*
|
|
@@ -22,20 +46,37 @@ export function splitKeyElementFromObject(key, object) {
|
|
|
22
46
|
* @param $ref - The ref string for which the schema definition is desired
|
|
23
47
|
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
24
48
|
* @param recurseList - List of $refs already resolved to prevent recursion
|
|
49
|
+
* @param baseURI - The base URI to be used for resolving relative references
|
|
25
50
|
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
26
51
|
* @throws - Error indicating that no schema for that reference could be resolved
|
|
27
52
|
*/
|
|
28
|
-
export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = []) {
|
|
53
|
+
export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI = ID_KEY in rootSchema ? rootSchema[ID_KEY] : undefined) {
|
|
29
54
|
const ref = $ref || '';
|
|
30
|
-
let
|
|
55
|
+
let current = undefined;
|
|
31
56
|
if (ref.startsWith('#')) {
|
|
32
57
|
// Decode URI fragment representation.
|
|
33
|
-
decodedRef = decodeURIComponent(ref.substring(1));
|
|
58
|
+
const decodedRef = decodeURIComponent(ref.substring(1));
|
|
59
|
+
if (baseURI === undefined || (ID_KEY in rootSchema && rootSchema[ID_KEY] === baseURI)) {
|
|
60
|
+
current = jsonpointer.get(rootSchema, decodedRef);
|
|
61
|
+
}
|
|
62
|
+
else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
63
|
+
current = findEmbeddedSchemaRecursive(rootSchema, baseURI.replace(/\/$/, ''));
|
|
64
|
+
if (current !== undefined) {
|
|
65
|
+
current = jsonpointer.get(current, decodedRef);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
34
68
|
}
|
|
35
|
-
else {
|
|
36
|
-
|
|
69
|
+
else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
70
|
+
const resolvedRef = baseURI ? UriResolver.resolve(baseURI, ref) : ref;
|
|
71
|
+
const [refId, ...refAnchor] = resolvedRef.replace(/#\/?$/, '').split('#');
|
|
72
|
+
current = findEmbeddedSchemaRecursive(rootSchema, refId.replace(/\/$/, ''));
|
|
73
|
+
if (current !== undefined) {
|
|
74
|
+
baseURI = current[ID_KEY];
|
|
75
|
+
if (!isEmpty(refAnchor)) {
|
|
76
|
+
current = jsonpointer.get(current, decodeURIComponent(refAnchor.join('#')));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
37
79
|
}
|
|
38
|
-
const current = jsonpointer.get(rootSchema, decodedRef);
|
|
39
80
|
if (current === undefined) {
|
|
40
81
|
throw new Error(`Could not find a definition for ${$ref}.`);
|
|
41
82
|
}
|
|
@@ -51,7 +92,7 @@ export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList
|
|
|
51
92
|
throw new Error(`Definition for ${firstRef} contains a circular reference through ${circularPath}`);
|
|
52
93
|
}
|
|
53
94
|
const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
|
|
54
|
-
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref]);
|
|
95
|
+
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], baseURI);
|
|
55
96
|
if (Object.keys(remaining).length > 0) {
|
|
56
97
|
return { ...remaining, ...subSchema };
|
|
57
98
|
}
|
|
@@ -66,11 +107,12 @@ export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList
|
|
|
66
107
|
*
|
|
67
108
|
* @param $ref - The ref string for which the schema definition is desired
|
|
68
109
|
* @param [rootSchema={}] - The root schema in which to search for the definition
|
|
110
|
+
* @param [baseURI=rootSchema['$id']] - The base URI to be used for resolving relative references
|
|
69
111
|
* @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
|
|
70
112
|
* @throws - Error indicating that no schema for that reference could be resolved
|
|
71
113
|
*/
|
|
72
|
-
export default function findSchemaDefinition($ref, rootSchema = {}) {
|
|
114
|
+
export default function findSchemaDefinition($ref, rootSchema = {}, baseURI = ID_KEY in rootSchema ? rootSchema[ID_KEY] : undefined) {
|
|
73
115
|
const recurseList = [];
|
|
74
|
-
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList);
|
|
116
|
+
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);
|
|
75
117
|
}
|
|
76
118
|
//# sourceMappingURL=findSchemaDefinition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findSchemaDefinition.js","sourceRoot":"","sources":["../src/findSchemaDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"findSchemaDefinition.js","sourceRoot":"","sources":["../src/findSchemaDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErF,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,WAAW,MAAM,UAAU,CAAC;AAEnC;;;;;;GAMG;AACH,SAAS,2BAA2B,CAA0C,MAAS,EAAE,GAAW;IAClG,IAAI,MAAM,IAAI,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAW,EAAE,GAAG,CAAC,EAAE,CAAC;QACzE,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9C,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,2BAA2B,CAAI,SAAc,EAAE,GAAG,CAAC,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,KAAK,CAAC,kBAAkB,IAAI,0BAA0B,CAAC,CAAC;YACpE,CAAC;YACD,MAAM,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC,GAAG,WAAW,CAAC;YAC5C,MAAM,YAAY,GAAG,CAAC,GAAG,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/D,MAAM,IAAI,KAAK,CAAC,kBAAkB,QAAQ,0CAA0C,YAAY,EAAE,CAAC,CAAC;QACtG,CAAC;QACD,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,SAAS,GAAG,6BAA6B,CAAI,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;QACvG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC;QACxC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,IAAa,EACb,aAAgB,EAAO,EACvB,UAA8B,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;IAEnF,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,OAAO,6BAA6B,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two objects and returns the names of the fields that have changed.
|
|
3
|
+
* This function iterates over each field of object `a`, using `_.isEqual` to compare the field value
|
|
4
|
+
* with the corresponding field value in object `b`. If the values are different, the field name will
|
|
5
|
+
* be included in the returned array.
|
|
6
|
+
*
|
|
7
|
+
* @param a - The first object, representing the original data to compare.
|
|
8
|
+
* @param b - The second object, representing the updated data to compare.
|
|
9
|
+
* @returns - An array of field names that have changed.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const a = { name: 'John', age: 30 };
|
|
13
|
+
* const b = { name: 'John', age: 31 };
|
|
14
|
+
* const changedFields = getChangedFields(a, b);
|
|
15
|
+
* console.log(changedFields); // Output: ['age']
|
|
16
|
+
*/
|
|
17
|
+
export default function getChangedFields(a: unknown, b: unknown): string[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import keys from 'lodash-es/keys.js';
|
|
2
|
+
import pickBy from 'lodash-es/pickBy.js';
|
|
3
|
+
import isPlainObject from 'lodash-es/isPlainObject.js';
|
|
4
|
+
import get from 'lodash-es/get.js';
|
|
5
|
+
import difference from 'lodash-es/difference.js';
|
|
6
|
+
import deepEquals from './deepEquals.js';
|
|
7
|
+
/**
|
|
8
|
+
* Compares two objects and returns the names of the fields that have changed.
|
|
9
|
+
* This function iterates over each field of object `a`, using `_.isEqual` to compare the field value
|
|
10
|
+
* with the corresponding field value in object `b`. If the values are different, the field name will
|
|
11
|
+
* be included in the returned array.
|
|
12
|
+
*
|
|
13
|
+
* @param a - The first object, representing the original data to compare.
|
|
14
|
+
* @param b - The second object, representing the updated data to compare.
|
|
15
|
+
* @returns - An array of field names that have changed.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const a = { name: 'John', age: 30 };
|
|
19
|
+
* const b = { name: 'John', age: 31 };
|
|
20
|
+
* const changedFields = getChangedFields(a, b);
|
|
21
|
+
* console.log(changedFields); // Output: ['age']
|
|
22
|
+
*/
|
|
23
|
+
export default function getChangedFields(a, b) {
|
|
24
|
+
const aIsPlainObject = isPlainObject(a);
|
|
25
|
+
const bIsPlainObject = isPlainObject(b);
|
|
26
|
+
// If strictly equal or neither of them is a plainObject returns an empty array
|
|
27
|
+
if (a === b || (!aIsPlainObject && !bIsPlainObject)) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
if (aIsPlainObject && !bIsPlainObject) {
|
|
31
|
+
return keys(a);
|
|
32
|
+
}
|
|
33
|
+
else if (!aIsPlainObject && bIsPlainObject) {
|
|
34
|
+
return keys(b);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value, get(b, key))));
|
|
38
|
+
const diffFields = difference(keys(b), keys(a));
|
|
39
|
+
return [...unequalFields, ...diffFields];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=getChangedFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getChangedFields.js","sourceRoot":"","sources":["../src/getChangedFields.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAU,EAAE,CAAU;IAC7D,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACxC,+EAA+E;IAC/E,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,cAAc,IAAI,CAAC,cAAc,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IAC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MAAM,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,IAAI,EAAE,CAAC;QACT,eAAe,CAAC,IAAI,CAClB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAC7C,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EACjD,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAClD,CAAC;IACJ,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when
|
|
3
3
|
* it is not a string. Returns `undefined` when a valid discriminator is not present.
|
|
4
4
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
|
-
import isString from 'lodash/isString';
|
|
1
|
+
import get from 'lodash-es/get.js';
|
|
2
|
+
import isString from 'lodash-es/isString.js';
|
|
3
|
+
import { DISCRIMINATOR_PATH } from './constants.js';
|
|
3
4
|
/** Returns the `discriminator.propertyName` when defined in the `schema` if it is a string. A warning is generated when
|
|
4
5
|
* it is not a string. Returns `undefined` when a valid discriminator is not present.
|
|
5
6
|
*
|
|
@@ -8,7 +9,7 @@ import isString from 'lodash/isString';
|
|
|
8
9
|
*/
|
|
9
10
|
export default function getDiscriminatorFieldFromSchema(schema) {
|
|
10
11
|
let discriminator;
|
|
11
|
-
const maybeString = get(schema,
|
|
12
|
+
const maybeString = get(schema, DISCRIMINATOR_PATH);
|
|
12
13
|
if (isString(maybeString)) {
|
|
13
14
|
discriminator = maybeString;
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDiscriminatorFieldFromSchema.js","sourceRoot":"","sources":["../src/getDiscriminatorFieldFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"getDiscriminatorFieldFromSchema.js","sourceRoot":"","sources":["../src/getDiscriminatorFieldFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,+BAA+B,CAA0C,MAAS;IACxG,IAAI,aAAiC,CAAC;IACtC,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACpD,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC1B,aAAa,GAAG,WAAW,CAAC;IAC9B,CAAC;SAAM,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,gDAAgD,OAAO,WAAW,WAAW,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/lib/getInputProps.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, InputPropsType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from './types';
|
|
1
|
+
import { FormContextType, InputPropsType, RJSFSchema, StrictRJSFSchema, UIOptionsType } from './types.js';
|
|
2
2
|
/** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
|
|
3
3
|
*
|
|
4
4
|
* @param schema - The schema for the field provided by the widget
|
package/lib/getInputProps.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import rangeSpec from './rangeSpec';
|
|
1
|
+
import rangeSpec from './rangeSpec.js';
|
|
2
2
|
/** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
|
|
3
3
|
*
|
|
4
4
|
* @param schema - The schema for the field provided by the widget
|
|
@@ -39,6 +39,9 @@ export default function getInputProps(schema, defaultType, options = {}, autoDef
|
|
|
39
39
|
if (options.autocomplete) {
|
|
40
40
|
inputProps.autoComplete = options.autocomplete;
|
|
41
41
|
}
|
|
42
|
+
if (options.accept) {
|
|
43
|
+
inputProps.accept = options.accept;
|
|
44
|
+
}
|
|
42
45
|
return inputProps;
|
|
43
46
|
}
|
|
44
47
|
//# sourceMappingURL=getInputProps.js.map
|
package/lib/getInputProps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInputProps.js","sourceRoot":"","sources":["../src/getInputProps.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAKnC,MAAkB,EAClB,WAAoB,EACpB,UAAkC,EAAE,EACpC,kBAAkB,GAAG,IAAI;IAEzB,MAAM,UAAU,GAAmB;QACjC,IAAI,EAAE,WAAW,IAAI,MAAM;QAC3B,GAAG,SAAS,CAAC,MAAM,CAAC;KACrB,CAAC;IAEF,yDAAyD;IACzD,IAAI,OAAO,CAAC,SAAS,EAAE;
|
|
1
|
+
{"version":3,"file":"getInputProps.js","sourceRoot":"","sources":["../src/getInputProps.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAKnC,MAAkB,EAClB,WAAoB,EACpB,UAAkC,EAAE,EACpC,kBAAkB,GAAG,IAAI;IAEzB,MAAM,UAAU,GAAmB;QACjC,IAAI,EAAE,WAAW,IAAI,MAAM;QAC3B,GAAG,SAAS,CAAC,MAAM,CAAC;KACrB,CAAC;IAEF,yDAAyD;IACzD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,UAAU,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC;IACtC,CAAC;SAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QACxB,2EAA2E;QAC3E,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,UAAU,CAAC,IAAI,GAAG,QAAQ,CAAC;YAC3B,uFAAuF;YACvF,IAAI,kBAAkB,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACxD,qEAAqE;gBACrE,2BAA2B;gBAC3B,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;YAC1B,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YACrC,UAAU,CAAC,IAAI,GAAG,QAAQ,CAAC;YAC3B,6CAA6C;YAC7C,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAClC,8EAA8E;gBAC9E,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACzB,UAAU,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAgB,CAAC;IAC/C,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Compares the value of `discriminatorField` within `formData` against the value of `discriminatorField` within schema for each `option`.
|
|
3
3
|
* Returns index of first `option` whose discriminator matches formData. Returns `undefined` if there is no match.
|
|
4
4
|
* This function does not work with discriminators of `"type": "object"` and `"type": "array"`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
|
-
import { PROPERTIES_KEY } from './constants';
|
|
1
|
+
import get from 'lodash-es/get.js';
|
|
2
|
+
import { PROPERTIES_KEY } from './constants.js';
|
|
3
3
|
/** Compares the value of `discriminatorField` within `formData` against the value of `discriminatorField` within schema for each `option`.
|
|
4
4
|
* Returns index of first `option` whose discriminator matches formData. Returns `undefined` if there is no match.
|
|
5
5
|
* This function does not work with discriminators of `"type": "object"` and `"type": "array"`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOptionMatchingSimpleDiscriminator.js","sourceRoot":"","sources":["../src/getOptionMatchingSimpleDiscriminator.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,oCAAoC,CAC1D,QAAuB,EACvB,OAAY,EACZ,kBAA2B;;IAE3B,IAAI,QAAQ,IAAI,kBAAkB,EAAE;
|
|
1
|
+
{"version":3,"file":"getOptionMatchingSimpleDiscriminator.js","sourceRoot":"","sources":["../src/getOptionMatchingSimpleDiscriminator.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,oCAAoC,CAC1D,QAAuB,EACvB,OAAY,EACZ,kBAA2B;;IAE3B,IAAI,QAAQ,IAAI,kBAAkB,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;QAEhD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,MAAM,aAAa,GAAM,GAAG,CAAC,MAAM,EAAE,CAAC,cAAc,EAAE,kBAAkB,CAAC,EAAE,EAAE,CAAM,CAAC;YAEpF,IAAI,aAAa,CAAC,IAAI,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACtE,SAAS;YACX,CAAC;YAED,IAAI,aAAa,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;gBAClC,OAAO,CAAC,CAAC;YACX,CAAC;YAED,IAAI,MAAA,aAAa,CAAC,IAAI,0CAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,CAAC;YACX,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;AACT,CAAC"}
|
package/lib/getSchemaType.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { RJSFSchema, StrictRJSFSchema } from './types';
|
|
1
|
+
import { RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
2
|
/** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
|
|
3
3
|
* other elements of the schema as follows:
|
|
4
4
|
* - schema.const: Returns the `guessType()` of that value
|
|
5
5
|
* - schema.enum: Returns `string`
|
|
6
6
|
* - schema.properties: Returns `object`
|
|
7
7
|
* - schema.additionalProperties: Returns `object`
|
|
8
|
+
* - schema.patternProperties: Returns `object`
|
|
8
9
|
* - type is an array with a length of 2 and one type is 'null': Returns the other type
|
|
9
10
|
*
|
|
10
11
|
* @param schema - The schema for which to get the type
|
package/lib/getSchemaType.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import guessType from './guessType';
|
|
1
|
+
import guessType from './guessType.js';
|
|
2
2
|
/** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
|
|
3
3
|
* other elements of the schema as follows:
|
|
4
4
|
* - schema.const: Returns the `guessType()` of that value
|
|
5
5
|
* - schema.enum: Returns `string`
|
|
6
6
|
* - schema.properties: Returns `object`
|
|
7
7
|
* - schema.additionalProperties: Returns `object`
|
|
8
|
+
* - schema.patternProperties: Returns `object`
|
|
8
9
|
* - type is an array with a length of 2 and one type is 'null': Returns the other type
|
|
9
10
|
*
|
|
10
11
|
* @param schema - The schema for which to get the type
|
|
@@ -18,7 +19,7 @@ export default function getSchemaType(schema) {
|
|
|
18
19
|
if (!type && schema.enum) {
|
|
19
20
|
return 'string';
|
|
20
21
|
}
|
|
21
|
-
if (!type && (schema.properties || schema.additionalProperties)) {
|
|
22
|
+
if (!type && (schema.properties || schema.additionalProperties || schema.patternProperties)) {
|
|
22
23
|
return 'object';
|
|
23
24
|
}
|
|
24
25
|
if (Array.isArray(type)) {
|
package/lib/getSchemaType.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemaType.js","sourceRoot":"","sources":["../src/getSchemaType.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC
|
|
1
|
+
{"version":3,"file":"getSchemaType.js","sourceRoot":"","sources":["../src/getSchemaType.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,MAAS;IAET,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAEtB,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,oBAAoB,IAAI,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC5F,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/C,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema, UISchemaSubmitButtonOptions } from './types';
|
|
1
|
+
import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema, UISchemaSubmitButtonOptions } from './types.js';
|
|
2
2
|
/** The default submit button options, exported for testing purposes
|
|
3
3
|
*/
|
|
4
4
|
export declare const DEFAULT_OPTIONS: UISchemaSubmitButtonOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SUBMIT_BTN_OPTIONS_KEY } from './constants';
|
|
2
|
-
import getUiOptions from './getUiOptions';
|
|
1
|
+
import { SUBMIT_BTN_OPTIONS_KEY } from './constants.js';
|
|
2
|
+
import getUiOptions from './getUiOptions.js';
|
|
3
3
|
/** The default submit button options, exported for testing purposes
|
|
4
4
|
*/
|
|
5
5
|
export const DEFAULT_OPTIONS = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSubmitButtonOptions.js","sourceRoot":"","sources":["../src/getSubmitButtonOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAG1C;GACG;AACH,MAAM,CAAC,MAAM,eAAe,GAAgC;IAC1D,KAAK,EAAE;QACL,QAAQ,EAAE,KAAK;KAChB;IACD,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAI5C,WAA8B,EAAE;IAChC,MAAM,SAAS,GAAG,YAAY,CAAU,QAAQ,CAAC,CAAC;IAClD,IAAI,SAAS,IAAI,SAAS,CAAC,sBAAsB,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"getSubmitButtonOptions.js","sourceRoot":"","sources":["../src/getSubmitButtonOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAG1C;GACG;AACH,MAAM,CAAC,MAAM,eAAe,GAAgC;IAC1D,KAAK,EAAE;QACL,QAAQ,EAAE,KAAK;KAChB;IACD,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAI5C,WAA8B,EAAE;IAChC,MAAM,SAAS,GAAG,YAAY,CAAU,QAAQ,CAAC,CAAC;IAClD,IAAI,SAAS,IAAI,SAAS,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACnD,MAAM,OAAO,GAAG,SAAS,CAAC,sBAAsB,CAAgC,CAAC;QACjF,OAAO,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/lib/getTemplate.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, TemplatesType, Registry, UIOptionsType, StrictRJSFSchema, RJSFSchema } from './types';
|
|
1
|
+
import { FormContextType, TemplatesType, Registry, UIOptionsType, StrictRJSFSchema, RJSFSchema } from './types.js';
|
|
2
2
|
/** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`
|
|
3
3
|
* otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.
|
|
4
4
|
*
|
package/lib/getTemplate.js
CHANGED
|
@@ -11,6 +11,15 @@ export default function getTemplate(name, registry, uiOptions = {}) {
|
|
|
11
11
|
if (name === 'ButtonTemplates') {
|
|
12
12
|
return templates[name];
|
|
13
13
|
}
|
|
14
|
+
// Allow templates to be customized per-field by using string keys from the registry
|
|
15
|
+
if (Object.hasOwn(uiOptions, name) &&
|
|
16
|
+
typeof uiOptions[name] === 'string' &&
|
|
17
|
+
Object.hasOwn(templates, uiOptions[name])) {
|
|
18
|
+
const key = uiOptions[name];
|
|
19
|
+
// Evaluating templates[key] results in TS2590: Expression produces a union type that is too complex to represent
|
|
20
|
+
// To avoid that, we cast templates to `any` before accessing the key field
|
|
21
|
+
return templates[key];
|
|
22
|
+
}
|
|
14
23
|
return (
|
|
15
24
|
// Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent
|
|
16
25
|
// To avoid that, we cast uiOptions to `any` before accessing the name field
|
package/lib/getTemplate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTemplate.js","sourceRoot":"","sources":["../src/getTemplate.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAKjC,IAAU,EAAE,QAA2B,EAAE,YAAoC,EAAE;IAC/E,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IAC/B,IAAI,IAAI,KAAK,iBAAiB,EAAE;QAC9B,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getTemplate.js","sourceRoot":"","sources":["../src/getTemplate.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAKjC,IAAU,EAAE,QAA2B,EAAE,YAAoC,EAAE;IAC/E,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IAC/B,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,oFAAoF;IACpF,IACE,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC;QAC9B,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,QAAQ;QACnC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAW,CAAC,EACnD,CAAC;QACD,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAC5B,iHAAiH;QACjH,2EAA2E;QAC3E,OAAQ,SAAiB,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,OAAO;IACL,kHAAkH;IAClH,4EAA4E;IAC1E,SAAiB,CAAC,IAAI,CAAkC,IAAI,SAAS,CAAC,IAAI,CAAC,CAC9E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TestIdShape } from './types.js';
|
|
2
|
+
/** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment
|
|
3
|
+
* (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned
|
|
4
|
+
* object is accessed, if the value already exists the object will return that value, otherwise it will create that key
|
|
5
|
+
* with a generated `uuid` value and return the generated ID. If it is called outside of a test environment, the
|
|
6
|
+
* function will return an empty object, therefore returning `undefined` for any property within the object and
|
|
7
|
+
* excluding the prop from the rendered output of the component in which it is used.
|
|
8
|
+
* This implementation was adapted from the following blog post: https://www.matthewsessions.com/blog/react-test-id/
|
|
9
|
+
* To use this helper, you will want to generate a separate object for each component to avoid potential overlapping of
|
|
10
|
+
* ID names. You will also want to export the object for use in tests, because the keys will be generated in the
|
|
11
|
+
* component file, and used in the test file. Within the component file, add:
|
|
12
|
+
* `export const TEST_IDS = getTestIds();`
|
|
13
|
+
* Then pass `TEST_IDS.examplePropertyName` as the value of the test ID attribute of the intended component. This will
|
|
14
|
+
* allow you to use `TEST_IDS.examplePropertyName` within your tests, while keeping the test IDs out of your rendered
|
|
15
|
+
* output.
|
|
16
|
+
*/
|
|
17
|
+
export default function getTestIds(): TestIdShape;
|