@linzjs/step-ag-grid 20.0.0 → 21.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 (180) hide show
  1. package/dist/src/components/ComponentLoadingWrapper.d.ts +9 -9
  2. package/dist/src/components/Grid.d.ts +80 -80
  3. package/dist/src/components/GridCell.d.ts +63 -27
  4. package/dist/src/components/GridCell.test.d.ts +1 -1
  5. package/dist/src/components/GridCellFiller.d.ts +5 -4
  6. package/dist/src/components/GridCellMultiEditor.d.ts +18 -18
  7. package/dist/src/components/GridCellMultiSelectClassRules.d.ts +2 -2
  8. package/dist/src/components/GridIcon.d.ts +9 -9
  9. package/dist/src/components/GridLoadableCell.d.ts +1 -1
  10. package/dist/src/components/GridNoRowsOverlay.d.ts +9 -9
  11. package/dist/src/components/GridPopoverHook.d.ts +12 -12
  12. package/dist/src/components/GridWrapper.d.ts +5 -5
  13. package/dist/src/components/PostSortRowsHook.d.ts +11 -11
  14. package/dist/src/components/gridFilter/GridFilterButtons.d.ts +16 -16
  15. package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +5 -5
  16. package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +2 -2
  17. package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +11 -11
  18. package/dist/src/components/gridFilter/GridFilterQuick.d.ts +5 -5
  19. package/dist/src/components/gridFilter/GridFilters.d.ts +2 -2
  20. package/dist/src/components/gridFilter/index.d.ts +7 -7
  21. package/dist/src/components/gridFilter/useGridFilter.d.ts +3 -3
  22. package/dist/src/components/gridForm/GridFormDropDown.d.ts +37 -37
  23. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +12 -12
  24. package/dist/src/components/gridForm/GridFormMessage.d.ts +7 -7
  25. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +36 -36
  26. package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +24 -24
  27. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +36 -36
  28. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +12 -12
  29. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +11 -11
  30. package/dist/src/components/gridForm/GridFormTextArea.d.ts +14 -14
  31. package/dist/src/components/gridForm/GridFormTextInput.d.ts +14 -14
  32. package/dist/src/components/gridForm/index.d.ts +10 -10
  33. package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +7 -7
  34. package/dist/src/components/gridHeader/index.d.ts +1 -1
  35. package/dist/src/components/gridHook/index.d.ts +1 -1
  36. package/dist/src/components/gridHook/useGridContextMenu.d.ts +19 -19
  37. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +5 -5
  38. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +5 -5
  39. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +16 -16
  40. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +5 -5
  41. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +8 -8
  42. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +5 -5
  43. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +5 -5
  44. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +5 -5
  45. package/dist/src/components/gridPopoverEdit/index.d.ts +9 -9
  46. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +16 -37
  47. package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +2 -2
  48. package/dist/src/components/gridRender/index.d.ts +2 -2
  49. package/dist/src/components/gridUtil.d.ts +3 -3
  50. package/dist/src/components/index.d.ts +18 -18
  51. package/dist/src/contexts/GridContext.d.ts +67 -67
  52. package/dist/src/contexts/GridContextProvider.d.ts +15 -15
  53. package/dist/src/contexts/GridContextProvider.test.d.ts +1 -1
  54. package/dist/src/contexts/GridPopoverContext.d.ts +15 -15
  55. package/dist/src/contexts/GridPopoverContextProvider.d.ts +7 -7
  56. package/dist/src/contexts/GridSubComponentContext.d.ts +10 -10
  57. package/dist/src/contexts/GridUpdatingContext.d.ts +8 -8
  58. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +3 -3
  59. package/dist/src/index.d.ts +17 -17
  60. package/dist/src/lui/ActionButton.d.ts +20 -20
  61. package/dist/src/lui/FormError.d.ts +7 -7
  62. package/dist/src/lui/TextAreaInput.d.ts +11 -11
  63. package/dist/src/lui/TextInputFormatted.d.ts +10 -10
  64. package/dist/src/lui/reactUtils.d.ts +6 -6
  65. package/dist/src/lui/reactUtils.test.d.ts +1 -1
  66. package/dist/src/lui/stateDeferredHook.d.ts +4 -4
  67. package/dist/src/lui/timeoutHook.d.ts +14 -14
  68. package/dist/src/lui/timeoutHook.test.d.ts +1 -1
  69. package/dist/src/react-menu3/components/ControlledMenu.d.ts +8 -8
  70. package/dist/src/react-menu3/components/FocusableItem.d.ts +9 -9
  71. package/dist/src/react-menu3/components/Menu.d.ts +16 -16
  72. package/dist/src/react-menu3/components/MenuButton.d.ts +8 -8
  73. package/dist/src/react-menu3/components/MenuDivider.d.ts +3 -3
  74. package/dist/src/react-menu3/components/MenuGroup.d.ts +12 -12
  75. package/dist/src/react-menu3/components/MenuHeader.d.ts +4 -4
  76. package/dist/src/react-menu3/components/MenuItem.d.ts +59 -59
  77. package/dist/src/react-menu3/components/MenuList.d.ts +2 -2
  78. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +25 -25
  79. package/dist/src/react-menu3/components/SubMenu.d.ts +110 -110
  80. package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +7 -7
  81. package/dist/src/react-menu3/contexts/HoverItemContext.d.ts +2 -2
  82. package/dist/src/react-menu3/contexts/ItemSettingsContext.d.ts +5 -5
  83. package/dist/src/react-menu3/contexts/MenuListContext.d.ts +9 -9
  84. package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +11 -11
  85. package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +7 -7
  86. package/dist/src/react-menu3/contexts/SettingsContext.d.ts +20 -20
  87. package/dist/src/react-menu3/hooks/index.d.ts +9 -9
  88. package/dist/src/react-menu3/hooks/useBEM.d.ts +10 -10
  89. package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +2 -2
  90. package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +3 -3
  91. package/dist/src/react-menu3/hooks/useItemEffect.d.ts +2 -2
  92. package/dist/src/react-menu3/hooks/useItemState.d.ts +7 -7
  93. package/dist/src/react-menu3/hooks/useItems.d.ts +7 -7
  94. package/dist/src/react-menu3/hooks/useMenuChange.d.ts +2 -2
  95. package/dist/src/react-menu3/hooks/useMenuState.d.ts +23 -14
  96. package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +2 -2
  97. package/dist/src/react-menu3/index.d.ts +11 -11
  98. package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +11 -11
  99. package/dist/src/react-menu3/positionUtils/index.d.ts +3 -3
  100. package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +8 -8
  101. package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +8 -8
  102. package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +19 -19
  103. package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +19 -19
  104. package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +13 -13
  105. package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +26 -26
  106. package/dist/src/react-menu3/style-utils/index.d.ts +11 -11
  107. package/dist/src/react-menu3/types.d.ts +401 -401
  108. package/dist/src/react-menu3/utils/constants.d.ts +54 -54
  109. package/dist/src/react-menu3/utils/index.d.ts +3 -3
  110. package/dist/src/react-menu3/utils/propTypes2.d.ts +56 -56
  111. package/dist/src/react-menu3/utils/utils.d.ts +37 -37
  112. package/dist/src/react-menu3/utils/withHovering.d.ts +7 -7
  113. package/dist/src/utils/bearing.d.ts +19 -19
  114. package/dist/src/utils/bearing.test.d.ts +1 -1
  115. package/dist/src/utils/deferredPromise.d.ts +5 -5
  116. package/dist/src/utils/storybookTestUtil.d.ts +3 -3
  117. package/dist/src/utils/testQuick.d.ts +62 -62
  118. package/dist/src/utils/testUtil.d.ts +46 -45
  119. package/dist/src/utils/textMatcher.d.ts +13 -13
  120. package/dist/src/utils/textMatcher.test.d.ts +1 -1
  121. package/dist/src/utils/textValidator.d.ts +18 -18
  122. package/dist/src/utils/textValidator.test.d.ts +1 -1
  123. package/dist/src/utils/util.d.ts +8 -8
  124. package/dist/src/utils/util.test.d.ts +1 -1
  125. package/dist/step-ag-grid.cjs.js +4652 -4651
  126. package/dist/step-ag-grid.cjs.js.map +1 -1
  127. package/dist/step-ag-grid.esm.js +4652 -4651
  128. package/dist/step-ag-grid.esm.js.map +1 -1
  129. package/dist/vite.config.d.ts +2 -0
  130. package/package.json +21 -20
  131. package/src/components/Grid.tsx +4 -4
  132. package/src/components/GridCell.test.tsx +2 -3
  133. package/src/components/GridCell.tsx +75 -23
  134. package/src/components/GridCellFiller.tsx +2 -1
  135. package/src/components/GridCellMultiEditor.tsx +9 -9
  136. package/src/components/GridCellMultiSelectClassRules.tsx +4 -4
  137. package/src/components/GridPopoverHook.tsx +4 -4
  138. package/src/components/PostSortRowsHook.ts +2 -2
  139. package/src/components/gridFilter/GridFilterButtons.tsx +6 -6
  140. package/src/components/gridFilter/GridFilterColumnsToggle.tsx +2 -5
  141. package/src/components/gridFilter/GridFilterDownloadCsvButton.tsx +1 -1
  142. package/src/components/gridFilter/useGridFilter.ts +1 -1
  143. package/src/components/gridForm/GridFormDropDown.tsx +9 -9
  144. package/src/components/gridForm/GridFormEditBearing.tsx +5 -5
  145. package/src/components/gridForm/GridFormMessage.tsx +4 -4
  146. package/src/components/gridForm/GridFormMultiSelect.tsx +9 -9
  147. package/src/components/gridForm/GridFormMultiSelectGrid.tsx +11 -11
  148. package/src/components/gridForm/GridFormPopoverMenu.tsx +13 -13
  149. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +4 -4
  150. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +4 -4
  151. package/src/components/gridForm/GridFormTextArea.tsx +6 -6
  152. package/src/components/gridForm/GridFormTextInput.tsx +7 -7
  153. package/src/components/gridHook/useGridContextMenu.tsx +8 -8
  154. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +6 -6
  155. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +6 -6
  156. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +16 -16
  157. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +6 -6
  158. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +5 -5
  159. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +5 -5
  160. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +5 -4
  161. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +5 -5
  162. package/src/components/gridRender/GridRenderGenericCell.tsx +6 -36
  163. package/src/contexts/GridContext.tsx +7 -7
  164. package/src/contexts/GridContextProvider.test.tsx +1 -1
  165. package/src/contexts/GridContextProvider.tsx +10 -10
  166. package/src/contexts/GridPopoverContext.tsx +6 -6
  167. package/src/stories/grid/GridDragRow.stories.tsx +4 -4
  168. package/src/stories/grid/GridNonEditableRow.stories.tsx +2 -3
  169. package/src/stories/grid/GridPopoutContextMenu.stories.tsx +2 -2
  170. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +1 -1
  171. package/src/stories/grid/GridPopoverEditBearing.stories.tsx +2 -2
  172. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +3 -3
  173. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +2 -2
  174. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +2 -2
  175. package/src/stories/grid/GridReadOnly.stories.tsx +6 -6
  176. package/src/stories/grid/GridViewList.stories.tsx +5 -7
  177. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +3 -3
  178. package/src/utils/testUtil.ts +49 -7
  179. package/src/utils/textValidator.ts +5 -5
  180. package/src/utils/util.ts +1 -1
@@ -1,6 +1,6 @@
1
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";
2
+ import { ValueFormatterParams } from "ag-grid-community";
3
+ import { CsvExportParams, ProcessCellForExportParams } from "ag-grid-community";
4
4
  import debounce from "debounce-promise";
5
5
  import { compact, defer, delay, difference, filter, isEmpty, last, pull, remove, sortBy, sumBy } from "lodash-es";
6
6
  import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
@@ -8,7 +8,7 @@ import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, us
8
8
  import { ColDefT, GridBaseRow } from "../components";
9
9
  import { GridCellFillerColId, isGridCellFiller } from "../components/GridCellFiller";
10
10
  import { getColId, isFlexColumn } from "../components/gridUtil";
11
- import { isNotEmpty, sanitiseFileName, wait } from "../utils/util";
11
+ import { fnOrVar, isNotEmpty, sanitiseFileName, wait } from "../utils/util";
12
12
  import { AutoSizeColumnsProps, AutoSizeColumnsResult, GridContext, GridFilterExternal } from "./GridContext";
13
13
  import { GridUpdatingContext } from "./GridUpdatingContext";
14
14
 
@@ -17,7 +17,7 @@ import { GridUpdatingContext } from "./GridUpdatingContext";
17
17
  * Make sure you wrap AgGrid in this.
18
18
  * Also, make sure the provider is created in a separate component, otherwise it won't be found.
19
19
  */
20
- export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWithChildren): ReactElement => {
20
+ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithChildren): ReactElement => {
21
21
  const { modifyUpdating, checkUpdating } = useContext(GridUpdatingContext);
22
22
  const [gridApi, setGridApi] = useState<GridApi>();
23
23
  const [columnApi, setColumnApi] = useState<ColumnApi>();
@@ -28,7 +28,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
28
28
  const idsBeforeUpdate = useRef<number[]>([]);
29
29
  const prePopupFocusedCell = useRef<CellPosition>();
30
30
  const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = useState(false);
31
- const externalFilters = useRef<GridFilterExternal<RowType>[]>([]);
31
+ const externalFilters = useRef<GridFilterExternal<TData>[]>([]);
32
32
 
33
33
  /**
34
34
  * Make extra sure the GridCellFillerColId never gets added to invisibleColumnIds as it's dynamically determined
@@ -204,8 +204,8 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
204
204
  const getColumns = useCallback(
205
205
  (
206
206
  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>[],
207
+ ): ColDefT<TData>[] =>
208
+ filter(columnApi?.getColumns()?.map((col) => col.getColDef()) ?? [], filterDef) as ColDefT<TData>[],
209
209
  [columnApi],
210
210
  );
211
211
 
@@ -639,12 +639,12 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
639
639
  [gridApi],
640
640
  );
641
641
 
642
- const addExternalFilter = (filter: GridFilterExternal<RowType>) => {
642
+ const addExternalFilter = (filter: GridFilterExternal<TData>) => {
643
643
  externalFilters.current.push(filter);
644
644
  onFilterChanged().then();
645
645
  };
646
646
 
647
- const removeExternalFilter = (filter: GridFilterExternal<RowType>) => {
647
+ const removeExternalFilter = (filter: GridFilterExternal<TData>) => {
648
648
  remove(externalFilters.current, (v) => v === filter);
649
649
  onFilterChanged().then();
650
650
  };
@@ -695,7 +695,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
695
695
  (csvExportParams?: CsvExportParams) => {
696
696
  if (!gridApi || !columnApi) return;
697
697
 
698
- const fileName = csvExportParams?.fileName && sanitiseFileName(csvExportParams.fileName);
698
+ const fileName = csvExportParams?.fileName && sanitiseFileName(fnOrVar(csvExportParams.fileName));
699
699
 
700
700
  const columnKeys = columnApi
701
701
  ?.getColumnState()
@@ -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({
@@ -112,7 +112,7 @@ const GridDragRowTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
112
112
  onRowDragEnd={async (row, _, targetIndex) => {
113
113
  alert(`Row ${row.id} request to be moved to index ${targetIndex}.`);
114
114
  }}
115
- rowDragText={(params) => `${params.rowNode?.data.id} - ${params.rowNode?.data.position}`}
115
+ rowDragText={({ rowNode }) => `${rowNode?.data.id} - ${rowNode?.data.position}`}
116
116
  />
117
117
  </GridWrapper>
118
118
  );
@@ -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,
@@ -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({
@@ -17,6 +17,43 @@ export const countRows = async (within?: HTMLElement): Promise<number> => {
17
17
  return getAllQuick({ tagName: `div[row-id]:not(:empty)` }, within).length;
18
18
  };
19
19
 
20
+ export const findRowByIndex = async (rowIndex: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
21
+ await waitFor(async () => {
22
+ expect(getAllQuick({ classes: ".ag-row" }).length > 0).toBe(true);
23
+ });
24
+ //if this is not wrapped in an act console errors are logged during testing
25
+ let row!: HTMLDivElement;
26
+ await act(async () => {
27
+ row = await findQuick<HTMLDivElement>(
28
+ { tagName: `.ag-center-cols-container div[row-index='${rowIndex}']:not(:empty)` },
29
+ within,
30
+ );
31
+ // @ts-ignore
32
+ let combineChildren = [...Array.from(row.children)];
33
+
34
+ const leftCols = queryQuick<HTMLDivElement>(
35
+ { tagName: `.ag-pinned-left-cols-container div[row-index='${rowIndex}']` },
36
+ within,
37
+ );
38
+ if (leftCols) {
39
+ // @ts-ignore
40
+ combineChildren = [...Array.from(leftCols.children), ...combineChildren];
41
+ }
42
+
43
+ const rightCols = queryQuick<HTMLDivElement>(
44
+ { tagName: `.ag-pinned-right-cols-container div[row-index='${rowIndex}']` },
45
+ within,
46
+ );
47
+ if (rightCols) {
48
+ // @ts-ignore
49
+ combineChildren = [...Array.from(rightCols.children), ...combineChildren];
50
+ }
51
+
52
+ row.replaceChildren(...combineChildren);
53
+ });
54
+ return row;
55
+ };
56
+
20
57
  export const findRow = async (rowId: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
21
58
  await waitFor(async () => {
22
59
  expect(getAllQuick({ classes: ".ag-row" }).length > 0).toBe(true);
@@ -29,7 +66,7 @@ export const findRow = async (rowId: number | string, within?: HTMLElement): Pro
29
66
  within,
30
67
  );
31
68
  // @ts-ignore
32
- let combineChildren = [...row.children];
69
+ let combineChildren = [...Array.from(row.children)];
33
70
 
34
71
  const leftCols = queryQuick<HTMLDivElement>(
35
72
  { tagName: `.ag-pinned-left-cols-container div[row-id='${rowId}']` },
@@ -37,7 +74,7 @@ export const findRow = async (rowId: number | string, within?: HTMLElement): Pro
37
74
  );
38
75
  if (leftCols) {
39
76
  // @ts-ignore
40
- combineChildren = [...leftCols.children, ...combineChildren];
77
+ combineChildren = [...Array.from(leftCols.children), ...combineChildren];
41
78
  }
42
79
 
43
80
  const rightCols = queryQuick<HTMLDivElement>(
@@ -46,7 +83,7 @@ export const findRow = async (rowId: number | string, within?: HTMLElement): Pro
46
83
  );
47
84
  if (rightCols) {
48
85
  // @ts-ignore
49
- combineChildren = [...rightCols.children, ...combineChildren];
86
+ combineChildren = [...Array.from(rightCols.children), ...combineChildren];
50
87
  }
51
88
 
52
89
  row.replaceChildren(...combineChildren);
@@ -108,9 +145,14 @@ export const selectCell = async (rowId: string | number, colId: string, within?:
108
145
  };
109
146
 
110
147
  export const editCell = async (rowId: number | string, colId: string, within?: HTMLElement): Promise<void> => {
111
- const cell = await findCell(rowId, colId, within);
112
- await user.dblClick(cell);
113
- await waitFor(findOpenPopover);
148
+ await waitFor(
149
+ async () => {
150
+ const cell = await findCell(rowId, colId, within);
151
+ await user.dblClick(cell);
152
+ await waitFor(findOpenPopover, { timeout: 1000 });
153
+ },
154
+ { timeout: 10000 },
155
+ );
114
156
  };
115
157
 
116
158
  export const isCellReadOnly = async (rowId: number | string, colId: string, within?: HTMLElement): Promise<boolean> => {
@@ -118,7 +160,7 @@ export const isCellReadOnly = async (rowId: number | string, colId: string, with
118
160
  return cell.className.includes("GridCell-readonly");
119
161
  };
120
162
 
121
- export const findOpenPopover = async (): Promise<HTMLElement> => findQuick({ classes: ".szh-menu--state-open" });
163
+ export const findOpenPopover = () => findQuick({ classes: ".szh-menu--state-open" });
122
164
 
123
165
  export const queryMenuOption = async (menuOptionText: string | RegExp): Promise<HTMLElement | null> => {
124
166
  const openMenu = await findOpenPopover();
@@ -3,11 +3,11 @@ import { ReactElement } from "react";
3
3
  import { GridBaseRow } from "../components/Grid";
4
4
  import { isFloat, stringByteLengthIsInvalid } from "./util";
5
5
 
6
- export interface TextInputValidatorProps<RowType extends GridBaseRow> {
6
+ export interface TextInputValidatorProps<TData extends GridBaseRow> {
7
7
  required?: boolean;
8
8
  maxLength?: number;
9
9
  maxBytes?: number;
10
- invalid?: (value: string, data: RowType, context: any) => ReactElement | string | null;
10
+ invalid?: (value: string, data: TData, context: any) => ReactElement | string | null;
11
11
  numberFormat?: {
12
12
  precision?: number;
13
13
  scale?: number;
@@ -19,10 +19,10 @@ export interface TextInputValidatorProps<RowType extends GridBaseRow> {
19
19
  };
20
20
  }
21
21
 
22
- export const TextInputValidator = <RowType extends GridBaseRow>(
23
- props: TextInputValidatorProps<RowType>,
22
+ export const TextInputValidator = <TData extends GridBaseRow>(
23
+ props: TextInputValidatorProps<TData>,
24
24
  value: string | null,
25
- data: RowType,
25
+ data: TData,
26
26
  context: any,
27
27
  ) => {
28
28
  if (value == null) return null;
package/src/utils/util.ts CHANGED
@@ -44,7 +44,7 @@ export const hasParentClass = function (className: string, child: Node) {
44
44
  export const stringByteLengthIsInvalid = (str: string, maxBytes: number) =>
45
45
  new TextEncoder().encode(str).length > maxBytes;
46
46
 
47
- export const fnOrVar = (fn: any, param: any) => (typeof fn === "function" ? fn(param) : fn);
47
+ export const fnOrVar = (fn: any, param?: any) => (typeof fn === "function" ? fn(param) : fn);
48
48
 
49
49
  export const sanitiseFileName = (filename: string): string => {
50
50
  const valid = filename