@linzjs/step-ag-grid 1.5.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/index.d.ts +9 -9
  2. package/dist/index.js +410 -358
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/Grid.d.ts +1 -1
  5. package/dist/src/components/GridCell.d.ts +18 -27
  6. package/dist/src/components/GridPopoverHook.d.ts +4 -2
  7. package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -3
  8. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +3 -4
  9. package/dist/src/components/gridForm/GridFormMessage.d.ts +4 -5
  10. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +5 -10
  11. package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +3 -4
  12. package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -3
  13. package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -4
  14. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +3 -2
  15. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +5 -270
  16. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +3 -2
  17. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
  18. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +3 -2
  19. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +3 -2
  20. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +3 -2
  21. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -3
  22. package/dist/src/contexts/GridContext.d.ts +1 -0
  23. package/dist/src/contexts/GridPopoverContext.d.ts +17 -0
  24. package/dist/src/contexts/GridPopoverContextProvider.d.ts +6 -0
  25. package/dist/src/contexts/{UpdatingContext.d.ts → GridUpdatingContext.d.ts} +2 -2
  26. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +7 -0
  27. package/dist/src/stories/components/FormTest.d.ts +1 -2
  28. package/dist/step-ag-grid.esm.js +404 -356
  29. package/dist/step-ag-grid.esm.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/components/Grid.tsx +20 -15
  32. package/src/components/GridCell.tsx +57 -79
  33. package/src/components/GridLoadableCell.tsx +4 -1
  34. package/src/components/GridPopoverHook.tsx +10 -14
  35. package/src/components/gridForm/GridFormDropDown.tsx +41 -30
  36. package/src/components/gridForm/GridFormEditBearing.tsx +13 -13
  37. package/src/components/gridForm/GridFormMessage.tsx +8 -13
  38. package/src/components/gridForm/GridFormMultiSelect.tsx +27 -29
  39. package/src/components/gridForm/GridFormPopoutMenu.tsx +10 -11
  40. package/src/components/gridForm/GridFormTextArea.tsx +16 -17
  41. package/src/components/gridForm/GridFormTextInput.tsx +19 -18
  42. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +17 -16
  43. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +53 -45
  44. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +17 -16
  45. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +20 -21
  46. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +18 -16
  47. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +12 -16
  48. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +15 -15
  49. package/src/components/gridRender/GridRenderGenericCell.tsx +3 -5
  50. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +2 -2
  51. package/src/contexts/GridContext.tsx +4 -0
  52. package/src/contexts/GridContextProvider.tsx +13 -5
  53. package/src/contexts/GridPopoverContext.tsx +32 -0
  54. package/src/contexts/GridPopoverContextProvider.tsx +53 -0
  55. package/src/contexts/{UpdatingContext.tsx → GridUpdatingContext.tsx} +2 -2
  56. package/src/contexts/{UpdatingContextProvider.tsx → GridUpdatingContextProvider.tsx} +8 -6
  57. package/src/stories/components/FormTest.tsx +4 -3
  58. package/src/stories/components/GridPopoutBearing.stories.tsx +28 -25
  59. package/src/stories/components/GridPopoutEditDropDown.stories.tsx +91 -50
  60. package/src/stories/components/GridPopoutEditGeneric.stories.tsx +18 -13
  61. package/src/stories/components/GridPopoutEditGenericTextArea.stories.tsx +76 -61
  62. package/src/stories/components/GridPopoutEditMultiSelect.stories.tsx +58 -51
  63. package/src/stories/components/GridReadOnly.stories.tsx +73 -57
  64. package/dist/src/contexts/UpdatingContextProvider.d.ts +0 -7
package/dist/index.js CHANGED
@@ -1640,7 +1640,7 @@ var MenuRadioGroupFr = function (_a, externalRef) {
1640
1640
  };
1641
1641
  var MenuRadioGroup = react.forwardRef(MenuRadioGroupFr);
1642
1642
 
1643
- var UpdatingContext = react.createContext({
1643
+ var GridUpdatingContext = react.createContext({
1644
1644
  checkUpdating: function () {
1645
1645
  console.error("Missing UpdatingContext");
1646
1646
  return false;
@@ -1653,7 +1653,7 @@ var UpdatingContext = react.createContext({
1653
1653
  }); }
1654
1654
  });
1655
1655
 
1656
- var UpdatingContextProvider = function (props) {
1656
+ var GridUpdatingContextProvider = function (props) {
1657
1657
  var updatingBlocks = react.useRef({});
1658
1658
  var updating = react.useRef({});
1659
1659
  var resetUpdating = function () {
@@ -1685,7 +1685,7 @@ var UpdatingContextProvider = function (props) {
1685
1685
  var checkUpdating = function (fields, id) {
1686
1686
  return lodashEs.castArray(fields).some(function (f) { var _a; return (_a = updating.current[f]) === null || _a === void 0 ? void 0 : _a.includes(id); });
1687
1687
  };
1688
- return (jsxRuntime.jsx(UpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
1688
+ return (jsxRuntime.jsx(GridUpdatingContext.Provider, __assign({ value: { modifyUpdating: modifyUpdating, checkUpdating: checkUpdating } }, { children: props.children })));
1689
1689
  };
1690
1690
 
1691
1691
  var GridContext = react.createContext({
@@ -1740,6 +1740,9 @@ var GridContext = react.createContext({
1740
1740
  ensureSelectedRowIsVisible: function () {
1741
1741
  console.error("no context provider for ensureSelectedRowIsVisible");
1742
1742
  },
1743
+ sizeColumnsToFit: function () {
1744
+ console.error("no context provider for sizeColumnsToFit");
1745
+ },
1743
1746
  editingCells: function () {
1744
1747
  console.error("no context provider for editingCells");
1745
1748
  return false;
@@ -1761,7 +1764,7 @@ var GridContext = react.createContext({
1761
1764
  * Also, make sure the provider is created in a separate component, otherwise it won't be found.
1762
1765
  */
1763
1766
  var GridContextProvider = function (props) {
1764
- var modifyUpdating = react.useContext(UpdatingContext).modifyUpdating;
1767
+ var modifyUpdating = react.useContext(GridUpdatingContext).modifyUpdating;
1765
1768
  var gridApiRef = react.useRef();
1766
1769
  var idsBeforeUpdate = react.useRef([]);
1767
1770
  /**
@@ -1787,10 +1790,7 @@ var GridContextProvider = function (props) {
1787
1790
  noApiFn = (function () { });
1788
1791
  }
1789
1792
  var gridApi = gridApiRef.current;
1790
- if (gridApi)
1791
- return hasApiFn(gridApi);
1792
- console.error("GridApi not ready");
1793
- return noApiFn();
1793
+ return gridApi ? hasApiFn(gridApi) : noApiFn();
1794
1794
  };
1795
1795
  /**
1796
1796
  * Set the quick filter value to grid.
@@ -1950,6 +1950,14 @@ var GridContextProvider = function (props) {
1950
1950
  gridApi.ensureNodeVisible(lodashEs.last(selectedNodes));
1951
1951
  });
1952
1952
  };
1953
+ /**
1954
+ * Resize columns to fit container
1955
+ */
1956
+ var sizeColumnsToFit = function () {
1957
+ gridApiOp(function (gridApi) {
1958
+ gridApi.sizeColumnsToFit();
1959
+ });
1960
+ };
1953
1961
  var stopEditing = function () { return gridApiOp(function (gridApi) { return gridApi.stopEditing(); }); };
1954
1962
  var updatingCells = function (props, fnUpdate, setSaving) { return __awaiter(void 0, void 0, void 0, function () {
1955
1963
  return __generator(this, function (_a) {
@@ -2016,6 +2024,7 @@ var GridContextProvider = function (props) {
2016
2024
  editingCells: editingCells,
2017
2025
  ensureRowVisible: ensureRowVisible,
2018
2026
  ensureSelectedRowIsVisible: ensureSelectedRowIsVisible,
2027
+ sizeColumnsToFit: sizeColumnsToFit,
2019
2028
  stopEditing: stopEditing,
2020
2029
  updatingCells: updatingCells
2021
2030
  } }, { children: props.children })));
@@ -2201,8 +2210,8 @@ var GridHeaderSelect = function (_a) {
2201
2210
  */
2202
2211
  var Grid = function (params) {
2203
2212
  var _a;
2204
- var _b = react.useContext(GridContext), gridReady = _b.gridReady, setGridApi = _b.setGridApi, setQuickFilter = _b.setQuickFilter, ensureRowVisible = _b.ensureRowVisible, selectRowsById = _b.selectRowsById, ensureSelectedRowIsVisible = _b.ensureSelectedRowIsVisible;
2205
- var checkUpdating = react.useContext(UpdatingContext).checkUpdating;
2213
+ var _b = react.useContext(GridContext), gridReady = _b.gridReady, setGridApi = _b.setGridApi, setQuickFilter = _b.setQuickFilter, ensureRowVisible = _b.ensureRowVisible, selectRowsById = _b.selectRowsById, ensureSelectedRowIsVisible = _b.ensureSelectedRowIsVisible, sizeColumnsToFit = _b.sizeColumnsToFit;
2214
+ var checkUpdating = react.useContext(GridUpdatingContext).checkUpdating;
2206
2215
  var _c = react.useState(""), internalQuickFilter = _c[0], setInternalQuickFilter = _c[1];
2207
2216
  var lastSelectedIds = react.useRef([]);
2208
2217
  var _d = react.useState(false), staleGrid = _d[0], setStaleGrid = _d[1];
@@ -2300,14 +2309,6 @@ var Grid = function (params) {
2300
2309
  var _a;
2301
2310
  return (jsxRuntime.jsx("span", __assign({ className: "ag-overlay-no-rows-center" }, { children: (_a = params.noRowsOverlayText) !== null && _a !== void 0 ? _a : "There are currently no rows" })));
2302
2311
  }, [params.noRowsOverlayText]);
2303
- var sizeColumnsToFit = react.useCallback(function (event) {
2304
- // @ts-ignore (gridBodyCtrl is private)
2305
- if (event.api.gridBodyCtrl == undefined) {
2306
- return;
2307
- // this is here because ag grid was throwing api undefined error when closing POPPED OUT panel
2308
- }
2309
- event.api.sizeColumnsToFit();
2310
- }, []);
2311
2312
  var refreshSelectedRows = react.useCallback(function (event) {
2312
2313
  // Force-refresh all selected rows to re-run class function, to update selection highlighting
2313
2314
  event.api.refreshCells({
@@ -2353,6 +2354,12 @@ var Grid = function (params) {
2353
2354
  var cell = event.api.getFocusedCell();
2354
2355
  cell && event.api.setFocusedCell(cell.rowIndex, cell.column);
2355
2356
  }, [refreshSelectedRows]);
2357
+ // When rows added or removed then resize columns
2358
+ react.useEffect(function () {
2359
+ if (columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length) {
2360
+ sizeColumnsToFit();
2361
+ }
2362
+ }, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
2356
2363
  return (jsxRuntime.jsxs("div", __assign({ "data-testid": params.dataTestId, className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsxRuntime.jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsxRuntime.jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
2357
2364
  setInternalQuickFilter(event.target.value);
2358
2365
  } }) }))), jsxRuntime.jsx(agGridReact.AgGridReact, { getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyDown: onCellKeyDown, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
@@ -2377,8 +2384,24 @@ styleInject(css_248z$5);
2377
2384
  var css_248z$4 = ".GridLoadableCell-container {\n display: flex;\n align-items: center;\n}";
2378
2385
  styleInject(css_248z$4);
2379
2386
 
2387
+ var GridPopoverContext = react.createContext({
2388
+ anchorRef: { current: null },
2389
+ updateValueRef: {
2390
+ current: function () { return __awaiter(void 0, void 0, void 0, function () {
2391
+ return __generator(this, function (_a) {
2392
+ console.error("Missing GridPopoverContext updateValueRef");
2393
+ return [2 /*return*/, false];
2394
+ });
2395
+ }); }
2396
+ },
2397
+ saving: false,
2398
+ setSaving: function () { },
2399
+ setProps: function () { },
2400
+ propsRef: { current: null }
2401
+ });
2402
+
2380
2403
  var GridLoadableCell = function (props) {
2381
- // console.log(`Rendering LoadableCell - loading: ${props.isLoading}`);
2404
+ react.useContext(GridPopoverContext).saving;
2382
2405
  if (props.isLoading) {
2383
2406
  return (jsxRuntime.jsx("div", __assign({ style: { display: "flex", alignItems: "center" } }, { children: jsxRuntime.jsx(lui.LuiMiniSpinner, { size: 22, divProps: { role: "status", "aria-label": "Loading", style: { marginBottom: 4 } } }) })));
2384
2407
  }
@@ -2390,7 +2413,7 @@ var GridIcon = function (props) { return (jsxRuntime.jsx(lui.LuiIcon, { name: pr
2390
2413
 
2391
2414
  var GridRendererGenericCell = function (props) {
2392
2415
  var _a, _b, _c;
2393
- var checkUpdating = react.useContext(UpdatingContext).checkUpdating;
2416
+ var checkUpdating = react.useContext(GridUpdatingContext).checkUpdating;
2394
2417
  var colDef = props.colDef;
2395
2418
  var cellRendererParams = colDef.cellRendererParams;
2396
2419
  var warningFn = cellRendererParams === null || cellRendererParams === void 0 ? void 0 : cellRendererParams.warning;
@@ -2407,9 +2430,57 @@ var GridRendererGenericCell = function (props) {
2407
2430
  return (jsxRuntime.jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_c = (_b = colDef.field) !== null && _b !== void 0 ? _b : colDef.colId) !== null && _c !== void 0 ? _c : "", props.data.id) }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [typeof warningText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_info", title: infoText }), jsxRuntime.jsx("span", __assign({ title: formatted }, { children: formatted }))] }) })));
2408
2431
  };
2409
2432
 
2433
+ var GridPopoverContextProvider = function (props) {
2434
+ var _a = react.useContext(GridContext), getSelectedRows = _a.getSelectedRows, updatingCells = _a.updatingCells;
2435
+ var anchorRef = react.useRef();
2436
+ var propsRef = react.useRef({});
2437
+ var updateValueRef = react.useRef(function () { return __awaiter(void 0, void 0, void 0, function () {
2438
+ return __generator(this, function (_a) {
2439
+ console.error("updateValueRef.current is not set");
2440
+ return [2 /*return*/, false];
2441
+ });
2442
+ }); });
2443
+ var _b = react.useState(false), saving = _b[0], setSaving = _b[1];
2444
+ var setProps = function (props, multiEdit) {
2445
+ var _a, _b;
2446
+ var selectedRows = multiEdit ? getSelectedRows() : [props.data];
2447
+ var field = (_b = (_a = props.colDef) === null || _a === void 0 ? void 0 : _a.field) !== null && _b !== void 0 ? _b : "";
2448
+ anchorRef.current = props.eGridCell;
2449
+ propsRef.current = {
2450
+ value: props.value,
2451
+ data: props.data,
2452
+ field: field,
2453
+ selectedRows: selectedRows
2454
+ };
2455
+ updateValueRef.current = function (saveFn) { return __awaiter(void 0, void 0, void 0, function () {
2456
+ var _a;
2457
+ return __generator(this, function (_b) {
2458
+ switch (_b.label) {
2459
+ case 0:
2460
+ _a = !saving;
2461
+ if (!_a) return [3 /*break*/, 2];
2462
+ return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2463
+ case 1:
2464
+ _a = (_b.sent());
2465
+ _b.label = 2;
2466
+ case 2: return [2 /*return*/, _a];
2467
+ }
2468
+ });
2469
+ }); };
2470
+ };
2471
+ return (jsxRuntime.jsx(GridPopoverContext.Provider, __assign({ value: {
2472
+ anchorRef: anchorRef,
2473
+ saving: saving,
2474
+ setSaving: setSaving,
2475
+ updateValueRef: updateValueRef,
2476
+ propsRef: propsRef,
2477
+ setProps: setProps
2478
+ } }, { children: props.children })));
2479
+ };
2480
+
2410
2481
  var GridCellRenderer = function (props) {
2411
2482
  var _a, _b, _c;
2412
- var checkUpdating = react.useContext(UpdatingContext).checkUpdating;
2483
+ var checkUpdating = react.useContext(GridUpdatingContext).checkUpdating;
2413
2484
  var colDef = props.colDef;
2414
2485
  var rendererParams = colDef.cellRendererParams;
2415
2486
  var warningFn = rendererParams === null || rendererParams === void 0 ? void 0 : rendererParams.warning;
@@ -2418,15 +2489,17 @@ var GridCellRenderer = function (props) {
2418
2489
  var infoText = infoFn ? infoFn(props) : undefined;
2419
2490
  return ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.originalCellRenderer) ? (jsxRuntime.jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_c = (_b = colDef.field) !== null && _b !== void 0 ? _b : colDef.colId) !== null && _c !== void 0 ? _c : "", props.data.id) }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [typeof warningText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsxRuntime.jsx(GridIcon, { icon: "ic_info", title: infoText }), jsxRuntime.jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))] }) }))) : (jsxRuntime.jsx(GridRendererGenericCell, __assign({}, props)));
2420
2491
  };
2421
- /**
2492
+ /*
2422
2493
  * For editing a text area.
2423
2494
  */
2424
- var GridCell = function (props) {
2495
+ var GridCell = function (props, custom) {
2425
2496
  var _a;
2426
- return __assign(__assign(__assign(__assign({ sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, (props.cellEditorParams && {
2427
- cellClass: ((_a = props === null || props === void 0 ? void 0 : props.cellEditorParams) === null || _a === void 0 ? void 0 : _a.multiEdit) ? GenericMultiEditCellClass : undefined,
2428
- editable: true,
2429
- cellEditor: GenericCellEditorComponent
2497
+ return __assign(__assign(__assign(__assign(__assign({ sortable: !!((props === null || props === void 0 ? void 0 : props.field) || (props === null || props === void 0 ? void 0 : props.valueGetter)), resizable: true }, ((custom === null || custom === void 0 ? void 0 : custom.editor) && {
2498
+ cellClass: (custom === null || custom === void 0 ? void 0 : custom.multiEdit) ? GenericMultiEditCellClass : undefined,
2499
+ editable: (_a = props.editable) !== null && _a !== void 0 ? _a : true,
2500
+ cellEditor: GenericCellEditorComponent(custom.editor)
2501
+ })), ((custom === null || custom === void 0 ? void 0 : custom.editorParams) && {
2502
+ cellEditorParams: __assign(__assign({}, custom.editorParams), { multiEdit: custom.multiEdit })
2430
2503
  })), {
2431
2504
  // Default value formatter, otherwise react freaks out on objects
2432
2505
  valueFormatter: function (params) {
@@ -2439,37 +2512,22 @@ var GridCell = function (props) {
2439
2512
  return JSON.stringify(params.value);
2440
2513
  } }), props), { cellRenderer: GridCellRenderer, cellRendererParams: __assign({ originalCellRenderer: props.cellRenderer }, props.cellRendererParams) });
2441
2514
  };
2442
- var GenericCellEditorComponentFr = function (props, _) {
2443
- var _a, _b, _c;
2444
- var _d = react.useContext(GridContext), updatingCells = _d.updatingCells, getSelectedRows = _d.getSelectedRows;
2445
- var colDef = props.colDef, data = props.data;
2446
- var cellEditorParams = props.colDef.cellEditorParams;
2447
- var multiEdit = (_a = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _a !== void 0 ? _a : false;
2448
- var field = (_b = props.colDef.field) !== null && _b !== void 0 ? _b : "";
2449
- var formProps = (_c = colDef.cellEditorParams) !== null && _c !== void 0 ? _c : {};
2450
- var value = props.value;
2451
- var selectedRows = react.useMemo(function () { return (multiEdit ? getSelectedRows() : [data]); }, [data, getSelectedRows, multiEdit]);
2452
- var _e = react.useState(false), saving = _e[0], setSaving = _e[1];
2453
- var updateValue = react.useCallback(function (saveFn) { return __awaiter(void 0, void 0, void 0, function () {
2454
- var _a;
2455
- return __generator(this, function (_b) {
2456
- switch (_b.label) {
2457
- case 0:
2458
- _a = !saving;
2459
- if (!_a) return [3 /*break*/, 2];
2460
- return [4 /*yield*/, updatingCells({ selectedRows: selectedRows, field: field }, saveFn, setSaving)];
2461
- case 1:
2462
- _a = (_b.sent());
2463
- _b.label = 2;
2464
- case 2: return [2 /*return*/, _a];
2465
- }
2466
- });
2467
- }); }, [field, saving, selectedRows, updatingCells]);
2468
- if (cellEditorParams == null)
2469
- return jsxRuntime.jsx(jsxRuntime.Fragment, {});
2470
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { children: colDef.cellRenderer ? jsxRuntime.jsx(colDef.cellRenderer, __assign({}, props, { saving: saving })) : props.value }), (cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.form) && (jsxRuntime.jsx(cellEditorParams.form, { cellEditorParams: props, updateValue: updateValue, saving: saving, formProps: formProps, data: data, value: value, field: field, selectedRows: selectedRows }))] }));
2515
+ // TODO memo?
2516
+ var GenericCellEditorComponent = function (editor) {
2517
+ return react.forwardRef(function GenericCellEditorComponent2(props, _) {
2518
+ return (jsxRuntime.jsx(GridPopoverContextProvider, { children: jsxRuntime.jsx(GenericCellEditorComponent3, __assign({}, __assign(__assign({}, props), { editor: editor }))) }));
2519
+ });
2471
2520
  };
2472
- var GenericCellEditorComponent = react.forwardRef(GenericCellEditorComponentFr);
2521
+ var GenericCellEditorComponent3 = function (props) {
2522
+ var _a;
2523
+ var _b = react.useContext(GridPopoverContext), setProps = _b.setProps, propsRef = _b.propsRef;
2524
+ var colDef = props.colDef;
2525
+ var cellEditorParams = colDef.cellEditorParams;
2526
+ var multiEdit = (_a = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _a !== void 0 ? _a : false;
2527
+ // TODO don't need all these props in context
2528
+ setProps(props, multiEdit);
2529
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { children: colDef.cellRenderer ? jsxRuntime.jsx(colDef.cellRenderer, __assign({}, props)) : props.value }), (props === null || props === void 0 ? void 0 : props.editor) && jsxRuntime.jsx(props.editor, __assign({}, cellEditorParams, propsRef.current))] }));
2530
+ };
2473
2531
 
2474
2532
  /**
2475
2533
  * If loading is true this returns a loading spinner, otherwise it returns its children.
@@ -2487,29 +2545,32 @@ var ComponentLoadingWrapper = function (props) {
2487
2545
  } })), props.children] })));
2488
2546
  };
2489
2547
 
2490
- var useGridPopoverHook = function (props, save) {
2491
- var cellEditorParams = props.cellEditorParams, saving = props.saving, updateValue = props.updateValue;
2492
- var eGridCell = cellEditorParams.eGridCell;
2548
+ var useGridPopoverHook = function (props) {
2549
+ if (props === void 0) { props = {}; }
2493
2550
  var stopEditing = react.useContext(GridContext).stopEditing;
2551
+ var _a = react.useContext(GridPopoverContext), anchorRef = _a.anchorRef, saving = _a.saving, updateValueRef = _a.updateValueRef;
2494
2552
  var saveButtonRef = react.useRef(null);
2495
- var anchorRef = react.useRef(eGridCell);
2496
- anchorRef.current = eGridCell;
2497
- var _a = react.useState(false), isOpen = _a[0], setOpen = _a[1];
2553
+ var _b = react.useState(false), isOpen = _b[0], setOpen = _b[1];
2498
2554
  react.useEffect(function () {
2499
2555
  setOpen(true);
2500
2556
  }, []);
2501
2557
  var triggerSave = react.useCallback(function (reason) { return __awaiter(void 0, void 0, void 0, function () {
2502
- var _a;
2503
- return __generator(this, function (_b) {
2504
- switch (_b.label) {
2558
+ var _a, _b;
2559
+ return __generator(this, function (_c) {
2560
+ switch (_c.label) {
2505
2561
  case 0:
2506
- _a = reason == "cancel" || !save;
2507
- if (_a) return [3 /*break*/, 2];
2508
- return [4 /*yield*/, updateValue(save)];
2562
+ _a = reason == "cancel" || !props.save;
2563
+ if (_a) return [3 /*break*/, 3];
2564
+ _b = updateValueRef.current;
2565
+ if (!_b) return [3 /*break*/, 2];
2566
+ return [4 /*yield*/, updateValueRef.current(props.save)];
2509
2567
  case 1:
2510
- _a = (_b.sent());
2511
- _b.label = 2;
2568
+ _b = (_c.sent());
2569
+ _c.label = 2;
2512
2570
  case 2:
2571
+ _a = (_b);
2572
+ _c.label = 3;
2573
+ case 3:
2513
2574
  if (_a) {
2514
2575
  setOpen(false);
2515
2576
  stopEditing();
@@ -2517,9 +2578,9 @@ var useGridPopoverHook = function (props, save) {
2517
2578
  return [2 /*return*/];
2518
2579
  }
2519
2580
  });
2520
- }); }, [save, stopEditing, updateValue]);
2581
+ }); }, [props, stopEditing, updateValueRef]);
2521
2582
  var popoverWrapper = react.useCallback(function (children) {
2522
- 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: "lui-menu", onClose: function (event) { return triggerSave(event.reason).then(); }, reposition: "initial", viewScroll: "auto", dontShrinkIfDirectionIsTop: true }, { children: [saving && (jsxRuntime.jsx("div", { style: {
2583
+ 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: "lui-menu", onClose: function (event) { return triggerSave(event.reason).then(); }, viewScroll: "auto", dontShrinkIfDirectionIsTop: true }, { children: [saving && (jsxRuntime.jsx("div", { style: {
2523
2584
  position: "absolute",
2524
2585
  left: 0,
2525
2586
  top: 0,
@@ -2528,7 +2589,7 @@ var useGridPopoverHook = function (props, save) {
2528
2589
  backgroundColor: "rgba(64,64,64,0.1)",
2529
2590
  zIndex: 1000
2530
2591
  } })), children, jsxRuntime.jsx("button", { ref: saveButtonRef, onClick: function () { return triggerSave().then(); }, style: { display: "none" } })] }))) }));
2531
- }, [isOpen, saving, triggerSave]);
2592
+ }, [anchorRef, isOpen, saving, triggerSave]);
2532
2593
  return {
2533
2594
  popoverWrapper: popoverWrapper,
2534
2595
  triggerSave: triggerSave
@@ -2537,7 +2598,7 @@ var useGridPopoverHook = function (props, save) {
2537
2598
 
2538
2599
  var GridRenderPopoutMenuCell = function (props) {
2539
2600
  var _a, _b, _c;
2540
- var checkUpdating = react.useContext(UpdatingContext).checkUpdating;
2601
+ var checkUpdating = react.useContext(GridUpdatingContext).checkUpdating;
2541
2602
  var isLoading = checkUpdating((_b = (_a = props.colDef) === null || _a === void 0 ? void 0 : _a.field) !== null && _b !== void 0 ? _b : "", props.data.id);
2542
2603
  var editable = (_c = props.colDef) === null || _c === void 0 ? void 0 : _c.editable;
2543
2604
  var disabled = !(typeof editable === "function"
@@ -2557,17 +2618,189 @@ var GridRenderPopoutMenuCell = function (props) {
2557
2618
  var css_248z$3 = "@charset \"UTF-8\";\n.szh-menu {\n margin: 0;\n padding: 0;\n list-style: none;\n box-sizing: border-box;\n width: max-content;\n z-index: 100;\n border: 1px solid rgba(0, 0, 0, 0.1);\n background-color: #fff;\n}\n.szh-menu:focus {\n outline: none;\n}\n.szh-menu__arrow {\n box-sizing: border-box;\n width: 0.75rem;\n height: 0.75rem;\n background-color: #fff;\n border: 1px solid transparent;\n border-left-color: rgba(0, 0, 0, 0.1);\n border-top-color: rgba(0, 0, 0, 0.1);\n z-index: -1;\n}\n.szh-menu__arrow--dir-left {\n right: -0.375rem;\n transform: translateY(-50%) rotate(135deg);\n}\n.szh-menu__arrow--dir-right {\n left: -0.375rem;\n transform: translateY(-50%) rotate(-45deg);\n}\n.szh-menu__arrow--dir-top {\n bottom: -0.375rem;\n transform: translateX(-50%) rotate(-135deg);\n}\n.szh-menu__arrow--dir-bottom {\n top: -0.375rem;\n transform: translateX(-50%) rotate(45deg);\n}\n.szh-menu__item {\n cursor: pointer;\n}\n.szh-menu__item:focus {\n outline: none;\n}\n.szh-menu__item--hover {\n background-color: #ebebeb;\n}\n.szh-menu__item--focusable {\n cursor: default;\n background-color: inherit;\n}\n.szh-menu__item--disabled {\n cursor: default;\n color: #aaa;\n}\n.szh-menu__group {\n box-sizing: border-box;\n}\n.szh-menu__radio-group {\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.szh-menu__divider {\n height: 1px;\n margin: 0.5rem 0;\n background-color: rgba(0, 0, 0, 0.12);\n}\n\n.szh-menu-button {\n box-sizing: border-box;\n}\n\n.szh-menu {\n user-select: none;\n color: #212529;\n border: none;\n border-radius: 0.25rem;\n box-shadow: 0 3px 7px rgba(0, 0, 0, 0.133), 0 0.6px 2px rgba(0, 0, 0, 0.1);\n min-width: 10rem;\n padding: 0.5rem 0;\n}\n.szh-menu__item {\n display: flex;\n align-items: center;\n position: relative;\n padding: 0.375rem 1.5rem;\n}\n.szh-menu-container--itemTransition .szh-menu__item {\n transition-property: background-color, color;\n transition-duration: 0.15s;\n transition-timing-function: ease-in-out;\n}\n.szh-menu__item--type-radio {\n padding-left: 2.2rem;\n}\n.szh-menu__item--type-radio::before {\n content: \"○\";\n position: absolute;\n left: 0.8rem;\n top: 0.55rem;\n font-size: 0.8rem;\n}\n.szh-menu__item--type-radio.szh-menu__item--checked::before {\n content: \"●\";\n}\n.szh-menu__item--type-checkbox {\n padding-left: 2.2rem;\n}\n.szh-menu__item--type-checkbox::before {\n position: absolute;\n left: 0.8rem;\n}\n.szh-menu__item--type-checkbox.szh-menu__item--checked::before {\n content: \"✔\";\n}\n.szh-menu__submenu > .szh-menu__item {\n padding-right: 2.5rem;\n}\n.szh-menu__submenu > .szh-menu__item::after {\n content: \"❯\";\n position: absolute;\n right: 1rem;\n}\n.szh-menu__header {\n color: #888;\n font-size: 0.8rem;\n padding: 0.2rem 1.5rem;\n text-transform: uppercase;\n}";
2558
2619
  styleInject(css_248z$3);
2559
2620
 
2560
- var MenuSeparatorString$1 = "_____MENU_SEPARATOR_____";
2561
- Object.freeze({ value: MenuSeparatorString$1 });
2621
+ var MenuSeparatorString = "_____MENU_SEPARATOR_____";
2622
+ var MenuSeparator = Object.freeze({ value: MenuSeparatorString });
2623
+ var MenuHeaderString = "_____MENU_HEADER_____";
2624
+ var MenuHeaderItem = function (title) {
2625
+ return { label: title, value: MenuHeaderString };
2626
+ };
2627
+ var GridFormDropDown = function (_props) {
2628
+ var props = _props;
2629
+ var _a = react.useContext(GridContext), updatingCells = _a.updatingCells, stopEditing = _a.stopEditing;
2630
+ var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
2631
+ var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
2632
+ var optionsInitialising = react.useRef(false);
2633
+ var _d = react.useState(null), options = _d[0], setOptions = _d[1];
2634
+ var selectItemHandler = react.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
2635
+ var field;
2636
+ return __generator(this, function (_a) {
2637
+ switch (_a.label) {
2638
+ case 0:
2639
+ field = props.field;
2640
+ return [4 /*yield*/, updatingCells({ selectedRows: props.selectedRows, field: field }, function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
2641
+ var hasChanged;
2642
+ return __generator(this, function (_a) {
2643
+ switch (_a.label) {
2644
+ case 0:
2645
+ hasChanged = selectedRows.some(function (row) { return row[field] !== value; });
2646
+ if (!hasChanged) return [3 /*break*/, 3];
2647
+ if (!props.onSelectedItem) return [3 /*break*/, 2];
2648
+ return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value })];
2649
+ case 1:
2650
+ _a.sent();
2651
+ return [3 /*break*/, 3];
2652
+ case 2:
2653
+ selectedRows.forEach(function (row) { return (row[field] = value); });
2654
+ _a.label = 3;
2655
+ case 3: return [2 /*return*/, true];
2656
+ }
2657
+ });
2658
+ }); })];
2659
+ case 1: return [2 /*return*/, _a.sent()];
2660
+ }
2661
+ });
2662
+ }); }, [props, updatingCells]);
2663
+ var selectFilterHandler = react.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
2664
+ var field;
2665
+ return __generator(this, function (_a) {
2666
+ switch (_a.label) {
2667
+ case 0:
2668
+ field = props.field;
2669
+ return [4 /*yield*/, updatingCells({ selectedRows: props.selectedRows, field: field }, function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
2670
+ return __generator(this, function (_a) {
2671
+ switch (_a.label) {
2672
+ case 0:
2673
+ if (!props.onSelectFilter) return [3 /*break*/, 2];
2674
+ return [4 /*yield*/, props.onSelectFilter({ selectedRows: selectedRows, value: value })];
2675
+ case 1:
2676
+ _a.sent();
2677
+ _a.label = 2;
2678
+ case 2: return [2 /*return*/, true];
2679
+ }
2680
+ });
2681
+ }); })];
2682
+ case 1: return [2 /*return*/, _a.sent()];
2683
+ }
2684
+ });
2685
+ }); }, [props, updatingCells]);
2686
+ // Load up options list if it's async function
2687
+ react.useEffect(function () {
2688
+ var _a;
2689
+ if (options || optionsInitialising.current)
2690
+ return;
2691
+ optionsInitialising.current = true;
2692
+ var optionsConf = (_a = props.options) !== null && _a !== void 0 ? _a : [];
2693
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
2694
+ var optionsList;
2695
+ return __generator(this, function (_a) {
2696
+ switch (_a.label) {
2697
+ case 0:
2698
+ if (!(typeof optionsConf == "function")) return [3 /*break*/, 2];
2699
+ return [4 /*yield*/, optionsConf(props.selectedRows, filter)];
2700
+ case 1:
2701
+ optionsConf = _a.sent();
2702
+ _a.label = 2;
2703
+ case 2:
2704
+ optionsList = optionsConf === null || optionsConf === void 0 ? void 0 : optionsConf.map(function (item) {
2705
+ if (item == null || typeof item == "string" || typeof item == "number") {
2706
+ item = { value: item, label: item, disabled: false };
2707
+ }
2708
+ return item;
2709
+ });
2710
+ if (props.filtered) {
2711
+ // This is needed otherwise when filter input is rendered and sets autofocus
2712
+ // the mouse up of the double click edit triggers the cell to cancel editing
2713
+ lodashEs.delay(function () { return setOptions(optionsList); }, 100);
2714
+ }
2715
+ else {
2716
+ setOptions(optionsList);
2717
+ }
2718
+ optionsInitialising.current = false;
2719
+ return [2 /*return*/];
2720
+ }
2721
+ });
2722
+ }); })();
2723
+ }, [filter, options, props]);
2724
+ // Local filtering.
2725
+ react.useEffect(function () {
2726
+ if (props.filtered == "local") {
2727
+ if (options == null)
2728
+ return;
2729
+ setFilteredValues(options
2730
+ .map(function (option) {
2731
+ if (option.label != null && typeof option.label !== "string") {
2732
+ console.error("Cannot filter non-string labels", option);
2733
+ return undefined;
2734
+ }
2735
+ var str = option.label || "";
2736
+ return str.toLowerCase().indexOf(filter) === -1 ? option.value : undefined;
2737
+ })
2738
+ .filter(function (r) { return r !== undefined; }));
2739
+ }
2740
+ }, [props.filtered, filter, options]);
2741
+ var researchOnFilterChange = debounce__default["default"](react.useCallback(function () {
2742
+ setOptions(null);
2743
+ }, []), 500);
2744
+ var previousFilter = react.useRef(filter);
2745
+ // Reload filtering.
2746
+ react.useEffect(function () {
2747
+ if (previousFilter.current != filter && props.filtered == "reload") {
2748
+ previousFilter.current = filter;
2749
+ props.optionsRequestCancel && props.optionsRequestCancel();
2750
+ researchOnFilterChange().then();
2751
+ }
2752
+ }, [filter, props, researchOnFilterChange]);
2753
+ var onFilterKeyDown = react.useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
2754
+ var activeOptions;
2755
+ return __generator(this, function (_a) {
2756
+ switch (_a.label) {
2757
+ case 0:
2758
+ if (!options)
2759
+ return [2 /*return*/];
2760
+ if (!(e.key == "Enter" || e.key == "Tab")) return [3 /*break*/, 5];
2761
+ activeOptions = options.filter(function (option) { return !filteredValues.includes(option.value); });
2762
+ if (!(activeOptions.length == 1)) return [3 /*break*/, 2];
2763
+ return [4 /*yield*/, selectItemHandler(activeOptions[0].value)];
2764
+ case 1:
2765
+ _a.sent();
2766
+ stopEditing();
2767
+ return [3 /*break*/, 5];
2768
+ case 2:
2769
+ if (!props.onSelectFilter) return [3 /*break*/, 4];
2770
+ return [4 /*yield*/, selectFilterHandler(filter)];
2771
+ case 3:
2772
+ _a.sent();
2773
+ stopEditing();
2774
+ return [3 /*break*/, 5];
2775
+ case 4:
2776
+ e.preventDefault();
2777
+ e.stopPropagation();
2778
+ _a.label = 5;
2779
+ case 5: return [2 /*return*/];
2780
+ }
2781
+ });
2782
+ }); }, [filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, props]);
2783
+ var maxRowsStyles = props.maxRows !== undefined ? { maxHeight: 62 + 34 * props.maxRows, overFlowY: "auto" } : undefined;
2784
+ var popoverWrapper = useGridPopoverHook().popoverWrapper;
2785
+ return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
2786
+ var _b;
2787
+ var ref = _a.ref;
2788
+ 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); } }) })));
2789
+ } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options }, { children: jsxRuntime.jsxs("div", __assign({ style: maxRowsStyles }, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && jsxRuntime.jsx(MenuItem, { children: "[Empty]" }), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2790
+ var _a;
2791
+ return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsxRuntime.jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () { return selectItemHandler(item.value); } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(props.field, "-").concat(index)));
2792
+ })] })) }))] }));
2793
+ };
2794
+
2562
2795
  var GridFormMultiSelect = function (props) {
2563
- var formProps = props.formProps;
2796
+ var selectedRows = props.selectedRows;
2564
2797
  var _a = react.useState(""), filter = _a[0], setFilter = _a[1];
2565
2798
  var _b = react.useState([]), filteredValues = _b[0], setFilteredValues = _b[1];
2566
2799
  var optionsInitialising = react.useRef(false);
2567
2800
  var _c = react.useState(), options = _c[0], setOptions = _c[1];
2568
2801
  var subSelectedValues = react.useRef({});
2569
2802
  var _d = react.useState(function () {
2570
- return formProps.initialSelectedValues ? formProps.initialSelectedValues(props.selectedRows) : [];
2803
+ return props.initialSelectedValues ? props.initialSelectedValues(selectedRows) : [];
2571
2804
  }), selectedValues = _d[0], setSelectedValues = _d[1];
2572
2805
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
2573
2806
  var values;
@@ -2575,28 +2808,28 @@ var GridFormMultiSelect = function (props) {
2575
2808
  switch (_a.label) {
2576
2809
  case 0:
2577
2810
  values = lodashEs.fromPairs(selectedValues.map(function (value) { var _a; return [value, (_a = subSelectedValues.current[value]) !== null && _a !== void 0 ? _a : true]; }));
2578
- if (!formProps.onSave) return [3 /*break*/, 2];
2579
- return [4 /*yield*/, formProps.onSave({ selectedRows: selectedRows, values: values })];
2811
+ if (!props.onSave) return [3 /*break*/, 2];
2812
+ return [4 /*yield*/, props.onSave({ selectedRows: selectedRows, values: values })];
2580
2813
  case 1: return [2 /*return*/, _a.sent()];
2581
2814
  case 2: return [2 /*return*/, true];
2582
2815
  }
2583
2816
  });
2584
- }); }, [formProps, selectedValues]);
2585
- var _e = useGridPopoverHook(props, save), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
2817
+ }); }, [props, selectedValues]);
2818
+ var _e = useGridPopoverHook({ save: save }), popoverWrapper = _e.popoverWrapper, triggerSave = _e.triggerSave;
2586
2819
  // Load up options list if it's async function
2587
2820
  react.useEffect(function () {
2588
2821
  var _a;
2589
2822
  if (options || optionsInitialising.current)
2590
2823
  return;
2591
2824
  optionsInitialising.current = true;
2592
- var optionsConf = (_a = formProps.options) !== null && _a !== void 0 ? _a : [];
2825
+ var optionsConf = (_a = props.options) !== null && _a !== void 0 ? _a : [];
2593
2826
  (function () { return __awaiter(void 0, void 0, void 0, function () {
2594
2827
  var optionsList;
2595
2828
  return __generator(this, function (_a) {
2596
2829
  switch (_a.label) {
2597
2830
  case 0:
2598
2831
  if (!(typeof optionsConf == "function")) return [3 /*break*/, 2];
2599
- return [4 /*yield*/, optionsConf(props.selectedRows)];
2832
+ return [4 /*yield*/, optionsConf(selectedRows)];
2600
2833
  case 1:
2601
2834
  optionsConf = _a.sent();
2602
2835
  _a.label = 2;
@@ -2607,7 +2840,7 @@ var GridFormMultiSelect = function (props) {
2607
2840
  }
2608
2841
  return item;
2609
2842
  });
2610
- if (formProps.filtered) {
2843
+ if (props.filtered) {
2611
2844
  // This is needed otherwise when filter input is rendered and sets autofocus
2612
2845
  // the mouse up of the double click edit triggers the cell to cancel editing
2613
2846
  lodashEs.delay(function () { return setOptions(optionsList); }, 100);
@@ -2620,9 +2853,9 @@ var GridFormMultiSelect = function (props) {
2620
2853
  }
2621
2854
  });
2622
2855
  }); })();
2623
- }, [formProps.filtered, formProps.options, options, props.selectedRows]);
2856
+ }, [props.filtered, props.options, options, selectedRows]);
2624
2857
  react.useEffect(function () {
2625
- if (!formProps.filtered || options == null)
2858
+ if (!props.filtered || options == null)
2626
2859
  return;
2627
2860
  setFilteredValues(options
2628
2861
  .map(function (option) {
@@ -2634,14 +2867,14 @@ var GridFormMultiSelect = function (props) {
2634
2867
  return str.toLowerCase().indexOf(filter.trim()) === -1 ? option.value : undefined;
2635
2868
  })
2636
2869
  .filter(function (r) { return r !== undefined; }));
2637
- }, [formProps.filtered, filter, options]);
2638
- return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options }, { children: jsxRuntime.jsxs("div", __assign({ className: "Grid-popoverContainerList" }, { children: [options && formProps.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
2870
+ }, [props.filtered, filter, options]);
2871
+ return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options }, { children: jsxRuntime.jsxs("div", __assign({ className: "Grid-popoverContainerList" }, { children: [options && props.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
2639
2872
  var _b;
2640
2873
  var ref = _a.ref;
2641
- 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 = formProps.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: "", onChange: function (e) { return setFilter(e.target.value.toLowerCase()); } }) })));
2874
+ 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: "", onChange: function (e) { return setFilter(e.target.value.toLowerCase()); } }) })));
2642
2875
  } }), "filter"), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2643
2876
  var _a;
2644
- return item.value === MenuSeparatorString$1 ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) {
2877
+ return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(MenuItem, __assign({ onClick: function (e) {
2645
2878
  e.keepOpen = true;
2646
2879
  if (selectedValues.includes(item.value)) {
2647
2880
  setSelectedValues(selectedValues.filter(function (value) { return value != item.value; }));
@@ -2684,24 +2917,21 @@ var GridFormMultiSelect = function (props) {
2684
2917
  })] })) })));
2685
2918
  };
2686
2919
 
2687
- var GridPopoutEditMultiSelect = function (colDef) {
2688
- var _a;
2689
- return GridCell(__assign(__assign({ initialWidth: 65, maxWidth: 150, cellClass: ((_a = colDef.cellEditor) === null || _a === void 0 ? void 0 : _a.multiEdit) ? GenericMultiEditCellClass : undefined }, colDef), ((colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) && {
2690
- cellEditorParams: __assign(__assign({}, colDef.cellEditorParams), { form: GridFormMultiSelect })
2691
- })));
2920
+ var GridPopoutEditMultiSelect = function (colDef, props) {
2921
+ return GridCell(__assign({ initialWidth: 65, maxWidth: 150, cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined }, colDef), __assign({ editor: GridFormMultiSelect }, props));
2692
2922
  };
2693
2923
 
2694
2924
  var css_248z$2 = "/**\n @deprecated\n */\n/**\n @deprecated\n */\n/**\n @deprecated\n */\n.GridPopoutMenu-burger {\n cursor: pointer;\n}\n.GridPopoutMenu-burger svg {\n fill: #007198;\n}\n\n.GridPopoutMenu-burgerDisabled svg {\n fill: #989189;\n}";
2695
2925
  styleInject(css_248z$2);
2696
2926
 
2697
2927
  /** Menu configuration types **/
2698
- var MenuSeparator = Object.freeze({ __isMenuSeparator__: true });
2928
+ var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
2699
2929
  /**
2700
2930
  * NOTE: If the popout menu doesn't appear on single click when also selecting row it's because
2701
2931
  * you need a useMemo around your columnDefs
2702
2932
  */
2703
- var GridFormPopoutMenu = function (props) {
2704
- var formProps = props.formProps;
2933
+ var GridFormPopoutMenu = function (_props) {
2934
+ var props = _props;
2705
2935
  var updatingCells = react.useContext(GridContext).updatingCells;
2706
2936
  var optionsInitialising = react.useRef(false);
2707
2937
  var _a = react.useState(), options = _a[0], setOptions = _a[1];
@@ -2711,7 +2941,7 @@ var GridFormPopoutMenu = function (props) {
2711
2941
  if (options || optionsInitialising.current)
2712
2942
  return;
2713
2943
  optionsInitialising.current = true;
2714
- var optionsConf = (_a = formProps.options) !== null && _a !== void 0 ? _a : [];
2944
+ var optionsConf = (_a = props.options) !== null && _a !== void 0 ? _a : [];
2715
2945
  (function () { return __awaiter(void 0, void 0, void 0, function () {
2716
2946
  var _a;
2717
2947
  return __generator(this, function (_b) {
@@ -2732,7 +2962,7 @@ var GridFormPopoutMenu = function (props) {
2732
2962
  }
2733
2963
  });
2734
2964
  }); })();
2735
- }, [options, formProps.options, props.selectedRows]);
2965
+ }, [options, props.options, props.selectedRows]);
2736
2966
  var actionClick = react.useCallback(function (menuOption) { return __awaiter(void 0, void 0, void 0, function () {
2737
2967
  return __generator(this, function (_a) {
2738
2968
  switch (_a.label) {
@@ -2758,25 +2988,23 @@ var GridFormPopoutMenu = function (props) {
2758
2988
  }); }, [props.field, props.selectedRows, updatingCells]);
2759
2989
  var selectedRowCount = props.selectedRows.length;
2760
2990
  var filteredOptions = options === null || options === void 0 ? void 0 : options.filter(function (menuOption) {
2761
- return menuOption.label === MenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
2991
+ return menuOption.label === PopoutMenuSeparator || selectedRowCount === 1 || menuOption.supportsMultiEdit;
2762
2992
  });
2763
- var popoverWrapper = useGridPopoverHook(props).popoverWrapper;
2993
+ var popoverWrapper = useGridPopoverHook().popoverWrapper;
2764
2994
  return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !filteredOptions }, { children: jsxRuntime.jsx("div", __assign({ className: "Grid-popoverContainerList" }, { children: options === null || options === void 0 ? void 0 : options.map(function (item, index) {
2765
- return item.label === MenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsx(MenuItem, __assign({ onClick: function () { return actionClick(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))));
2995
+ return item.label === PopoutMenuSeparator ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : (!item.hidden && (jsxRuntime.jsx(MenuItem, __assign({ onClick: function () { return actionClick(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))));
2766
2996
  }) })) })));
2767
2997
  };
2768
2998
 
2769
2999
  /**
2770
3000
  * Popout burger menu
2771
3001
  */
2772
- var GridPopoverMenu = function (colDef) {
3002
+ var GridPopoverMenu = function (colDef, props) {
2773
3003
  var _a;
2774
- return GridCell(__assign(__assign(__assign({ maxWidth: 64, editable: colDef.editable != null ? colDef.editable : true, cellRenderer: GridRenderPopoutMenuCell, cellClass: ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) === null || _a === void 0 ? void 0 : _a.multiEdit) !== false ? GenericMultiEditCellClass : undefined }, colDef), { cellRendererParams: {
3004
+ return GridCell(__assign(__assign({ maxWidth: 64, editable: colDef.editable != null ? colDef.editable : true, cellRenderer: GridRenderPopoutMenuCell, cellClass: ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) === null || _a === void 0 ? void 0 : _a.multiEdit) !== false ? GenericMultiEditCellClass : undefined }, colDef), { cellRendererParams: {
2775
3005
  // Menus open on single click, this parameter is picked up in Grid.tsx
2776
3006
  singleClickEdit: true
2777
- } }), ((colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) && {
2778
- cellEditorParams: __assign(__assign({ multiEdit: true }, colDef.cellEditorParams), { form: GridFormPopoutMenu })
2779
- })));
3007
+ } }), __assign({ editor: GridFormPopoutMenu }, props));
2780
3008
  };
2781
3009
 
2782
3010
  var bearingValueFormatter = function (params) {
@@ -2867,9 +3095,9 @@ var TextInputFormatted = function (props) {
2867
3095
  return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.warning && "hasWarning", props.className) }, { children: [jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsxRuntime.jsx("input", __assign({ type: "text", className: "LuiTextInput-input", min: "0", value: props.value, onChange: props.onChange }, props.inputProps)), 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.warning && (jsxRuntime.jsxs("span", __assign({ className: "LuiTextInput-warning" }, { children: [jsxRuntime.jsx(lui.LuiIcon, { alt: "warning", name: "ic_warning", className: "LuiTextInput-warning-icon", size: "sm", status: "warning" }), props.warning] })))] })));
2868
3096
  };
2869
3097
 
2870
- var GridFormEditBearing = function (props) {
3098
+ var GridFormEditBearing = function (_props) {
2871
3099
  var _a;
2872
- var formProps = props.formProps;
3100
+ var props = _props;
2873
3101
  var _b = react.useState("".concat((_a = props.value) !== null && _a !== void 0 ? _a : "")), value = _b[0], setValue = _b[1];
2874
3102
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
2875
3103
  var parsedValue, field_1;
@@ -2883,8 +3111,8 @@ var GridFormEditBearing = function (props) {
2883
3111
  if (parsedValue === props.value) {
2884
3112
  return [2 /*return*/, true];
2885
3113
  }
2886
- if (!formProps.onSave) return [3 /*break*/, 2];
2887
- return [4 /*yield*/, formProps.onSave(selectedRows, parsedValue)];
3114
+ if (!props.onSave) return [3 /*break*/, 2];
3115
+ return [4 /*yield*/, props.onSave(selectedRows, parsedValue)];
2888
3116
  case 1: return [2 /*return*/, _a.sent()];
2889
3117
  case 2:
2890
3118
  field_1 = props.field;
@@ -2898,42 +3126,42 @@ var GridFormEditBearing = function (props) {
2898
3126
  case 3: return [2 /*return*/, true];
2899
3127
  }
2900
3128
  });
2901
- }); }, [formProps, props.field, props.value, value]);
2902
- var _c = useGridPopoverHook(props, save), popoverWrapper = _c.popoverWrapper, triggerSave = _c.triggerSave;
3129
+ }); }, [props, value]);
3130
+ var _c = useGridPopoverHook({ save: save }), triggerSave = _c.triggerSave, popoverWrapper = _c.popoverWrapper;
2903
3131
  return popoverWrapper(jsxRuntime.jsx("div", __assign({ className: "GridFormEditBearing-input Grid-popoverContainer" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: value !== null && value !== void 0 ? value : "", onChange: function (e) {
2904
3132
  setValue(e.target.value.trim());
2905
3133
  }, inputProps: {
2906
3134
  autoFocus: true,
2907
- placeholder: formProps.placeHolder,
3135
+ placeholder: props.placeHolder,
2908
3136
  disabled: false,
2909
3137
  maxLength: 16,
2910
3138
  onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
2911
3139
  return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
2912
3140
  }); }); }
2913
- }, formatted: bearingStringValidator(value, formProps.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, formProps.range) }) })));
3141
+ }, formatted: bearingStringValidator(value, props.range) ? "?" : convertDDToDMS(bearingNumberParser(value)), error: bearingStringValidator(value, props.range) }) })));
2914
3142
  };
2915
3143
 
2916
- var GridPopoverEditBearingLike = function (colDef) {
2917
- var _a;
2918
- return GridCell(__assign(__assign({ initialWidth: 65, maxWidth: 150, valueFormatter: bearingValueFormatter, cellClass: ((_a = colDef.cellEditorParams) === null || _a === void 0 ? void 0 : _a.multiEdit) ? GenericMultiEditCellClass : undefined }, colDef), ((colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) && {
2919
- cellEditorParams: __assign(__assign({}, colDef.cellEditorParams), { form: GridFormEditBearing })
2920
- })));
3144
+ var GridPopoverEditBearingLike = function (colDef, props) {
3145
+ return GridCell(__assign({ initialWidth: 65, maxWidth: 150, valueFormatter: bearingValueFormatter, cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined }, colDef), __assign({ editor: GridFormEditBearing }, props));
2921
3146
  };
2922
- var GridPopoverEditBearing = function (colDef) {
2923
- var init = GridPopoverEditBearingLike(colDef);
2924
- return __assign(__assign({}, init), { valueFormatter: bearingValueFormatter, cellEditorParams: __assign({ range: function (value) {
3147
+ var GridPopoverEditBearing = function (colDef, props) {
3148
+ return GridPopoverEditBearingLike(__assign({ valueFormatter: bearingValueFormatter }, colDef), {
3149
+ multiEdit: !!props.multiEdit,
3150
+ editorParams: __assign({ placeHolder: "Enter bearing correction", range: function (value) {
2925
3151
  if (value === null)
2926
- return "Bearing is required";
3152
+ return "Bearing correction is required";
2927
3153
  if (value >= 360)
2928
- return "Bearing must be less than 360 degrees";
3154
+ return "Bearing correction must be less than 360 degrees";
2929
3155
  if (value < 0)
2930
- return "Bearing must not be negative";
3156
+ return "Bearing correction must not be negative";
2931
3157
  return null;
2932
- } }, init.cellEditorParams) });
3158
+ } }, props.editorParams)
3159
+ });
2933
3160
  };
2934
- var GridPopoverEditBearingCorrection = function (colDef) {
2935
- var init = GridPopoverEditBearingLike(colDef);
2936
- return __assign(__assign({}, init), { valueFormatter: bearingCorrectionValueFormatter, cellEditorParams: __assign({ range: function (value) {
3161
+ var GridPopoverEditBearingCorrection = function (colDef, props) {
3162
+ return GridPopoverEditBearingLike(__assign({ valueFormatter: bearingCorrectionValueFormatter }, colDef), {
3163
+ multiEdit: !!props.multiEdit,
3164
+ editorParams: __assign({ placeHolder: "Enter bearing correction", range: function (value) {
2937
3165
  if (value === null)
2938
3166
  return "Bearing is required";
2939
3167
  if (value >= 360)
@@ -2941,189 +3169,18 @@ var GridPopoverEditBearingCorrection = function (colDef) {
2941
3169
  if (value <= -180)
2942
3170
  return "Bearing must be greater then -180 degrees";
2943
3171
  return null;
2944
- } }, init.cellEditorParams) });
2945
- };
2946
-
2947
- var MenuSeparatorString = "_____MENU_SEPARATOR_____";
2948
- Object.freeze({ value: MenuSeparatorString });
2949
- var GridFormDropDown = function (props) {
2950
- var popoverWrapper = useGridPopoverHook(props).popoverWrapper;
2951
- var formProps = props.formProps;
2952
- var _a = react.useContext(GridContext), updatingCells = _a.updatingCells, stopEditing = _a.stopEditing;
2953
- var _b = react.useState(""), filter = _b[0], setFilter = _b[1];
2954
- var _c = react.useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
2955
- var optionsInitialising = react.useRef(false);
2956
- var _d = react.useState(null), options = _d[0], setOptions = _d[1];
2957
- var selectItemHandler = react.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
2958
- var field;
2959
- return __generator(this, function (_a) {
2960
- switch (_a.label) {
2961
- case 0:
2962
- field = props.field;
2963
- return [4 /*yield*/, updatingCells({ selectedRows: props.selectedRows, field: field }, function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
2964
- var hasChanged;
2965
- return __generator(this, function (_a) {
2966
- switch (_a.label) {
2967
- case 0:
2968
- hasChanged = selectedRows.some(function (row) { return row[field] !== value; });
2969
- if (!hasChanged) return [3 /*break*/, 3];
2970
- if (!formProps.onSelectedItem) return [3 /*break*/, 2];
2971
- return [4 /*yield*/, formProps.onSelectedItem({ selectedRows: selectedRows, value: value })];
2972
- case 1:
2973
- _a.sent();
2974
- return [3 /*break*/, 3];
2975
- case 2:
2976
- selectedRows.forEach(function (row) { return (row[field] = value); });
2977
- _a.label = 3;
2978
- case 3: return [2 /*return*/, true];
2979
- }
2980
- });
2981
- }); })];
2982
- case 1: return [2 /*return*/, _a.sent()];
2983
- }
2984
- });
2985
- }); }, [formProps, props.field, props.selectedRows, updatingCells]);
2986
- var selectFilterHandler = react.useCallback(function (value) { return __awaiter(void 0, void 0, void 0, function () {
2987
- var field;
2988
- return __generator(this, function (_a) {
2989
- switch (_a.label) {
2990
- case 0:
2991
- field = props.field;
2992
- return [4 /*yield*/, updatingCells({ selectedRows: props.selectedRows, field: field }, function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
2993
- return __generator(this, function (_a) {
2994
- switch (_a.label) {
2995
- case 0:
2996
- if (!formProps.onSelectFilter) return [3 /*break*/, 2];
2997
- return [4 /*yield*/, formProps.onSelectFilter({ selectedRows: selectedRows, value: value })];
2998
- case 1:
2999
- _a.sent();
3000
- _a.label = 2;
3001
- case 2: return [2 /*return*/, true];
3002
- }
3003
- });
3004
- }); })];
3005
- case 1: return [2 /*return*/, _a.sent()];
3006
- }
3007
- });
3008
- }); }, [formProps, props.field, props.selectedRows, updatingCells]);
3009
- // Load up options list if it's async function
3010
- react.useEffect(function () {
3011
- var _a;
3012
- if (options || optionsInitialising.current)
3013
- return;
3014
- optionsInitialising.current = true;
3015
- var optionsConf = (_a = formProps.options) !== null && _a !== void 0 ? _a : [];
3016
- (function () { return __awaiter(void 0, void 0, void 0, function () {
3017
- var optionsList;
3018
- return __generator(this, function (_a) {
3019
- switch (_a.label) {
3020
- case 0:
3021
- if (!(typeof optionsConf == "function")) return [3 /*break*/, 2];
3022
- return [4 /*yield*/, optionsConf(props.selectedRows, filter)];
3023
- case 1:
3024
- optionsConf = _a.sent();
3025
- _a.label = 2;
3026
- case 2:
3027
- optionsList = optionsConf === null || optionsConf === void 0 ? void 0 : optionsConf.map(function (item) {
3028
- if (item == null || typeof item == "string" || typeof item == "number") {
3029
- item = { value: item, label: item, disabled: false };
3030
- }
3031
- return item;
3032
- });
3033
- if (formProps.filtered) {
3034
- // This is needed otherwise when filter input is rendered and sets autofocus
3035
- // the mouse up of the double click edit triggers the cell to cancel editing
3036
- lodashEs.delay(function () { return setOptions(optionsList); }, 100);
3037
- }
3038
- else {
3039
- setOptions(optionsList);
3040
- }
3041
- optionsInitialising.current = false;
3042
- return [2 /*return*/];
3043
- }
3044
- });
3045
- }); })();
3046
- }, [filter, options, formProps.filtered, formProps.options, props.selectedRows]);
3047
- // Local filtering
3048
- react.useEffect(function () {
3049
- if (formProps.filtered == "local") {
3050
- if (options == null)
3051
- return;
3052
- setFilteredValues(options
3053
- .map(function (option) {
3054
- if (option.label != null && typeof option.label !== "string") {
3055
- console.error("Cannot filter non-string labels", option);
3056
- return undefined;
3057
- }
3058
- var str = option.label || "";
3059
- return str.toLowerCase().indexOf(filter) === -1 ? option.value : undefined;
3060
- })
3061
- .filter(function (r) { return r !== undefined; }));
3062
- }
3063
- }, [formProps.filtered, filter, options]);
3064
- var researchOnFilterChange = debounce__default["default"](react.useCallback(function () {
3065
- setOptions(null);
3066
- }, []), 500);
3067
- var previousFilter = react.useRef(filter);
3068
- // Reload filtering
3069
- react.useEffect(function () {
3070
- if (previousFilter.current != filter && formProps.filtered == "reload") {
3071
- previousFilter.current = filter;
3072
- formProps.optionsRequestCancel && formProps.optionsRequestCancel();
3073
- researchOnFilterChange().then();
3074
- }
3075
- }, [filter, formProps, props, researchOnFilterChange]);
3076
- var onFilterKeyDown = react.useCallback(function (e) { return __awaiter(void 0, void 0, void 0, function () {
3077
- var activeOptions;
3078
- return __generator(this, function (_a) {
3079
- switch (_a.label) {
3080
- case 0:
3081
- if (!options)
3082
- return [2 /*return*/];
3083
- if (!(e.key == "Enter" || e.key == "Tab")) return [3 /*break*/, 5];
3084
- activeOptions = options.filter(function (option) { return !filteredValues.includes(option.value); });
3085
- if (!(activeOptions.length == 1)) return [3 /*break*/, 2];
3086
- return [4 /*yield*/, selectItemHandler(activeOptions[0].value)];
3087
- case 1:
3088
- _a.sent();
3089
- stopEditing();
3090
- return [3 /*break*/, 5];
3091
- case 2:
3092
- if (!formProps.onSelectFilter) return [3 /*break*/, 4];
3093
- return [4 /*yield*/, selectFilterHandler(filter)];
3094
- case 3:
3095
- _a.sent();
3096
- stopEditing();
3097
- return [3 /*break*/, 5];
3098
- case 4:
3099
- e.preventDefault();
3100
- e.stopPropagation();
3101
- _a.label = 5;
3102
- case 5: return [2 /*return*/];
3103
- }
3104
- });
3105
- }); }, [filteredValues, options, selectItemHandler, selectFilterHandler, stopEditing, filter, formProps]);
3106
- return popoverWrapper(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [formProps.filtered && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(FocusableItem, __assign({ className: "filter-item" }, { children: function (_a) {
3107
- var _b;
3108
- var ref = _a.ref;
3109
- 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 = formProps.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); } }) })));
3110
- } })), jsxRuntime.jsx(MenuDivider, {}, "$$divider_filter")] })), jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: !options }, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && jsxRuntime.jsx(MenuItem, { children: "[Empty]" }), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
3111
- var _a;
3112
- return item.value === MenuSeparatorString ? (jsxRuntime.jsx(MenuDivider, {}, "$$divider_".concat(index))) : filteredValues.includes(item.value) ? null : (jsxRuntime.jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () { return selectItemHandler(item.value); } }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(props.field, "-").concat(index)));
3113
- })] }) }))] }));
3172
+ } }, props.editorParams)
3173
+ });
3114
3174
  };
3115
3175
 
3116
- var GridPopoverEditDropDown = function (colDef) {
3117
- var _a;
3118
- return GridCell(__assign(__assign({ initialWidth: 65, maxWidth: 150, cellClass: ((_a = colDef.cellEditor) === null || _a === void 0 ? void 0 : _a.multiEdit) ? GenericMultiEditCellClass : undefined }, colDef), ((colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) && {
3119
- cellEditorParams: __assign(__assign({}, colDef.cellEditorParams), { form: GridFormDropDown })
3120
- })));
3176
+ var GridPopoverEditDropDown = function (colDef, props) {
3177
+ return GridCell(__assign({ initialWidth: 65, maxWidth: 150, cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined }, colDef), __assign({ editor: GridFormDropDown }, props));
3121
3178
  };
3122
3179
 
3123
- var GridFormMessage = function (props) {
3124
- var formProps = props.formProps;
3180
+ var GridFormMessage = function (_props) {
3181
+ var props = _props;
3125
3182
  var _a = react.useState(null), message = _a[0], setMessage = _a[1];
3126
- var popoverWrapper = useGridPopoverHook(props).popoverWrapper;
3183
+ var popoverWrapper = useGridPopoverHook().popoverWrapper;
3127
3184
  react.useEffect(function () {
3128
3185
  (function () { return __awaiter(void 0, void 0, void 0, function () {
3129
3186
  var _a;
@@ -3131,24 +3188,19 @@ var GridFormMessage = function (props) {
3131
3188
  switch (_b.label) {
3132
3189
  case 0:
3133
3190
  _a = setMessage;
3134
- return [4 /*yield*/, formProps.message(props.selectedRows, props.cellEditorParams)];
3191
+ return [4 /*yield*/, props.message(props)];
3135
3192
  case 1:
3136
3193
  _a.apply(void 0, [_b.sent()]);
3137
3194
  return [2 /*return*/];
3138
3195
  }
3139
3196
  });
3140
3197
  }); })().then();
3141
- }, [formProps, props.selectedRows, props]);
3198
+ }, [props]);
3142
3199
  return popoverWrapper(jsxRuntime.jsx(ComponentLoadingWrapper, __assign({ loading: message === null }, { children: jsxRuntime.jsx("div", __assign({ style: { maxWidth: 400 }, className: "Grid-popoverContainer" }, { children: message })) })));
3143
3200
  };
3144
3201
 
3145
- var GridPopoverMessage = function (colDef) {
3146
- var _a;
3147
- return GridCell(__assign(__assign(__assign({ maxWidth: 140 }, colDef), { cellRendererParams: (_a = colDef.cellRendererParams) !== null && _a !== void 0 ? _a : {
3148
- singleClickEdit: true
3149
- } }), ((colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) && {
3150
- cellEditorParams: __assign(__assign({}, colDef.cellEditorParams), { form: GridFormMessage })
3151
- })));
3202
+ var GridPopoverMessage = function (colDef, props) {
3203
+ return GridCell(__assign(__assign({ maxWidth: 140 }, colDef), { cellRendererParams: __assign({ singleClickEdit: true }, colDef.cellRendererParams) }), __assign({ editor: GridFormMessage }, props));
3152
3204
  };
3153
3205
 
3154
3206
  var useGenerateOrDefaultId = function (idFromProps) {
@@ -3161,22 +3213,22 @@ var TextAreaInput = function (props) {
3161
3213
  return (jsxRuntime.jsxs("div", __assign({ className: clsx("LuiTextAreaInput Grid-popoverContainer", ((_b = props.inputProps) === null || _b === void 0 ? void 0 : _b.disabled) ? "isDisabled" : "", (props === null || props === void 0 ? void 0 : props.error) ? "hasError" : "") }, { children: [jsxRuntime.jsxs("label", __assign({ htmlFor: id }, { children: [props.mandatory && jsxRuntime.jsx("span", __assign({ className: "LuiTextAreaInput-mandatory" }, { children: "*" })), props.label && jsxRuntime.jsx("span", __assign({ className: "LuiTextAreaInput-label" }, { children: props.label })), jsxRuntime.jsxs("div", __assign({ className: "LuiTextAreaInput-wrapper" }, { children: [" ", jsxRuntime.jsx("textarea", __assign({ id: id, value: props.value, onChange: props.onChange, rows: 5 }, props.inputProps))] }))] })), 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] })))] })));
3162
3214
  };
3163
3215
 
3164
- var GridFormTextArea = function (props) {
3216
+ var GridFormTextArea = function (_props) {
3165
3217
  var _a, _b;
3166
- var formProps = props.formProps;
3218
+ var props = _props;
3167
3219
  var _c = react.useState((_a = props.value) !== null && _a !== void 0 ? _a : ""), value = _c[0], setValue = _c[1];
3168
3220
  var invalid = react.useCallback(function () {
3169
- if (formProps.required && value.length == 0) {
3221
+ if (props.required && value.length == 0) {
3170
3222
  return "Some text is required";
3171
3223
  }
3172
- if (formProps.maxlength && value.length > formProps.maxlength) {
3173
- return "Text must be no longer than ".concat(formProps.maxlength, " characters");
3224
+ if (props.maxlength && value.length > props.maxlength) {
3225
+ return "Text must be no longer than ".concat(props.maxlength, " characters");
3174
3226
  }
3175
- if (formProps.validate) {
3176
- return formProps.validate(value);
3227
+ if (props.validate) {
3228
+ return props.validate(value);
3177
3229
  }
3178
3230
  return null;
3179
- }, [formProps, value]);
3231
+ }, [props, value]);
3180
3232
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3181
3233
  var field;
3182
3234
  return __generator(this, function (_a) {
@@ -3186,8 +3238,8 @@ var GridFormTextArea = function (props) {
3186
3238
  return [2 /*return*/, false];
3187
3239
  if (props.value === (value !== null && value !== void 0 ? value : ""))
3188
3240
  return [2 /*return*/, true];
3189
- if (!formProps.onSave) return [3 /*break*/, 2];
3190
- return [4 /*yield*/, formProps.onSave(selectedRows, value)];
3241
+ if (!props.onSave) return [3 /*break*/, 2];
3242
+ return [4 /*yield*/, props.onSave(selectedRows, value)];
3191
3243
  case 1: return [2 /*return*/, _a.sent()];
3192
3244
  case 2:
3193
3245
  field = props.field;
@@ -3199,35 +3251,33 @@ var GridFormTextArea = function (props) {
3199
3251
  return [2 /*return*/, true];
3200
3252
  }
3201
3253
  });
3202
- }); }, [formProps, invalid, props.field, props.value, value]);
3203
- var popoverWrapper = useGridPopoverHook(props, save).popoverWrapper;
3204
- return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_b = formProps.width) !== null && _b !== void 0 ? _b : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextAreaInput, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), inputProps: { placeholder: formProps.placeholder } }) })));
3254
+ }); }, [props, invalid, value]);
3255
+ var popoverWrapper = useGridPopoverHook({ save: save }).popoverWrapper;
3256
+ 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(TextAreaInput, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), inputProps: { placeholder: props.placeholder } }) })));
3205
3257
  };
3206
3258
 
3207
- var GridPopoverTextArea = function (colDef) {
3208
- return GridCell(__assign(__assign({ maxWidth: 260 }, colDef), ((colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) && {
3209
- cellEditorParams: __assign(__assign({ width: 260 }, colDef.cellEditorParams), { form: GridFormTextArea })
3210
- })));
3259
+ var GridPopoverTextArea = function (colDef, params) {
3260
+ return GridCell(__assign({ maxWidth: 260 }, colDef), __assign({ editor: GridFormTextArea }, params));
3211
3261
  };
3212
3262
 
3213
- var GridFormTextInput = function (props) {
3263
+ var GridFormTextInput = function (_props) {
3214
3264
  var _a;
3215
- var formProps = props.formProps;
3265
+ var props = _props;
3216
3266
  var initValue = props.value == null ? "" : "".concat(props.value);
3217
3267
  var _b = react.useState(initValue), value = _b[0], setValue = _b[1];
3218
3268
  var invalid = react.useCallback(function () {
3219
3269
  var trimmedValue = value.trim();
3220
- if (formProps.required && trimmedValue.length == 0) {
3270
+ if (props.required && trimmedValue.length == 0) {
3221
3271
  return "Some text is required";
3222
3272
  }
3223
- if (formProps.maxlength && trimmedValue.length > formProps.maxlength) {
3224
- return "Text must be no longer than ".concat(formProps.maxlength, " characters");
3273
+ if (props.maxlength && trimmedValue.length > props.maxlength) {
3274
+ return "Text must be no longer than ".concat(props.maxlength, " characters");
3225
3275
  }
3226
- if (formProps.validate) {
3227
- return formProps.validate(trimmedValue);
3276
+ if (props.validate) {
3277
+ return props.validate(trimmedValue, props.data);
3228
3278
  }
3229
3279
  return null;
3230
- }, [formProps, value]);
3280
+ }, [props, value]);
3231
3281
  var save = react.useCallback(function (selectedRows) { return __awaiter(void 0, void 0, void 0, function () {
3232
3282
  var trimmedValue, field;
3233
3283
  return __generator(this, function (_a) {
@@ -3238,8 +3288,8 @@ var GridFormTextInput = function (props) {
3238
3288
  trimmedValue = value.trim();
3239
3289
  if (initValue === trimmedValue)
3240
3290
  return [2 /*return*/, true];
3241
- if (!formProps.onSave) return [3 /*break*/, 2];
3242
- return [4 /*yield*/, formProps.onSave(selectedRows, trimmedValue)];
3291
+ if (!props.onSave) return [3 /*break*/, 2];
3292
+ return [4 /*yield*/, props.onSave(selectedRows, trimmedValue)];
3243
3293
  case 1: return [2 /*return*/, _a.sent()];
3244
3294
  case 2:
3245
3295
  field = props.field;
@@ -3251,21 +3301,19 @@ var GridFormTextInput = function (props) {
3251
3301
  return [2 /*return*/, true];
3252
3302
  }
3253
3303
  });
3254
- }); }, [invalid, value, initValue, formProps, props.field]);
3255
- var _c = useGridPopoverHook(props, save), popoverWrapper = _c.popoverWrapper, triggerSave = _c.triggerSave;
3256
- return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_a = formProps.width) !== null && _a !== void 0 ? _a : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: formProps.units, inputProps: {
3304
+ }); }, [invalid, value, initValue, props]);
3305
+ var _c = useGridPopoverHook({ save: save }), popoverWrapper = _c.popoverWrapper, triggerSave = _c.triggerSave;
3306
+ return popoverWrapper(jsxRuntime.jsx("div", __assign({ style: { display: "flex", flexDirection: "row", width: (_a = props.width) !== null && _a !== void 0 ? _a : 240 }, className: "FormTest" }, { children: jsxRuntime.jsx(TextInputFormatted, { value: value, onChange: function (e) { return setValue(e.target.value); }, error: invalid(), formatted: props.units, inputProps: {
3257
3307
  style: { width: "100%" },
3258
- placeholder: formProps.placeholder,
3308
+ placeholder: props.placeholder,
3259
3309
  onKeyDown: function (e) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
3260
3310
  return [2 /*return*/, e.key === "Enter" && triggerSave().then()];
3261
3311
  }); }); }
3262
3312
  } }) })));
3263
3313
  };
3264
3314
 
3265
- var GridPopoverTextInput = function (colDef) {
3266
- return GridCell(__assign(__assign({ maxWidth: 140 }, colDef), ((colDef === null || colDef === void 0 ? void 0 : colDef.cellEditorParams) && {
3267
- cellEditorParams: __assign(__assign({ width: 240 }, colDef.cellEditorParams), { form: GridFormTextInput })
3268
- })));
3315
+ var GridPopoverTextInput = function (colDef, params) {
3316
+ return GridCell(__assign({ maxWidth: 140 }, colDef), __assign({ editor: GridFormTextInput }, params));
3269
3317
  };
3270
3318
 
3271
3319
  var GridSubComponentTextArea = function (props) {
@@ -3280,7 +3328,6 @@ exports.ComponentLoadingWrapper = ComponentLoadingWrapper;
3280
3328
  exports.ControlledMenu = ControlledMenu;
3281
3329
  exports.FocusableItem = FocusableItem;
3282
3330
  exports.GenericCellEditorComponent = GenericCellEditorComponent;
3283
- exports.GenericCellEditorComponentFr = GenericCellEditorComponentFr;
3284
3331
  exports.GenericMultiEditCellClass = GenericMultiEditCellClass;
3285
3332
  exports.Grid = Grid;
3286
3333
  exports.GridCell = GridCell;
@@ -3308,18 +3355,23 @@ exports.GridPopoverTextInput = GridPopoverTextInput;
3308
3355
  exports.GridRenderPopoutMenuCell = GridRenderPopoutMenuCell;
3309
3356
  exports.GridRendererGenericCell = GridRendererGenericCell;
3310
3357
  exports.GridSubComponentTextArea = GridSubComponentTextArea;
3358
+ exports.GridUpdatingContext = GridUpdatingContext;
3359
+ exports.GridUpdatingContextProvider = GridUpdatingContextProvider;
3311
3360
  exports.Menu = Menu;
3312
3361
  exports.MenuButton = MenuButton;
3313
3362
  exports.MenuDivider = MenuDivider;
3314
3363
  exports.MenuGroup = MenuGroup;
3315
3364
  exports.MenuHeader = MenuHeader;
3365
+ exports.MenuHeaderItem = MenuHeaderItem;
3366
+ exports.MenuHeaderString = MenuHeaderString;
3316
3367
  exports.MenuItem = MenuItem;
3317
3368
  exports.MenuRadioGroup = MenuRadioGroup;
3369
+ exports.MenuSeparator = MenuSeparator;
3370
+ exports.MenuSeparatorString = MenuSeparatorString;
3371
+ exports.PopoutMenuSeparator = PopoutMenuSeparator;
3318
3372
  exports.SubMenu = SubMenu;
3319
3373
  exports.TextAreaInput = TextAreaInput;
3320
3374
  exports.TextInputFormatted = TextInputFormatted;
3321
- exports.UpdatingContext = UpdatingContext;
3322
- exports.UpdatingContextProvider = UpdatingContextProvider;
3323
3375
  exports.bearingCorrectionValueFormatter = bearingCorrectionValueFormatter;
3324
3376
  exports.bearingNumberParser = bearingNumberParser;
3325
3377
  exports.bearingStringValidator = bearingStringValidator;