@linzjs/step-ag-grid 3.0.0 → 3.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
@@ -1784,54 +1784,6 @@ var MenuRadioGroupFr = function (_a, externalRef) {
1784
1784
  };
1785
1785
  var MenuRadioGroup = react.forwardRef(MenuRadioGroupFr);
1786
1786
 
1787
- var GridUpdatingContext = react.createContext({
1788
- checkUpdating: function () {
1789
- console.error("Missing GridUpdatingContext");
1790
- return false;
1791
- },
1792
- modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
1793
- return __generator(this, function (_a) {
1794
- console.error("Missing GridUpdatingContext");
1795
- return [2 /*return*/];
1796
- });
1797
- }); }
1798
- });
1799
-
1800
- var GridUpdatingContextProvider = function (props) {
1801
- var updatingBlocks = react.useRef({});
1802
- var updating = react.useRef({});
1803
- var resetUpdating = function () {
1804
- var mergedUpdatingBlocks = {};
1805
- for (var key in updatingBlocks.current) {
1806
- mergedUpdatingBlocks[key] = lodashEs.flatten(updatingBlocks.current[key]);
1807
- }
1808
- updating.current = mergedUpdatingBlocks;
1809
- };
1810
- var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
1811
- var fieldUpdatingIds, idRef;
1812
- var _a;
1813
- return __generator(this, function (_b) {
1814
- switch (_b.label) {
1815
- case 0:
1816
- fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
1817
- idRef = __spreadArray([], ids, true);
1818
- fieldUpdatingIds.push(idRef);
1819
- resetUpdating();
1820
- return [4 /*yield*/, fn()];
1821
- case 1:
1822
- _b.sent();
1823
- lodashEs.remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
1824
- resetUpdating();
1825
- return [2 /*return*/];
1826
- }
1827
- });
1828
- }); };
1829
- var checkUpdating = function (fields, id) {
1830
- return lodashEs.castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
1831
- };
1832
- return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
1833
- };
1834
-
1835
1787
  var GridContext = react.createContext({
1836
1788
  gridReady: function () {
1837
1789
  console.error("no context provider for gridReady");
@@ -1905,6 +1857,19 @@ var GridContext = react.createContext({
1905
1857
  }
1906
1858
  });
1907
1859
 
1860
+ var GridUpdatingContext = react.createContext({
1861
+ checkUpdating: function () {
1862
+ console.error("Missing GridUpdatingContext");
1863
+ return false;
1864
+ },
1865
+ modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
1866
+ return __generator(this, function (_a) {
1867
+ console.error("Missing GridUpdatingContext");
1868
+ return [2 /*return*/];
1869
+ });
1870
+ }); }
1871
+ });
1872
+
1908
1873
  /**
1909
1874
  * Context for AgGrid operations.
1910
1875
  * Make sure you wrap AgGrid in this.
@@ -2184,6 +2149,109 @@ var GridContextProvider = function (props) {
2184
2149
  } }, { children: props.children })));
2185
2150
  };
2186
2151
 
2152
+ var GridUpdatingContextProvider = function (props) {
2153
+ var updatingBlocks = react.useRef({});
2154
+ var updating = react.useRef({});
2155
+ var resetUpdating = function () {
2156
+ var mergedUpdatingBlocks = {};
2157
+ for (var key in updatingBlocks.current) {
2158
+ mergedUpdatingBlocks[key] = lodashEs.flatten(updatingBlocks.current[key]);
2159
+ }
2160
+ updating.current = mergedUpdatingBlocks;
2161
+ };
2162
+ var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
2163
+ var fieldUpdatingIds, idRef;
2164
+ var _a;
2165
+ return __generator(this, function (_b) {
2166
+ switch (_b.label) {
2167
+ case 0:
2168
+ fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2169
+ idRef = __spreadArray([], ids, true);
2170
+ fieldUpdatingIds.push(idRef);
2171
+ resetUpdating();
2172
+ return [4 /*yield*/, fn()];
2173
+ case 1:
2174
+ _b.sent();
2175
+ lodashEs.remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2176
+ resetUpdating();
2177
+ return [2 /*return*/];
2178
+ }
2179
+ });
2180
+ }); };
2181
+ var checkUpdating = function (fields, id) {
2182
+ return lodashEs.castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
2183
+ };
2184
+ return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
2185
+ };
2186
+
2187
+ var GridPopoverContext = react.createContext({
2188
+ anchorRef: { current: null },
2189
+ saving: false,
2190
+ setSaving: function () { },
2191
+ field: "",
2192
+ value: null,
2193
+ data: {},
2194
+ selectedRows: [],
2195
+ updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2196
+ return [2 /*return*/, false];
2197
+ }); }); }
2198
+ });
2199
+ var useGridPopoverContext = function () {
2200
+ return react.useContext(GridPopoverContext);
2201
+ };
2202
+
2203
+ var GridPopoverContextProvider = function (_a) {
2204
+ var _b, _c, _d;
2205
+ var props = _a.props, children = _a.children;
2206
+ var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
2207
+ var anchorRef = react.useRef(props.eGridCell);
2208
+ var _f = react.useState(false), saving = _f[0], setSaving = _f[1];
2209
+ var colDef = props.colDef;
2210
+ var cellEditorParams = colDef.cellEditorParams;
2211
+ var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2212
+ // Then item that is clicked on will always be first in the list
2213
+ var selectedRows = react.useMemo(function () { return (multiEdit ? lodashEs.sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2214
+ var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2215
+ var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
2216
+ switch (_b.label) {
2217
+ case 0:
2218
+ _a = !saving;
2219
+ if (!_a) return [3 /*break*/, 2];
2220
+ return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2221
+ case 1:
2222
+ _a = (_b.sent());
2223
+ _b.label = 2;
2224
+ case 2: return [2 /*return*/, _a];
2225
+ }
2226
+ }); }); }, [field, saving, selectedRows, updatingCells]);
2227
+ return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
2228
+ anchorRef: anchorRef,
2229
+ saving: saving,
2230
+ setSaving: setSaving,
2231
+ selectedRows: selectedRows,
2232
+ field: field,
2233
+ data: props.data,
2234
+ value: props.value,
2235
+ updateValue: updateValue
2236
+ } }, { children: children })));
2237
+ };
2238
+
2239
+ var GridSubComponentContext = react.createContext({
2240
+ value: "GridSubComponentContext value no context",
2241
+ setValue: function () {
2242
+ console.error("GridSubComponentContext setValue no context");
2243
+ },
2244
+ setValid: function () {
2245
+ console.error("GridSubComponentContext setValid no context");
2246
+ },
2247
+ triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
2248
+ return __generator(this, function (_a) {
2249
+ console.error("GridSubComponentContext triggerSave no context");
2250
+ return [2 /*return*/];
2251
+ });
2252
+ }); }
2253
+ });
2254
+
2187
2255
  function toVal(mix) {
2188
2256
  var k, y, str='';
2189
2257
  if (mix) {
@@ -2650,55 +2718,6 @@ var GridRendererGenericCell = function (props) {
2650
2718
  return (jsxRuntime.jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_c = (_b = colDef.field) !== null && _b !== void 0 ? _b : colDef.colId) !== null && _c !== void 0 ? _c : "", props.data.id) }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [typeof warningText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_info", title: infoText }), jsxRuntime.jsx("span", __assign({ title: formatted }, { children: formatted }))] }) })));
2651
2719
  };
2652
2720
 
2653
- var GridPopoverContext = react.createContext({
2654
- anchorRef: { current: null },
2655
- saving: false,
2656
- setSaving: function () { },
2657
- field: "",
2658
- value: null,
2659
- data: null,
2660
- selectedRows: [],
2661
- updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2662
- return [2 /*return*/, false];
2663
- }); }); }
2664
- });
2665
-
2666
- var GridPopoverContextProvider = function (_a) {
2667
- var _b, _c, _d;
2668
- var props = _a.props, children = _a.children;
2669
- var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
2670
- var anchorRef = react.useRef(props.eGridCell);
2671
- var _f = react.useState(false), saving = _f[0], setSaving = _f[1];
2672
- var colDef = props.colDef;
2673
- var cellEditorParams = colDef.cellEditorParams;
2674
- var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2675
- // Then item that is clicked on will always be first in the list
2676
- var selectedRows = react.useMemo(function () { return (multiEdit ? lodashEs.sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2677
- var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2678
- var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
2679
- switch (_b.label) {
2680
- case 0:
2681
- _a = !saving;
2682
- if (!_a) return [3 /*break*/, 2];
2683
- return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2684
- case 1:
2685
- _a = (_b.sent());
2686
- _b.label = 2;
2687
- case 2: return [2 /*return*/, _a];
2688
- }
2689
- }); }); }, [field, saving, selectedRows, updatingCells]);
2690
- return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
2691
- anchorRef: anchorRef,
2692
- saving: saving,
2693
- setSaving: setSaving,
2694
- selectedRows: selectedRows,
2695
- field: field,
2696
- data: props.data,
2697
- value: props.value,
2698
- updateValue: updateValue
2699
- } }, { children: children })));
2700
- };
2701
-
2702
2721
  var GridCellRenderer = function (props) {
2703
2722
  var _a, _b, _c;
2704
2723
  var checkUpdating = react.useContext(GridUpdatingContext).checkUpdating;
@@ -2757,7 +2776,7 @@ var ComponentLoadingWrapper = function (props) {
2757
2776
 
2758
2777
  var useGridPopoverHook = function (props) {
2759
2778
  var stopEditing = react.useContext(GridContext).stopEditing;
2760
- var _a = react.useContext(GridPopoverContext), anchorRef = _a.anchorRef, saving = _a.saving, updateValue = _a.updateValue;
2779
+ var _a = useGridPopoverContext(), anchorRef = _a.anchorRef, saving = _a.saving, updateValue = _a.updateValue;
2761
2780
  var saveButtonRef = react.useRef(null);
2762
2781
  var _b = react.useState(false), isOpen = _b[0], setOpen = _b[1];
2763
2782
  react.useEffect(function () {
@@ -2910,8 +2929,11 @@ var MenuHeaderString = "_____MENU_HEADER_____";
2910
2929
  var MenuHeaderItem = function (title) {
2911
2930
  return { label: title, value: MenuHeaderString };
2912
2931
  };
2932
+ var fieldToString = function (field) {
2933
+ return typeof field == "symbol" ? field.toString() : "".concat(field);
2934
+ };
2913
2935
  var GridFormDropDown = function (props) {
2914
- var _a = react.useContext(GridPopoverContext), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue;
2936
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue;
2915
2937
  var stopEditing = react.useContext(GridContext).stopEditing;
2916
2938
  var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
2917
2939
  var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
@@ -3067,69 +3089,48 @@ var GridFormDropDown = function (props) {
3067
3089
  var _b;
3068
3090
  var ref = _a.ref;
3069
3091
  return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsxRuntime.jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));
3070
- } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] }))), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && jsxRuntime.jsx(MenuItem, { children: "[Empty]" }, "".concat(field, "-empty")), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3092
+ } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] }))), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && (jsxRuntime.jsx(MenuItem, { children: "[Empty]" }, "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3071
3093
  var _a;
3072
3094
  return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsx("div", { children: !item.subComponent ? (jsxRuntime.jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
3073
3095
  selectItemHandler(item.value).then();
3074
- } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(field, "-").concat(index))) : (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
3075
- return item.subComponent &&
3076
- item.subComponent({
3077
- setValue: function (value) {
3078
- var localSubComponentValues = __spreadArray([], subComponentValues, true);
3079
- var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
3080
- var optionValue = _a.optionValue;
3081
- return optionValue === item.value;
3096
+ } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(fieldToString(field), "-").concat(index))) : (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
3097
+ return item.subComponent && (jsxRuntime.jsx(item.subComponent, { setValue: function (value) {
3098
+ var localSubComponentValues = __spreadArray([], subComponentValues, true);
3099
+ var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
3100
+ var optionValue = _a.optionValue;
3101
+ return optionValue === item.value;
3102
+ });
3103
+ if (subComponentValueIndex !== -1) {
3104
+ localSubComponentValues[subComponentValueIndex].subComponentValue = value;
3105
+ }
3106
+ else {
3107
+ localSubComponentValues.push({
3108
+ subComponentValue: value,
3109
+ optionValue: item.value
3082
3110
  });
3083
- if (subComponentValueIndex !== -1) {
3084
- localSubComponentValues[subComponentValueIndex].subComponentValue = value;
3085
- }
3086
- else {
3087
- localSubComponentValues.push({
3088
- subComponentValue: value,
3089
- optionValue: item.value
3090
- });
3091
- }
3092
- setSubComponentValues(localSubComponentValues);
3093
- },
3094
- keyDown: function (key, event) {
3095
- var subComponentItem = subComponentValues.find(function (_a) {
3096
- var optionValue = _a.optionValue;
3097
- return optionValue === item.value;
3111
+ }
3112
+ setSubComponentValues(localSubComponentValues);
3113
+ }, keyDown: function (key, event) {
3114
+ var subComponentItem = subComponentValues.find(function (_a) {
3115
+ var optionValue = _a.optionValue;
3116
+ return optionValue === item.value;
3117
+ });
3118
+ if ((key === "Enter" || key === "Tab") && subComponentItem) {
3119
+ event.preventDefault();
3120
+ event.stopPropagation();
3121
+ return selectItemHandler(item.value, subComponentItem.subComponentValue).then(function () {
3122
+ ref.closeMenu();
3123
+ return true;
3098
3124
  });
3099
- if ((key === "Enter" || key === "Tab") && subComponentItem) {
3100
- event.preventDefault();
3101
- event.stopPropagation();
3102
- return selectItemHandler(item.value, subComponentItem.subComponentValue).then(function () {
3103
- ref.closeMenu();
3104
- return true;
3105
- });
3106
- }
3107
- return false;
3108
- },
3109
- key: "".concat(field, "-").concat(index, "_subcomponent_inner")
3110
- }, ref);
3111
- } }), "".concat(field, "-").concat(index, "_subcomponent"))) }, "menu-wrapper-".concat(index)));
3125
+ }
3126
+ return false;
3127
+ } }, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")));
3128
+ } }), "".concat(fieldToString(field), "-").concat(index, "_subcomponent"))) }, "menu-wrapper-".concat(index)));
3112
3129
  })] }) }))] }));
3113
3130
  };
3114
3131
 
3115
- var GridSubComponentContext = react.createContext({
3116
- value: "GridSubComponentContext value no context",
3117
- setValue: function () {
3118
- console.error("GridSubComponentContext setValue no context");
3119
- },
3120
- setValid: function () {
3121
- console.error("GridSubComponentContext setValid no context");
3122
- },
3123
- triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
3124
- return __generator(this, function (_a) {
3125
- console.error("GridSubComponentContext triggerSave no context");
3126
- return [2 /*return*/];
3127
- });
3128
- }); }
3129
- });
3130
-
3131
3132
  var GridFormMultiSelect = function (props) {
3132
- var selectedRows = react.useContext(GridPopoverContext).selectedRows;
3133
+ var selectedRows = useGridPopoverContext().selectedRows;
3133
3134
  var initialiseValues = react.useMemo(function () {
3134
3135
  var r = props.initialSelectedValues && props.initialSelectedValues(selectedRows);
3135
3136
  // convert array of strings to object<value,null>
@@ -3291,7 +3292,7 @@ var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
3291
3292
  * you need a useMemo around your columnDefs
3292
3293
  */
3293
3294
  var GridFormPopoverMenu = function (props) {
3294
- var _a = react.useContext(GridPopoverContext), selectedRows = _a.selectedRows, updateValue = _a.updateValue;
3295
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, updateValue = _a.updateValue;
3295
3296
  var optionsInitialising = react.useRef(false);
3296
3297
  var _b = react.useState(), options = _b[0], setOptions = _b[1];
3297
3298
  // Save triggers during async action processing which triggers another action(), this ref blocks that
@@ -3299,6 +3300,22 @@ var GridFormPopoverMenu = function (props) {
3299
3300
  var _c = react.useState(null), subComponentSelected = _c[0], setSubComponentSelected = _c[1];
3300
3301
  var subComponentIsValid = react.useRef(false);
3301
3302
  var _d = react.useState(), subSelectedValue = _d[0], setSubSelectedValue = _d[1];
3303
+ var defaultAction = react.useCallback(function (selectedRows, menuOption) { return __awaiter(void 0, void 0, void 0, function () {
3304
+ return __generator(this, function (_a) {
3305
+ switch (_a.label) {
3306
+ case 0:
3307
+ if (!props.defaultAction) return [3 /*break*/, 2];
3308
+ return [4 /*yield*/, props.defaultAction(selectedRows, menuOption)];
3309
+ case 1:
3310
+ _a.sent();
3311
+ return [3 /*break*/, 3];
3312
+ case 2:
3313
+ console.error("No action specified for ".concat(menuOption.label, " menu options"));
3314
+ _a.label = 3;
3315
+ case 3: return [2 /*return*/];
3316
+ }
3317
+ });
3318
+ }); }, [props]);
3302
3319
  // Load up options list if it's async function
3303
3320
  react.useEffect(function () {
3304
3321
  var _a;
@@ -3307,50 +3324,55 @@ var GridFormPopoverMenu = function (props) {
3307
3324
  optionsInitialising.current = true;
3308
3325
  var optionsConf = (_a = props.options) !== null && _a !== void 0 ? _a : [];
3309
3326
  (function () { return __awaiter(void 0, void 0, void 0, function () {
3310
- var _a, _b;
3311
- return __generator(this, function (_c) {
3312
- switch (_c.label) {
3327
+ var newOptions, _a, anyOptionsAreMissingAction;
3328
+ return __generator(this, function (_b) {
3329
+ switch (_b.label) {
3313
3330
  case 0:
3314
- _a = setOptions;
3315
3331
  if (!(typeof optionsConf == "function")) return [3 /*break*/, 2];
3316
3332
  return [4 /*yield*/, optionsConf(selectedRows)];
3317
3333
  case 1:
3318
- _b = _c.sent();
3334
+ _a = _b.sent();
3319
3335
  return [3 /*break*/, 3];
3320
3336
  case 2:
3321
- _b = optionsConf;
3322
- _c.label = 3;
3337
+ _a = optionsConf;
3338
+ _b.label = 3;
3323
3339
  case 3:
3324
- _a.apply(void 0, [_b]);
3340
+ newOptions = _a;
3341
+ setOptions(newOptions);
3342
+ if (!props.defaultAction) {
3343
+ anyOptionsAreMissingAction = newOptions.some(function (option) { return !option.action; });
3344
+ if (anyOptionsAreMissingAction) {
3345
+ console.error("There's no default action handler and some Menu options are missing an action handler", {
3346
+ invalidMenuOptions: newOptions.filter(function (option) { return !option.action; })
3347
+ });
3348
+ }
3349
+ }
3325
3350
  optionsInitialising.current = false;
3326
3351
  return [2 /*return*/];
3327
3352
  }
3328
3353
  });
3329
3354
  }); })();
3330
- }, [options, props.options, selectedRows]);
3355
+ }, [options, props.defaultAction, props.options, selectedRows]);
3331
3356
  var actionClick = react.useCallback(function (menuOption) { return __awaiter(void 0, void 0, void 0, function () {
3332
3357
  return __generator(this, function (_a) {
3333
3358
  actionProcessing.current = true;
3334
3359
  return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
3335
- var result, _a;
3360
+ var result;
3361
+ var _a;
3336
3362
  return __generator(this, function (_b) {
3337
3363
  switch (_b.label) {
3338
3364
  case 0:
3339
3365
  result = __assign(__assign({}, menuOption), { subValue: subSelectedValue });
3340
- _a = menuOption.action;
3341
- if (!_a) return [3 /*break*/, 2];
3342
- return [4 /*yield*/, menuOption.action(selectedRows, result)];
3366
+ return [4 /*yield*/, ((_a = menuOption.action) !== null && _a !== void 0 ? _a : defaultAction)(selectedRows, result)];
3343
3367
  case 1:
3344
- _a = (_b.sent());
3345
- _b.label = 2;
3346
- case 2:
3368
+ _b.sent();
3347
3369
  actionProcessing.current = false;
3348
3370
  return [2 /*return*/, true];
3349
3371
  }
3350
3372
  });
3351
3373
  }); })];
3352
3374
  });
3353
- }); }, [selectedRows, subSelectedValue, updateValue]);
3375
+ }); }, [defaultAction, selectedRows, subSelectedValue, updateValue]);
3354
3376
  var onMenuItemClick = react.useCallback(function (e, item) {
3355
3377
  if (item.subComponent) {
3356
3378
  subComponentIsValid.current = false;
@@ -3507,7 +3529,7 @@ var TextInputFormatted = function (props) {
3507
3529
  };
3508
3530
 
3509
3531
  var GridFormEditBearing = function (props) {
3510
- var _a = react.useContext(GridPopoverContext), field = _a.field, initialValue = _a.value;
3532
+ var _a = useGridPopoverContext(), field = _a.field, initialValue = _a.value;
3511
3533
  var _b = react.useState("".concat(initialValue !== null && initialValue !== void 0 ? initialValue : "")), value = _b[0], setValue = _b[1];
3512
3534
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3513
3535
  var parsedValue;
@@ -3529,7 +3551,9 @@ var GridFormEditBearing = function (props) {
3529
3551
  console.error("field is not defined in ColDef");
3530
3552
  }
3531
3553
  else {
3532
- selectedRows.forEach(function (row) { return (row[field] = parsedValue); });
3554
+ selectedRows.forEach(function (row) {
3555
+ row[field] = parsedValue;
3556
+ });
3533
3557
  }
3534
3558
  _a.label = 3;
3535
3559
  case 3: return [2 /*return*/, true];
@@ -3589,7 +3613,7 @@ var GridPopoverEditDropDown = function (colDef, props) {
3589
3613
  };
3590
3614
 
3591
3615
  var GridFormMessage = function (props) {
3592
- var selectedRows = react.useContext(GridPopoverContext).selectedRows;
3616
+ var selectedRows = useGridPopoverContext().selectedRows;
3593
3617
  var _a = react.useState(null), message = _a[0], setMessage = _a[1];
3594
3618
  var popoverWrapper = useGridPopoverHook({ className: props.className }).popoverWrapper;
3595
3619
  react.useEffect(function () {
@@ -3696,8 +3720,8 @@ var TextAreaInput = function (props) {
3696
3720
 
3697
3721
  var GridFormTextArea = function (props) {
3698
3722
  var _a;
3699
- var _b = react.useContext(GridPopoverContext), field = _b.field, initialVale = _b.value;
3700
- var _c = react.useState(initialVale !== null && initialVale !== void 0 ? initialVale : ""), value = _c[0], setValue = _c[1];
3723
+ var _b = useGridPopoverContext(), field = _b.field, initialVale = _b.value;
3724
+ var _c = react.useState(initialVale != null ? "".concat(initialVale) : ""), value = _c[0], setValue = _c[1];
3701
3725
  var invalid = react.useCallback(function () {
3702
3726
  if (props.required && value.length == 0) {
3703
3727
  return "Some text is required";
@@ -3726,7 +3750,9 @@ var GridFormTextArea = function (props) {
3726
3750
  console.error("ColDef has no field set");
3727
3751
  return [2 /*return*/, false];
3728
3752
  }
3729
- selectedRows.forEach(function (row) { return (row[field] = value); });
3753
+ selectedRows.forEach(function (row) {
3754
+ row[field] = value;
3755
+ });
3730
3756
  return [2 /*return*/, true];
3731
3757
  }
3732
3758
  });
@@ -3739,7 +3765,7 @@ var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __
3739
3765
 
3740
3766
  var GridFormTextInput = function (props) {
3741
3767
  var _a;
3742
- var _b = react.useContext(GridPopoverContext), field = _b.field, data = _b.data, initialVale = _b.value;
3768
+ var _b = useGridPopoverContext(), field = _b.field, data = _b.data, initialVale = _b.value;
3743
3769
  var initValue = initialVale == null ? "" : "".concat(initialVale);
3744
3770
  var _c = react.useState(initValue), value = _c[0], setValue = _c[1];
3745
3771
  var invalid = react.useCallback(function () {
@@ -3773,8 +3799,9 @@ var GridFormTextInput = function (props) {
3773
3799
  console.error("ColDef has no field set");
3774
3800
  return [2 /*return*/, false];
3775
3801
  }
3776
- // @ts-ignore row[field] row is of type any
3777
- selectedRows.forEach(function (row) { return (row[field] = trimmedValue); });
3802
+ selectedRows.forEach(function (row) {
3803
+ row[field] = trimmedValue;
3804
+ });
3778
3805
  return [2 /*return*/, true];
3779
3806
  }
3780
3807
  });
@@ -3997,6 +4024,8 @@ exports.GridHeaderSelect = GridHeaderSelect;
3997
4024
  exports.GridIcon = GridIcon;
3998
4025
  exports.GridLoadableCell = GridLoadableCell;
3999
4026
  exports.GridPopoutEditMultiSelect = GridPopoutEditMultiSelect;
4027
+ exports.GridPopoverContext = GridPopoverContext;
4028
+ exports.GridPopoverContextProvider = GridPopoverContextProvider;
4000
4029
  exports.GridPopoverEditBearing = GridPopoverEditBearing;
4001
4030
  exports.GridPopoverEditBearingCorrection = GridPopoverEditBearingCorrection;
4002
4031
  exports.GridPopoverEditDropDown = GridPopoverEditDropDown;
@@ -4006,6 +4035,7 @@ exports.GridPopoverTextArea = GridPopoverTextArea;
4006
4035
  exports.GridPopoverTextInput = GridPopoverTextInput;
4007
4036
  exports.GridRenderPopoutMenuCell = GridRenderPopoutMenuCell;
4008
4037
  exports.GridRendererGenericCell = GridRendererGenericCell;
4038
+ exports.GridSubComponentContext = GridSubComponentContext;
4009
4039
  exports.GridSubComponentTextArea = GridSubComponentTextArea;
4010
4040
  exports.GridUpdatingContext = GridUpdatingContext;
4011
4041
  exports.GridUpdatingContextProvider = GridUpdatingContextProvider;
@@ -4032,6 +4062,7 @@ exports.convertDDToDMS = convertDDToDMS;
4032
4062
  exports.hasParentClass = hasParentClass;
4033
4063
  exports.isFloat = isFloat;
4034
4064
  exports.isNotEmpty = isNotEmpty;
4065
+ exports.useGridPopoverContext = useGridPopoverContext;
4035
4066
  exports.useGridPopoverHook = useGridPopoverHook;
4036
4067
  exports.useMenuState = useMenuState;
4037
4068
  exports.usePostSortRowsHook = usePostSortRowsHook;