@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
package/dist/index.js CHANGED
@@ -71,6 +71,7 @@ var subMenuClass = "submenu";
71
71
  var radioGroupClass = "radio-group";
72
72
  var Keys = Object.freeze({
73
73
  ENTER: "Enter",
74
+ TAB: "Tab",
74
75
  ESC: "Escape",
75
76
  SPACE: " ",
76
77
  HOME: "Home",
@@ -94,7 +95,9 @@ var CloseReason = Object.freeze({
94
95
  CLICK: "click",
95
96
  CANCEL: "cancel",
96
97
  BLUR: "blur",
97
- SCROLL: "scroll"
98
+ SCROLL: "scroll",
99
+ TAB_FORWARD: "tab_forward",
100
+ TAB_BACKWARD: "tab_backward"
98
101
  });
99
102
  var FocusPositions = Object.freeze({
100
103
  FIRST: "first",
@@ -1366,14 +1369,120 @@ var ControlledMenuFr = function (_a, externalRef) {
1366
1369
  ev.stopPropagation();
1367
1370
  }
1368
1371
  }, [isWithinMenu]);
1372
+ var lastTabDownEl = react.useRef();
1373
+ var lastEnterDownEl = react.useRef();
1374
+ var handleKeyboardTabAndEnter = react.useCallback(function (isDown) { return function (ev) {
1375
+ var thisDocument = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
1376
+ var activeElement = thisDocument.activeElement;
1377
+ if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) || !activeElement)
1378
+ return;
1379
+ if (ev.key !== "Tab" && ev.key !== "Enter")
1380
+ return;
1381
+ if (ev.repeat) {
1382
+ ev.preventDefault();
1383
+ ev.stopPropagation();
1384
+ return;
1385
+ }
1386
+ var inputElsIterator = thisDocument.querySelectorAll(".szh-menu--state-open input,textarea");
1387
+ var inputEls = [];
1388
+ inputElsIterator.forEach(function (el) { return inputEls.push(el); });
1389
+ inputEls = inputEls.filter(function (el) { return !el.disabled; });
1390
+ if (inputEls.length === 0)
1391
+ return;
1392
+ var firstInputEl = inputEls[0];
1393
+ var lastInputEl = inputEls[inputEls.length - 1];
1394
+ if (activeElement !== firstInputEl && activeElement !== lastInputEl)
1395
+ return;
1396
+ var suppressAutoSaveEvents = activeElement.getAttribute("data-suppressAutoSaveEvents");
1397
+ var invokeSave = function (reason) {
1398
+ var _a, _b;
1399
+ if (!(saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) || suppressAutoSaveEvents)
1400
+ return;
1401
+ (_a = saveButtonRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-reason", reason);
1402
+ (_b = saveButtonRef === null || saveButtonRef === void 0 ? void 0 : saveButtonRef.current) === null || _b === void 0 ? void 0 : _b.click();
1403
+ };
1404
+ var isTextArea = activeElement.nodeName === "TEXTAREA";
1405
+ switch (activeElement.nodeName) {
1406
+ case "TEXTAREA":
1407
+ case "INPUT": {
1408
+ if (activeElement === lastInputEl && activeElement === firstInputEl) {
1409
+ if (ev.key === "Tab") {
1410
+ // Can't forward/backwards tab out of popup
1411
+ ev.preventDefault();
1412
+ ev.stopPropagation();
1413
+ if (isDown) {
1414
+ lastTabDownEl.current = activeElement;
1415
+ }
1416
+ else {
1417
+ lastTabDownEl.current == activeElement &&
1418
+ invokeSave(ev.shiftKey ? CloseReason.TAB_BACKWARD : CloseReason.TAB_FORWARD);
1419
+ }
1420
+ }
1421
+ if (ev.key === "Enter" && !isTextArea) {
1422
+ ev.preventDefault();
1423
+ ev.stopPropagation();
1424
+ if (isDown) {
1425
+ lastEnterDownEl.current = activeElement;
1426
+ }
1427
+ else {
1428
+ lastEnterDownEl.current == activeElement && invokeSave(CloseReason.CLICK);
1429
+ }
1430
+ }
1431
+ }
1432
+ else if (activeElement === lastInputEl) {
1433
+ if (ev.key === "Tab" && !ev.shiftKey) {
1434
+ // Can't backward tab out of popup
1435
+ ev.preventDefault();
1436
+ ev.stopPropagation();
1437
+ if (isDown) {
1438
+ lastTabDownEl.current = activeElement;
1439
+ }
1440
+ else {
1441
+ lastTabDownEl.current == activeElement && invokeSave(CloseReason.TAB_FORWARD);
1442
+ }
1443
+ }
1444
+ if (ev.key === "Enter" && !isTextArea) {
1445
+ ev.preventDefault();
1446
+ ev.stopPropagation();
1447
+ if (isDown) {
1448
+ lastEnterDownEl.current = activeElement;
1449
+ }
1450
+ else {
1451
+ lastEnterDownEl.current == activeElement && invokeSave(CloseReason.CLICK);
1452
+ }
1453
+ }
1454
+ }
1455
+ else if (activeElement === firstInputEl) {
1456
+ if (ev.key === "Tab" && ev.shiftKey) {
1457
+ // Can't backward tab out of popup
1458
+ ev.preventDefault();
1459
+ ev.stopPropagation();
1460
+ if (isDown) {
1461
+ lastTabDownEl.current = activeElement;
1462
+ }
1463
+ else {
1464
+ lastTabDownEl.current == activeElement && invokeSave(CloseReason.TAB_BACKWARD);
1465
+ }
1466
+ }
1467
+ }
1468
+ break;
1469
+ }
1470
+ }
1471
+ }; }, [anchorRef, saveButtonRef]);
1472
+ var handleKeydownTabAndEnter = react.useMemo(function () { return handleKeyboardTabAndEnter(true); }, [handleKeyboardTabAndEnter]);
1473
+ var handleKeyupTabAndEnter = react.useMemo(function () { return handleKeyboardTabAndEnter(false); }, [handleKeyboardTabAndEnter]);
1369
1474
  react.useEffect(function () {
1370
1475
  if (isMenuOpen(state)) {
1371
1476
  var thisDocument_1 = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
1477
+ thisDocument_1.addEventListener("keydown", handleKeydownTabAndEnter, true);
1478
+ thisDocument_1.addEventListener("keyup", handleKeyupTabAndEnter, true);
1372
1479
  thisDocument_1.addEventListener("mousedown", handleScreenEventForSave, true);
1373
1480
  thisDocument_1.addEventListener("mouseup", handleScreenEventForCancel, true);
1374
1481
  thisDocument_1.addEventListener("click", handleScreenEventForCancel, true);
1375
1482
  thisDocument_1.addEventListener("dblclick", handleScreenEventForCancel, true);
1376
1483
  return function () {
1484
+ thisDocument_1.addEventListener("keydown", handleKeydownTabAndEnter, true);
1485
+ thisDocument_1.addEventListener("keyup", handleKeyupTabAndEnter, true);
1377
1486
  thisDocument_1.removeEventListener("mousedown", handleScreenEventForSave, true);
1378
1487
  thisDocument_1.removeEventListener("mouseup", handleScreenEventForCancel, true);
1379
1488
  thisDocument_1.removeEventListener("click", handleScreenEventForCancel, true);
@@ -1381,7 +1490,14 @@ var ControlledMenuFr = function (_a, externalRef) {
1381
1490
  };
1382
1491
  }
1383
1492
  return function () { };
1384
- }, [handleScreenEventForSave, handleScreenEventForCancel, state, anchorRef]);
1493
+ }, [
1494
+ handleScreenEventForSave,
1495
+ handleScreenEventForCancel,
1496
+ state,
1497
+ anchorRef,
1498
+ handleKeydownTabAndEnter,
1499
+ handleKeyupTabAndEnter,
1500
+ ]);
1385
1501
  var itemSettings = react.useMemo(function () { return ({
1386
1502
  submenuOpenDelay: submenuOpenDelay,
1387
1503
  submenuCloseDelay: submenuCloseDelay
@@ -1401,7 +1517,12 @@ var ControlledMenuFr = function (_a, externalRef) {
1401
1517
  safeCall(onClose, {
1402
1518
  value: event.value,
1403
1519
  key: event.key,
1404
- reason: CloseReason.CLICK
1520
+ shiftKey: event.shiftKey,
1521
+ reason: event.key === "Tab"
1522
+ ? event.shiftKey
1523
+ ? CloseReason.TAB_BACKWARD
1524
+ : CloseReason.TAB_FORWARD
1525
+ : CloseReason.CLICK
1405
1526
  });
1406
1527
  }
1407
1528
  },
@@ -1676,8 +1797,11 @@ var MenuItemFr = function (_a) {
1676
1797
  value: value,
1677
1798
  syntheticEvent: e
1678
1799
  };
1679
- if (e.key !== undefined)
1680
- event.key = e.key;
1800
+ if (e.key !== undefined) {
1801
+ var ke = e;
1802
+ event.key = ke.key;
1803
+ event.shiftKey = ke.shiftKey;
1804
+ }
1681
1805
  if (isCheckBox)
1682
1806
  event.checked = !isChecked;
1683
1807
  if (isRadio)
@@ -1687,6 +1811,13 @@ var MenuItemFr = function (_a) {
1687
1811
  safeCall(radioGroup.onRadioChange, event);
1688
1812
  eventHandlers.handleClick(event, isCheckBox || isRadio);
1689
1813
  };
1814
+ var handleKeyDown = function (e) {
1815
+ // if tab is allowed the handleKeyUp event can't process the tab
1816
+ if (e.key === "Tab") {
1817
+ e.preventDefault();
1818
+ e.stopPropagation();
1819
+ }
1820
+ };
1690
1821
  /**
1691
1822
  * Keyboard events are triggered on up, otherwise sub-components get spaces and enters typed in them
1692
1823
  */
@@ -1695,7 +1826,10 @@ var MenuItemFr = function (_a) {
1695
1826
  return;
1696
1827
  switch (e.key) {
1697
1828
  case Keys.ENTER:
1829
+ case Keys.TAB:
1698
1830
  case Keys.SPACE:
1831
+ e.preventDefault();
1832
+ e.stopPropagation();
1699
1833
  if (isAnchor) {
1700
1834
  (menuItemRef === null || menuItemRef === void 0 ? void 0 : menuItemRef.current) && menuItemRef.current.click();
1701
1835
  }
@@ -1712,7 +1846,7 @@ var MenuItemFr = function (_a) {
1712
1846
  checked: isChecked,
1713
1847
  anchor: isAnchor
1714
1848
  }); }, [type, isDisabled, isHovering, isChecked, isAnchor]);
1715
- var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
1849
+ var mergedProps = mergeProps(__assign(__assign({}, restStateProps), { onPointerDown: setHover, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onClick: handleClick }), restProps);
1716
1850
  // Order of props overriding (same in all components):
1717
1851
  // 1. Preset props adhering to WAI-ARIA Authoring Practices.
1718
1852
  // 2. Merged outer and local props
@@ -1857,6 +1991,9 @@ var GridContext = react.createContext({
1857
1991
  }); },
1858
1992
  redrawRows: function () {
1859
1993
  console.error("no context provider for redrawRows");
1994
+ },
1995
+ selectNextCell: function () {
1996
+ console.error("no context provider for selectNextCell");
1860
1997
  }
1861
1998
  });
1862
1999
 
@@ -1870,7 +2007,8 @@ var GridUpdatingContext = react.createContext({
1870
2007
  console.error("Missing GridUpdatingContext");
1871
2008
  return [2 /*return*/];
1872
2009
  });
1873
- }); }
2010
+ }); },
2011
+ updatedDep: 0
1874
2012
  });
1875
2013
 
1876
2014
  /**
@@ -2130,6 +2268,15 @@ var GridContextProvider = function (props) {
2130
2268
  gridApi.redrawRows(rowNodes ? { rowNodes: rowNodes } : undefined);
2131
2269
  });
2132
2270
  };
2271
+ var selectNextCell = function (tabDirection) {
2272
+ if (tabDirection === void 0) { tabDirection = 0; }
2273
+ gridApiOp(function (gridApi) {
2274
+ if (tabDirection == 1)
2275
+ gridApi.tabToNextCell();
2276
+ if (tabDirection == -1)
2277
+ gridApi.tabToPreviousCell();
2278
+ });
2279
+ };
2133
2280
  return (jsxRuntime.jsx(GridContext.Provider, __assign({ value: {
2134
2281
  gridReady: gridReady,
2135
2282
  setGridApi: setGridApi,
@@ -2148,34 +2295,42 @@ var GridContextProvider = function (props) {
2148
2295
  sizeColumnsToFit: sizeColumnsToFit,
2149
2296
  stopEditing: stopEditing,
2150
2297
  updatingCells: updatingCells,
2151
- redrawRows: redrawRows
2298
+ redrawRows: redrawRows,
2299
+ selectNextCell: selectNextCell
2152
2300
  } }, { children: props.children })));
2153
2301
  };
2154
2302
 
2155
2303
  var GridUpdatingContextProvider = function (props) {
2156
2304
  var updatingBlocks = react.useRef({});
2157
2305
  var updating = react.useRef({});
2306
+ var _a = react.useState(0), updatedDep = _a[0], setUpdatedDep = _a[1];
2158
2307
  var resetUpdating = function () {
2159
2308
  var mergedUpdatingBlocks = {};
2160
2309
  for (var key in updatingBlocks.current) {
2161
2310
  mergedUpdatingBlocks[key] = lodashEs.flatten(updatingBlocks.current[key]);
2162
2311
  }
2163
2312
  updating.current = mergedUpdatingBlocks;
2313
+ setUpdatedDep(function (updatedDep) { return updatedDep + 1; });
2164
2314
  };
2165
- var modifyUpdating = function (field, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
2166
- var fieldUpdatingIds, idRef;
2167
- var _a;
2168
- return __generator(this, function (_b) {
2169
- switch (_b.label) {
2315
+ var modifyUpdating = function (fields, ids, fn) { return __awaiter(void 0, void 0, void 0, function () {
2316
+ var idRef;
2317
+ return __generator(this, function (_a) {
2318
+ switch (_a.label) {
2170
2319
  case 0:
2171
- fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2172
2320
  idRef = __spreadArray([], ids, true);
2173
- fieldUpdatingIds.push(idRef);
2321
+ lodashEs.castArray(fields).forEach(function (field) {
2322
+ var _a;
2323
+ var fieldUpdatingIds = (_a = updatingBlocks.current[field]) !== null && _a !== void 0 ? _a : (updatingBlocks.current[field] = []);
2324
+ fieldUpdatingIds.push(idRef);
2325
+ });
2174
2326
  resetUpdating();
2175
2327
  return [4 /*yield*/, fn()];
2176
2328
  case 1:
2177
- _b.sent();
2178
- lodashEs.remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2329
+ _a.sent();
2330
+ lodashEs.castArray(fields).forEach(function (field) {
2331
+ var fieldUpdatingIds = updatingBlocks.current[field];
2332
+ lodashEs.remove(fieldUpdatingIds, function (idList) { return idList === idRef; });
2333
+ });
2179
2334
  resetUpdating();
2180
2335
  return [2 /*return*/];
2181
2336
  }
@@ -2184,7 +2339,7 @@ var GridUpdatingContextProvider = function (props) {
2184
2339
  var checkUpdating = function (fields, id) {
2185
2340
  return lodashEs.castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
2186
2341
  };
2187
- return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
2342
+ return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating, updatedDep: updatedDep } }, { children: props.children })));
2188
2343
  };
2189
2344
 
2190
2345
  var GridPopoverContext = react.createContext({
@@ -2206,7 +2361,7 @@ var useGridPopoverContext = function () {
2206
2361
  var GridPopoverContextProvider = function (_a) {
2207
2362
  var _b, _c, _d;
2208
2363
  var props = _a.props, children = _a.children;
2209
- var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing;
2364
+ var _e = react.useContext(GridContext), getSelectedRows = _e.getSelectedRows, updatingCells = _e.updatingCells, stopEditing = _e.stopEditing, selectNextCell = _e.selectNextCell;
2210
2365
  var anchorRef = react.useRef(props.eGridCell);
2211
2366
  var _f = react.useState(false), saving = _f[0], setSaving = _f[1];
2212
2367
  var colDef = props.colDef;
@@ -2215,7 +2370,7 @@ var GridPopoverContextProvider = function (_a) {
2215
2370
  // Then item that is clicked on will always be first in the list
2216
2371
  var selectedRows = react.useMemo(function () { return (multiEdit ? lodashEs.sortBy(getSelectedRows(), function (row) { return row.id !== props.data.id; }) : [props.data]); }, [getSelectedRows, multiEdit, props.data]);
2217
2372
  var field = (_d = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.field) !== null && _d !== void 0 ? _d : "";
2218
- var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () {
2373
+ var updateValue = react.useCallback(function (saveFn, tabDirection) { return __awaiter(void 0, void 0, void 0, function () {
2219
2374
  var result;
2220
2375
  return __generator(this, function (_a) {
2221
2376
  switch (_a.label) {
@@ -2225,13 +2380,15 @@ var GridPopoverContextProvider = function (_a) {
2225
2380
  return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2226
2381
  case 1:
2227
2382
  result = _a.sent();
2228
- if (result)
2383
+ if (result) {
2229
2384
  stopEditing();
2385
+ tabDirection && selectNextCell(tabDirection);
2386
+ }
2230
2387
  _a.label = 2;
2231
2388
  case 2: return [2 /*return*/, result];
2232
2389
  }
2233
2390
  });
2234
- }); }, [field, saving, selectedRows, stopEditing, updatingCells]);
2391
+ }); }, [field, saving, selectNextCell, selectedRows, stopEditing, updatingCells]);
2235
2392
  return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
2236
2393
  anchorRef: anchorRef,
2237
2394
  saving: saving,
@@ -2261,43 +2418,7 @@ var GridSubComponentContext = react.createContext({
2261
2418
  }); }
2262
2419
  });
2263
2420
 
2264
- function toVal(mix) {
2265
- var k, y, str='';
2266
- if (mix) {
2267
- if (typeof mix === 'object') {
2268
- if (Array.isArray(mix)) {
2269
- for (k=0; k < mix.length; k++) {
2270
- if (mix[k] && (y = toVal(mix[k]))) {
2271
- str && (str += ' ');
2272
- str += y;
2273
- }
2274
- }
2275
- } else {
2276
- for (k in mix) {
2277
- if (mix[k] && (y = toVal(k))) {
2278
- str && (str += ' ');
2279
- str += y;
2280
- }
2281
- }
2282
- }
2283
- } else if (typeof mix !== 'boolean' && !mix.call) {
2284
- str && (str += ' ');
2285
- str += mix;
2286
- }
2287
- }
2288
- return str;
2289
- }
2290
-
2291
- function clsx () {
2292
- var i=0, x, str='';
2293
- while (i < arguments.length) {
2294
- if (x = toVal(arguments[i++])) {
2295
- str && (str += ' ');
2296
- str += x;
2297
- }
2298
- }
2299
- return str;
2300
- }
2421
+ 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}
2301
2422
 
2302
2423
  /**
2303
2424
  * Retains last sort order from via <AgGrid postRowSort>.
@@ -2814,7 +2935,7 @@ var useGridPopoverHook = function (props) {
2814
2935
  // forms that don't provide an invalid fn must wait until they have saved to close
2815
2936
  if (props.invalid)
2816
2937
  stopEditing();
2817
- return [4 /*yield*/, updateValue(props.save)];
2938
+ return [4 /*yield*/, updateValue(props.save, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
2818
2939
  case 2:
2819
2940
  if (_a.sent()) {
2820
2941
  if (!props.invalid)
@@ -2825,72 +2946,6 @@ var useGridPopoverHook = function (props) {
2825
2946
  }
2826
2947
  });
2827
2948
  }); }, [props, stopEditing, updateValue]);
2828
- var onlyInputKeyboardEventHandlers = {
2829
- onKeyUp: function (e) {
2830
- var isTextArea = e.currentTarget.type === "textarea";
2831
- if (e.key === "Enter" && !isTextArea) {
2832
- e.preventDefault();
2833
- e.stopPropagation();
2834
- triggerSave().then();
2835
- }
2836
- else if (e.key === "Tab") {
2837
- e.preventDefault();
2838
- e.stopPropagation();
2839
- }
2840
- },
2841
- onKeyDown: function (e) {
2842
- var isTextArea = e.currentTarget.type === "textarea";
2843
- if (e.key === "Enter" && !isTextArea) {
2844
- e.preventDefault();
2845
- e.stopPropagation();
2846
- }
2847
- else if (e.key === "Tab") {
2848
- e.preventDefault();
2849
- e.stopPropagation();
2850
- !e.shiftKey && triggerSave().then();
2851
- }
2852
- }
2853
- };
2854
- var firstInputKeyboardEventHandlers = {
2855
- onKeyUp: function (e) {
2856
- if (e.key === "Tab" && e.shiftKey) {
2857
- e.preventDefault();
2858
- e.stopPropagation();
2859
- }
2860
- },
2861
- onKeyDown: function (e) {
2862
- if (e.key === "Tab" && e.shiftKey) {
2863
- e.preventDefault();
2864
- e.stopPropagation();
2865
- }
2866
- }
2867
- };
2868
- var lastInputKeyboardEventHandlers = {
2869
- onKeyUp: function (e) {
2870
- var isTextArea = e.currentTarget.type === "textarea";
2871
- if (e.key === "Enter" && !isTextArea) {
2872
- e.preventDefault();
2873
- e.stopPropagation();
2874
- triggerSave().then();
2875
- }
2876
- else if (e.key === "Tab" && !e.shiftKey) {
2877
- e.preventDefault();
2878
- e.stopPropagation();
2879
- }
2880
- },
2881
- onKeyDown: function (e) {
2882
- var isTextArea = e.currentTarget.type === "textarea";
2883
- if (e.key === "Enter" && !isTextArea) {
2884
- e.preventDefault();
2885
- e.stopPropagation();
2886
- }
2887
- else if (e.key === "Tab" && !e.shiftKey) {
2888
- e.preventDefault();
2889
- e.stopPropagation();
2890
- triggerSave().then();
2891
- }
2892
- }
2893
- };
2894
2949
  var popoverWrapper = react.useCallback(function (children) {
2895
2950
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: anchorRef.current && (jsxRuntime.jsxs(ControlledMenu, __assign({ state: isOpen ? "open" : "closed", portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: "step-ag-grid-react-menu", onClose: function (event) {
2896
2951
  // Prevent menu from closing when modals are invoked
@@ -2906,16 +2961,14 @@ var useGridPopoverHook = function (props) {
2906
2961
  right: 0,
2907
2962
  backgroundColor: "rgba(64,64,64,0.1)",
2908
2963
  zIndex: 1000
2909
- } })), children, jsxRuntime.jsx("button", { ref: saveButtonRef, onClick: function () {
2910
- triggerSave().then();
2964
+ } })), children, jsxRuntime.jsx("button", { ref: saveButtonRef, "data-reason": "", onClick: function (e) {
2965
+ var _a;
2966
+ triggerSave((_a = e.currentTarget.getAttribute("data-reason")) !== null && _a !== void 0 ? _a : undefined).then();
2911
2967
  }, style: { display: "none" } })] }))) }));
2912
2968
  }, [anchorRef, isOpen, props.className, saving, triggerSave]);
2913
2969
  return {
2914
2970
  popoverWrapper: popoverWrapper,
2915
- triggerSave: triggerSave,
2916
- onlyInputKeyboardEventHandlers: onlyInputKeyboardEventHandlers,
2917
- firstInputKeyboardEventHandlers: firstInputKeyboardEventHandlers,
2918
- lastInputKeyboardEventHandlers: lastInputKeyboardEventHandlers
2971
+ triggerSave: triggerSave
2919
2972
  };
2920
2973
  };
2921
2974
 
@@ -2941,7 +2994,7 @@ var GridRenderPopoutMenuCell = function (props) {
2941
2994
  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}";
2942
2995
  styleInject(css_248z$5);
2943
2996
 
2944
- 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}";
2997
+ 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}";
2945
2998
  styleInject(css_248z$4);
2946
2999
 
2947
3000
  /* global setTimeout, clearTimeout */
@@ -3026,7 +3079,6 @@ var fieldToString = function (field) {
3026
3079
  };
3027
3080
  var GridFormDropDown = function (props) {
3028
3081
  var _a = useGridPopoverContext(), selectedRows = _a.selectedRows, field = _a.field, updateValue = _a.updateValue, data = _a.data;
3029
- var stopEditing = react.useContext(GridContext).stopEditing;
3030
3082
  // Save triggers during async action processing which triggers another selectItem(), this ref blocks that
3031
3083
  var hasSubmitted = react.useRef(false);
3032
3084
  var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
@@ -3036,7 +3088,7 @@ var GridFormDropDown = function (props) {
3036
3088
  var subComponentIsValid = react.useRef(false);
3037
3089
  var _e = react.useState(), subSelectedValue = _e[0], setSubSelectedValue = _e[1];
3038
3090
  var _f = react.useState(null), selectedSubComponent = _f[0], setSelectedSubComponent = _f[1];
3039
- var selectItemHandler = react.useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
3091
+ var selectItemHandler = react.useCallback(function (value, subComponentValue, reason) { return __awaiter(void 0, void 0, void 0, function () {
3040
3092
  return __generator(this, function (_a) {
3041
3093
  if (hasSubmitted.current || (subComponentValue !== undefined && !subComponentIsValid.current))
3042
3094
  return [2 /*return*/, false];
@@ -3059,7 +3111,7 @@ var GridFormDropDown = function (props) {
3059
3111
  case 3: return [2 /*return*/, true];
3060
3112
  }
3061
3113
  });
3062
- }); })];
3114
+ }); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
3063
3115
  });
3064
3116
  }); }, [field, props, updateValue]);
3065
3117
  var selectFilterHandler = react.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
@@ -3079,7 +3131,7 @@ var GridFormDropDown = function (props) {
3079
3131
  return [2 /*return*/, true];
3080
3132
  }
3081
3133
  });
3082
- }); })];
3134
+ }); }, 0)];
3083
3135
  });
3084
3136
  }); }, [props, updateValue]);
3085
3137
  // Load up options list if it's async function
@@ -3153,52 +3205,48 @@ var GridFormDropDown = function (props) {
3153
3205
  researchOnFilterChange().then();
3154
3206
  }
3155
3207
  }, [filter, props, researchOnFilterChange]);
3156
- var onFilterKeyDown = react.useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
3208
+ var save = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3157
3209
  var activeOptions;
3158
3210
  return __generator(this, function (_a) {
3159
3211
  switch (_a.label) {
3160
3212
  case 0:
3161
3213
  if (!options)
3162
- return [2 /*return*/];
3163
- if (!(e.key == "Enter" || e.key == "Tab")) return [3 /*break*/, 5];
3214
+ return [2 /*return*/, true];
3164
3215
  activeOptions = options.filter(function (option) { return !filteredValues.includes(option.value); });
3165
- if (!(activeOptions.length == 1)) return [3 /*break*/, 2];
3216
+ if (!(activeOptions.length === 1)) return [3 /*break*/, 2];
3166
3217
  return [4 /*yield*/, selectItemHandler(activeOptions[0].value)];
3167
3218
  case 1:
3168
3219
  _a.sent();
3169
- stopEditing();
3170
- return [3 /*break*/, 5];
3220
+ return [3 /*break*/, 6];
3171
3221
  case 2:
3172
- if (!props.onSelectFilter) return [3 /*break*/, 4];
3222
+ if (!(activeOptions.length === 0 && props.onSelectFilter)) return [3 /*break*/, 4];
3173
3223
  return [4 /*yield*/, selectFilterHandler(filter)];
3174
3224
  case 3:
3175
3225
  _a.sent();
3176
- stopEditing();
3177
- return [3 /*break*/, 5];
3226
+ return [3 /*break*/, 6];
3178
3227
  case 4:
3179
- e.preventDefault();
3180
- e.stopPropagation();
3181
- _a.label = 5;
3182
- case 5: return [2 /*return*/];
3183
- }
3184
- });
3185
- }); }, [filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, props]);
3186
- var save = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3187
- return __generator(this, function (_a) {
3188
- switch (_a.label) {
3189
- case 0:
3190
3228
  // Handler for sub-selected value
3191
3229
  if (!selectedSubComponent)
3192
3230
  return [2 /*return*/, true];
3193
3231
  if (selectedSubComponent.subComponent && !subComponentIsValid.current)
3194
3232
  return [2 /*return*/, false];
3195
3233
  return [4 /*yield*/, selectItemHandler(selectedSubComponent.value, subSelectedValue)];
3196
- case 1:
3234
+ case 5:
3197
3235
  _a.sent();
3198
- return [2 /*return*/, true];
3236
+ _a.label = 6;
3237
+ case 6: return [2 /*return*/, true];
3199
3238
  }
3200
3239
  });
3201
- }); }, [selectItemHandler, selectedSubComponent, subSelectedValue]);
3240
+ }); }, [
3241
+ filter,
3242
+ filteredValues,
3243
+ options,
3244
+ props.onSelectFilter,
3245
+ selectFilterHandler,
3246
+ selectItemHandler,
3247
+ selectedSubComponent,
3248
+ subSelectedValue,
3249
+ ]);
3202
3250
  var popoverWrapper = useGridPopoverHook({
3203
3251
  className: props.className,
3204
3252
  invalid: function () { return !!(selectedSubComponent && !subComponentIsValid.current); },
@@ -3207,7 +3255,7 @@ var GridFormDropDown = function (props) {
3207
3255
  return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs("div", __assign({ className: "GridFormDropDown-filter" }, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3208
3256
  var _b;
3209
3257
  var ref = _a.ref;
3210
- return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsxRuntime.jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));
3258
+ return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsxRuntime.jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); } }) })));
3211
3259
  } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] }))), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && (jsxRuntime.jsx(MenuItem, { children: "[Empty]" }, "".concat(fieldToString(field), "-empty"))), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3212
3260
  var _a;
3213
3261
  return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label }, "$$header_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function (e) {
@@ -3224,7 +3272,11 @@ var GridFormDropDown = function (props) {
3224
3272
  e.keepOpen = true;
3225
3273
  }
3226
3274
  else {
3227
- selectItemHandler(item.value).then();
3275
+ selectItemHandler(item.value, undefined, e.key === "Tab"
3276
+ ? e.shiftKey
3277
+ ? CloseReason.TAB_BACKWARD
3278
+ : CloseReason.TAB_FORWARD
3279
+ : CloseReason.CLICK).then();
3228
3280
  }
3229
3281
  } }, { 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 && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) { return (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
3230
3282
  data: data,
@@ -3258,6 +3310,10 @@ var GridFormMultiSelect = function (props) {
3258
3310
  var _d = react.useState([]), filteredValues = _d[0], setFilteredValues = _d[1];
3259
3311
  var optionsInitialising = react.useRef(false);
3260
3312
  var _e = react.useState(), options = _e[0], setOptions = _e[1];
3313
+ var invalid = react.useCallback(function () {
3314
+ var validations = lodashEs.pick(subComponentIsValid.current, Object.keys(selectedValues));
3315
+ return Object.values(validations).some(function (v) { return !v; });
3316
+ }, [selectedValues]);
3261
3317
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3262
3318
  var validations, notValid, menuOptionSubValueResult;
3263
3319
  return __generator(this, function (_a) {
@@ -3351,8 +3407,9 @@ var GridFormMultiSelect = function (props) {
3351
3407
  }, [selectedValues]);
3352
3408
  var _f = useGridPopoverHook({
3353
3409
  className: props.className,
3410
+ invalid: invalid,
3354
3411
  save: save
3355
- }), popoverWrapper = _f.popoverWrapper, lastInputKeyboardEventHandlers = _f.lastInputKeyboardEventHandlers, triggerSave = _f.triggerSave;
3412
+ }), popoverWrapper = _f.popoverWrapper, triggerSave = _f.triggerSave;
3356
3413
  return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormMultiSelect-container" }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && props.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3357
3414
  var _b;
3358
3415
  var ref = _a.ref;
@@ -3360,9 +3417,12 @@ var GridFormMultiSelect = function (props) {
3360
3417
  } }), "filter"), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), jsxRuntime.jsx("div", __assign({ className: "GridFormMultiSelect-options" }, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3361
3418
  var _a;
3362
3419
  return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) {
3363
- e.keepOpen = true;
3364
- toggleValue(item);
3365
- } }, lastInputKeyboardEventHandlers, { children: jsxRuntime.jsx(lui.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: {
3420
+ // Global react-menu MenuItem handler handles tabs
3421
+ if (e.key !== "Tab") {
3422
+ e.keepOpen = true;
3423
+ toggleValue(item);
3424
+ }
3425
+ } }, { children: jsxRuntime.jsx(lui.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: {
3366
3426
  onClick: function (e) {
3367
3427
  e.preventDefault();
3368
3428
  e.stopPropagation();
@@ -3462,7 +3522,7 @@ var GridFormPopoverMenu = function (props) {
3462
3522
  });
3463
3523
  }); })();
3464
3524
  }, [options, props.defaultAction, props.options, selectedRows]);
3465
- var actionClick = react.useCallback(function (menuOption) { return __awaiter(void 0, void 0, void 0, function () {
3525
+ var actionClick = react.useCallback(function (menuOption, reason) { return __awaiter(void 0, void 0, void 0, function () {
3466
3526
  return __generator(this, function (_a) {
3467
3527
  actionProcessing.current = true;
3468
3528
  return [2 /*return*/, updateValue(function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -3479,25 +3539,27 @@ var GridFormPopoverMenu = function (props) {
3479
3539
  return [2 /*return*/, true];
3480
3540
  }
3481
3541
  });
3482
- }); })];
3542
+ }); }, reason === CloseReason.TAB_FORWARD ? 1 : reason === CloseReason.TAB_BACKWARD ? -1 : 0)];
3483
3543
  });
3484
3544
  }); }, [defaultAction, selectedRows, subSelectedValue, updateValue]);
3485
- var onMenuItemClick = react.useCallback(function (e, item) {
3486
- if (item.subComponent) {
3487
- subComponentIsValid.current = false;
3488
- setSubSelectedValue(null);
3489
- setSubComponentSelected(subComponentSelected === item ? null : item);
3490
- e.keepOpen = true;
3491
- }
3492
- else {
3493
- actionClick(item).then();
3494
- e.keepOpen = true;
3495
- }
3496
- }, [actionClick, subComponentSelected]);
3497
- var selectedRowCount = selectedRows.length;
3498
- var filteredOptions = options === null || options === void 0 ? void 0 : options.filter(function (menuOption) {
3499
- return menuOption.label === PopoutMenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
3500
- });
3545
+ var onMenuItemClick = react.useCallback(function (e, item) { return __awaiter(void 0, void 0, void 0, function () {
3546
+ return __generator(this, function (_a) {
3547
+ switch (_a.label) {
3548
+ case 0:
3549
+ if (!item.subComponent) return [3 /*break*/, 1];
3550
+ subComponentIsValid.current = false;
3551
+ setSubSelectedValue(null);
3552
+ setSubComponentSelected(subComponentSelected === item ? null : item);
3553
+ e.keepOpen = true;
3554
+ return [3 /*break*/, 3];
3555
+ case 1: return [4 /*yield*/, actionClick(item, e.key === "Tab" ? (e.shiftKey ? CloseReason.TAB_BACKWARD : CloseReason.TAB_FORWARD) : CloseReason.CLICK).then()];
3556
+ case 2:
3557
+ _a.sent();
3558
+ _a.label = 3;
3559
+ case 3: return [2 /*return*/];
3560
+ }
3561
+ });
3562
+ }); }, [actionClick, subComponentSelected]);
3501
3563
  var save = react.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
3502
3564
  return __generator(this, function (_a) {
3503
3565
  switch (_a.label) {
@@ -3505,19 +3567,23 @@ var GridFormPopoverMenu = function (props) {
3505
3567
  if (!(!actionProcessing.current && subComponentSelected)) return [3 /*break*/, 2];
3506
3568
  if (!subComponentIsValid.current)
3507
3569
  return [2 /*return*/, false];
3508
- return [4 /*yield*/, actionClick(subComponentSelected)];
3570
+ return [4 /*yield*/, actionClick(subComponentSelected, "click")];
3509
3571
  case 1:
3510
3572
  _a.sent();
3511
- return [2 /*return*/, false];
3573
+ return [2 /*return*/, true];
3512
3574
  case 2:
3513
3575
  // Otherwise assume it's a cancel, either way we close the menu
3514
3576
  return [2 /*return*/, true];
3515
3577
  }
3516
3578
  });
3517
3579
  }); }, [actionClick, subComponentSelected]);
3518
- var _e = useGridPopoverHook({ className: props.className, save: save }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
3519
- return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !filteredOptions, className: "GridFormPopupMenu" }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3520
- return item.label === PopoutMenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) { return onMenuItemClick(e, item); }, disabled: !!item.disabled || !(filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.includes(item)), title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "" }, { children: item.label }), "".concat(item.label)), item.subComponent && subComponentSelected === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
3580
+ var _e = useGridPopoverHook({
3581
+ className: props.className,
3582
+ invalid: function () { return subComponentSelected && !subComponentIsValid.current; },
3583
+ save: save
3584
+ }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
3585
+ return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormPopupMenu" }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3586
+ return item.label === PopoutMenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) { return onMenuItemClick(e, item); }, disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "" }, { children: item.label }), "".concat(item.label)), item.subComponent && subComponentSelected === item && (jsxRuntime.jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
3521
3587
  return item.subComponent && (jsxRuntime.jsx(GridSubComponentContext.Provider, __assign({ value: {
3522
3588
  data: data,
3523
3589
  value: subSelectedValue,
@@ -3627,13 +3693,17 @@ styleInject(css_248z$2);
3627
3693
  var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3628
3694
  styleInject(css_248z$1);
3629
3695
 
3696
+ var FormError = function (props) {
3697
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.error && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-error" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.helpText && !props.error && (jsxRuntime.jsx("span", __assign({ style: {
3698
+ fontSize: "0.7rem"
3699
+ } }, { children: props.helpText })))] }));
3700
+ };
3701
+
3630
3702
  var TextInputFormatted = function (props) {
3631
3703
  return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.className) }, { children: [jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsxRuntime.jsx("input", __assign({ type: "text", spellCheck: true, defaultValue: props.value }, lodashEs.omit(props, ["error", "value", "helpText", "formatted", "className"]), { className: "LuiTextInput-input", onMouseEnter: function (e) {
3632
3704
  e.currentTarget.focus();
3633
3705
  props.onMouseEnter && props.onMouseEnter(e);
3634
- } })), jsxRuntime.jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), props.error && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-error" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.helpText && !props.error && (jsxRuntime.jsx("span", __assign({ style: {
3635
- fontSize: "0.7rem"
3636
- } }, { children: props.helpText })))] })));
3706
+ } })), jsxRuntime.jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), jsxRuntime.jsx(FormError, { error: props.error, helpText: props.helpText })] })));
3637
3707
  };
3638
3708
 
3639
3709
  var GridFormEditBearing = function (props) {
@@ -3669,14 +3739,14 @@ var GridFormEditBearing = function (props) {
3669
3739
  }
3670
3740
  });
3671
3741
  }); }, [defaultValue, field, props, value]);
3672
- var _c = useGridPopoverHook({
3742
+ var popoverWrapper = useGridPopoverHook({
3673
3743
  className: props.className,
3674
3744
  invalid: invalid,
3675
3745
  save: save
3676
- }), popoverWrapper = _c.popoverWrapper, onlyInputKeyboardEventHandlers = _c.onlyInputKeyboardEventHandlers;
3677
- return popoverWrapper(jsxRuntime.jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsxRuntime.jsx(TextInputFormatted, __assign({ value: defaultValue, onChange: function (e) {
3746
+ }).popoverWrapper;
3747
+ return popoverWrapper(jsxRuntime.jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: defaultValue, onChange: function (e) {
3678
3748
  setValue(e.target.value.trim());
3679
- }, 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" })) })));
3749
+ }, 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" }) })));
3680
3750
  };
3681
3751
 
3682
3752
  var GridPopoverEditBearingLike = function (colDef, props) {
@@ -3821,9 +3891,7 @@ var TextAreaInput = function (props) {
3821
3891
  e.currentTarget.selectionStart = e.currentTarget.value.length;
3822
3892
  }
3823
3893
  props.onMouseEnter && props.onMouseEnter(e);
3824
- } }, { children: props.value })) }))] })), props.error && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextAreaInput-error" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextAreaInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.helpText && !props.error && (jsxRuntime.jsx("span", __assign({ style: {
3825
- fontSize: "0.7rem"
3826
- } }, { children: props.helpText })))] })));
3894
+ } }, { children: props.value })) }))] })), jsxRuntime.jsx(FormError, { error: props.error, helpText: props.helpText })] })));
3827
3895
  };
3828
3896
 
3829
3897
  var TextInputValidator = function (props, value, data) {
@@ -3872,19 +3940,18 @@ var GridFormTextArea = function (props) {
3872
3940
  }
3873
3941
  });
3874
3942
  }); }, [initialVale, value, props, field]);
3875
- var _e = useGridPopoverHook({
3943
+ var popoverWrapper = useGridPopoverHook({
3876
3944
  className: props.className,
3877
3945
  invalid: invalid,
3878
3946
  save: save
3879
- }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
3880
- return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsxRuntime.jsx(TextAreaInput, __assign({ value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText }, onlyInputKeyboardEventHandlers)) })));
3947
+ }).popoverWrapper;
3948
+ return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 } }, { children: jsxRuntime.jsx(TextAreaInput, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), placeholder: props.placeholder, helpText: helpText }) })));
3881
3949
  };
3882
3950
 
3883
3951
  var GridPopoverTextArea = function (colDef, params) { return GridCell(colDef, __assign({ editor: GridFormTextArea }, params)); };
3884
3952
 
3885
3953
  var GridFormTextInput = function (props) {
3886
3954
  var _a, _b;
3887
- var stopEditing = react.useContext(GridContext).stopEditing;
3888
3955
  var _c = useGridPopoverContext(), field = _c.field, initialVale = _c.value, data = _c.data;
3889
3956
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3890
3957
  var initValue = react.useMemo(function () { return (initialVale == null ? "" : "".concat(initialVale)); }, [initialVale]);
@@ -3897,7 +3964,6 @@ var GridFormTextInput = function (props) {
3897
3964
  case 0:
3898
3965
  if (invalid())
3899
3966
  return [2 /*return*/, false];
3900
- stopEditing();
3901
3967
  trimmedValue = value.trim();
3902
3968
  if (initValue === trimmedValue)
3903
3969
  return [2 /*return*/, true];
@@ -3915,13 +3981,13 @@ var GridFormTextInput = function (props) {
3915
3981
  return [2 /*return*/, true];
3916
3982
  }
3917
3983
  });
3918
- }); }, [invalid, stopEditing, value, initValue, props, field]);
3919
- var _e = useGridPopoverHook({
3984
+ }); }, [invalid, value, initValue, props, field]);
3985
+ var popoverWrapper = useGridPopoverHook({
3920
3986
  className: props.className,
3921
3987
  invalid: invalid,
3922
3988
  save: save
3923
- }), popoverWrapper = _e.popoverWrapper, onlyInputKeyboardEventHandlers = _e.onlyInputKeyboardEventHandlers;
3924
- return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsxRuntime.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 })) })));
3989
+ }).popoverWrapper;
3990
+ return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = props.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsxRuntime.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 }) })));
3925
3991
  };
3926
3992
 
3927
3993
  var GridPopoverTextInput = function (colDef, params) {
@@ -3930,7 +3996,7 @@ var GridPopoverTextInput = function (colDef, params) {
3930
3996
 
3931
3997
  var GridFormSubComponentTextInput = function (props) {
3932
3998
  var _a;
3933
- var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave, data = _b.data;
3999
+ var _b = react.useContext(GridSubComponentContext), value = _b.value, setValue = _b.setValue, setValid = _b.setValid, data = _b.data;
3934
4000
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press enter or tab to save";
3935
4001
  // If is not initialised yet as it's just been created then set the default value
3936
4002
  react.useEffect(function () {
@@ -3941,30 +4007,14 @@ var GridFormSubComponentTextInput = function (props) {
3941
4007
  react.useEffect(function () {
3942
4008
  setValid(value != null && invalid() == null);
3943
4009
  }, [setValid, invalid, value]);
3944
- return (jsxRuntime.jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true, onKeyDown: function (e) {
3945
- if (e.key === "Tab" || e.key === "Enter") {
3946
- e.preventDefault();
3947
- e.stopPropagation();
3948
- }
3949
- }, onKeyUp: function (e) {
3950
- if (e.key === "Tab") {
3951
- e.preventDefault();
3952
- e.stopPropagation();
3953
- !e.shiftKey && triggerSave().then();
3954
- }
3955
- else if (e.key === "Enter") {
3956
- triggerSave().then();
3957
- e.preventDefault();
3958
- e.stopPropagation();
3959
- }
3960
- }, placeholder: props.placeholder, style: {
4010
+ return (jsxRuntime.jsx(TextInputFormatted, { value: value, error: invalid(), onChange: function (e) { return setValue(e.target.value); }, helpText: helpText, autoFocus: true, placeholder: props.placeholder, style: {
3961
4011
  width: "100%"
3962
4012
  } }));
3963
4013
  };
3964
4014
 
3965
4015
  var GridFormSubComponentTextArea = function (props) {
3966
4016
  var _a;
3967
- var _b = react.useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid, triggerSave = _b.triggerSave;
4017
+ var _b = react.useContext(GridSubComponentContext), value = _b.value, data = _b.data, setValue = _b.setValue, setValid = _b.setValid;
3968
4018
  var helpText = (_a = props.helpText) !== null && _a !== void 0 ? _a : "Press tab to save";
3969
4019
  // If is not initialised yet as it's just been created then set the default value
3970
4020
  react.useEffect(function () {
@@ -3975,18 +4025,7 @@ var GridFormSubComponentTextArea = function (props) {
3975
4025
  react.useEffect(function () {
3976
4026
  setValid(value != null && invalid() == null);
3977
4027
  }, [setValid, invalid, value]);
3978
- return (jsxRuntime.jsx("div", __assign({ className: clsx("FreeTextInput LuiDeprecatedForms", props.className) }, { children: jsxRuntime.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) {
3979
- if (e.key === "Tab") {
3980
- e.preventDefault();
3981
- e.stopPropagation();
3982
- }
3983
- }, onKeyUp: function (e) {
3984
- if (e.key === "Tab") {
3985
- e.preventDefault();
3986
- e.stopPropagation();
3987
- !e.shiftKey && triggerSave().then();
3988
- }
3989
- } }) })));
4028
+ return (jsxRuntime.jsx("div", __assign({ className: clsx("FreeTextInput LuiDeprecatedForms", props.className) }, { children: jsxRuntime.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 }) })));
3990
4029
  };
3991
4030
 
3992
4031
  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}";