@react-typed-forms/schemas 11.13.4 → 11.14.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/hooks.d.ts +1 -0
- package/lib/index.js +18 -3
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +2 -1
- package/package.json +3 -1
package/lib/hooks.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare function useEvalDynamicBoolHook(definition: ControlDefinition, ty
|
|
|
18
18
|
export declare function useEvalDynamicHook(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: UseEvalExpressionHook, coerce?: (v: any) => any): DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
|
|
19
19
|
export declare function matchesType(context: ControlDataContext, fieldPath?: SchemaField[]): boolean | undefined;
|
|
20
20
|
export declare function hideDisplayOnly(context: ControlDataContext, fieldPath: SchemaField[], definition: ControlDefinition, schemaInterface: SchemaInterface): boolean | undefined;
|
|
21
|
+
export declare function useUuidExpression(coerce?: (v: any) => any): Control<any>;
|
|
21
22
|
export declare function useJsonataExpression(jExpr: string, dataContext: DataContext, bindings?: () => Record<string, any>, coerce?: (v: any) => any): Control<any>;
|
|
22
23
|
export declare function useEvalActionHook(useExpr: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<string | null>;
|
|
23
24
|
export declare function useEvalLabelText(useExpr: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<string | null>;
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@ var React = require('react');
|
|
|
2
2
|
var core = require('@react-typed-forms/core');
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var jsonata = require('jsonata');
|
|
5
|
+
var uuid = require('uuid');
|
|
5
6
|
|
|
6
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
8
|
|
|
@@ -59,6 +60,7 @@ exports.ExpressionType = void 0;
|
|
|
59
60
|
ExpressionType["DataMatch"] = "FieldValue";
|
|
60
61
|
ExpressionType["UserMatch"] = "UserMatch";
|
|
61
62
|
ExpressionType["NotEmpty"] = "NotEmpty";
|
|
63
|
+
ExpressionType["UUID"] = "UUID";
|
|
62
64
|
})(exports.ExpressionType || (exports.ExpressionType = {}));
|
|
63
65
|
exports.AdornmentPlacement = void 0;
|
|
64
66
|
(function (AdornmentPlacement) {
|
|
@@ -1089,6 +1091,8 @@ function defaultEvalHooks(expr, context, coerce) {
|
|
|
1089
1091
|
switch (expr.type) {
|
|
1090
1092
|
case exports.ExpressionType.Jsonata:
|
|
1091
1093
|
return useJsonataExpression(expr.expression, context, undefined, coerce);
|
|
1094
|
+
case exports.ExpressionType.UUID:
|
|
1095
|
+
return useUuidExpression(coerce);
|
|
1092
1096
|
case exports.ExpressionType.Data:
|
|
1093
1097
|
return useDataExpression(expr, context.fields, context, coerce);
|
|
1094
1098
|
case exports.ExpressionType.DataMatch:
|
|
@@ -1139,6 +1143,16 @@ function hideDisplayOnly(context, fieldPath, definition, schemaInterface) {
|
|
|
1139
1143
|
var displayOptions = getDisplayOnlyOptions(definition);
|
|
1140
1144
|
return displayOptions && !displayOptions.emptyText && schemaInterface.isEmptyValue(fieldPath.at(-1), (_lookupChildControl = lookupChildControl(context, fieldPath)) == null ? void 0 : _lookupChildControl.value);
|
|
1141
1145
|
}
|
|
1146
|
+
function useUuidExpression(coerce) {
|
|
1147
|
+
if (coerce === void 0) {
|
|
1148
|
+
coerce = function coerce(x) {
|
|
1149
|
+
return x;
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
return core.useControl(function () {
|
|
1153
|
+
return coerce(uuid.v4());
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1142
1156
|
function useJsonataExpression(jExpr, dataContext, bindings, coerce) {
|
|
1143
1157
|
if (coerce === void 0) {
|
|
1144
1158
|
coerce = function coerce(x) {
|
|
@@ -1519,9 +1533,9 @@ function useControlRenderer(definition, fields, renderer, options) {
|
|
|
1519
1533
|
if (control) {
|
|
1520
1534
|
if (vc && vc.visible === vc.showing) {
|
|
1521
1535
|
if (hidden || !vc.visible) {
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
}
|
|
1536
|
+
control.setValue(function (x) {
|
|
1537
|
+
return _options.clearHidden && !dontClear ? undefined : x == null && dontClear && !dontDefault ? dv : x;
|
|
1538
|
+
});
|
|
1525
1539
|
} else if (!dontDefault) control.setValue(function (x) {
|
|
1526
1540
|
return x != null ? x : dv;
|
|
1527
1541
|
});
|
|
@@ -3309,6 +3323,7 @@ exports.useJsonataValidator = useJsonataValidator;
|
|
|
3309
3323
|
exports.useLengthValidator = useLengthValidator;
|
|
3310
3324
|
exports.useMakeValidationHook = useMakeValidationHook;
|
|
3311
3325
|
exports.useUpdatedRef = useUpdatedRef;
|
|
3326
|
+
exports.useUuidExpression = useUuidExpression;
|
|
3312
3327
|
exports.visitControlData = visitControlData;
|
|
3313
3328
|
exports.visitControlDataArray = visitControlDataArray;
|
|
3314
3329
|
exports.visitControlDefinition = visitControlDefinition;
|