@react-typed-forms/schemas 11.11.0 → 11.12.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/lib/createDefaultRenderers.d.ts +1 -0
- package/lib/hooks.d.ts +1 -1
- package/lib/index.js +112 -29
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +11 -3
- package/package.json +1 -1
|
@@ -70,5 +70,6 @@ interface DefaultLabelRendererOptions {
|
|
|
70
70
|
labelContainer?: (children: ReactElement) => ReactElement;
|
|
71
71
|
}
|
|
72
72
|
export declare function createDefaultLabelRenderer(options?: DefaultLabelRendererOptions): LabelRendererRegistration;
|
|
73
|
+
export declare function createNullToggleRenderer(): DataRendererRegistration;
|
|
73
74
|
export declare function createDefaultRenderers(options?: DefaultRendererOptions): DefaultRenderers;
|
|
74
75
|
export {};
|
package/lib/hooks.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpr
|
|
|
8
8
|
export declare function useEvalReadonlyHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
9
9
|
export declare function useEvalStyleHook(useEvalExpressionHook: UseEvalExpressionHook, property: DynamicPropertyType, definition: ControlDefinition): EvalExpressionHook<React.CSSProperties>;
|
|
10
10
|
export declare function useEvalAllowedOptionsHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<any[]>;
|
|
11
|
-
export declare function useEvalDisabledHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
11
|
+
export declare function useEvalDisabledHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, fieldPath?: SchemaField[]): EvalExpressionHook<boolean>;
|
|
12
12
|
export declare function useEvalDisplayHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): DynamicHookGenerator<Control<string | undefined> | undefined, ControlDataContext>;
|
|
13
13
|
export declare function useEvalDefaultValueHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField: SchemaField | undefined, element: boolean): EvalExpressionHook;
|
|
14
14
|
export declare function defaultEvalHooks(expr: EntityExpression, context: ControlDataContext, coerce: (v: any) => any): Control<any>;
|
package/lib/index.js
CHANGED
|
@@ -29,6 +29,8 @@ exports.ValidationMessageType = void 0;
|
|
|
29
29
|
ValidationMessageType["NotEmpty"] = "NotEmpty";
|
|
30
30
|
ValidationMessageType["MinLength"] = "MinLength";
|
|
31
31
|
ValidationMessageType["MaxLength"] = "MaxLength";
|
|
32
|
+
ValidationMessageType["NotAfterDate"] = "NotAfterDate";
|
|
33
|
+
ValidationMessageType["NotBeforeDate"] = "NotBeforeDate";
|
|
32
34
|
})(exports.ValidationMessageType || (exports.ValidationMessageType = {}));
|
|
33
35
|
exports.ControlDefinitionType = void 0;
|
|
34
36
|
(function (ControlDefinitionType) {
|
|
@@ -56,6 +58,7 @@ exports.ExpressionType = void 0;
|
|
|
56
58
|
ExpressionType["Data"] = "Data";
|
|
57
59
|
ExpressionType["DataMatch"] = "FieldValue";
|
|
58
60
|
ExpressionType["UserMatch"] = "UserMatch";
|
|
61
|
+
ExpressionType["NotEmpty"] = "NotEmpty";
|
|
59
62
|
})(exports.ExpressionType || (exports.ExpressionType = {}));
|
|
60
63
|
exports.AdornmentPlacement = void 0;
|
|
61
64
|
(function (AdornmentPlacement) {
|
|
@@ -87,6 +90,7 @@ exports.DataRenderType = void 0;
|
|
|
87
90
|
DataRenderType["Dropdown"] = "Dropdown";
|
|
88
91
|
DataRenderType["DisplayOnly"] = "DisplayOnly";
|
|
89
92
|
DataRenderType["Group"] = "Group";
|
|
93
|
+
DataRenderType["NullToggle"] = "NullToggle";
|
|
90
94
|
})(exports.DataRenderType || (exports.DataRenderType = {}));
|
|
91
95
|
exports.SyncTextType = void 0;
|
|
92
96
|
(function (SyncTextType) {
|
|
@@ -195,7 +199,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
195
199
|
if (null == r) return {};
|
|
196
200
|
var t = {};
|
|
197
201
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
198
|
-
if (e.
|
|
202
|
+
if (e.includes(n)) continue;
|
|
199
203
|
t[n] = r[n];
|
|
200
204
|
}
|
|
201
205
|
return t;
|
|
@@ -996,27 +1000,33 @@ function useEvalAllowedOptionsHook(useEvalExpressionHook, definition) {
|
|
|
996
1000
|
return core.useControl([]);
|
|
997
1001
|
}, undefined);
|
|
998
1002
|
}
|
|
999
|
-
function useEvalDisabledHook(useEvalExpressionHook, definition) {
|
|
1003
|
+
function useEvalDisabledHook(useEvalExpressionHook, definition, fieldPath) {
|
|
1000
1004
|
var dynamicDisabled = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Disabled, useEvalExpressionHook);
|
|
1001
|
-
return makeDynamicPropertyHook(dynamicDisabled, function () {
|
|
1005
|
+
return makeDynamicPropertyHook(dynamicDisabled, function (ctx, _ref3) {
|
|
1006
|
+
var fieldPath = _ref3.fieldPath;
|
|
1002
1007
|
return core.useComputed(function () {
|
|
1003
|
-
|
|
1008
|
+
var _dataControl$meta$nul;
|
|
1009
|
+
var dataControl = fieldPath && lookupChildControl(ctx, fieldPath);
|
|
1010
|
+
var setToNull = (dataControl == null || (_dataControl$meta$nul = dataControl.meta["nullControl"]) == null ? void 0 : _dataControl$meta$nul.value) === false;
|
|
1011
|
+
return setToNull || isControlDisabled(definition);
|
|
1004
1012
|
});
|
|
1005
|
-
},
|
|
1013
|
+
}, {
|
|
1014
|
+
fieldPath: fieldPath
|
|
1015
|
+
});
|
|
1006
1016
|
}
|
|
1007
1017
|
function useEvalDisplayHook(useEvalExpressionHook, definition) {
|
|
1008
1018
|
return useEvalDynamicHook(definition, exports.DynamicPropertyType.Display, useEvalExpressionHook);
|
|
1009
1019
|
}
|
|
1010
1020
|
function useEvalDefaultValueHook(useEvalExpressionHook, definition, schemaField, element) {
|
|
1011
1021
|
var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.DefaultValue, useEvalExpressionHook);
|
|
1012
|
-
return makeDynamicPropertyHook(dynamicValue, function (ctx,
|
|
1013
|
-
var definition =
|
|
1014
|
-
schemaField =
|
|
1022
|
+
return makeDynamicPropertyHook(dynamicValue, function (ctx, _ref4) {
|
|
1023
|
+
var definition = _ref4.definition,
|
|
1024
|
+
schemaField = _ref4.schemaField;
|
|
1015
1025
|
return core.useComputed(calcDefault);
|
|
1016
1026
|
function calcDefault() {
|
|
1017
|
-
var
|
|
1018
|
-
required =
|
|
1019
|
-
dcv =
|
|
1027
|
+
var _ref5 = isDataControlDefinition(definition) ? [definition.required, definition.defaultValue] : [false, undefined],
|
|
1028
|
+
required = _ref5[0],
|
|
1029
|
+
dcv = _ref5[1];
|
|
1020
1030
|
return dcv != null ? dcv : schemaField ? element ? elementValueForField(schemaField) : defaultValueForField(schemaField, required, true) : undefined;
|
|
1021
1031
|
}
|
|
1022
1032
|
}, {
|
|
@@ -1049,6 +1059,20 @@ function useDataMatchExpression(fvExpr, fields, data, coerce) {
|
|
|
1049
1059
|
return coerce(Array.isArray(fv) ? fv.includes(fvExpr.value) : fv === fvExpr.value);
|
|
1050
1060
|
});
|
|
1051
1061
|
}
|
|
1062
|
+
function useNotEmptyExpression(fvExpr, fields, schemaInterface, data, coerce) {
|
|
1063
|
+
if (coerce === void 0) {
|
|
1064
|
+
coerce = function coerce(x) {
|
|
1065
|
+
return x;
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
var refField = findFieldPath(fields, fvExpr.field);
|
|
1069
|
+
var otherField = refField ? lookupChildControl(data, refField) : undefined;
|
|
1070
|
+
return core.useCalculatedControl(function () {
|
|
1071
|
+
var fv = otherField == null ? void 0 : otherField.value;
|
|
1072
|
+
var field = refField == null ? void 0 : refField.at(-1);
|
|
1073
|
+
return coerce(field && !schemaInterface.isEmptyValue(field, fv));
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1052
1076
|
function defaultEvalHooks(expr, context, coerce) {
|
|
1053
1077
|
switch (expr.type) {
|
|
1054
1078
|
case exports.ExpressionType.Jsonata:
|
|
@@ -1057,6 +1081,8 @@ function defaultEvalHooks(expr, context, coerce) {
|
|
|
1057
1081
|
return useDataExpression(expr, context.fields, context, coerce);
|
|
1058
1082
|
case exports.ExpressionType.DataMatch:
|
|
1059
1083
|
return useDataMatchExpression(expr, context.fields, context, coerce);
|
|
1084
|
+
case exports.ExpressionType.NotEmpty:
|
|
1085
|
+
return useNotEmptyExpression(expr, context.fields, context.schemaInterface, context, coerce);
|
|
1060
1086
|
default:
|
|
1061
1087
|
return core.useControl(undefined);
|
|
1062
1088
|
}
|
|
@@ -1282,7 +1308,7 @@ function useDateValidator(dv, ctx) {
|
|
|
1282
1308
|
schemaInterface = ctx.dataContext.schemaInterface;
|
|
1283
1309
|
var comparisonDate;
|
|
1284
1310
|
if (dv.fixedDate) {
|
|
1285
|
-
comparisonDate =
|
|
1311
|
+
comparisonDate = schemaInterface.parseToMillis(field, dv.fixedDate);
|
|
1286
1312
|
} else {
|
|
1287
1313
|
var nowDate = new Date();
|
|
1288
1314
|
comparisonDate = Date.UTC(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate());
|
|
@@ -1295,7 +1321,7 @@ function useDateValidator(dv, ctx) {
|
|
|
1295
1321
|
var selDate = schemaInterface.parseToMillis(field, v);
|
|
1296
1322
|
var notAfter = dv.comparison === exports.DateComparison.NotAfter;
|
|
1297
1323
|
if (notAfter ? selDate > comparisonDate : selDate < comparisonDate) {
|
|
1298
|
-
return
|
|
1324
|
+
return schemaInterface.validationMessageText(field, notAfter ? exports.ValidationMessageType.NotAfterDate : exports.ValidationMessageType.NotBeforeDate, selDate, comparisonDate);
|
|
1299
1325
|
}
|
|
1300
1326
|
}
|
|
1301
1327
|
return null;
|
|
@@ -1326,6 +1352,10 @@ var DefaultSchemaInterface = /*#__PURE__*/function () {
|
|
|
1326
1352
|
return "Length must be at least " + expected;
|
|
1327
1353
|
case exports.ValidationMessageType.MaxLength:
|
|
1328
1354
|
return "Length must be less than " + expected;
|
|
1355
|
+
case exports.ValidationMessageType.NotBeforeDate:
|
|
1356
|
+
return "Date must not be before " + new Date(expected).toDateString();
|
|
1357
|
+
case exports.ValidationMessageType.NotAfterDate:
|
|
1358
|
+
return "Date must not be after " + new Date(expected).toDateString();
|
|
1329
1359
|
default:
|
|
1330
1360
|
return "Unknown error";
|
|
1331
1361
|
}
|
|
@@ -1367,7 +1397,7 @@ var DefaultSchemaInterface = /*#__PURE__*/function () {
|
|
|
1367
1397
|
}();
|
|
1368
1398
|
var defaultSchemaInterface = new DefaultSchemaInterface();
|
|
1369
1399
|
|
|
1370
|
-
var _excluded$
|
|
1400
|
+
var _excluded$4 = ["definition", "field", "control", "formOptions", "style", "allowedOptions", "schemaInterface"];
|
|
1371
1401
|
var AppendAdornmentPriority = 0;
|
|
1372
1402
|
var WrapAdornmentPriority = 1000;
|
|
1373
1403
|
exports.LabelType = void 0;
|
|
@@ -1392,7 +1422,7 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1392
1422
|
defaultValueControl: useEvalDefaultValueHook(useExpr, definition, schemaField, elementIndex != null),
|
|
1393
1423
|
visibleControl: useEvalVisibilityHook(useExpr, definition, fieldPath),
|
|
1394
1424
|
readonlyControl: useEvalReadonlyHook(useExpr, definition),
|
|
1395
|
-
disabledControl: useEvalDisabledHook(useExpr, definition),
|
|
1425
|
+
disabledControl: useEvalDisabledHook(useExpr, definition, fieldPath),
|
|
1396
1426
|
allowedOptions: useEvalAllowedOptionsHook(useExpr, definition),
|
|
1397
1427
|
labelText: useEvalLabelText(useExpr, definition),
|
|
1398
1428
|
actionData: useEvalActionHook(useExpr, definition),
|
|
@@ -1460,15 +1490,17 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1460
1490
|
control = _getControlData[1],
|
|
1461
1491
|
controlDataContext = _getControlData[2];
|
|
1462
1492
|
core.useControlEffect(function () {
|
|
1463
|
-
|
|
1493
|
+
var _definition$renderOpt;
|
|
1494
|
+
return [visibility.value, defaultValueControl.value, control == null ? void 0 : control.isNull, isDataControlDefinition(definition) && definition.dontClearHidden, isDataControlDefinition(definition) && ((_definition$renderOpt = definition.renderOptions) == null ? void 0 : _definition$renderOpt.type) == exports.DataRenderType.NullToggle, parentControl.isNull, _options.hidden, readonlyControl.value];
|
|
1464
1495
|
}, function (_ref2) {
|
|
1465
1496
|
var vc = _ref2[0],
|
|
1466
1497
|
dv = _ref2[1],
|
|
1467
1498
|
_ = _ref2[2],
|
|
1468
1499
|
dontClear = _ref2[3],
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1500
|
+
dontDefault = _ref2[4],
|
|
1501
|
+
parentNull = _ref2[5],
|
|
1502
|
+
hidden = _ref2[6],
|
|
1503
|
+
ro = _ref2[7];
|
|
1472
1504
|
if (!ro) {
|
|
1473
1505
|
if (control) {
|
|
1474
1506
|
if (vc && vc.visible === vc.showing) {
|
|
@@ -1476,7 +1508,7 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1476
1508
|
if (_options.clearHidden && !dontClear) {
|
|
1477
1509
|
control.value = undefined;
|
|
1478
1510
|
}
|
|
1479
|
-
} else control.setValue(function (x) {
|
|
1511
|
+
} else if (!dontDefault) control.setValue(function (x) {
|
|
1480
1512
|
return x != null ? x : dv;
|
|
1481
1513
|
});
|
|
1482
1514
|
}
|
|
@@ -1629,7 +1661,7 @@ function ControlRenderer(_ref3) {
|
|
|
1629
1661
|
}
|
|
1630
1662
|
}
|
|
1631
1663
|
function defaultDataProps(_ref4) {
|
|
1632
|
-
var _definition$validator, _allowedOptions$value, _definition$children, _definition$
|
|
1664
|
+
var _definition$validator, _allowedOptions$value, _definition$children, _definition$renderOpt2;
|
|
1633
1665
|
var definition = _ref4.definition,
|
|
1634
1666
|
field = _ref4.field,
|
|
1635
1667
|
control = _ref4.control,
|
|
@@ -1638,7 +1670,7 @@ function defaultDataProps(_ref4) {
|
|
|
1638
1670
|
allowedOptions = _ref4.allowedOptions,
|
|
1639
1671
|
_ref4$schemaInterface = _ref4.schemaInterface,
|
|
1640
1672
|
schemaInterface = _ref4$schemaInterface === void 0 ? defaultSchemaInterface : _ref4$schemaInterface,
|
|
1641
|
-
props = _objectWithoutPropertiesLoose(_ref4, _excluded$
|
|
1673
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded$4);
|
|
1642
1674
|
var lengthVal = (_definition$validator = definition.validators) == null ? void 0 : _definition$validator.find(function (x) {
|
|
1643
1675
|
return x.type === exports.ValidatorType.Length;
|
|
1644
1676
|
});
|
|
@@ -1663,7 +1695,7 @@ function defaultDataProps(_ref4) {
|
|
|
1663
1695
|
};
|
|
1664
1696
|
}) : fieldOptions,
|
|
1665
1697
|
readonly: !!formOptions.readonly,
|
|
1666
|
-
renderOptions: (_definition$
|
|
1698
|
+
renderOptions: (_definition$renderOpt2 = definition.renderOptions) != null ? _definition$renderOpt2 : {
|
|
1667
1699
|
type: "Standard"
|
|
1668
1700
|
},
|
|
1669
1701
|
required: required,
|
|
@@ -2009,7 +2041,7 @@ var defaultTailwindTheme = {
|
|
|
2009
2041
|
}
|
|
2010
2042
|
};
|
|
2011
2043
|
|
|
2012
|
-
var _excluded$
|
|
2044
|
+
var _excluded$3 = ["data", "display", "className", "style"];
|
|
2013
2045
|
function createDefaultDisplayRenderer(options) {
|
|
2014
2046
|
if (options === void 0) {
|
|
2015
2047
|
options = {};
|
|
@@ -2029,7 +2061,7 @@ function DefaultDisplay(_ref) {
|
|
|
2029
2061
|
display = _ref.display,
|
|
2030
2062
|
className = _ref.className,
|
|
2031
2063
|
style = _ref.style,
|
|
2032
|
-
options = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
2064
|
+
options = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
2033
2065
|
switch (data.type) {
|
|
2034
2066
|
case exports.DisplayDataType.Icon:
|
|
2035
2067
|
return /*#__PURE__*/React__default["default"].createElement("i", {
|
|
@@ -2115,7 +2147,7 @@ function DefaultVisibility(_ref) {
|
|
|
2115
2147
|
}
|
|
2116
2148
|
}
|
|
2117
2149
|
|
|
2118
|
-
var _excluded$
|
|
2150
|
+
var _excluded$2 = ["state", "options", "className", "convert", "required", "emptyText", "requiredText", "readonly"];
|
|
2119
2151
|
function createSelectRenderer(options) {
|
|
2120
2152
|
if (options === void 0) {
|
|
2121
2153
|
options = {};
|
|
@@ -2150,7 +2182,7 @@ function SelectDataRenderer(_ref) {
|
|
|
2150
2182
|
_ref$requiredText = _ref.requiredText,
|
|
2151
2183
|
requiredText = _ref$requiredText === void 0 ? "<please select>" : _ref$requiredText,
|
|
2152
2184
|
readonly = _ref.readonly,
|
|
2153
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
2185
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
2154
2186
|
var value = state.value,
|
|
2155
2187
|
disabled = state.disabled;
|
|
2156
2188
|
var _useState = React.useState(!required || value == null),
|
|
@@ -2217,7 +2249,7 @@ function DefaultDisplayOnly(_ref) {
|
|
|
2217
2249
|
}
|
|
2218
2250
|
}
|
|
2219
2251
|
|
|
2220
|
-
var _excluded = ["control", "convert"],
|
|
2252
|
+
var _excluded$1 = ["control", "convert"],
|
|
2221
2253
|
_excluded2 = ["errorText", "value", "onChange"];
|
|
2222
2254
|
function ControlInput(_ref) {
|
|
2223
2255
|
var _effect = core.useComponentTracking();
|
|
@@ -2227,7 +2259,7 @@ function ControlInput(_ref) {
|
|
|
2227
2259
|
};
|
|
2228
2260
|
var control = _ref.control,
|
|
2229
2261
|
convert = _ref.convert,
|
|
2230
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
2262
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
2231
2263
|
var _formControlProps = core.formControlProps(control),
|
|
2232
2264
|
errorText = _formControlProps.errorText,
|
|
2233
2265
|
value = _formControlProps.value,
|
|
@@ -2528,6 +2560,7 @@ function DefaultAccordion(_ref) {
|
|
|
2528
2560
|
}
|
|
2529
2561
|
}
|
|
2530
2562
|
|
|
2563
|
+
var _excluded = ["control", "field", "renderOptions"];
|
|
2531
2564
|
function createButtonActionRenderer(actionId, options) {
|
|
2532
2565
|
if (options === void 0) {
|
|
2533
2566
|
options = {};
|
|
@@ -2616,6 +2649,7 @@ function createDefaultDataRenderer(options) {
|
|
|
2616
2649
|
if (options === void 0) {
|
|
2617
2650
|
options = {};
|
|
2618
2651
|
}
|
|
2652
|
+
var nullToggler = createNullToggleRenderer();
|
|
2619
2653
|
var checkboxRenderer = createCheckboxRenderer((_options$checkOptions = options.checkOptions) != null ? _options$checkOptions : options.checkboxOptions);
|
|
2620
2654
|
var selectRenderer = createSelectRenderer(options.selectOptions);
|
|
2621
2655
|
var radioRenderer = createRadioRenderer((_options$radioOptions = options.radioOptions) != null ? _options$radioOptions : options.checkOptions);
|
|
@@ -2673,6 +2707,8 @@ function createDefaultDataRenderer(options) {
|
|
|
2673
2707
|
return optionRenderer.render(props, renderers);
|
|
2674
2708
|
}
|
|
2675
2709
|
switch (renderType) {
|
|
2710
|
+
case exports.DataRenderType.NullToggle:
|
|
2711
|
+
return nullToggler.render(props, renderers);
|
|
2676
2712
|
case exports.DataRenderType.CheckList:
|
|
2677
2713
|
return checkListRenderer.render(props, renderers);
|
|
2678
2714
|
case exports.DataRenderType.Dropdown:
|
|
@@ -2773,6 +2809,52 @@ function createDefaultLabelRenderer(options) {
|
|
|
2773
2809
|
type: "label"
|
|
2774
2810
|
};
|
|
2775
2811
|
}
|
|
2812
|
+
function createNullToggleRenderer() {
|
|
2813
|
+
return createDataRenderer(function (_ref7, renderers) {
|
|
2814
|
+
var _control$meta, _nullControl, _control$meta$_nullCo;
|
|
2815
|
+
var control = _ref7.control,
|
|
2816
|
+
field = _ref7.field,
|
|
2817
|
+
props = _objectWithoutPropertiesLoose(_ref7, _excluded);
|
|
2818
|
+
var nullControl = (_control$meta$_nullCo = (_control$meta = control.meta)[_nullControl = "nullControl"]) != null ? _control$meta$_nullCo : _control$meta[_nullControl] = core.newControl(control.current.value != null);
|
|
2819
|
+
return function (layout) {
|
|
2820
|
+
var newLayout = renderers.renderData(_extends({}, props, {
|
|
2821
|
+
control: nullControl,
|
|
2822
|
+
field: _extends({}, field, {
|
|
2823
|
+
type: exports.FieldType.Bool
|
|
2824
|
+
}),
|
|
2825
|
+
renderOptions: {
|
|
2826
|
+
type: exports.DataRenderType.Checkbox
|
|
2827
|
+
}
|
|
2828
|
+
}))(layout);
|
|
2829
|
+
return _extends({}, newLayout, {
|
|
2830
|
+
children: /*#__PURE__*/React__default["default"].createElement(NullWrapper, {
|
|
2831
|
+
control: control,
|
|
2832
|
+
nullControl: nullControl,
|
|
2833
|
+
children: newLayout.children,
|
|
2834
|
+
defaultValue: props.definition.defaultValue
|
|
2835
|
+
})
|
|
2836
|
+
});
|
|
2837
|
+
};
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
function NullWrapper(_ref8) {
|
|
2841
|
+
var children = _ref8.children,
|
|
2842
|
+
nullControl = _ref8.nullControl,
|
|
2843
|
+
control = _ref8.control,
|
|
2844
|
+
defaultValue = _ref8.defaultValue;
|
|
2845
|
+
core.useControlEffect(function () {
|
|
2846
|
+
return nullControl.value;
|
|
2847
|
+
}, function (e) {
|
|
2848
|
+
if (e) {
|
|
2849
|
+
var _nullControl$meta$non;
|
|
2850
|
+
control.value = (_nullControl$meta$non = nullControl.meta["nonNullValue"]) != null ? _nullControl$meta$non : defaultValue;
|
|
2851
|
+
} else {
|
|
2852
|
+
nullControl.meta["nonNullValue"] = control.value;
|
|
2853
|
+
control.value = null;
|
|
2854
|
+
}
|
|
2855
|
+
});
|
|
2856
|
+
return children;
|
|
2857
|
+
}
|
|
2776
2858
|
function createDefaultRenderers(options) {
|
|
2777
2859
|
if (options === void 0) {
|
|
2778
2860
|
options = {};
|
|
@@ -3002,6 +3084,7 @@ exports.createGroupRenderer = createGroupRenderer;
|
|
|
3002
3084
|
exports.createInputConversion = createInputConversion;
|
|
3003
3085
|
exports.createLabelRenderer = createLabelRenderer;
|
|
3004
3086
|
exports.createLayoutRenderer = createLayoutRenderer;
|
|
3087
|
+
exports.createNullToggleRenderer = createNullToggleRenderer;
|
|
3005
3088
|
exports.createRadioRenderer = createRadioRenderer;
|
|
3006
3089
|
exports.createSelectConversion = createSelectConversion;
|
|
3007
3090
|
exports.createSelectRenderer = createSelectRenderer;
|