@rjsf/utils 6.4.2 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +198 -84
- package/dist/index.cjs.map +4 -4
- package/dist/utils.esm.js +198 -84
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +185 -80
- package/lib/enumOptionSelectedValue.d.ts +15 -0
- package/lib/enumOptionSelectedValue.js +28 -0
- package/lib/enumOptionSelectedValue.js.map +1 -0
- package/lib/enumOptionValueDecoder.d.ts +17 -0
- package/lib/enumOptionValueDecoder.js +53 -0
- package/lib/enumOptionValueDecoder.js.map +1 -0
- package/lib/enumOptionValueEncoder.d.ts +15 -0
- package/lib/enumOptionValueEncoder.js +27 -0
- package/lib/enumOptionValueEncoder.js.map +1 -0
- package/lib/getInputProps.js +9 -0
- package/lib/getInputProps.js.map +1 -1
- package/lib/getOptionValueFormat.d.ts +16 -0
- package/lib/getOptionValueFormat.js +17 -0
- package/lib/getOptionValueFormat.js.map +1 -0
- package/lib/index.d.ts +7 -2
- package/lib/index.js +7 -2
- package/lib/index.js.map +1 -1
- package/lib/removeOptionalEmptyObjects.d.ts +17 -0
- package/lib/removeOptionalEmptyObjects.js +108 -0
- package/lib/removeOptionalEmptyObjects.js.map +1 -0
- package/lib/resolveUiSchema.d.ts +5 -19
- package/lib/resolveUiSchema.js +49 -95
- package/lib/resolveUiSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +27 -1
- package/package.json +4 -4
- package/src/enumOptionSelectedValue.ts +39 -0
- package/src/enumOptionValueDecoder.ts +64 -0
- package/src/enumOptionValueEncoder.ts +33 -0
- package/src/getInputProps.ts +10 -0
- package/src/getOptionValueFormat.ts +17 -0
- package/src/index.ts +11 -2
- package/src/removeOptionalEmptyObjects.ts +127 -0
- package/src/resolveUiSchema.ts +55 -122
- package/src/types.ts +28 -1
package/dist/utils.umd.js
CHANGED
|
@@ -2573,6 +2573,36 @@
|
|
|
2573
2573
|
return replaceStringParameters(stringToTranslate, params);
|
|
2574
2574
|
}
|
|
2575
2575
|
|
|
2576
|
+
// src/enumOptionsIsSelected.ts
|
|
2577
|
+
function enumOptionsIsSelected(value, selected) {
|
|
2578
|
+
if (Array.isArray(selected)) {
|
|
2579
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
2580
|
+
}
|
|
2581
|
+
return deepEquals(selected, value);
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
// src/enumOptionsIndexForValue.ts
|
|
2585
|
+
function enumOptionsIndexForValue(value, allEnumOptions = [], multiple = false) {
|
|
2586
|
+
const selectedIndexes = allEnumOptions.map((opt, index) => enumOptionsIsSelected(opt.value, value) ? String(index) : void 0).filter((opt) => typeof opt !== "undefined");
|
|
2587
|
+
if (!multiple) {
|
|
2588
|
+
return selectedIndexes[0];
|
|
2589
|
+
}
|
|
2590
|
+
return selectedIndexes;
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
// src/enumOptionSelectedValue.ts
|
|
2594
|
+
function enumOptionSelectedValue(value, enumOptions, multiple, format = "indexed", emptyValue) {
|
|
2595
|
+
const isEmpty9 = typeof value === "undefined" || multiple && Array.isArray(value) && value.length < 1 || !multiple && value === emptyValue;
|
|
2596
|
+
if (isEmpty9) {
|
|
2597
|
+
return emptyValue;
|
|
2598
|
+
}
|
|
2599
|
+
if (format === "realValue") {
|
|
2600
|
+
return multiple ? value.map(String) : String(value);
|
|
2601
|
+
}
|
|
2602
|
+
const indexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
2603
|
+
return typeof indexes === "undefined" ? emptyValue : indexes;
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2576
2606
|
// src/enumOptionsValueForIndex.ts
|
|
2577
2607
|
function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
2578
2608
|
if (Array.isArray(valueIndex)) {
|
|
@@ -2583,6 +2613,43 @@
|
|
|
2583
2613
|
return option ? option.value : emptyValue;
|
|
2584
2614
|
}
|
|
2585
2615
|
|
|
2616
|
+
// src/enumOptionValueDecoder.ts
|
|
2617
|
+
function decodeSingle(value, enumOptions, emptyValue) {
|
|
2618
|
+
if (value === "" || !Array.isArray(enumOptions)) {
|
|
2619
|
+
return emptyValue;
|
|
2620
|
+
}
|
|
2621
|
+
const match = enumOptions.find((opt) => String(opt.value) === value);
|
|
2622
|
+
if (match) {
|
|
2623
|
+
return match.value;
|
|
2624
|
+
}
|
|
2625
|
+
const index = Number(value);
|
|
2626
|
+
if (!isNaN(index) && index >= 0 && index < enumOptions.length) {
|
|
2627
|
+
return enumOptions[index].value;
|
|
2628
|
+
}
|
|
2629
|
+
return emptyValue;
|
|
2630
|
+
}
|
|
2631
|
+
function enumOptionValueDecoder(value, enumOptions, format = "indexed", emptyValue) {
|
|
2632
|
+
if (format !== "realValue") {
|
|
2633
|
+
return enumOptionsValueForIndex(value, enumOptions, emptyValue);
|
|
2634
|
+
}
|
|
2635
|
+
if (Array.isArray(value)) {
|
|
2636
|
+
return value.map((v) => decodeSingle(v, enumOptions, emptyValue));
|
|
2637
|
+
}
|
|
2638
|
+
return decodeSingle(value, enumOptions, emptyValue);
|
|
2639
|
+
}
|
|
2640
|
+
function enumOptionValueEncoder(value, index, format = "indexed") {
|
|
2641
|
+
if (format !== "realValue") {
|
|
2642
|
+
return String(index);
|
|
2643
|
+
}
|
|
2644
|
+
if (isNil(value)) {
|
|
2645
|
+
return "";
|
|
2646
|
+
}
|
|
2647
|
+
if (typeof value === "object") {
|
|
2648
|
+
return String(index);
|
|
2649
|
+
}
|
|
2650
|
+
return String(value);
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2586
2653
|
// src/enumOptionsDeselectValue.ts
|
|
2587
2654
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2588
2655
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
@@ -2591,23 +2658,6 @@
|
|
|
2591
2658
|
}
|
|
2592
2659
|
return deepEquals(value, selected) ? void 0 : selected;
|
|
2593
2660
|
}
|
|
2594
|
-
|
|
2595
|
-
// src/enumOptionsIsSelected.ts
|
|
2596
|
-
function enumOptionsIsSelected(value, selected) {
|
|
2597
|
-
if (Array.isArray(selected)) {
|
|
2598
|
-
return selected.some((sel) => deepEquals(sel, value));
|
|
2599
|
-
}
|
|
2600
|
-
return deepEquals(selected, value);
|
|
2601
|
-
}
|
|
2602
|
-
|
|
2603
|
-
// src/enumOptionsIndexForValue.ts
|
|
2604
|
-
function enumOptionsIndexForValue(value, allEnumOptions = [], multiple = false) {
|
|
2605
|
-
const selectedIndexes = allEnumOptions.map((opt, index) => enumOptionsIsSelected(opt.value, value) ? String(index) : void 0).filter((opt) => typeof opt !== "undefined");
|
|
2606
|
-
if (!multiple) {
|
|
2607
|
-
return selectedIndexes[0];
|
|
2608
|
-
}
|
|
2609
|
-
return selectedIndexes;
|
|
2610
|
-
}
|
|
2611
2661
|
function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2612
2662
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2613
2663
|
if (!isNil(value)) {
|
|
@@ -2790,6 +2840,14 @@
|
|
|
2790
2840
|
}
|
|
2791
2841
|
}
|
|
2792
2842
|
}
|
|
2843
|
+
if (["date", "datetime-local", "time", "week", "month"].includes(inputProps.type)) {
|
|
2844
|
+
if (schema.formatMinimum !== void 0) {
|
|
2845
|
+
inputProps.min = schema.formatMinimum;
|
|
2846
|
+
}
|
|
2847
|
+
if (schema.formatMaximum !== void 0) {
|
|
2848
|
+
inputProps.max = schema.formatMaximum;
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2793
2851
|
if (options.autocomplete) {
|
|
2794
2852
|
inputProps.autoComplete = options.autocomplete;
|
|
2795
2853
|
}
|
|
@@ -2799,6 +2857,11 @@
|
|
|
2799
2857
|
return inputProps;
|
|
2800
2858
|
}
|
|
2801
2859
|
|
|
2860
|
+
// src/getOptionValueFormat.ts
|
|
2861
|
+
function getOptionValueFormat(options) {
|
|
2862
|
+
return options?.optionValueFormat ?? "indexed";
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2802
2865
|
// src/getSubmitButtonOptions.ts
|
|
2803
2866
|
var DEFAULT_OPTIONS = {
|
|
2804
2867
|
props: {
|
|
@@ -3034,6 +3097,78 @@
|
|
|
3034
3097
|
}
|
|
3035
3098
|
return get16(regOrFc, [...lookupPath, toLookup], fallback);
|
|
3036
3099
|
}
|
|
3100
|
+
function isValueEmpty(value) {
|
|
3101
|
+
if (isNil(value) || value === "") {
|
|
3102
|
+
return true;
|
|
3103
|
+
}
|
|
3104
|
+
if (Array.isArray(value)) {
|
|
3105
|
+
return value.length === 0;
|
|
3106
|
+
}
|
|
3107
|
+
if (isObject(value)) {
|
|
3108
|
+
const obj = value;
|
|
3109
|
+
const keys2 = Object.keys(obj);
|
|
3110
|
+
return keys2.every((key) => isValueEmpty(obj[key]));
|
|
3111
|
+
}
|
|
3112
|
+
return false;
|
|
3113
|
+
}
|
|
3114
|
+
function removeOptionalEmptyObjects(validator, schema, rootSchema, formData) {
|
|
3115
|
+
if (!isObject(schema)) {
|
|
3116
|
+
return formData;
|
|
3117
|
+
}
|
|
3118
|
+
const resolvedSchema = retrieveSchema(validator, schema, rootSchema, formData);
|
|
3119
|
+
if (Array.isArray(formData)) {
|
|
3120
|
+
const itemsSchema = resolvedSchema.items;
|
|
3121
|
+
if (!itemsSchema) {
|
|
3122
|
+
return formData;
|
|
3123
|
+
}
|
|
3124
|
+
let hasChanges = false;
|
|
3125
|
+
const mapped = formData.map((item, index) => {
|
|
3126
|
+
let itemSchema = itemsSchema;
|
|
3127
|
+
if (Array.isArray(itemsSchema)) {
|
|
3128
|
+
itemSchema = itemsSchema[index] || resolvedSchema.additionalItems || {};
|
|
3129
|
+
}
|
|
3130
|
+
const cleaned = removeOptionalEmptyObjects(validator, itemSchema, rootSchema, item);
|
|
3131
|
+
if (cleaned !== item) {
|
|
3132
|
+
hasChanges = true;
|
|
3133
|
+
}
|
|
3134
|
+
return cleaned === void 0 ? {} : cleaned;
|
|
3135
|
+
});
|
|
3136
|
+
return hasChanges ? mapped : formData;
|
|
3137
|
+
}
|
|
3138
|
+
const { properties, required: requiredFields = [] } = resolvedSchema;
|
|
3139
|
+
if (!isObject(formData) || !properties) {
|
|
3140
|
+
return formData;
|
|
3141
|
+
}
|
|
3142
|
+
const result = {};
|
|
3143
|
+
const data = formData;
|
|
3144
|
+
let hasAnyValue = false;
|
|
3145
|
+
for (const key of Object.keys(data)) {
|
|
3146
|
+
const value = data[key];
|
|
3147
|
+
const propertySchema = properties[key] || {};
|
|
3148
|
+
const isRequired = requiredFields.includes(key);
|
|
3149
|
+
const isObj = isObject(value);
|
|
3150
|
+
const isArr = Array.isArray(value);
|
|
3151
|
+
if ((isObj || isArr) && properties[key]) {
|
|
3152
|
+
const cleaned = removeOptionalEmptyObjects(validator, propertySchema, rootSchema, value);
|
|
3153
|
+
if (!isRequired && isValueEmpty(cleaned)) {
|
|
3154
|
+
continue;
|
|
3155
|
+
}
|
|
3156
|
+
result[key] = cleaned;
|
|
3157
|
+
hasAnyValue = true;
|
|
3158
|
+
} else if (!isRequired && isValueEmpty(value) && properties[key]) {
|
|
3159
|
+
continue;
|
|
3160
|
+
} else {
|
|
3161
|
+
result[key] = value;
|
|
3162
|
+
if (!isValueEmpty(value)) {
|
|
3163
|
+
hasAnyValue = true;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
if (!hasAnyValue && Object.keys(result).length === 0) {
|
|
3168
|
+
return void 0;
|
|
3169
|
+
}
|
|
3170
|
+
return result;
|
|
3171
|
+
}
|
|
3037
3172
|
|
|
3038
3173
|
// src/orderProperties.ts
|
|
3039
3174
|
function orderProperties(properties, order) {
|
|
@@ -3090,65 +3225,42 @@
|
|
|
3090
3225
|
second: includeTime ? date.getUTCSeconds() : 0
|
|
3091
3226
|
};
|
|
3092
3227
|
}
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
visited.add(ref);
|
|
3105
|
-
if (definitions && ref in definitions) {
|
|
3106
|
-
result = mergeObjects(definitions[ref], result);
|
|
3107
|
-
}
|
|
3108
|
-
if (isRecursive) {
|
|
3109
|
-
return result;
|
|
3110
|
-
}
|
|
3111
|
-
try {
|
|
3112
|
-
resolvedSchema = findSchemaDefinition(ref, rootSchema);
|
|
3113
|
-
} catch {
|
|
3114
|
-
resolvedSchema = currentSchema;
|
|
3115
|
-
}
|
|
3228
|
+
function resolveUiSchema(schema, localUiSchema, registry) {
|
|
3229
|
+
const ref = schema[RJSF_REF_KEY] ?? schema[REF_KEY];
|
|
3230
|
+
const definitions = registry.uiSchemaDefinitions;
|
|
3231
|
+
const definitionUiSchema = ref && definitions ? definitions[ref] : void 0;
|
|
3232
|
+
let result;
|
|
3233
|
+
if (!definitionUiSchema) {
|
|
3234
|
+
result = localUiSchema || {};
|
|
3235
|
+
} else if (!localUiSchema || isEmpty4(localUiSchema)) {
|
|
3236
|
+
result = { ...definitionUiSchema };
|
|
3237
|
+
} else {
|
|
3238
|
+
result = mergeObjects(definitionUiSchema, localUiSchema);
|
|
3116
3239
|
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3240
|
+
if (definitions) {
|
|
3241
|
+
let resolvedSchema = schema;
|
|
3242
|
+
if (ref && schema[REF_KEY] && !schema[RJSF_REF_KEY]) {
|
|
3243
|
+
try {
|
|
3244
|
+
resolvedSchema = findSchemaDefinition(ref, registry.rootSchema);
|
|
3245
|
+
} catch (e) {
|
|
3246
|
+
console.warn("could not resolve $ref in resolveUiSchema:\n", e);
|
|
3247
|
+
return result;
|
|
3124
3248
|
}
|
|
3125
3249
|
}
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
const currentUiSchema = result[keyword];
|
|
3131
|
-
if (typeof currentUiSchema !== "function") {
|
|
3132
|
-
const subUiSchema = currentUiSchema || {};
|
|
3133
|
-
const expanded = expandUiSchemaDefinitions(subSchema, subUiSchema, registry, new Set(visited));
|
|
3134
|
-
if (Object.keys(expanded).length > 0) {
|
|
3135
|
-
result[keyword] = expanded;
|
|
3136
|
-
}
|
|
3250
|
+
for (const keyword of [ONE_OF_KEY, ANY_OF_KEY]) {
|
|
3251
|
+
const schemaOptions = resolvedSchema[keyword];
|
|
3252
|
+
if (!Array.isArray(schemaOptions) || schemaOptions.length === 0) {
|
|
3253
|
+
continue;
|
|
3137
3254
|
}
|
|
3138
|
-
}
|
|
3139
|
-
}
|
|
3140
|
-
for (const keyword of ARRAY_KEYWORDS) {
|
|
3141
|
-
const schemaOptions = resolvedSchema[keyword];
|
|
3142
|
-
if (Array.isArray(schemaOptions) && schemaOptions.length > 0) {
|
|
3143
3255
|
const currentUiSchemaArray = result[keyword];
|
|
3144
3256
|
const uiSchemaArray = Array.isArray(currentUiSchemaArray) ? [...currentUiSchemaArray] : [];
|
|
3145
3257
|
let hasExpanded = false;
|
|
3146
3258
|
for (let i = 0; i < schemaOptions.length; i++) {
|
|
3147
|
-
const
|
|
3148
|
-
const
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
uiSchemaArray[i] =
|
|
3259
|
+
const option = schemaOptions[i];
|
|
3260
|
+
const optionRef = option?.[RJSF_REF_KEY] ?? option?.[REF_KEY];
|
|
3261
|
+
if (optionRef && optionRef in definitions) {
|
|
3262
|
+
const optionUiSchema = uiSchemaArray[i] || {};
|
|
3263
|
+
uiSchemaArray[i] = mergeObjects(definitions[optionRef], optionUiSchema);
|
|
3152
3264
|
hasExpanded = true;
|
|
3153
3265
|
}
|
|
3154
3266
|
}
|
|
@@ -3159,17 +3271,6 @@
|
|
|
3159
3271
|
}
|
|
3160
3272
|
return result;
|
|
3161
3273
|
}
|
|
3162
|
-
function resolveUiSchema(schema, localUiSchema, registry) {
|
|
3163
|
-
const ref = schema[RJSF_REF_KEY] ?? schema[REF_KEY];
|
|
3164
|
-
const definitionUiSchema = ref ? registry.uiSchemaDefinitions?.[ref] : void 0;
|
|
3165
|
-
if (!definitionUiSchema) {
|
|
3166
|
-
return localUiSchema || {};
|
|
3167
|
-
}
|
|
3168
|
-
if (!localUiSchema || Object.keys(localUiSchema).length === 0) {
|
|
3169
|
-
return { ...definitionUiSchema };
|
|
3170
|
-
}
|
|
3171
|
-
return mergeObjects(definitionUiSchema, localUiSchema);
|
|
3172
|
-
}
|
|
3173
3274
|
|
|
3174
3275
|
// src/schemaRequiresTrueValue.ts
|
|
3175
3276
|
function schemaRequiresTrueValue(schema) {
|
|
@@ -3786,6 +3887,9 @@
|
|
|
3786
3887
|
exports.descriptionId = descriptionId;
|
|
3787
3888
|
exports.dotNotationNameGenerator = dotNotationNameGenerator;
|
|
3788
3889
|
exports.englishStringTranslator = englishStringTranslator;
|
|
3890
|
+
exports.enumOptionSelectedValue = enumOptionSelectedValue;
|
|
3891
|
+
exports.enumOptionValueDecoder = enumOptionValueDecoder;
|
|
3892
|
+
exports.enumOptionValueEncoder = enumOptionValueEncoder;
|
|
3789
3893
|
exports.enumOptionsDeselectValue = enumOptionsDeselectValue;
|
|
3790
3894
|
exports.enumOptionsIndexForValue = enumOptionsIndexForValue;
|
|
3791
3895
|
exports.enumOptionsIsSelected = enumOptionsIsSelected;
|
|
@@ -3793,7 +3897,6 @@
|
|
|
3793
3897
|
exports.enumOptionsValueForIndex = enumOptionsValueForIndex;
|
|
3794
3898
|
exports.errorId = errorId;
|
|
3795
3899
|
exports.examplesId = examplesId;
|
|
3796
|
-
exports.expandUiSchemaDefinitions = expandUiSchemaDefinitions;
|
|
3797
3900
|
exports.findFieldInSchema = findFieldInSchema;
|
|
3798
3901
|
exports.findSchemaDefinition = findSchemaDefinition;
|
|
3799
3902
|
exports.findSelectedOptionInXxxOf = findSelectedOptionInXxxOf;
|
|
@@ -3808,6 +3911,7 @@
|
|
|
3808
3911
|
exports.getFromSchema = getFromSchema;
|
|
3809
3912
|
exports.getInputProps = getInputProps;
|
|
3810
3913
|
exports.getOptionMatchingSimpleDiscriminator = getOptionMatchingSimpleDiscriminator;
|
|
3914
|
+
exports.getOptionValueFormat = getOptionValueFormat;
|
|
3811
3915
|
exports.getSchemaType = getSchemaType;
|
|
3812
3916
|
exports.getSubmitButtonOptions = getSubmitButtonOptions;
|
|
3813
3917
|
exports.getTemplate = getTemplate;
|
|
@@ -3844,6 +3948,7 @@
|
|
|
3844
3948
|
exports.pad = pad;
|
|
3845
3949
|
exports.parseDateString = parseDateString;
|
|
3846
3950
|
exports.rangeSpec = rangeSpec;
|
|
3951
|
+
exports.removeOptionalEmptyObjects = removeOptionalEmptyObjects;
|
|
3847
3952
|
exports.replaceStringParameters = replaceStringParameters;
|
|
3848
3953
|
exports.resolveUiSchema = resolveUiSchema;
|
|
3849
3954
|
exports.retrieveSchema = retrieveSchema;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types.js';
|
|
2
|
+
/** Computes the value to pass to a select element's `value` attribute.
|
|
3
|
+
*
|
|
4
|
+
* When `format` is `'realValue'`, converts form data values to strings.
|
|
5
|
+
* When `format` is `'indexed'` (the default), resolves to index-based values via
|
|
6
|
+
* `enumOptionsIndexForValue`. Returns `emptyValue` when the current value is empty.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The current form data value
|
|
9
|
+
* @param enumOptions - The available enum options
|
|
10
|
+
* @param multiple - Whether the select allows multiple selections
|
|
11
|
+
* @param [format='indexed'] - How option values are encoded on the DOM
|
|
12
|
+
* @param emptyValue - The value to return when the selection is empty
|
|
13
|
+
* @returns The value to use for the select element's `value` attribute
|
|
14
|
+
*/
|
|
15
|
+
export default function enumOptionSelectedValue<S extends StrictRJSFSchema = RJSFSchema>(value: any, enumOptions: EnumOptionsType<S>[] | undefined, multiple: boolean, format?: OptionValueFormat, emptyValue?: any): any;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
2
|
+
/** Computes the value to pass to a select element's `value` attribute.
|
|
3
|
+
*
|
|
4
|
+
* When `format` is `'realValue'`, converts form data values to strings.
|
|
5
|
+
* When `format` is `'indexed'` (the default), resolves to index-based values via
|
|
6
|
+
* `enumOptionsIndexForValue`. Returns `emptyValue` when the current value is empty.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The current form data value
|
|
9
|
+
* @param enumOptions - The available enum options
|
|
10
|
+
* @param multiple - Whether the select allows multiple selections
|
|
11
|
+
* @param [format='indexed'] - How option values are encoded on the DOM
|
|
12
|
+
* @param emptyValue - The value to return when the selection is empty
|
|
13
|
+
* @returns The value to use for the select element's `value` attribute
|
|
14
|
+
*/
|
|
15
|
+
export default function enumOptionSelectedValue(value, enumOptions, multiple, format = 'indexed', emptyValue) {
|
|
16
|
+
const isEmpty = typeof value === 'undefined' ||
|
|
17
|
+
(multiple && Array.isArray(value) && value.length < 1) ||
|
|
18
|
+
(!multiple && value === emptyValue);
|
|
19
|
+
if (isEmpty) {
|
|
20
|
+
return emptyValue;
|
|
21
|
+
}
|
|
22
|
+
if (format === 'realValue') {
|
|
23
|
+
return multiple ? value.map(String) : String(value);
|
|
24
|
+
}
|
|
25
|
+
const indexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
26
|
+
return typeof indexes === 'undefined' ? emptyValue : indexes;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=enumOptionSelectedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumOptionSelectedValue.js","sourceRoot":"","sources":["../src/enumOptionSelectedValue.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,KAAU,EACV,WAA6C,EAC7C,QAAiB,EACjB,SAA4B,SAAS,EACrC,UAAgB;IAEhB,MAAM,OAAO,GACX,OAAO,KAAK,KAAK,WAAW;QAC5B,CAAC,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACtD,CAAC,CAAC,QAAQ,IAAI,KAAK,KAAK,UAAU,CAAC,CAAC;IAEtC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,OAAO,GAAG,wBAAwB,CAAI,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC1E,OAAO,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EnumOptionsType, OptionValueFormat, StrictRJSFSchema, RJSFSchema } from './types.js';
|
|
2
|
+
/** Decodes a string from a DOM value attribute back to a typed enum value.
|
|
3
|
+
*
|
|
4
|
+
* When `format` is `'realValue'`, does a reverse lookup: finds the enum option
|
|
5
|
+
* whose `String(value)` matches the input string and returns the original typed value.
|
|
6
|
+
* For object/array values that were encoded as indices, falls back to index resolution.
|
|
7
|
+
*
|
|
8
|
+
* When `format` is `'indexed'` (the default), uses index-based resolution via
|
|
9
|
+
* `enumOptionsValueForIndex`.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The string value(s) from the DOM
|
|
12
|
+
* @param enumOptions - The available enum options
|
|
13
|
+
* @param [format='indexed'] - How the values were encoded on the DOM
|
|
14
|
+
* @param emptyValue - The value to return for empty/missing selections
|
|
15
|
+
* @returns The original typed enum value(s)
|
|
16
|
+
*/
|
|
17
|
+
export default function enumOptionValueDecoder<S extends StrictRJSFSchema = RJSFSchema>(value: string | string[], enumOptions: EnumOptionsType<S>[] | undefined, format?: OptionValueFormat, emptyValue?: unknown): unknown;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import enumOptionsValueForIndex from './enumOptionsValueForIndex.js';
|
|
2
|
+
/** Resolves a single DOM value string back to its typed enum value in `'realValue'` mode.
|
|
3
|
+
*
|
|
4
|
+
* First attempts a reverse lookup by matching `String(opt.value)` against the input.
|
|
5
|
+
* If no option matches and the input parses as a valid index, falls back to the
|
|
6
|
+
* option at that index — this is how object/array enum values round-trip, since
|
|
7
|
+
* they are encoded as indices by the encoder.
|
|
8
|
+
*
|
|
9
|
+
* @param value - A single string value from a DOM attribute
|
|
10
|
+
* @param enumOptions - The available enum options
|
|
11
|
+
* @param emptyValue - The value to return when the input is empty, options are missing, or no match is found
|
|
12
|
+
* @returns The original typed enum value, or `emptyValue`
|
|
13
|
+
*/
|
|
14
|
+
function decodeSingle(value, enumOptions, emptyValue) {
|
|
15
|
+
if (value === '' || !Array.isArray(enumOptions)) {
|
|
16
|
+
return emptyValue;
|
|
17
|
+
}
|
|
18
|
+
const match = enumOptions.find((opt) => String(opt.value) === value);
|
|
19
|
+
if (match) {
|
|
20
|
+
return match.value;
|
|
21
|
+
}
|
|
22
|
+
// Fallback: value might be an index (for object/array enum values)
|
|
23
|
+
const index = Number(value);
|
|
24
|
+
if (!isNaN(index) && index >= 0 && index < enumOptions.length) {
|
|
25
|
+
return enumOptions[index].value;
|
|
26
|
+
}
|
|
27
|
+
return emptyValue;
|
|
28
|
+
}
|
|
29
|
+
/** Decodes a string from a DOM value attribute back to a typed enum value.
|
|
30
|
+
*
|
|
31
|
+
* When `format` is `'realValue'`, does a reverse lookup: finds the enum option
|
|
32
|
+
* whose `String(value)` matches the input string and returns the original typed value.
|
|
33
|
+
* For object/array values that were encoded as indices, falls back to index resolution.
|
|
34
|
+
*
|
|
35
|
+
* When `format` is `'indexed'` (the default), uses index-based resolution via
|
|
36
|
+
* `enumOptionsValueForIndex`.
|
|
37
|
+
*
|
|
38
|
+
* @param value - The string value(s) from the DOM
|
|
39
|
+
* @param enumOptions - The available enum options
|
|
40
|
+
* @param [format='indexed'] - How the values were encoded on the DOM
|
|
41
|
+
* @param emptyValue - The value to return for empty/missing selections
|
|
42
|
+
* @returns The original typed enum value(s)
|
|
43
|
+
*/
|
|
44
|
+
export default function enumOptionValueDecoder(value, enumOptions, format = 'indexed', emptyValue) {
|
|
45
|
+
if (format !== 'realValue') {
|
|
46
|
+
return enumOptionsValueForIndex(value, enumOptions, emptyValue);
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
return value.map((v) => decodeSingle(v, enumOptions, emptyValue));
|
|
50
|
+
}
|
|
51
|
+
return decodeSingle(value, enumOptions, emptyValue);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=enumOptionValueDecoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumOptionValueDecoder.js","sourceRoot":"","sources":["../src/enumOptionValueDecoder.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,SAAS,YAAY,CACnB,KAAa,EACb,WAA6C,EAC7C,UAAoB;IAEpB,IAAI,KAAK,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAChD,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC;IACrE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,mEAAmE;IACnE,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;QAC9D,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,KAAwB,EACxB,WAA6C,EAC7C,SAA4B,SAAS,EACrC,UAAoB;IAEpB,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAC3B,OAAO,wBAAwB,CAAI,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OptionValueFormat } from './types.js';
|
|
2
|
+
/** Encodes an enum option value into a string for a DOM value attribute.
|
|
3
|
+
*
|
|
4
|
+
* When `format` is `'realValue'`, primitive values are converted via `String()`.
|
|
5
|
+
* Non-primitive values (objects, arrays) fall back to the index since
|
|
6
|
+
* `String()` would produce `"[object Object]"`.
|
|
7
|
+
*
|
|
8
|
+
* When `format` is `'indexed'` (the default), returns the index as a string.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The typed enum value
|
|
11
|
+
* @param index - The option's position in the enumOptions array
|
|
12
|
+
* @param [format='indexed'] - How to encode the value for the DOM attribute
|
|
13
|
+
* @returns The string to use as the DOM value attribute
|
|
14
|
+
*/
|
|
15
|
+
export default function enumOptionValueEncoder(value: unknown, index: number, format?: OptionValueFormat): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import isNil from 'lodash-es/isNil.js';
|
|
2
|
+
/** Encodes an enum option value into a string for a DOM value attribute.
|
|
3
|
+
*
|
|
4
|
+
* When `format` is `'realValue'`, primitive values are converted via `String()`.
|
|
5
|
+
* Non-primitive values (objects, arrays) fall back to the index since
|
|
6
|
+
* `String()` would produce `"[object Object]"`.
|
|
7
|
+
*
|
|
8
|
+
* When `format` is `'indexed'` (the default), returns the index as a string.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The typed enum value
|
|
11
|
+
* @param index - The option's position in the enumOptions array
|
|
12
|
+
* @param [format='indexed'] - How to encode the value for the DOM attribute
|
|
13
|
+
* @returns The string to use as the DOM value attribute
|
|
14
|
+
*/
|
|
15
|
+
export default function enumOptionValueEncoder(value, index, format = 'indexed') {
|
|
16
|
+
if (format !== 'realValue') {
|
|
17
|
+
return String(index);
|
|
18
|
+
}
|
|
19
|
+
if (isNil(value)) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === 'object') {
|
|
23
|
+
return String(index);
|
|
24
|
+
}
|
|
25
|
+
return String(value);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=enumOptionValueEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumOptionValueEncoder.js","sourceRoot":"","sources":["../src/enumOptionValueEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAIjC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,KAAc,EACd,KAAa,EACb,SAA4B,SAAS;IAErC,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
package/lib/getInputProps.js
CHANGED
|
@@ -36,6 +36,15 @@ export default function getInputProps(schema, defaultType, options = {}, autoDef
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
// For date/time input types, propagate formatMinimum/formatMaximum to min/max
|
|
40
|
+
if (['date', 'datetime-local', 'time', 'week', 'month'].includes(inputProps.type)) {
|
|
41
|
+
if (schema.formatMinimum !== undefined) {
|
|
42
|
+
inputProps.min = schema.formatMinimum;
|
|
43
|
+
}
|
|
44
|
+
if (schema.formatMaximum !== undefined) {
|
|
45
|
+
inputProps.max = schema.formatMaximum;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
39
48
|
if (options.autocomplete) {
|
|
40
49
|
inputProps.autoComplete = options.autocomplete;
|
|
41
50
|
}
|
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,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
|
+
{"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,8EAA8E;IAC9E,IAAI,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAClF,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACvC,UAAU,CAAC,GAAG,GAAG,MAAM,CAAC,aAAuB,CAAC;QAClD,CAAC;QACD,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACvC,UAAU,CAAC,GAAG,GAAG,MAAM,CAAC,aAAuB,CAAC;QAClD,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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OptionValueFormat } from './types.js';
|
|
2
|
+
/** Resolves the effective `optionValueFormat` for enum-backed widgets.
|
|
3
|
+
*
|
|
4
|
+
* Provides a single source of truth for the default DOM encoding format
|
|
5
|
+
* (`'indexed'`) used by `SelectWidget`, `RadioWidget`, and `CheckboxesWidget`.
|
|
6
|
+
* Widgets should call this helper once and pass the result to
|
|
7
|
+
* `enumOptionValueEncoder`, `enumOptionValueDecoder`, and `enumOptionSelectedValue`
|
|
8
|
+
* rather than reading `options.optionValueFormat` directly.
|
|
9
|
+
*
|
|
10
|
+
* @param options - The widget options (typically from the `options` prop, already
|
|
11
|
+
* resolved from `ui:options` and `ui:globalOptions`)
|
|
12
|
+
* @returns The resolved `OptionValueFormat`, defaulting to `'indexed'` when not set
|
|
13
|
+
*/
|
|
14
|
+
export default function getOptionValueFormat(options?: {
|
|
15
|
+
optionValueFormat?: OptionValueFormat;
|
|
16
|
+
}): OptionValueFormat;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Resolves the effective `optionValueFormat` for enum-backed widgets.
|
|
2
|
+
*
|
|
3
|
+
* Provides a single source of truth for the default DOM encoding format
|
|
4
|
+
* (`'indexed'`) used by `SelectWidget`, `RadioWidget`, and `CheckboxesWidget`.
|
|
5
|
+
* Widgets should call this helper once and pass the result to
|
|
6
|
+
* `enumOptionValueEncoder`, `enumOptionValueDecoder`, and `enumOptionSelectedValue`
|
|
7
|
+
* rather than reading `options.optionValueFormat` directly.
|
|
8
|
+
*
|
|
9
|
+
* @param options - The widget options (typically from the `options` prop, already
|
|
10
|
+
* resolved from `ui:options` and `ui:globalOptions`)
|
|
11
|
+
* @returns The resolved `OptionValueFormat`, defaulting to `'indexed'` when not set
|
|
12
|
+
*/
|
|
13
|
+
export default function getOptionValueFormat(options) {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = options === null || options === void 0 ? void 0 : options.optionValueFormat) !== null && _a !== void 0 ? _a : 'indexed';
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=getOptionValueFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOptionValueFormat.js","sourceRoot":"","sources":["../src/getOptionValueFormat.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,OAAmD;;IAC9F,OAAO,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,mCAAI,SAAS,CAAC;AACjD,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ import dateRangeOptions from './dateRangeOptions.js';
|
|
|
8
8
|
import deepEquals from './deepEquals.js';
|
|
9
9
|
import shallowEquals from './shallowEquals.js';
|
|
10
10
|
import englishStringTranslator from './englishStringTranslator.js';
|
|
11
|
+
import enumOptionSelectedValue from './enumOptionSelectedValue.js';
|
|
12
|
+
import enumOptionValueDecoder from './enumOptionValueDecoder.js';
|
|
13
|
+
import enumOptionValueEncoder from './enumOptionValueEncoder.js';
|
|
11
14
|
import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
|
|
12
15
|
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
13
16
|
import enumOptionsIsSelected from './enumOptionsIsSelected.js';
|
|
@@ -20,6 +23,7 @@ import getDateElementProps, { DateElementFormat, DateElementProp } from './getDa
|
|
|
20
23
|
import getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema.js';
|
|
21
24
|
import getInputProps from './getInputProps.js';
|
|
22
25
|
import getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator.js';
|
|
26
|
+
import getOptionValueFormat from './getOptionValueFormat.js';
|
|
23
27
|
import getSchemaType from './getSchemaType.js';
|
|
24
28
|
import getSubmitButtonOptions from './getSubmitButtonOptions.js';
|
|
25
29
|
import getTemplate from './getTemplate.js';
|
|
@@ -43,12 +47,13 @@ import mergeDefaultsWithFormData from './mergeDefaultsWithFormData.js';
|
|
|
43
47
|
import mergeObjects from './mergeObjects.js';
|
|
44
48
|
import mergeSchemas from './mergeSchemas.js';
|
|
45
49
|
import optionsList from './optionsList.js';
|
|
50
|
+
import removeOptionalEmptyObjects from './removeOptionalEmptyObjects.js';
|
|
46
51
|
import orderProperties from './orderProperties.js';
|
|
47
52
|
import pad from './pad.js';
|
|
48
53
|
import parseDateString from './parseDateString.js';
|
|
49
54
|
import rangeSpec from './rangeSpec.js';
|
|
50
55
|
import replaceStringParameters from './replaceStringParameters.js';
|
|
51
|
-
import resolveUiSchema
|
|
56
|
+
import resolveUiSchema from './resolveUiSchema.js';
|
|
52
57
|
import schemaRequiresTrueValue from './schemaRequiresTrueValue.js';
|
|
53
58
|
import shouldRender, { ComponentUpdateStrategy } from './shouldRender.js';
|
|
54
59
|
import shouldRenderOptionalField from './shouldRenderOptionalField.js';
|
|
@@ -71,4 +76,4 @@ export * from './constants.js';
|
|
|
71
76
|
export * from './parser/index.js';
|
|
72
77
|
export * from './schema/index.js';
|
|
73
78
|
export type { ComponentUpdateStrategy, DateElementFormat, DateElementProp, DateElementProps, FileInfoType, UseAltDateWidgetResult, UseFileWidgetPropsResult, };
|
|
74
|
-
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElement, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isFormDataAvailable, isObject, isRootSchema, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionalControlsId, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, resolveUiSchema,
|
|
79
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElement, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionSelectedValue, enumOptionValueDecoder, enumOptionValueEncoder, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getOptionValueFormat, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isFormDataAvailable, isObject, isRootSchema, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionalControlsId, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, removeOptionalEmptyObjects, replaceStringParameters, resolveUiSchema, schemaRequiresTrueValue, shallowEquals, shouldRender, shouldRenderOptionalField, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, toFieldPathId, unwrapErrorHandler, useAltDateWidgetProps, useDeepCompareMemo, useFileWidgetProps, utcToLocal, validationDataMerge, withIdRefPrefix, bracketNameGenerator, dotNotationNameGenerator, };
|