@react-typed-forms/schemas 6.0.0 → 7.1.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/.rush/temp/shrinkwrap-deps.json +39 -11
- package/lib/controlRender.d.ts +17 -8
- package/lib/hooks.d.ts +1 -0
- package/lib/index.js +141 -136
- package/lib/index.js.map +1 -1
- package/lib/renderers.d.ts +1 -1
- package/lib/types.d.ts +3 -1
- package/lib/util.d.ts +2 -1
- package/package.json +1 -1
- package/src/controlRender.tsx +92 -103
- package/src/hooks.tsx +18 -0
- package/src/renderers.tsx +31 -24
- package/src/types.ts +2 -0
- package/src/util.ts +16 -11
package/lib/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var React = require('react');
|
|
2
|
+
var clsx = require('clsx');
|
|
2
3
|
var core = require('@react-typed-forms/core');
|
|
3
4
|
var jsonata = require('jsonata');
|
|
4
|
-
var clsx = require('clsx');
|
|
5
5
|
|
|
6
6
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
7
|
|
|
8
8
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
9
|
-
var jsonata__default = /*#__PURE__*/_interopDefaultLegacy(jsonata);
|
|
10
9
|
var clsx__default = /*#__PURE__*/_interopDefaultLegacy(clsx);
|
|
10
|
+
var jsonata__default = /*#__PURE__*/_interopDefaultLegacy(jsonata);
|
|
11
11
|
|
|
12
12
|
exports.FieldType = void 0;
|
|
13
13
|
(function (FieldType) {
|
|
@@ -39,6 +39,7 @@ exports.DynamicPropertyType = void 0;
|
|
|
39
39
|
DynamicPropertyType["Display"] = "Display";
|
|
40
40
|
DynamicPropertyType["Style"] = "Style";
|
|
41
41
|
DynamicPropertyType["LayoutStyle"] = "LayoutStyle";
|
|
42
|
+
DynamicPropertyType["AllowedOptions"] = "AllowedOptions";
|
|
42
43
|
})(exports.DynamicPropertyType || (exports.DynamicPropertyType = {}));
|
|
43
44
|
exports.ExpressionType = void 0;
|
|
44
45
|
(function (ExpressionType) {
|
|
@@ -356,13 +357,10 @@ function hasOptions(o) {
|
|
|
356
357
|
function defaultControlForField(sf) {
|
|
357
358
|
if (isCompoundField(sf)) {
|
|
358
359
|
return {
|
|
359
|
-
type: exports.ControlDefinitionType.
|
|
360
|
+
type: exports.ControlDefinitionType.Data,
|
|
360
361
|
title: sf.displayName,
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
type: exports.GroupRenderType.Grid,
|
|
364
|
-
hideTitle: false
|
|
365
|
-
},
|
|
362
|
+
field: sf.field,
|
|
363
|
+
required: sf.required,
|
|
366
364
|
children: sf.children.map(defaultControlForField)
|
|
367
365
|
};
|
|
368
366
|
} else if (isScalarField(sf)) {
|
|
@@ -533,6 +531,15 @@ function cleanDataForSchema(v, fields) {
|
|
|
533
531
|
|
|
534
532
|
return out;
|
|
535
533
|
}
|
|
534
|
+
function getAllReferencedClasses(c) {
|
|
535
|
+
var _c$children;
|
|
536
|
+
var childClasses = (_c$children = c.children) == null ? void 0 : _c$children.flatMap(getAllReferencedClasses);
|
|
537
|
+
var tc = clsx__default["default"](c.styleClass, c.layoutClass);
|
|
538
|
+
if (childClasses && !tc) return childClasses;
|
|
539
|
+
if (!tc) return [];
|
|
540
|
+
if (childClasses) return [tc].concat(childClasses);
|
|
541
|
+
return [tc];
|
|
542
|
+
}
|
|
536
543
|
|
|
537
544
|
function dataControl(field, title, options) {
|
|
538
545
|
return _extends({
|
|
@@ -689,6 +696,13 @@ function useEvalStyleHook(useEvalExpressionHook, property, definition) {
|
|
|
689
696
|
return core.useControl(undefined);
|
|
690
697
|
}, [dynamicStyle]);
|
|
691
698
|
}
|
|
699
|
+
function useEvalAllowedOptionsHook(useEvalExpressionHook, definition) {
|
|
700
|
+
var dynamicAllowed = useEvalDynamicHook(definition, exports.DynamicPropertyType.AllowedOptions, useEvalExpressionHook);
|
|
701
|
+
return React.useCallback(function (ctx) {
|
|
702
|
+
if (dynamicAllowed) return dynamicAllowed(ctx);
|
|
703
|
+
return core.useControl([]);
|
|
704
|
+
}, [dynamicAllowed]);
|
|
705
|
+
}
|
|
692
706
|
function useEvalDisabledHook(useEvalExpressionHook, definition) {
|
|
693
707
|
var dynamicDisabled = useEvalDynamicHook(definition, exports.DynamicPropertyType.Disabled, useEvalExpressionHook);
|
|
694
708
|
return React.useCallback(function (ctx) {
|
|
@@ -883,6 +897,7 @@ function defaultTextValue(f, value) {
|
|
|
883
897
|
}
|
|
884
898
|
}
|
|
885
899
|
|
|
900
|
+
var _excluded$1 = ["definition", "field", "control", "options", "elementRenderer", "style", "allowedOptions"];
|
|
886
901
|
var AppendAdornmentPriority = 0;
|
|
887
902
|
var WrapAdornmentPriority = 1000;
|
|
888
903
|
exports.LabelType = void 0;
|
|
@@ -903,6 +918,7 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
903
918
|
var useIsVisible = useEvalVisibilityHook(useExpr, definition, schemaField);
|
|
904
919
|
var useIsReadonly = useEvalReadonlyHook(useExpr, definition);
|
|
905
920
|
var useIsDisabled = useEvalDisabledHook(useExpr, definition);
|
|
921
|
+
var useAllowedOptions = useEvalAllowedOptionsHook(useExpr, definition);
|
|
906
922
|
var useCustomStyle = useEvalStyleHook(useExpr, exports.DynamicPropertyType.Style, definition);
|
|
907
923
|
var useLayoutStyle = useEvalStyleHook(useExpr, exports.DynamicPropertyType.LayoutStyle, definition);
|
|
908
924
|
var useDynamicDisplay = useEvalDisplayHook(useExpr, definition);
|
|
@@ -951,23 +967,25 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
951
967
|
};
|
|
952
968
|
});
|
|
953
969
|
});
|
|
970
|
+
var allowedOptions = useAllowedOptions(dataContext);
|
|
954
971
|
var defaultValueControl = useDefaultValue(dataContext);
|
|
955
972
|
var _getControlData = getControlData(_schemaField, dataContext),
|
|
956
973
|
control = _getControlData[0],
|
|
957
974
|
childContext = _getControlData[1];
|
|
958
975
|
core.useControlEffect(function () {
|
|
959
|
-
return [visibility.value, defaultValueControl.value, control, parentControl.isNull];
|
|
976
|
+
return [visibility.value, defaultValueControl.value, control, parentControl.isNull, isDataControlDefinition(definition) && definition.dontClearHidden];
|
|
960
977
|
}, function (_ref2) {
|
|
961
978
|
var vc = _ref2[0],
|
|
962
979
|
dv = _ref2[1],
|
|
963
980
|
cd = _ref2[2],
|
|
964
|
-
pn = _ref2[3]
|
|
981
|
+
pn = _ref2[3],
|
|
982
|
+
dontClear = _ref2[4];
|
|
965
983
|
if (pn) {
|
|
966
984
|
parentControl.value = {};
|
|
967
985
|
}
|
|
968
986
|
if (vc && cd && vc.visible === vc.showing) {
|
|
969
987
|
if (!vc.visible) {
|
|
970
|
-
if (_options.clearHidden) cd.value = undefined;
|
|
988
|
+
if (_options.clearHidden && !dontClear) cd.value = undefined;
|
|
971
989
|
} else if (cd.value == null) {
|
|
972
990
|
cd.value = dv;
|
|
973
991
|
}
|
|
@@ -1010,7 +1028,8 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1010
1028
|
control: displayControl != null ? displayControl : control,
|
|
1011
1029
|
schemaField: _schemaField,
|
|
1012
1030
|
displayControl: displayControl,
|
|
1013
|
-
style: customStyle
|
|
1031
|
+
style: customStyle,
|
|
1032
|
+
allowedOptions: allowedOptions
|
|
1014
1033
|
});
|
|
1015
1034
|
var renderedControl = renderer.renderLayout(_extends({}, labelAndChildren, {
|
|
1016
1035
|
adornments: adornments,
|
|
@@ -1023,7 +1042,7 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1023
1042
|
} finally {
|
|
1024
1043
|
stopTracking();
|
|
1025
1044
|
}
|
|
1026
|
-
}, [r, dataProps, useIsVisible, useDefaultValue, useIsReadonly, useIsDisabled, useCustomStyle, useLayoutStyle, useDynamicDisplay, useValidation, renderer, schemaInterface]);
|
|
1045
|
+
}, [r, dataProps, useIsVisible, useDefaultValue, useIsReadonly, useIsDisabled, useCustomStyle, useLayoutStyle, useAllowedOptions, useDynamicDisplay, useValidation, renderer, schemaInterface]);
|
|
1027
1046
|
Component.displayName = "RenderControl";
|
|
1028
1047
|
return Component;
|
|
1029
1048
|
}
|
|
@@ -1040,40 +1059,7 @@ function getControlData(schemaField, parentContext) {
|
|
|
1040
1059
|
schemaInterface: parentContext.schemaInterface
|
|
1041
1060
|
} : parentContext];
|
|
1042
1061
|
}
|
|
1043
|
-
function
|
|
1044
|
-
var _arrayControl$element;
|
|
1045
|
-
var elems = (_arrayControl$element = arrayControl.elements) != null ? _arrayControl$element : [];
|
|
1046
|
-
return renderer.renderArray({
|
|
1047
|
-
arrayControl: arrayControl,
|
|
1048
|
-
childCount: elems.length,
|
|
1049
|
-
required: required,
|
|
1050
|
-
addAction: {
|
|
1051
|
-
actionId: "add",
|
|
1052
|
-
actionText: "Add " + noun,
|
|
1053
|
-
onClick: function onClick() {
|
|
1054
|
-
return core.addElement(arrayControl, elementValueForField(field));
|
|
1055
|
-
}
|
|
1056
|
-
},
|
|
1057
|
-
childKey: function childKey(i) {
|
|
1058
|
-
return elems[i].uniqueId;
|
|
1059
|
-
},
|
|
1060
|
-
removeAction: function removeAction(i) {
|
|
1061
|
-
return {
|
|
1062
|
-
actionId: "",
|
|
1063
|
-
actionText: "Remove",
|
|
1064
|
-
onClick: function onClick() {
|
|
1065
|
-
return core.removeElement(arrayControl, i);
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
1068
|
-
},
|
|
1069
|
-
renderChild: function renderChild(i) {
|
|
1070
|
-
return _renderChild(i, elems[i]);
|
|
1071
|
-
},
|
|
1072
|
-
className: cc(className),
|
|
1073
|
-
style: style
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
function groupProps(renderOptions, childCount, _renderChild2, control, className, style) {
|
|
1062
|
+
function groupProps(renderOptions, childCount, _renderChild, control, className, style) {
|
|
1077
1063
|
if (renderOptions === void 0) {
|
|
1078
1064
|
renderOptions = {
|
|
1079
1065
|
type: "Standard"
|
|
@@ -1082,7 +1068,7 @@ function groupProps(renderOptions, childCount, _renderChild2, control, className
|
|
|
1082
1068
|
return {
|
|
1083
1069
|
childCount: childCount,
|
|
1084
1070
|
renderChild: function renderChild(i) {
|
|
1085
|
-
return
|
|
1071
|
+
return _renderChild(i, i, {
|
|
1086
1072
|
control: control
|
|
1087
1073
|
});
|
|
1088
1074
|
},
|
|
@@ -1092,27 +1078,72 @@ function groupProps(renderOptions, childCount, _renderChild2, control, className
|
|
|
1092
1078
|
};
|
|
1093
1079
|
}
|
|
1094
1080
|
function defaultDataProps(_ref3) {
|
|
1095
|
-
var _field$options$length, _field$options, _definition$renderOpt;
|
|
1081
|
+
var _field$options$length, _field$options, _allowedOptions$value, _definition$renderOpt;
|
|
1096
1082
|
var definition = _ref3.definition,
|
|
1097
1083
|
field = _ref3.field,
|
|
1098
|
-
dataContext = _ref3.dataContext,
|
|
1099
1084
|
control = _ref3.control,
|
|
1100
1085
|
options = _ref3.options,
|
|
1101
|
-
|
|
1102
|
-
|
|
1086
|
+
elementRenderer = _ref3.elementRenderer,
|
|
1087
|
+
style = _ref3.style,
|
|
1088
|
+
allowedOptions = _ref3.allowedOptions,
|
|
1089
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded$1);
|
|
1090
|
+
var className = cc(definition.styleClass);
|
|
1091
|
+
var required = !!definition.required;
|
|
1092
|
+
var fieldOptions = ((_field$options$length = (_field$options = field.options) == null ? void 0 : _field$options.length) != null ? _field$options$length : 0) === 0 ? null : field.options;
|
|
1093
|
+
var allowed = (_allowedOptions$value = allowedOptions == null ? void 0 : allowedOptions.value) != null ? _allowedOptions$value : [];
|
|
1094
|
+
return _extends({
|
|
1103
1095
|
control: control,
|
|
1104
1096
|
field: field,
|
|
1105
1097
|
id: "c" + control.uniqueId,
|
|
1106
|
-
options:
|
|
1098
|
+
options: fieldOptions && allowed.length > 0 ? fieldOptions.filter(function (x) {
|
|
1099
|
+
return allowed.includes(x.value);
|
|
1100
|
+
}) : fieldOptions,
|
|
1107
1101
|
readonly: !!options.readonly,
|
|
1108
1102
|
renderOptions: (_definition$renderOpt = definition.renderOptions) != null ? _definition$renderOpt : {
|
|
1109
1103
|
type: "Standard"
|
|
1110
1104
|
},
|
|
1111
|
-
required:
|
|
1105
|
+
required: required,
|
|
1112
1106
|
hidden: !!options.hidden,
|
|
1113
|
-
className:
|
|
1114
|
-
style: style
|
|
1115
|
-
|
|
1107
|
+
className: className,
|
|
1108
|
+
style: style
|
|
1109
|
+
}, props, {
|
|
1110
|
+
toArrayProps: elementRenderer ? function () {
|
|
1111
|
+
return defaultArrayProps(control, field, required, style, className, elementRenderer);
|
|
1112
|
+
} : undefined
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
function defaultArrayProps(arrayControl, field, required, style, className, _renderElement) {
|
|
1116
|
+
var _field$displayName, _arrayControl$element;
|
|
1117
|
+
var noun = (_field$displayName = field.displayName) != null ? _field$displayName : field.field;
|
|
1118
|
+
var elems = (_arrayControl$element = arrayControl.elements) != null ? _arrayControl$element : [];
|
|
1119
|
+
return {
|
|
1120
|
+
arrayControl: arrayControl,
|
|
1121
|
+
elementCount: elems.length,
|
|
1122
|
+
required: required,
|
|
1123
|
+
addAction: {
|
|
1124
|
+
actionId: "add",
|
|
1125
|
+
actionText: "Add " + noun,
|
|
1126
|
+
onClick: function onClick() {
|
|
1127
|
+
return core.addElement(arrayControl, elementValueForField(field));
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
elementKey: function elementKey(i) {
|
|
1131
|
+
return elems[i].uniqueId;
|
|
1132
|
+
},
|
|
1133
|
+
removeAction: function removeAction(i) {
|
|
1134
|
+
return {
|
|
1135
|
+
actionId: "",
|
|
1136
|
+
actionText: "Remove",
|
|
1137
|
+
onClick: function onClick() {
|
|
1138
|
+
return core.removeElement(arrayControl, i);
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
},
|
|
1142
|
+
renderElement: function renderElement(i) {
|
|
1143
|
+
return _renderElement(elems[i]);
|
|
1144
|
+
},
|
|
1145
|
+
className: cc(className),
|
|
1146
|
+
style: style
|
|
1116
1147
|
};
|
|
1117
1148
|
}
|
|
1118
1149
|
function renderControlLayout(_ref4) {
|
|
@@ -1126,7 +1157,8 @@ function renderControlLayout(_ref4) {
|
|
|
1126
1157
|
dataOptions = _ref4.formOptions,
|
|
1127
1158
|
dataProps = _ref4.createDataProps,
|
|
1128
1159
|
displayControl = _ref4.displayControl,
|
|
1129
|
-
style = _ref4.style
|
|
1160
|
+
style = _ref4.style,
|
|
1161
|
+
allowedOptions = _ref4.allowedOptions;
|
|
1130
1162
|
if (isDataControlDefinition(c)) {
|
|
1131
1163
|
return renderData(c);
|
|
1132
1164
|
}
|
|
@@ -1172,44 +1204,27 @@ function renderControlLayout(_ref4) {
|
|
|
1172
1204
|
};
|
|
1173
1205
|
}
|
|
1174
1206
|
return {};
|
|
1175
|
-
function renderData(c) {
|
|
1207
|
+
function renderData(c, elementControl) {
|
|
1176
1208
|
if (!schemaField) return {
|
|
1177
1209
|
children: "No schema field for: " + c.field
|
|
1178
1210
|
};
|
|
1179
|
-
if (isCompoundField(schemaField)) {
|
|
1180
|
-
var label = {
|
|
1181
|
-
hide: c.hideTitle,
|
|
1182
|
-
label: controlTitle(c.title, schemaField),
|
|
1183
|
-
type: schemaField.collection ? exports.LabelType.Control : exports.LabelType.Group
|
|
1184
|
-
};
|
|
1185
|
-
if (schemaField.collection) {
|
|
1186
|
-
return {
|
|
1187
|
-
label: label,
|
|
1188
|
-
children: renderArray(renderer, controlTitle(c.title, schemaField), schemaField, !!c.required, childControl, compoundRenderer, c.styleClass, style),
|
|
1189
|
-
errorControl: childControl
|
|
1190
|
-
};
|
|
1191
|
-
}
|
|
1192
|
-
return {
|
|
1193
|
-
processLayout: renderer.renderGroup(groupProps({
|
|
1194
|
-
type: "Standard"
|
|
1195
|
-
}, childCount, childRenderer, childControl, c.styleClass, style)),
|
|
1196
|
-
label: label,
|
|
1197
|
-
errorControl: childControl
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
1211
|
var props = dataProps({
|
|
1201
1212
|
definition: c,
|
|
1202
1213
|
field: schemaField,
|
|
1203
1214
|
dataContext: dataContext,
|
|
1204
|
-
control: childControl,
|
|
1215
|
+
control: elementControl != null ? elementControl : childControl,
|
|
1205
1216
|
options: dataOptions,
|
|
1206
|
-
style: style
|
|
1217
|
+
style: style,
|
|
1218
|
+
childCount: childCount,
|
|
1219
|
+
allowedOptions: allowedOptions,
|
|
1220
|
+
renderChild: childRenderer,
|
|
1221
|
+
elementRenderer: elementControl == null && schemaField.collection ? function (element) {
|
|
1222
|
+
return renderLayoutParts(renderData(c, element), renderer).children;
|
|
1223
|
+
} : undefined
|
|
1207
1224
|
});
|
|
1208
1225
|
var labelText = !c.hideTitle ? controlTitle(c.title, schemaField) : undefined;
|
|
1209
1226
|
return {
|
|
1210
|
-
processLayout: renderer.renderData(props,
|
|
1211
|
-
return renderArray(renderer, controlTitle(c.title, schemaField), schemaField, !!c.required, childControl, scalarRenderer(props), c.styleClass, style);
|
|
1212
|
-
} : undefined),
|
|
1227
|
+
processLayout: renderer.renderData(props),
|
|
1213
1228
|
label: {
|
|
1214
1229
|
type: exports.LabelType.Control,
|
|
1215
1230
|
label: labelText,
|
|
@@ -1220,39 +1235,6 @@ function renderControlLayout(_ref4) {
|
|
|
1220
1235
|
errorControl: childControl
|
|
1221
1236
|
};
|
|
1222
1237
|
}
|
|
1223
|
-
function compoundRenderer(i, control) {
|
|
1224
|
-
var _renderer$renderLayou = renderer.renderLayout({
|
|
1225
|
-
processLayout: renderer.renderGroup({
|
|
1226
|
-
renderOptions: {
|
|
1227
|
-
type: "Standard",
|
|
1228
|
-
hideTitle: true
|
|
1229
|
-
},
|
|
1230
|
-
childCount: childCount,
|
|
1231
|
-
renderChild: function renderChild(ci) {
|
|
1232
|
-
return childRenderer(ci, ci, {
|
|
1233
|
-
control: control
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
})
|
|
1237
|
-
}),
|
|
1238
|
-
className = _renderer$renderLayou.className,
|
|
1239
|
-
style = _renderer$renderLayou.style,
|
|
1240
|
-
children = _renderer$renderLayou.children;
|
|
1241
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1242
|
-
key: control.uniqueId,
|
|
1243
|
-
style: style,
|
|
1244
|
-
className: cc(className)
|
|
1245
|
-
}, children);
|
|
1246
|
-
}
|
|
1247
|
-
function scalarRenderer(dataProps) {
|
|
1248
|
-
return function (i, control) {
|
|
1249
|
-
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, {
|
|
1250
|
-
key: control.uniqueId
|
|
1251
|
-
}, renderer.renderData(_extends({}, dataProps, {
|
|
1252
|
-
control: control
|
|
1253
|
-
}), undefined)({}).children);
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
1238
|
}
|
|
1257
1239
|
function appendMarkup(k, markup) {
|
|
1258
1240
|
return function (layout) {
|
|
@@ -1366,7 +1348,7 @@ function createFormRenderer(customRenderers, defaultRenderers) {
|
|
|
1366
1348
|
})) != null ? _labelRenderers$find : defaultRenderers.label;
|
|
1367
1349
|
return renderer.render(props, labelStart, labelEnd, formRenderers);
|
|
1368
1350
|
}
|
|
1369
|
-
function renderData(props
|
|
1351
|
+
function renderData(props) {
|
|
1370
1352
|
var _dataRegistrations$fi;
|
|
1371
1353
|
var renderType = props.renderOptions.type,
|
|
1372
1354
|
field = props.field;
|
|
@@ -1375,7 +1357,7 @@ function createFormRenderer(customRenderers, defaultRenderers) {
|
|
|
1375
1357
|
var _x$collection, _field$collection, _x$options;
|
|
1376
1358
|
return ((_x$collection = x.collection) != null ? _x$collection : false) === ((_field$collection = field.collection) != null ? _field$collection : false) && ((_x$options = x.options) != null ? _x$options : false) === options && isOneOf(x.schemaType, field.type) && isOneOf(x.renderType, renderType) && (!x.match || x.match(props));
|
|
1377
1359
|
})) != null ? _dataRegistrations$fi : defaultRenderers.data;
|
|
1378
|
-
var result = renderer.render(props,
|
|
1360
|
+
var result = renderer.render(props, formRenderers);
|
|
1379
1361
|
if (typeof result === "function") return result;
|
|
1380
1362
|
return function (l) {
|
|
1381
1363
|
return _extends({}, l, {
|
|
@@ -1460,29 +1442,29 @@ function createDefaultArrayRenderer(options) {
|
|
|
1460
1442
|
removeActionClass = _ref2.removeActionClass,
|
|
1461
1443
|
addActionClass = _ref2.addActionClass;
|
|
1462
1444
|
function render(_ref3, _ref4) {
|
|
1463
|
-
var
|
|
1464
|
-
|
|
1445
|
+
var elementCount = _ref3.elementCount,
|
|
1446
|
+
renderElement = _ref3.renderElement,
|
|
1465
1447
|
addAction = _ref3.addAction,
|
|
1466
1448
|
removeAction = _ref3.removeAction,
|
|
1467
|
-
|
|
1449
|
+
elementKey = _ref3.elementKey,
|
|
1468
1450
|
required = _ref3.required;
|
|
1469
1451
|
var renderAction = _ref4.renderAction;
|
|
1470
|
-
var showRemove = !required ||
|
|
1452
|
+
var showRemove = !required || elementCount > 1;
|
|
1471
1453
|
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1472
1454
|
className: clsx__default["default"](className, removeAction && removableClass)
|
|
1473
1455
|
}, Array.from({
|
|
1474
|
-
length:
|
|
1456
|
+
length: elementCount
|
|
1475
1457
|
}, function (_, x) {
|
|
1476
1458
|
return removeAction ? /*#__PURE__*/React__default["default"].createElement(React.Fragment, {
|
|
1477
|
-
key:
|
|
1459
|
+
key: elementKey(x)
|
|
1478
1460
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1479
1461
|
className: clsx__default["default"](childClass, removableChildClass)
|
|
1480
|
-
},
|
|
1462
|
+
}, renderElement(x)), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1481
1463
|
className: removeActionClass
|
|
1482
1464
|
}, showRemove && renderAction(removeAction(x)))) : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1483
|
-
key:
|
|
1465
|
+
key: elementKey(x),
|
|
1484
1466
|
className: childClass
|
|
1485
|
-
},
|
|
1467
|
+
}, renderElement(x));
|
|
1486
1468
|
})), addAction && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1487
1469
|
className: addActionClass
|
|
1488
1470
|
}, renderAction(addAction)));
|
|
@@ -1618,13 +1600,33 @@ function createDefaultDataRenderer(options) {
|
|
|
1618
1600
|
booleanOptions = _optionRenderer$boole.booleanOptions,
|
|
1619
1601
|
optionRenderer = _optionRenderer$boole.optionRenderer,
|
|
1620
1602
|
displayOnlyClass = _optionRenderer$boole.displayOnlyClass;
|
|
1621
|
-
return createDataRenderer(function (props,
|
|
1622
|
-
|
|
1623
|
-
|
|
1603
|
+
return createDataRenderer(function (props, renderers) {
|
|
1604
|
+
var fieldType = props.field.type;
|
|
1605
|
+
if (props.toArrayProps) {
|
|
1606
|
+
return function (p) {
|
|
1607
|
+
return _extends({}, p, {
|
|
1608
|
+
children: renderers.renderArray(props.toArrayProps())
|
|
1609
|
+
});
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
if (fieldType === exports.FieldType.Compound) {
|
|
1613
|
+
return renderers.renderGroup({
|
|
1614
|
+
style: props.style,
|
|
1615
|
+
className: props.className,
|
|
1616
|
+
renderOptions: {
|
|
1617
|
+
type: "Standard",
|
|
1618
|
+
hideTitle: true
|
|
1619
|
+
},
|
|
1620
|
+
renderChild: function renderChild(i) {
|
|
1621
|
+
return props.renderChild(i, i, {
|
|
1622
|
+
control: props.control
|
|
1623
|
+
});
|
|
1624
|
+
},
|
|
1625
|
+
childCount: props.childCount
|
|
1626
|
+
});
|
|
1624
1627
|
}
|
|
1625
1628
|
var renderOptions = props.renderOptions;
|
|
1626
1629
|
var renderType = renderOptions.type;
|
|
1627
|
-
var fieldType = props.field.type;
|
|
1628
1630
|
if (fieldType == exports.FieldType.Any) return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, "No control for Any");
|
|
1629
1631
|
if (isDisplayOnlyRenderer(renderOptions)) return function (p) {
|
|
1630
1632
|
return _extends({}, p, {
|
|
@@ -1643,14 +1645,14 @@ function createDefaultDataRenderer(options) {
|
|
|
1643
1645
|
if (booleanOptions != null && isBool && props.options == null) {
|
|
1644
1646
|
return renderers.renderData(_extends({}, props, {
|
|
1645
1647
|
options: booleanOptions
|
|
1646
|
-
})
|
|
1648
|
+
}));
|
|
1647
1649
|
}
|
|
1648
1650
|
if (renderType === exports.DataRenderType.Standard && hasOptions(props)) {
|
|
1649
|
-
return optionRenderer.render(props,
|
|
1651
|
+
return optionRenderer.render(props, renderers);
|
|
1650
1652
|
}
|
|
1651
1653
|
switch (renderType) {
|
|
1652
1654
|
case exports.DataRenderType.Dropdown:
|
|
1653
|
-
return selectRenderer.render(props,
|
|
1655
|
+
return selectRenderer.render(props, renderers);
|
|
1654
1656
|
}
|
|
1655
1657
|
return renderType === exports.DataRenderType.Checkbox ? /*#__PURE__*/React__default["default"].createElement(core.Fcheckbox, {
|
|
1656
1658
|
style: props.style,
|
|
@@ -2098,6 +2100,7 @@ exports.createSelectConversion = createSelectConversion;
|
|
|
2098
2100
|
exports.createSelectRenderer = createSelectRenderer;
|
|
2099
2101
|
exports.createVisibilityRenderer = createVisibilityRenderer;
|
|
2100
2102
|
exports.dataControl = dataControl;
|
|
2103
|
+
exports.defaultArrayProps = defaultArrayProps;
|
|
2101
2104
|
exports.defaultCompoundField = defaultCompoundField;
|
|
2102
2105
|
exports.defaultControlForField = defaultControlForField;
|
|
2103
2106
|
exports.defaultDataProps = defaultDataProps;
|
|
@@ -2122,6 +2125,7 @@ exports.fieldHasTag = fieldHasTag;
|
|
|
2122
2125
|
exports.findCompoundField = findCompoundField;
|
|
2123
2126
|
exports.findField = findField;
|
|
2124
2127
|
exports.findScalarField = findScalarField;
|
|
2128
|
+
exports.getAllReferencedClasses = getAllReferencedClasses;
|
|
2125
2129
|
exports.getControlData = getControlData;
|
|
2126
2130
|
exports.getDisplayOnlyOptions = getDisplayOnlyOptions;
|
|
2127
2131
|
exports.getTypeField = getTypeField;
|
|
@@ -2157,6 +2161,7 @@ exports.stringOptionsField = stringOptionsField;
|
|
|
2157
2161
|
exports.textDisplayControl = textDisplayControl;
|
|
2158
2162
|
exports.useControlDefinitionForSchema = useControlDefinitionForSchema;
|
|
2159
2163
|
exports.useControlRenderer = useControlRenderer;
|
|
2164
|
+
exports.useEvalAllowedOptionsHook = useEvalAllowedOptionsHook;
|
|
2160
2165
|
exports.useEvalDefaultValueHook = useEvalDefaultValueHook;
|
|
2161
2166
|
exports.useEvalDisabledHook = useEvalDisabledHook;
|
|
2162
2167
|
exports.useEvalDisplayHook = useEvalDisplayHook;
|