@rjsf/utils 5.24.0 → 5.24.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 +33 -25
- package/dist/index.js.map +3 -3
- package/dist/utils.esm.js +33 -25
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +36 -28
- package/lib/deepEquals.d.ts +3 -3
- package/lib/deepEquals.js +15 -13
- package/lib/deepEquals.js.map +1 -1
- package/lib/getChangedFields.d.ts +3 -3
- package/lib/getChangedFields.js +3 -3
- package/lib/getInputProps.js +3 -0
- package/lib/getInputProps.js.map +1 -1
- package/lib/mergeDefaultsWithFormData.js +2 -1
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +2 -0
- package/package.json +3 -2
- package/src/deepEquals.ts +16 -13
- package/src/getChangedFields.ts +3 -3
- package/src/getInputProps.ts +4 -0
- package/src/mergeDefaultsWithFormData.ts +2 -1
- package/src/types.ts +2 -0
package/dist/utils.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject4, global.
|
|
5
|
-
})(this, (function (exports, isPlainObject4,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('fast-equals'), require('lodash/get'), require('lodash/isEmpty'), require('jsonpointer'), require('lodash/omit'), require('lodash/has'), require('lodash/isNumber'), require('lodash/isObject'), require('lodash/isString'), require('lodash/reduce'), require('lodash/times'), require('lodash/set'), require('lodash/transform'), require('lodash/merge'), require('lodash/flattenDeep'), require('lodash/uniq'), require('json-schema-merge-allof'), require('lodash/union'), require('lodash/isNil'), require('lodash/cloneDeep'), require('lodash/setWith'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/keys'), require('lodash/pickBy'), require('lodash/difference'), require('lodash/forEach')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'fast-equals', 'lodash/get', 'lodash/isEmpty', 'jsonpointer', 'lodash/omit', 'lodash/has', 'lodash/isNumber', 'lodash/isObject', 'lodash/isString', 'lodash/reduce', 'lodash/times', 'lodash/set', 'lodash/transform', 'lodash/merge', 'lodash/flattenDeep', 'lodash/uniq', 'json-schema-merge-allof', 'lodash/union', 'lodash/isNil', 'lodash/cloneDeep', 'lodash/setWith', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/keys', 'lodash/pickBy', 'lodash/difference', 'lodash/forEach'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject4, global.fastEquals, global.get8, global.isEmpty, global.jsonpointer, global.omit, global.has3, global.isNumber, global.isObject2, global.isString, global.reduce, global.times, global.set3, global.transform, global.merge, global.flattenDeep, global.uniq, global.mergeAllOf, global.union, global.isNil, global.cloneDeep, global.setWith, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.keys, global.pickBy, global.difference, global.forEach));
|
|
5
|
+
})(this, (function (exports, isPlainObject4, fastEquals, get8, isEmpty, jsonpointer, omit, has3, isNumber, isObject2, isString, reduce, times, set3, transform, merge, flattenDeep, uniq, mergeAllOf, union, isNil, cloneDeep, setWith, react, ReactIs, jsxRuntime, toPath, keys, pickBy, difference, forEach) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/isObject.ts
|
|
8
8
|
function isObject(thing) {
|
|
@@ -132,14 +132,19 @@
|
|
|
132
132
|
}
|
|
133
133
|
return handler;
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
var deepEquals = fastEquals.createCustomEqual({
|
|
136
|
+
createCustomConfig: () => ({
|
|
137
|
+
// Assume all functions are equivalent
|
|
138
|
+
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255
|
|
139
|
+
//
|
|
140
|
+
// Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function.
|
|
141
|
+
// https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99
|
|
142
|
+
areFunctionsEqual(_a, b) {
|
|
143
|
+
return typeof b === "function";
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
var deepEquals_default = deepEquals;
|
|
143
148
|
function splitKeyElementFromObject(key, object) {
|
|
144
149
|
const value = object[key];
|
|
145
150
|
const remaining = omit(object, [key]);
|
|
@@ -517,7 +522,7 @@
|
|
|
517
522
|
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
|
|
518
523
|
};
|
|
519
524
|
}
|
|
520
|
-
return
|
|
525
|
+
return deepEquals_default(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
521
526
|
}
|
|
522
527
|
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
|
|
523
528
|
const schema = {
|
|
@@ -923,7 +928,7 @@
|
|
|
923
928
|
const overrideArray = overrideFormDataWithDefaults ? defaultsArray : formData;
|
|
924
929
|
const overrideOppositeArray = overrideFormDataWithDefaults ? formData : defaultsArray;
|
|
925
930
|
const mapped = overrideArray.map((value, idx) => {
|
|
926
|
-
if (overrideOppositeArray[idx]) {
|
|
931
|
+
if (overrideOppositeArray[idx] !== void 0) {
|
|
927
932
|
return mergeDefaultsWithFormData(
|
|
928
933
|
defaultsArray[idx],
|
|
929
934
|
formData[idx],
|
|
@@ -1259,7 +1264,7 @@
|
|
|
1259
1264
|
let validFormData = formData;
|
|
1260
1265
|
if (isSelectField) {
|
|
1261
1266
|
const getOptionsList = optionsList(schema);
|
|
1262
|
-
const isValid = getOptionsList?.some((option) =>
|
|
1267
|
+
const isValid = getOptionsList?.some((option) => deepEquals_default(option.value, formData));
|
|
1263
1268
|
validFormData = isValid ? formData : void 0;
|
|
1264
1269
|
}
|
|
1265
1270
|
const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
|
|
@@ -1663,7 +1668,7 @@
|
|
|
1663
1668
|
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1664
1669
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1665
1670
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1666
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1671
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
|
|
1667
1672
|
if (sameSchemaIndex === -1) {
|
|
1668
1673
|
return toIdSchemaInternal(
|
|
1669
1674
|
validator,
|
|
@@ -1730,7 +1735,7 @@
|
|
|
1730
1735
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1731
1736
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1732
1737
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1733
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1738
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
|
|
1734
1739
|
if (sameSchemaIndex === -1) {
|
|
1735
1740
|
return toPathSchemaInternal(
|
|
1736
1741
|
validator,
|
|
@@ -1874,7 +1879,7 @@
|
|
|
1874
1879
|
if (!validator || !rootSchema) {
|
|
1875
1880
|
return false;
|
|
1876
1881
|
}
|
|
1877
|
-
return this.validator !== validator || !
|
|
1882
|
+
return this.validator !== validator || !deepEquals_default(this.rootSchema, rootSchema) || !deepEquals_default(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
|
|
1878
1883
|
}
|
|
1879
1884
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
1880
1885
|
* computed to have defaults provided in the `schema`.
|
|
@@ -2182,17 +2187,17 @@
|
|
|
2182
2187
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2183
2188
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2184
2189
|
if (Array.isArray(selected)) {
|
|
2185
|
-
return selected.filter((v) => !
|
|
2190
|
+
return selected.filter((v) => !deepEquals_default(v, value));
|
|
2186
2191
|
}
|
|
2187
|
-
return
|
|
2192
|
+
return deepEquals_default(value, selected) ? void 0 : selected;
|
|
2188
2193
|
}
|
|
2189
2194
|
|
|
2190
2195
|
// src/enumOptionsIsSelected.ts
|
|
2191
2196
|
function enumOptionsIsSelected(value, selected) {
|
|
2192
2197
|
if (Array.isArray(selected)) {
|
|
2193
|
-
return selected.some((sel) =>
|
|
2198
|
+
return selected.some((sel) => deepEquals_default(sel, value));
|
|
2194
2199
|
}
|
|
2195
|
-
return
|
|
2200
|
+
return deepEquals_default(selected, value);
|
|
2196
2201
|
}
|
|
2197
2202
|
|
|
2198
2203
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -2372,6 +2377,9 @@
|
|
|
2372
2377
|
if (options.autocomplete) {
|
|
2373
2378
|
inputProps.autoComplete = options.autocomplete;
|
|
2374
2379
|
}
|
|
2380
|
+
if (options.accept) {
|
|
2381
|
+
inputProps.accept = options.accept;
|
|
2382
|
+
}
|
|
2375
2383
|
return inputProps;
|
|
2376
2384
|
}
|
|
2377
2385
|
|
|
@@ -2637,7 +2645,7 @@
|
|
|
2637
2645
|
// src/shouldRender.ts
|
|
2638
2646
|
function shouldRender(component, nextProps, nextState) {
|
|
2639
2647
|
const { props, state } = component;
|
|
2640
|
-
return !
|
|
2648
|
+
return !deepEquals_default(props, nextProps) || !deepEquals_default(state, nextState);
|
|
2641
2649
|
}
|
|
2642
2650
|
|
|
2643
2651
|
// src/toDateString.ts
|
|
@@ -2773,7 +2781,7 @@
|
|
|
2773
2781
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
2774
2782
|
return keys(b);
|
|
2775
2783
|
} else {
|
|
2776
|
-
const unequalFields = keys(pickBy(a, (value, key) => !
|
|
2784
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value, get8(b, key))));
|
|
2777
2785
|
const diffFields = difference(keys(b), keys(a));
|
|
2778
2786
|
return [...unequalFields, ...diffFields];
|
|
2779
2787
|
}
|
|
@@ -2842,7 +2850,7 @@
|
|
|
2842
2850
|
const existing = this.schemaMap[key];
|
|
2843
2851
|
if (!existing) {
|
|
2844
2852
|
this.schemaMap[key] = identifiedSchema;
|
|
2845
|
-
} else if (!
|
|
2853
|
+
} else if (!deepEquals_default(existing, identifiedSchema)) {
|
|
2846
2854
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
2847
2855
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
2848
2856
|
throw new Error(
|
|
@@ -2864,7 +2872,7 @@
|
|
|
2864
2872
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
2865
2873
|
*/
|
|
2866
2874
|
isValid(schema, _formData, rootSchema) {
|
|
2867
|
-
if (!
|
|
2875
|
+
if (!deepEquals_default(rootSchema, this.rootSchema)) {
|
|
2868
2876
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
2869
2877
|
}
|
|
2870
2878
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -2904,7 +2912,7 @@
|
|
|
2904
2912
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
2905
2913
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
2906
2914
|
schemas.forEach((schema2) => {
|
|
2907
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
2915
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals_default(item, schema2));
|
|
2908
2916
|
if (sameSchemaIndex === -1) {
|
|
2909
2917
|
recurseList.push(schema2);
|
|
2910
2918
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|
|
@@ -2965,7 +2973,7 @@
|
|
|
2965
2973
|
exports.createSchemaUtils = createSchemaUtils;
|
|
2966
2974
|
exports.dataURItoBlob = dataURItoBlob;
|
|
2967
2975
|
exports.dateRangeOptions = dateRangeOptions;
|
|
2968
|
-
exports.deepEquals =
|
|
2976
|
+
exports.deepEquals = deepEquals_default;
|
|
2969
2977
|
exports.descriptionId = descriptionId;
|
|
2970
2978
|
exports.englishStringTranslator = englishStringTranslator;
|
|
2971
2979
|
exports.enumOptionsDeselectValue = enumOptionsDeselectValue;
|
package/lib/deepEquals.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** Implements a deep equals using the `
|
|
2
|
-
* assumes all functions are equivalent.
|
|
1
|
+
/** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent.
|
|
3
2
|
*
|
|
4
3
|
* @param a - The first element to compare
|
|
5
4
|
* @param b - The second element to compare
|
|
6
5
|
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
7
6
|
*/
|
|
8
|
-
|
|
7
|
+
declare const deepEquals: <A, B>(a: A, b: B) => boolean;
|
|
8
|
+
export default deepEquals;
|
package/lib/deepEquals.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
/** Implements a deep equals using the `
|
|
3
|
-
* assumes all functions are equivalent.
|
|
1
|
+
import { createCustomEqual } from 'fast-equals';
|
|
2
|
+
/** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent.
|
|
4
3
|
*
|
|
5
4
|
* @param a - The first element to compare
|
|
6
5
|
* @param b - The second element to compare
|
|
7
6
|
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
8
|
+
const deepEquals = createCustomEqual({
|
|
9
|
+
createCustomConfig: () => ({
|
|
10
|
+
// Assume all functions are equivalent
|
|
11
|
+
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255
|
|
12
|
+
//
|
|
13
|
+
// Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function.
|
|
14
|
+
// https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99
|
|
15
|
+
areFunctionsEqual(_a, b) {
|
|
16
|
+
return typeof b === 'function';
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
export default deepEquals;
|
|
19
21
|
//# sourceMappingURL=deepEquals.js.map
|
package/lib/deepEquals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepEquals.js","sourceRoot":"","sources":["../src/deepEquals.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"deepEquals.js","sourceRoot":"","sources":["../src/deepEquals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,iBAAiB,CAAC;IACnC,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC;QACzB,sCAAsC;QACtC,oEAAoE;QACpE,EAAE;QACF,iHAAiH;QACjH,kHAAkH;QAClH,iBAAiB,CAAC,EAAE,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC;QACjC,CAAC;KACF,CAAC;CACH,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* with the corresponding field value in object `b`. If the values are different, the field name will
|
|
5
5
|
* be included in the returned array.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
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
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* const a = { name: 'John', age: 30 };
|
package/lib/getChangedFields.js
CHANGED
|
@@ -10,9 +10,9 @@ import deepEquals from './deepEquals';
|
|
|
10
10
|
* with the corresponding field value in object `b`. If the values are different, the field name will
|
|
11
11
|
* be included in the returned array.
|
|
12
12
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @returns
|
|
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
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* const a = { name: 'John', age: 30 };
|
package/lib/getInputProps.js
CHANGED
|
@@ -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,O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,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;QACrB,UAAU,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC;KACrC;SAAM,IAAI,CAAC,WAAW,EAAE;QACvB,2EAA2E;QAC3E,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC5B,UAAU,CAAC,IAAI,GAAG,QAAQ,CAAC;YAC3B,uFAAuF;YACvF,IAAI,kBAAkB,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE;gBACvD,qEAAqE;gBACrE,2BAA2B;gBAC3B,UAAU,CAAC,IAAI,GAAG,KAAK,CAAC;aACzB;SACF;aAAM,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE;YACpC,UAAU,CAAC,IAAI,GAAG,QAAQ,CAAC;YAC3B,6CAA6C;YAC7C,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE;gBACjC,8EAA8E;gBAC9E,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;aACrB;SACF;KACF;IAED,IAAI,OAAO,CAAC,YAAY,EAAE;QACxB,UAAU,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;KAChD;IAED,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAgB,CAAC;KAC9C;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -30,7 +30,8 @@ export default function mergeDefaultsWithFormData(defaults, formData, mergeExtra
|
|
|
30
30
|
const overrideArray = overrideFormDataWithDefaults ? defaultsArray : formData;
|
|
31
31
|
const overrideOppositeArray = overrideFormDataWithDefaults ? formData : defaultsArray;
|
|
32
32
|
const mapped = overrideArray.map((value, idx) => {
|
|
33
|
-
|
|
33
|
+
// We want to explicitly make sure that the value is NOT undefined since null, 0 and empty space are valid values
|
|
34
|
+
if (overrideOppositeArray[idx] !== undefined) {
|
|
34
35
|
return mergeDefaultsWithFormData(defaultsArray[idx], formData[idx], mergeExtraArrayDefaults, defaultSupercedesUndefined, overrideFormDataWithDefaults);
|
|
35
36
|
}
|
|
36
37
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeDefaultsWithFormData.js","sourceRoot":"","sources":["../src/mergeDefaultsWithFormData.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,QAAY,EACZ,QAAY,EACZ,uBAAuB,GAAG,KAAK,EAC/B,0BAA0B,GAAG,KAAK,EAClC,4BAA4B,GAAG,KAAK;IAEpC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAE9D,8FAA8F;QAC9F,MAAM,aAAa,GAAG,4BAA4B,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC9E,MAAM,qBAAqB,GAAG,4BAA4B,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC;QAEtF,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC9C,IAAI,qBAAqB,CAAC,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"mergeDefaultsWithFormData.js","sourceRoot":"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