@linzjs/step-ag-grid 20.0.0 → 21.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/index.css +3 -4
  2. package/dist/src/components/ComponentLoadingWrapper.d.ts +9 -9
  3. package/dist/src/components/Grid.d.ts +80 -80
  4. package/dist/src/components/GridCell.d.ts +63 -27
  5. package/dist/src/components/GridCell.test.d.ts +1 -1
  6. package/dist/src/components/GridCellFiller.d.ts +5 -4
  7. package/dist/src/components/GridCellMultiEditor.d.ts +18 -18
  8. package/dist/src/components/GridCellMultiSelectClassRules.d.ts +2 -2
  9. package/dist/src/components/GridIcon.d.ts +9 -9
  10. package/dist/src/components/GridLoadableCell.d.ts +1 -1
  11. package/dist/src/components/GridNoRowsOverlay.d.ts +9 -9
  12. package/dist/src/components/GridPopoverHook.d.ts +12 -12
  13. package/dist/src/components/GridWrapper.d.ts +5 -5
  14. package/dist/src/components/PostSortRowsHook.d.ts +11 -11
  15. package/dist/src/components/gridFilter/GridFilterButtons.d.ts +16 -16
  16. package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +5 -5
  17. package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +2 -2
  18. package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +11 -11
  19. package/dist/src/components/gridFilter/GridFilterQuick.d.ts +5 -5
  20. package/dist/src/components/gridFilter/GridFilters.d.ts +2 -2
  21. package/dist/src/components/gridFilter/index.d.ts +7 -7
  22. package/dist/src/components/gridFilter/useGridFilter.d.ts +3 -3
  23. package/dist/src/components/gridForm/GridFormDropDown.d.ts +37 -37
  24. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +12 -12
  25. package/dist/src/components/gridForm/GridFormMessage.d.ts +7 -7
  26. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +36 -36
  27. package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +24 -24
  28. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +36 -36
  29. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +12 -12
  30. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +11 -11
  31. package/dist/src/components/gridForm/GridFormTextArea.d.ts +14 -14
  32. package/dist/src/components/gridForm/GridFormTextInput.d.ts +14 -14
  33. package/dist/src/components/gridForm/index.d.ts +10 -10
  34. package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +7 -7
  35. package/dist/src/components/gridHeader/index.d.ts +1 -1
  36. package/dist/src/components/gridHook/index.d.ts +1 -1
  37. package/dist/src/components/gridHook/useGridContextMenu.d.ts +19 -19
  38. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +5 -5
  39. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +5 -5
  40. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +16 -16
  41. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +5 -5
  42. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +8 -8
  43. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +5 -5
  44. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +5 -5
  45. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +5 -5
  46. package/dist/src/components/gridPopoverEdit/index.d.ts +9 -9
  47. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +16 -37
  48. package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +2 -2
  49. package/dist/src/components/gridRender/index.d.ts +2 -2
  50. package/dist/src/components/gridUtil.d.ts +3 -3
  51. package/dist/src/components/index.d.ts +18 -18
  52. package/dist/src/contexts/GridContext.d.ts +67 -67
  53. package/dist/src/contexts/GridContextProvider.d.ts +15 -15
  54. package/dist/src/contexts/GridContextProvider.test.d.ts +1 -1
  55. package/dist/src/contexts/GridPopoverContext.d.ts +15 -15
  56. package/dist/src/contexts/GridPopoverContextProvider.d.ts +7 -7
  57. package/dist/src/contexts/GridSubComponentContext.d.ts +10 -10
  58. package/dist/src/contexts/GridUpdatingContext.d.ts +8 -8
  59. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +3 -3
  60. package/dist/src/index.d.ts +17 -17
  61. package/dist/src/lui/ActionButton.d.ts +20 -20
  62. package/dist/src/lui/FormError.d.ts +7 -7
  63. package/dist/src/lui/TextAreaInput.d.ts +11 -11
  64. package/dist/src/lui/TextInputFormatted.d.ts +10 -10
  65. package/dist/src/lui/reactUtils.d.ts +6 -6
  66. package/dist/src/lui/reactUtils.test.d.ts +1 -1
  67. package/dist/src/lui/stateDeferredHook.d.ts +4 -4
  68. package/dist/src/lui/timeoutHook.d.ts +14 -14
  69. package/dist/src/lui/timeoutHook.test.d.ts +1 -1
  70. package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -8
  71. package/dist/src/react-menu3/components/FocusableItem.d.ts +9 -9
  72. package/dist/src/react-menu3/components/Menu.d.ts +16 -16
  73. package/dist/src/react-menu3/components/MenuButton.d.ts +8 -8
  74. package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -3
  75. package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -12
  76. package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -4
  77. package/dist/src/react-menu3/components/MenuItem.d.ts +59 -59
  78. package/dist/src/react-menu3/components/MenuList.d.ts +2 -2
  79. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +25 -25
  80. package/dist/src/react-menu3/components/SubMenu.d.ts +110 -110
  81. package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -7
  82. package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -2
  83. package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -5
  84. package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -9
  85. package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -11
  86. package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -7
  87. package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -20
  88. package/dist/src/react-menu3/hooks/index.d.ts +9 -9
  89. package/dist/src/react-menu3/hooks/useBEM.d.ts +10 -10
  90. package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -2
  91. package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +3 -3
  92. package/dist/src/react-menu3/hooks/useItemEffect.d.ts +2 -2
  93. package/dist/src/react-menu3/hooks/useItemState.d.ts +7 -7
  94. package/dist/src/react-menu3/hooks/useItems.d.ts +7 -7
  95. package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -2
  96. package/dist/src/react-menu3/hooks/useMenuState.d.ts +23 -14
  97. package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -2
  98. package/dist/src/react-menu3/index.d.ts +11 -11
  99. package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +11 -11
  100. package/dist/src/react-menu3/positionUtils/index.d.ts +3 -3
  101. package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +8 -8
  102. package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +8 -8
  103. package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +19 -19
  104. package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +19 -19
  105. package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +13 -13
  106. package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +26 -26
  107. package/dist/src/react-menu3/style-utils/index.d.ts +11 -11
  108. package/dist/src/react-menu3/types.d.ts +401 -401
  109. package/dist/src/react-menu3/utils/constants.d.ts +54 -54
  110. package/dist/src/react-menu3/utils/index.d.ts +3 -3
  111. package/dist/src/react-menu3/utils/propTypes2.d.ts +56 -56
  112. package/dist/src/react-menu3/utils/utils.d.ts +37 -37
  113. package/dist/src/react-menu3/utils/withHovering.d.ts +7 -7
  114. package/dist/src/utils/bearing.d.ts +19 -19
  115. package/dist/src/utils/bearing.test.d.ts +1 -1
  116. package/dist/src/utils/deferredPromise.d.ts +5 -5
  117. package/dist/src/utils/storybookTestUtil.d.ts +3 -3
  118. package/dist/src/utils/testQuick.d.ts +62 -62
  119. package/dist/src/utils/testUtil.d.ts +46 -45
  120. package/dist/src/utils/textMatcher.d.ts +13 -13
  121. package/dist/src/utils/textMatcher.test.d.ts +1 -1
  122. package/dist/src/utils/textValidator.d.ts +18 -18
  123. package/dist/src/utils/textValidator.test.d.ts +1 -1
  124. package/dist/src/utils/util.d.ts +8 -8
  125. package/dist/src/utils/util.test.d.ts +1 -1
  126. package/dist/step-ag-grid.cjs.js +4651 -4651
  127. package/dist/step-ag-grid.cjs.js.map +1 -1
  128. package/dist/step-ag-grid.esm.js +4651 -4651
  129. package/dist/step-ag-grid.esm.js.map +1 -1
  130. package/dist/vite.config.d.ts +2 -0
  131. package/package.json +23 -22
  132. package/src/components/Grid.tsx +10 -9
  133. package/src/components/GridCell.test.tsx +2 -3
  134. package/src/components/GridCell.tsx +75 -23
  135. package/src/components/GridCellFiller.tsx +2 -1
  136. package/src/components/GridCellMultiEditor.tsx +9 -9
  137. package/src/components/GridCellMultiSelectClassRules.tsx +4 -4
  138. package/src/components/GridPopoverHook.tsx +4 -4
  139. package/src/components/PostSortRowsHook.ts +7 -7
  140. package/src/components/gridFilter/GridFilterButtons.tsx +6 -6
  141. package/src/components/gridFilter/GridFilterColumnsToggle.tsx +2 -5
  142. package/src/components/gridFilter/GridFilterDownloadCsvButton.tsx +1 -1
  143. package/src/components/gridFilter/useGridFilter.ts +1 -1
  144. package/src/components/gridForm/GridFormDropDown.tsx +9 -9
  145. package/src/components/gridForm/GridFormEditBearing.tsx +5 -5
  146. package/src/components/gridForm/GridFormMessage.tsx +4 -4
  147. package/src/components/gridForm/GridFormMultiSelect.tsx +9 -9
  148. package/src/components/gridForm/GridFormMultiSelectGrid.tsx +11 -11
  149. package/src/components/gridForm/GridFormPopoverMenu.tsx +13 -13
  150. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +4 -4
  151. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +4 -4
  152. package/src/components/gridForm/GridFormTextArea.tsx +6 -6
  153. package/src/components/gridForm/GridFormTextInput.tsx +7 -7
  154. package/src/components/gridHeader/GridHeaderSelect.tsx +10 -8
  155. package/src/components/gridHook/useGridContextMenu.tsx +8 -8
  156. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +6 -6
  157. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +6 -6
  158. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +16 -16
  159. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +6 -6
  160. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +5 -5
  161. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +5 -5
  162. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +5 -4
  163. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +5 -5
  164. package/src/components/gridRender/GridRenderGenericCell.tsx +6 -36
  165. package/src/contexts/GridContext.tsx +9 -9
  166. package/src/contexts/GridContextProvider.test.tsx +1 -1
  167. package/src/contexts/GridContextProvider.tsx +32 -36
  168. package/src/contexts/GridPopoverContext.tsx +6 -6
  169. package/src/stories/grid/GridDragRow.stories.tsx +13 -7
  170. package/src/stories/grid/GridNonEditableRow.stories.tsx +2 -3
  171. package/src/stories/grid/GridPopoutContextMenu.stories.tsx +2 -2
  172. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +1 -1
  173. package/src/stories/grid/GridPopoverEditBearing.stories.tsx +2 -2
  174. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +12 -3
  175. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +2 -2
  176. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +2 -2
  177. package/src/stories/grid/GridReadOnly.stories.tsx +6 -6
  178. package/src/stories/grid/GridViewList.stories.tsx +5 -7
  179. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +3 -3
  180. package/src/styles/Grid.scss +3 -6
  181. package/src/utils/testUtil.ts +49 -7
  182. package/src/utils/textValidator.ts +5 -5
  183. package/src/utils/util.ts +1 -1
@@ -1,49 +1,19 @@
1
1
  import { ICellRendererParams } from "ag-grid-community";
2
- import {
3
- EditableCallbackParams,
4
- SuppressKeyboardEventParams,
5
- ValueFormatterParams,
6
- ValueGetterParams,
7
- } from "ag-grid-community/dist/lib/entities/colDef";
2
+ import { SuppressKeyboardEventParams } from "ag-grid-community";
8
3
  import { ReactElement } from "react";
9
4
 
10
5
  import { GridBaseRow } from "../Grid";
11
6
  import { ColDefT } from "../GridCell";
12
7
 
13
- export interface RowICellRendererParams<RowType extends GridBaseRow> extends ICellRendererParams {
14
- data: RowType;
15
- }
16
-
17
- export interface RowEditableCallbackParams<RowType extends GridBaseRow> extends EditableCallbackParams {
18
- data: RowType;
19
- }
20
-
21
- export interface RowValueFormatterParams<RowType extends GridBaseRow> extends ValueFormatterParams {
22
- data: RowType;
23
- }
24
- export interface RowValueGetterParams<RowType extends GridBaseRow> extends ValueGetterParams {
25
- data: RowType;
26
- }
27
-
28
- export interface RowValueGetterParams<RowType extends GridBaseRow> extends ValueGetterParams {
29
- data: RowType;
30
- }
31
-
32
- export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<RowType> {
33
- cellRenderer?: (params: RowICellRendererParams<RowType>) => any;
34
- cellRendererParams?: GenericCellRendererParams<RowType>;
35
- valueGetter?: string | ((params: RowValueGetterParams<RowType>) => any);
36
- valueFormatter?: string | ((params: RowValueFormatterParams<RowType>) => string);
37
- filterValueGetter?: string | ((params: RowValueGetterParams<RowType>) => string);
38
- editable?: boolean | ((params: RowEditableCallbackParams<RowType>) => boolean);
8
+ export interface GenericCellColDef<TData extends GridBaseRow, TValue = any> extends ColDefT<TData, TValue> {
39
9
  exportable?: boolean;
40
10
  }
41
11
 
42
- export interface GenericCellRendererParams<RowType extends GridBaseRow> {
12
+ export interface GenericCellRendererParams<TData extends GridBaseRow> {
43
13
  singleClickEdit?: boolean;
44
14
  rightHoverElement?: ReactElement | undefined;
45
- editAction?: (selectedRows: RowType[]) => void;
15
+ editAction?: (selectedRows: TData[]) => void;
46
16
  shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
47
- warning?: (props: RowICellRendererParams<RowType>) => string | string[] | boolean | null | undefined;
48
- info?: (props: RowICellRendererParams<RowType>) => string | string[] | boolean | null | undefined;
17
+ warning?: (props: ICellRendererParams<TData>) => string | string[] | boolean | null | undefined;
18
+ info?: (props: ICellRendererParams<TData>) => string | string[] | boolean | null | undefined;
49
19
  }
@@ -1,10 +1,10 @@
1
- import { ColDef, ColumnApi, GridApi, IRowNode } from "ag-grid-community";
2
- import { CsvExportParams } from "ag-grid-community/dist/lib/interfaces/exportParams";
1
+ import { ColDef, GridApi, IRowNode } from "ag-grid-community";
2
+ import { CsvExportParams } from "ag-grid-community";
3
3
  import { createContext, useContext } from "react";
4
4
 
5
5
  import { ColDefT, GridBaseRow } from "../components";
6
6
 
7
- export type GridFilterExternal<RowType extends GridBaseRow> = (data: RowType, rowNode: IRowNode) => boolean;
7
+ export type GridFilterExternal<TData extends GridBaseRow> = (data: TData, rowNode: IRowNode) => boolean;
8
8
 
9
9
  export interface AutoSizeColumnsProps {
10
10
  skipHeader?: boolean;
@@ -15,15 +15,15 @@ export interface AutoSizeColumnsProps {
15
15
 
16
16
  export type AutoSizeColumnsResult = { width: number } | null;
17
17
 
18
- export interface GridContextType<RowType extends GridBaseRow> {
18
+ export interface GridContextType<TData extends GridBaseRow> {
19
19
  gridReady: boolean;
20
20
  gridRenderState: () => null | "empty" | "rows-visible";
21
21
  getColDef: (colId?: string) => ColDef | undefined;
22
22
  getColumns: (
23
23
  filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string),
24
- ) => ColDefT<RowType>[];
24
+ ) => ColDefT<TData, any>[];
25
25
  getColumnIds: (filter?: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string)) => string[];
26
- setApis: (gridApi: GridApi | undefined, columnApi: ColumnApi | undefined, dataTestId?: string) => void;
26
+ setApis: (gridApi: GridApi | undefined, dataTestId?: string) => void;
27
27
  prePopupOps: () => void;
28
28
  postPopupOps: () => void;
29
29
  setQuickFilter: (quickFilter: string) => void;
@@ -57,8 +57,8 @@ export interface GridContextType<RowType extends GridBaseRow> {
57
57
  externallySelectedItemsAreInSync: boolean;
58
58
  setExternallySelectedItemsAreInSync: (inSync: boolean) => void;
59
59
  waitForExternallySelectedItemsToBeInSync: () => Promise<void>;
60
- addExternalFilter: (filter: GridFilterExternal<RowType>) => void;
61
- removeExternalFilter: (filter: GridFilterExternal<RowType>) => void;
60
+ addExternalFilter: (filter: GridFilterExternal<TData>) => void;
61
+ removeExternalFilter: (filter: GridFilterExternal<TData>) => void;
62
62
  isExternalFilterPresent: () => boolean;
63
63
  doesExternalFilterPass: (node: IRowNode) => boolean;
64
64
  invisibleColumnIds: string[] | undefined;
@@ -207,4 +207,4 @@ export const GridContext = createContext<GridContextType<any>>({
207
207
  },
208
208
  });
209
209
 
210
- export const useGridContext = <RowType extends GridBaseRow>() => useContext<GridContextType<RowType>>(GridContext);
210
+ export const useGridContext = <TData extends GridBaseRow>() => useContext<GridContextType<TData>>(GridContext);
@@ -1,4 +1,4 @@
1
- import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
1
+ import { ValueFormatterParams } from "ag-grid-community";
2
2
 
3
3
  import { downloadCsvUseValueFormattersProcessCellCallback as Dpcc } from "./GridContextProvider";
4
4
 
@@ -1,6 +1,5 @@
1
- import { CellPosition, ColDef, ColumnApi, GridApi, IRowNode, RowNode } from "ag-grid-community";
2
- import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
3
- import { CsvExportParams, ProcessCellForExportParams } from "ag-grid-community/dist/lib/interfaces/exportParams";
1
+ import { CellPosition, ColDef, GridApi, IRowNode, RowNode } from "ag-grid-community";
2
+ import { CsvExportParams, ProcessCellForExportParams } from "ag-grid-community";
4
3
  import debounce from "debounce-promise";
5
4
  import { compact, defer, delay, difference, filter, isEmpty, last, pull, remove, sortBy, sumBy } from "lodash-es";
6
5
  import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
@@ -8,7 +7,7 @@ import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, us
8
7
  import { ColDefT, GridBaseRow } from "../components";
9
8
  import { GridCellFillerColId, isGridCellFiller } from "../components/GridCellFiller";
10
9
  import { getColId, isFlexColumn } from "../components/gridUtil";
11
- import { isNotEmpty, sanitiseFileName, wait } from "../utils/util";
10
+ import { fnOrVar, isNotEmpty, sanitiseFileName, wait } from "../utils/util";
12
11
  import { AutoSizeColumnsProps, AutoSizeColumnsResult, GridContext, GridFilterExternal } from "./GridContext";
13
12
  import { GridUpdatingContext } from "./GridUpdatingContext";
14
13
 
@@ -17,10 +16,9 @@ import { GridUpdatingContext } from "./GridUpdatingContext";
17
16
  * Make sure you wrap AgGrid in this.
18
17
  * Also, make sure the provider is created in a separate component, otherwise it won't be found.
19
18
  */
20
- export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWithChildren): ReactElement => {
19
+ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithChildren): ReactElement => {
21
20
  const { modifyUpdating, checkUpdating } = useContext(GridUpdatingContext);
22
21
  const [gridApi, setGridApi] = useState<GridApi>();
23
- const [columnApi, setColumnApi] = useState<ColumnApi>();
24
22
  const [gridReady, setGridReady] = useState(false);
25
23
  const [quickFilter, setQuickFilter] = useState("");
26
24
  const [invisibleColumnIds, _setInvisibleColumnIds] = useState<string[]>();
@@ -28,7 +26,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
28
26
  const idsBeforeUpdate = useRef<number[]>([]);
29
27
  const prePopupFocusedCell = useRef<CellPosition>();
30
28
  const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = useState(false);
31
- const externalFilters = useRef<GridFilterExternal<RowType>[]>([]);
29
+ const externalFilters = useRef<GridFilterExternal<TData>[]>([]);
32
30
 
33
31
  /**
34
32
  * Make extra sure the GridCellFillerColId never gets added to invisibleColumnIds as it's dynamically determined
@@ -40,7 +38,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
40
38
  * Set quick filter directly on grid, based on previously save quickFilter state.
41
39
  */
42
40
  useEffect(() => {
43
- gridApi?.setQuickFilter(quickFilter);
41
+ gridApi?.setGridOption("quickFilterText", quickFilter);
44
42
  }, [gridApi, quickFilter]);
45
43
 
46
44
  /**
@@ -94,11 +92,10 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
94
92
  * Set the grid api when the grid is ready.
95
93
  */
96
94
  const setApis = useCallback(
97
- (gridApi: GridApi | undefined, columnApi: ColumnApi | undefined, dataTestId?: string) => {
95
+ (gridApi: GridApi | undefined, dataTestId?: string) => {
98
96
  testId.current = dataTestId;
99
97
  setGridApi(gridApi);
100
- setColumnApi(columnApi);
101
- gridApi?.setQuickFilter(quickFilter);
98
+ gridApi?.setGridOption("quickFilterText", quickFilter);
102
99
  setGridReady(!!gridApi);
103
100
  },
104
101
  [quickFilter],
@@ -108,9 +105,8 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
108
105
  * Used to check if it's OK to autosize.
109
106
  */
110
107
  const gridRenderState = useCallback((): null | "empty" | "rows-visible" => {
111
- // Even though getModel can't be null, sometimes it is
112
- if (!gridApi || !gridApi.getModel()) return null;
113
- if (!gridApi.getModel().isRowsToRender()) return "empty";
108
+ if (!gridApi) return null;
109
+ if (!gridApi.getDisplayedRowCount()) return "empty";
114
110
  if (!isEmpty(gridApi.getRenderedNodes())) return "rows-visible";
115
111
  // If there are rows to render, but there are no rendered nodes then we should wait
116
112
  return null;
@@ -204,9 +200,9 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
204
200
  const getColumns = useCallback(
205
201
  (
206
202
  filterDef: keyof ColDef | ((r: ColDef) => boolean | undefined | null | number | string) = () => true,
207
- ): ColDefT<RowType>[] =>
208
- filter(columnApi?.getColumns()?.map((col) => col.getColDef()) ?? [], filterDef) as ColDefT<RowType>[],
209
- [columnApi],
203
+ ): ColDefT<TData>[] =>
204
+ filter(gridApi?.getColumns()?.map((col) => col.getColDef()) ?? [], filterDef) as ColDefT<TData>[],
205
+ [gridApi],
210
206
  );
211
207
 
212
208
  const getColumnIds = useCallback(
@@ -407,9 +403,9 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
407
403
  */
408
404
  const autoSizeColumns = useCallback(
409
405
  ({ skipHeader, colIds, userSizedColIds, includeFlex }: AutoSizeColumnsProps = {}): AutoSizeColumnsResult => {
410
- if (!columnApi) return null;
406
+ if (!gridApi) return null;
411
407
  const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
412
- const colsToResize = columnApi.getColumnState().filter((colState) => {
408
+ const colsToResize = gridApi.getColumnState().filter((colState) => {
413
409
  const colId = colState.colId;
414
410
  return (
415
411
  (isEmpty(colIdsSet) || colIdsSet.has(colId)) &&
@@ -418,19 +414,19 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
418
414
  );
419
415
  });
420
416
  if (!isEmpty(colsToResize)) {
421
- columnApi.autoSizeColumns(
417
+ gridApi.autoSizeColumns(
422
418
  colsToResize.map((colState) => colState.colId),
423
419
  skipHeader,
424
420
  );
425
421
  }
426
422
  return {
427
423
  width: sumBy(
428
- columnApi.getColumnState().filter((col) => !col.hide),
424
+ gridApi.getColumnState().filter((col) => !col.hide),
429
425
  "width",
430
426
  ),
431
427
  };
432
428
  },
433
- [columnApi],
429
+ [gridApi],
434
430
  );
435
431
 
436
432
  /**
@@ -489,7 +485,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
489
485
  */
490
486
  const cancelEdit = useCallback((): void => {
491
487
  stopEditing();
492
- cellEditingCompleteCallbackRef.current && cellEditingCompleteCallbackRef.current();
488
+ cellEditingCompleteCallbackRef.current?.();
493
489
  }, [stopEditing]);
494
490
 
495
491
  const cellEditingCompleteCallbackRef = useRef<() => void>();
@@ -583,7 +579,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
583
579
  gridApi.refreshClientSideRowModel();
584
580
  } else {
585
581
  // Don't set saving if ok as the form has already closed
586
- setSaving && setSaving(false);
582
+ setSaving?.(false);
587
583
  }
588
584
 
589
585
  // Only focus next cell if user hasn't already manually changed focus
@@ -639,12 +635,12 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
639
635
  [gridApi],
640
636
  );
641
637
 
642
- const addExternalFilter = (filter: GridFilterExternal<RowType>) => {
638
+ const addExternalFilter = (filter: GridFilterExternal<TData>) => {
643
639
  externalFilters.current.push(filter);
644
640
  onFilterChanged().then();
645
641
  };
646
642
 
647
- const removeExternalFilter = (filter: GridFilterExternal<RowType>) => {
643
+ const removeExternalFilter = (filter: GridFilterExternal<TData>) => {
648
644
  remove(externalFilters.current, (v) => v === filter);
649
645
  onFilterChanged().then();
650
646
  };
@@ -667,7 +663,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
667
663
  * Apply column visibility
668
664
  */
669
665
  useEffect(() => {
670
- if (!columnApi || !invisibleColumnIds) return;
666
+ if (!gridApi || !invisibleColumnIds) return;
671
667
 
672
668
  // show all columns that aren't invisible
673
669
  const newVisibleColumns = getColumns(
@@ -679,26 +675,26 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
679
675
  const fillerColumn = getColumns(isGridCellFiller)[0];
680
676
  fillerColumn && newVisibleColumns.push(fillerColumn);
681
677
  }
682
- columnApi.setColumnsVisible(compact(newVisibleColumns.map(getColId)), true);
678
+ gridApi.setColumnsVisible(compact(newVisibleColumns.map(getColId)), true);
683
679
 
684
680
  // Hide the filler column if there's already a flex column
685
681
  const invisibleColumnIdsWithOptionalFiller = visibleColumnsContainsAFlex
686
682
  ? [...invisibleColumnIds, GridCellFillerColId]
687
683
  : invisibleColumnIds;
688
- columnApi.setColumnsVisible(invisibleColumnIdsWithOptionalFiller, false);
689
- }, [invisibleColumnIds, columnApi, getColumns]);
684
+ gridApi.setColumnsVisible(invisibleColumnIdsWithOptionalFiller, false);
685
+ }, [invisibleColumnIds, getColumns, gridApi]);
690
686
 
691
687
  /**
692
688
  * Download visible columns as a CSV
693
689
  */
694
690
  const downloadCsv = useCallback(
695
691
  (csvExportParams?: CsvExportParams) => {
696
- if (!gridApi || !columnApi) return;
692
+ if (!gridApi) return;
697
693
 
698
- const fileName = csvExportParams?.fileName && sanitiseFileName(csvExportParams.fileName);
694
+ const fileName = csvExportParams?.fileName && sanitiseFileName(fnOrVar(csvExportParams.fileName));
699
695
 
700
- const columnKeys = columnApi
701
- ?.getColumnState()
696
+ const columnKeys = gridApi
697
+ .getColumnState()
702
698
  .filter((cs) => {
703
699
  const colDef = gridApi.getColumnDef(cs.colId);
704
700
  return !cs.hide && colDef && !isGridCellFiller(colDef) && colDef.headerComponentParams?.exportable !== false;
@@ -711,7 +707,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
711
707
  fileName,
712
708
  });
713
709
  },
714
- [columnApi, gridApi],
710
+ [gridApi],
715
711
  );
716
712
 
717
713
  return (
@@ -807,7 +803,7 @@ export const downloadCsvUseValueFormattersProcessCellCallback = (params: Process
807
803
  return encodeToString(params.value);
808
804
  }
809
805
 
810
- const result = valueFormatter({ ...params, data: params.node?.data, colDef } as ValueFormatterParams);
806
+ const result = valueFormatter({ ...params, data: params.node?.data, colDef, node: null });
811
807
  // type may not be string due to casting, leave the type check in
812
808
  if (params.value != null && typeof result !== "string") {
813
809
  console.error(`downloadCsv: valueFormatter is returning non string values, colDef:", colId: ${colDef.colId}`);
@@ -2,14 +2,14 @@ import { RefObject, createContext, useContext } from "react";
2
2
 
3
3
  import { GridBaseRow } from "../components/Grid";
4
4
 
5
- export interface GridPopoverContextType<RowType extends GridBaseRow> {
5
+ export interface GridPopoverContextType<TData extends GridBaseRow> {
6
6
  anchorRef: RefObject<Element>;
7
7
  saving: boolean;
8
8
  setSaving: (saving: boolean) => void;
9
- field: keyof RowType;
9
+ field: keyof TData;
10
10
  value: any;
11
- data: RowType;
12
- selectedRows: RowType[];
11
+ data: TData;
12
+ selectedRows: TData[];
13
13
  updateValue: (saveFn: (selectedRows: any[]) => Promise<boolean>, tabDirection: 1 | 0 | -1) => Promise<boolean>;
14
14
  formatValue: (value: any) => any;
15
15
  }
@@ -26,5 +26,5 @@ export const GridPopoverContext = createContext<GridPopoverContextType<any>>({
26
26
  formatValue: () => "! No gridPopoverContextProvider !",
27
27
  });
28
28
 
29
- export const useGridPopoverContext = <RowType extends GridBaseRow>() =>
30
- useContext<GridPopoverContextType<RowType>>(GridPopoverContext);
29
+ export const useGridPopoverContext = <TData extends GridBaseRow>() =>
30
+ useContext<GridPopoverContextType<TData>>(GridPopoverContext);
@@ -66,12 +66,12 @@ const GridDragRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
66
66
  headerName: "Id",
67
67
  lockVisible: true,
68
68
  }),
69
- GridCell({
69
+ GridCell<ITestRow, ITestRow["position"]>({
70
70
  field: "position",
71
71
  headerName: "Position",
72
72
  cellRendererParams: {
73
- warning: (props) => props.value === "Tester" && "Testers are testing",
74
- info: (props) => props.value === "Developer" && "Developers are awesome",
73
+ warning: ({ value }) => value === "Tester" && "Testers are testing",
74
+ info: ({ value }) => value === "Developer" && "Developers are awesome",
75
75
  },
76
76
  }),
77
77
  GridCell({
@@ -91,7 +91,7 @@ const GridDragRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
91
91
  [],
92
92
  );
93
93
 
94
- const [rowData] = useState([
94
+ const [rowData, setRowData] = useState([
95
95
  { id: 1000, position: "Tester", age: 30, height: `6'4"`, desc: "Tests application", dd: "1" },
96
96
  { id: 1001, position: "Developer", age: 12, height: `5'3"`, desc: "Develops application", dd: "2" },
97
97
  { id: 1002, position: "Manager", age: 65, height: `5'9"`, desc: "Manages", dd: "3" },
@@ -109,10 +109,16 @@ const GridDragRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
109
109
  columnDefs={columnDefs}
110
110
  defaultColDef={{ sortable: false }}
111
111
  rowData={rowData}
112
- onRowDragEnd={async (row, _, targetIndex) => {
113
- alert(`Row ${row.id} request to be moved to index ${targetIndex}.`);
112
+ onRowDragEnd={async (movedRow, targetRow, _targetIndex) => {
113
+ setRowData(
114
+ rowData.map((r) => {
115
+ if (r.id === movedRow.id) return targetRow;
116
+ if (r.id === targetRow.id) return movedRow;
117
+ return r;
118
+ }),
119
+ );
114
120
  }}
115
- rowDragText={(params) => `${params.rowNode?.data.id} - ${params.rowNode?.data.position}`}
121
+ rowDragText={({ rowNode }) => `${rowNode?.data.id} - ${rowNode?.data.position}`}
116
122
  />
117
123
  </GridWrapper>
118
124
  );
@@ -3,7 +3,6 @@ import "../../styles/index.scss";
3
3
  import "@linzjs/lui/dist/scss/base.scss";
4
4
 
5
5
  import { Meta, StoryFn } from "@storybook/react";
6
- import { ColDef } from "ag-grid-community";
7
6
  import { GridPopoverEditDropDown } from "components/gridPopoverEdit/GridPopoverEditDropDown";
8
7
  import { GridPopoverTextArea } from "components/gridPopoverEdit/GridPopoverTextArea";
9
8
  import { useMemo, useState } from "react";
@@ -155,9 +154,9 @@ const GridNonEditableRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
155
154
  { id: 1002, position: "Manager", age: 65, desc: "Manages", dd: "3" },
156
155
  ]);
157
156
 
158
- const defaultColDef: ColDef = useMemo(
157
+ const defaultColDef: ColDefT<ITestRow> = useMemo(
159
158
  () => ({
160
- editable: (params) => (params.data as ITestRow).position !== "Manager",
159
+ editable: ({ data }) => data?.position !== "Manager",
161
160
  }),
162
161
  [],
163
162
  );
@@ -85,8 +85,8 @@ const GridPopoutContextMenuTemplate: StoryFn<typeof Grid> = (props: GridProps) =
85
85
  GridCell({
86
86
  field: "distance",
87
87
  headerName: "Number input",
88
- valueFormatter: (params) => {
89
- const v = params.data.distance;
88
+ valueFormatter: ({ data }) => {
89
+ const v = data?.distance;
90
90
  return v != null ? `${v}m` : "–";
91
91
  },
92
92
  }),
@@ -91,7 +91,7 @@ const GridPopoutEditGenericTemplate: StoryFn<typeof Grid> = (props: GridProps) =
91
91
  field: "distance",
92
92
  headerName: "Number input",
93
93
  valueFormatter: (params) => {
94
- const v = params.data.distance;
94
+ const v = params.data?.distance;
95
95
  return v != null ? `${v}${params.colDef.cellEditorParams.units}` : "–";
96
96
  },
97
97
  },
@@ -65,8 +65,8 @@ const GridPopoverEditBearingTemplate: StoryFn<typeof Grid> = (props: GridProps)
65
65
  field: "bearingCorrection",
66
66
  headerName: "Bearing correction",
67
67
  cellRendererParams: {
68
- warning: ({ data }) => data.id == 1002 && "Testers are testing",
69
- info: ({ data }) => data.id == 1001 && "Developers are developing",
68
+ warning: ({ data }) => data?.id == 1002 && "Testers are testing",
69
+ info: ({ data }) => data?.id == 1001 && "Developers are developing",
70
70
  },
71
71
  },
72
72
  {
@@ -99,7 +99,7 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
99
99
  field: "id",
100
100
  headerName: "Id",
101
101
  }),
102
- GridPopoverEditDropDown(
102
+ GridPopoverEditDropDown<ITestRow, ITestRow["position2"]>(
103
103
  {
104
104
  field: "position2",
105
105
  headerName: "Multi-edit",
@@ -173,7 +173,7 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
173
173
  {
174
174
  field: "position4",
175
175
  headerName: "Filtered (object)",
176
- valueGetter: (params) => params.data.position4?.desc,
176
+ valueGetter: ({ data }) => data?.position4?.desc,
177
177
  },
178
178
  {
179
179
  multiEdit: true,
@@ -217,7 +217,7 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
217
217
  {
218
218
  field: "sub",
219
219
  headerName: "Subcomponent",
220
- valueGetter: (params) => params.data.sub,
220
+ valueGetter: ({ data }) => data?.sub,
221
221
  },
222
222
  {
223
223
  multiEdit: true,
@@ -290,6 +290,15 @@ const GridEditDropDownTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
290
290
  code: "O2",
291
291
  sub: "one",
292
292
  },
293
+ {
294
+ id: 1002,
295
+ position: "Scrum Master",
296
+ position2: "2",
297
+ position3: "Architect",
298
+ position4: { code: "O2", desc: "Object Two" },
299
+ code: "O2",
300
+ sub: "one",
301
+ },
293
302
  ] as ITestRow[]);
294
303
 
295
304
  return (
@@ -68,7 +68,7 @@ const GridEditMultiSelectTemplate: StoryFn<typeof Grid> = (props: GridProps) =>
68
68
  field: "id",
69
69
  headerName: "Id",
70
70
  }),
71
- GridPopoutEditMultiSelect(
71
+ GridPopoutEditMultiSelect<ITestRow, ITestRow["position"]>(
72
72
  {
73
73
  field: "position",
74
74
  headerName: "Position",
@@ -112,7 +112,7 @@ const GridEditMultiSelectTemplate: StoryFn<typeof Grid> = (props: GridProps) =>
112
112
  },
113
113
  },
114
114
  ),
115
- GridPopoutEditMultiSelect(
115
+ GridPopoutEditMultiSelect<ITestRow, ITestRow["position"]>(
116
116
  {
117
117
  field: "position",
118
118
  headerName: "Parcel picker",
@@ -49,7 +49,7 @@ const GridEditMultiSelectGridTemplate: StoryFn<typeof Grid> = (props: GridProps)
49
49
  field: "id",
50
50
  headerName: "Id",
51
51
  }),
52
- GridPopoutEditMultiSelectGrid(
52
+ GridPopoutEditMultiSelectGrid<ITestRow, ITestRow["position"]>(
53
53
  {
54
54
  field: "position",
55
55
  headerName: "Position",
@@ -62,7 +62,7 @@ const GridEditMultiSelectGridTemplate: StoryFn<typeof Grid> = (props: GridProps)
62
62
  multiEdit: true,
63
63
  editorParams: {
64
64
  className: "GridMultiSelect-containerUnlimited",
65
- options: (selectedRows) => {
65
+ options: (selectedRows: ITestRow[]) => {
66
66
  const counts: Record<number, number> = mergeWith(
67
67
  {},
68
68
  ...selectedRows.map((row) => countBy(row.position)),
@@ -80,23 +80,23 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
80
80
  headerName: "Id",
81
81
  lockVisible: true,
82
82
  }),
83
- GridCell({
83
+ GridCell<ITestRow, ITestRow["position"]>({
84
84
  field: "position",
85
85
  headerName: "Position",
86
86
  cellRendererParams: {
87
- warning: (props) => props.value === "Tester" && "Testers are testing",
88
- info: (props) => props.value === "Developer" && "Developers are awesome",
87
+ warning: ({ value }) => value === "Tester" && "Testers are testing",
88
+ info: ({ value }) => value === "Developer" && "Developers are awesome",
89
89
  },
90
90
  }),
91
91
  {
92
92
  headerName: "Metrics",
93
93
  marryChildren: true,
94
94
  children: [
95
- GridCell({
95
+ GridCell<ITestRow, ITestRow["age"]>({
96
96
  field: "age",
97
97
  headerName: "Age",
98
98
  }),
99
- GridCell({
99
+ GridCell<ITestRow, ITestRow["height"]>({
100
100
  field: "height",
101
101
  headerName: "Height",
102
102
  }),
@@ -134,7 +134,7 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
134
134
  rightHoverElement: (
135
135
  <GridIcon icon={"ic_launch_modal"} title={"Title text"} className={"GridCell-editableIcon"} />
136
136
  ),
137
- editAction: (selectedRows) => {
137
+ editAction: (selectedRows: ITestRow[]) => {
138
138
  alert(`Custom edit ${selectedRows.map((r) => r.id)} rowId(s) selected`);
139
139
  },
140
140
  shortcutKeys: {
@@ -54,24 +54,22 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
54
54
  const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
55
55
  const columnDefs: ColDefT<ITestRow>[] = useMemo(
56
56
  () => [
57
- GridCell({
57
+ GridCell<ITestRow, ITestRow["id"]>({
58
58
  field: "id",
59
59
  headerName: "Id",
60
60
  lockVisible: true,
61
61
  resizable: false,
62
62
  lockPosition: "left",
63
- cellRenderer: (props) => {
64
- return <a href={"#"}>{props.value}</a>;
65
- },
63
+ cellRenderer: ({ value }) => <a href={"#"}>{value}</a>,
66
64
  }),
67
- GridCell({
65
+ GridCell<ITestRow, ITestRow["position"]>({
68
66
  field: "position",
69
67
  headerName: "Position",
70
68
  resizable: false,
71
69
  lockPosition: "left",
72
70
  cellRendererParams: {
73
- warning: (props) => props.value === "Tester" && "Testers are testing",
74
- info: (props) => props.value === "Developer" && "Developers are awesome",
71
+ warning: ({ value }) => value === "Tester" && "Testers are testing",
72
+ info: ({ value }) => value === "Developer" && "Developers are awesome",
75
73
  },
76
74
  }),
77
75
  GridCell({
@@ -82,12 +82,12 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
82
82
  field: "id",
83
83
  headerName: "Id",
84
84
  }),
85
- GridCell({
85
+ GridCell<ITestRow, ITestRow["position"]>({
86
86
  field: "position",
87
87
  headerName: "Position",
88
88
  cellRendererParams: {
89
- warning: (props) => props.value === "Tester" && "Testers are testing",
90
- info: (props) => props.value === "Developer" && "Developers are awesome",
89
+ warning: ({ value }) => value === "Tester" && "Testers are testing",
90
+ info: ({ value }) => value === "Developer" && "Developers are awesome",
91
91
  },
92
92
  }),
93
93
  GridCell({
@@ -15,13 +15,10 @@
15
15
  flex: 1;
16
16
  }
17
17
 
18
-
19
18
  .Grid-sortIsStale {
20
- span.ag-icon.ag-icon-desc::after {
21
- content: "*";
22
- }
23
-
24
- span.ag-icon.ag-icon-asc::after {
19
+ span.ag-sort-indicator-icon::before {
20
+ margin-left: -6px;
21
+ position: absolute;
25
22
  content: "*";
26
23
  }
27
24
  }