@linzjs/step-ag-grid 4.0.3 → 5.0.1

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 (47) hide show
  1. package/dist/index.js +278 -239
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/components/GridPopoverHook.d.ts +1 -13
  4. package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
  5. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
  6. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +0 -1
  7. package/dist/src/contexts/GridContext.d.ts +1 -0
  8. package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
  9. package/dist/src/contexts/GridUpdatingContext.d.ts +3 -2
  10. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +1 -1
  11. package/dist/src/lui/FormError.d.ts +6 -0
  12. package/dist/src/react-menu3/components/MenuItem.d.ts +1 -1
  13. package/dist/src/react-menu3/components/SubMenu.d.ts +1 -1
  14. package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
  15. package/dist/src/react-menu3/types.d.ts +18 -17
  16. package/dist/src/react-menu3/utils/constants.d.ts +4 -0
  17. package/dist/src/react-menu3/utils/utils.d.ts +1 -1
  18. package/dist/step-ag-grid.esm.js +279 -240
  19. package/dist/step-ag-grid.esm.js.map +1 -1
  20. package/package.json +1 -1
  21. package/src/components/GridPopoverHook.tsx +11 -80
  22. package/src/components/gridForm/GridFormDropDown.tsx +49 -43
  23. package/src/components/gridForm/GridFormEditBearing.tsx +1 -2
  24. package/src/components/gridForm/GridFormMultiSelect.tsx +12 -4
  25. package/src/components/gridForm/GridFormPopoverMenu.tsx +25 -22
  26. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -14
  27. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -18
  28. package/src/components/gridForm/GridFormTextArea.tsx +3 -2
  29. package/src/components/gridForm/GridFormTextInput.tsx +4 -7
  30. package/src/contexts/GridContext.tsx +4 -0
  31. package/src/contexts/GridContextProvider.tsx +8 -0
  32. package/src/contexts/GridPopoverContext.tsx +1 -1
  33. package/src/contexts/GridPopoverContextProvider.tsx +7 -4
  34. package/src/contexts/GridUpdatingContext.tsx +7 -1
  35. package/src/contexts/GridUpdatingContextProvider.tsx +17 -6
  36. package/src/lui/FormError.tsx +29 -0
  37. package/src/lui/TextAreaInput.tsx +2 -18
  38. package/src/lui/TextInputFormatted.tsx +2 -17
  39. package/src/react-menu3/components/ControlledMenu.tsx +121 -13
  40. package/src/react-menu3/components/MenuItem.tsx +19 -2
  41. package/src/react-menu3/types.ts +2 -0
  42. package/src/react-menu3/utils/constants.ts +4 -0
  43. package/src/stories/grid/FormTest.tsx +25 -25
  44. package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +10 -0
  45. package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +1 -1
  46. package/src/stories/grid/GridReadOnly.stories.tsx +11 -11
  47. package/src/styles/GridFormDropDown.scss +1 -1
@@ -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, delay, sortBy, last, difference, castArray, remove, flatten, xorBy, fromPairs, omit, pick, toPairs, isEqual } from 'lodash-es';
3
+ import { findIndex, debounce, isEmpty, delay, sortBy, last, difference, castArray, remove, flatten, xorBy, fromPairs, pick, omit, 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';
@@ -69,6 +69,7 @@ var subMenuClass = "submenu";
69
69
  var radioGroupClass = "radio-group";
70
70
  var Keys = Object.freeze({
71
71
  ENTER: "Enter",
72
+ TAB: "Tab",
72
73
  ESC: "Escape",
73
74
  SPACE: " ",
74
75
  HOME: "Home",
@@ -92,7 +93,9 @@ var CloseReason = Object.freeze({
92
93
  CLICK: "click",
93
94
  CANCEL: "cancel",
94
95
  BLUR: "blur",
95
- SCROLL: "scroll"
96
+ SCROLL: "scroll",
97
+ TAB_FORWARD: "tab_forward",
98
+ TAB_BACKWARD: "tab_backward"
96
99
  });
97
100
  var FocusPositions = Object.freeze({
98
101
  FIRST: "first",
@@ -1364,14 +1367,120 @@ var ControlledMenuFr = function (_a, externalRef) {
1364
1367
  ev.stopPropagation();
1365
1368
  }
1366
1369
  }, [isWithinMenu]);
1370
+ var lastTabDownEl = useRef();
1371
+ var lastEnterDownEl = useRef();
1372
+ var handleKeyboardTabAndEnter = useCallback(function (isDown) { return function (ev) {
1373
+ var thisDocument = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
1374
+ var activeElement = thisDocument.activeElement;
1375
+ if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) || !activeElement)
1376
+ return;
1377
+ if (ev.key !== "Tab" && ev.key !== "Enter")
1378
+ return;
1379
+ if (ev.repeat) {
1380
+ ev.preventDefault();
1381
+ ev.stopPropagation();
1382
+ return;
1383
+ }
1384
+ var inputElsIterator = thisDocument.querySelectorAll(".szh-menu--state-open input,textarea");
1385
+ var inputEls = [];
1386
+ inputElsIterator.forEach(function (el) { return inputEls.push(el); });
1387
+ inputEls = inputEls.filter(function (el) { return !el.disabled; });
1388
+ if (inputEls.length === 0)
1389
+ return;
1390
+ var firstInputEl = inputEls[0];
1391
+ var lastInputEl = inputEls[inputEls.length - 1];
1392
+ if (activeElement !== firstInputEl && activeElement !== lastInputEl)
1393
+ return;
1394
+ var suppressAutoSaveEvents = activeElement.getAttribute("data-suppressAutoSaveEvents");
1395
+ var invokeSave = function (reason) {
1396
+ var _a, _b;
1397
+ if (!(saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) || suppressAutoSaveEvents)
1398
+ return;
1399
+ (_a = saveButtonRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-reason", reason);
1400
+ (_b = saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) === null || _b === void 0 ? void 0 : _b.click();
1401
+ };
1402
+ var isTextArea = activeElement.nodeName === "TEXTAREA";
1403
+ switch (activeElement.nodeName) {
1404
+ case "TEXTAREA":
1405
+ case "INPUT": {
1406
+ if (activeElement === lastInputEl && activeElement === firstInputEl) {
1407
+ if (ev.key === "Tab") {
1408
+ // Can't forward/backwards tab out of popup
1409
+ ev.preventDefault();
1410
+ ev.stopPropagation();
1411
+ if (isDown) {
1412
+ lastTabDownEl.current = activeElement;
1413
+ }
1414
+ else {
1415
+ lastTabDownEl.current == activeElement &&
1416
+ invokeSave(ev.shiftKey ? CloseReason.TAB_BACKWARD : CloseReason.TAB_FORWARD);
1417
+ }
1418
+ }
1419
+ if (ev.key === "Enter" && !isTextArea) {
1420
+ ev.preventDefault();
1421
+ ev.stopPropagation();
1422
+ if (isDown) {
1423
+ lastEnterDownEl.current = activeElement;
1424
+ }
1425
+ else {
1426
+ lastEnterDownEl.current == activeElement && invokeSave(CloseReason.CLICK);
1427
+ }
1428
+ }
1429
+ }
1430
+ else if (activeElement === lastInputEl) {
1431
+ if (ev.key === "Tab" && !ev.shiftKey) {
1432
+ // Can't backward tab out of popup
1433
+ ev.preventDefault();
1434
+ ev.stopPropagation();
1435
+ if (isDown) {
1436
+ lastTabDownEl.current = activeElement;
1437
+ }
1438
+ else {
1439
+ lastTabDownEl.current == activeElement && invokeSave(CloseReason.TAB_FORWARD);
1440
+ }
1441
+ }
1442
+ if (ev.key === "Enter" && !isTextArea) {
1443
+ ev.preventDefault();
1444
+ ev.stopPropagation();
1445
+ if (isDown) {
1446
+ lastEnterDownEl.current = activeElement;
1447
+ }
1448
+ else {
1449
+ lastEnterDownEl.current == activeElement && invokeSave(CloseReason.CLICK);
1450
+ }
1451
+ }
1452
+ }
1453
+ else if (activeElement === firstInputEl) {
1454
+ if (ev.key === "Tab" && ev.shiftKey) {
1455
+ // Can't backward tab out of popup
1456
+ ev.preventDefault();
1457
+ ev.stopPropagation();
1458
+ if (isDown) {
1459
+ lastTabDownEl.current = activeElement;
1460
+ }
1461
+ else {
1462
+ lastTabDownEl.current == activeElement && invokeSave(CloseReason.TAB_BACKWARD);
1463
+ }
1464
+ }
1465
+ }
1466
+ break;
1467
+ }
1468
+ }
1469
+ }; }, [anchorRef, saveButtonRef]);
1470
+ var handleKeydownTabAndEnter = useMemo(function () { return handleKeyboardTabAndEnter(true); }, [handleKeyboardTabAndEnter]);
1471
+ var handleKeyupTabAndEnter = useMemo(function () { return handleKeyboardTabAndEnter(false); }, [handleKeyboardTabAndEnter]);
1367
1472
  useEffect(function () {
1368
1473
  if (isMenuOpen(state)) {
1369
1474
  var thisDocument_1 = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
1475
+ thisDocument_1.addEventListener("keydown", handleKeydownTabAndEnter, true);
1476
+ thisDocument_1.addEventListener("keyup", handleKeyupTabAndEnter, true);
1370
1477
  thisDocument_1.addEventListener("mousedown", handleScreenEventForSave, true);
1371
1478
  thisDocument_1.addEventListener("mouseup", handleScreenEventForCancel, true);
1372
1479
  thisDocument_1.addEventListener("click", handleScreenEventForCancel, true);
1373
1480
  thisDocument_1.addEventListener("dblclick", handleScreenEventForCancel, true);
1374
1481
  return function () {
1482
+ thisDocument_1.addEventListener("keydown", handleKeydownTabAndEnter, true);
1483
+ thisDocument_1.addEventListener("keyup", handleKeyupTabAndEnter, true);
1375
1484
  thisDocument_1.removeEventListener("mousedown", handleScreenEventForSave, true);
1376
1485
  thisDocument_1.removeEventListener("mouseup", handleScreenEventForCancel, true);
1377
1486
  thisDocument_1.removeEventListener("click", handleScreenEventForCancel, true);
@@ -1379,7 +1488,14 @@ var ControlledMenuFr = function (_a, externalRef) {
1379
1488
  };
1380
1489
  }
1381
1490
  return function () { };
1382
- }, [handleScreenEventForSave, handleScreenEventForCancel, state, anchorRef]);
1491
+ }, [
1492
+ handleScreenEventForSave,
1493
+ handleScreenEventForCancel,
1494
+ state,
1495
+ anchorRef,
1496
+ handleKeydownTabAndEnter,
1497
+ handleKeyupTabAndEnter,
1498
+ ]);
1383
1499
  var itemSettings = useMemo(function () { return ({
1384
1500
  submenuOpenDelay: submenuOpenDelay,
1385
1501
  submenuCloseDelay: submenuCloseDelay
@@ -1399,7 +1515,12 @@ var ControlledMenuFr = function (_a, externalRef) {
1399
1515
  safeCall(onClose, {
1400
1516
  value: event.value,
1401
1517
  key: event.key,
1402
- reason: CloseReason.CLICK
1518
+ shiftKey: event.shiftKey,
1519
+ reason: event.key === "Tab"
1520
+ ? event.shiftKey
1521
+ ? CloseReason.TAB_BACKWARD
1522
+ : CloseReason.TAB_FORWARD
1523
+ : CloseReason.CLICK
1403
1524
  });
1404
1525
  }
1405
1526
  },
@@ -1674,8 +1795,11 @@ var MenuItemFr = function (_a) {
1674
1795
  value: value,
1675
1796
  syntheticEvent: e
1676
1797
  };
1677
- if (e.key !== undefined)
1678
- event.key = e.key;
1798
+ if (e.key !== undefined) {
1799
+ var ke = e;
1800
+ event.key = ke.key;
1801
+ event.shiftKey = ke.shiftKey;
1802
+ }
1679
1803
  if (isCheckBox)
1680
1804
  event.checked = !isChecked;
1681
1805
  if (isRadio)
@@ -1685,6 +1809,13 @@ var MenuItemFr = function (_a) {
1685
1809
  safeCall(radioGroup.onRadioChange, event);
1686
1810
  eventHandlers.handleClick(event, isCheckBox || isRadio);
1687
1811
  };
1812
+ var handleKeyDown = function (e) {
1813
+ // if tab is allowed the handleKeyUp event can't process the tab
1814
+ if (e.key === "Tab") {
1815
+ e.preventDefault();
1816
+ e.stopPropagation();
1817
+ }
1818
+ };
1688
1819
  /**
1689
1820
  * Keyboard events are triggered on up, otherwise sub-components get spaces and enters typed in them
1690
1821
  */
@@ -1693,7 +1824,10 @@ var MenuItemFr = function (_a) {
1693
1824
  return;
1694
1825
  switch (e.key) {
1695
1826
  case Keys.ENTER:
1827
+ case Keys.TAB:
1696
1828
  case Keys.SPACE:
1829
+ e.preventDefault();
1830
+ e.stopPropagation();
1697
1831
  if (isAnchor) {
1698
1832
  (menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.click();
1699
1833
  }
@@ -1710,7 +1844,7 @@ var MenuItemFr = function (_a) {
1710
1844
  checked: isChecked,
1711
1845
  anchor: isAnchor
1712
1846
  }); }, [type, isDisabled, isHovering, isChecked, isAnchor]);
1713
- var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
1847
+ var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
1714
1848
  // Order of props overriding (same in all components):
1715
1849
  // 1. Preset props adhering to WAI-ARIA Authoring Practices.
1716
1850
  // 2. Merged outer and local props
@@ -1855,6 +1989,9 @@ var GridContext = createContext({
1855
1989
  }); },
1856
1990
  redrawRows: function () {
1857
1991
  console.error("no context provider for redrawRows");
1992
+ },
1993
+ selectNextCell: function () {
1994
+ console.error("no context provider for selectNextCell");
1858
1995
  }
1859
1996
  });
1860
1997
 
@@ -1868,7 +2005,8 @@ var GridUpdatingContext = createContext({
1868
2005
  console.error("Missing GridUpdatingContext");
1869
2006
  return [2 /*return*/];
1870
2007
  });
1871
- }); }
2008
+ }); },
2009
+ updatedDep: 0
1872
2010
  });
1873
2011
 
1874
2012
  /**
@@ -2128,6 +2266,15 @@ var GridContextProvider = function (props) {
2128
2266
  gridApi.redrawRows(rowNodes ? { rowNodes: rowNodes } : undefined);
2129
2267
  });
2130
2268
  };
2269
+ var selectNextCell = function (tabDirection) {
2270
+ if (tabDirection === void 0) { tabDirection = 0; }
2271
+ gridApiOp(function (gridApi) {
2272
+ if (tabDirection == 1)
2273
+ gridApi.tabToNextCell();
2274
+ if (tabDirection == -1)
2275
+ gridApi.tabToPreviousCell();
2276
+ });
2277
+ };
2131
2278
  return (jsx(GridContext.Provider, __assign({ value: {
2132
2279
  gridReady: gridReady,
2133
2280
  setGridApi: setGridApi,
@@ -2146,34 +2293,42 @@ var GridContextProvider = function (props) {
2146
2293
  sizeColumnsToFit: sizeColumnsToFit,
2147
2294
  stopEditing: stopEditing,
2148
2295
  updatingCells: updatingCells,
2149
- redrawRows: redrawRows
2296
+ redrawRows: redrawRows,
2297
+ selectNextCell: selectNextCell
2150
2298
  } }, { children: props.children })));
2151
2299
  };
2152
2300
 
2153
2301
  var GridUpdatingContextProvider = function (props) {
2154
2302
  var updatingBlocks = useRef({});
2155
2303
  var updating = useRef({});
2304
+ var _a = useState(0), updatedDep = _a[0], setUpdatedDep = _a[1];
2156
2305
  var resetUpdating = function () {
2157
2306
  var mergedUpdatingBlocks = {};
2158
2307
  for (var key in updatingBlocks.current) {
2159
2308
  mergedUpdatingBlocks[key] = flatten(updatingBlocks.current[key]);
2160
2309
  }
2161
2310
  updating.current = mergedUpdatingBlocks;
2311
+ setUpdatedDep(function (updatedDep) { return updatedDep + 1; });
2162
2312
  };
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) {
2313
+ var modifyUpdating = function (fields, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
2314
+ var idRef;
2315
+ return __generator(this, function (_a) {
2316
+ switch (_a.label) {
2168
2317
  case 0:
2169
- fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2170
2318
  idRef = __spreadArray([], ids, true);
2171
- fieldUpdatingIds.push(idRef);
2319
+ castArray(fields).forEach(function (field) {
2320
+ var _a;
2321
+ var fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2322
+ fieldUpdatingIds.push(idRef);
2323
+ });
2172
2324
  resetUpdating();
2173
2325
  return [4 /*yield*/, fn()];
2174
2326
  case 1:
2175
- _b.sent();
2176
- remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2327
+ _a.sent();
2328
+ castArray(fields).forEach(function (field) {
2329
+ var fieldUpdatingIds = updatingBlocks.current[field];
2330
+ remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2331
+ });
2177
2332
  resetUpdating();
2178
2333
  return [2 /*return*/];
2179
2334
  }
@@ -2182,7 +2337,7 @@ var GridUpdatingContextProvider = function (props) {
2182
2337
  var checkUpdating = function (fields, id) {
2183
2338
  return castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
2184
2339
  };
2185
- return (jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
2340
+ return (jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating, updatedDep: updatedDep } }, { children: props.children })));
2186
2341
  };
2187
2342
 
2188
2343
  var GridPopoverContext = createContext({
@@ -2204,7 +2359,7 @@ var useGridPopoverContext = function () {
2204
2359
  var GridPopoverContextProvider = function (_a) {
2205
2360
  var _b, _c, _d;
2206
2361
  var props = _a.props, children = _a.children;
2207
- var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing;
2362
+ var _e = useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing, selectNextCell = _e.selectNextCell;
2208
2363
  var anchorRef = useRef(props.eGridCell);
2209
2364
  var _f = useState(false), saving = _f[0], setSaving = _f[1];
2210
2365
  var colDef = props.colDef;
@@ -2213,7 +2368,7 @@ var GridPopoverContextProvider = function (_a) {
2213
2368
  // Then item that is clicked on will always be first in the list
2214
2369
  var selectedRows = useMemo(function () { return (multiEdit ? sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2215
2370
  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 () {
2371
+ var updateValue = useCallback(function (saveFn, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
2217
2372
  var result;
2218
2373
  return __generator(this, function (_a) {
2219
2374
  switch (_a.label) {
@@ -2223,13 +2378,15 @@ var GridPopoverContextProvider = function (_a) {
2223
2378
  return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2224
2379
  case 1:
2225
2380
  result = _a.sent();
2226
- if (result)
2381
+ if (result) {
2227
2382
  stopEditing();
2383
+ tabDirection && selectNextCell(tabDirection);
2384
+ }
2228
2385
  _a.label = 2;
2229
2386
  case 2: return [2 /*return*/, result];
2230
2387
  }
2231
2388
  });
2232
- }); }, [field, saving, selectedRows, stopEditing, updatingCells]);
2389
+ }); }, [field, saving, selectNextCell, selectedRows, stopEditing, updatingCells]);
2233
2390
  return (jsx(GridPopoverContext.Provider, __assign({ value: {
2234
2391
  anchorRef: anchorRef,
2235
2392
  saving: saving,
@@ -2259,43 +2416,7 @@ var GridSubComponentContext = createContext({
2259
2416
  }); }
2260
2417
  });
2261
2418
 
2262
- function toVal(mix) {
2263
- var k, y, str='';
2264
- if (mix) {
2265
- if (typeof mix === 'object') {
2266
- if (Array.isArray(mix)) {
2267
- for (k=0; k < mix.length; k++) {
2268
- if (mix[k] && (y = toVal(mix[k]))) {
2269
- str && (str += ' ');
2270
- str += y;
2271
- }
2272
- }
2273
- } else {
2274
- for (k in mix) {
2275
- if (mix[k] && (y = toVal(k))) {
2276
- str && (str += ' ');
2277
- str += y;
2278
- }
2279
- }
2280
- }
2281
- } else if (typeof mix !== 'boolean' && !mix.call) {
2282
- str && (str += ' ');
2283
- str += mix;
2284
- }
2285
- }
2286
- return str;
2287
- }
2288
-
2289
- function clsx () {
2290
- var i=0, x, str='';
2291
- while (i < arguments.length) {
2292
- if (x = toVal(arguments[i++])) {
2293
- str && (str += ' ');
2294
- str += x;
2295
- }
2296
- }
2297
- return str;
2298
- }
2419
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
2299
2420
 
2300
2421
  /**
2301
2422
  * Retains last sort order from via <AgGrid postRowSort>.
@@ -2812,7 +2933,7 @@ var useGridPopoverHook = function (props) {
2812
2933
  // forms that don't provide an invalid fn must wait until they have saved to close
2813
2934
  if (props.invalid)
2814
2935
  stopEditing();
2815
- return [4 /*yield*/, updateValue(props.save)];
2936
+ return [4 /*yield*/, updateValue(props.save, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
2816
2937
  case 2:
2817
2938
  if (_a.sent()) {
2818
2939
  if (!props.invalid)
@@ -2823,72 +2944,6 @@ var useGridPopoverHook = function (props) {
2823
2944
  }
2824
2945
  });
2825
2946
  }); }, [props, stopEditing, updateValue]);
2826
- var onlyInputKeyboardEventHandlers = {
2827
- onKeyUp: function (e) {
2828
- var isTextArea = e.currentTarget.type === "textarea";
2829
- if (e.key === "Enter" && !isTextArea) {
2830
- e.preventDefault();
2831
- e.stopPropagation();
2832
- triggerSave().then();
2833
- }
2834
- else if (e.key === "Tab") {
2835
- e.preventDefault();
2836
- e.stopPropagation();
2837
- }
2838
- },
2839
- onKeyDown: function (e) {
2840
- var isTextArea = e.currentTarget.type === "textarea";
2841
- if (e.key === "Enter" && !isTextArea) {
2842
- e.preventDefault();
2843
- e.stopPropagation();
2844
- }
2845
- else if (e.key === "Tab") {
2846
- e.preventDefault();
2847
- e.stopPropagation();
2848
- !e.shiftKey && triggerSave().then();
2849
- }
2850
- }
2851
- };
2852
- var firstInputKeyboardEventHandlers = {
2853
- onKeyUp: function (e) {
2854
- if (e.key === "Tab" && e.shiftKey) {
2855
- e.preventDefault();
2856
- e.stopPropagation();
2857
- }
2858
- },
2859
- onKeyDown: function (e) {
2860
- if (e.key === "Tab" && e.shiftKey) {
2861
- e.preventDefault();
2862
- e.stopPropagation();
2863
- }
2864
- }
2865
- };
2866
- var lastInputKeyboardEventHandlers = {
2867
- onKeyUp: function (e) {
2868
- var isTextArea = e.currentTarget.type === "textarea";
2869
- if (e.key === "Enter" && !isTextArea) {
2870
- e.preventDefault();
2871
- e.stopPropagation();
2872
- triggerSave().then();
2873
- }
2874
- else if (e.key === "Tab" && !e.shiftKey) {
2875
- e.preventDefault();
2876
- e.stopPropagation();
2877
- }
2878
- },
2879
- onKeyDown: function (e) {
2880
- var isTextArea = e.currentTarget.type === "textarea";
2881
- if (e.key === "Enter" && !isTextArea) {
2882
- e.preventDefault();
2883
- e.stopPropagation();
2884
- }
2885
- else if (e.key === "Tab" && !e.shiftKey) {
2886
- e.preventDefault();
2887
- e.stopPropagation();
2888
- triggerSave().then();
2889
- }
2890
- }
2891
- };
2892
2947
  var popoverWrapper = useCallback(function (children) {
2893
2948
  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) {
2894
2949
  // Prevent menu from closing when modals are invoked
@@ -2904,16 +2959,14 @@ var useGridPopoverHook = function (props) {
2904
2959
  right: 0,
2905
2960
  backgroundColor: "rgba(64,64,64,0.1)",
2906
2961
  zIndex: 1000
2907
- } })), children, jsx("button", { ref: saveButtonRef, onClick: function () {
2908
- triggerSave().then();
2962
+ } })), children, jsx("button", { ref: saveButtonRef, "data-reason": "", onClick: function (e) {
2963
+ var _a;
2964
+ triggerSave((_a = e.currentTarget.getAttribute("data-reason")) !== null && _a !== void 0 ? _a : undefined).then();
2909
2965
  }, style: { display: "none" } })] }))) }));
2910
2966
  }, [anchorRef, isOpen, props.className, saving, triggerSave]);
2911
2967
  return {
2912
2968
  popoverWrapper: popoverWrapper,
2913
- triggerSave: triggerSave,
2914
- onlyInputKeyboardEventHandlers: onlyInputKeyboardEventHandlers,
2915
- firstInputKeyboardEventHandlers: firstInputKeyboardEventHandlers,
2916
- lastInputKeyboardEventHandlers: lastInputKeyboardEventHandlers
2969
+ triggerSave: triggerSave
2917
2970
  };
2918
2971
  };
2919
2972
 
@@ -2939,7 +2992,7 @@ var GridRenderPopoutMenuCell = function (props) {
2939
2992
  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}";
2940
2993
  styleInject(css_248z$5);
2941
2994
 
2942
- 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}";
2995
+ var css_248z$4 = ".GridPopoverEditDropDown-containerSmall .GridFormDropDown-options{max-height:120px;overflow-y:auto}.GridPopoverEditDropDown-containerMedium .GridFormDropDown-options{max-height:220px;overflow-y:auto}.GridPopoverEditDropDown-containerLarge .GridFormDropDown-options{max-height:400px;overflow-y:auto}.GridPopoverEditDropDown-containerUnlimited .GridFormDropDown-options{overflow-y:auto}";
2943
2996
  styleInject(css_248z$4);
2944
2997
 
2945
2998
  /* global setTimeout, clearTimeout */
@@ -3024,7 +3077,6 @@ var fieldToString = function (field) {
3024
3077
  };
3025
3078
  var GridFormDropDown = function (props) {
3026
3079
  var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
3027
- var stopEditing = useContext(GridContext).stopEditing;
3028
3080
  // Save triggers during async action processing which triggers another selectItem(), this ref blocks that
3029
3081
  var hasSubmitted = useRef(false);
3030
3082
  var _b = useState(""), filter = _b[0], setFilter = _b[1];
@@ -3034,7 +3086,7 @@ var GridFormDropDown = function (props) {
3034
3086
  var subComponentIsValid = useRef(false);
3035
3087
  var _e = useState(), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
3036
3088
  var _f = useState(null), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
3037
- var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
3089
+ var selectItemHandler = useCallback(function (value, subComponentValue, reason) { return __awaiter(void 0, void 0, void 0, function () {
3038
3090
  return __generator(this, function (_a) {
3039
3091
  if (hasSubmitted.current || (subComponentValue !== undefined && !subComponentIsValid.current))
3040
3092
  return [2 /*return*/, false];
@@ -3057,7 +3109,7 @@ var GridFormDropDown = function (props) {
3057
3109
  case 3: return [2 /*return*/, true];
3058
3110
  }
3059
3111
  });
3060
- }); })];
3112
+ }); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
3061
3113
  });
3062
3114
  }); }, [field, props, updateValue]);
3063
3115
  var selectFilterHandler = useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
@@ -3077,7 +3129,7 @@ var GridFormDropDown = function (props) {
3077
3129
  return [2 /*return*/, true];
3078
3130
  }
3079
3131
  });
3080
- }); })];
3132
+ }); }, 0)];
3081
3133
  });
3082
3134
  }); }, [props, updateValue]);
3083
3135
  // Load up options list if it's async function
@@ -3151,52 +3203,48 @@ var GridFormDropDown = function (props) {
3151
3203
  researchOnFilterChange().then();
3152
3204
  }
3153
3205
  }, [filter, props, researchOnFilterChange]);
3154
- var onFilterKeyDown = useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
3206
+ var save = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3155
3207
  var activeOptions;
3156
3208
  return __generator(this, function (_a) {
3157
3209
  switch (_a.label) {
3158
3210
  case 0:
3159
3211
  if (!options)
3160
- return [2 /*return*/];
3161
- if (!(e.key == "Enter" || e.key == "Tab")) return [3 /*break*/, 5];
3212
+ return [2 /*return*/, true];
3162
3213
  activeOptions = options.filter(function (option) { return !filteredValues.includes(option.value); });
3163
- if (!(activeOptions.length == 1)) return [3 /*break*/, 2];
3214
+ if (!(activeOptions.length === 1)) return [3 /*break*/, 2];
3164
3215
  return [4 /*yield*/, selectItemHandler(activeOptions[0].value)];
3165
3216
  case 1:
3166
3217
  _a.sent();
3167
- stopEditing();
3168
- return [3 /*break*/, 5];
3218
+ return [3 /*break*/, 6];
3169
3219
  case 2:
3170
- if (!props.onSelectFilter) return [3 /*break*/, 4];
3220
+ if (!(activeOptions.length === 0 && props.onSelectFilter)) return [3 /*break*/, 4];
3171
3221
  return [4 /*yield*/, selectFilterHandler(filter)];
3172
3222
  case 3:
3173
3223
  _a.sent();
3174
- stopEditing();
3175
- return [3 /*break*/, 5];
3224
+ return [3 /*break*/, 6];
3176
3225
  case 4:
3177
- e.preventDefault();
3178
- e.stopPropagation();
3179
- _a.label = 5;
3180
- case 5: return [2 /*return*/];
3181
- }
3182
- });
3183
- }); }, [filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, props]);
3184
- var save = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3185
- return __generator(this, function (_a) {
3186
- switch (_a.label) {
3187
- case 0:
3188
3226
  // Handler for sub-selected value
3189
3227
  if (!selectedSubComponent)
3190
3228
  return [2 /*return*/, true];
3191
3229
  if (selectedSubComponent.subComponent && !subComponentIsValid.current)
3192
3230
  return [2 /*return*/, false];
3193
3231
  return [4 /*yield*/, selectItemHandler(selectedSubComponent.value, subSelectedValue)];
3194
- case 1:
3232
+ case 5:
3195
3233
  _a.sent();
3196
- return [2 /*return*/, true];
3234
+ _a.label = 6;
3235
+ case 6: return [2 /*return*/, true];
3197
3236
  }
3198
3237
  });
3199
- }); }, [selectItemHandler, selectedSubComponent, subSelectedValue]);
3238
+ }); }, [
3239
+ filter,
3240
+ filteredValues,
3241
+ options,
3242
+ props.onSelectFilter,
3243
+ selectFilterHandler,
3244
+ selectItemHandler,
3245
+ selectedSubComponent,
3246
+ subSelectedValue,
3247
+ ]);
3200
3248
  var popoverWrapper = useGridPopoverHook({
3201
3249
  className: props.className,
3202
3250
  invalid: function () { return !!(selectedSubComponent && !subComponentIsValid.current); },
@@ -3205,7 +3253,7 @@ var GridFormDropDown = function (props) {
3205
3253
  return popoverWrapper(jsxs(Fragment$1, { children: [props.filtered && (jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3206
3254
  var _b;
3207
3255
  var ref = _a.ref;
3208
- 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); } }) })));
3256
+ 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()); } }) })));
3209
3257
  } })), 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) {
3210
3258
  var _a;
3211
3259
  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: [jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function (e) {
@@ -3222,7 +3270,11 @@ var GridFormDropDown = function (props) {
3222
3270
  e.keepOpen = true;
3223
3271
  }
3224
3272
  else {
3225
- selectItemHandler(item.value).then();
3273
+ selectItemHandler(item.value, undefined, e.key === "Tab"
3274
+ ? e.shiftKey
3275
+ ? CloseReason.TAB_BACKWARD
3276
+ : CloseReason.TAB_FORWARD
3277
+ : CloseReason.CLICK).then();
3226
3278
  }
3227
3279
  } }, { children: [(_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)), item.subComponent ? "..." : ""] }), "".concat(fieldToString(field), "-").concat(index)), item.subComponent && selectedSubComponent === item && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsx(GridSubComponentContext.Provider, __assign({ value: {
3228
3280
  data: data,
@@ -3256,6 +3308,10 @@ var GridFormMultiSelect = function (props) {
3256
3308
  var _d = useState([]), filteredValues = _d[0], setFilteredValues = _d[1];
3257
3309
  var optionsInitialising = useRef(false);
3258
3310
  var _e = useState(), options = _e[0], setOptions = _e[1];
3311
+ var invalid = useCallback(function () {
3312
+ var validations = pick(subComponentIsValid.current, Object.keys(selectedValues));
3313
+ return Object.values(validations).some(function (v) { return !v; });
3314
+ }, [selectedValues]);
3259
3315
  var save = useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3260
3316
  var validations, notValid, menuOptionSubValueResult;
3261
3317
  return __generator(this, function (_a) {
@@ -3349,8 +3405,9 @@ var GridFormMultiSelect = function (props) {
3349
3405
  }, [selectedValues]);
3350
3406
  var _f = useGridPopoverHook({
3351
3407
  className: props.className,
3408
+ invalid: invalid,
3352
3409
  save: save
3353
- }), popoverWrapper = _f.popoverWrapper, lastInputKeyboardEventHandlers = _f.lastInputKeyboardEventHandlers, triggerSave = _f.triggerSave;
3410
+ }), popoverWrapper = _f.popoverWrapper, triggerSave = _f.triggerSave;
3354
3411
  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) {
3355
3412
  var _b;
3356
3413
  var ref = _a.ref;
@@ -3358,9 +3415,12 @@ var GridFormMultiSelect = function (props) {
3358
3415
  } }), "filter"), jsx(MenuDivider, {}, "$$divider_filter")] })), jsx("div", __assign({ className: "GridFormMultiSelect-options" }, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3359
3416
  var _a;
3360
3417
  return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxs("div", { children: [jsx(MenuItem, __assign({ onClick: function (e) {
3361
- e.keepOpen = true;
3362
- toggleValue(item);
3363
- } }, 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: {
3418
+ // Global react-menu MenuItem handler handles tabs
3419
+ if (e.key !== "Tab") {
3420
+ e.keepOpen = true;
3421
+ toggleValue(item);
3422
+ }
3423
+ } }, { 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: {
3364
3424
  onClick: function (e) {
3365
3425
  e.preventDefault();
3366
3426
  e.stopPropagation();
@@ -3460,7 +3520,7 @@ var GridFormPopoverMenu = function (props) {
3460
3520
  });
3461
3521
  }); })();
3462
3522
  }, [options, props.defaultAction, props.options, selectedRows]);
3463
- var actionClick = useCallback(function (menuOption) { return __awaiter(void 0, void 0, void 0, function () {
3523
+ var actionClick = useCallback(function (menuOption, reason) { return __awaiter(void 0, void 0, void 0, function () {
3464
3524
  return __generator(this, function (_a) {
3465
3525
  actionProcessing.current = true;
3466
3526
  return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -3477,25 +3537,27 @@ var GridFormPopoverMenu = function (props) {
3477
3537
  return [2 /*return*/, true];
3478
3538
  }
3479
3539
  });
3480
- }); })];
3540
+ }); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
3481
3541
  });
3482
3542
  }); }, [defaultAction, selectedRows, subSelectedValue, updateValue]);
3483
- var onMenuItemClick = useCallback(function (e, item) {
3484
- if (item.subComponent) {
3485
- subComponentIsValid.current = false;
3486
- setSubSelectedValue(null);
3487
- setSubComponentSelected(subComponentSelected === item ? null : item);
3488
- e.keepOpen = true;
3489
- }
3490
- else {
3491
- actionClick(item).then();
3492
- e.keepOpen = true;
3493
- }
3494
- }, [actionClick, subComponentSelected]);
3495
- var selectedRowCount = selectedRows.length;
3496
- var filteredOptions = options === null || options === void 0 ? void 0 : options.filter(function (menuOption) {
3497
- return menuOption.label === PopoutMenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
3498
- });
3543
+ var onMenuItemClick = useCallback(function (e, item) { return __awaiter(void 0, void 0, void 0, function () {
3544
+ return __generator(this, function (_a) {
3545
+ switch (_a.label) {
3546
+ case 0:
3547
+ if (!item.subComponent) return [3 /*break*/, 1];
3548
+ subComponentIsValid.current = false;
3549
+ setSubSelectedValue(null);
3550
+ setSubComponentSelected(subComponentSelected === item ? null : item);
3551
+ e.keepOpen = true;
3552
+ return [3 /*break*/, 3];
3553
+ case 1: return [4 /*yield*/, actionClick(item, e.key === "Tab" ? (e.shiftKey ? CloseReason.TAB_BACKWARD : CloseReason.TAB_FORWARD) : CloseReason.CLICK).then()];
3554
+ case 2:
3555
+ _a.sent();
3556
+ _a.label = 3;
3557
+ case 3: return [2 /*return*/];
3558
+ }
3559
+ });
3560
+ }); }, [actionClick, subComponentSelected]);
3499
3561
  var save = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3500
3562
  return __generator(this, function (_a) {
3501
3563
  switch (_a.label) {
@@ -3503,19 +3565,23 @@ var GridFormPopoverMenu = function (props) {
3503
3565
  if (!(!actionProcessing.current && subComponentSelected)) return [3 /*break*/, 2];
3504
3566
  if (!subComponentIsValid.current)
3505
3567
  return [2 /*return*/, false];
3506
- return [4 /*yield*/, actionClick(subComponentSelected)];
3568
+ return [4 /*yield*/, actionClick(subComponentSelected, "click")];
3507
3569
  case 1:
3508
3570
  _a.sent();
3509
- return [2 /*return*/, false];
3571
+ return [2 /*return*/, true];
3510
3572
  case 2:
3511
3573
  // Otherwise assume it's a cancel, either way we close the menu
3512
3574
  return [2 /*return*/, true];
3513
3575
  }
3514
3576
  });
3515
3577
  }); }, [actionClick, subComponentSelected]);
3516
- var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
3517
- 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) {
3518
- 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 (_) {
3578
+ var _e = useGridPopoverHook({
3579
+ className: props.className,
3580
+ invalid: function () { return subComponentSelected && !subComponentIsValid.current; },
3581
+ save: save
3582
+ }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
3583
+ return popoverWrapper(jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormPopupMenu" }, { children: jsx(Fragment$1, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3584
+ 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, 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 (_) {
3519
3585
  return item.subComponent && (jsx(GridSubComponentContext.Provider, __assign({ value: {
3520
3586
  data: data,
3521
3587
  value: subSelectedValue,
@@ -3625,13 +3691,17 @@ styleInject(css_248z$2);
3625
3691
  var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3626
3692
  styleInject(css_248z$1);
3627
3693
 
3694
+ var FormError = function (props) {
3695
+ return (jsxs(Fragment$1, { children: [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: {
3696
+ fontSize: "0.7rem"
3697
+ } }, { children: props.helpText })))] }));
3698
+ };
3699
+
3628
3700
  var TextInputFormatted = function (props) {
3629
3701
  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) {
3630
3702
  e.currentTarget.focus();
3631
3703
  props.onMouseEnter && props.onMouseEnter(e);
3632
- } })), 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: {
3633
- fontSize: "0.7rem"
3634
- } }, { children: props.helpText })))] })));
3704
+ } })), jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), jsx(FormError, { error: props.error, helpText: props.helpText })] })));
3635
3705
  };
3636
3706
 
3637
3707
  var GridFormEditBearing = function (props) {
@@ -3667,14 +3737,14 @@ var GridFormEditBearing = function (props) {
3667
3737
  }
3668
3738
  });
3669
3739
  }); }, [defaultValue, field, props, value]);
3670
- var _c = useGridPopoverHook({
3740
+ var popoverWrapper = useGridPopoverHook({
3671
3741
  className: props.className,
3672
3742
  invalid: invalid,
3673
3743
  save: save
3674
- }), popoverWrapper = _c.popoverWrapper, onlyInputKeyboardEventHandlers = _c.onlyInputKeyboardEventHandlers;
3675
- return popoverWrapper(jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsx(TextInputFormatted, __assign({ value: defaultValue, onChange: function (e) {
3744
+ }).popoverWrapper;
3745
+ return popoverWrapper(jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsx(TextInputFormatted, { value: defaultValue, onChange: function (e) {
3676
3746
  setValue(e.target.value.trim());
3677
- }, autoFocus: true, placeholder: props.placeHolder }, onlyInputKeyboardEventHandlers, { formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range), helpText: "Press enter or tab to save" })) })));
3747
+ }, autoFocus: true, placeholder: props.placeHolder, formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range), helpText: "Press enter or tab to save" }) })));
3678
3748
  };
3679
3749
 
3680
3750
  var GridPopoverEditBearingLike = function (colDef, props) {
@@ -3819,9 +3889,7 @@ var TextAreaInput = function (props) {
3819
3889
  e.currentTarget.selectionStart = e.currentTarget.value.length;
3820
3890
  }
3821
3891
  props.onMouseEnter && props.onMouseEnter(e);
3822
- } }, { 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: {
3823
- fontSize: "0.7rem"
3824
- } }, { children: props.helpText })))] })));
3892
+ } }, { children: props.value })) }))] })), jsx(FormError, { error: props.error, helpText: props.helpText })] })));
3825
3893
  };
3826
3894
 
3827
3895
  var TextInputValidator = function (props, value, data) {
@@ -3870,19 +3938,18 @@ var GridFormTextArea = function (props) {
3870
3938
  }
3871
3939
  });
3872
3940
  }); }, [initialVale, value, props, field]);
3873
- var _e = useGridPopoverHook({
3941
+ var popoverWrapper = useGridPopoverHook({
3874
3942
  className: props.className,
3875
3943
  invalid: invalid,
3876
3944
  save: save
3877
- }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
3878
- 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 }, onlyInputKeyboardEventHandlers)) })));
3945
+ }).popoverWrapper;
3946
+ return popoverWrapper(jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsx(TextAreaInput, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText }) })));
3879
3947
  };
3880
3948
 
3881
3949
  var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
3882
3950
 
3883
3951
  var GridFormTextInput = function (props) {
3884
3952
  var _a, _b;
3885
- var stopEditing = useContext(GridContext).stopEditing;
3886
3953
  var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value, data = _c.data;
3887
3954
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3888
3955
  var initValue = useMemo(function () { return (initialVale == null ? "" : "".concat(initialVale)); }, [initialVale]);
@@ -3895,7 +3962,6 @@ var GridFormTextInput = function (props) {
3895
3962
  case 0:
3896
3963
  if (invalid())
3897
3964
  return [2 /*return*/, false];
3898
- stopEditing();
3899
3965
  trimmedValue = value.trim();
3900
3966
  if (initValue === trimmedValue)
3901
3967
  return [2 /*return*/, true];
@@ -3913,13 +3979,13 @@ var GridFormTextInput = function (props) {
3913
3979
  return [2 /*return*/, true];
3914
3980
  }
3915
3981
  });
3916
- }); }, [invalid, stopEditing, value, initValue, props, field]);
3917
- var _e = useGridPopoverHook({
3982
+ }); }, [invalid, value, initValue, props, field]);
3983
+ var popoverWrapper = useGridPopoverHook({
3918
3984
  className: props.className,
3919
3985
  invalid: invalid,
3920
3986
  save: save
3921
- }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
3922
- 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 }, onlyInputKeyboardEventHandlers, { helpText: helpText })) })));
3987
+ }).popoverWrapper;
3988
+ 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, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, style: { width: "100%" }, placeholder: props.placeholder, helpText: helpText }) })));
3923
3989
  };
3924
3990
 
3925
3991
  var GridPopoverTextInput = function (colDef, params) {
@@ -3928,7 +3994,7 @@ var GridPopoverTextInput = function (colDef, params) {
3928
3994
 
3929
3995
  var GridFormSubComponentTextInput = function (props) {
3930
3996
  var _a;
3931
- var _b = useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave, data = _b.data;
3997
+ var _b = useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, data = _b.data;
3932
3998
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3933
3999
  // If is not initialised yet as it's just been created then set the default value
3934
4000
  useEffect(function () {
@@ -3939,30 +4005,14 @@ var GridFormSubComponentTextInput = function (props) {
3939
4005
  useEffect(function () {
3940
4006
  setValid(value != null && invalid() == null);
3941
4007
  }, [setValid, invalid, value]);
3942
- return (jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true, onKeyDown: function (e) {
3943
- if (e.key === "Tab" || e.key === "Enter") {
3944
- e.preventDefault();
3945
- e.stopPropagation();
3946
- }
3947
- }, onKeyUp: function (e) {
3948
- if (e.key === "Tab") {
3949
- e.preventDefault();
3950
- e.stopPropagation();
3951
- !e.shiftKey && triggerSave().then();
3952
- }
3953
- else if (e.key === "Enter") {
3954
- triggerSave().then();
3955
- e.preventDefault();
3956
- e.stopPropagation();
3957
- }
3958
- }, placeholder: props.placeholder, style: {
4008
+ return (jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true, placeholder: props.placeholder, style: {
3959
4009
  width: "100%"
3960
4010
  } }));
3961
4011
  };
3962
4012
 
3963
4013
  var GridFormSubComponentTextArea = function (props) {
3964
4014
  var _a;
3965
- var _b = useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
4015
+ var _b = useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid;
3966
4016
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
3967
4017
  // If is not initialised yet as it's just been created then set the default value
3968
4018
  useEffect(function () {
@@ -3973,18 +4023,7 @@ var GridFormSubComponentTextArea = function (props) {
3973
4023
  useEffect(function () {
3974
4024
  setValid(value != null && invalid() == null);
3975
4025
  }, [setValid, invalid, value]);
3976
- 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) {
3977
- if (e.key === "Tab") {
3978
- e.preventDefault();
3979
- e.stopPropagation();
3980
- }
3981
- }, onKeyUp: function (e) {
3982
- if (e.key === "Tab") {
3983
- e.preventDefault();
3984
- e.stopPropagation();
3985
- !e.shiftKey && triggerSave().then();
3986
- }
3987
- } }) })));
4026
+ 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 }) })));
3988
4027
  };
3989
4028
 
3990
4029
  var css_248z = ".ActionButton{align-items:center;display:flex}.ActionButton .LuiIcon{margin:0 4px!important}.ActionButton-minimalArea{position:relative}.ActionButton-minimalAreaDisplay{position:absolute}.ActionButton-minimalAreaExpand{visibility:hidden}.ActionButton-inProgress{background-color:#e2f3f7!important;color:#007198!important;cursor:progress}.ActionButton-inProgress svg *{fill:#0000!important}";