@linzjs/step-ag-grid 4.0.1 → 4.0.2

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/dist/index.js CHANGED
@@ -2246,6 +2246,7 @@ var GridPopoverContextProvider = function (_a) {
2246
2246
 
2247
2247
  var GridSubComponentContext = react.createContext({
2248
2248
  value: "GridSubComponentContext value no context",
2249
+ data: {},
2249
2250
  setValue: function () {
2250
2251
  console.error("GridSubComponentContext setValue no context");
2251
2252
  },
@@ -3017,7 +3018,7 @@ var fieldToString = function (field) {
3017
3018
  return typeof field == "symbol" ? field.toString() : "".concat(field);
3018
3019
  };
3019
3020
  var GridFormDropDown = function (props) {
3020
- var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue;
3021
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
3021
3022
  var stopEditing = react.useContext(GridContext).stopEditing;
3022
3023
  var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
3023
3024
  var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
@@ -3210,6 +3211,7 @@ var GridFormDropDown = function (props) {
3210
3211
  selectItemHandler(item.value).then();
3211
3212
  }
3212
3213
  } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedSubComponent === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
3214
+ data: data,
3213
3215
  value: subSelectedValue,
3214
3216
  setValue: function (value) {
3215
3217
  setSubSelectedValue(value);
@@ -3228,18 +3230,18 @@ var GridFormDropDown = function (props) {
3228
3230
  };
3229
3231
 
3230
3232
  var GridFormMultiSelect = function (props) {
3231
- var selectedRows = useGridPopoverContext().selectedRows;
3233
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, data = _a.data;
3232
3234
  var initialiseValues = react.useMemo(function () {
3233
3235
  var r = props.initialSelectedValues && props.initialSelectedValues(selectedRows);
3234
3236
  // convert array of strings to object<value,null>
3235
3237
  return Array.isArray(r) ? lodashEs.fromPairs(r.map(function (v) { return [v, null]; })) : r;
3236
3238
  }, [props, selectedRows]);
3237
3239
  var subComponentIsValid = react.useRef({});
3238
- var _a = react.useState(function () { return initialiseValues !== null && initialiseValues !== void 0 ? initialiseValues : {}; }), selectedValues = _a[0], setSelectedValues = _a[1];
3239
- var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
3240
- var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
3240
+ var _b = react.useState(function () { return initialiseValues !== null && initialiseValues !== void 0 ? initialiseValues : {}; }), selectedValues = _b[0], setSelectedValues = _b[1];
3241
+ var _c = react.useState(""), filter = _c[0], setFilter = _c[1];
3242
+ var _d = react.useState([]), filteredValues = _d[0], setFilteredValues = _d[1];
3241
3243
  var optionsInitialising = react.useRef(false);
3242
- var _d = react.useState(), options = _d[0], setOptions = _d[1];
3244
+ var _e = react.useState(), options = _e[0], setOptions = _e[1];
3243
3245
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3244
3246
  var validations, notValid, menuOptionSubValueResult;
3245
3247
  return __generator(this, function (_a) {
@@ -3331,10 +3333,10 @@ var GridFormMultiSelect = function (props) {
3331
3333
  setSelectedValues(__assign(__assign({}, selectedValues), (_a = {}, _a["".concat(item.value)] = null, _a)));
3332
3334
  }
3333
3335
  }, [selectedValues]);
3334
- var _e = useGridPopoverHook({
3336
+ var _f = useGridPopoverHook({
3335
3337
  className: props.className,
3336
3338
  save: save
3337
- }), popoverWrapper = _e.popoverWrapper, lastInputKeyboardEventHandlers = _e.lastInputKeyboardEventHandlers, triggerSave = _e.triggerSave;
3339
+ }), popoverWrapper = _f.popoverWrapper, lastInputKeyboardEventHandlers = _f.lastInputKeyboardEventHandlers, triggerSave = _f.triggerSave;
3338
3340
  return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormMultiSelect-container" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && props.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3339
3341
  var _b;
3340
3342
  var ref = _a.ref;
@@ -3354,6 +3356,7 @@ var GridFormMultiSelect = function (props) {
3354
3356
  /*Do nothing, change handled by menuItem*/
3355
3357
  } }) })), "".concat(item.value) in selectedValues && item.subComponent && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
3356
3358
  return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
3359
+ data: data,
3357
3360
  value: selectedValues["".concat(item.value)],
3358
3361
  setValue: function (value) {
3359
3362
  var _a;
@@ -3382,7 +3385,7 @@ var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
3382
3385
  * you need a useMemo around your columnDefs
3383
3386
  */
3384
3387
  var GridFormPopoverMenu = function (props) {
3385
- var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, updateValue = _a.updateValue;
3388
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, updateValue = _a.updateValue, data = _a.data;
3386
3389
  var optionsInitialising = react.useRef(false);
3387
3390
  var _b = react.useState(), options = _b[0], setOptions = _b[1];
3388
3391
  // Save triggers during async action processing which triggers another action(), this ref blocks that
@@ -3500,6 +3503,7 @@ var GridFormPopoverMenu = function (props) {
3500
3503
  return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !filteredOptions, className: "GridFormPopupMenu" }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3501
3504
  return item.label === PopoutMenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) { return onMenuItemClick(e, item); }, disabled: !!item.disabled || !(filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.includes(item)), title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "" }, { children: item.label }), "".concat(item.label)), item.subComponent && subComponentSelected === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
3502
3505
  return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
3506
+ data: data,
3503
3507
  value: subSelectedValue,
3504
3508
  setValue: function (value) {
3505
3509
  setSubSelectedValue(value);
@@ -3804,7 +3808,7 @@ var TextAreaInput = function (props) {
3804
3808
  } }, { children: props.helpText })))] })));
3805
3809
  };
3806
3810
 
3807
- var TextInputValidator = function (props, value) {
3811
+ var TextInputValidator = function (props, value, data) {
3808
3812
  if (value == null)
3809
3813
  return null;
3810
3814
  // This can happen because subcomponent is invoked without type safety
@@ -3818,17 +3822,17 @@ var TextInputValidator = function (props, value) {
3818
3822
  return "Text must be no longer than ".concat(props.maxLength, " characters");
3819
3823
  }
3820
3824
  if (props.validate) {
3821
- return props.validate(value);
3825
+ return props.validate(value, data);
3822
3826
  }
3823
3827
  return null;
3824
3828
  };
3825
3829
 
3826
3830
  var GridFormTextArea = function (props) {
3827
3831
  var _a, _b;
3828
- var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
3832
+ var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value, data = _c.data;
3829
3833
  var _d = react.useState(initialVale != null ? "".concat(initialVale) : ""), value = _d[0], setValue = _d[1];
3830
3834
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
3831
- var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3835
+ var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [props, value, data]);
3832
3836
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3833
3837
  return __generator(this, function (_a) {
3834
3838
  switch (_a.label) {
@@ -3860,11 +3864,11 @@ var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __
3860
3864
 
3861
3865
  var GridFormTextInput = function (props) {
3862
3866
  var _a, _b;
3863
- var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
3867
+ var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value, data = _c.data;
3864
3868
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3865
3869
  var initValue = initialVale == null ? "" : "".concat(initialVale);
3866
3870
  var _d = react.useState(initValue), value = _d[0], setValue = _d[1];
3867
- var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3871
+ var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [data, props, value]);
3868
3872
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3869
3873
  var trimmedValue;
3870
3874
  return __generator(this, function (_a) {
@@ -3900,14 +3904,14 @@ var GridPopoverTextInput = function (colDef, params) {
3900
3904
 
3901
3905
  var GridFormSubComponentTextInput = function (props) {
3902
3906
  var _a;
3903
- var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
3907
+ var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave, data = _b.data;
3904
3908
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3905
3909
  // If is not initialised yet as it's just been created then set the default value
3906
3910
  react.useEffect(function () {
3907
3911
  if (value == null)
3908
3912
  setValue(props.defaultValue);
3909
3913
  }, [props.defaultValue, setValue, value]);
3910
- var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3914
+ var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [data, props, value]);
3911
3915
  react.useEffect(function () {
3912
3916
  setValid(value != null && invalid() == null);
3913
3917
  }, [setValid, invalid, value]);
@@ -3934,14 +3938,14 @@ var GridFormSubComponentTextInput = function (props) {
3934
3938
 
3935
3939
  var GridFormSubComponentTextArea = function (props) {
3936
3940
  var _a;
3937
- var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
3941
+ var _b = react.useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
3938
3942
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
3939
3943
  // If is not initialised yet as it's just been created then set the default value
3940
3944
  react.useEffect(function () {
3941
3945
  if (value == null)
3942
3946
  setValue(props.defaultValue);
3943
3947
  }, [props.defaultValue, setValue, value]);
3944
- var invalid = react.useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3948
+ var invalid = react.useCallback(function () { return TextInputValidator(props, value, data); }, [data, props, value]);
3945
3949
  react.useEffect(function () {
3946
3950
  setValid(value != null && invalid() == null);
3947
3951
  }, [setValid, invalid, value]);