@react-typed-forms/schemas 16.0.0 → 16.0.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/lib/index.cjs +42 -5
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +32 -6
- package/lib/index.js.map +1 -1
- package/lib/util.d.ts +1 -0
- package/package.json +2 -2
- package/src/RenderForm.tsx +15 -2
- package/src/util.ts +22 -2
package/lib/index.js
CHANGED
|
@@ -597,6 +597,9 @@ function getNullToggler(c) {
|
|
|
597
597
|
c.value = currentNotNull ? lastDefined.current.value : null;
|
|
598
598
|
c.disabled = !currentNotNull;
|
|
599
599
|
}, ControlChange.Value);
|
|
600
|
+
c.subscribe(() => {
|
|
601
|
+
notNull.value = c.current.value != null;
|
|
602
|
+
}, ControlChange.Value);
|
|
600
603
|
return notNull;
|
|
601
604
|
function disableIfNotEditing() {
|
|
602
605
|
notNull.disabled = isEditing.current.value === false;
|
|
@@ -632,6 +635,20 @@ function getIsEditing(control) {
|
|
|
632
635
|
function getAllValues(control) {
|
|
633
636
|
return ensureMetaValue(control, "$allValues", () => newControl([control.value]));
|
|
634
637
|
}
|
|
638
|
+
function clearMultiValues(dataNode) {
|
|
639
|
+
const c = dataNode.control;
|
|
640
|
+
const sf = dataNode.schema.field;
|
|
641
|
+
if (sf.collection) {
|
|
642
|
+
return;
|
|
643
|
+
} else if (isCompoundField(sf)) {
|
|
644
|
+
dataNode.schema.getChildNodes().forEach(c => {
|
|
645
|
+
clearMultiValues(dataNode.getChild(c));
|
|
646
|
+
});
|
|
647
|
+
} else {
|
|
648
|
+
const allValues = getAllValues(c);
|
|
649
|
+
allValues.setValue(x => [c.current.value]);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
635
652
|
function applyValues(dataNode, value) {
|
|
636
653
|
const c = dataNode.control;
|
|
637
654
|
const sf = dataNode.schema.field;
|
|
@@ -650,7 +667,10 @@ function applyValues(dataNode, value) {
|
|
|
650
667
|
}
|
|
651
668
|
function collectDifferences(dataNode, values) {
|
|
652
669
|
values.forEach((v, i) => {
|
|
653
|
-
if (i == 0)
|
|
670
|
+
if (i == 0) {
|
|
671
|
+
dataNode.control.setInitialValue(v);
|
|
672
|
+
clearMultiValues(dataNode);
|
|
673
|
+
} else applyValues(dataNode, v);
|
|
654
674
|
});
|
|
655
675
|
const allEdits = [];
|
|
656
676
|
resetMultiValues(dataNode);
|
|
@@ -1495,7 +1515,8 @@ function RenderForm({
|
|
|
1495
1515
|
var _options$formState;
|
|
1496
1516
|
return (_options$formState = options == null ? void 0 : options.formState) != null ? _options$formState : createFormState(schemaInterface);
|
|
1497
1517
|
});
|
|
1498
|
-
const
|
|
1518
|
+
const effects = [];
|
|
1519
|
+
const state = formState.getControlState(data, form, options, cb => effects.push(cb));
|
|
1499
1520
|
useEffect(() => {
|
|
1500
1521
|
if (!(options != null && options.formState)) {
|
|
1501
1522
|
return () => formState.cleanup();
|
|
@@ -1581,7 +1602,7 @@ function RenderForm({
|
|
|
1581
1602
|
textClass: textClass,
|
|
1582
1603
|
getChildState(child, parent) {
|
|
1583
1604
|
var _ref3;
|
|
1584
|
-
return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions);
|
|
1605
|
+
return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions, cb => effects.push(cb));
|
|
1585
1606
|
},
|
|
1586
1607
|
runExpression: (scope, expr, returnResult) => {
|
|
1587
1608
|
if (expr != null && expr.type) {
|
|
@@ -1589,7 +1610,8 @@ function RenderForm({
|
|
|
1589
1610
|
scope,
|
|
1590
1611
|
dataNode: data,
|
|
1591
1612
|
schemaInterface,
|
|
1592
|
-
returnResult
|
|
1613
|
+
returnResult,
|
|
1614
|
+
runAsync: cb => effects.push(cb)
|
|
1593
1615
|
});
|
|
1594
1616
|
}
|
|
1595
1617
|
}
|
|
@@ -1600,9 +1622,13 @@ function RenderForm({
|
|
|
1600
1622
|
style: state.layoutStyle
|
|
1601
1623
|
});
|
|
1602
1624
|
const renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
|
|
1603
|
-
|
|
1625
|
+
const rendered = renderer.renderVisibility(_extends({
|
|
1604
1626
|
visibility
|
|
1605
1627
|
}, renderedControl));
|
|
1628
|
+
useEffect(() => {
|
|
1629
|
+
effects.forEach(cb => cb());
|
|
1630
|
+
}, [effects]);
|
|
1631
|
+
return rendered;
|
|
1606
1632
|
} finally {
|
|
1607
1633
|
_effect();
|
|
1608
1634
|
}
|
|
@@ -1691,5 +1717,5 @@ function useControlRenderer(definition, fields, renderer, options = {}) {
|
|
|
1691
1717
|
}, [r]);
|
|
1692
1718
|
}
|
|
1693
1719
|
|
|
1694
|
-
export { AppendAdornmentPriority, ControlRenderer, LabelType, NewControlRenderer, RenderForm, WrapAdornmentPriority, accordionOptions, actionControl, actionHandlers, addMissingControls, addMissingControlsForSchema, adornmentOptions, appendMarkup, appendMarkupAt, applyArrayLengthRestrictions, applyDefaultForField, applyDefaultValues, applyExtensionToSchema, applyExtensionsToSchema, applyLengthRestrictions, applyValues, autocompleteOptions, checkListOptions, cleanDataForSchema, coerceToString, collectDifferences, compoundControl, controlTitle, createAction, createActionRenderer, createAdornmentRenderer, createArrayActions, createArrayRenderer, createDataRenderer, createDisplayRenderer, createFormRenderer, createGroupRenderer, createLabelRenderer, createLayoutRenderer, createVisibilityRenderer, dataControl, dateValidatorOptions, deepMerge, defaultControlForField, defaultDataProps, defaultValueForField, defaultValueForFields, displayOnlyOptions, dynamicDefaultValue, dynamicDisabled, dynamicReadonly, dynamicVisibility, elementValueForField, emptyGroupDefinition, fieldDisplayName, fieldEqExpr, fieldExpr, fieldHasTag, fieldOptionAdornment, findChildDefinition, findCompoundField, findControlsForCompound, findFieldPath, findNonDataGroups, findScalarField, getAllReferencedClasses, getAllValues, getDiffObject, getExternalEditData, getGroupClassOverrides, getIsEditing, getLastDefinedValue, getLengthRestrictions, getNullToggler, getOverrideClass, groupedControl, hasOptions, htmlDisplayControl, isAccordionAdornment, isIconAdornment, isOptionalAdornment, isSetFieldAdornment, jsonataExpr, jsonataOptions, jsonataValidatorOptions, layoutKeyForPlacement, lengthValidatorOptions, lookupChildDataContext, mergeObjects, radioButtonOptions, renderControlLayout, renderLayoutParts, renderOptionsFor, rendererClass, textDisplayControl, textfieldOptions, useControlDefinitionForSchema, useControlRenderer, useControlRendererComponent, useExpression, useUpdatedRef, validationVisitor, validatorOptions, wrapLayout, wrapMarkup, wrapMarkupAt };
|
|
1720
|
+
export { AppendAdornmentPriority, ControlRenderer, LabelType, NewControlRenderer, RenderForm, WrapAdornmentPriority, accordionOptions, actionControl, actionHandlers, addMissingControls, addMissingControlsForSchema, adornmentOptions, appendMarkup, appendMarkupAt, applyArrayLengthRestrictions, applyDefaultForField, applyDefaultValues, applyExtensionToSchema, applyExtensionsToSchema, applyLengthRestrictions, applyValues, autocompleteOptions, checkListOptions, cleanDataForSchema, clearMultiValues, coerceToString, collectDifferences, compoundControl, controlTitle, createAction, createActionRenderer, createAdornmentRenderer, createArrayActions, createArrayRenderer, createDataRenderer, createDisplayRenderer, createFormRenderer, createGroupRenderer, createLabelRenderer, createLayoutRenderer, createVisibilityRenderer, dataControl, dateValidatorOptions, deepMerge, defaultControlForField, defaultDataProps, defaultValueForField, defaultValueForFields, displayOnlyOptions, dynamicDefaultValue, dynamicDisabled, dynamicReadonly, dynamicVisibility, elementValueForField, emptyGroupDefinition, fieldDisplayName, fieldEqExpr, fieldExpr, fieldHasTag, fieldOptionAdornment, findChildDefinition, findCompoundField, findControlsForCompound, findFieldPath, findNonDataGroups, findScalarField, getAllReferencedClasses, getAllValues, getDiffObject, getExternalEditData, getGroupClassOverrides, getIsEditing, getLastDefinedValue, getLengthRestrictions, getNullToggler, getOverrideClass, groupedControl, hasOptions, htmlDisplayControl, isAccordionAdornment, isIconAdornment, isOptionalAdornment, isSetFieldAdornment, jsonataExpr, jsonataOptions, jsonataValidatorOptions, layoutKeyForPlacement, lengthValidatorOptions, lookupChildDataContext, mergeObjects, radioButtonOptions, renderControlLayout, renderLayoutParts, renderOptionsFor, rendererClass, textDisplayControl, textfieldOptions, useControlDefinitionForSchema, useControlRenderer, useControlRendererComponent, useExpression, useUpdatedRef, validationVisitor, validatorOptions, wrapLayout, wrapMarkup, wrapMarkupAt };
|
|
1695
1721
|
//# sourceMappingURL=index.js.map
|