@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.
@@ -3,6 +3,7 @@ import { GridBaseRow } from "../Grid";
3
3
  import { CellEditorCommon } from "../GridCell";
4
4
  export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> extends CellEditorCommon {
5
5
  options: (selectedRows: RowType[]) => Promise<MenuOption<RowType>[]>;
6
+ defaultAction?: (selectedRows: RowType[], menuOption: SelectedMenuOptionResult<RowType>) => Promise<void>;
6
7
  }
7
8
  /** Menu configuration types **/
8
9
  export declare const PopoutMenuSeparator: Readonly<{
@@ -1,4 +1,5 @@
1
1
  import { RefObject } from "react";
2
+ import { GridBaseRow } from "../components/Grid";
2
3
  export interface PropsType {
3
4
  value: any;
4
5
  data: any;
@@ -6,14 +7,15 @@ export interface PropsType {
6
7
  selectedRows: any[];
7
8
  updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>;
8
9
  }
9
- export declare type GridPopoverContextType = {
10
+ export interface GridPopoverContextType<RowType extends GridBaseRow> {
10
11
  anchorRef: RefObject<Element>;
11
12
  saving: boolean;
12
13
  setSaving: (saving: boolean) => void;
13
- field: string;
14
+ field: keyof RowType;
14
15
  value: any;
15
- data: any;
16
- selectedRows: any[];
16
+ data: RowType;
17
+ selectedRows: RowType[];
17
18
  updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>) => Promise<boolean>;
18
- };
19
- export declare const GridPopoverContext: import("react").Context<GridPopoverContextType>;
19
+ }
20
+ export declare const GridPopoverContext: import("react").Context<GridPopoverContextType<any>>;
21
+ export declare const useGridPopoverContext: <RowType extends GridBaseRow>() => GridPopoverContextType<RowType>;
@@ -1,9 +1,12 @@
1
1
  export * from "./react-menu3/index";
2
2
  export * from "./react-menu3/types";
3
- export * from "./contexts/GridUpdatingContext";
4
- export * from "./contexts/GridUpdatingContextProvider";
5
3
  export * from "./contexts/GridContext";
6
4
  export * from "./contexts/GridContextProvider";
5
+ export * from "./contexts/GridUpdatingContext";
6
+ export * from "./contexts/GridUpdatingContextProvider";
7
+ export * from "./contexts/GridPopoverContext";
8
+ export * from "./contexts/GridPopoverContextProvider";
9
+ export * from "./contexts/GridSubComponentContext";
7
10
  export type { GridBaseRow } from "./components/Grid";
8
11
  export { Grid } from "./components/Grid";
9
12
  export * from "./components/GridCell";
@@ -1,6 +1,6 @@
1
1
  import { useMemo, useLayoutEffect, useEffect, createContext, memo, forwardRef, useRef, useContext, useState, useCallback, useReducer, cloneElement, useImperativeHandle, Fragment } from 'react';
2
2
  import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
3
- import { findIndex, debounce, isEmpty, castArray, remove, flatten, delay, sortBy, last, difference, xorBy, fromPairs, omit, pick, toPairs, isEqual } from 'lodash-es';
3
+ import { findIndex, debounce, isEmpty, delay, sortBy, last, difference, castArray, remove, flatten, xorBy, fromPairs, omit, pick, toPairs, isEqual } from 'lodash-es';
4
4
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
5
5
  import { AgGridReact } from 'ag-grid-react';
6
6
  import { LuiMiniSpinner, LuiIcon, LuiCheckboxInput, LuiButton } from '@linzjs/lui';
@@ -1782,54 +1782,6 @@ var MenuRadioGroupFr = function (_a, externalRef) {
1782
1782
  };
1783
1783
  var MenuRadioGroup = forwardRef(MenuRadioGroupFr);
1784
1784
 
1785
- var GridUpdatingContext = createContext({
1786
- checkUpdating: function () {
1787
- console.error("Missing GridUpdatingContext");
1788
- return false;
1789
- },
1790
- modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
1791
- return __generator(this, function (_a) {
1792
- console.error("Missing GridUpdatingContext");
1793
- return [2 /*return*/];
1794
- });
1795
- }); }
1796
- });
1797
-
1798
- var GridUpdatingContextProvider = function (props) {
1799
- var updatingBlocks = useRef({});
1800
- var updating = useRef({});
1801
- var resetUpdating = function () {
1802
- var mergedUpdatingBlocks = {};
1803
- for (var key in updatingBlocks.current) {
1804
- mergedUpdatingBlocks[key] = flatten(updatingBlocks.current[key]);
1805
- }
1806
- updating.current = mergedUpdatingBlocks;
1807
- };
1808
- var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
1809
- var fieldUpdatingIds, idRef;
1810
- var _a;
1811
- return __generator(this, function (_b) {
1812
- switch (_b.label) {
1813
- case 0:
1814
- fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
1815
- idRef = __spreadArray([], ids, true);
1816
- fieldUpdatingIds.push(idRef);
1817
- resetUpdating();
1818
- return [4 /*yield*/, fn()];
1819
- case 1:
1820
- _b.sent();
1821
- remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
1822
- resetUpdating();
1823
- return [2 /*return*/];
1824
- }
1825
- });
1826
- }); };
1827
- var checkUpdating = function (fields, id) {
1828
- return castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
1829
- };
1830
- return (jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
1831
- };
1832
-
1833
1785
  var GridContext = createContext({
1834
1786
  gridReady: function () {
1835
1787
  console.error("no context provider for gridReady");
@@ -1903,6 +1855,19 @@ var GridContext = createContext({
1903
1855
  }
1904
1856
  });
1905
1857
 
1858
+ var GridUpdatingContext = createContext({
1859
+ checkUpdating: function () {
1860
+ console.error("Missing GridUpdatingContext");
1861
+ return false;
1862
+ },
1863
+ modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
1864
+ return __generator(this, function (_a) {
1865
+ console.error("Missing GridUpdatingContext");
1866
+ return [2 /*return*/];
1867
+ });
1868
+ }); }
1869
+ });
1870
+
1906
1871
  /**
1907
1872
  * Context for AgGrid operations.
1908
1873
  * Make sure you wrap AgGrid in this.
@@ -2182,6 +2147,109 @@ var GridContextProvider = function (props) {
2182
2147
  } }, { children: props.children })));
2183
2148
  };
2184
2149
 
2150
+ var GridUpdatingContextProvider = function (props) {
2151
+ var updatingBlocks = useRef({});
2152
+ var updating = useRef({});
2153
+ var resetUpdating = function () {
2154
+ var mergedUpdatingBlocks = {};
2155
+ for (var key in updatingBlocks.current) {
2156
+ mergedUpdatingBlocks[key] = flatten(updatingBlocks.current[key]);
2157
+ }
2158
+ updating.current = mergedUpdatingBlocks;
2159
+ };
2160
+ var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
2161
+ var fieldUpdatingIds, idRef;
2162
+ var _a;
2163
+ return __generator(this, function (_b) {
2164
+ switch (_b.label) {
2165
+ case 0:
2166
+ fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2167
+ idRef = __spreadArray([], ids, true);
2168
+ fieldUpdatingIds.push(idRef);
2169
+ resetUpdating();
2170
+ return [4 /*yield*/, fn()];
2171
+ case 1:
2172
+ _b.sent();
2173
+ remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2174
+ resetUpdating();
2175
+ return [2 /*return*/];
2176
+ }
2177
+ });
2178
+ }); };
2179
+ var checkUpdating = function (fields, id) {
2180
+ return castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
2181
+ };
2182
+ return (jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
2183
+ };
2184
+
2185
+ var GridPopoverContext = createContext({
2186
+ anchorRef: { current: null },
2187
+ saving: false,
2188
+ setSaving: function () { },
2189
+ field: "",
2190
+ value: null,
2191
+ data: {},
2192
+ selectedRows: [],
2193
+ updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2194
+ return [2 /*return*/, false];
2195
+ }); }); }
2196
+ });
2197
+ var useGridPopoverContext = function () {
2198
+ return useContext(GridPopoverContext);
2199
+ };
2200
+
2201
+ var GridPopoverContextProvider = function (_a) {
2202
+ var _b, _c, _d;
2203
+ var props = _a.props, children = _a.children;
2204
+ var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
2205
+ var anchorRef = useRef(props.eGridCell);
2206
+ var _f = useState(false), saving = _f[0], setSaving = _f[1];
2207
+ var colDef = props.colDef;
2208
+ var cellEditorParams = colDef.cellEditorParams;
2209
+ var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2210
+ // Then item that is clicked on will always be first in the list
2211
+ var selectedRows = useMemo(function () { return (multiEdit ? sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2212
+ var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2213
+ var updateValue = useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
2214
+ switch (_b.label) {
2215
+ case 0:
2216
+ _a = !saving;
2217
+ if (!_a) return [3 /*break*/, 2];
2218
+ return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2219
+ case 1:
2220
+ _a = (_b.sent());
2221
+ _b.label = 2;
2222
+ case 2: return [2 /*return*/, _a];
2223
+ }
2224
+ }); }); }, [field, saving, selectedRows, updatingCells]);
2225
+ return (jsx(GridPopoverContext.Provider, __assign({ value: {
2226
+ anchorRef: anchorRef,
2227
+ saving: saving,
2228
+ setSaving: setSaving,
2229
+ selectedRows: selectedRows,
2230
+ field: field,
2231
+ data: props.data,
2232
+ value: props.value,
2233
+ updateValue: updateValue
2234
+ } }, { children: children })));
2235
+ };
2236
+
2237
+ var GridSubComponentContext = createContext({
2238
+ value: "GridSubComponentContext value no context",
2239
+ setValue: function () {
2240
+ console.error("GridSubComponentContext setValue no context");
2241
+ },
2242
+ setValid: function () {
2243
+ console.error("GridSubComponentContext setValid no context");
2244
+ },
2245
+ triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
2246
+ return __generator(this, function (_a) {
2247
+ console.error("GridSubComponentContext triggerSave no context");
2248
+ return [2 /*return*/];
2249
+ });
2250
+ }); }
2251
+ });
2252
+
2185
2253
  function toVal(mix) {
2186
2254
  var k, y, str='';
2187
2255
  if (mix) {
@@ -2648,55 +2716,6 @@ var GridRendererGenericCell = function (props) {
2648
2716
  return (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: jsxs(Fragment$1, { children: [typeof warningText === "string" && jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsx(GridIcon, { icon: "ic_info", title: infoText }), jsx("span", __assign({ title: formatted }, { children: formatted }))] }) })));
2649
2717
  };
2650
2718
 
2651
- var GridPopoverContext = createContext({
2652
- anchorRef: { current: null },
2653
- saving: false,
2654
- setSaving: function () { },
2655
- field: "",
2656
- value: null,
2657
- data: null,
2658
- selectedRows: [],
2659
- updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2660
- return [2 /*return*/, false];
2661
- }); }); }
2662
- });
2663
-
2664
- var GridPopoverContextProvider = function (_a) {
2665
- var _b, _c, _d;
2666
- var props = _a.props, children = _a.children;
2667
- var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
2668
- var anchorRef = useRef(props.eGridCell);
2669
- var _f = useState(false), saving = _f[0], setSaving = _f[1];
2670
- var colDef = props.colDef;
2671
- var cellEditorParams = colDef.cellEditorParams;
2672
- var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2673
- // Then item that is clicked on will always be first in the list
2674
- var selectedRows = useMemo(function () { return (multiEdit ? sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2675
- var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2676
- var updateValue = useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
2677
- switch (_b.label) {
2678
- case 0:
2679
- _a = !saving;
2680
- if (!_a) return [3 /*break*/, 2];
2681
- return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2682
- case 1:
2683
- _a = (_b.sent());
2684
- _b.label = 2;
2685
- case 2: return [2 /*return*/, _a];
2686
- }
2687
- }); }); }, [field, saving, selectedRows, updatingCells]);
2688
- return (jsx(GridPopoverContext.Provider, __assign({ value: {
2689
- anchorRef: anchorRef,
2690
- saving: saving,
2691
- setSaving: setSaving,
2692
- selectedRows: selectedRows,
2693
- field: field,
2694
- data: props.data,
2695
- value: props.value,
2696
- updateValue: updateValue
2697
- } }, { children: children })));
2698
- };
2699
-
2700
2719
  var GridCellRenderer = function (props) {
2701
2720
  var _a, _b, _c;
2702
2721
  var checkUpdating = useContext(GridUpdatingContext).checkUpdating;
@@ -2755,7 +2774,7 @@ var ComponentLoadingWrapper = function (props) {
2755
2774
 
2756
2775
  var useGridPopoverHook = function (props) {
2757
2776
  var stopEditing = useContext(GridContext).stopEditing;
2758
- var _a = useContext(GridPopoverContext), anchorRef = _a.anchorRef, saving = _a.saving, updateValue = _a.updateValue;
2777
+ var _a = useGridPopoverContext(), anchorRef = _a.anchorRef, saving = _a.saving, updateValue = _a.updateValue;
2759
2778
  var saveButtonRef = useRef(null);
2760
2779
  var _b = useState(false), isOpen = _b[0], setOpen = _b[1];
2761
2780
  useEffect(function () {
@@ -2908,8 +2927,11 @@ var MenuHeaderString = "_____MENU_HEADER_____";
2908
2927
  var MenuHeaderItem = function (title) {
2909
2928
  return { label: title, value: MenuHeaderString };
2910
2929
  };
2930
+ var fieldToString = function (field) {
2931
+ return typeof field == "symbol" ? field.toString() : "".concat(field);
2932
+ };
2911
2933
  var GridFormDropDown = function (props) {
2912
- var _a = useContext(GridPopoverContext), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue;
2934
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue;
2913
2935
  var stopEditing = useContext(GridContext).stopEditing;
2914
2936
  var _b = useState(""), filter = _b[0], setFilter = _b[1];
2915
2937
  var _c = useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
@@ -3065,69 +3087,48 @@ var GridFormDropDown = function (props) {
3065
3087
  var _b;
3066
3088
  var ref = _a.ref;
3067
3089
  return (jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: 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); } }) })));
3068
- } })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && jsx(MenuItem, { children: "[Empty]" }, "".concat(field, "-empty")), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3090
+ } })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && (jsx(MenuItem, { children: "[Empty]" }, "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3069
3091
  var _a;
3070
3092
  return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : filteredValues.includes(item.value) ? null : (jsx("div", { children: !item.subComponent ? (jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
3071
3093
  selectItemHandler(item.value).then();
3072
- } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(field, "-").concat(index))) : (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
3073
- return item.subComponent &&
3074
- item.subComponent({
3075
- setValue: function (value) {
3076
- var localSubComponentValues = __spreadArray([], subComponentValues, true);
3077
- var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
3078
- var optionValue = _a.optionValue;
3079
- return optionValue === item.value;
3094
+ } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(fieldToString(field), "-").concat(index))) : (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
3095
+ return item.subComponent && (jsx(item.subComponent, { setValue: function (value) {
3096
+ var localSubComponentValues = __spreadArray([], subComponentValues, true);
3097
+ var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
3098
+ var optionValue = _a.optionValue;
3099
+ return optionValue === item.value;
3100
+ });
3101
+ if (subComponentValueIndex !== -1) {
3102
+ localSubComponentValues[subComponentValueIndex].subComponentValue = value;
3103
+ }
3104
+ else {
3105
+ localSubComponentValues.push({
3106
+ subComponentValue: value,
3107
+ optionValue: item.value
3080
3108
  });
3081
- if (subComponentValueIndex !== -1) {
3082
- localSubComponentValues[subComponentValueIndex].subComponentValue = value;
3083
- }
3084
- else {
3085
- localSubComponentValues.push({
3086
- subComponentValue: value,
3087
- optionValue: item.value
3088
- });
3089
- }
3090
- setSubComponentValues(localSubComponentValues);
3091
- },
3092
- keyDown: function (key, event) {
3093
- var subComponentItem = subComponentValues.find(function (_a) {
3094
- var optionValue = _a.optionValue;
3095
- return optionValue === item.value;
3109
+ }
3110
+ setSubComponentValues(localSubComponentValues);
3111
+ }, keyDown: function (key, event) {
3112
+ var subComponentItem = subComponentValues.find(function (_a) {
3113
+ var optionValue = _a.optionValue;
3114
+ return optionValue === item.value;
3115
+ });
3116
+ if ((key === "Enter" || key === "Tab") && subComponentItem) {
3117
+ event.preventDefault();
3118
+ event.stopPropagation();
3119
+ return selectItemHandler(item.value, subComponentItem.subComponentValue).then(function () {
3120
+ ref.closeMenu();
3121
+ return true;
3096
3122
  });
3097
- if ((key === "Enter" || key === "Tab") && subComponentItem) {
3098
- event.preventDefault();
3099
- event.stopPropagation();
3100
- return selectItemHandler(item.value, subComponentItem.subComponentValue).then(function () {
3101
- ref.closeMenu();
3102
- return true;
3103
- });
3104
- }
3105
- return false;
3106
- },
3107
- key: "".concat(field, "-").concat(index, "_subcomponent_inner")
3108
- }, ref);
3109
- } }), "".concat(field, "-").concat(index, "_subcomponent"))) }, "menu-wrapper-".concat(index)));
3123
+ }
3124
+ return false;
3125
+ } }, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")));
3126
+ } }), "".concat(fieldToString(field), "-").concat(index, "_subcomponent"))) }, "menu-wrapper-".concat(index)));
3110
3127
  })] }) }))] }));
3111
3128
  };
3112
3129
 
3113
- var GridSubComponentContext = createContext({
3114
- value: "GridSubComponentContext value no context",
3115
- setValue: function () {
3116
- console.error("GridSubComponentContext setValue no context");
3117
- },
3118
- setValid: function () {
3119
- console.error("GridSubComponentContext setValid no context");
3120
- },
3121
- triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
3122
- return __generator(this, function (_a) {
3123
- console.error("GridSubComponentContext triggerSave no context");
3124
- return [2 /*return*/];
3125
- });
3126
- }); }
3127
- });
3128
-
3129
3130
  var GridFormMultiSelect = function (props) {
3130
- var selectedRows = useContext(GridPopoverContext).selectedRows;
3131
+ var selectedRows = useGridPopoverContext().selectedRows;
3131
3132
  var initialiseValues = useMemo(function () {
3132
3133
  var r = props.initialSelectedValues && props.initialSelectedValues(selectedRows);
3133
3134
  // convert array of strings to object<value,null>
@@ -3289,7 +3290,7 @@ var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
3289
3290
  * you need a useMemo around your columnDefs
3290
3291
  */
3291
3292
  var GridFormPopoverMenu = function (props) {
3292
- var _a = useContext(GridPopoverContext), selectedRows = _a.selectedRows, updateValue = _a.updateValue;
3293
+ var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, updateValue = _a.updateValue;
3293
3294
  var optionsInitialising = useRef(false);
3294
3295
  var _b = useState(), options = _b[0], setOptions = _b[1];
3295
3296
  // Save triggers during async action processing which triggers another action(), this ref blocks that
@@ -3297,6 +3298,22 @@ var GridFormPopoverMenu = function (props) {
3297
3298
  var _c = useState(null), subComponentSelected = _c[0], setSubComponentSelected = _c[1];
3298
3299
  var subComponentIsValid = useRef(false);
3299
3300
  var _d = useState(), subSelectedValue = _d[0], setSubSelectedValue = _d[1];
3301
+ var defaultAction = useCallback(function (selectedRows, menuOption) { return __awaiter(void 0, void 0, void 0, function () {
3302
+ return __generator(this, function (_a) {
3303
+ switch (_a.label) {
3304
+ case 0:
3305
+ if (!props.defaultAction) return [3 /*break*/, 2];
3306
+ return [4 /*yield*/, props.defaultAction(selectedRows, menuOption)];
3307
+ case 1:
3308
+ _a.sent();
3309
+ return [3 /*break*/, 3];
3310
+ case 2:
3311
+ console.error("No action specified for ".concat(menuOption.label, " menu options"));
3312
+ _a.label = 3;
3313
+ case 3: return [2 /*return*/];
3314
+ }
3315
+ });
3316
+ }); }, [props]);
3300
3317
  // Load up options list if it's async function
3301
3318
  useEffect(function () {
3302
3319
  var _a;
@@ -3305,50 +3322,55 @@ var GridFormPopoverMenu = function (props) {
3305
3322
  optionsInitialising.current = true;
3306
3323
  var optionsConf = (_a = props.options) !== null && _a !== void 0 ? _a : [];
3307
3324
  (function () { return __awaiter(void 0, void 0, void 0, function () {
3308
- var _a, _b;
3309
- return __generator(this, function (_c) {
3310
- switch (_c.label) {
3325
+ var newOptions, _a, anyOptionsAreMissingAction;
3326
+ return __generator(this, function (_b) {
3327
+ switch (_b.label) {
3311
3328
  case 0:
3312
- _a = setOptions;
3313
3329
  if (!(typeof optionsConf == "function")) return [3 /*break*/, 2];
3314
3330
  return [4 /*yield*/, optionsConf(selectedRows)];
3315
3331
  case 1:
3316
- _b = _c.sent();
3332
+ _a = _b.sent();
3317
3333
  return [3 /*break*/, 3];
3318
3334
  case 2:
3319
- _b = optionsConf;
3320
- _c.label = 3;
3335
+ _a = optionsConf;
3336
+ _b.label = 3;
3321
3337
  case 3:
3322
- _a.apply(void 0, [_b]);
3338
+ newOptions = _a;
3339
+ setOptions(newOptions);
3340
+ if (!props.defaultAction) {
3341
+ anyOptionsAreMissingAction = newOptions.some(function (option) { return !option.action; });
3342
+ if (anyOptionsAreMissingAction) {
3343
+ console.error("There's no default action handler and some Menu options are missing an action handler", {
3344
+ invalidMenuOptions: newOptions.filter(function (option) { return !option.action; })
3345
+ });
3346
+ }
3347
+ }
3323
3348
  optionsInitialising.current = false;
3324
3349
  return [2 /*return*/];
3325
3350
  }
3326
3351
  });
3327
3352
  }); })();
3328
- }, [options, props.options, selectedRows]);
3353
+ }, [options, props.defaultAction, props.options, selectedRows]);
3329
3354
  var actionClick = useCallback(function (menuOption) { return __awaiter(void 0, void 0, void 0, function () {
3330
3355
  return __generator(this, function (_a) {
3331
3356
  actionProcessing.current = true;
3332
3357
  return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
3333
- var result, _a;
3358
+ var result;
3359
+ var _a;
3334
3360
  return __generator(this, function (_b) {
3335
3361
  switch (_b.label) {
3336
3362
  case 0:
3337
3363
  result = __assign(__assign({}, menuOption), { subValue: subSelectedValue });
3338
- _a = menuOption.action;
3339
- if (!_a) return [3 /*break*/, 2];
3340
- return [4 /*yield*/, menuOption.action(selectedRows, result)];
3364
+ return [4 /*yield*/, ((_a = menuOption.action) !== null && _a !== void 0 ? _a : defaultAction)(selectedRows, result)];
3341
3365
  case 1:
3342
- _a = (_b.sent());
3343
- _b.label = 2;
3344
- case 2:
3366
+ _b.sent();
3345
3367
  actionProcessing.current = false;
3346
3368
  return [2 /*return*/, true];
3347
3369
  }
3348
3370
  });
3349
3371
  }); })];
3350
3372
  });
3351
- }); }, [selectedRows, subSelectedValue, updateValue]);
3373
+ }); }, [defaultAction, selectedRows, subSelectedValue, updateValue]);
3352
3374
  var onMenuItemClick = useCallback(function (e, item) {
3353
3375
  if (item.subComponent) {
3354
3376
  subComponentIsValid.current = false;
@@ -3505,7 +3527,7 @@ var TextInputFormatted = function (props) {
3505
3527
  };
3506
3528
 
3507
3529
  var GridFormEditBearing = function (props) {
3508
- var _a = useContext(GridPopoverContext), field = _a.field, initialValue = _a.value;
3530
+ var _a = useGridPopoverContext(), field = _a.field, initialValue = _a.value;
3509
3531
  var _b = useState("".concat(initialValue !== null && initialValue !== void 0 ? initialValue : "")), value = _b[0], setValue = _b[1];
3510
3532
  var save = useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3511
3533
  var parsedValue;
@@ -3527,7 +3549,9 @@ var GridFormEditBearing = function (props) {
3527
3549
  console.error("field is not defined in ColDef");
3528
3550
  }
3529
3551
  else {
3530
- selectedRows.forEach(function (row) { return (row[field] = parsedValue); });
3552
+ selectedRows.forEach(function (row) {
3553
+ row[field] = parsedValue;
3554
+ });
3531
3555
  }
3532
3556
  _a.label = 3;
3533
3557
  case 3: return [2 /*return*/, true];
@@ -3587,7 +3611,7 @@ var GridPopoverEditDropDown = function (colDef, props) {
3587
3611
  };
3588
3612
 
3589
3613
  var GridFormMessage = function (props) {
3590
- var selectedRows = useContext(GridPopoverContext).selectedRows;
3614
+ var selectedRows = useGridPopoverContext().selectedRows;
3591
3615
  var _a = useState(null), message = _a[0], setMessage = _a[1];
3592
3616
  var popoverWrapper = useGridPopoverHook({ className: props.className }).popoverWrapper;
3593
3617
  useEffect(function () {
@@ -3694,8 +3718,8 @@ var TextAreaInput = function (props) {
3694
3718
 
3695
3719
  var GridFormTextArea = function (props) {
3696
3720
  var _a;
3697
- var _b = useContext(GridPopoverContext), field = _b.field, initialVale = _b.value;
3698
- var _c = useState(initialVale !== null && initialVale !== void 0 ? initialVale : ""), value = _c[0], setValue = _c[1];
3721
+ var _b = useGridPopoverContext(), field = _b.field, initialVale = _b.value;
3722
+ var _c = useState(initialVale != null ? "".concat(initialVale) : ""), value = _c[0], setValue = _c[1];
3699
3723
  var invalid = useCallback(function () {
3700
3724
  if (props.required && value.length == 0) {
3701
3725
  return "Some text is required";
@@ -3724,7 +3748,9 @@ var GridFormTextArea = function (props) {
3724
3748
  console.error("ColDef has no field set");
3725
3749
  return [2 /*return*/, false];
3726
3750
  }
3727
- selectedRows.forEach(function (row) { return (row[field] = value); });
3751
+ selectedRows.forEach(function (row) {
3752
+ row[field] = value;
3753
+ });
3728
3754
  return [2 /*return*/, true];
3729
3755
  }
3730
3756
  });
@@ -3737,7 +3763,7 @@ var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __
3737
3763
 
3738
3764
  var GridFormTextInput = function (props) {
3739
3765
  var _a;
3740
- var _b = useContext(GridPopoverContext), field = _b.field, data = _b.data, initialVale = _b.value;
3766
+ var _b = useGridPopoverContext(), field = _b.field, data = _b.data, initialVale = _b.value;
3741
3767
  var initValue = initialVale == null ? "" : "".concat(initialVale);
3742
3768
  var _c = useState(initValue), value = _c[0], setValue = _c[1];
3743
3769
  var invalid = useCallback(function () {
@@ -3771,8 +3797,9 @@ var GridFormTextInput = function (props) {
3771
3797
  console.error("ColDef has no field set");
3772
3798
  return [2 /*return*/, false];
3773
3799
  }
3774
- // @ts-ignore row[field] row is of type any
3775
- selectedRows.forEach(function (row) { return (row[field] = trimmedValue); });
3800
+ selectedRows.forEach(function (row) {
3801
+ row[field] = trimmedValue;
3802
+ });
3776
3803
  return [2 /*return*/, true];
3777
3804
  }
3778
3805
  });
@@ -3976,5 +4003,5 @@ var ActionButton = function (_a) {
3976
4003
  } })) : (jsx(LuiIcon, { name: icon, alt: (_c = ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : name) !== null && _c !== void 0 ? _c : "", size: size })), jsxs("span", __assign({ className: "ActionButton-minimalArea" }, { children: [jsx("span", __assign({ className: "ActionButton-minimalAreaDisplay" }, { children: (_d = (localInProgress ? inProgressName : name)) !== null && _d !== void 0 ? _d : name })), jsx("span", __assign({ className: "ActionButton-minimalAreaExpand" }, { children: name }))] }))] })));
3977
4004
  };
3978
4005
 
3979
- export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponentWrapper, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoverMenu, GridFormSubComponentTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
4006
+ export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponentWrapper, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoverMenu, GridFormSubComponentTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentContext, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverContext, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
3980
4007
  //# sourceMappingURL=step-ag-grid.esm.js.map