@react-typed-forms/schemas 16.0.0 → 16.0.1
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/lib/index.cjs +26 -5
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +24 -8
- package/lib/index.js.map +1 -1
- package/lib/util.d.ts +1 -0
- package/package.json +1 -1
- package/src/util.ts +22 -2
package/lib/index.cjs
CHANGED
|
@@ -35,10 +35,9 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
35
35
|
* @returns The record with default values applied.
|
|
36
36
|
*/
|
|
37
37
|
function applyDefaultValues(v, fields, doneSet) {
|
|
38
|
-
var _doneSet;
|
|
39
38
|
if (!v) return defaultValueForFields(fields);
|
|
40
39
|
if (doneSet && doneSet.has(v)) return v;
|
|
41
|
-
|
|
40
|
+
doneSet != null ? doneSet : doneSet = new Set();
|
|
42
41
|
doneSet.add(v);
|
|
43
42
|
var applyValue = fields.filter(function (x) {
|
|
44
43
|
return formsCore.isCompoundField(x) || !(x.field in v);
|
|
@@ -334,8 +333,7 @@ function addMissingControlsForSchema(schema, controls, warning) {
|
|
|
334
333
|
parent: parentNode
|
|
335
334
|
};
|
|
336
335
|
entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(function (x) {
|
|
337
|
-
|
|
338
|
-
return toControlAndSchema(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema, entry, dontRegister);
|
|
336
|
+
return toControlAndSchema(x, dataSchema != null ? dataSchema : parentSchema, entry, dontRegister);
|
|
339
337
|
})) != null ? _c$children$map : [];
|
|
340
338
|
if (!dontRegister && c.id) controlMap[c.id] = entry;
|
|
341
339
|
if (dataSchema) {
|
|
@@ -631,6 +629,9 @@ function getNullToggler(c) {
|
|
|
631
629
|
c.value = currentNotNull ? lastDefined.current.value : null;
|
|
632
630
|
c.disabled = !currentNotNull;
|
|
633
631
|
}, core.ControlChange.Value);
|
|
632
|
+
c.subscribe(function () {
|
|
633
|
+
notNull.value = c.current.value != null;
|
|
634
|
+
}, core.ControlChange.Value);
|
|
634
635
|
return notNull;
|
|
635
636
|
function disableIfNotEditing() {
|
|
636
637
|
notNull.disabled = isEditing.current.value === false;
|
|
@@ -670,6 +671,22 @@ function getAllValues(control) {
|
|
|
670
671
|
return core.newControl([control.value]);
|
|
671
672
|
});
|
|
672
673
|
}
|
|
674
|
+
function clearMultiValues(dataNode) {
|
|
675
|
+
var c = dataNode.control;
|
|
676
|
+
var sf = dataNode.schema.field;
|
|
677
|
+
if (sf.collection) {
|
|
678
|
+
return;
|
|
679
|
+
} else if (formsCore.isCompoundField(sf)) {
|
|
680
|
+
dataNode.schema.getChildNodes().forEach(function (c) {
|
|
681
|
+
clearMultiValues(dataNode.getChild(c));
|
|
682
|
+
});
|
|
683
|
+
} else {
|
|
684
|
+
var allValues = getAllValues(c);
|
|
685
|
+
allValues.setValue(function (x) {
|
|
686
|
+
return [c.current.value];
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
}
|
|
673
690
|
function applyValues(dataNode, value) {
|
|
674
691
|
var c = dataNode.control;
|
|
675
692
|
var sf = dataNode.schema.field;
|
|
@@ -692,7 +709,10 @@ function applyValues(dataNode, value) {
|
|
|
692
709
|
}
|
|
693
710
|
function collectDifferences(dataNode, values) {
|
|
694
711
|
values.forEach(function (v, i) {
|
|
695
|
-
if (i == 0)
|
|
712
|
+
if (i == 0) {
|
|
713
|
+
dataNode.control.setInitialValue(v);
|
|
714
|
+
clearMultiValues(dataNode);
|
|
715
|
+
} else applyValues(dataNode, v);
|
|
696
716
|
});
|
|
697
717
|
var allEdits = [];
|
|
698
718
|
resetMultiValues(dataNode);
|
|
@@ -1815,6 +1835,7 @@ exports.applyValues = applyValues;
|
|
|
1815
1835
|
exports.autocompleteOptions = autocompleteOptions;
|
|
1816
1836
|
exports.checkListOptions = checkListOptions;
|
|
1817
1837
|
exports.cleanDataForSchema = cleanDataForSchema;
|
|
1838
|
+
exports.clearMultiValues = clearMultiValues;
|
|
1818
1839
|
exports.coerceToString = coerceToString;
|
|
1819
1840
|
exports.collectDifferences = collectDifferences;
|
|
1820
1841
|
exports.compoundControl = compoundControl;
|