@react-typed-forms/schemas 11.4.0 → 11.5.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/index.js +29 -19
- package/lib/index.js.map +1 -1
- package/lib/util.d.ts +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ interface StyleProps {
|
|
|
22
22
|
}
|
|
23
23
|
interface DefaultActionRendererOptions {
|
|
24
24
|
className?: string;
|
|
25
|
+
renderContent?: (actionText: string, actionId: string, actionData: any) => ReactNode;
|
|
25
26
|
}
|
|
26
27
|
export declare function createButtonActionRenderer(actionId: string | string[] | undefined, options?: DefaultActionRendererOptions): ActionRendererRegistration;
|
|
27
28
|
interface DefaultGroupRendererOptions {
|
package/lib/index.js
CHANGED
|
@@ -234,7 +234,7 @@ function defaultValueForFields(fields) {
|
|
|
234
234
|
return [x.field, defaultValueForField(x)];
|
|
235
235
|
}));
|
|
236
236
|
}
|
|
237
|
-
function defaultValueForField(sf, required) {
|
|
237
|
+
function defaultValueForField(sf, required, forceNotNull) {
|
|
238
238
|
if (sf.defaultValue !== undefined) return sf.defaultValue;
|
|
239
239
|
var isRequired = !!(required || sf.required);
|
|
240
240
|
if (isCompoundField(sf)) {
|
|
@@ -242,7 +242,7 @@ function defaultValueForField(sf, required) {
|
|
|
242
242
|
var childValue = defaultValueForFields(sf.children);
|
|
243
243
|
return sf.collection ? [childValue] : childValue;
|
|
244
244
|
}
|
|
245
|
-
return sf.notNullable ? sf.collection ? [] : {} : undefined;
|
|
245
|
+
return sf.notNullable || forceNotNull ? sf.collection ? [] : {} : undefined;
|
|
246
246
|
}
|
|
247
247
|
if (sf.collection) {
|
|
248
248
|
return [];
|
|
@@ -988,7 +988,7 @@ function useEvalDefaultValueHook(useEvalExpressionHook, definition, schemaField,
|
|
|
988
988
|
var _ref4 = isDataControlDefinition(definition) ? [definition.required, definition.defaultValue] : [false, undefined],
|
|
989
989
|
required = _ref4[0],
|
|
990
990
|
dcv = _ref4[1];
|
|
991
|
-
return dcv != null ? dcv : schemaField ? element ? elementValueForField(schemaField) : defaultValueForField(schemaField, required) : undefined;
|
|
991
|
+
return dcv != null ? dcv : schemaField ? element ? elementValueForField(schemaField) : defaultValueForField(schemaField, required, true) : undefined;
|
|
992
992
|
}
|
|
993
993
|
}, {
|
|
994
994
|
definition: definition,
|
|
@@ -1387,28 +1387,32 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1387
1387
|
control = _getControlData[1],
|
|
1388
1388
|
controlDataContext = _getControlData[2];
|
|
1389
1389
|
core.useControlEffect(function () {
|
|
1390
|
-
return [visibility.value, defaultValueControl.value, control, isDataControlDefinition(definition) && definition.dontClearHidden, parentControl.isNull, _options.hidden];
|
|
1390
|
+
return [visibility.value, defaultValueControl.value, control == null ? void 0 : control.isNull, isDataControlDefinition(definition) && definition.dontClearHidden, parentControl.isNull, _options.hidden, readonlyControl.value];
|
|
1391
1391
|
}, function (_ref2) {
|
|
1392
1392
|
var vc = _ref2[0],
|
|
1393
1393
|
dv = _ref2[1],
|
|
1394
|
-
|
|
1394
|
+
_ = _ref2[2],
|
|
1395
1395
|
dontClear = _ref2[3],
|
|
1396
1396
|
parentNull = _ref2[4],
|
|
1397
|
-
hidden = _ref2[5]
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1397
|
+
hidden = _ref2[5],
|
|
1398
|
+
ro = _ref2[6];
|
|
1399
|
+
if (!ro) {
|
|
1400
|
+
if (control) {
|
|
1401
|
+
if (vc && vc.visible === vc.showing) {
|
|
1402
|
+
if (hidden || !vc.visible) {
|
|
1403
|
+
if (_options.clearHidden && !dontClear) {
|
|
1404
|
+
control.value = undefined;
|
|
1405
|
+
}
|
|
1406
|
+
} else control.setValue(function (x) {
|
|
1407
|
+
return x ? x : dv;
|
|
1408
|
+
});
|
|
1402
1409
|
}
|
|
1403
|
-
} else if (
|
|
1404
|
-
|
|
1410
|
+
} else if (parentNull) {
|
|
1411
|
+
parentControl.setValue(function (x) {
|
|
1412
|
+
return x != null ? x : {};
|
|
1413
|
+
});
|
|
1405
1414
|
}
|
|
1406
1415
|
}
|
|
1407
|
-
if (parentNull) {
|
|
1408
|
-
parentControl.setValue(function (x) {
|
|
1409
|
-
return x != null ? x : {};
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
1416
|
}, true);
|
|
1413
1417
|
var myOptions = core.useCalculatedControl(function () {
|
|
1414
1418
|
var _visibility$fields;
|
|
@@ -1436,6 +1440,9 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1436
1440
|
renderer: renderer,
|
|
1437
1441
|
renderChild: function renderChild(k, child, options) {
|
|
1438
1442
|
var _options$dataContext;
|
|
1443
|
+
if (control && control.isNull) return /*#__PURE__*/React__default["default"].createElement(React.Fragment, {
|
|
1444
|
+
key: k
|
|
1445
|
+
});
|
|
1439
1446
|
var dataContext = (_options$dataContext = options == null ? void 0 : options.dataContext) != null ? _options$dataContext : controlDataContext;
|
|
1440
1447
|
return /*#__PURE__*/React__default["default"].createElement(ControlRenderer, {
|
|
1441
1448
|
key: k,
|
|
@@ -2352,15 +2359,18 @@ function createButtonActionRenderer(actionId, options) {
|
|
|
2352
2359
|
options = {};
|
|
2353
2360
|
}
|
|
2354
2361
|
return createActionRenderer(actionId, function (_ref) {
|
|
2362
|
+
var _options$renderConten;
|
|
2355
2363
|
var onClick = _ref.onClick,
|
|
2356
2364
|
actionText = _ref.actionText,
|
|
2357
2365
|
className = _ref.className,
|
|
2358
|
-
style = _ref.style
|
|
2366
|
+
style = _ref.style,
|
|
2367
|
+
actionId = _ref.actionId,
|
|
2368
|
+
actionData = _ref.actionData;
|
|
2359
2369
|
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
2360
2370
|
className: rendererClass(className, options.className),
|
|
2361
2371
|
style: style,
|
|
2362
2372
|
onClick: onClick
|
|
2363
|
-
}, actionText);
|
|
2373
|
+
}, (_options$renderConten = options.renderContent == null ? void 0 : options.renderContent(actionText, actionId, actionData)) != null ? _options$renderConten : actionText);
|
|
2364
2374
|
});
|
|
2365
2375
|
}
|
|
2366
2376
|
function createDefaultGroupRenderer(options) {
|