@linzjs/step-ag-grid 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/index.js +390 -320
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/components/GridPopoverHook.d.ts +13 -1
  4. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +11 -0
  5. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +8 -8
  6. package/dist/src/components/gridForm/GridFormTextArea.d.ts +3 -4
  7. package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -4
  8. package/dist/src/index.d.ts +6 -3
  9. package/dist/src/lui/TextAreaInput.d.ts +4 -5
  10. package/dist/src/lui/TextInputFormatted.d.ts +4 -10
  11. package/dist/src/utils/textValidator.d.ts +6 -0
  12. package/dist/step-ag-grid.esm.js +387 -321
  13. package/dist/step-ag-grid.esm.js.map +1 -1
  14. package/package.json +1 -1
  15. package/src/components/Grid.tsx +2 -2
  16. package/src/components/GridCell.tsx +5 -0
  17. package/src/components/GridPopoverHook.tsx +79 -1
  18. package/src/components/gridForm/GridFormDropDown.tsx +63 -56
  19. package/src/components/gridForm/GridFormEditBearing.tsx +7 -8
  20. package/src/components/gridForm/GridFormMultiSelect.tsx +6 -10
  21. package/src/components/gridForm/GridFormPopoverMenu.tsx +7 -10
  22. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +58 -0
  23. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +48 -55
  24. package/src/components/gridForm/GridFormTextArea.tsx +10 -18
  25. package/src/components/gridForm/GridFormTextInput.tsx +12 -25
  26. package/src/contexts/GridPopoverContextProvider.tsx +11 -4
  27. package/src/index.ts +6 -3
  28. package/src/lui/TextAreaInput.tsx +34 -18
  29. package/src/lui/TextInputFormatted.tsx +19 -35
  30. package/src/react-menu3/components/MenuItem.tsx +5 -2
  31. package/src/stories/grid/FormTest.tsx +16 -3
  32. package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +20 -17
  33. package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +2 -2
  34. package/src/stories/grid/GridReadOnly.stories.tsx +15 -3
  35. package/src/utils/textValidator.ts +24 -0
  36. package/dist/src/components/GridSubComponentTextArea.d.ts +0 -10
  37. package/src/components/GridSubComponentTextArea.tsx +0 -62
@@ -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';
@@ -1685,7 +1685,10 @@ var MenuItemFr = function (_a) {
1685
1685
  safeCall(radioGroup.onRadioChange, event);
1686
1686
  eventHandlers.handleClick(event, isCheckBox || isRadio);
1687
1687
  };
1688
- var handleKeyDown = function (e) {
1688
+ /**
1689
+ * Keyboard events are triggered on up, otherwise sub-components get spaces and enters typed in them
1690
+ */
1691
+ var handleKeyUp = function (e) {
1689
1692
  if (!isHovering)
1690
1693
  return;
1691
1694
  switch (e.key) {
@@ -1707,7 +1710,7 @@ var MenuItemFr = function (_a) {
1707
1710
  checked: isChecked,
1708
1711
  anchor: isAnchor
1709
1712
  }); }, [type, isDisabled, isHovering, isChecked, isAnchor]);
1710
- var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyDown: handleKeyDown, onClick: handleClick }), restProps);
1713
+ var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
1711
1714
  // Order of props overriding (same in all components):
1712
1715
  // 1. Preset props adhering to WAI-ARIA Authoring Practices.
1713
1716
  // 2. Merged outer and local props
@@ -1782,54 +1785,6 @@ var MenuRadioGroupFr = function (_a, externalRef) {
1782
1785
  };
1783
1786
  var MenuRadioGroup = forwardRef(MenuRadioGroupFr);
1784
1787
 
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
1788
  var GridContext = createContext({
1834
1789
  gridReady: function () {
1835
1790
  console.error("no context provider for gridReady");
@@ -1903,6 +1858,19 @@ var GridContext = createContext({
1903
1858
  }
1904
1859
  });
1905
1860
 
1861
+ var GridUpdatingContext = createContext({
1862
+ checkUpdating: function () {
1863
+ console.error("Missing GridUpdatingContext");
1864
+ return false;
1865
+ },
1866
+ modifyUpdating: function () { return __awaiter(void 0, void 0, void 0, function () {
1867
+ return __generator(this, function (_a) {
1868
+ console.error("Missing GridUpdatingContext");
1869
+ return [2 /*return*/];
1870
+ });
1871
+ }); }
1872
+ });
1873
+
1906
1874
  /**
1907
1875
  * Context for AgGrid operations.
1908
1876
  * Make sure you wrap AgGrid in this.
@@ -2182,6 +2150,114 @@ var GridContextProvider = function (props) {
2182
2150
  } }, { children: props.children })));
2183
2151
  };
2184
2152
 
2153
+ var GridUpdatingContextProvider = function (props) {
2154
+ var updatingBlocks = useRef({});
2155
+ var updating = useRef({});
2156
+ var resetUpdating = function () {
2157
+ var mergedUpdatingBlocks = {};
2158
+ for (var key in updatingBlocks.current) {
2159
+ mergedUpdatingBlocks[key] = flatten(updatingBlocks.current[key]);
2160
+ }
2161
+ updating.current = mergedUpdatingBlocks;
2162
+ };
2163
+ var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
2164
+ var fieldUpdatingIds, idRef;
2165
+ var _a;
2166
+ return __generator(this, function (_b) {
2167
+ switch (_b.label) {
2168
+ case 0:
2169
+ fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2170
+ idRef = __spreadArray([], ids, true);
2171
+ fieldUpdatingIds.push(idRef);
2172
+ resetUpdating();
2173
+ return [4 /*yield*/, fn()];
2174
+ case 1:
2175
+ _b.sent();
2176
+ remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2177
+ resetUpdating();
2178
+ return [2 /*return*/];
2179
+ }
2180
+ });
2181
+ }); };
2182
+ var checkUpdating = function (fields, id) {
2183
+ return castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
2184
+ };
2185
+ return (jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
2186
+ };
2187
+
2188
+ var GridPopoverContext = createContext({
2189
+ anchorRef: { current: null },
2190
+ saving: false,
2191
+ setSaving: function () { },
2192
+ field: "",
2193
+ value: null,
2194
+ data: {},
2195
+ selectedRows: [],
2196
+ updateValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2197
+ return [2 /*return*/, false];
2198
+ }); }); }
2199
+ });
2200
+ var useGridPopoverContext = function () {
2201
+ return useContext(GridPopoverContext);
2202
+ };
2203
+
2204
+ var GridPopoverContextProvider = function (_a) {
2205
+ var _b, _c, _d;
2206
+ var props = _a.props, children = _a.children;
2207
+ var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing;
2208
+ var anchorRef = useRef(props.eGridCell);
2209
+ var _f = useState(false), saving = _f[0], setSaving = _f[1];
2210
+ var colDef = props.colDef;
2211
+ var cellEditorParams = colDef.cellEditorParams;
2212
+ var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2213
+ // Then item that is clicked on will always be first in the list
2214
+ var selectedRows = useMemo(function () { return (multiEdit ? sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2215
+ var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2216
+ var updateValue = useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () {
2217
+ var result;
2218
+ return __generator(this, function (_a) {
2219
+ switch (_a.label) {
2220
+ case 0:
2221
+ result = false;
2222
+ if (!!saving) return [3 /*break*/, 2];
2223
+ return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2224
+ case 1:
2225
+ result = _a.sent();
2226
+ if (result)
2227
+ stopEditing();
2228
+ _a.label = 2;
2229
+ case 2: return [2 /*return*/, result];
2230
+ }
2231
+ });
2232
+ }); }, [field, saving, selectedRows, stopEditing, updatingCells]);
2233
+ return (jsx(GridPopoverContext.Provider, __assign({ value: {
2234
+ anchorRef: anchorRef,
2235
+ saving: saving,
2236
+ setSaving: setSaving,
2237
+ selectedRows: selectedRows,
2238
+ field: field,
2239
+ data: props.data,
2240
+ value: props.value,
2241
+ updateValue: updateValue
2242
+ } }, { children: children })));
2243
+ };
2244
+
2245
+ var GridSubComponentContext = createContext({
2246
+ value: "GridSubComponentContext value no context",
2247
+ setValue: function () {
2248
+ console.error("GridSubComponentContext setValue no context");
2249
+ },
2250
+ setValid: function () {
2251
+ console.error("GridSubComponentContext setValid no context");
2252
+ },
2253
+ triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
2254
+ return __generator(this, function (_a) {
2255
+ console.error("GridSubComponentContext triggerSave no context");
2256
+ return [2 /*return*/];
2257
+ });
2258
+ }); }
2259
+ });
2260
+
2185
2261
  function toVal(mix) {
2186
2262
  var k, y, str='';
2187
2263
  if (mix) {
@@ -2552,7 +2628,7 @@ var Grid = function (params) {
2552
2628
  startCellEditing(event);
2553
2629
  }
2554
2630
  }, [startCellEditing]);
2555
- var onCellKeyDown = useCallback(function (e) {
2631
+ var onCellKeyPress = useCallback(function (e) {
2556
2632
  if (e.event.key === "Enter")
2557
2633
  startCellEditing(e);
2558
2634
  }, [startCellEditing]);
@@ -2570,7 +2646,7 @@ var Grid = function (params) {
2570
2646
  }, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
2571
2647
  return (jsxs("div", __assign({ "data-testid": params.dataTestId, className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
2572
2648
  setInternalQuickFilter(event.target.value);
2573
- } }) }))), jsx(AgGridReact, { getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyDown: onCellKeyDown, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_b = params.postSortRows) !== null && _b !== void 0 ? _b : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
2649
+ } }) }))), jsx(AgGridReact, { getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyPress: onCellKeyPress, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_b = params.postSortRows) !== null && _b !== void 0 ? _b : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
2574
2650
  };
2575
2651
 
2576
2652
  var GenericMultiEditCellClass = function (props) {
@@ -2613,12 +2689,12 @@ function styleInject(css, ref) {
2613
2689
  }
2614
2690
  }
2615
2691
 
2616
- var css_248z$8 = ".AgGridGenericCellRenderer-icon{margin-right:4px}.AgGridGenericCellRenderer-ic_infoIcon{fill:#3a7cdf;margin-right:4px}.AgGridGenericCellRenderer-ic_warningIcon{fill:#ea6a2e;margin-right:4px}";
2617
- styleInject(css_248z$8);
2618
-
2619
- var css_248z$7 = ".GridLoadableCell-container{align-items:center;display:flex}";
2692
+ var css_248z$7 = ".AgGridGenericCellRenderer-icon{margin-right:4px}.AgGridGenericCellRenderer-ic_infoIcon{fill:#3a7cdf;margin-right:4px}.AgGridGenericCellRenderer-ic_warningIcon{fill:#ea6a2e;margin-right:4px}";
2620
2693
  styleInject(css_248z$7);
2621
2694
 
2695
+ var css_248z$6 = ".GridLoadableCell-container{align-items:center;display:flex}";
2696
+ styleInject(css_248z$6);
2697
+
2622
2698
  var GridLoadableCell = function (props) {
2623
2699
  if (props.isLoading) {
2624
2700
  return (jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: jsx(LuiMiniSpinner, { size: 22, divProps: { role: "status", "aria-label": "Loading", style: { marginBottom: 4 } } }) })));
@@ -2648,58 +2724,6 @@ var GridRendererGenericCell = function (props) {
2648
2724
  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
2725
  };
2650
2726
 
2651
- var GridPopoverContext = createContext({
2652
- anchorRef: { current: null },
2653
- saving: false,
2654
- setSaving: function () { },
2655
- field: "",
2656
- value: null,
2657
- data: {},
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
- var useGridPopoverContext = function () {
2664
- return useContext(GridPopoverContext);
2665
- };
2666
-
2667
- var GridPopoverContextProvider = function (_a) {
2668
- var _b, _c, _d;
2669
- var props = _a.props, children = _a.children;
2670
- var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells;
2671
- var anchorRef = useRef(props.eGridCell);
2672
- var _f = useState(false), saving = _f[0], setSaving = _f[1];
2673
- var colDef = props.colDef;
2674
- var cellEditorParams = colDef.cellEditorParams;
2675
- var multiEdit = (_b = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _b !== void 0 ? _b : false;
2676
- // Then item that is clicked on will always be first in the list
2677
- var selectedRows = useMemo(function () { return (multiEdit ? sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2678
- var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2679
- var updateValue = useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
2680
- switch (_b.label) {
2681
- case 0:
2682
- _a = !saving;
2683
- if (!_a) return [3 /*break*/, 2];
2684
- return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2685
- case 1:
2686
- _a = (_b.sent());
2687
- _b.label = 2;
2688
- case 2: return [2 /*return*/, _a];
2689
- }
2690
- }); }); }, [field, saving, selectedRows, updatingCells]);
2691
- return (jsx(GridPopoverContext.Provider, __assign({ value: {
2692
- anchorRef: anchorRef,
2693
- saving: saving,
2694
- setSaving: setSaving,
2695
- selectedRows: selectedRows,
2696
- field: field,
2697
- data: props.data,
2698
- value: props.value,
2699
- updateValue: updateValue
2700
- } }, { children: children })));
2701
- };
2702
-
2703
2727
  var GridCellRenderer = function (props) {
2704
2728
  var _a, _b, _c;
2705
2729
  var checkUpdating = useContext(GridUpdatingContext).checkUpdating;
@@ -2716,11 +2740,15 @@ var GridCellRenderer = function (props) {
2716
2740
  */
2717
2741
  var GridCell = function (props, custom) {
2718
2742
  var _a;
2719
- return __assign(__assign(__assign(__assign(__assign({ colId: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
2743
+ return __assign(__assign(__assign(__assign(__assign(__assign({ colId: props.field, sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
2720
2744
  cellClass: (custom === null || custom === void 0 ? void 0 : custom.multiEdit) ? GenericMultiEditCellClass : undefined,
2721
2745
  editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
2722
2746
  cellEditor: GenericCellEditorComponentWrapper(custom)
2723
- })), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
2747
+ })), { suppressKeyboardEvent: function (e) {
2748
+ // It's important that aggrid doesn't trigger edit on enter
2749
+ // as the incorrect selected rows will be returned
2750
+ return e.event.key === "Enter";
2751
+ } }), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
2724
2752
  cellEditorParams: __assign(__assign({}, custom.editorParams), { multiEdit: custom.multiEdit })
2725
2753
  })), {
2726
2754
  // Default value formatter, otherwise react freaks out on objects
@@ -2789,8 +2817,77 @@ var useGridPopoverHook = function (props) {
2789
2817
  }
2790
2818
  });
2791
2819
  }); }, [props.save, stopEditing, updateValue]);
2820
+ var onlyInputKeyboardEventHandlers = {
2821
+ onKeyUp: function (e) {
2822
+ var isTextArea = e.currentTarget.type === "textarea";
2823
+ if (e.key === "Enter" && !isTextArea) {
2824
+ e.preventDefault();
2825
+ e.stopPropagation();
2826
+ triggerSave().then();
2827
+ }
2828
+ else if (e.key === "Tab") {
2829
+ e.preventDefault();
2830
+ e.stopPropagation();
2831
+ }
2832
+ },
2833
+ onKeyDown: function (e) {
2834
+ var isTextArea = e.currentTarget.type === "textarea";
2835
+ if (e.key === "Enter" && !isTextArea) {
2836
+ e.preventDefault();
2837
+ e.stopPropagation();
2838
+ }
2839
+ else if (e.key === "Tab") {
2840
+ e.preventDefault();
2841
+ e.stopPropagation();
2842
+ !e.shiftKey && triggerSave().then();
2843
+ }
2844
+ }
2845
+ };
2846
+ var firstInputKeyboardEventHandlers = {
2847
+ onKeyUp: function (e) {
2848
+ if (e.key === "Tab" && e.shiftKey) {
2849
+ e.preventDefault();
2850
+ e.stopPropagation();
2851
+ }
2852
+ },
2853
+ onKeyDown: function (e) {
2854
+ if (e.key === "Tab" && e.shiftKey) {
2855
+ e.preventDefault();
2856
+ e.stopPropagation();
2857
+ }
2858
+ }
2859
+ };
2860
+ var lastInputKeyboardEventHandlers = {
2861
+ onKeyUp: function (e) {
2862
+ var isTextArea = e.currentTarget.type === "textarea";
2863
+ if (e.key === "Enter" && !isTextArea) {
2864
+ e.preventDefault();
2865
+ e.stopPropagation();
2866
+ triggerSave().then();
2867
+ }
2868
+ else if (e.key === "Tab" && !e.shiftKey) {
2869
+ e.preventDefault();
2870
+ e.stopPropagation();
2871
+ }
2872
+ },
2873
+ onKeyDown: function (e) {
2874
+ var isTextArea = e.currentTarget.type === "textarea";
2875
+ if (e.key === "Enter" && !isTextArea) {
2876
+ e.preventDefault();
2877
+ e.stopPropagation();
2878
+ }
2879
+ else if (e.key === "Tab" && !e.shiftKey) {
2880
+ e.preventDefault();
2881
+ e.stopPropagation();
2882
+ triggerSave().then();
2883
+ }
2884
+ }
2885
+ };
2792
2886
  var popoverWrapper = useCallback(function (children) {
2793
2887
  return (jsx(Fragment$1, { children: anchorRef.current && (jsxs(ControlledMenu, __assign({ state: isOpen ? "open" : "closed", portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: "step-ag-grid-react-menu", onClose: function (event) {
2888
+ // Prevent menu from closing when modals are invoked
2889
+ if (event.reason === "blur")
2890
+ return;
2794
2891
  triggerSave(event.reason).then();
2795
2892
  }, viewScroll: "auto", dontShrinkIfDirectionIsTop: true, className: props.className, closeMenuExclusionClassName: "ReactModal__Content" }, { children: [saving && ( // This is the overlay that prevents editing when the editor is saving
2796
2893
  jsx("div", { style: {
@@ -2805,7 +2902,10 @@ var useGridPopoverHook = function (props) {
2805
2902
  }, [anchorRef, isOpen, props.className, saving, triggerSave]);
2806
2903
  return {
2807
2904
  popoverWrapper: popoverWrapper,
2808
- triggerSave: triggerSave
2905
+ triggerSave: triggerSave,
2906
+ onlyInputKeyboardEventHandlers: onlyInputKeyboardEventHandlers,
2907
+ firstInputKeyboardEventHandlers: firstInputKeyboardEventHandlers,
2908
+ lastInputKeyboardEventHandlers: lastInputKeyboardEventHandlers
2809
2909
  };
2810
2910
  };
2811
2911
 
@@ -2828,12 +2928,12 @@ var GridRenderPopoutMenuCell = function (props) {
2828
2928
  return (jsx(GridLoadableCell, __assign({ isLoading: isLoading, className: disabled ? "GridPopoutMenu-burgerDisabled" : "GridPopoutMenu-burger" }, { children: jsx(LuiIcon, { name: "ic_more_vert", alt: "More actions", size: "md" }) })));
2829
2929
  };
2830
2930
 
2831
- var css_248z$6 = ".GridMultiSelect-containerSmall .GridFormMultiSelect-options{max-height:130px;overflow-y:auto}.GridMultiSelect-containerMedium .GridFormMultiSelect-options{max-height:190px;overflow-y:auto}.GridMultiSelect-containerLarge .GridFormMultiSelect-options{max-height:320px;overflow-y:auto}.GridMultiSelect-containerUnlimited .GridFormMultiSelect-options{overflow-y:auto}";
2832
- styleInject(css_248z$6);
2833
-
2834
- var css_248z$5 = ".GridPopoverEditDropDown-containerSmall .GridFormDropDown-options{max-height:120px;overflow-y:auto}.GridPopoverEditDropDown-containerMedium .GridFormDropDown-options{max-height:200px;overflow-y:auto}.GridPopoverEditDropDown-containerLarge .GridFormDropDown-options{max-height:400px;overflow-y:auto}.GridPopoverEditDropDown-containerUnlimited .GridFormDropDown-options{overflow-y:auto}";
2931
+ var css_248z$5 = ".GridMultiSelect-containerSmall .GridFormMultiSelect-options{max-height:130px;overflow-y:auto}.GridMultiSelect-containerMedium .GridFormMultiSelect-options{max-height:190px;overflow-y:auto}.GridMultiSelect-containerLarge .GridFormMultiSelect-options{max-height:320px;overflow-y:auto}.GridMultiSelect-containerUnlimited .GridFormMultiSelect-options{overflow-y:auto}";
2835
2932
  styleInject(css_248z$5);
2836
2933
 
2934
+ var css_248z$4 = ".GridPopoverEditDropDown-containerSmall .GridFormDropDown-options{max-height:120px;overflow-y:auto}.GridPopoverEditDropDown-containerMedium .GridFormDropDown-options{max-height:200px;overflow-y:auto}.GridPopoverEditDropDown-containerLarge .GridFormDropDown-options{max-height:400px;overflow-y:auto}.GridPopoverEditDropDown-containerUnlimited .GridFormDropDown-options{overflow-y:auto}";
2935
+ styleInject(css_248z$4);
2936
+
2837
2937
  /* global setTimeout, clearTimeout */
2838
2938
 
2839
2939
  var dist = function debounce(fn) {
@@ -2921,9 +3021,13 @@ var GridFormDropDown = function (props) {
2921
3021
  var _c = useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
2922
3022
  var optionsInitialising = useRef(false);
2923
3023
  var _d = useState(null), options = _d[0], setOptions = _d[1];
2924
- var _e = useState([]), subComponentValues = _e[0], setSubComponentValues = _e[1];
3024
+ var subComponentIsValid = useRef(false);
3025
+ var _e = useState(), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
3026
+ var _f = useState(), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
2925
3027
  var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
2926
3028
  return __generator(this, function (_a) {
3029
+ if (subComponentValue !== undefined && !subComponentIsValid.current)
3030
+ return [2 /*return*/, false];
2927
3031
  return [2 /*return*/, updateValue(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
2928
3032
  var hasChanged;
2929
3033
  return __generator(this, function (_a) {
@@ -3066,67 +3170,61 @@ var GridFormDropDown = function (props) {
3066
3170
  }
3067
3171
  });
3068
3172
  }); }, [filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, props]);
3069
- var popoverWrapper = useGridPopoverHook({ className: props.className }).popoverWrapper;
3173
+ var save = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3174
+ return __generator(this, function (_a) {
3175
+ switch (_a.label) {
3176
+ case 0:
3177
+ // Handler for sub-selected value
3178
+ if (!selectedSubComponent)
3179
+ return [2 /*return*/, true];
3180
+ if (!subComponentIsValid.current)
3181
+ return [2 /*return*/, false];
3182
+ return [4 /*yield*/, selectItemHandler(selectedSubComponent.value, subSelectedValue)];
3183
+ case 1:
3184
+ _a.sent();
3185
+ return [2 /*return*/, true];
3186
+ }
3187
+ });
3188
+ }); }, [selectItemHandler, selectedSubComponent, subSelectedValue]);
3189
+ var popoverWrapper = useGridPopoverHook({ className: props.className, save: save }).popoverWrapper;
3070
3190
  return popoverWrapper(jsxs(Fragment$1, { children: [props.filtered && (jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3071
3191
  var _b;
3072
3192
  var ref = _a.ref;
3073
3193
  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); } }) })));
3074
3194
  } })), 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) {
3075
3195
  var _a;
3076
- 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 () {
3077
- selectItemHandler(item.value).then();
3078
- } }, { 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) {
3079
- return item.subComponent && (jsx(item.subComponent, { setValue: function (value) {
3080
- var localSubComponentValues = __spreadArray([], subComponentValues, true);
3081
- var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
3082
- var optionValue = _a.optionValue;
3083
- return optionValue === item.value;
3084
- });
3085
- if (subComponentValueIndex !== -1) {
3086
- localSubComponentValues[subComponentValueIndex].subComponentValue = value;
3196
+ 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 : (jsxs("div", { children: [jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function (e) {
3197
+ if (item.subComponent) {
3198
+ if (selectedSubComponent === item) {
3199
+ setSelectedSubComponent(null);
3200
+ subComponentIsValid.current = true;
3087
3201
  }
3088
3202
  else {
3089
- localSubComponentValues.push({
3090
- subComponentValue: value,
3091
- optionValue: item.value
3092
- });
3203
+ setSelectedSubComponent(item);
3093
3204
  }
3094
- setSubComponentValues(localSubComponentValues);
3095
- }, keyDown: function (key, event) {
3096
- var subComponentItem = subComponentValues.find(function (_a) {
3097
- var optionValue = _a.optionValue;
3098
- return optionValue === item.value;
3099
- });
3100
- if ((key === "Enter" || key === "Tab") && subComponentItem) {
3101
- event.preventDefault();
3102
- event.stopPropagation();
3103
- return selectItemHandler(item.value, subComponentItem.subComponentValue).then(function () {
3205
+ e.keepOpen = true;
3206
+ }
3207
+ else {
3208
+ selectItemHandler(item.value).then();
3209
+ }
3210
+ } }, { 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 && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsx(GridSubComponentContext.Provider, __assign({ value: {
3211
+ value: subSelectedValue,
3212
+ setValue: function (value) {
3213
+ setSubSelectedValue(value);
3214
+ },
3215
+ setValid: function (valid) {
3216
+ subComponentIsValid.current = valid;
3217
+ },
3218
+ triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
3219
+ return __generator(this, function (_a) {
3104
3220
  ref.closeMenu();
3105
- return true;
3221
+ return [2 /*return*/];
3106
3222
  });
3107
- }
3108
- return false;
3109
- } }, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner")));
3110
- } }), "".concat(fieldToString(field), "-").concat(index, "_subcomponent"))) }, "menu-wrapper-".concat(index)));
3223
+ }); }
3224
+ } }, { children: item.subComponent && (jsx(item.subComponent, {}, "".concat(fieldToString(field), "-").concat(index, "_subcomponent_inner"))) }))); } }), "".concat(item.label, "_subcomponent")))] }, "menu-wrapper-".concat(index)));
3111
3225
  })] }) }))] }));
3112
3226
  };
3113
3227
 
3114
- var GridSubComponentContext = createContext({
3115
- value: "GridSubComponentContext value no context",
3116
- setValue: function () {
3117
- console.error("GridSubComponentContext setValue no context");
3118
- },
3119
- setValid: function () {
3120
- console.error("GridSubComponentContext setValid no context");
3121
- },
3122
- triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
3123
- return __generator(this, function (_a) {
3124
- console.error("GridSubComponentContext triggerSave no context");
3125
- return [2 /*return*/];
3126
- });
3127
- }); }
3128
- });
3129
-
3130
3228
  var GridFormMultiSelect = function (props) {
3131
3229
  var selectedRows = useGridPopoverContext().selectedRows;
3132
3230
  var initialiseValues = useMemo(function () {
@@ -3231,7 +3329,10 @@ var GridFormMultiSelect = function (props) {
3231
3329
  setSelectedValues(__assign(__assign({}, selectedValues), (_a = {}, _a["".concat(item.value)] = null, _a)));
3232
3330
  }
3233
3331
  }, [selectedValues]);
3234
- var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
3332
+ var _e = useGridPopoverHook({
3333
+ className: props.className,
3334
+ save: save
3335
+ }), popoverWrapper = _e.popoverWrapper, lastInputKeyboardEventHandlers = _e.lastInputKeyboardEventHandlers, triggerSave = _e.triggerSave;
3235
3336
  return popoverWrapper(jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormMultiSelect-container" }, { children: jsxs(Fragment$1, { children: [options && props.filtered && (jsxs(Fragment$1, { children: [jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3236
3337
  var _b;
3237
3338
  var ref = _a.ref;
@@ -3241,18 +3342,7 @@ var GridFormMultiSelect = function (props) {
3241
3342
  return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxs("div", { children: [jsx(MenuItem, __assign({ onClick: function (e) {
3242
3343
  e.keepOpen = true;
3243
3344
  toggleValue(item);
3244
- }, onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () {
3245
- return __generator(this, function (_a) {
3246
- if (e.key === "Enter")
3247
- triggerSave().then();
3248
- else if (e.key === " ") {
3249
- toggleValue(item);
3250
- e.preventDefault();
3251
- e.stopPropagation();
3252
- }
3253
- return [2 /*return*/];
3254
- });
3255
- }); } }, { children: jsx(LuiCheckboxInput, { isChecked: "".concat(item.value) in selectedValues, value: "".concat(item.value), label: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), inputProps: {
3345
+ } }, lastInputKeyboardEventHandlers, { children: jsx(LuiCheckboxInput, { isChecked: "".concat(item.value) in selectedValues, value: "".concat(item.value), label: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), inputProps: {
3256
3346
  onClick: function (e) {
3257
3347
  e.preventDefault();
3258
3348
  e.stopPropagation();
@@ -3280,8 +3370,8 @@ var GridPopoutEditMultiSelect = function (colDef, props) {
3280
3370
  return GridCell(colDef, __assign(__assign({ editor: GridFormMultiSelect }, props), { editorParams: __assign({ className: "GridMultiSelect-containerMedium" }, props.editorParams) }));
3281
3371
  };
3282
3372
 
3283
- var css_248z$4 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
3284
- styleInject(css_248z$4);
3373
+ var css_248z$3 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
3374
+ styleInject(css_248z$3);
3285
3375
 
3286
3376
  /** Menu configuration types **/
3287
3377
  var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
@@ -3379,8 +3469,8 @@ var GridFormPopoverMenu = function (props) {
3379
3469
  e.keepOpen = true;
3380
3470
  }
3381
3471
  else {
3382
- setSubComponentSelected(null);
3383
3472
  actionClick(item).then();
3473
+ e.keepOpen = true;
3384
3474
  }
3385
3475
  }, [actionClick, subComponentSelected]);
3386
3476
  var selectedRowCount = selectedRows.length;
@@ -3397,21 +3487,16 @@ var GridFormPopoverMenu = function (props) {
3397
3487
  return [4 /*yield*/, actionClick(subComponentSelected)];
3398
3488
  case 1:
3399
3489
  _a.sent();
3400
- _a.label = 2;
3401
- case 2: return [2 /*return*/, true];
3490
+ return [2 /*return*/, false];
3491
+ case 2:
3492
+ // Otherwise assume it's a cancel, either way we close the menu
3493
+ return [2 /*return*/, true];
3402
3494
  }
3403
3495
  });
3404
3496
  }); }, [actionClick, subComponentSelected]);
3405
3497
  var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
3406
- var localTriggerSave = function (reason) { return __awaiter(void 0, void 0, void 0, function () {
3407
- return __generator(this, function (_a) {
3408
- if (!subComponentIsValid.current)
3409
- return [2 /*return*/];
3410
- return [2 /*return*/, triggerSave(reason)];
3411
- });
3412
- }); };
3413
3498
  return popoverWrapper(jsx(ComponentLoadingWrapper, __assign({ loading: !filteredOptions, className: "GridFormPopupMenu" }, { children: jsx(Fragment$1, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3414
- return item.label === PopoutMenuSeparator ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxs(Fragment$1, { children: [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 && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
3499
+ return item.label === PopoutMenuSeparator ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxs(Fragment, { children: [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 && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
3415
3500
  return item.subComponent && (jsx(GridSubComponentContext.Provider, __assign({ value: {
3416
3501
  value: subSelectedValue,
3417
3502
  setValue: function (value) {
@@ -3420,9 +3505,9 @@ var GridFormPopoverMenu = function (props) {
3420
3505
  setValid: function (valid) {
3421
3506
  subComponentIsValid.current = valid;
3422
3507
  },
3423
- triggerSave: localTriggerSave
3508
+ triggerSave: triggerSave
3424
3509
  } }, { children: jsx(item.subComponent, {}) })));
3425
- } }), "".concat(item.label, "_subcomponent")))] })));
3510
+ } }), "".concat(item.label, "_subcomponent")))] }, "".concat(item.label))));
3426
3511
  }) }) })));
3427
3512
  };
3428
3513
 
@@ -3514,16 +3599,19 @@ var convertDDToDMS = function (dd, showPositiveSymbol, addTrailingZeros) {
3514
3599
  return dmsString;
3515
3600
  };
3516
3601
 
3517
- var css_248z$3 = ".GridFormEditBearing-input{width:320px}";
3518
- styleInject(css_248z$3);
3519
-
3520
- var css_248z$2 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3602
+ var css_248z$2 = ".GridFormEditBearing-input{width:320px}";
3521
3603
  styleInject(css_248z$2);
3522
3604
 
3605
+ var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3606
+ styleInject(css_248z$1);
3607
+
3523
3608
  var TextInputFormatted = function (props) {
3524
- return (jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.warning && "hasWarning", props.className) }, { children: [jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsx("input", __assign({ type: "text", className: "LuiTextInput-input", min: "0", spellCheck: true, defaultValue: props.value, onChange: props.onChange, onFocus: props.onFocus, onClick: props.onClick, onMouseEnter: function (e) {
3609
+ return (jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.className) }, { children: [jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsx("input", __assign({ type: "text", spellCheck: true, defaultValue: props.value }, omit(props, ["error", "value", "helpText", "formatted", "className"]), { className: "LuiTextInput-input", onMouseEnter: function (e) {
3525
3610
  e.currentTarget.focus();
3526
- } }, props.inputProps)), jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), props.error && (jsxs("span", __assign({ className: "LuiTextInput-error" }, { children: [jsx(LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.warning && (jsxs("span", __assign({ className: "LuiTextInput-warning" }, { children: [jsx(LuiIcon, { alt: "warning", name: "ic_warning", className: "LuiTextInput-warning-icon", size: "sm", status: "warning" }), props.warning] })))] })));
3611
+ props.onMouseEnter && props.onMouseEnter(e);
3612
+ } })), jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), props.error && (jsxs("span", __assign({ className: "LuiTextInput-error" }, { children: [jsx(LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.helpText && !props.error && (jsx("span", __assign({ style: {
3613
+ fontSize: "0.7rem"
3614
+ } }, { children: props.helpText })))] })));
3527
3615
  };
3528
3616
 
3529
3617
  var GridFormEditBearing = function (props) {
@@ -3558,18 +3646,13 @@ var GridFormEditBearing = function (props) {
3558
3646
  }
3559
3647
  });
3560
3648
  }); }, [field, initialValue, props, value]);
3561
- var _c = useGridPopoverHook({ className: props.className, save: save }), triggerSave = _c.triggerSave, popoverWrapper = _c.popoverWrapper;
3562
- return popoverWrapper(jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsx(TextInputFormatted, { value: value !== null && value !== void 0 ? value : "", onChange: function (e) {
3649
+ var _c = useGridPopoverHook({
3650
+ className: props.className,
3651
+ save: save
3652
+ }), popoverWrapper = _c.popoverWrapper, onlyInputKeyboardEventHandlers = _c.onlyInputKeyboardEventHandlers;
3653
+ return popoverWrapper(jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsx(TextInputFormatted, __assign({ value: value !== null && value !== void 0 ? value : "", onChange: function (e) {
3563
3654
  setValue(e.target.value.trim());
3564
- }, inputProps: {
3565
- autoFocus: true,
3566
- placeholder: props.placeHolder,
3567
- disabled: false,
3568
- maxLength: 16,
3569
- onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
3570
- return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
3571
- }); }); }
3572
- }, formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range) }) })));
3655
+ }, autoFocus: true, placeholder: props.placeHolder }, onlyInputKeyboardEventHandlers, { formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range) })) })));
3573
3656
  };
3574
3657
 
3575
3658
  var GridPopoverEditBearingLike = function (colDef, props) {
@@ -3706,32 +3789,44 @@ var useGenerateOrDefaultId = function (idFromProps) {
3706
3789
  return id;
3707
3790
  };
3708
3791
  var TextAreaInput = function (props) {
3709
- var _a, _b;
3710
- var id = useGenerateOrDefaultId((_a = props.inputProps) === null || _a === void 0 ? void 0 : _a.id);
3711
- return (jsxs("div", __assign({ className: clsx("LuiTextAreaInput Grid-popoverContainer", ((_b = props.inputProps) === null || _b === void 0 ? void 0 : _b.disabled) ? "isDisabled" : "", (props === null || props === void 0 ? void 0 : props.error) ? "hasError" : "") }, { children: [jsxs("label", __assign({ htmlFor: id }, { children: [props.mandatory && jsx("span", __assign({ className: "LuiTextAreaInput-mandatory" }, { children: "*" })), props.label && jsx("span", __assign({ className: "LuiTextAreaInput-label" }, { children: props.label })), jsxs("div", __assign({ className: "LuiTextAreaInput-wrapper" }, { children: [" ", jsx("textarea", __assign({ id: id, value: props.value, onChange: props.onChange, rows: 5 }, props.inputProps, { onMouseEnter: function (e) {
3712
- if (document.activeElement != e.currentTarget) {
3713
- e.currentTarget.focus();
3714
- e.currentTarget.selectionStart = e.currentTarget.value.length;
3715
- }
3716
- } }))] }))] })), props.error && (jsxs("span", __assign({ className: "LuiTextAreaInput-error" }, { children: [jsx(LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextAreaInput-error-icon", size: "sm", status: "error" }), props.error] })))] })));
3792
+ var _a;
3793
+ var id = useGenerateOrDefaultId(props === null || props === void 0 ? void 0 : props.id);
3794
+ return (jsxs("div", __assign({ className: clsx("LuiTextAreaInput Grid-popoverContainer", props.disabled ? "isDisabled" : "", props.error ? "hasError" : "", props.className) }, { children: [jsxs("label", __assign({ htmlFor: id }, { children: [props.mandatory != null && jsx("span", __assign({ className: "LuiTextAreaInput-mandatory" }, { children: "*" })), props.label != null && jsx("span", __assign({ className: "LuiTextAreaInput-label" }, { children: props.label })), jsx("div", __assign({ className: "LuiTextAreaInput-wrapper" }, { children: jsx("textarea", __assign({ rows: 5 }, omit(props, ["error", "value", "helpText", "formatted", "className"]), { id: id, value: (_a = props.value) !== null && _a !== void 0 ? _a : "", spellCheck: true, onMouseEnter: function (e) {
3795
+ if (document.activeElement != e.currentTarget) {
3796
+ e.currentTarget.focus();
3797
+ e.currentTarget.selectionStart = e.currentTarget.value.length;
3798
+ }
3799
+ props.onMouseEnter && props.onMouseEnter(e);
3800
+ } }, { children: props.value })) }))] })), props.error && (jsxs("span", __assign({ className: "LuiTextAreaInput-error" }, { children: [jsx(LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextAreaInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.helpText && !props.error && (jsx("span", __assign({ style: {
3801
+ fontSize: "0.7rem"
3802
+ } }, { children: props.helpText })))] })));
3717
3803
  };
3718
3804
 
3719
- var GridFormTextArea = function (props) {
3720
- var _a;
3721
- var _b = useGridPopoverContext(), field = _b.field, initialVale = _b.value;
3722
- var _c = useState(initialVale != null ? "".concat(initialVale) : ""), value = _c[0], setValue = _c[1];
3723
- var invalid = useCallback(function () {
3724
- if (props.required && value.length == 0) {
3725
- return "Some text is required";
3726
- }
3727
- if (props.maxLength && value.length > props.maxLength) {
3728
- return "Text must be no longer than ".concat(props.maxLength, " characters");
3729
- }
3730
- if (props.validate) {
3731
- return props.validate(value);
3732
- }
3805
+ var TextInputValidator = function (props, value) {
3806
+ if (value == null)
3733
3807
  return null;
3734
- }, [props, value]);
3808
+ // This can happen because subcomponent is invoked without type safety
3809
+ if (typeof value !== "string") {
3810
+ console.error("Value is not a string", value);
3811
+ }
3812
+ if (props.required && value.length === 0) {
3813
+ return "Some text is required";
3814
+ }
3815
+ if (props.maxLength && value.length > props.maxLength) {
3816
+ return "Text must be no longer than ".concat(props.maxLength, " characters");
3817
+ }
3818
+ if (props.validate) {
3819
+ return props.validate(value);
3820
+ }
3821
+ return null;
3822
+ };
3823
+
3824
+ var GridFormTextArea = function (props) {
3825
+ var _a, _b;
3826
+ var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
3827
+ var _d = useState(initialVale != null ? "".concat(initialVale) : ""), value = _d[0], setValue = _d[1];
3828
+ var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
3829
+ var invalid = useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3735
3830
  var save = useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3736
3831
  return __generator(this, function (_a) {
3737
3832
  switch (_a.label) {
@@ -3755,30 +3850,19 @@ var GridFormTextArea = function (props) {
3755
3850
  }
3756
3851
  });
3757
3852
  }); }, [invalid, initialVale, value, props, field]);
3758
- var popoverWrapper = useGridPopoverHook({ className: props.className, save: save }).popoverWrapper;
3759
- return popoverWrapper(jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_a = props.width) !== null && _a !== void 0 ? _a : 240 } }, { children: jsx(TextAreaInput, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), inputProps: { placeholder: props.placeholder } }) })));
3853
+ var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, lastInputKeyboardEventHandlers = _e.lastInputKeyboardEventHandlers;
3854
+ return popoverWrapper(jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsx(TextAreaInput, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText }, lastInputKeyboardEventHandlers)) })));
3760
3855
  };
3761
3856
 
3762
3857
  var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
3763
3858
 
3764
3859
  var GridFormTextInput = function (props) {
3765
- var _a;
3766
- var _b = useGridPopoverContext(), field = _b.field, data = _b.data, initialVale = _b.value;
3860
+ var _a, _b;
3861
+ var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value;
3862
+ var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3767
3863
  var initValue = initialVale == null ? "" : "".concat(initialVale);
3768
- var _c = useState(initValue), value = _c[0], setValue = _c[1];
3769
- var invalid = useCallback(function () {
3770
- var trimmedValue = value.trim();
3771
- if (props.required && trimmedValue.length == 0) {
3772
- return "Some text is required";
3773
- }
3774
- if (props.maxLength && trimmedValue.length > props.maxLength) {
3775
- return "Text must be no longer than ".concat(props.maxLength, " characters");
3776
- }
3777
- if (props.validate) {
3778
- return props.validate(trimmedValue, data);
3779
- }
3780
- return null;
3781
- }, [data, props, value]);
3864
+ var _d = useState(initValue), value = _d[0], setValue = _d[1];
3865
+ var invalid = useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3782
3866
  var save = useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3783
3867
  var trimmedValue;
3784
3868
  return __generator(this, function (_a) {
@@ -3804,90 +3888,72 @@ var GridFormTextInput = function (props) {
3804
3888
  }
3805
3889
  });
3806
3890
  }); }, [invalid, value, initValue, props, field]);
3807
- var _d = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _d.popoverWrapper, triggerSave = _d.triggerSave;
3808
- return popoverWrapper(jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_a = props.width) !== null && _a !== void 0 ? _a : 240 }, className: "FormTest" }, { children: jsx(TextInputFormatted, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, inputProps: {
3809
- style: { width: "100%" },
3810
- placeholder: props.placeholder,
3811
- onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
3812
- return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
3813
- }); }); }
3814
- } }) })));
3891
+ var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, lastInputKeyboardEventHandlers = _e.lastInputKeyboardEventHandlers;
3892
+ return popoverWrapper(jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsx(TextInputFormatted, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, style: { width: "100%" }, placeholder: props.placeholder }, lastInputKeyboardEventHandlers, { helpText: helpText })) })));
3815
3893
  };
3816
3894
 
3817
3895
  var GridPopoverTextInput = function (colDef, params) {
3818
3896
  return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
3819
3897
  };
3820
3898
 
3821
- var css_248z$1 = ".GridFormSubComponentTextInput-full-width-input{padding:0;width:100%}";
3822
- styleInject(css_248z$1);
3823
-
3824
- var GridFormSubComponentTextInput = function (_a) {
3825
- var keyDown = _a.keyDown, placeholder = _a.placeholder, setValue = _a.setValue, className = _a.className, customHelpText = _a.customHelpText;
3826
- var placeholderText = placeholder || "Other...";
3827
- var helpText = customHelpText || "Press enter or tab to save";
3828
- var inputClass = className || "GridFormSubComponentTextInput-full-width-input";
3829
- var _b = useState(""), inputValue = _b[0], setInputValue = _b[1];
3830
- return (jsxs("div", __assign({ style: {
3831
- display: "flex",
3832
- flexDirection: "column",
3833
- width: "100%",
3834
- padding: 0
3835
- } }, { children: [jsx(TextInputFormatted, { className: inputClass, value: inputValue, onChange: function (e) {
3836
- var value = e.target.value;
3837
- setValue(value);
3838
- setInputValue(value);
3839
- }, inputProps: {
3840
- onKeyDown: function (e) {
3841
- return keyDown(e.key, e);
3842
- },
3843
- placeholder: placeholderText,
3844
- onMouseEnter: function (e) {
3845
- if (document.activeElement != e.currentTarget) {
3846
- e.currentTarget.focus();
3847
- }
3848
- },
3849
- style: {
3850
- width: "100%"
3851
- }
3852
- } }), jsx("span", __assign({ style: {
3853
- fontSize: "0.7rem"
3854
- } }, { children: helpText }))] })));
3899
+ var GridFormSubComponentTextInput = function (props) {
3900
+ var _a;
3901
+ var _b = useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
3902
+ var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3903
+ // If is not initialised yet as it's just been created then set the default value
3904
+ useEffect(function () {
3905
+ if (value == null)
3906
+ setValue(props.defaultValue);
3907
+ }, [props.defaultValue, setValue, value]);
3908
+ var invalid = useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3909
+ useEffect(function () {
3910
+ setValid(value != null && invalid() == null);
3911
+ }, [setValid, invalid, value]);
3912
+ return (jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true, onKeyDown: function (e) {
3913
+ if (e.key === "Tab" || e.key === "Enter") {
3914
+ e.preventDefault();
3915
+ e.stopPropagation();
3916
+ }
3917
+ }, onKeyUp: function (e) {
3918
+ if (e.key === "Tab") {
3919
+ !e.shiftKey && triggerSave().then();
3920
+ e.preventDefault();
3921
+ e.stopPropagation();
3922
+ }
3923
+ else if (e.key === "Enter") {
3924
+ triggerSave().then();
3925
+ e.preventDefault();
3926
+ e.stopPropagation();
3927
+ }
3928
+ }, placeholder: props.placeholder, style: {
3929
+ width: "100%"
3930
+ } }));
3855
3931
  };
3856
3932
 
3857
- var GridSubComponentTextArea = function (props) {
3858
- var _a = useContext(GridSubComponentContext), value = _a.value, setValue = _a.setValue, setValid = _a.setValid, triggerSave = _a.triggerSave;
3933
+ var GridFormSubComponentTextArea = function (props) {
3934
+ var _a;
3935
+ var _b = useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
3936
+ var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
3859
3937
  // If is not initialised yet as it's just been created then set the default value
3860
3938
  useEffect(function () {
3861
3939
  if (value == null)
3862
3940
  setValue(props.defaultValue);
3863
3941
  }, [props.defaultValue, setValue, value]);
3864
- var validate = useCallback(function (value) {
3865
- if (value == null)
3866
- return null;
3867
- // This can happen because subcomponent is invoked without type safety
3868
- if (typeof value !== "string") {
3869
- console.error("Value is not a string", value);
3870
- }
3871
- if (props.required && value.length === 0) {
3872
- return "Some text is required";
3873
- }
3874
- if (props.maxLength && value.length > props.maxLength) {
3875
- return "Text must be no longer than ".concat(props.maxLength, " characters");
3876
- }
3877
- if (props.validate) {
3878
- return props.validate(value);
3879
- }
3880
- return null;
3881
- }, [props]);
3942
+ var invalid = useCallback(function () { return TextInputValidator(props, value); }, [props, value]);
3882
3943
  useEffect(function () {
3883
- setValid(value != null && validate(value) == null);
3884
- }, [setValid, validate, value]);
3885
- return (jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsx(TextInputFormatted, { className: "free-text-input", value: value, onChange: function (e) { return setValue(e.target.value); }, error: validate(value), inputProps: {
3886
- autoFocus: true,
3887
- placeholder: props.placeholder,
3888
- onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
3889
- return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
3890
- }); }); }
3944
+ setValid(value != null && invalid() == null);
3945
+ }, [setValid, invalid, value]);
3946
+ return (jsx("div", __assign({ className: clsx("FreeTextInput LuiDeprecatedForms", props.className) }, { children: jsx(TextAreaInput, { className: "free-text-input", value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), helpText: helpText, autoFocus: true, placeholder: props.placeholder, onKeyDown: function (e) {
3947
+ if (e.key === "Tab") {
3948
+ e.preventDefault();
3949
+ e.stopPropagation();
3950
+ }
3951
+ }, onKeyUp: function (e) {
3952
+ if (e.key === "Tab") {
3953
+ !e.shiftKey && triggerSave().then();
3954
+ e.preventDefault();
3955
+ e.stopPropagation();
3956
+ }
3891
3957
  } }) })));
3892
3958
  };
3893
3959
 
@@ -4003,5 +4069,5 @@ var ActionButton = function (_a) {
4003
4069
  } })) : (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 }))] }))] })));
4004
4070
  };
4005
4071
 
4006
- 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 };
4072
+ export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponentWrapper, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoverMenu, GridFormSubComponentTextArea, GridFormSubComponentTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverContext, GridPopoverContextProvider, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentContext, 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 };
4007
4073
  //# sourceMappingURL=step-ag-grid.esm.js.map