@react-typed-forms/schemas 10.3.0 → 11.0.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.
@@ -117,6 +117,7 @@ export interface DataRendererProps extends ParentRendererProps {
117
117
  export interface ActionRendererProps {
118
118
  actionId: string;
119
119
  actionText: string;
120
+ actionData?: any;
120
121
  onClick: () => void;
121
122
  className?: string;
122
123
  style?: React.CSSProperties;
@@ -146,14 +147,15 @@ export interface DataControlProps {
146
147
  export type CreateDataProps = (controlProps: DataControlProps) => DataRendererProps;
147
148
  export interface ControlRenderOptions extends FormContextOptions {
148
149
  useDataHook?: (c: ControlDefinition) => CreateDataProps;
150
+ actionOnClick?: (actionId: string, actionData: any) => () => void;
149
151
  useEvalExpressionHook?: UseEvalExpressionHook;
150
152
  clearHidden?: boolean;
151
153
  schemaInterface?: SchemaInterface;
152
154
  elementIndex?: number;
153
155
  }
154
156
  export declare function useControlRenderer(definition: ControlDefinition, fields: SchemaField[], renderer: FormRenderer, options?: ControlRenderOptions): FC<ControlRenderProps>;
155
- export declare function lookupSchemaField(c: ControlDefinition, fields: SchemaField[]): SchemaField | undefined;
156
- export declare function getControlData(schemaField: SchemaField | undefined, parentContext: ControlDataContext, elementIndex: number | undefined): [Control<any> | undefined, Control<any> | undefined, ControlDataContext];
157
+ export declare function lookupSchemaField(c: ControlDefinition, fields: SchemaField[]): SchemaField[] | undefined;
158
+ export declare function getControlData(fieldPath: SchemaField[] | undefined, parentContext: ControlDataContext, elementIndex: number | undefined): [Control<any> | undefined, Control<any> | undefined, ControlDataContext];
157
159
  export declare function ControlRenderer({ definition, fields, renderer, options, control, parentPath, }: {
158
160
  definition: ControlDefinition;
159
161
  fields: SchemaField[];
@@ -184,7 +186,9 @@ export interface RenderControlProps {
184
186
  displayControl?: Control<string | undefined>;
185
187
  style?: React.CSSProperties;
186
188
  allowedOptions?: Control<any[] | undefined>;
189
+ actionDataControl?: Control<any | undefined | null>;
187
190
  useChildVisibility: ChildVisibilityFunc;
191
+ actionOnClick?: (actionId: string, actionData: any) => () => void;
188
192
  }
189
193
  export declare function renderControlLayout(props: RenderControlProps): ControlLayoutProps;
190
194
  export declare function appendMarkup(k: keyof Omit<RenderedLayout, "errorControl" | "style" | "className">, markup: ReactNode): (layout: RenderedLayout) => void;
package/lib/hooks.d.ts CHANGED
@@ -3,19 +3,21 @@ import React from "react";
3
3
  import { Control } from "@react-typed-forms/core";
4
4
  import { ControlDataContext, DataContext, DynamicHookGenerator } from "./util";
5
5
  export type EvalExpressionHook<A = any> = DynamicHookGenerator<Control<A | undefined>, ControlDataContext>;
6
- export type UseEvalExpressionHook = (expr: EntityExpression | undefined) => DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
7
- export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField?: SchemaField): EvalExpressionHook<boolean>;
6
+ export type UseEvalExpressionHook = (expr: EntityExpression | undefined, coerce: (v: any) => any) => DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
7
+ export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, fieldPath?: SchemaField[]): EvalExpressionHook<boolean>;
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
11
  export declare function useEvalDisabledHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): 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
- export declare function defaultEvalHooks(expr: EntityExpression, context: ControlDataContext): Control<any>;
14
+ export declare function defaultEvalHooks(expr: EntityExpression, context: ControlDataContext, coerce: (v: any) => any): Control<any>;
15
15
  export declare const defaultUseEvalExpressionHook: UseEvalExpressionHook;
16
- export declare function makeEvalExpressionHook(f: (expr: EntityExpression, context: ControlDataContext) => Control<any>): UseEvalExpressionHook;
17
- export declare function useEvalDynamicHook(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: UseEvalExpressionHook): DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
18
- export declare function matchesType(context: ControlDataContext, types?: string[] | null): boolean | undefined;
19
- export declare function hideDisplayOnly(context: ControlDataContext, field: SchemaField, definition: ControlDefinition, schemaInterface: SchemaInterface): boolean | undefined;
20
- export declare function useJsonataExpression(jExpr: string, dataContext: DataContext, bindings?: () => Record<string, any>): Control<any>;
16
+ export declare function makeEvalExpressionHook(f: (expr: EntityExpression, context: ControlDataContext, coerce: (v: any) => any) => Control<any>): UseEvalExpressionHook;
17
+ export declare function useEvalDynamicBoolHook(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: UseEvalExpressionHook): DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
18
+ export declare function useEvalDynamicHook(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: UseEvalExpressionHook, coerce?: (v: any) => any): DynamicHookGenerator<Control<any> | undefined, ControlDataContext>;
19
+ export declare function matchesType(context: ControlDataContext, fieldPath?: SchemaField[]): boolean | undefined;
20
+ export declare function hideDisplayOnly(context: ControlDataContext, fieldPath: SchemaField[], definition: ControlDefinition, schemaInterface: SchemaInterface): boolean | undefined;
21
+ export declare function useJsonataExpression(jExpr: string, dataContext: DataContext, bindings?: () => Record<string, any>, coerce?: (v: any) => any): Control<any>;
22
+ export declare function useEvalActionHook(useExpr: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<string | null>;
21
23
  export declare function useEvalLabelText(useExpr: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<string | null>;
package/lib/index.js CHANGED
@@ -41,6 +41,7 @@ exports.DynamicPropertyType = void 0;
41
41
  DynamicPropertyType["LayoutStyle"] = "LayoutStyle";
42
42
  DynamicPropertyType["AllowedOptions"] = "AllowedOptions";
43
43
  DynamicPropertyType["Label"] = "Label";
44
+ DynamicPropertyType["ActionData"] = "ActionData";
44
45
  })(exports.DynamicPropertyType || (exports.DynamicPropertyType = {}));
45
46
  exports.ExpressionType = void 0;
46
47
  (function (ExpressionType) {
@@ -419,11 +420,13 @@ function isControlReadonly(c) {
419
420
  function getDisplayOnlyOptions(d) {
420
421
  return isDataControlDefinition(d) && d.renderOptions && isDisplayOnlyRenderer(d.renderOptions) ? d.renderOptions : undefined;
421
422
  }
422
- function getTypeField(context) {
423
- var typeSchemaField = context.fields.find(function (x) {
423
+ function getTypeField(context, fieldPath) {
424
+ var withoutLast = fieldPath.slice(0, -1);
425
+ var fieldList = withoutLast.length > 0 ? withoutLast.at(-1).children : context.fields;
426
+ var typeSchemaField = fieldList.find(function (x) {
424
427
  return x.isTypeField;
425
428
  });
426
- return typeSchemaField ? lookupChildControl(context, typeSchemaField.field) : undefined;
429
+ return typeSchemaField ? lookupChildControl(context, [].concat(withoutLast, [typeSchemaField])) : undefined;
427
430
  }
428
431
  function visitControlDataArray(controls, context, cb) {
429
432
  if (!controls) return undefined;
@@ -478,8 +481,13 @@ function visitControlData(definition, ctx, cb) {
478
481
  }
479
482
  }
480
483
  }
481
- function lookupChildControl(data, child) {
482
- var childPath = [].concat(data.path, [child]);
484
+ function lookupChildControl(data, path) {
485
+ return lookupChildControlPath(data, path.map(function (x) {
486
+ return x.field;
487
+ }));
488
+ }
489
+ function lookupChildControlPath(data, jsonPath) {
490
+ var childPath = [].concat(data.path, jsonPath);
483
491
  return watchControlLookup(data.data, childPath);
484
492
  }
485
493
  function cleanDataForSchema(v, fields) {
@@ -624,6 +632,21 @@ function appendElementIndex(dataContext, elementIndex) {
624
632
  function applyLengthRestrictions(length, min, max, minValue, maxValue) {
625
633
  return [min == null || length > min ? minValue : undefined, max == null || length < max ? maxValue : undefined];
626
634
  }
635
+ function findFieldPath(fields, fieldPath) {
636
+ var fieldNames = fieldPath.split("/");
637
+ var foundFields = [];
638
+ var i = 0;
639
+ var currentFields = fields;
640
+ while (i < fieldNames.length && currentFields) {
641
+ var cf = fieldNames[i];
642
+ var nextField = findField(currentFields, cf);
643
+ if (!nextField) return undefined;
644
+ foundFields.push(nextField);
645
+ currentFields = isCompoundField(nextField) && !nextField.collection ? nextField.children : undefined;
646
+ i++;
647
+ }
648
+ return foundFields.length === fieldNames.length ? foundFields : undefined;
649
+ }
627
650
 
628
651
  function buildSchema(def) {
629
652
  return Object.entries(def).map(function (x) {
@@ -884,43 +907,6 @@ function applyExtensionsToSchema(schemaMap, extensions) {
884
907
  return resolveSchemas(extensions.reduce(applyExtensionToSchema, schemaMap));
885
908
  }
886
909
 
887
- function useCalculatedControl(calculate) {
888
- var c = core.useControl(calculate);
889
- core.useControlEffect(calculate, function (v) {
890
- return c.value = v;
891
- });
892
- return c;
893
- }
894
- function cc(n) {
895
- return n ? n : undefined;
896
- }
897
- function trackedStructure(c, tracker) {
898
- var cc = c.current;
899
- var cv = cc.value;
900
- if (cv == null) {
901
- tracker(c, core.ControlChange.Structure);
902
- return cv;
903
- }
904
- if (typeof cv !== "object") {
905
- tracker(c, core.ControlChange.Value);
906
- return cv;
907
- }
908
- return new Proxy(cv, {
909
- get: function get(target, p, receiver) {
910
- if (Array.isArray(cv)) {
911
- tracker(c, core.ControlChange.Structure);
912
- if (typeof p === "symbol" || p[0] >= "9" || p[0] < "0") return Reflect.get(cv, p);
913
- var nc = cc.elements[p];
914
- if (typeof nc === "function") return nc;
915
- if (nc == null) return null;
916
- return trackedStructure(nc, tracker);
917
- }
918
- if (p in cc.fields || p in cv) return trackedStructure(cc.fields[p], tracker);
919
- return undefined;
920
- }
921
- });
922
- }
923
-
924
910
  function _finallyRethrows(body, finalizer) {
925
911
  try {
926
912
  var result = body();
@@ -932,24 +918,24 @@ function _finallyRethrows(body, finalizer) {
932
918
  }
933
919
  return finalizer(false, result);
934
920
  }
935
- function useEvalVisibilityHook(useEvalExpressionHook, definition, schemaField) {
936
- var dynamicVisibility = useEvalDynamicHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
921
+ function useEvalVisibilityHook(useEvalExpressionHook, definition, fieldPath) {
922
+ var dynamicVisibility = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
937
923
  return makeDynamicPropertyHook(dynamicVisibility, function (ctx, _ref) {
938
- var schemaField = _ref.schemaField,
924
+ var fieldPath = _ref.fieldPath,
939
925
  definition = _ref.definition;
940
926
  return core.useComputed(function () {
941
- return matchesType(ctx, schemaField == null ? void 0 : schemaField.onlyForTypes) && (!schemaField || !hideDisplayOnly(ctx, schemaField, definition, ctx.schemaInterface));
927
+ return matchesType(ctx, fieldPath) && (!fieldPath || !hideDisplayOnly(ctx, fieldPath, definition, ctx.schemaInterface));
942
928
  });
943
929
  }, {
944
- schemaField: schemaField,
930
+ fieldPath: fieldPath,
945
931
  definition: definition
946
932
  });
947
933
  }
948
934
  function useEvalReadonlyHook(useEvalExpressionHook, definition) {
949
- var dynamicReadonly = useEvalDynamicHook(definition, exports.DynamicPropertyType.Readonly, useEvalExpressionHook);
935
+ var dynamicReadonly = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Readonly, useEvalExpressionHook);
950
936
  return makeDynamicPropertyHook(dynamicReadonly, function (ctx, _ref2) {
951
937
  var definition = _ref2.definition;
952
- return useCalculatedControl(function () {
938
+ return core.useCalculatedControl(function () {
953
939
  return isControlReadonly(definition);
954
940
  });
955
941
  }, {
@@ -969,7 +955,7 @@ function useEvalAllowedOptionsHook(useEvalExpressionHook, definition) {
969
955
  }, undefined);
970
956
  }
971
957
  function useEvalDisabledHook(useEvalExpressionHook, definition) {
972
- var dynamicDisabled = useEvalDynamicHook(definition, exports.DynamicPropertyType.Disabled, useEvalExpressionHook);
958
+ var dynamicDisabled = useEvalDynamicBoolHook(definition, exports.DynamicPropertyType.Disabled, useEvalExpressionHook);
973
959
  return makeDynamicPropertyHook(dynamicDisabled, function () {
974
960
  return core.useControl(false);
975
961
  }, undefined);
@@ -994,63 +980,89 @@ function useEvalDefaultValueHook(useEvalExpressionHook, definition, schemaField,
994
980
  schemaField: schemaField
995
981
  });
996
982
  }
997
- function useDataExpression(fvExpr, fields, data) {
998
- var refField = findField(fields, fvExpr.field);
999
- var otherField = refField ? lookupChildControl(data, refField.field) : undefined;
1000
- return useCalculatedControl(function () {
1001
- return otherField == null ? void 0 : otherField.value;
983
+ function useDataExpression(fvExpr, fields, data, coerce) {
984
+ if (coerce === void 0) {
985
+ coerce = function coerce(x) {
986
+ return x;
987
+ };
988
+ }
989
+ var refField = findFieldPath(fields, fvExpr.field);
990
+ var otherField = refField ? lookupChildControl(data, refField) : undefined;
991
+ return core.useCalculatedControl(function () {
992
+ return coerce(otherField == null ? void 0 : otherField.value);
1002
993
  });
1003
994
  }
1004
- function useDataMatchExpression(fvExpr, fields, data) {
1005
- var refField = findField(fields, fvExpr.field);
1006
- var otherField = refField ? lookupChildControl(data, refField.field) : undefined;
1007
- return core.useComputed(function () {
995
+ function useDataMatchExpression(fvExpr, fields, data, coerce) {
996
+ if (coerce === void 0) {
997
+ coerce = function coerce(x) {
998
+ return x;
999
+ };
1000
+ }
1001
+ var refField = findFieldPath(fields, fvExpr.field);
1002
+ var otherField = refField ? lookupChildControl(data, refField) : undefined;
1003
+ return core.useCalculatedControl(function () {
1008
1004
  var fv = otherField == null ? void 0 : otherField.value;
1009
- return Array.isArray(fv) ? fv.includes(fvExpr.value) : fv === fvExpr.value;
1005
+ return coerce(Array.isArray(fv) ? fv.includes(fvExpr.value) : fv === fvExpr.value);
1010
1006
  });
1011
1007
  }
1012
- function defaultEvalHooks(expr, context) {
1008
+ function defaultEvalHooks(expr, context, coerce) {
1013
1009
  switch (expr.type) {
1014
1010
  case exports.ExpressionType.Jsonata:
1015
- return useJsonataExpression(expr.expression, context);
1011
+ return useJsonataExpression(expr.expression, context, undefined, coerce);
1016
1012
  case exports.ExpressionType.Data:
1017
- return useDataExpression(expr, context.fields, context);
1013
+ return useDataExpression(expr, context.fields, context, coerce);
1018
1014
  case exports.ExpressionType.DataMatch:
1019
- return useDataMatchExpression(expr, context.fields, context);
1015
+ return useDataMatchExpression(expr, context.fields, context, coerce);
1020
1016
  default:
1021
1017
  return core.useControl(undefined);
1022
1018
  }
1023
1019
  }
1024
1020
  var defaultUseEvalExpressionHook = makeEvalExpressionHook(defaultEvalHooks);
1025
1021
  function makeEvalExpressionHook(f) {
1026
- return function (expr) {
1022
+ return function (expr, coerce) {
1027
1023
  return {
1028
1024
  deps: expr == null ? void 0 : expr.type,
1029
1025
  state: expr,
1030
1026
  runHook: function runHook(ctx, state) {
1031
- return state ? f(state, ctx) : undefined;
1027
+ return state ? f(state, ctx, coerce) : undefined;
1032
1028
  }
1033
1029
  };
1034
1030
  };
1035
1031
  }
1036
- function useEvalDynamicHook(definition, type, useEvalExpressionHook) {
1032
+ function useEvalDynamicBoolHook(definition, type, useEvalExpressionHook) {
1033
+ return useEvalDynamicHook(definition, type, useEvalExpressionHook, function (x) {
1034
+ return Boolean(x);
1035
+ });
1036
+ }
1037
+ function useEvalDynamicHook(definition, type, useEvalExpressionHook, coerce) {
1037
1038
  var _definition$dynamic;
1039
+ if (coerce === void 0) {
1040
+ coerce = function coerce(x) {
1041
+ return x;
1042
+ };
1043
+ }
1038
1044
  var expression = (_definition$dynamic = definition.dynamic) == null ? void 0 : _definition$dynamic.find(function (x) {
1039
1045
  return x.type === type;
1040
1046
  });
1041
- return useEvalExpressionHook(expression == null ? void 0 : expression.expr);
1047
+ return useEvalExpressionHook(expression == null ? void 0 : expression.expr, coerce);
1042
1048
  }
1043
- function matchesType(context, types) {
1049
+ function matchesType(context, fieldPath) {
1050
+ var types = fieldPath ? fieldPath[fieldPath.length - 1].onlyForTypes : undefined;
1044
1051
  if (types == null || types.length === 0) return true;
1045
- var typeField = getTypeField(context);
1052
+ var typeField = getTypeField(context, fieldPath);
1046
1053
  return typeField && types.includes(typeField.value);
1047
1054
  }
1048
- function hideDisplayOnly(context, field, definition, schemaInterface) {
1055
+ function hideDisplayOnly(context, fieldPath, definition, schemaInterface) {
1049
1056
  var _lookupChildControl;
1050
1057
  var displayOptions = getDisplayOnlyOptions(definition);
1051
- return displayOptions && !displayOptions.emptyText && schemaInterface.isEmptyValue(field, (_lookupChildControl = lookupChildControl(context, field.field)) == null ? void 0 : _lookupChildControl.value);
1058
+ return displayOptions && !displayOptions.emptyText && schemaInterface.isEmptyValue(fieldPath.at(-1), (_lookupChildControl = lookupChildControl(context, fieldPath)) == null ? void 0 : _lookupChildControl.value);
1052
1059
  }
1053
- function useJsonataExpression(jExpr, dataContext, bindings) {
1060
+ function useJsonataExpression(jExpr, dataContext, bindings, coerce) {
1061
+ if (coerce === void 0) {
1062
+ coerce = function coerce(x) {
1063
+ return x;
1064
+ };
1065
+ }
1054
1066
  var pathString = jsonPathString(dataContext.path, function (x) {
1055
1067
  return "#$i[" + x + "]";
1056
1068
  });
@@ -1086,8 +1098,9 @@ function useJsonataExpression(jExpr, dataContext, bindings) {
1086
1098
  updateSubscriptions = _ref$current[1];
1087
1099
  var _temp = _finallyRethrows(function () {
1088
1100
  var bindingData = bindings ? core.collectChanges(collect, bindings) : undefined;
1089
- return Promise.resolve(compiledExpr.evaluate(trackedStructure(dataContext.data, collect), bindingData)).then(function (_compiledExpr$evaluat) {
1090
- control.value = _compiledExpr$evaluat;
1101
+ var _coerce = coerce;
1102
+ return Promise.resolve(compiledExpr.evaluate(core.trackedValue(dataContext.data, collect), bindingData)).then(function (_compiledExpr$evaluat) {
1103
+ control.value = _coerce(_compiledExpr$evaluat);
1091
1104
  });
1092
1105
  }, function (_wasThrown, _result) {
1093
1106
  updateSubscriptions();
@@ -1107,6 +1120,12 @@ function useJsonataExpression(jExpr, dataContext, bindings) {
1107
1120
  }, [compiledExpr]);
1108
1121
  return control;
1109
1122
  }
1123
+ function useEvalActionHook(useExpr, definition) {
1124
+ var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.ActionData, useExpr);
1125
+ return makeDynamicPropertyHook(dynamicValue, function () {
1126
+ return core.useControl(null);
1127
+ }, undefined);
1128
+ }
1110
1129
  function useEvalLabelText(useExpr, definition) {
1111
1130
  var dynamicValue = useEvalDynamicHook(definition, exports.DynamicPropertyType.Label, useExpr);
1112
1131
  return makeDynamicPropertyHook(dynamicValue, function () {
@@ -1143,8 +1162,8 @@ function useValidationHook(definition, field) {
1143
1162
  return control.setError("default", "");
1144
1163
  });
1145
1164
  core.useValidator(control, function (v) {
1146
- return !hidden && dd.required && (v == null || v === "" || Array.isArray(v) && v.length === 0) ? "Please enter a value" : null;
1147
- }, "required");
1165
+ return !hidden && dd.required && field && schemaInterface.isEmptyValue(field, v) ? "Please enter a value" : null;
1166
+ }, "required", undefined, [hidden, dd.required, !!field]);
1148
1167
  ((_dd$validators = dd.validators) != null ? _dd$validators : []).forEach(function (x, i) {
1149
1168
  switch (x.type) {
1150
1169
  case exports.ValidatorType.Length:
@@ -1217,6 +1236,10 @@ function useDateValidator(control, dv, i) {
1217
1236
  }, "date" + i);
1218
1237
  }
1219
1238
 
1239
+ function cc(n) {
1240
+ return n ? n : undefined;
1241
+ }
1242
+
1220
1243
  var DefaultSchemaInterface = /*#__PURE__*/function () {
1221
1244
  function DefaultSchemaInterface() {}
1222
1245
  var _proto = DefaultSchemaInterface.prototype;
@@ -1268,14 +1291,16 @@ function useControlRenderer(definition, fields, renderer, options) {
1268
1291
  var elementIndex = options.elementIndex;
1269
1292
  var schemaInterface = (_options$schemaInterf = options.schemaInterface) != null ? _options$schemaInterf : defaultSchemaInterface;
1270
1293
  var useExpr = (_options$useEvalExpre = options.useEvalExpressionHook) != null ? _options$useEvalExpre : defaultUseEvalExpressionHook;
1271
- var schemaField = lookupSchemaField(definition, fields);
1294
+ var fieldPath = lookupSchemaField(definition, fields);
1295
+ var schemaField = fieldPath == null ? void 0 : fieldPath.at(-1);
1272
1296
  var dynamicHooks = useDynamicHooks({
1273
1297
  defaultValueControl: useEvalDefaultValueHook(useExpr, definition, schemaField, elementIndex != null),
1274
- visibleControl: useEvalVisibilityHook(useExpr, definition, schemaField),
1298
+ visibleControl: useEvalVisibilityHook(useExpr, definition, fieldPath),
1275
1299
  readonlyControl: useEvalReadonlyHook(useExpr, definition),
1276
1300
  disabledControl: useEvalDisabledHook(useExpr, definition),
1277
1301
  allowedOptions: useEvalAllowedOptionsHook(useExpr, definition),
1278
1302
  labelText: useEvalLabelText(useExpr, definition),
1303
+ actionData: useEvalActionHook(useExpr, definition),
1279
1304
  customStyle: useEvalStyleHook(useExpr, exports.DynamicPropertyType.Style, definition),
1280
1305
  layoutStyle: useEvalStyleHook(useExpr, exports.DynamicPropertyType.LayoutStyle, definition),
1281
1306
  displayControl: useEvalDisplayHook(useExpr, definition)
@@ -1285,7 +1310,7 @@ function useControlRenderer(definition, fields, renderer, options) {
1285
1310
  options: options,
1286
1311
  definition: definition,
1287
1312
  fields: fields,
1288
- schemaField: schemaField,
1313
+ fieldPath: fieldPath,
1289
1314
  elementIndex: elementIndex
1290
1315
  });
1291
1316
  var Component = React.useCallback(function (_ref) {
@@ -1299,8 +1324,9 @@ function useControlRenderer(definition, fields, renderer, options) {
1299
1324
  c = _r$current.definition,
1300
1325
  _options = _r$current.options,
1301
1326
  _fields = _r$current.fields,
1302
- _schemaField = _r$current.schemaField,
1327
+ _fieldPath = _r$current.fieldPath,
1303
1328
  _elementIndex = _r$current.elementIndex;
1329
+ var _schemaField = _fieldPath == null ? void 0 : _fieldPath.at(-1);
1304
1330
  var parentDataContext = {
1305
1331
  fields: _fields,
1306
1332
  schemaInterface: schemaInterface,
@@ -1316,7 +1342,8 @@ function useControlRenderer(definition, fields, renderer, options) {
1316
1342
  labelText = _dynamicHooks.labelText,
1317
1343
  customStyle = _dynamicHooks.customStyle,
1318
1344
  allowedOptions = _dynamicHooks.allowedOptions,
1319
- defaultValueControl = _dynamicHooks.defaultValueControl;
1345
+ defaultValueControl = _dynamicHooks.defaultValueControl,
1346
+ actionData = _dynamicHooks.actionData;
1320
1347
  var visible = visibleControl.current.value;
1321
1348
  var visibility = core.useControl(function () {
1322
1349
  return visible != null ? {
@@ -1334,7 +1361,7 @@ function useControlRenderer(definition, fields, renderer, options) {
1334
1361
  };
1335
1362
  });
1336
1363
  });
1337
- var _getControlData = getControlData(_schemaField, parentDataContext, _elementIndex),
1364
+ var _getControlData = getControlData(_fieldPath, parentDataContext, _elementIndex),
1338
1365
  parentControl = _getControlData[0],
1339
1366
  control = _getControlData[1],
1340
1367
  controlDataContext = _getControlData[2];
@@ -1360,7 +1387,7 @@ function useControlRenderer(definition, fields, renderer, options) {
1360
1387
  parentControl.value = {};
1361
1388
  }
1362
1389
  }, true);
1363
- var myOptions = useCalculatedControl(function () {
1390
+ var myOptions = core.useCalculatedControl(function () {
1364
1391
  var _visibility$fields;
1365
1392
  return {
1366
1393
  hidden: _options.hidden || !((_visibility$fields = visibility.fields) != null && _visibility$fields.showing.value),
@@ -1410,6 +1437,8 @@ function useControlRenderer(definition, fields, renderer, options) {
1410
1437
  displayControl: displayControl,
1411
1438
  style: customStyle.value,
1412
1439
  allowedOptions: allowedOptions,
1440
+ actionDataControl: actionData,
1441
+ actionOnClick: _options.actionOnClick,
1413
1442
  useChildVisibility: function useChildVisibility(childDef, context) {
1414
1443
  var schemaField = lookupSchemaField(childDef, (context != null ? context : controlDataContext).fields);
1415
1444
  return useEvalVisibilityHook(useExpr, childDef, schemaField);
@@ -1432,12 +1461,17 @@ function useControlRenderer(definition, fields, renderer, options) {
1432
1461
  }
1433
1462
  function lookupSchemaField(c, fields) {
1434
1463
  var fieldName = isGroupControlsDefinition(c) ? c.compoundField : isDataControlDefinition(c) ? c.field : undefined;
1435
- return fieldName ? findField(fields, fieldName) : undefined;
1464
+ return fieldName ? findFieldPath(fields, fieldName) : undefined;
1436
1465
  }
1437
- function getControlData(schemaField, parentContext, elementIndex) {
1438
- var _parentControl$fields, _childControl$element;
1466
+ function getControlData(fieldPath, parentContext, elementIndex) {
1467
+ var _fieldPath$slice$map, _parentControl$fields, _childControl$element;
1439
1468
  var data = parentContext.data,
1440
- path = parentContext.path;
1469
+ pp = parentContext.path;
1470
+ var extraPath = (_fieldPath$slice$map = fieldPath == null ? void 0 : fieldPath.slice(0, -1).map(function (x) {
1471
+ return x.field;
1472
+ })) != null ? _fieldPath$slice$map : [];
1473
+ var path = [].concat(pp, extraPath);
1474
+ var schemaField = fieldPath == null ? void 0 : fieldPath.at(-1);
1441
1475
  var parentControl = data.lookupControl(path);
1442
1476
  var childPath = schemaField ? elementIndex != null ? [].concat(path, [schemaField.field, elementIndex]) : [].concat(path, [schemaField.field]) : path;
1443
1477
  var childControl = schemaField && parentControl ? (_parentControl$fields = parentControl.fields) == null ? void 0 : _parentControl$fields[schemaField.field] : undefined;
@@ -1593,12 +1627,14 @@ function renderControlLayout(props) {
1593
1627
  };
1594
1628
  }
1595
1629
  if (isActionControlsDefinition(c)) {
1596
- var _ref5, _labelText$value2;
1630
+ var _props$actionDataCont, _props$actionDataCont2, _ref5, _labelText$value2, _props$actionOnClick;
1631
+ var actionData = (_props$actionDataCont = (_props$actionDataCont2 = props.actionDataControl) == null ? void 0 : _props$actionDataCont2.value) != null ? _props$actionDataCont : c.actionData;
1597
1632
  return {
1598
1633
  children: renderer.renderAction({
1599
1634
  actionText: (_ref5 = (_labelText$value2 = labelText == null ? void 0 : labelText.value) != null ? _labelText$value2 : c.title) != null ? _ref5 : c.actionId,
1600
1635
  actionId: c.actionId,
1601
- onClick: function onClick() {},
1636
+ actionData: actionData,
1637
+ onClick: (_props$actionOnClick = props.actionOnClick == null ? void 0 : props.actionOnClick(c.actionId, actionData)) != null ? _props$actionOnClick : function () {},
1602
1638
  className: cc(c.styleClass),
1603
1639
  style: style
1604
1640
  })
@@ -2555,7 +2591,7 @@ function createFormRenderer(customRenderers, defaultRenderers) {
2555
2591
  var options = hasOptions(props);
2556
2592
  var renderer = (_dataRegistrations$fi = dataRegistrations.find(function (x) {
2557
2593
  var _x$collection, _field$collection, _x$options;
2558
- return ((_x$collection = x.collection) != null ? _x$collection : false) === (props.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false)) && ((_x$options = x.options) != null ? _x$options : false) === options && (x.schemaType && isOneOf(x.schemaType, field.type) || x.renderType && isOneOf(x.renderType, renderType) || x.match && x.match(props));
2594
+ return ((_x$collection = x.collection) != null ? _x$collection : false) === (props.elementIndex == null && ((_field$collection = field.collection) != null ? _field$collection : false)) && ((_x$options = x.options) != null ? _x$options : false) === options && (x.schemaType && renderType == exports.DataRenderType.Standard && isOneOf(x.schemaType, field.type) || x.renderType && isOneOf(x.renderType, renderType) || x.match && x.match(props));
2559
2595
  })) != null ? _dataRegistrations$fi : defaultRenderers.data;
2560
2596
  var result = renderer.render(props, formRenderers);
2561
2597
  if (typeof result === "function") return result;
@@ -2730,6 +2766,7 @@ exports.findCompoundField = findCompoundField;
2730
2766
  exports.findCompoundGroups = findCompoundGroups;
2731
2767
  exports.findControlsForCompound = findControlsForCompound;
2732
2768
  exports.findField = findField;
2769
+ exports.findFieldPath = findFieldPath;
2733
2770
  exports.findNonDataGroups = findNonDataGroups;
2734
2771
  exports.findScalarField = findScalarField;
2735
2772
  exports.getAllReferencedClasses = getAllReferencedClasses;
@@ -2761,6 +2798,7 @@ exports.jsonPathString = jsonPathString;
2761
2798
  exports.jsonataExpr = jsonataExpr;
2762
2799
  exports.layoutKeyForPlacement = layoutKeyForPlacement;
2763
2800
  exports.lookupChildControl = lookupChildControl;
2801
+ exports.lookupChildControlPath = lookupChildControlPath;
2764
2802
  exports.lookupSchemaField = lookupSchemaField;
2765
2803
  exports.makeCompoundField = makeCompoundField;
2766
2804
  exports.makeEvalExpressionHook = makeEvalExpressionHook;
@@ -2781,10 +2819,12 @@ exports.toDepString = toDepString;
2781
2819
  exports.useControlDefinitionForSchema = useControlDefinitionForSchema;
2782
2820
  exports.useControlRenderer = useControlRenderer;
2783
2821
  exports.useDynamicHooks = useDynamicHooks;
2822
+ exports.useEvalActionHook = useEvalActionHook;
2784
2823
  exports.useEvalAllowedOptionsHook = useEvalAllowedOptionsHook;
2785
2824
  exports.useEvalDefaultValueHook = useEvalDefaultValueHook;
2786
2825
  exports.useEvalDisabledHook = useEvalDisabledHook;
2787
2826
  exports.useEvalDisplayHook = useEvalDisplayHook;
2827
+ exports.useEvalDynamicBoolHook = useEvalDynamicBoolHook;
2788
2828
  exports.useEvalDynamicHook = useEvalDynamicHook;
2789
2829
  exports.useEvalLabelText = useEvalLabelText;
2790
2830
  exports.useEvalReadonlyHook = useEvalReadonlyHook;
@@ -2796,6 +2836,7 @@ exports.useValidationHook = useValidationHook;
2796
2836
  exports.visitControlData = visitControlData;
2797
2837
  exports.visitControlDataArray = visitControlDataArray;
2798
2838
  exports.visitControlDefinition = visitControlDefinition;
2839
+ exports.watchControlLookup = watchControlLookup;
2799
2840
  exports.withScalarOptions = withScalarOptions;
2800
2841
  exports.wrapMarkup = wrapMarkup;
2801
2842
  exports.wrapMarkupAt = wrapMarkupAt;