@react-typed-forms/schemas 16.2.2 → 17.0.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/FORM_EXTENSIONS_GUIDE.md +781 -0
- package/lib/RenderForm.d.ts +22 -5
- package/lib/controlBuilder.d.ts +4 -47
- package/lib/controlRender.d.ts +49 -24
- package/lib/index.cjs +310 -332
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +270 -272
- package/lib/index.js.map +1 -1
- package/lib/renderer/elementSelected.d.ts +8 -0
- package/lib/renderers.d.ts +6 -2
- package/lib/types.d.ts +10 -5
- package/lib/util.d.ts +3 -2
- package/package.json +5 -5
- package/src/RenderForm.tsx +130 -64
- package/src/controlBuilder.ts +6 -193
- package/src/controlRender.tsx +127 -81
- package/src/createFormRenderer.tsx +52 -19
- package/src/index.ts +1 -0
- package/src/renderer/elementSelected.ts +48 -0
- package/src/renderers.tsx +8 -1
- package/src/types.ts +15 -5
- package/src/util.ts +13 -1
package/lib/index.cjs
CHANGED
|
@@ -21,7 +21,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
21
21
|
if (null == r) return {};
|
|
22
22
|
var t = {};
|
|
23
23
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
24
|
-
if (e.
|
|
24
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
25
25
|
t[n] = r[n];
|
|
26
26
|
}
|
|
27
27
|
return t;
|
|
@@ -772,137 +772,19 @@ function useExpression(defaultValue, runExpression, expression, coerce, bindings
|
|
|
772
772
|
}, value);
|
|
773
773
|
return value;
|
|
774
774
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
function
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
type: type
|
|
787
|
-
}, o);
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
function adornmentOptions(type) {
|
|
791
|
-
return function (o) {
|
|
792
|
-
return _extends({
|
|
793
|
-
type: type
|
|
794
|
-
}, o);
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
function renderOptionsFor(type) {
|
|
798
|
-
return function (o) {
|
|
799
|
-
return {
|
|
800
|
-
renderOptions: _extends({
|
|
801
|
-
type: type
|
|
802
|
-
}, o)
|
|
803
|
-
};
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
var autocompleteOptions = renderOptionsFor(formsCore.DataRenderType.Autocomplete);
|
|
807
|
-
var checkListOptions = renderOptionsFor(formsCore.DataRenderType.CheckList);
|
|
808
|
-
var radioButtonOptions = renderOptionsFor(formsCore.DataRenderType.Radio);
|
|
809
|
-
var lengthValidatorOptions = validatorOptions(formsCore.ValidatorType.Length);
|
|
810
|
-
var jsonataValidatorOptions = validatorOptions(formsCore.ValidatorType.Jsonata);
|
|
811
|
-
var dateValidatorOptions = validatorOptions(formsCore.ValidatorType.Date);
|
|
812
|
-
var accordionOptions = adornmentOptions(formsCore.ControlAdornmentType.Accordion);
|
|
813
|
-
var textfieldOptions = renderOptionsFor(formsCore.DataRenderType.Textfield);
|
|
814
|
-
var displayOnlyOptions = renderOptionsFor(formsCore.DataRenderType.DisplayOnly);
|
|
815
|
-
var jsonataOptions = renderOptionsFor(formsCore.DataRenderType.Jsonata);
|
|
816
|
-
function textDisplayControl(text, options) {
|
|
817
|
-
return _extends({
|
|
818
|
-
type: formsCore.ControlDefinitionType.Display,
|
|
819
|
-
displayData: {
|
|
820
|
-
type: formsCore.DisplayDataType.Text,
|
|
821
|
-
text: text
|
|
822
|
-
}
|
|
823
|
-
}, options);
|
|
824
|
-
}
|
|
825
|
-
function htmlDisplayControl(html, options) {
|
|
826
|
-
return _extends({
|
|
827
|
-
type: formsCore.ControlDefinitionType.Display,
|
|
828
|
-
displayData: {
|
|
829
|
-
type: formsCore.DisplayDataType.Html,
|
|
830
|
-
html: html
|
|
831
|
-
}
|
|
832
|
-
}, options);
|
|
833
|
-
}
|
|
834
|
-
function dynamicDefaultValue(expr) {
|
|
835
|
-
return {
|
|
836
|
-
type: formsCore.DynamicPropertyType.DefaultValue,
|
|
837
|
-
expr: expr
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
function dynamicReadonly(expr) {
|
|
841
|
-
return {
|
|
842
|
-
type: formsCore.DynamicPropertyType.Readonly,
|
|
843
|
-
expr: expr
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
function dynamicVisibility(expr) {
|
|
847
|
-
return {
|
|
848
|
-
type: formsCore.DynamicPropertyType.Visible,
|
|
849
|
-
expr: expr
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
function dynamicDisabled(expr) {
|
|
853
|
-
return {
|
|
854
|
-
type: formsCore.DynamicPropertyType.Disabled,
|
|
855
|
-
expr: expr
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
function fieldExpr(field) {
|
|
859
|
-
return {
|
|
860
|
-
type: formsCore.ExpressionType.Data,
|
|
861
|
-
field: field
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
function fieldEqExpr(field, value) {
|
|
865
|
-
return {
|
|
866
|
-
type: formsCore.ExpressionType.DataMatch,
|
|
867
|
-
field: field,
|
|
868
|
-
value: value
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
function jsonataExpr(expression) {
|
|
872
|
-
return {
|
|
873
|
-
type: formsCore.ExpressionType.Jsonata,
|
|
874
|
-
expression: expression
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
function groupedControl(children, title, options) {
|
|
878
|
-
return _extends({
|
|
879
|
-
type: formsCore.ControlDefinitionType.Group,
|
|
880
|
-
children: children,
|
|
881
|
-
title: title,
|
|
882
|
-
groupOptions: {
|
|
883
|
-
type: "Standard",
|
|
884
|
-
hideTitle: !title
|
|
885
|
-
}
|
|
886
|
-
}, options);
|
|
887
|
-
}
|
|
888
|
-
function compoundControl(field, title, children, options) {
|
|
889
|
-
return _extends({
|
|
890
|
-
type: formsCore.ControlDefinitionType.Data,
|
|
891
|
-
field: field,
|
|
892
|
-
children: children,
|
|
893
|
-
title: title,
|
|
894
|
-
renderOptions: {
|
|
895
|
-
type: "Standard"
|
|
896
|
-
}
|
|
897
|
-
}, options);
|
|
898
|
-
}
|
|
899
|
-
function actionControl(actionText, actionId, options) {
|
|
900
|
-
return _extends({
|
|
901
|
-
type: formsCore.ControlDefinitionType.Action,
|
|
902
|
-
title: actionText,
|
|
903
|
-
actionId: actionId
|
|
904
|
-
}, options);
|
|
775
|
+
function setIncluded(array, elem, included) {
|
|
776
|
+
var already = array.includes(elem);
|
|
777
|
+
if (included === already) {
|
|
778
|
+
return array;
|
|
779
|
+
}
|
|
780
|
+
if (included) {
|
|
781
|
+
return [].concat(array, [elem]);
|
|
782
|
+
}
|
|
783
|
+
return array.filter(function (e) {
|
|
784
|
+
return e !== elem;
|
|
785
|
+
});
|
|
905
786
|
}
|
|
787
|
+
|
|
906
788
|
function createAction(actionId, onClick, actionText, options) {
|
|
907
789
|
return _extends({
|
|
908
790
|
actionId: actionId,
|
|
@@ -910,17 +792,9 @@ function createAction(actionId, onClick, actionText, options) {
|
|
|
910
792
|
actionText: actionText != null ? actionText : actionId
|
|
911
793
|
}, options);
|
|
912
794
|
}
|
|
913
|
-
var emptyGroupDefinition = {
|
|
914
|
-
type: formsCore.ControlDefinitionType.Group,
|
|
915
|
-
children: [],
|
|
916
|
-
groupOptions: {
|
|
917
|
-
type: formsCore.GroupRenderType.Standard,
|
|
918
|
-
hideTitle: true
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
795
|
function useControlDefinitionForSchema(sf, definition) {
|
|
922
796
|
if (definition === void 0) {
|
|
923
|
-
definition = emptyGroupDefinition;
|
|
797
|
+
definition = formsCore.emptyGroupDefinition;
|
|
924
798
|
}
|
|
925
799
|
return react.useMemo(function () {
|
|
926
800
|
var _definition$children;
|
|
@@ -954,7 +828,7 @@ function createIconLibraryExtension(name, value) {
|
|
|
954
828
|
};
|
|
955
829
|
}
|
|
956
830
|
|
|
957
|
-
var _excluded$1 = ["
|
|
831
|
+
var _excluded$1 = ["formNode", "style", "schemaInterface", "styleClass", "textClass", "displayOnly", "inline"];
|
|
958
832
|
var AppendAdornmentPriority = 0;
|
|
959
833
|
var WrapAdornmentPriority = 1000;
|
|
960
834
|
/**
|
|
@@ -977,11 +851,8 @@ exports.LabelType = void 0;
|
|
|
977
851
|
})(exports.LabelType || (exports.LabelType = {}));
|
|
978
852
|
function defaultDataProps(_ref, definition, control) {
|
|
979
853
|
var _definition$renderOpt;
|
|
980
|
-
var
|
|
854
|
+
var formNode = _ref.formNode,
|
|
981
855
|
style = _ref.style,
|
|
982
|
-
allowedOptions = _ref.allowedOptions,
|
|
983
|
-
_ref$schemaInterface = _ref.schemaInterface,
|
|
984
|
-
schemaInterface = _ref$schemaInterface === void 0 ? formsCore.defaultSchemaInterface : _ref$schemaInterface,
|
|
985
856
|
styleClass = _ref.styleClass,
|
|
986
857
|
tc = _ref.textClass,
|
|
987
858
|
displayOnly = _ref.displayOnly,
|
|
@@ -992,34 +863,24 @@ function defaultDataProps(_ref, definition, control) {
|
|
|
992
863
|
var className = rendererClass(styleClass, definition.styleClass);
|
|
993
864
|
var textClass = rendererClass(tc, definition.textClass);
|
|
994
865
|
var required = !!definition.required && !displayOnly;
|
|
995
|
-
var
|
|
996
|
-
var _allowed = allowedOptions != null ? allowedOptions : [];
|
|
997
|
-
var allowed = Array.isArray(_allowed) ? _allowed : [_allowed];
|
|
866
|
+
var id = "c" + control.uniqueId;
|
|
998
867
|
return _extends({
|
|
999
868
|
dataNode: dataNode,
|
|
869
|
+
formNode: formNode,
|
|
1000
870
|
definition: definition,
|
|
1001
871
|
control: control,
|
|
1002
872
|
field: field,
|
|
1003
|
-
id:
|
|
873
|
+
id: id,
|
|
874
|
+
errorId: "err_" + id,
|
|
1004
875
|
inline: !!inline,
|
|
1005
|
-
options:
|
|
1006
|
-
|
|
1007
|
-
return typeof x === "object" ? x : (_fieldOptions$find = fieldOptions == null ? void 0 : fieldOptions.find(function (y) {
|
|
1008
|
-
return y.value == x;
|
|
1009
|
-
})) != null ? _fieldOptions$find : {
|
|
1010
|
-
name: x.toString(),
|
|
1011
|
-
value: x
|
|
1012
|
-
};
|
|
1013
|
-
}).filter(function (x) {
|
|
1014
|
-
return x != null;
|
|
1015
|
-
}) : fieldOptions,
|
|
1016
|
-
readonly: !!formOptions.readonly,
|
|
876
|
+
options: formNode.resolved.fieldOptions,
|
|
877
|
+
readonly: formNode.readonly,
|
|
1017
878
|
displayOnly: !!displayOnly,
|
|
1018
879
|
renderOptions: (_definition$renderOpt = definition.renderOptions) != null ? _definition$renderOpt : {
|
|
1019
880
|
type: "Standard"
|
|
1020
881
|
},
|
|
1021
882
|
required: required,
|
|
1022
|
-
hidden:
|
|
883
|
+
hidden: !formNode.visible,
|
|
1023
884
|
className: className,
|
|
1024
885
|
textClass: textClass,
|
|
1025
886
|
style: style
|
|
@@ -1041,11 +902,9 @@ function renderControlLayout(props) {
|
|
|
1041
902
|
textClass = props.textClass,
|
|
1042
903
|
formNode = props.formNode,
|
|
1043
904
|
actionOnClick = props.actionOnClick,
|
|
1044
|
-
state = props.state,
|
|
1045
|
-
getChildState = props.getChildState,
|
|
1046
905
|
inline = props.inline,
|
|
1047
906
|
displayOnly = props.displayOnly;
|
|
1048
|
-
var c =
|
|
907
|
+
var c = formNode.definition;
|
|
1049
908
|
if (formsCore.isDataControl(c)) {
|
|
1050
909
|
return renderData(c);
|
|
1051
910
|
}
|
|
@@ -1053,7 +912,7 @@ function renderControlLayout(props) {
|
|
|
1053
912
|
var _c$groupOptions2, _c$groupOptions3;
|
|
1054
913
|
if (c.compoundField) {
|
|
1055
914
|
var _c$groupOptions;
|
|
1056
|
-
return renderData(dataControl(c.compoundField, c.title, {
|
|
915
|
+
return renderData(formsCore.dataControl(c.compoundField, c.title, {
|
|
1057
916
|
children: c.children,
|
|
1058
917
|
hideTitle: (_c$groupOptions = c.groupOptions) == null ? void 0 : _c$groupOptions.hideTitle
|
|
1059
918
|
}));
|
|
@@ -1062,7 +921,6 @@ function renderControlLayout(props) {
|
|
|
1062
921
|
inline: inline,
|
|
1063
922
|
processLayout: renderer.renderGroup({
|
|
1064
923
|
formNode: formNode,
|
|
1065
|
-
state: state,
|
|
1066
924
|
definition: c,
|
|
1067
925
|
renderChild: renderChild,
|
|
1068
926
|
runExpression: runExpression,
|
|
@@ -1074,8 +932,7 @@ function renderControlLayout(props) {
|
|
|
1074
932
|
textClass: rendererClass(textClass, c.textClass),
|
|
1075
933
|
style: style,
|
|
1076
934
|
designMode: designMode,
|
|
1077
|
-
actionOnClick: actionOnClick
|
|
1078
|
-
getChildState: getChildState
|
|
935
|
+
actionOnClick: actionOnClick
|
|
1079
936
|
}),
|
|
1080
937
|
label: {
|
|
1081
938
|
label: c.title,
|
|
@@ -1087,23 +944,18 @@ function renderControlLayout(props) {
|
|
|
1087
944
|
};
|
|
1088
945
|
}
|
|
1089
946
|
if (formsCore.isActionControl(c)) {
|
|
1090
|
-
var _c$actionStyle, _c$title
|
|
947
|
+
var _c$actionStyle, _c$title;
|
|
1091
948
|
var renderActionGroup = function renderActionGroup() {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
hideTitle: true
|
|
1098
|
-
},
|
|
1099
|
-
children: childDefs
|
|
1100
|
-
};
|
|
1101
|
-
var childNode = formNode.createChildNode("child", childDef);
|
|
1102
|
-
return renderChild("child", childNode, {});
|
|
949
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
950
|
+
children: formNode.children.map(function (x) {
|
|
951
|
+
return renderChild(x);
|
|
952
|
+
})
|
|
953
|
+
});
|
|
1103
954
|
};
|
|
1104
955
|
var actionData = c.actionData;
|
|
1105
956
|
var actionStyle = (_c$actionStyle = c.actionStyle) != null ? _c$actionStyle : formsCore.ActionStyle.Button;
|
|
1106
957
|
var actionContent = actionStyle == formsCore.ActionStyle.Group ? renderActionGroup() : undefined;
|
|
958
|
+
var handler = props.actionOnClick == null ? void 0 : props.actionOnClick(c.actionId, actionData, dataContext);
|
|
1107
959
|
return {
|
|
1108
960
|
inline: inline,
|
|
1109
961
|
children: renderer.renderAction({
|
|
@@ -1116,10 +968,35 @@ function renderControlLayout(props) {
|
|
|
1116
968
|
iconPlacement: c.iconPlacement,
|
|
1117
969
|
icon: c.icon,
|
|
1118
970
|
inline: inline,
|
|
1119
|
-
disabled:
|
|
1120
|
-
onClick:
|
|
971
|
+
disabled: formNode.disabled,
|
|
972
|
+
onClick: handler ? function () {
|
|
973
|
+
var _c$disableType;
|
|
974
|
+
var disableType = (_c$disableType = c.disableType) != null ? _c$disableType : formsCore.ControlDisableType.Self;
|
|
975
|
+
var actionContext = {
|
|
976
|
+
disableForm: function disableForm(type) {
|
|
977
|
+
disableType = type;
|
|
978
|
+
},
|
|
979
|
+
runAction: function runAction(actionId, actionData) {
|
|
980
|
+
var h = props.actionOnClick == null ? void 0 : props.actionOnClick(actionId, actionData, dataContext);
|
|
981
|
+
if (h) {
|
|
982
|
+
h(actionContext);
|
|
983
|
+
}
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
var r = handler(actionContext);
|
|
988
|
+
if (r instanceof Promise) {
|
|
989
|
+
var cleanup = formNode.ui.getDisabler(disableType)();
|
|
990
|
+
formNode.setBusy(true);
|
|
991
|
+
r.then(function () {
|
|
992
|
+
cleanup();
|
|
993
|
+
formNode.setBusy(false);
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
} : function () {},
|
|
1121
997
|
className: rendererClass(styleClass, c.styleClass),
|
|
1122
|
-
style: style
|
|
998
|
+
style: style,
|
|
999
|
+
busy: formNode.busy
|
|
1123
1000
|
})
|
|
1124
1001
|
};
|
|
1125
1002
|
}
|
|
@@ -1165,7 +1042,8 @@ function renderControlLayout(props) {
|
|
|
1165
1042
|
className: rendererClass(labelClass, c.labelClass),
|
|
1166
1043
|
textClass: rendererClass(labelTextClass, c.labelTextClass)
|
|
1167
1044
|
},
|
|
1168
|
-
errorControl: control
|
|
1045
|
+
errorControl: control,
|
|
1046
|
+
errorId: rendererProps.errorId
|
|
1169
1047
|
};
|
|
1170
1048
|
}
|
|
1171
1049
|
}
|
|
@@ -1216,13 +1094,15 @@ function renderLayoutParts(props, renderer) {
|
|
|
1216
1094
|
errorControl = _ref2.errorControl,
|
|
1217
1095
|
label = _ref2.label,
|
|
1218
1096
|
adornments = _ref2.adornments,
|
|
1219
|
-
inline = _ref2.inline
|
|
1097
|
+
inline = _ref2.inline,
|
|
1098
|
+
errorId = _ref2.errorId;
|
|
1220
1099
|
var layout = {
|
|
1221
1100
|
children: children,
|
|
1222
1101
|
errorControl: errorControl,
|
|
1223
1102
|
style: style,
|
|
1224
1103
|
className: className,
|
|
1225
1104
|
inline: inline,
|
|
1105
|
+
errorId: errorId,
|
|
1226
1106
|
wrapLayout: function wrapLayout(x) {
|
|
1227
1107
|
return x;
|
|
1228
1108
|
}
|
|
@@ -1248,7 +1128,7 @@ function getLengthRestrictions(definition) {
|
|
|
1248
1128
|
max: lengthVal == null ? void 0 : lengthVal.max
|
|
1249
1129
|
};
|
|
1250
1130
|
}
|
|
1251
|
-
function createArrayActions(control, field, options) {
|
|
1131
|
+
function createArrayActions(control, getElementCount, field, options) {
|
|
1252
1132
|
var _field$displayName;
|
|
1253
1133
|
var noun = (_field$displayName = field.displayName) != null ? _field$displayName : field.field;
|
|
1254
1134
|
var _ref3 = options != null ? options : {},
|
|
@@ -1266,6 +1146,7 @@ function createArrayActions(control, field, options) {
|
|
|
1266
1146
|
editExternal = _ref3.editExternal;
|
|
1267
1147
|
return {
|
|
1268
1148
|
arrayControl: control,
|
|
1149
|
+
getElementCount: getElementCount,
|
|
1269
1150
|
addAction: !readonly && !noAdd ? makeAdd(function () {
|
|
1270
1151
|
if (!designMode) {
|
|
1271
1152
|
var newValue = elementValueForField(field);
|
|
@@ -1340,15 +1221,14 @@ function createArrayActions(control, field, options) {
|
|
|
1340
1221
|
}
|
|
1341
1222
|
}
|
|
1342
1223
|
function applyArrayLengthRestrictions(_ref4, disable) {
|
|
1343
|
-
var
|
|
1344
|
-
var arrayControl = _ref4.arrayControl,
|
|
1224
|
+
var getElementCount = _ref4.getElementCount,
|
|
1345
1225
|
min = _ref4.min,
|
|
1346
1226
|
max = _ref4.max,
|
|
1347
1227
|
editAction = _ref4.editAction,
|
|
1348
1228
|
aa = _ref4.addAction,
|
|
1349
1229
|
ra = _ref4.removeAction,
|
|
1350
1230
|
required = _ref4.required;
|
|
1351
|
-
var _applyLengthRestricti = applyLengthRestrictions((
|
|
1231
|
+
var _applyLengthRestricti = applyLengthRestrictions(getElementCount(), min == null && required ? 1 : min, max, true, true),
|
|
1352
1232
|
removeAllowed = _applyLengthRestricti[0],
|
|
1353
1233
|
addAllowed = _applyLengthRestricti[1];
|
|
1354
1234
|
return {
|
|
@@ -1361,21 +1241,11 @@ function applyArrayLengthRestrictions(_ref4, disable) {
|
|
|
1361
1241
|
}
|
|
1362
1242
|
function fieldOptionAdornment(p) {
|
|
1363
1243
|
return function (o, fieldIndex, selected) {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
children: function children(cd, i) {
|
|
1367
|
-
return p.renderChild(i, cd, {
|
|
1368
|
-
parentDataNode: p.dataContext.parentNode,
|
|
1369
|
-
stateKey: fieldIndex.toString(),
|
|
1370
|
-
variables: {
|
|
1371
|
-
formData: {
|
|
1372
|
-
option: o,
|
|
1373
|
-
optionSelected: selected
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1244
|
+
var fieldChild = p.formNode.children.find(function (x) {
|
|
1245
|
+
return x.meta["fieldOptionValue"] === o.value;
|
|
1378
1246
|
});
|
|
1247
|
+
if (fieldChild) return p.renderChild(fieldChild);
|
|
1248
|
+
return undefined;
|
|
1379
1249
|
};
|
|
1380
1250
|
}
|
|
1381
1251
|
function lookupChildDataContext(dataContext, c) {
|
|
@@ -1483,7 +1353,19 @@ function createFormRenderer(customRenderers, defaultRenderers) {
|
|
|
1483
1353
|
renderLayout: renderLayout,
|
|
1484
1354
|
renderVisibility: renderVisibility,
|
|
1485
1355
|
renderLabelText: renderLabelText,
|
|
1486
|
-
html: defaultRenderers.html
|
|
1356
|
+
html: defaultRenderers.html,
|
|
1357
|
+
resolveChildren: function resolveChildren(c) {
|
|
1358
|
+
var def = c.definition;
|
|
1359
|
+
if (formsCore.isDataControl(def)) {
|
|
1360
|
+
var _def$renderOptions;
|
|
1361
|
+
if (!c.dataNode) return [];
|
|
1362
|
+
var matching = matchData(c, (_def$renderOptions = def.renderOptions) != null ? _def$renderOptions : {
|
|
1363
|
+
type: formsCore.DataRenderType.Standard
|
|
1364
|
+
}, c.dataNode);
|
|
1365
|
+
if (matching != null && matching.resolveChildren) return matching.resolveChildren(c);
|
|
1366
|
+
}
|
|
1367
|
+
return formsCore.defaultResolveChildNodes(c);
|
|
1368
|
+
}
|
|
1487
1369
|
};
|
|
1488
1370
|
function renderVisibility(props) {
|
|
1489
1371
|
return visibilityRenderer.render(props, formRenderers);
|
|
@@ -1519,12 +1401,25 @@ function createFormRenderer(customRenderers, defaultRenderers) {
|
|
|
1519
1401
|
})) != null ? _labelRenderers$find : defaultRenderers.label;
|
|
1520
1402
|
return renderer.render(props, labelStart, labelEnd, formRenderers);
|
|
1521
1403
|
}
|
|
1522
|
-
function
|
|
1523
|
-
var
|
|
1524
|
-
|
|
1525
|
-
var options =
|
|
1404
|
+
function matchData(formState, renderOptions, dataNode) {
|
|
1405
|
+
var _formState$resolved$f, _formState$resolved$f2;
|
|
1406
|
+
var field = dataNode.schema.field;
|
|
1407
|
+
var options = ((_formState$resolved$f = (_formState$resolved$f2 = formState.resolved.fieldOptions) == null ? void 0 : _formState$resolved$f2.length) != null ? _formState$resolved$f : 0) > 0;
|
|
1526
1408
|
var renderType = renderOptions.type;
|
|
1527
|
-
|
|
1409
|
+
return dataRegistrations.find(matchesRenderer);
|
|
1410
|
+
function matchesRenderer(x) {
|
|
1411
|
+
var _x$collection, _field$collection, _x$options;
|
|
1412
|
+
var noMatch = x.match ? !x.match(formState, renderOptions) : undefined;
|
|
1413
|
+
if (noMatch === true) return false;
|
|
1414
|
+
var matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (dataNode.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
|
|
1415
|
+
var isSchemaAllowed = !!x.schemaType && renderType == formsCore.DataRenderType.Standard ? isOneOf(x.schemaType, field.type) : undefined;
|
|
1416
|
+
var isRendererAllowed = !!x.renderType && isOneOf(x.renderType, renderType);
|
|
1417
|
+
var optionsMatch = isRendererAllowed || ((_x$options = x.options) != null ? _x$options : false) === options;
|
|
1418
|
+
return matchCollection && optionsMatch && (isSchemaAllowed || isRendererAllowed || !x.renderType && !x.schemaType && noMatch === false);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
function renderData(props) {
|
|
1422
|
+
var renderer = matchData(props.formNode, props.renderOptions, props.dataNode);
|
|
1528
1423
|
var result = (renderer != null ? renderer : defaultRenderers.data).render(props, formRenderers);
|
|
1529
1424
|
if (typeof result === "function") return result;
|
|
1530
1425
|
return function (l) {
|
|
@@ -1532,15 +1427,6 @@ function createFormRenderer(customRenderers, defaultRenderers) {
|
|
|
1532
1427
|
children: result
|
|
1533
1428
|
});
|
|
1534
1429
|
};
|
|
1535
|
-
function matchesRenderer(x) {
|
|
1536
|
-
var _x$collection, _field$collection, _x$options;
|
|
1537
|
-
var noMatch = x.match ? !x.match(props, renderOptions) : undefined;
|
|
1538
|
-
if (noMatch === true) return false;
|
|
1539
|
-
var matchCollection = ((_x$collection = x.collection) != null ? _x$collection : false) === (props.dataNode.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false));
|
|
1540
|
-
var isSchemaAllowed = !!x.schemaType && renderType == formsCore.DataRenderType.Standard ? isOneOf(x.schemaType, field.type) : undefined;
|
|
1541
|
-
var isRendererAllowed = !!x.renderType && isOneOf(x.renderType, renderType);
|
|
1542
|
-
return matchCollection && ((_x$options = x.options) != null ? _x$options : false) === options && (isSchemaAllowed || isRendererAllowed || !x.renderType && !x.schemaType && noMatch === false);
|
|
1543
|
-
}
|
|
1544
1430
|
}
|
|
1545
1431
|
function renderGroup(props) {
|
|
1546
1432
|
var _groupRegistrations$f;
|
|
@@ -1605,55 +1491,104 @@ function isArrayRegistration(x) {
|
|
|
1605
1491
|
}
|
|
1606
1492
|
|
|
1607
1493
|
var _excluded = ["styleClass", "labelClass", "layoutClass", "labelTextClass", "textClass"],
|
|
1608
|
-
_excluded2 = ["
|
|
1494
|
+
_excluded2 = ["actionOnClick"];
|
|
1609
1495
|
function RenderForm(_ref) {
|
|
1610
1496
|
var _effect = core.useComponentTracking();
|
|
1611
1497
|
try {
|
|
1612
|
-
var _options$schemaInterf
|
|
1498
|
+
var _options$schemaInterf;
|
|
1613
1499
|
var data = _ref.data,
|
|
1614
1500
|
form = _ref.form,
|
|
1615
1501
|
renderer = _ref.renderer,
|
|
1616
1502
|
_ref$options = _ref.options,
|
|
1617
|
-
options = _ref$options === void 0 ? {} : _ref$options
|
|
1503
|
+
options = _ref$options === void 0 ? {} : _ref$options,
|
|
1504
|
+
stateRef = _ref.stateRef;
|
|
1505
|
+
var readonly = options.readonly,
|
|
1506
|
+
disabled = options.disabled,
|
|
1507
|
+
displayOnly = options.displayOnly,
|
|
1508
|
+
hidden = options.hidden,
|
|
1509
|
+
variables = options.variables,
|
|
1510
|
+
clearHidden = options.clearHidden;
|
|
1618
1511
|
var schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : formsCore.defaultSchemaInterface;
|
|
1619
|
-
var
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1512
|
+
var _useAsyncRunner = useAsyncRunner(),
|
|
1513
|
+
runAsync = _useAsyncRunner.runAsync;
|
|
1514
|
+
var globals = {
|
|
1515
|
+
runAsync: runAsync,
|
|
1516
|
+
schemaInterface: schemaInterface,
|
|
1517
|
+
evalExpression: function evalExpression(e, ctx) {
|
|
1518
|
+
var _defaultEvaluators$e$;
|
|
1519
|
+
return (_defaultEvaluators$e$ = formsCore.defaultEvaluators[e.type]) == null ? void 0 : _defaultEvaluators$e$.call(formsCore.defaultEvaluators, e, ctx);
|
|
1520
|
+
},
|
|
1521
|
+
resolveChildren: renderer.resolveChildren,
|
|
1522
|
+
clearHidden: !!clearHidden
|
|
1628
1523
|
};
|
|
1629
|
-
var state =
|
|
1524
|
+
var state = react.useMemo(function () {
|
|
1525
|
+
return formsCore.createFormStateNode(form, data, globals, {
|
|
1526
|
+
forceReadonly: !!readonly,
|
|
1527
|
+
forceDisabled: !!disabled,
|
|
1528
|
+
variables: variables,
|
|
1529
|
+
forceHidden: !!hidden
|
|
1530
|
+
});
|
|
1531
|
+
}, [form.id]);
|
|
1532
|
+
state.globals.value = globals;
|
|
1533
|
+
state.options.setValue(function (x) {
|
|
1534
|
+
return {
|
|
1535
|
+
variables: variables,
|
|
1536
|
+
forceHidden: hidden != null ? hidden : x.forceHidden,
|
|
1537
|
+
forceDisabled: disabled != null ? disabled : x.forceDisabled,
|
|
1538
|
+
forceReadonly: readonly != null ? readonly : x.forceReadonly
|
|
1539
|
+
};
|
|
1540
|
+
});
|
|
1541
|
+
if (stateRef) stateRef.current = state;
|
|
1630
1542
|
react.useEffect(function () {
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1543
|
+
return function () {
|
|
1544
|
+
state.cleanup();
|
|
1545
|
+
};
|
|
1546
|
+
}, [state]);
|
|
1547
|
+
return /*#__PURE__*/jsxRuntime.jsx(RenderFormNode, {
|
|
1548
|
+
node: state,
|
|
1549
|
+
renderer: renderer,
|
|
1550
|
+
options: options
|
|
1551
|
+
});
|
|
1552
|
+
} finally {
|
|
1553
|
+
_effect();
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
/* @trackControls */
|
|
1557
|
+
function RenderFormNode(_ref2) {
|
|
1558
|
+
var _effect2 = core.useComponentTracking();
|
|
1559
|
+
try {
|
|
1560
|
+
var _definition$adornment, _definition$adornment2, _dataContext$dataNode, _options$adjustLayout;
|
|
1561
|
+
var state = _ref2.node,
|
|
1562
|
+
renderer = _ref2.renderer,
|
|
1563
|
+
_ref2$options = _ref2.options,
|
|
1564
|
+
options = _ref2$options === void 0 ? {} : _ref2$options;
|
|
1565
|
+
react.useEffect(function () {
|
|
1566
|
+
state.attachUi(new DefaultFormNodeUi(state));
|
|
1567
|
+
}, [state]);
|
|
1568
|
+
var _useAsyncRunner2 = useAsyncRunner(),
|
|
1569
|
+
runAsync = _useAsyncRunner2.runAsync;
|
|
1570
|
+
var schemaInterface = state.schemaInterface;
|
|
1637
1571
|
var definition = state.definition;
|
|
1638
|
-
var visible =
|
|
1572
|
+
var visible = state.visible;
|
|
1639
1573
|
var visibility = core.useControl(function () {
|
|
1640
1574
|
return visible != null ? {
|
|
1641
1575
|
visible: visible,
|
|
1642
1576
|
showing: visible
|
|
1643
1577
|
} : undefined;
|
|
1644
1578
|
});
|
|
1645
|
-
|
|
1579
|
+
if (visible != null) {
|
|
1580
|
+
visibility.fields.visible.value = visible;
|
|
1581
|
+
}
|
|
1646
1582
|
var dataContext = {
|
|
1647
1583
|
schemaInterface: state.schemaInterface,
|
|
1648
1584
|
dataNode: state.dataNode,
|
|
1649
|
-
parentNode:
|
|
1650
|
-
variables: state.variables
|
|
1585
|
+
parentNode: state.parent
|
|
1651
1586
|
};
|
|
1652
1587
|
var adornments = (_definition$adornment = (_definition$adornment2 = definition.adornments) == null ? void 0 : _definition$adornment2.map(function (x) {
|
|
1653
1588
|
return renderer.renderAdornment({
|
|
1654
1589
|
adornment: x,
|
|
1655
1590
|
dataContext: dataContext,
|
|
1656
|
-
|
|
1591
|
+
formNode: state
|
|
1657
1592
|
});
|
|
1658
1593
|
})) != null ? _definition$adornment : [];
|
|
1659
1594
|
var styleClass = options.styleClass,
|
|
@@ -1663,65 +1598,51 @@ function RenderForm(_ref) {
|
|
|
1663
1598
|
textClass = options.textClass,
|
|
1664
1599
|
inheritableOptions = _objectWithoutPropertiesLoose(options, _excluded);
|
|
1665
1600
|
var readonly = state.readonly,
|
|
1666
|
-
|
|
1601
|
+
vis = state.visible,
|
|
1667
1602
|
disabled = state.disabled,
|
|
1668
1603
|
variables = state.variables;
|
|
1669
1604
|
var childOptions = _extends({}, inheritableOptions, {
|
|
1670
1605
|
readonly: readonly,
|
|
1671
1606
|
disabled: disabled,
|
|
1672
1607
|
variables: variables,
|
|
1673
|
-
|
|
1674
|
-
hidden: hidden
|
|
1608
|
+
hidden: vis === false
|
|
1675
1609
|
});
|
|
1676
1610
|
var labelAndChildren = renderControlLayout({
|
|
1677
|
-
formNode:
|
|
1611
|
+
formNode: state,
|
|
1678
1612
|
renderer: renderer,
|
|
1679
|
-
|
|
1680
|
-
renderChild: function renderChild(k, child, options) {
|
|
1681
|
-
var _ref3;
|
|
1613
|
+
renderChild: function renderChild(child, options) {
|
|
1682
1614
|
var overrideClasses = getGroupClassOverrides(definition);
|
|
1683
|
-
var
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
variables = _ref2.variables,
|
|
1687
|
-
renderOptions = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
1688
|
-
var dContext = (_ref3 = parentDataNode != null ? parentDataNode : dataContext.dataNode) != null ? _ref3 : data;
|
|
1615
|
+
var _ref3 = options != null ? options : {},
|
|
1616
|
+
actionOnClick = _ref3.actionOnClick,
|
|
1617
|
+
renderOptions = _objectWithoutPropertiesLoose(_ref3, _excluded2);
|
|
1689
1618
|
var allChildOptions = _extends({}, childOptions, overrideClasses, renderOptions, {
|
|
1690
|
-
variables: _extends({}, childOptions.variables, variables),
|
|
1691
1619
|
actionOnClick: actionHandlers(actionOnClick, childOptions.actionOnClick)
|
|
1692
1620
|
});
|
|
1693
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
1694
|
-
|
|
1621
|
+
return /*#__PURE__*/jsxRuntime.jsx(RenderFormNode, {
|
|
1622
|
+
node: child,
|
|
1695
1623
|
renderer: renderer,
|
|
1696
|
-
data: dContext,
|
|
1697
1624
|
options: allChildOptions
|
|
1698
|
-
},
|
|
1625
|
+
}, child.childKey);
|
|
1699
1626
|
},
|
|
1700
1627
|
inline: options == null ? void 0 : options.inline,
|
|
1701
1628
|
displayOnly: options == null ? void 0 : options.displayOnly,
|
|
1702
1629
|
createDataProps: defaultDataProps,
|
|
1703
|
-
formOptions: state,
|
|
1704
1630
|
dataContext: dataContext,
|
|
1705
1631
|
control: (_dataContext$dataNode = dataContext.dataNode) == null ? void 0 : _dataContext$dataNode.control,
|
|
1706
1632
|
schemaInterface: schemaInterface,
|
|
1707
|
-
style: state.style,
|
|
1708
|
-
allowedOptions: state.allowedOptions,
|
|
1633
|
+
style: state.resolved.style,
|
|
1709
1634
|
customDisplay: options.customDisplay,
|
|
1710
1635
|
actionOnClick: options.actionOnClick,
|
|
1711
1636
|
styleClass: styleClass,
|
|
1712
1637
|
labelClass: labelClass,
|
|
1713
1638
|
labelTextClass: labelTextClass,
|
|
1714
1639
|
textClass: textClass,
|
|
1715
|
-
getChildState: function getChildState(child, parent) {
|
|
1716
|
-
var _ref4;
|
|
1717
|
-
return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions, runAsync);
|
|
1718
|
-
},
|
|
1719
1640
|
runExpression: function runExpression(scope, expr, returnResult) {
|
|
1720
1641
|
if (expr != null && expr.type) {
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
dataNode: data,
|
|
1642
|
+
formsCore.defaultEvaluators[expr.type](expr, {
|
|
1643
|
+
dataNode: state.parent,
|
|
1724
1644
|
schemaInterface: schemaInterface,
|
|
1645
|
+
scope: scope,
|
|
1725
1646
|
returnResult: returnResult,
|
|
1726
1647
|
runAsync: runAsync
|
|
1727
1648
|
});
|
|
@@ -1731,24 +1652,14 @@ function RenderForm(_ref) {
|
|
|
1731
1652
|
var layoutProps = _extends({}, labelAndChildren, {
|
|
1732
1653
|
adornments: adornments,
|
|
1733
1654
|
className: rendererClass(options.layoutClass, definition.layoutClass),
|
|
1734
|
-
style: state.layoutStyle
|
|
1655
|
+
style: state.resolved.layoutStyle
|
|
1735
1656
|
});
|
|
1736
1657
|
var renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
|
|
1737
|
-
|
|
1658
|
+
return renderer.renderVisibility(_extends({
|
|
1738
1659
|
visibility: visibility
|
|
1739
1660
|
}, renderedControl));
|
|
1740
|
-
react.useEffect(function () {
|
|
1741
|
-
if (effects) {
|
|
1742
|
-
var toRun = effects;
|
|
1743
|
-
effects = undefined;
|
|
1744
|
-
toRun.forEach(function (cb) {
|
|
1745
|
-
return cb();
|
|
1746
|
-
});
|
|
1747
|
-
}
|
|
1748
|
-
}, [effects]);
|
|
1749
|
-
return rendered;
|
|
1750
1661
|
} finally {
|
|
1751
|
-
|
|
1662
|
+
_effect2();
|
|
1752
1663
|
}
|
|
1753
1664
|
}
|
|
1754
1665
|
/**
|
|
@@ -1758,8 +1669,8 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
|
|
|
1758
1669
|
if (options === void 0) {
|
|
1759
1670
|
options = {};
|
|
1760
1671
|
}
|
|
1761
|
-
var
|
|
1762
|
-
formNode =
|
|
1672
|
+
var _ref4 = "definition" in controlOrFormNode ? [controlOrFormNode.definition, controlOrFormNode] : [controlOrFormNode, formsCore.legacyFormNode(controlOrFormNode)],
|
|
1673
|
+
formNode = _ref4[1];
|
|
1763
1674
|
var r = useUpdatedRef({
|
|
1764
1675
|
options: options,
|
|
1765
1676
|
renderer: renderer,
|
|
@@ -1785,36 +1696,36 @@ function useControlRendererComponent(controlOrFormNode, renderer, options, paren
|
|
|
1785
1696
|
/**
|
|
1786
1697
|
* @deprecated Use RenderForm instead.
|
|
1787
1698
|
*/
|
|
1788
|
-
function ControlRenderer(
|
|
1789
|
-
var
|
|
1699
|
+
function ControlRenderer(_ref5) {
|
|
1700
|
+
var _effect3 = core.useComponentTracking();
|
|
1790
1701
|
try {
|
|
1791
|
-
var definition =
|
|
1792
|
-
fields =
|
|
1793
|
-
renderer =
|
|
1794
|
-
options =
|
|
1795
|
-
control =
|
|
1796
|
-
parentPath =
|
|
1702
|
+
var definition = _ref5.definition,
|
|
1703
|
+
fields = _ref5.fields,
|
|
1704
|
+
renderer = _ref5.renderer,
|
|
1705
|
+
options = _ref5.options,
|
|
1706
|
+
control = _ref5.control,
|
|
1707
|
+
parentPath = _ref5.parentPath;
|
|
1797
1708
|
var schemaDataNode = formsCore.createSchemaDataNode(formsCore.createSchemaTree(fields).rootNode, control);
|
|
1798
1709
|
var Render = useControlRendererComponent(definition, renderer, options, schemaDataNode);
|
|
1799
1710
|
return /*#__PURE__*/jsxRuntime.jsx(Render, {});
|
|
1800
1711
|
} finally {
|
|
1801
|
-
|
|
1712
|
+
_effect3();
|
|
1802
1713
|
}
|
|
1803
1714
|
}
|
|
1804
1715
|
/**
|
|
1805
1716
|
* @deprecated Use RenderForm instead.
|
|
1806
1717
|
*/
|
|
1807
|
-
function NewControlRenderer(
|
|
1808
|
-
var
|
|
1718
|
+
function NewControlRenderer(_ref6) {
|
|
1719
|
+
var _effect4 = core.useComponentTracking();
|
|
1809
1720
|
try {
|
|
1810
|
-
var definition =
|
|
1811
|
-
renderer =
|
|
1812
|
-
options =
|
|
1813
|
-
parentDataNode =
|
|
1721
|
+
var definition = _ref6.definition,
|
|
1722
|
+
renderer = _ref6.renderer,
|
|
1723
|
+
options = _ref6.options,
|
|
1724
|
+
parentDataNode = _ref6.parentDataNode;
|
|
1814
1725
|
var Render = useControlRendererComponent(definition, renderer, options, parentDataNode);
|
|
1815
1726
|
return /*#__PURE__*/jsxRuntime.jsx(Render, {});
|
|
1816
1727
|
} finally {
|
|
1817
|
-
|
|
1728
|
+
_effect4();
|
|
1818
1729
|
}
|
|
1819
1730
|
}
|
|
1820
1731
|
/**
|
|
@@ -1830,27 +1741,115 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1830
1741
|
renderer: renderer,
|
|
1831
1742
|
options: options
|
|
1832
1743
|
});
|
|
1833
|
-
return react.useCallback(function (
|
|
1834
|
-
var control =
|
|
1835
|
-
parentPath =
|
|
1744
|
+
return react.useCallback(function (_ref7) {
|
|
1745
|
+
var control = _ref7.control,
|
|
1746
|
+
parentPath = _ref7.parentPath;
|
|
1836
1747
|
return /*#__PURE__*/jsxRuntime.jsx(ControlRenderer, _extends({}, r.current, {
|
|
1837
1748
|
control: control,
|
|
1838
1749
|
parentPath: parentPath
|
|
1839
1750
|
}));
|
|
1840
1751
|
}, [r]);
|
|
1841
1752
|
}
|
|
1753
|
+
function useAsyncRunner() {
|
|
1754
|
+
var effects = [];
|
|
1755
|
+
var runAsync = function runAsync(cb) {
|
|
1756
|
+
if (effects) effects.push(cb);else cb();
|
|
1757
|
+
};
|
|
1758
|
+
react.useEffect(function () {
|
|
1759
|
+
if (effects) {
|
|
1760
|
+
var toRun = effects;
|
|
1761
|
+
effects = undefined;
|
|
1762
|
+
toRun.forEach(function (cb) {
|
|
1763
|
+
return cb();
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
}, [effects]);
|
|
1767
|
+
return {
|
|
1768
|
+
runAsync: runAsync
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
var DefaultFormNodeUi = /*#__PURE__*/function () {
|
|
1772
|
+
function DefaultFormNodeUi(node) {
|
|
1773
|
+
this.node = void 0;
|
|
1774
|
+
this.node = node;
|
|
1775
|
+
}
|
|
1776
|
+
var _proto = DefaultFormNodeUi.prototype;
|
|
1777
|
+
_proto.ensureVisible = function ensureVisible() {
|
|
1778
|
+
var _this$node$parentNode;
|
|
1779
|
+
(_this$node$parentNode = this.node.parentNode) == null || _this$node$parentNode.ui.ensureChildVisible(this.node.childIndex);
|
|
1780
|
+
};
|
|
1781
|
+
_proto.ensureChildVisible = function ensureChildVisible(childIndex) {
|
|
1782
|
+
this.ensureVisible();
|
|
1783
|
+
};
|
|
1784
|
+
_proto.getDisabler = function getDisabler(type) {
|
|
1785
|
+
var _this = this;
|
|
1786
|
+
if (type === formsCore.ControlDisableType.Self) {
|
|
1787
|
+
return function () {
|
|
1788
|
+
var old = !!_this.node.forceDisabled;
|
|
1789
|
+
_this.node.setForceDisabled(true);
|
|
1790
|
+
return function () {
|
|
1791
|
+
_this.node.setForceDisabled(old);
|
|
1792
|
+
};
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
if (type === formsCore.ControlDisableType.Global) {
|
|
1796
|
+
var topLevel = this.node;
|
|
1797
|
+
while (topLevel.parentNode) {
|
|
1798
|
+
topLevel = topLevel.parentNode;
|
|
1799
|
+
}
|
|
1800
|
+
return topLevel.ui.getDisabler(formsCore.ControlDisableType.Self);
|
|
1801
|
+
}
|
|
1802
|
+
return function () {
|
|
1803
|
+
return function () {};
|
|
1804
|
+
};
|
|
1805
|
+
};
|
|
1806
|
+
return DefaultFormNodeUi;
|
|
1807
|
+
}();
|
|
1808
|
+
|
|
1809
|
+
var NoOpControlActionContext = {
|
|
1810
|
+
disableForm: function disableForm(disable) {},
|
|
1811
|
+
runAction: function runAction(actionId, actionData) {}
|
|
1812
|
+
};
|
|
1813
|
+
|
|
1814
|
+
function useElementSelectedRenderer(_ref) {
|
|
1815
|
+
var runExpression = _ref.runExpression,
|
|
1816
|
+
renderOptions = _ref.renderOptions,
|
|
1817
|
+
control = _ref.control;
|
|
1818
|
+
var elementValue = core.useControl();
|
|
1819
|
+
react.useEffect(function () {
|
|
1820
|
+
runExpression(elementValue, renderOptions.elementExpression, function (v) {
|
|
1821
|
+
return elementValue.value = v;
|
|
1822
|
+
});
|
|
1823
|
+
}, []);
|
|
1824
|
+
var isSelected = core.useComputed(function () {
|
|
1825
|
+
var _control$as$value$inc, _control$as$value;
|
|
1826
|
+
return (_control$as$value$inc = (_control$as$value = control.as().value) == null ? void 0 : _control$as$value.includes(elementValue.value)) != null ? _control$as$value$inc : false;
|
|
1827
|
+
});
|
|
1828
|
+
var selControl = core.useControl(function () {
|
|
1829
|
+
return isSelected.current.value;
|
|
1830
|
+
});
|
|
1831
|
+
selControl.value = isSelected.value;
|
|
1832
|
+
core.useControlEffect(function () {
|
|
1833
|
+
return selControl.value;
|
|
1834
|
+
}, function (v) {
|
|
1835
|
+
control.as().setValue(function (x) {
|
|
1836
|
+
return setIncluded(x != null ? x : [], elementValue.value, v);
|
|
1837
|
+
});
|
|
1838
|
+
});
|
|
1839
|
+
return selControl;
|
|
1840
|
+
}
|
|
1842
1841
|
|
|
1843
1842
|
exports.AppendAdornmentPriority = AppendAdornmentPriority;
|
|
1844
1843
|
exports.ControlRenderer = ControlRenderer;
|
|
1844
|
+
exports.DefaultFormNodeUi = DefaultFormNodeUi;
|
|
1845
1845
|
exports.NewControlRenderer = NewControlRenderer;
|
|
1846
|
+
exports.NoOpControlActionContext = NoOpControlActionContext;
|
|
1846
1847
|
exports.RenderForm = RenderForm;
|
|
1848
|
+
exports.RenderFormNode = RenderFormNode;
|
|
1847
1849
|
exports.WrapAdornmentPriority = WrapAdornmentPriority;
|
|
1848
|
-
exports.accordionOptions = accordionOptions;
|
|
1849
|
-
exports.actionControl = actionControl;
|
|
1850
1850
|
exports.actionHandlers = actionHandlers;
|
|
1851
1851
|
exports.addMissingControls = addMissingControls;
|
|
1852
1852
|
exports.addMissingControlsForSchema = addMissingControlsForSchema;
|
|
1853
|
-
exports.adornmentOptions = adornmentOptions;
|
|
1854
1853
|
exports.appendMarkup = appendMarkup;
|
|
1855
1854
|
exports.appendMarkupAt = appendMarkupAt;
|
|
1856
1855
|
exports.applyArrayLengthRestrictions = applyArrayLengthRestrictions;
|
|
@@ -1860,13 +1859,10 @@ exports.applyExtensionToSchema = applyExtensionToSchema;
|
|
|
1860
1859
|
exports.applyExtensionsToSchema = applyExtensionsToSchema;
|
|
1861
1860
|
exports.applyLengthRestrictions = applyLengthRestrictions;
|
|
1862
1861
|
exports.applyValues = applyValues;
|
|
1863
|
-
exports.autocompleteOptions = autocompleteOptions;
|
|
1864
|
-
exports.checkListOptions = checkListOptions;
|
|
1865
1862
|
exports.cleanDataForSchema = cleanDataForSchema;
|
|
1866
1863
|
exports.clearMultiValues = clearMultiValues;
|
|
1867
1864
|
exports.coerceToString = coerceToString;
|
|
1868
1865
|
exports.collectDifferences = collectDifferences;
|
|
1869
|
-
exports.compoundControl = compoundControl;
|
|
1870
1866
|
exports.controlTitle = controlTitle;
|
|
1871
1867
|
exports.createAction = createAction;
|
|
1872
1868
|
exports.createActionRenderer = createActionRenderer;
|
|
@@ -1881,23 +1877,13 @@ exports.createIconLibraryExtension = createIconLibraryExtension;
|
|
|
1881
1877
|
exports.createLabelRenderer = createLabelRenderer;
|
|
1882
1878
|
exports.createLayoutRenderer = createLayoutRenderer;
|
|
1883
1879
|
exports.createVisibilityRenderer = createVisibilityRenderer;
|
|
1884
|
-
exports.dataControl = dataControl;
|
|
1885
|
-
exports.dateValidatorOptions = dateValidatorOptions;
|
|
1886
1880
|
exports.deepMerge = deepMerge;
|
|
1887
1881
|
exports.defaultControlForField = defaultControlForField;
|
|
1888
1882
|
exports.defaultDataProps = defaultDataProps;
|
|
1889
1883
|
exports.defaultValueForField = defaultValueForField;
|
|
1890
1884
|
exports.defaultValueForFields = defaultValueForFields;
|
|
1891
|
-
exports.displayOnlyOptions = displayOnlyOptions;
|
|
1892
|
-
exports.dynamicDefaultValue = dynamicDefaultValue;
|
|
1893
|
-
exports.dynamicDisabled = dynamicDisabled;
|
|
1894
|
-
exports.dynamicReadonly = dynamicReadonly;
|
|
1895
|
-
exports.dynamicVisibility = dynamicVisibility;
|
|
1896
1885
|
exports.elementValueForField = elementValueForField;
|
|
1897
|
-
exports.emptyGroupDefinition = emptyGroupDefinition;
|
|
1898
1886
|
exports.fieldDisplayName = fieldDisplayName;
|
|
1899
|
-
exports.fieldEqExpr = fieldEqExpr;
|
|
1900
|
-
exports.fieldExpr = fieldExpr;
|
|
1901
1887
|
exports.fieldHasTag = fieldHasTag;
|
|
1902
1888
|
exports.fieldOptionAdornment = fieldOptionAdornment;
|
|
1903
1889
|
exports.findChildDefinition = findChildDefinition;
|
|
@@ -1916,34 +1902,26 @@ exports.getLastDefinedValue = getLastDefinedValue;
|
|
|
1916
1902
|
exports.getLengthRestrictions = getLengthRestrictions;
|
|
1917
1903
|
exports.getNullToggler = getNullToggler;
|
|
1918
1904
|
exports.getOverrideClass = getOverrideClass;
|
|
1919
|
-
exports.groupedControl = groupedControl;
|
|
1920
1905
|
exports.hasOptions = hasOptions;
|
|
1921
|
-
exports.htmlDisplayControl = htmlDisplayControl;
|
|
1922
1906
|
exports.isAccordionAdornment = isAccordionAdornment;
|
|
1923
1907
|
exports.isIconAdornment = isIconAdornment;
|
|
1924
1908
|
exports.isOptionalAdornment = isOptionalAdornment;
|
|
1925
1909
|
exports.isSetFieldAdornment = isSetFieldAdornment;
|
|
1926
|
-
exports.jsonataExpr = jsonataExpr;
|
|
1927
|
-
exports.jsonataOptions = jsonataOptions;
|
|
1928
|
-
exports.jsonataValidatorOptions = jsonataValidatorOptions;
|
|
1929
1910
|
exports.layoutKeyForPlacement = layoutKeyForPlacement;
|
|
1930
|
-
exports.lengthValidatorOptions = lengthValidatorOptions;
|
|
1931
1911
|
exports.lookupChildDataContext = lookupChildDataContext;
|
|
1932
1912
|
exports.mergeObjects = mergeObjects;
|
|
1933
|
-
exports.radioButtonOptions = radioButtonOptions;
|
|
1934
1913
|
exports.renderControlLayout = renderControlLayout;
|
|
1935
1914
|
exports.renderLayoutParts = renderLayoutParts;
|
|
1936
|
-
exports.renderOptionsFor = renderOptionsFor;
|
|
1937
1915
|
exports.rendererClass = rendererClass;
|
|
1938
|
-
exports.
|
|
1939
|
-
exports.
|
|
1916
|
+
exports.setIncluded = setIncluded;
|
|
1917
|
+
exports.useAsyncRunner = useAsyncRunner;
|
|
1940
1918
|
exports.useControlDefinitionForSchema = useControlDefinitionForSchema;
|
|
1941
1919
|
exports.useControlRenderer = useControlRenderer;
|
|
1942
1920
|
exports.useControlRendererComponent = useControlRendererComponent;
|
|
1921
|
+
exports.useElementSelectedRenderer = useElementSelectedRenderer;
|
|
1943
1922
|
exports.useExpression = useExpression;
|
|
1944
1923
|
exports.useUpdatedRef = useUpdatedRef;
|
|
1945
1924
|
exports.validationVisitor = validationVisitor;
|
|
1946
|
-
exports.validatorOptions = validatorOptions;
|
|
1947
1925
|
exports.wrapLayout = wrapLayout;
|
|
1948
1926
|
exports.wrapMarkup = wrapMarkup;
|
|
1949
1927
|
exports.wrapMarkupAt = wrapMarkupAt;
|