@react-typed-forms/schemas 7.1.0 → 7.3.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.
@@ -93,6 +93,7 @@ export interface GroupRendererProps {
93
93
  style?: React.CSSProperties;
94
94
  }
95
95
  export interface DataRendererProps {
96
+ definition: DataControlDefinition;
96
97
  renderOptions: RenderOptions;
97
98
  field: SchemaField;
98
99
  id: string;
@@ -117,6 +118,7 @@ export interface ActionRendererProps {
117
118
  }
118
119
  export interface ControlRenderProps {
119
120
  control: Control<any>;
121
+ parentPath?: JsonPath[];
120
122
  }
121
123
  export interface FormContextOptions {
122
124
  readonly?: boolean | null;
@@ -133,9 +135,14 @@ export interface DataControlProps {
133
135
  childCount: number;
134
136
  renderChild: ChildRenderer;
135
137
  allowedOptions?: Control<any[] | undefined>;
136
- elementRenderer?: (elemProps: Control<any>) => ReactNode;
138
+ elementRenderer?: (elemIndex: number) => ReactNode;
137
139
  }
138
140
  export type CreateDataProps = (controlProps: DataControlProps) => DataRendererProps;
141
+ export type JsonPath = string | number;
142
+ export interface DataContext {
143
+ data: Control<any>;
144
+ path: JsonPath[];
145
+ }
139
146
  export interface ControlRenderOptions extends FormContextOptions {
140
147
  useDataHook?: (c: ControlDefinition) => CreateDataProps;
141
148
  useEvalExpressionHook?: UseEvalExpressionHook;
@@ -144,9 +151,9 @@ export interface ControlRenderOptions extends FormContextOptions {
144
151
  }
145
152
  export declare function useControlRenderer(definition: ControlDefinition, fields: SchemaField[], renderer: FormRenderer, options?: ControlRenderOptions): FC<ControlRenderProps>;
146
153
  export declare function lookupSchemaField(c: ControlDefinition, fields: SchemaField[]): SchemaField | undefined;
147
- export declare function getControlData(schemaField: SchemaField | undefined, parentContext: ControlDataContext): [Control<any> | undefined, ControlDataContext];
154
+ export declare function getControlData(schemaField: SchemaField | undefined, parentContext: ControlDataContext): [Control<any> | undefined, Control<any> | undefined, ControlDataContext];
148
155
  export declare function defaultDataProps({ definition, field, control, options, elementRenderer, style, allowedOptions, ...props }: DataControlProps): DataRendererProps;
149
- export declare function defaultArrayProps(arrayControl: Control<any[] | undefined | null>, field: SchemaField, required: boolean, style: CSSProperties | undefined, className: string | undefined, renderElement: (elemProps: Control<any>) => ReactNode): ArrayRendererProps;
156
+ export declare function defaultArrayProps(arrayControl: Control<any[] | undefined | null>, field: SchemaField, required: boolean, style: CSSProperties | undefined, className: string | undefined, renderElement: (elemIndex: number) => ReactNode): ArrayRendererProps;
150
157
  export type ChildRenderer = (k: Key, childIndex: number, props: ControlRenderProps) => ReactNode;
151
158
  export interface RenderControlProps {
152
159
  definition: ControlDefinition;
package/lib/hooks.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import { ControlDefinition, DynamicPropertyType, EntityExpression, SchemaField, SchemaInterface } from "./types";
3
3
  import { Control } from "@react-typed-forms/core";
4
4
  import { ControlDataContext } from "./util";
5
+ import { DataContext } from "./controlRender";
5
6
  export type UseEvalExpressionHook = (expr: EntityExpression | undefined) => EvalExpressionHook | undefined;
6
7
  export declare function useEvalVisibilityHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition, schemaField?: SchemaField): EvalExpressionHook<boolean>;
7
8
  export declare function useEvalReadonlyHook(useEvalExpressionHook: UseEvalExpressionHook, definition: ControlDefinition): EvalExpressionHook<boolean>;
@@ -17,4 +18,4 @@ export declare function makeEvalExpressionHook(f: (expr: EntityExpression, conte
17
18
  export declare function useEvalDynamicHook(definition: ControlDefinition, type: DynamicPropertyType, useEvalExpressionHook: (expr: EntityExpression | undefined) => EvalExpressionHook | undefined): EvalExpressionHook | undefined;
18
19
  export declare function matchesType(context: ControlDataContext, types?: string[] | null): boolean | undefined;
19
20
  export declare function hideDisplayOnly(context: ControlDataContext, field: SchemaField, definition: ControlDefinition, schemaInterface: SchemaInterface): boolean | undefined;
20
- export declare function useJsonataExpression(jExpr: string, data: Control<any>): Control<any>;
21
+ export declare function useJsonataExpression(jExpr: string, dataContext: DataContext, bindings?: () => Record<string, any>): Control<any>;
package/lib/index.js CHANGED
@@ -434,11 +434,10 @@ function getDisplayOnlyOptions(d) {
434
434
  return isDataControlDefinition(d) && d.renderOptions && isDisplayOnlyRenderer(d.renderOptions) ? d.renderOptions : undefined;
435
435
  }
436
436
  function getTypeField(context) {
437
- var _context$groupControl;
438
437
  var typeSchemaField = context.fields.find(function (x) {
439
438
  return x.isTypeField;
440
439
  });
441
- return typeSchemaField ? (_context$groupControl = context.groupControl.fields) == null ? void 0 : _context$groupControl[typeSchemaField.field] : undefined;
440
+ return typeSchemaField ? lookupChildControl(context, typeSchemaField.field) : undefined;
442
441
  }
443
442
  function visitControlDataArray(controls, context, cb) {
444
443
  if (!controls) return undefined;
@@ -469,27 +468,34 @@ function visitControlData(definition, ctx, cb) {
469
468
  function processData(def, fieldName, children) {
470
469
  var fieldData = fieldName ? findField(ctx.fields, fieldName) : undefined;
471
470
  if (!fieldData) return !fieldName ? visitControlDataArray(children, ctx, cb) : undefined;
472
- var control = ctx.groupControl.fields[fieldData.field];
471
+ var thisPath = [].concat(ctx.path, [fieldData.field]);
472
+ var control = ctx.data.lookupControl(thisPath);
473
+ if (!control) throw "No control for field";
473
474
  var result = def ? cb(def, fieldData, control, false) : undefined;
474
475
  if (result !== undefined) return result;
475
476
  if (fieldData.collection) {
477
+ var cIndex = 0;
476
478
  for (var _iterator3 = _createForOfIteratorHelperLoose((_control$elements = control.elements) != null ? _control$elements : []), _step3; !(_step3 = _iterator3()).done;) {
477
479
  var _control$elements;
478
480
  var c = _step3.value;
479
481
  var elemResult = def ? cb(def, fieldData, c, true) : undefined;
480
482
  if (elemResult !== undefined) return elemResult;
481
483
  if (isCompoundField(fieldData)) {
482
- var cfResult = visitControlDataArray(children, {
484
+ var cfResult = visitControlDataArray(children, _extends({}, ctx, {
483
485
  fields: fieldData.children,
484
- groupControl: c,
485
- schemaInterface: ctx.schemaInterface
486
- }, cb);
486
+ path: [].concat(thisPath, [cIndex])
487
+ }), cb);
487
488
  if (cfResult !== undefined) return cfResult;
488
489
  }
490
+ cIndex++;
489
491
  }
490
492
  }
491
493
  }
492
494
  }
495
+ function lookupChildControl(data, child) {
496
+ var childPath = [].concat(data.path, [child]);
497
+ return data.data.lookupControl(childPath);
498
+ }
493
499
  function cleanDataForSchema(v, fields) {
494
500
  if (!v) return v;
495
501
  var typeField = fields.find(function (x) {
@@ -528,7 +534,6 @@ function cleanDataForSchema(v, fields) {
528
534
  ;
529
535
  }
530
536
  });
531
-
532
537
  return out;
533
538
  }
534
539
  function getAllReferencedClasses(c) {
@@ -540,6 +545,18 @@ function getAllReferencedClasses(c) {
540
545
  if (childClasses) return [tc].concat(childClasses);
541
546
  return [tc];
542
547
  }
548
+ function jsonPathString(jsonPath) {
549
+ var out = "";
550
+ jsonPath.forEach(function (v, i) {
551
+ if (typeof v === "number") {
552
+ out += "[" + v + "]";
553
+ } else {
554
+ if (i > 0) out += ".";
555
+ out += v;
556
+ }
557
+ });
558
+ return out;
559
+ }
543
560
 
544
561
  function dataControl(field, title, options) {
545
562
  return _extends({
@@ -662,7 +679,44 @@ function useCalculatedControl(calculate) {
662
679
  function cc(n) {
663
680
  return n ? n : undefined;
664
681
  }
682
+ function trackedStructure(c, tracker) {
683
+ var cc = c.current;
684
+ var cv = cc.value;
685
+ if (cv == null) {
686
+ tracker(c, core.ControlChange.Structure);
687
+ return cv;
688
+ }
689
+ if (typeof cv !== "object") {
690
+ tracker(c, core.ControlChange.Value);
691
+ return cv;
692
+ }
693
+ return new Proxy(cv, {
694
+ get: function get(target, p, receiver) {
695
+ if (Array.isArray(cv)) {
696
+ tracker(c, core.ControlChange.Structure);
697
+ if (typeof p === "symbol" || p[0] >= "9" || p[0] < "0") return Reflect.get(cv, p);
698
+ var nc = cc.elements[p];
699
+ if (typeof nc === "function") return nc;
700
+ if (nc == null) return null;
701
+ return trackedStructure(nc, tracker);
702
+ }
703
+ if (p in cv) return trackedStructure(cc.fields[p], tracker);
704
+ return undefined;
705
+ }
706
+ });
707
+ }
665
708
 
709
+ function _finallyRethrows(body, finalizer) {
710
+ try {
711
+ var result = body();
712
+ } catch (e) {
713
+ return finalizer(true, e);
714
+ }
715
+ if (result && result.then) {
716
+ return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
717
+ }
718
+ return finalizer(false, result);
719
+ }
666
720
  function useEvalVisibilityHook(useEvalExpressionHook, definition, schemaField) {
667
721
  var dynamicVisibility = useEvalDynamicHook(definition, exports.DynamicPropertyType.Visible, useEvalExpressionHook);
668
722
  var r = useUpdatedRef({
@@ -738,14 +792,14 @@ function useEvalDefaultValueHook(useEvalExpressionHook, definition, schemaField)
738
792
  }
739
793
  function useDataExpression(fvExpr, fields, data) {
740
794
  var refField = findField(fields, fvExpr.field);
741
- var otherField = refField ? data.fields[refField.field] : undefined;
795
+ var otherField = refField ? lookupChildControl(data, refField.field) : undefined;
742
796
  return useCalculatedControl(function () {
743
797
  return otherField == null ? void 0 : otherField.value;
744
798
  });
745
799
  }
746
800
  function useDataMatchExpression(fvExpr, fields, data) {
747
801
  var refField = findField(fields, fvExpr.field);
748
- var otherField = refField ? data.fields[refField.field] : undefined;
802
+ var otherField = refField ? lookupChildControl(data, refField.field) : undefined;
749
803
  return core.useComputed(function () {
750
804
  var fv = otherField == null ? void 0 : otherField.value;
751
805
  return Array.isArray(fv) ? fv.includes(fvExpr.value) : fv === fvExpr.value;
@@ -754,11 +808,11 @@ function useDataMatchExpression(fvExpr, fields, data) {
754
808
  function defaultEvalHooks(expr, context) {
755
809
  switch (expr.type) {
756
810
  case exports.ExpressionType.Jsonata:
757
- return useJsonataExpression(expr.expression, context.groupControl);
811
+ return useJsonataExpression(expr.expression, context);
758
812
  case exports.ExpressionType.Data:
759
- return useDataExpression(expr, context.fields, context.groupControl);
813
+ return useDataExpression(expr, context.fields, context);
760
814
  case exports.ExpressionType.DataMatch:
761
- return useDataMatchExpression(expr, context.fields, context.groupControl);
815
+ return useDataMatchExpression(expr, context.fields, context);
762
816
  default:
763
817
  return core.useControl(undefined);
764
818
  }
@@ -787,30 +841,62 @@ function matchesType(context, types) {
787
841
  return typeField && types.includes(typeField.value);
788
842
  }
789
843
  function hideDisplayOnly(context, field, definition, schemaInterface) {
844
+ var _lookupChildControl;
790
845
  var displayOptions = getDisplayOnlyOptions(definition);
791
- return displayOptions && !displayOptions.emptyText && schemaInterface.isEmptyValue(field, context.groupControl.fields[field.field].value);
846
+ return displayOptions && !displayOptions.emptyText && schemaInterface.isEmptyValue(field, (_lookupChildControl = lookupChildControl(context, field.field)) == null ? void 0 : _lookupChildControl.value);
792
847
  }
793
- function useJsonataExpression(jExpr, data) {
848
+ function useJsonataExpression(jExpr, dataContext, bindings) {
849
+ var pathString = jsonPathString(dataContext.path);
794
850
  var compiledExpr = React.useMemo(function () {
795
851
  try {
796
- return jsonata__default["default"](jExpr);
852
+ return jsonata__default["default"](pathString ? pathString + ".(" + jExpr + ")" : jExpr);
797
853
  } catch (e) {
798
854
  console.error(e);
799
- return jsonata__default["default"]("");
855
+ return jsonata__default["default"]("null");
800
856
  }
801
- }, [jExpr]);
857
+ }, [jExpr, pathString]);
802
858
  var control = core.useControl();
803
- core.useControlEffect(function () {
804
- return data.value;
805
- }, function (v) {
806
- try {
807
- return Promise.resolve(compiledExpr.evaluate(v)).then(function (_compiledExpr$evaluat) {
808
- control.value = _compiledExpr$evaluat;
859
+ var listenerRef = React.useRef();
860
+ var _useRefState = core.useRefState(function () {
861
+ return core.makeChangeTracker(function () {
862
+ var l = listenerRef.current;
863
+ if (l) {
864
+ listenerRef.current = undefined;
865
+ core.addAfterChangesCallback(function () {
866
+ l();
867
+ listenerRef.current = l;
868
+ });
869
+ }
809
870
  });
810
- } catch (e) {
811
- return Promise.reject(e);
812
- }
813
- }, true);
871
+ }),
872
+ ref = _useRefState[0];
873
+ React.useEffect(function () {
874
+ var apply = function apply() {
875
+ try {
876
+ var _ref$current = ref.current,
877
+ collect = _ref$current[0],
878
+ updateSubscriptions = _ref$current[1];
879
+ var _temp = _finallyRethrows(function () {
880
+ var bindingData = bindings ? core.collectChanges(collect, bindings) : undefined;
881
+ return Promise.resolve(compiledExpr.evaluate(trackedStructure(dataContext.data, collect), bindingData)).then(function (_compiledExpr$evaluat) {
882
+ control.value = _compiledExpr$evaluat;
883
+ });
884
+ }, function (_wasThrown, _result) {
885
+ updateSubscriptions();
886
+ if (_wasThrown) throw _result;
887
+ return _result;
888
+ });
889
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
890
+ } catch (e) {
891
+ return Promise.reject(e);
892
+ }
893
+ };
894
+ listenerRef.current = apply;
895
+ apply();
896
+ return function () {
897
+ return ref.current[1](true);
898
+ };
899
+ }, [compiledExpr]);
814
900
  return control;
815
901
  }
816
902
 
@@ -841,7 +927,7 @@ function useValidationHook(definition) {
841
927
  }, validatorTypes ? validatorTypes : [null]);
842
928
  }
843
929
  function useJsonataValidator(control, context, expr, hidden, i) {
844
- var errorMsg = useJsonataExpression(expr.expression, context.groupControl);
930
+ var errorMsg = useJsonataExpression(expr.expression, context);
845
931
  core.useControlEffect(function () {
846
932
  return [hidden, errorMsg.value];
847
933
  }, function (_ref) {
@@ -930,7 +1016,9 @@ function useControlRenderer(definition, fields, renderer, options) {
930
1016
  schemaField: schemaField
931
1017
  });
932
1018
  var Component = React.useCallback(function (_ref) {
933
- var parentControl = _ref.control;
1019
+ var rootControl = _ref.control,
1020
+ _ref$parentPath = _ref.parentPath,
1021
+ parentPath = _ref$parentPath === void 0 ? [] : _ref$parentPath;
934
1022
  var stopTracking = core.useComponentTracking();
935
1023
  try {
936
1024
  var _c$children$map, _c$children, _definition$adornment, _definition$adornment2;
@@ -939,17 +1027,18 @@ function useControlRenderer(definition, fields, renderer, options) {
939
1027
  _options = _r$current.options,
940
1028
  _fields = _r$current.fields,
941
1029
  _schemaField = _r$current.schemaField;
942
- var dataContext = {
943
- groupControl: parentControl,
1030
+ var parentDataContext = {
944
1031
  fields: _fields,
945
- schemaInterface: schemaInterface
1032
+ schemaInterface: schemaInterface,
1033
+ data: rootControl,
1034
+ path: parentPath
946
1035
  };
947
- var readonlyControl = useIsReadonly(dataContext);
948
- var disabledControl = useIsDisabled(dataContext);
949
- var visibleControl = useIsVisible(dataContext);
950
- var displayControl = useDynamicDisplay(dataContext);
951
- var customStyle = useCustomStyle(dataContext).value;
952
- var layoutStyle = useLayoutStyle(dataContext).value;
1036
+ var readonlyControl = useIsReadonly(parentDataContext);
1037
+ var disabledControl = useIsDisabled(parentDataContext);
1038
+ var visibleControl = useIsVisible(parentDataContext);
1039
+ var displayControl = useDynamicDisplay(parentDataContext);
1040
+ var customStyle = useCustomStyle(parentDataContext).value;
1041
+ var layoutStyle = useLayoutStyle(parentDataContext).value;
953
1042
  var visible = visibleControl.current.value;
954
1043
  var visibility = core.useControl(function () {
955
1044
  return visible != null ? {
@@ -967,29 +1056,34 @@ function useControlRenderer(definition, fields, renderer, options) {
967
1056
  };
968
1057
  });
969
1058
  });
970
- var allowedOptions = useAllowedOptions(dataContext);
971
- var defaultValueControl = useDefaultValue(dataContext);
972
- var _getControlData = getControlData(_schemaField, dataContext),
973
- control = _getControlData[0],
974
- childContext = _getControlData[1];
1059
+ var allowedOptions = useAllowedOptions(parentDataContext);
1060
+ var defaultValueControl = useDefaultValue(parentDataContext);
1061
+ var _getControlData = getControlData(_schemaField, parentDataContext),
1062
+ parentControl = _getControlData[0],
1063
+ control = _getControlData[1],
1064
+ controlDataContext = _getControlData[2];
975
1065
  core.useControlEffect(function () {
976
- return [visibility.value, defaultValueControl.value, control, parentControl.isNull, isDataControlDefinition(definition) && definition.dontClearHidden];
1066
+ return [visibility.value, defaultValueControl.value, control, isDataControlDefinition(definition) && definition.dontClearHidden, parentControl == null ? void 0 : parentControl.isNull];
977
1067
  }, function (_ref2) {
978
1068
  var vc = _ref2[0],
979
1069
  dv = _ref2[1],
980
1070
  cd = _ref2[2],
981
- pn = _ref2[3],
982
- dontClear = _ref2[4];
983
- if (pn) {
984
- parentControl.value = {};
985
- }
1071
+ dontClear = _ref2[3],
1072
+ parentNull = _ref2[4];
986
1073
  if (vc && cd && vc.visible === vc.showing) {
987
1074
  if (!vc.visible) {
988
- if (_options.clearHidden && !dontClear) cd.value = undefined;
1075
+ if (_options.clearHidden && !dontClear) {
1076
+ console.log("Clearing ", _schemaField == null ? void 0 : _schemaField.field);
1077
+ cd.value = undefined;
1078
+ }
989
1079
  } else if (cd.value == null) {
1080
+ console.log("Defaulting ", _schemaField == null ? void 0 : _schemaField.field, dv);
990
1081
  cd.value = dv;
991
1082
  }
992
1083
  }
1084
+ if (parentNull && parentControl != null && parentControl.isNull) {
1085
+ parentControl.value = {};
1086
+ }
993
1087
  }, true);
994
1088
  var myOptions = useCalculatedControl(function () {
995
1089
  var _visibility$fields;
@@ -999,14 +1093,14 @@ function useControlRenderer(definition, fields, renderer, options) {
999
1093
  disabled: _options.disabled || disabledControl.value
1000
1094
  };
1001
1095
  }).value;
1002
- useValidation(control, !!myOptions.hidden, dataContext);
1096
+ useValidation(control != null ? control : core.newControl(null), !!myOptions.hidden, parentDataContext);
1003
1097
  var childRenderers = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(function (cd) {
1004
- return useControlRenderer(cd, childContext.fields, renderer, _extends({}, _options, myOptions));
1098
+ return useControlRenderer(cd, controlDataContext.fields, renderer, _extends({}, _options, myOptions));
1005
1099
  })) != null ? _c$children$map : [];
1006
1100
  React.useEffect(function () {
1007
1101
  if (control && typeof myOptions.disabled === "boolean") control.disabled = myOptions.disabled;
1008
1102
  }, [control, myOptions.disabled]);
1009
- if (parentControl.isNull) return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null);
1103
+ if (parentControl != null && parentControl.isNull) return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null);
1010
1104
  var adornments = (_definition$adornment = (_definition$adornment2 = definition.adornments) == null ? void 0 : _definition$adornment2.map(function (x) {
1011
1105
  return renderer.renderAdornment({
1012
1106
  adornment: x
@@ -1024,7 +1118,7 @@ function useControlRenderer(definition, fields, renderer, options) {
1024
1118
  },
1025
1119
  createDataProps: dataProps,
1026
1120
  formOptions: myOptions,
1027
- dataContext: dataContext,
1121
+ dataContext: controlDataContext,
1028
1122
  control: displayControl != null ? displayControl : control,
1029
1123
  schemaField: _schemaField,
1030
1124
  displayControl: displayControl,
@@ -1051,15 +1145,17 @@ function lookupSchemaField(c, fields) {
1051
1145
  return fieldName ? findField(fields, fieldName) : undefined;
1052
1146
  }
1053
1147
  function getControlData(schemaField, parentContext) {
1054
- var _parentContext$groupC, _parentContext$groupC2;
1055
- var childControl = schemaField ? (_parentContext$groupC = (_parentContext$groupC2 = parentContext.groupControl.fields) == null ? void 0 : _parentContext$groupC2[schemaField.field]) != null ? _parentContext$groupC : core.newControl({}) : undefined;
1056
- return [childControl, schemaField && isCompoundField(schemaField) ? {
1057
- groupControl: childControl,
1058
- fields: schemaField.children,
1059
- schemaInterface: parentContext.schemaInterface
1060
- } : parentContext];
1061
- }
1062
- function groupProps(renderOptions, childCount, _renderChild, control, className, style) {
1148
+ var data = parentContext.data,
1149
+ path = parentContext.path;
1150
+ var parentControl = data.lookupControl(path);
1151
+ var childPath = schemaField ? [].concat(path, [schemaField.field]) : path;
1152
+ var childControl = schemaField && parentControl ? parentControl.fields[schemaField.field] : undefined;
1153
+ return [parentControl, childControl, schemaField ? _extends({}, parentContext, {
1154
+ path: childPath,
1155
+ fields: isCompoundField(schemaField) ? schemaField.children : parentContext.fields
1156
+ }) : parentContext];
1157
+ }
1158
+ function groupProps(renderOptions, childCount, _renderChild, data, className, style) {
1063
1159
  if (renderOptions === void 0) {
1064
1160
  renderOptions = {
1065
1161
  type: "Standard"
@@ -1069,7 +1165,8 @@ function groupProps(renderOptions, childCount, _renderChild, control, className,
1069
1165
  childCount: childCount,
1070
1166
  renderChild: function renderChild(i) {
1071
1167
  return _renderChild(i, i, {
1072
- control: control
1168
+ control: data.data,
1169
+ parentPath: data.path
1073
1170
  });
1074
1171
  },
1075
1172
  renderOptions: renderOptions,
@@ -1092,6 +1189,7 @@ function defaultDataProps(_ref3) {
1092
1189
  var fieldOptions = ((_field$options$length = (_field$options = field.options) == null ? void 0 : _field$options.length) != null ? _field$options$length : 0) === 0 ? null : field.options;
1093
1190
  var allowed = (_allowedOptions$value = allowedOptions == null ? void 0 : allowedOptions.value) != null ? _allowedOptions$value : [];
1094
1191
  return _extends({
1192
+ definition: definition,
1095
1193
  control: control,
1096
1194
  field: field,
1097
1195
  id: "c" + control.uniqueId,
@@ -1140,7 +1238,7 @@ function defaultArrayProps(arrayControl, field, required, style, className, _ren
1140
1238
  };
1141
1239
  },
1142
1240
  renderElement: function renderElement(i) {
1143
- return _renderElement(elems[i]);
1241
+ return _renderElement(i);
1144
1242
  },
1145
1243
  className: cc(className),
1146
1244
  style: style
@@ -1172,7 +1270,7 @@ function renderControlLayout(_ref4) {
1172
1270
  }));
1173
1271
  }
1174
1272
  return {
1175
- processLayout: renderer.renderGroup(groupProps(c.groupOptions, childCount, childRenderer, dataContext.groupControl, c.styleClass, style)),
1273
+ processLayout: renderer.renderGroup(groupProps(c.groupOptions, childCount, childRenderer, dataContext, c.styleClass, style)),
1176
1274
  label: {
1177
1275
  label: c.title,
1178
1276
  type: exports.LabelType.Group,
@@ -1204,22 +1302,27 @@ function renderControlLayout(_ref4) {
1204
1302
  };
1205
1303
  }
1206
1304
  return {};
1207
- function renderData(c, elementControl) {
1305
+ function renderData(c, elemIndex) {
1208
1306
  if (!schemaField) return {
1209
1307
  children: "No schema field for: " + c.field
1210
1308
  };
1309
+ if (!childControl) return {
1310
+ children: "No control for: " + c.field
1311
+ };
1211
1312
  var props = dataProps({
1212
1313
  definition: c,
1213
1314
  field: schemaField,
1214
- dataContext: dataContext,
1215
- control: elementControl != null ? elementControl : childControl,
1315
+ dataContext: elemIndex != null ? _extends({}, dataContext, {
1316
+ path: [].concat(dataContext.path, [elemIndex])
1317
+ }) : dataContext,
1318
+ control: elemIndex != null ? childControl.elements[elemIndex] : childControl,
1216
1319
  options: dataOptions,
1217
1320
  style: style,
1218
1321
  childCount: childCount,
1219
1322
  allowedOptions: allowedOptions,
1220
1323
  renderChild: childRenderer,
1221
- elementRenderer: elementControl == null && schemaField.collection ? function (element) {
1222
- return renderLayoutParts(renderData(c, element), renderer).children;
1324
+ elementRenderer: elemIndex == null && schemaField.collection ? function (ei) {
1325
+ return renderLayoutParts(renderData(c, ei), renderer).children;
1223
1326
  } : undefined
1224
1327
  });
1225
1328
  var labelText = !c.hideTitle ? controlTitle(c.title, schemaField) : undefined;
@@ -1619,7 +1722,8 @@ function createDefaultDataRenderer(options) {
1619
1722
  },
1620
1723
  renderChild: function renderChild(i) {
1621
1724
  return props.renderChild(i, i, {
1622
- control: props.control
1725
+ control: props.dataContext.data,
1726
+ parentPath: props.dataContext.path
1623
1727
  });
1624
1728
  },
1625
1729
  childCount: props.childCount
@@ -2147,8 +2251,10 @@ exports.isGroupControl = isGroupControl;
2147
2251
  exports.isGroupControlsDefinition = isGroupControlsDefinition;
2148
2252
  exports.isIconAdornment = isIconAdornment;
2149
2253
  exports.isScalarField = isScalarField;
2254
+ exports.jsonPathString = jsonPathString;
2150
2255
  exports.jsonataExpr = jsonataExpr;
2151
2256
  exports.layoutKeyForPlacement = layoutKeyForPlacement;
2257
+ exports.lookupChildControl = lookupChildControl;
2152
2258
  exports.lookupSchemaField = lookupSchemaField;
2153
2259
  exports.makeCompoundField = makeCompoundField;
2154
2260
  exports.makeEvalExpressionHook = makeEvalExpressionHook;