@react-typed-forms/schemas 14.4.1 → 14.5.1
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.cjs +6 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks.tsx +10 -0
- package/src/validators.ts +3 -3
package/lib/hooks.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { SchemaDataNode, SchemaInterface } from "./schemaField";
|
|
|
7
7
|
import { EntityExpression } from "./entityExpression";
|
|
8
8
|
export type EvalExpressionHook<A = any> = DynamicHookGenerator<Control<A | undefined>, ControlDataContext>;
|
|
9
9
|
export type UseEvalExpressionHook = (expr: EntityExpression | undefined | null, coerce: (v: any) => any) => DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
|
|
10
|
+
export declare function optionalHook(expr: EntityExpression | undefined | null, useHook: UseEvalExpressionHook, coerce: (v: any) => any): DynamicHookGenerator<Control<any> | undefined, ControlDataContext> | undefined;
|
|
10
11
|
export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, overrideDataNode?: SchemaDataNode): EvalExpressionHook<boolean>;
|
|
11
12
|
export declare function useEvalReadonlyHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
|
|
12
13
|
export declare function useEvalStyleHook(useEvalExpressionHook: UseEvalExpressionHook, property: DynamicPropertyType, definition: ControlDefinition): EvalExpressionHook<React.CSSProperties>;
|
package/lib/index.cjs
CHANGED
|
@@ -1806,6 +1806,9 @@ function _finallyRethrows(body, finalizer) {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
return finalizer(false, result);
|
|
1808
1808
|
}
|
|
1809
|
+
function optionalHook(expr, useHook, coerce) {
|
|
1810
|
+
return expr && expr.type ? useHook(expr, coerce) : undefined;
|
|
1811
|
+
}
|
|
1809
1812
|
function useEvalVisibilityHook(useEvalExpressionHook, definition, overrideDataNode) {
|
|
1810
1813
|
var dynamicVisibility = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
|
|
1811
1814
|
return makeDynamicPropertyHook(dynamicVisibility, function (ctx, _ref) {
|
|
@@ -2118,7 +2121,7 @@ function useMakeValidationHook(definition, useValidatorFor) {
|
|
|
2118
2121
|
});
|
|
2119
2122
|
}, [!!dd, dd == null ? void 0 : dd.required, depString, useValidatorFor]);
|
|
2120
2123
|
}
|
|
2121
|
-
function useDefaultValidator(validator, ctx) {
|
|
2124
|
+
var useDefaultValidator = function useDefaultValidator(validator, ctx) {
|
|
2122
2125
|
switch (validator.type) {
|
|
2123
2126
|
case exports.ValidatorType.Length:
|
|
2124
2127
|
useLengthValidator(validator, ctx);
|
|
@@ -2130,7 +2133,7 @@ function useDefaultValidator(validator, ctx) {
|
|
|
2130
2133
|
useDateValidator(validator, ctx);
|
|
2131
2134
|
break;
|
|
2132
2135
|
}
|
|
2133
|
-
}
|
|
2136
|
+
};
|
|
2134
2137
|
function useJsonataValidator(validator, ctx) {
|
|
2135
2138
|
var sdn = ctx.dataContext.parentNode;
|
|
2136
2139
|
var errorMsg = useJsonataExpression(validator.expression, getRootDataNode(sdn).control, getJsonPath(sdn), undefined, function (v) {
|
|
@@ -3367,6 +3370,7 @@ exports.mergeField = mergeField;
|
|
|
3367
3370
|
exports.mergeFields = mergeFields;
|
|
3368
3371
|
exports.mergeObjects = mergeObjects;
|
|
3369
3372
|
exports.nodeForControl = nodeForControl;
|
|
3373
|
+
exports.optionalHook = optionalHook;
|
|
3370
3374
|
exports.radioButtonOptions = radioButtonOptions;
|
|
3371
3375
|
exports.relativePath = relativePath;
|
|
3372
3376
|
exports.renderControlLayout = renderControlLayout;
|