@linzjs/step-ag-grid 2.1.2 → 2.2.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 (72) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +122 -25
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/Grid.d.ts +1 -0
  5. package/dist/src/components/GridCell.d.ts +1 -1
  6. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -1
  7. package/dist/src/components/gridForm/GridFormMessage.d.ts +1 -1
  8. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
  9. package/dist/src/components/gridForm/GridFormPopoutMenu.d.ts +1 -1
  10. package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -1
  11. package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
  12. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +1 -1
  13. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +1 -1
  14. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +1 -1
  15. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +1 -1
  16. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +1 -1
  17. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +1 -1
  18. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +1 -1
  19. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -1
  20. package/dist/src/contexts/GridContext.d.ts +1 -1
  21. package/dist/src/index.d.ts +29 -28
  22. package/dist/src/lui/ActionButton.d.ts +15 -0
  23. package/dist/src/lui/reactUtils.d.ts +6 -0
  24. package/dist/src/lui/reactUtils.test.d.ts +1 -0
  25. package/dist/src/lui/stateDeferredHook.d.ts +4 -0
  26. package/dist/src/lui/timeoutHook.d.ts +8 -0
  27. package/dist/src/lui/timeoutHook.test.d.ts +1 -0
  28. package/dist/step-ag-grid.esm.js +123 -27
  29. package/dist/step-ag-grid.esm.js.map +1 -1
  30. package/package.json +6 -4
  31. package/src/components/Grid.tsx +5 -4
  32. package/src/components/GridCell.tsx +7 -7
  33. package/src/components/GridPopoverHook.tsx +3 -3
  34. package/src/components/PostSortRowsHook.ts +8 -2
  35. package/src/components/gridForm/GridFormDropDown.tsx +2 -2
  36. package/src/components/gridForm/GridFormEditBearing.tsx +2 -2
  37. package/src/components/gridForm/GridFormMessage.tsx +1 -1
  38. package/src/components/gridForm/GridFormMultiSelect.tsx +3 -3
  39. package/src/components/gridForm/GridFormPopoutMenu.tsx +3 -3
  40. package/src/components/gridForm/GridFormTextArea.tsx +1 -1
  41. package/src/components/gridForm/GridFormTextInput.tsx +1 -1
  42. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +1 -3
  43. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +2 -4
  44. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +1 -3
  45. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +1 -1
  46. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +1 -1
  47. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +1 -1
  48. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +1 -1
  49. package/src/components/gridRender/GridRenderGenericCell.tsx +2 -2
  50. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +1 -1
  51. package/src/contexts/GridContext.tsx +1 -1
  52. package/src/contexts/GridContextProvider.tsx +2 -2
  53. package/src/contexts/GridPopoverContextProvider.tsx +2 -2
  54. package/src/index.ts +34 -32
  55. package/src/lui/ActionButton.scss +32 -0
  56. package/src/lui/ActionButton.tsx +76 -0
  57. package/src/lui/reactUtils.test.tsx +47 -0
  58. package/src/lui/reactUtils.tsx +14 -0
  59. package/src/lui/stateDeferredHook.tsx +29 -0
  60. package/src/lui/timeoutHook.test.tsx +38 -0
  61. package/src/lui/timeoutHook.tsx +40 -0
  62. package/src/react-menu3/components/ControlledMenu.tsx +1 -1
  63. package/src/stories/components/ActionButton.stories.tsx +33 -0
  64. package/src/stories/{components → grid}/FormTest.scss +0 -0
  65. package/src/stories/{components → grid}/FormTest.tsx +4 -4
  66. package/src/stories/{components → grid}/GridPopoutBearing.stories.tsx +13 -16
  67. package/src/stories/{components → grid}/GridPopoutEditDropDown.stories.tsx +27 -30
  68. package/src/stories/{components → grid}/GridPopoutEditGeneric.stories.tsx +10 -13
  69. package/src/stories/{components → grid}/GridPopoutEditGenericTextArea.stories.tsx +64 -25
  70. package/src/stories/{components → grid}/GridPopoutEditMultiSelect.stories.tsx +15 -18
  71. package/src/stories/{components → grid}/GridReadOnly.stories.tsx +13 -15
  72. package/src/stories/{components → react-menu}/ReactMenu.stories.tsx +2 -2
@@ -16,6 +16,7 @@ export interface GridProps {
16
16
  columnDefs: GridOptions["columnDefs"];
17
17
  rowData: GridOptions["rowData"];
18
18
  noRowsOverlayText?: string;
19
+ postSortRows?: GridOptions["postSortRows"];
19
20
  }
20
21
  /**
21
22
  * Wrapper for AgGrid to add commonly used functionality.
@@ -11,7 +11,7 @@ export declare const GridCellRenderer: (props: ICellRendererParams) => JSX.Eleme
11
11
  export interface ColDefT<RowType extends GridBaseRow> extends ColDef {
12
12
  _?: RowType;
13
13
  }
14
- export declare const GridCell: <RowType extends GridBaseRow, Props>(props: GenericCellColDef<RowType>, custom?: {
14
+ export declare const GridCell: <RowType extends GridBaseRow, Props extends CellEditorCommon>(props: GenericCellColDef<RowType>, custom?: {
15
15
  multiEdit?: boolean | undefined;
16
16
  editor?: ((editorProps: Props) => JSX.Element) | undefined;
17
17
  editorParams?: Props | undefined;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import "../../styles/GridFormEditBearing.scss";
3
3
  import { GridBaseRow } from "../Grid";
4
- import { CellEditorCommon } from "@components/GridCell";
4
+ import { CellEditorCommon } from "../GridCell";
5
5
  export interface GridFormEditBearingProps<RowType extends GridBaseRow> extends CellEditorCommon {
6
6
  placeHolder?: string;
7
7
  range?: (value: number | null) => string | null;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { GridBaseRow } from "../Grid";
3
- import { CellEditorCommon, CellParams } from "@components/GridCell";
3
+ import { CellEditorCommon, CellParams } from "../GridCell";
4
4
  export interface GridFormMessageProps<RowType extends GridBaseRow> extends CellEditorCommon {
5
5
  message: (cellParams: CellParams<RowType>) => Promise<string | JSX.Element> | string | JSX.Element;
6
6
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import "../../styles/GridFormMultiSelect.scss";
3
3
  import { GridBaseRow } from "../Grid";
4
- import { CellEditorCommon } from "@components/GridCell";
4
+ import { CellEditorCommon } from "../GridCell";
5
5
  interface MultiFinalSelectOption<ValueType> {
6
6
  value: ValueType;
7
7
  label?: JSX.Element | string;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { GridBaseRow } from "../Grid";
3
- import { CellEditorCommon } from "@components/GridCell";
3
+ import { CellEditorCommon } from "../GridCell";
4
4
  export interface GridFormPopoutMenuProps<RowType extends GridBaseRow> extends CellEditorCommon {
5
5
  options: (selectedRows: RowType[]) => Promise<MenuOption<RowType>[]>;
6
6
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { GridBaseRow } from "../Grid";
3
- import { CellEditorCommon } from "@components/GridCell";
3
+ import { CellEditorCommon } from "../GridCell";
4
4
  export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends CellEditorCommon {
5
5
  placeholder?: string;
6
6
  required?: boolean;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { GridBaseRow } from "../Grid";
3
- import { CellEditorCommon } from "@components/GridCell";
3
+ import { CellEditorCommon } from "../GridCell";
4
4
  export interface GridFormTextInputProps<RowType extends GridBaseRow> extends CellEditorCommon {
5
5
  placeholder?: string;
6
6
  units?: string;
@@ -1,5 +1,5 @@
1
1
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { GridFormMultiSelectProps } from "../gridForm/GridFormMultiSelect";
4
- import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
4
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
5
5
  export declare const GridPopoutEditMultiSelect: <RowType extends GridBaseRow, ValueType>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormMultiSelectProps<RowType, ValueType>>) => ColDefT<RowType>;
@@ -1,7 +1,7 @@
1
1
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
2
2
  import { GridFormEditBearingProps } from "../gridForm/GridFormEditBearing";
3
3
  import { GridBaseRow } from "../Grid";
4
- import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
4
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
5
5
  export declare const GridPopoverEditBearingLike: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>) => ColDefT<RowType>;
6
6
  export declare const GridPopoverEditBearing: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>) => ColDefT<RowType>;
7
7
  export declare const GridPopoverEditBearingCorrection: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormEditBearingProps<RowType>>) => ColDefT<RowType>;
@@ -1,5 +1,5 @@
1
1
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { GridFormPopoutDropDownProps } from "../gridForm/GridFormDropDown";
4
- import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
4
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
5
5
  export declare const GridPopoverEditDropDown: <RowType extends GridBaseRow, ValueType>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormPopoutDropDownProps<RowType, ValueType>>) => ColDefT<RowType>;
@@ -2,7 +2,7 @@ import "./GridPopoverMenu.scss";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
4
4
  import { GridFormPopoutMenuProps } from "../gridForm/GridFormPopoutMenu";
5
- import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
5
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
6
6
  /**
7
7
  * Popout burger menu
8
8
  */
@@ -1,5 +1,5 @@
1
1
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
2
2
  import { GridFormMessageProps } from "../gridForm/GridFormMessage";
3
3
  import { GridBaseRow } from "../Grid";
4
- import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
4
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
5
5
  export declare const GridPopoverMessage: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, props: GenericCellEditorProps<GridFormMessageProps<RowType>>) => ColDefT<RowType>;
@@ -1,5 +1,5 @@
1
1
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { GridFormTextAreaProps } from "../gridForm/GridFormTextArea";
4
- import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
4
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
5
5
  export declare const GridPopoverTextArea: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, params: GenericCellEditorProps<GridFormTextAreaProps<RowType>>) => ColDefT<RowType>;
@@ -1,5 +1,5 @@
1
1
  import { ColDefT, GenericCellEditorProps } from "../GridCell";
2
2
  import { GridBaseRow } from "../Grid";
3
3
  import { GridFormTextInputProps } from "../gridForm/GridFormTextInput";
4
- import { GenericCellColDef } from "@components/gridRender/GridRenderGenericCell";
4
+ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell";
5
5
  export declare const GridPopoverTextInput: <RowType extends GridBaseRow>(colDef: GenericCellColDef<RowType>, params: GenericCellEditorProps<GridFormTextInputProps<RowType>>) => ColDefT<RowType>;
@@ -2,7 +2,7 @@
2
2
  import "../../styles/GridRenderGenericCell.scss";
3
3
  import { ICellRendererParams } from "ag-grid-community";
4
4
  import { GridBaseRow } from "../Grid";
5
- import { ColDefT } from "@components/GridCell";
5
+ import { ColDefT } from "../GridCell";
6
6
  export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
7
7
  data: RowType;
8
8
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { GridApi } from "ag-grid-community";
3
- import { GridBaseRow } from "@components/Grid";
3
+ import { GridBaseRow } from "../components/Grid";
4
4
  export interface GridContextType {
5
5
  gridReady: () => boolean;
6
6
  setGridApi: (gridApi: GridApi | undefined) => void;
@@ -1,31 +1,32 @@
1
- export * from "@react-menu3";
1
+ export * from "./react-menu3/index";
2
2
  export * from "./react-menu3/types";
3
- export * from "@contexts/GridUpdatingContext";
4
- export * from "@contexts/GridUpdatingContextProvider";
5
- export * from "@contexts/GridContext";
6
- export * from "@contexts/GridContextProvider";
7
- export type { GridBaseRow } from "@components/Grid";
8
- export { Grid } from "@components/Grid";
9
- export * from "@components/GridCell";
10
- export { GridIcon } from "@components/GridIcon";
11
- export { ComponentLoadingWrapper } from "@components/ComponentLoadingWrapper";
12
- export { GenericMultiEditCellClass } from "@components/GenericCellClass";
13
- export { GridLoadableCell } from "@components/GridLoadableCell";
14
- export { useGridPopoverHook } from "@components/GridPopoverHook";
15
- export { usePostSortRowsHook } from "@components/PostSortRowsHook";
16
- export { GridRendererGenericCell } from "@components/gridRender/GridRenderGenericCell";
17
- export { GridRenderPopoutMenuCell } from "@components/gridRender/GridRenderPopoutMenuCell";
18
- export { GridPopoutEditMultiSelect } from "@components/gridPopoverEdit/GridPopoutEditMultiSelect";
19
- export { GridPopoverMenu } from "@components/gridPopoverEdit/GridPopoverMenu";
20
- export { GridPopoverEditBearing } from "@components/gridPopoverEdit/GridPopoverEditBearing";
21
- export { GridPopoverEditBearingCorrection } from "@components/gridPopoverEdit/GridPopoverEditBearing";
22
- export { GridPopoverEditDropDown } from "@components/gridPopoverEdit/GridPopoverEditDropDown";
23
- export { GridPopoverMessage } from "@components/gridPopoverEdit/GridPopoverMessage";
24
- export { GridPopoverTextArea } from "@components/gridPopoverEdit/GridPopoverTextArea";
25
- export { GridPopoverTextInput } from "@components/gridPopoverEdit/GridPopoverTextInput";
26
- export { GridHeaderSelect } from "@components/gridHeader/GridHeaderSelect";
3
+ export * from "./contexts/GridUpdatingContext";
4
+ export * from "./contexts/GridUpdatingContextProvider";
5
+ export * from "./contexts/GridContext";
6
+ export * from "./contexts/GridContextProvider";
7
+ export type { GridBaseRow } from "./components/Grid";
8
+ export { Grid } from "./components/Grid";
9
+ export * from "./components/GridCell";
10
+ export { GridIcon } from "./components/GridIcon";
11
+ export { ComponentLoadingWrapper } from "./components/ComponentLoadingWrapper";
12
+ export { GenericMultiEditCellClass } from "./components/GenericCellClass";
13
+ export { GridLoadableCell } from "./components/GridLoadableCell";
14
+ export { useGridPopoverHook } from "./components/GridPopoverHook";
15
+ export { usePostSortRowsHook } from "./components/PostSortRowsHook";
16
+ export * from "./components/gridRender/GridRenderGenericCell";
17
+ export { GridRenderPopoutMenuCell } from "./components/gridRender/GridRenderPopoutMenuCell";
18
+ export { GridPopoutEditMultiSelect } from "./components/gridPopoverEdit/GridPopoutEditMultiSelect";
19
+ export { GridPopoverMenu } from "./components/gridPopoverEdit/GridPopoverMenu";
20
+ export { GridPopoverEditBearing } from "./components/gridPopoverEdit/GridPopoverEditBearing";
21
+ export { GridPopoverEditBearingCorrection } from "./components/gridPopoverEdit/GridPopoverEditBearing";
22
+ export { GridPopoverEditDropDown } from "./components/gridPopoverEdit/GridPopoverEditDropDown";
23
+ export { GridPopoverMessage } from "./components/gridPopoverEdit/GridPopoverMessage";
24
+ export { GridPopoverTextArea } from "./components/gridPopoverEdit/GridPopoverTextArea";
25
+ export { GridPopoverTextInput } from "./components/gridPopoverEdit/GridPopoverTextInput";
26
+ export { GridHeaderSelect } from "./components/gridHeader/GridHeaderSelect";
27
27
  export { TextAreaInput } from "./lui/TextAreaInput";
28
28
  export { TextInputFormatted } from "./lui/TextInputFormatted";
29
- export { GridSubComponentTextArea } from "@components/GridSubComponentTextArea";
30
- export * from "@utils/bearing";
31
- export * from "@utils/util";
29
+ export { GridSubComponentTextArea } from "./components/GridSubComponentTextArea";
30
+ export * from "./lui/ActionButton";
31
+ export * from "./utils/bearing";
32
+ export * from "./utils/util";
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import "./ActionButton.scss";
3
+ import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
4
+ export interface ActionButtonProps {
5
+ icon: IconName;
6
+ name: string;
7
+ inProgressName?: string;
8
+ title?: string;
9
+ dataTestId?: string;
10
+ size?: "xs" | "sm" | "md" | "lg" | "xl" | "ns";
11
+ className?: string;
12
+ onClick?: () => void;
13
+ inProgress?: boolean;
14
+ }
15
+ export declare const ActionButton: ({ icon, name, inProgressName, dataTestId, inProgress, className, title, onClick, size, }: ActionButtonProps) => JSX.Element;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Track previous values of states.
3
+ *
4
+ * @param value Value to track.
5
+ */
6
+ export declare const usePrevious: <T extends unknown>(value: T) => T | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Defers state change up to a minimum time since last state change.
3
+ */
4
+ export declare const useStateDeferred: <T extends unknown>(initialValue: T) => [T, (v: T) => void, (v: T, w: number) => void];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Cancels timeouts on scope being destroyed.
3
+ *
4
+ * This could almost be a debounce, but debounce tracks by function reference, this tracks by hook reference.
5
+ * This could have been implemented using debounce if the callers function was wrapped in useCallback,
6
+ * but there's no way to enforce that, so it would lead to bugs.
7
+ */
8
+ export declare const useTimeoutHook: () => (fn: () => void, waitTimeMs: number) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -3,7 +3,7 @@ import { unstable_batchedUpdates, flushSync, createPortal } from 'react-dom';
3
3
  import { findIndex, isEmpty, castArray, remove, flatten, delay, sortBy, last, difference, xorBy, fromPairs } from 'lodash-es';
4
4
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
5
5
  import { AgGridReact } from 'ag-grid-react';
6
- import { LuiMiniSpinner, LuiIcon, LuiCheckboxInput } from '@linzjs/lui';
6
+ import { LuiMiniSpinner, LuiIcon, LuiCheckboxInput, LuiButton } from '@linzjs/lui';
7
7
 
8
8
  // Generate className following BEM methodology: http://getbem.com/naming/
9
9
  // Modifier value can be one of the following types: boolean, string, undefined
@@ -2216,7 +2216,11 @@ var usePostSortRowsHook = function (_a) {
2216
2216
  var restorePreviousSortColumnState = function () { return columnApi.applyColumnState({ state: previousColSort.current }); };
2217
2217
  var hasNewRows = function () { return nodes.some(function (row) { return previousRowSortIndex[row.data.id] == null; }); };
2218
2218
  var sortIsStale = function () {
2219
- return !hasNewRows() && nodes.some(function (row, index) { var _a; return ![null, index].includes((_a = previousRowSortIndex[row.data.id]) !== null && _a !== void 0 ? _a : null); });
2219
+ // If there are new rows we want to them to be at the bottom of the grid, so we treat it as sort not stale
2220
+ if (hasNewRows())
2221
+ return false;
2222
+ // Otherwise check if the stored sort index matches the new sort index
2223
+ return nodes.some(function (node, index) { return previousRowSortIndex[node.data.id] != index; });
2220
2224
  };
2221
2225
  var sortNodesByPreviousSort = function () {
2222
2226
  return nodes.sort(function (a, b) {
@@ -2272,6 +2276,7 @@ var usePostSortRowsHook = function (_a) {
2272
2276
  if (!sortWasStale.current) {
2273
2277
  // backup sort state, so we can restore it when sort is clicked on a stale column
2274
2278
  previousColSort.current = copyCurrentSortSettings();
2279
+ backupSortOrder();
2275
2280
  sortWasStale.current = true;
2276
2281
  setStaleGrid(true);
2277
2282
  }
@@ -2321,12 +2326,12 @@ var GridHeaderSelect = function (_a) {
2321
2326
  * Wrapper for AgGrid to add commonly used functionality.
2322
2327
  */
2323
2328
  var Grid = function (params) {
2324
- var _a;
2325
- var _b = useContext(GridContext), gridReady = _b.gridReady, setGridApi = _b.setGridApi, setQuickFilter = _b.setQuickFilter, ensureRowVisible = _b.ensureRowVisible, selectRowsById = _b.selectRowsById, ensureSelectedRowIsVisible = _b.ensureSelectedRowIsVisible, sizeColumnsToFit = _b.sizeColumnsToFit;
2329
+ var _a, _b;
2330
+ var _c = useContext(GridContext), gridReady = _c.gridReady, setGridApi = _c.setGridApi, setQuickFilter = _c.setQuickFilter, ensureRowVisible = _c.ensureRowVisible, selectRowsById = _c.selectRowsById, ensureSelectedRowIsVisible = _c.ensureSelectedRowIsVisible, sizeColumnsToFit = _c.sizeColumnsToFit;
2326
2331
  var checkUpdating = useContext(GridUpdatingContext).checkUpdating;
2327
- var _c = useState(""), internalQuickFilter = _c[0], setInternalQuickFilter = _c[1];
2332
+ var _d = useState(""), internalQuickFilter = _d[0], setInternalQuickFilter = _d[1];
2328
2333
  var lastSelectedIds = useRef([]);
2329
- var _d = useState(false), staleGrid = _d[0], setStaleGrid = _d[1];
2334
+ var _e = useState(false), staleGrid = _e[0], setStaleGrid = _e[1];
2330
2335
  var postSortRows = usePostSortRowsHook({ setStaleGrid: setStaleGrid });
2331
2336
  /**
2332
2337
  * AgGrid checkbox select does not pass clicks within cell but not on the checkbox to checkbox.
@@ -2470,7 +2475,7 @@ var Grid = function (params) {
2470
2475
  }, [columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length, sizeColumnsToFit]);
2471
2476
  return (jsxs("div", __assign({ "data-testid": params.dataTestId, className: clsx("Grid-container", "ag-theme-alpine", staleGrid && "Grid-sortIsStale") }, { children: [params.quickFilter && (jsx("div", __assign({ className: "Grid-quickFilter" }, { children: jsx("input", { "aria-label": "Search", className: "lui-margin-top-xxs lui-margin-bottom-xxs Grid-quickFilterBox", type: "text", placeholder: (_a = params.quickFilterPlaceholder) !== null && _a !== void 0 ? _a : "Search...", value: internalQuickFilter, onChange: function (event) {
2472
2477
  setInternalQuickFilter(event.target.value);
2473
- } }) }))), jsx(AgGridReact, { getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyDown: onCellKeyDown, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
2478
+ } }) }))), jsx(AgGridReact, { getRowId: function (params) { return "".concat(params.data.id); }, suppressRowClickSelection: true, rowSelection: "multiple", suppressBrowserResizeObserver: true, colResizeDefault: "shift", onFirstDataRendered: sizeColumnsToFit, onGridSizeChanged: sizeColumnsToFit, suppressClickEdit: true, onCellKeyDown: onCellKeyDown, onCellClicked: onCellClicked, onCellDoubleClicked: onCellDoubleClick, onCellEditingStarted: refreshSelectedRows, onCellEditingStopped: onCellEditingStopped, domLayout: params.domLayout, columnDefs: columnDefs, rowData: params.rowData, noRowsOverlayComponent: noRowsOverlayComponent, onGridReady: onGridReady, onSortChanged: ensureSelectedRowIsVisible, postSortRows: (_b = params.postSortRows) !== null && _b !== void 0 ? _b : postSortRows, onSelectionChanged: synchroniseExternalStateToGridSelection })] })));
2474
2479
  };
2475
2480
 
2476
2481
  var GenericMultiEditCellClass = function (props) {
@@ -2513,11 +2518,11 @@ function styleInject(css, ref) {
2513
2518
  }
2514
2519
  }
2515
2520
 
2516
- var css_248z$6 = ".AgGridGenericCellRenderer-icon{margin-right:4px}.AgGridGenericCellRenderer-ic_infoIcon{fill:#3a7cdf;margin-right:4px}.AgGridGenericCellRenderer-ic_warningIcon{fill:#ea6a2e;margin-right:4px}";
2517
- styleInject(css_248z$6);
2521
+ var css_248z$7 = ".AgGridGenericCellRenderer-icon{margin-right:4px}.AgGridGenericCellRenderer-ic_infoIcon{fill:#3a7cdf;margin-right:4px}.AgGridGenericCellRenderer-ic_warningIcon{fill:#ea6a2e;margin-right:4px}";
2522
+ styleInject(css_248z$7);
2518
2523
 
2519
- var css_248z$5 = ".GridLoadableCell-container{align-items:center;display:flex}";
2520
- styleInject(css_248z$5);
2524
+ var css_248z$6 = ".GridLoadableCell-container{align-items:center;display:flex}";
2525
+ styleInject(css_248z$6);
2521
2526
 
2522
2527
  var GridLoadableCell = function (props) {
2523
2528
  if (props.isLoading) {
@@ -2612,7 +2617,7 @@ var GridCellRenderer = function (props) {
2612
2617
  return ((_a = colDef === null || colDef === void 0 ? void 0 : colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.originalCellRenderer) ? (jsx(GridLoadableCell, __assign({ isLoading: checkUpdating((_c = (_b = colDef.field) !== null && _b !== void 0 ? _b : colDef.colId) !== null && _c !== void 0 ? _c : "", props.data.id) }, { children: jsxs(Fragment$1, { children: [typeof warningText === "string" && jsx(GridIcon, { icon: "ic_warning", title: warningText }), typeof infoText === "string" && jsx(GridIcon, { icon: "ic_info", title: infoText }), jsx(colDef.cellRendererParams.originalCellRenderer, __assign({}, props))] }) }))) : (jsx(GridRendererGenericCell, __assign({}, props)));
2613
2618
  };
2614
2619
  /*
2615
- * For editing a text area.
2620
+ * All cells should use this
2616
2621
  */
2617
2622
  var GridCell = function (props, custom) {
2618
2623
  var _a;
@@ -2648,7 +2653,7 @@ var GenericCellEditorComponent3 = function (props) {
2648
2653
  var multiEdit = (_a = cellEditorParams === null || cellEditorParams === void 0 ? void 0 : cellEditorParams.multiEdit) !== null && _a !== void 0 ? _a : false;
2649
2654
  // TODO don't need all these props in context
2650
2655
  setProps(props, multiEdit);
2651
- return (jsxs(Fragment$1, { children: [jsx("div", { children: colDef.cellRenderer ? jsx(colDef.cellRenderer, __assign({}, props)) : props.value }), (props === null || props === void 0 ? void 0 : props.editor) && jsx(props.editor, __assign({}, cellEditorParams, propsRef.current))] }));
2656
+ return (jsxs(Fragment$1, { children: [jsx(colDef.cellRenderer, __assign({}, props)), (props === null || props === void 0 ? void 0 : props.editor) && jsx(props.editor, __assign({}, cellEditorParams, propsRef.current))] }));
2652
2657
  };
2653
2658
 
2654
2659
  /**
@@ -2739,11 +2744,11 @@ var GridRenderPopoutMenuCell = function (props) {
2739
2744
  return (jsx(GridLoadableCell, __assign({ isLoading: isLoading, className: disabled ? "GridPopoutMenu-burgerDisabled" : "GridPopoutMenu-burger" }, { children: jsx(LuiIcon, { name: "ic_more_vert", alt: "More actions", size: "md" }) })));
2740
2745
  };
2741
2746
 
2742
- var css_248z$4 = ".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}";
2743
- styleInject(css_248z$4);
2747
+ 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}";
2748
+ styleInject(css_248z$5);
2744
2749
 
2745
- var css_248z$3 = ".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}";
2746
- styleInject(css_248z$3);
2750
+ 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}";
2751
+ styleInject(css_248z$4);
2747
2752
 
2748
2753
  /* global setTimeout, clearTimeout */
2749
2754
 
@@ -3112,11 +3117,11 @@ var GridFormMultiSelect = function (props) {
3112
3117
  };
3113
3118
 
3114
3119
  var GridPopoutEditMultiSelect = function (colDef, props) {
3115
- return GridCell(__assign({ initialWidth: 65, maxWidth: 150, cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined }, colDef), __assign(__assign({ editor: GridFormMultiSelect }, props), { editorParams: __assign({ className: "GridMultiSelect-containerMedium" }, props.editorParams) }));
3120
+ return GridCell(__assign({ initialWidth: 65, maxWidth: 150 }, colDef), __assign(__assign({ editor: GridFormMultiSelect }, props), { editorParams: __assign({ className: "GridMultiSelect-containerMedium" }, props.editorParams) }));
3116
3121
  };
3117
3122
 
3118
- var css_248z$2 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
3119
- styleInject(css_248z$2);
3123
+ var css_248z$3 = ".GridPopoutMenu-burger{cursor:pointer}.GridPopoutMenu-burger svg{fill:#007198}.GridPopoutMenu-burgerDisabled svg{fill:#989189}";
3124
+ styleInject(css_248z$3);
3120
3125
 
3121
3126
  /** Menu configuration types **/
3122
3127
  var PopoutMenuSeparator = Object.freeze({ __isMenuSeparator__: true });
@@ -3279,11 +3284,11 @@ var convertDDToDMS = function (dd, showPositiveSymbol, addTrailingZeros) {
3279
3284
  return dmsString;
3280
3285
  };
3281
3286
 
3282
- var css_248z$1 = ".GridFormEditBearing-input{width:320px}";
3283
- styleInject(css_248z$1);
3287
+ var css_248z$2 = ".GridFormEditBearing-input{width:320px}";
3288
+ styleInject(css_248z$2);
3284
3289
 
3285
- var css_248z = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3286
- styleInject(css_248z);
3290
+ var css_248z$1 = ".LuiTextInput{margin-bottom:0}.LuiTextInput-formatted{color:#beb9b4;line-height:48px;position:absolute;right:14px;top:0}";
3291
+ styleInject(css_248z$1);
3287
3292
 
3288
3293
  var TextInputFormatted = function (props) {
3289
3294
  return (jsxs("div", __assign({ className: clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.warning && "hasWarning", props.className) }, { children: [jsxs("span", __assign({ className: "LuiTextInput-inputWrapper" }, { children: [jsx("input", __assign({ type: "text", className: "LuiTextInput-input", min: "0", value: props.value, onChange: props.onChange }, props.inputProps)), jsx("span", __assign({ className: "LuiTextInput-formatted" }, { children: props.formatted }))] })), props.error && (jsxs("span", __assign({ className: "LuiTextInput-error" }, { children: [jsx(LuiIcon, { alt: "error", name: "ic_error", className: "LuiTextInput-error-icon", size: "sm", status: "error" }), props.error] }))), props.warning && (jsxs("span", __assign({ className: "LuiTextInput-warning" }, { children: [jsx(LuiIcon, { alt: "warning", name: "ic_warning", className: "LuiTextInput-warning-icon", size: "sm", status: "warning" }), props.warning] })))] })));
@@ -3336,7 +3341,7 @@ var GridFormEditBearing = function (_props) {
3336
3341
  };
3337
3342
 
3338
3343
  var GridPopoverEditBearingLike = function (colDef, props) {
3339
- return GridCell(__assign({ initialWidth: 65, maxWidth: 150, valueFormatter: bearingValueFormatter, cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined }, colDef), __assign({ editor: GridFormEditBearing }, props));
3344
+ return GridCell(__assign({ initialWidth: 65, maxWidth: 150, valueFormatter: bearingValueFormatter }, colDef), __assign({ editor: GridFormEditBearing }, props));
3340
3345
  };
3341
3346
  var GridPopoverEditBearing = function (colDef, props) {
3342
3347
  return GridPopoverEditBearingLike(__assign({ valueFormatter: bearingValueFormatter }, colDef), {
@@ -3368,7 +3373,7 @@ var GridPopoverEditBearingCorrection = function (colDef, props) {
3368
3373
  };
3369
3374
 
3370
3375
  var GridPopoverEditDropDown = function (colDef, props) {
3371
- return GridCell(__assign({ initialWidth: 65, maxWidth: 150, cellClass: props.multiEdit ? GenericMultiEditCellClass : undefined }, colDef), __assign(__assign({ editor: GridFormDropDown }, props), { editorParams: __assign({
3376
+ return GridCell(__assign({ initialWidth: 65, maxWidth: 150 }, colDef), __assign(__assign({ editor: GridFormDropDown }, props), { editorParams: __assign({
3372
3377
  // Defaults to medium size container
3373
3378
  className: "GridPopoverEditDropDown-containerMedium" }, props.editorParams) }));
3374
3379
  };
@@ -3585,5 +3590,96 @@ var GridSubComponentTextArea = function (props) {
3585
3590
  return (jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsx("textarea", { autoFocus: true, maxLength: 10000, spellCheck: true, className: "free-text-input", onChange: function (e) { return setValue(e.target.value); }, defaultValue: value }) })));
3586
3591
  };
3587
3592
 
3588
- export { ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponent, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuItem, MenuRadioGroup, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
3593
+ 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}";
3594
+ styleInject(css_248z);
3595
+
3596
+ /**
3597
+ * Track previous values of states.
3598
+ *
3599
+ * @param value Value to track.
3600
+ */
3601
+ var usePrevious = function (value) {
3602
+ var ref = useRef();
3603
+ useEffect(function () {
3604
+ ref.current = value;
3605
+ }, [value]);
3606
+ return ref.current;
3607
+ };
3608
+
3609
+ /**
3610
+ * Cancels timeouts on scope being destroyed.
3611
+ *
3612
+ * This could almost be a debounce, but debounce tracks by function reference, this tracks by hook reference.
3613
+ * This could have been implemented using debounce if the callers function was wrapped in useCallback,
3614
+ * but there's no way to enforce that, so it would lead to bugs.
3615
+ */
3616
+ var useTimeoutHook = function () {
3617
+ var timeout = useRef();
3618
+ /**
3619
+ * Clear any pending timeouts.
3620
+ */
3621
+ var clearTimeouts = function () {
3622
+ if (timeout.current) {
3623
+ var tc = timeout.current;
3624
+ timeout.current = undefined;
3625
+ clearTimeout(tc);
3626
+ }
3627
+ };
3628
+ /**
3629
+ * Call this when your action has completed.
3630
+ */
3631
+ var invoke = useCallback(function (fn, waitTimeMs) {
3632
+ clearTimeouts();
3633
+ timeout.current = setTimeout(fn, waitTimeMs);
3634
+ }, []);
3635
+ /**
3636
+ * Clear timeout on loss of scope.
3637
+ */
3638
+ useEffect(function () {
3639
+ return function () { return clearTimeouts(); };
3640
+ }, []);
3641
+ return invoke;
3642
+ };
3643
+
3644
+ /**
3645
+ * Defers state change up to a minimum time since last state change.
3646
+ */
3647
+ var useStateDeferred = function (initialValue) {
3648
+ var startTime = useRef(0);
3649
+ var timeoutHook = useTimeoutHook();
3650
+ var _a = useState(initialValue), value = _a[0], _setValue = _a[1];
3651
+ var setValue = useCallback(function (newValue) {
3652
+ startTime.current = Date.now();
3653
+ _setValue(newValue);
3654
+ }, []);
3655
+ var setValueDeferred = useCallback(function (newValue, minimumWaitTimeMs) {
3656
+ var waitTimeMs = Math.max(minimumWaitTimeMs - (Date.now() - startTime.current), 0);
3657
+ timeoutHook(function () { return _setValue(newValue); }, waitTimeMs);
3658
+ }, [timeoutHook]);
3659
+ return [value, setValue, setValueDeferred];
3660
+ };
3661
+
3662
+ // Kept this less than one second, so I don't have issues with waitFor as it defaults to 1s
3663
+ var minimumInProgressTimeMs = 950;
3664
+ var ActionButton = function (_a) {
3665
+ var _b;
3666
+ var _c;
3667
+ var icon = _a.icon, name = _a.name, inProgressName = _a.inProgressName, dataTestId = _a.dataTestId, inProgress = _a.inProgress, className = _a.className, title = _a.title, onClick = _a.onClick, _d = _a.size, size = _d === void 0 ? "sm" : _d;
3668
+ var lastInProgress = usePrevious(inProgress !== null && inProgress !== void 0 ? inProgress : false);
3669
+ var _e = useStateDeferred(!!inProgress), localInProgress = _e[0], setLocalInProgress = _e[1], setLocalInProgressDeferred = _e[2];
3670
+ useEffect(function () {
3671
+ if (inProgress == lastInProgress)
3672
+ return;
3673
+ inProgress ? setLocalInProgress(true) : setLocalInProgressDeferred(false, minimumInProgressTimeMs);
3674
+ }, [inProgress, lastInProgress, setLocalInProgress, setLocalInProgressDeferred]);
3675
+ return (jsxs(LuiButton, __assign({ "data-testid": dataTestId, type: "button", level: "tertiary", title: title !== null && title !== void 0 ? title : name, "aria-label": name, className: clsx("lui-button-icon", "ActionButton", className, localInProgress && "ActionButton-inProgress"), size: "lg", onClick: onClick, disabled: localInProgress }, { children: [localInProgress ? (jsx(LuiMiniSpinner, { size: 16, divProps: (_b = {
3676
+ "data-testid": "loading-spinner",
3677
+ style: { padding: 0, margin: 0, paddingRight: 8 },
3678
+ role: "status"
3679
+ },
3680
+ _b["aria-label"] = "Loading",
3681
+ _b) })) : (jsx(LuiIcon, { name: icon, alt: name, size: size })), jsxs("span", __assign({ className: "ActionButton-minimalArea" }, { children: [jsx("span", __assign({ className: "ActionButton-minimalAreaDisplay" }, { children: (_c = (localInProgress ? inProgressName : name)) !== null && _c !== void 0 ? _c : name })), jsx("span", __assign({ className: "ActionButton-minimalAreaExpand" }, { children: name }))] }))] })));
3682
+ };
3683
+
3684
+ export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponent, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuItem, MenuRadioGroup, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
3589
3685
  //# sourceMappingURL=step-ag-grid.esm.js.map