@linzjs/step-ag-grid 15.1.3 → 17.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 (127) hide show
  1. package/dist/GridTheme.scss +138 -106
  2. package/dist/index.css +1 -8
  3. package/dist/node_modules/@linzjs/lui/dist/assets/svg-content.d.ts +7 -0
  4. package/dist/src/components/ComponentLoadingWrapper.d.ts +3 -4
  5. package/dist/src/components/Grid.d.ts +2 -2
  6. package/dist/src/components/GridCell.d.ts +6 -6
  7. package/dist/src/components/GridCellMultiEditor.d.ts +2 -2
  8. package/dist/src/components/GridIcon.d.ts +2 -2
  9. package/dist/src/components/GridLoadableCell.d.ts +1 -2
  10. package/dist/src/components/GridNoRowsOverlay.d.ts +5 -4
  11. package/dist/src/components/GridPopoverHook.d.ts +3 -3
  12. package/dist/src/components/GridWrapper.d.ts +2 -3
  13. package/dist/src/components/PostSortRowsHook.d.ts +1 -1
  14. package/dist/src/components/gridFilter/GridFilterButtons.d.ts +2 -2
  15. package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +2 -2
  16. package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +1 -2
  17. package/dist/src/components/gridFilter/GridFilterQuick.d.ts +1 -2
  18. package/dist/src/components/gridFilter/GridFilters.d.ts +2 -5
  19. package/dist/src/components/gridForm/GridFormDropDown.d.ts +3 -3
  20. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -2
  21. package/dist/src/components/gridForm/GridFormMessage.d.ts +3 -3
  22. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +3 -3
  23. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +4 -4
  24. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +2 -2
  25. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +2 -2
  26. package/dist/src/components/gridForm/GridFormTextArea.d.ts +2 -2
  27. package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -2
  28. package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +1 -2
  29. package/dist/src/components/gridHook/useGridContextMenu.d.ts +1 -1
  30. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +2 -2
  31. package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +1 -2
  32. package/dist/src/contexts/GridContext.d.ts +5 -5
  33. package/dist/src/contexts/GridContextProvider.d.ts +2 -6
  34. package/dist/src/contexts/GridPopoverContextProvider.d.ts +2 -3
  35. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +2 -6
  36. package/dist/src/lui/ActionButton.d.ts +3 -3
  37. package/dist/src/lui/FormError.d.ts +3 -3
  38. package/dist/src/lui/TextAreaInput.d.ts +4 -4
  39. package/dist/src/lui/TextInputFormatted.d.ts +3 -3
  40. package/dist/src/react-menu3/components/ControlledMenu.d.ts +3 -3
  41. package/dist/src/react-menu3/components/FocusableItem.d.ts +4 -4
  42. package/dist/src/react-menu3/components/Menu.d.ts +2 -2
  43. package/dist/src/react-menu3/components/MenuButton.d.ts +1 -1
  44. package/dist/src/react-menu3/components/MenuDivider.d.ts +1 -1
  45. package/dist/src/react-menu3/components/MenuGroup.d.ts +2 -2
  46. package/dist/src/react-menu3/components/MenuHeader.d.ts +2 -2
  47. package/dist/src/react-menu3/components/MenuItem.d.ts +1 -1
  48. package/dist/src/react-menu3/components/MenuList.d.ts +1 -2
  49. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
  50. package/dist/src/react-menu3/components/SubMenu.d.ts +2 -2
  51. package/dist/src/react-menu3/utils/utils.d.ts +1 -1
  52. package/dist/src/react-menu3/utils/withHovering.d.ts +2 -2
  53. package/dist/src/utils/textValidator.d.ts +3 -3
  54. package/dist/step-ag-grid.cjs.js +1007 -3909
  55. package/dist/step-ag-grid.cjs.js.map +1 -1
  56. package/dist/step-ag-grid.esm.js +1008 -3910
  57. package/dist/step-ag-grid.esm.js.map +1 -1
  58. package/package.json +63 -59
  59. package/src/components/ComponentLoadingWrapper.tsx +9 -6
  60. package/src/components/Grid.tsx +32 -27
  61. package/src/components/GridCell.tsx +5 -5
  62. package/src/components/GridCellMultiEditor.tsx +2 -2
  63. package/src/components/GridIcon.tsx +2 -1
  64. package/src/components/GridNoRowsOverlay.tsx +10 -11
  65. package/src/components/GridPopoverHook.tsx +4 -4
  66. package/src/components/GridWrapper.tsx +2 -3
  67. package/src/components/PostSortRowsHook.ts +4 -4
  68. package/src/components/gridFilter/GridFilterButtons.tsx +2 -2
  69. package/src/components/gridFilter/GridFilterColumnsToggle.tsx +2 -2
  70. package/src/components/gridFilter/GridFilters.tsx +4 -6
  71. package/src/components/gridForm/GridFormDropDown.tsx +4 -4
  72. package/src/components/gridForm/GridFormMessage.tsx +3 -3
  73. package/src/components/gridForm/GridFormMultiSelect.tsx +2 -1
  74. package/src/components/gridForm/GridFormPopoverMenu.tsx +4 -4
  75. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +2 -2
  76. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +2 -2
  77. package/src/components/gridForm/GridFormTextArea.tsx +2 -2
  78. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +1 -1
  79. package/src/components/gridRender/GridRenderGenericCell.tsx +2 -1
  80. package/src/contexts/GridContext.tsx +5 -5
  81. package/src/contexts/GridContextProvider.tsx +57 -32
  82. package/src/contexts/GridPopoverContextProvider.tsx +2 -3
  83. package/src/contexts/GridUpdatingContextProvider.tsx +2 -6
  84. package/src/lui/ActionButton.tsx +4 -3
  85. package/src/lui/FormError.tsx +3 -1
  86. package/src/lui/TextAreaInput.tsx +3 -3
  87. package/src/lui/TextInputFormatted.tsx +5 -4
  88. package/src/lui/reactUtils.test.tsx +7 -6
  89. package/src/react-menu3/components/FocusableItem.tsx +2 -2
  90. package/src/react-menu3/utils/utils.ts +1 -1
  91. package/src/react-menu3/utils/withHovering.tsx +2 -2
  92. package/src/stories/components/ActionButton.stories.tsx +2 -1
  93. package/src/stories/grid/FormTest.tsx +4 -3
  94. package/src/stories/grid/GridFilterButtons.stories.tsx +13 -16
  95. package/src/stories/grid/GridNoRowsOverlay.stories.tsx +14 -11
  96. package/src/stories/grid/GridNonEditableRow.stories.tsx +13 -5
  97. package/src/stories/grid/GridPopoutContextMenu.stories.tsx +12 -4
  98. package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +12 -4
  99. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +13 -5
  100. package/src/stories/grid/GridPopoverEditBearing.stories.tsx +11 -3
  101. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +11 -3
  102. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +11 -3
  103. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +12 -3
  104. package/src/stories/grid/GridReadOnly.stories.tsx +22 -5
  105. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +15 -12
  106. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +20 -12
  107. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +20 -12
  108. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +13 -10
  109. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +19 -16
  110. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +21 -17
  111. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +13 -10
  112. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +15 -12
  113. package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +5 -2
  114. package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +5 -2
  115. package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +5 -2
  116. package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +6 -3
  117. package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +4 -1
  118. package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +4 -1
  119. package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +5 -2
  120. package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +5 -2
  121. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +25 -12
  122. package/src/stories/react-menu/ReactMenu.stories.tsx +6 -4
  123. package/src/styles/ComponentLoadingWrapper.scss +1 -4
  124. package/src/styles/Grid.scss +0 -4
  125. package/src/styles/GridTheme.scss +138 -106
  126. package/src/utils/testUtil.ts +3 -0
  127. package/src/utils/textValidator.ts +3 -1
@@ -1,5 +1,5 @@
1
1
  import { isEmpty } from "lodash-es";
2
- import { Fragment, useCallback, useEffect, useRef, useState } from "react";
2
+ import { Fragment, ReactElement, useCallback, useEffect, useRef, useState } from "react";
3
3
 
4
4
  import { useGridPopoverContext } from "../../contexts/GridPopoverContext";
5
5
  import { GridSubComponentContext } from "../../contexts/GridSubComponentContext";
@@ -28,11 +28,11 @@ export interface SelectedMenuOptionResult<RowType extends GridBaseRow> extends M
28
28
  }
29
29
 
30
30
  export interface MenuOption<RowType extends GridBaseRow> {
31
- label: JSX.Element | string | MenuSeparatorType;
31
+ label: ReactElement | string | MenuSeparatorType;
32
32
  action?: (props: { selectedRows: RowType[]; menuOption: SelectedMenuOptionResult<RowType> }) => Promise<void>;
33
33
  disabled?: string | boolean;
34
34
  hidden?: boolean;
35
- subComponent?: (props: any) => JSX.Element;
35
+ subComponent?: (props: any) => ReactElement;
36
36
  }
37
37
 
38
38
  /**
@@ -141,7 +141,7 @@ export const GridFormPopoverMenu = <RowType extends GridBaseRow>(props: GridForm
141
141
  disabled={!!item.disabled}
142
142
  title={item.disabled && typeof item.disabled !== "boolean" ? item.disabled : ""}
143
143
  >
144
- {item.label as JSX.Element | string}
144
+ {item.label as ReactElement | string}
145
145
  </MenuItem>
146
146
  {item.subComponent && subComponentSelected === item && (
147
147
  <FocusableItem className={"LuiDeprecatedForms"} key={`${item.label}_subcomponent`}>
@@ -1,5 +1,5 @@
1
1
  import clsx from "clsx";
2
- import { useCallback, useContext, useEffect } from "react";
2
+ import { ReactElement, useCallback, useContext, useEffect } from "react";
3
3
 
4
4
  import { GridSubComponentContext } from "../../contexts/GridSubComponentContext";
5
5
  import { TextAreaInput } from "../../lui/TextAreaInput";
@@ -19,7 +19,7 @@ export interface GridSubComponentTextAreaProps<RowType extends GridBaseRow>
19
19
 
20
20
  export const GridFormSubComponentTextArea = <RowType extends GridBaseRow>(
21
21
  props: GridSubComponentTextAreaProps<RowType>,
22
- ): JSX.Element => {
22
+ ): ReactElement => {
23
23
  const { value, data, setValue, setValid, context } = useContext(GridSubComponentContext);
24
24
 
25
25
  const helpText = props.helpText ?? "Press tab to save";
@@ -1,4 +1,4 @@
1
- import { useCallback, useContext, useEffect } from "react";
1
+ import { ReactElement, useCallback, useContext, useEffect } from "react";
2
2
 
3
3
  import { GridSubComponentContext } from "../../contexts/GridSubComponentContext";
4
4
  import { TextInputFormatted } from "../../lui/TextInputFormatted";
@@ -17,7 +17,7 @@ export interface GridFormSubComponentTextInputProps<RowType extends GridBaseRow>
17
17
 
18
18
  export const GridFormSubComponentTextInput = <RowType extends GridBaseRow>(
19
19
  props: GridFormSubComponentTextInputProps<RowType>,
20
- ): JSX.Element => {
20
+ ): ReactElement => {
21
21
  const { value, setValue, setValid, data, context } = useContext(GridSubComponentContext);
22
22
 
23
23
  const helpText = props.helpText ?? "Press enter or tab to save";
@@ -1,4 +1,4 @@
1
- import { useCallback, useMemo, useState } from "react";
1
+ import { ReactElement, useCallback, useMemo, useState } from "react";
2
2
 
3
3
  import { useGridPopoverContext } from "../../contexts/GridPopoverContext";
4
4
  import { TextAreaInput } from "../../lui/TextAreaInput";
@@ -16,7 +16,7 @@ export interface GridFormTextAreaProps<RowType extends GridBaseRow>
16
16
  helpText?: string;
17
17
  }
18
18
 
19
- export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormTextAreaProps<RowType>): JSX.Element => {
19
+ export const GridFormTextArea = <RowType extends GridBaseRow>(props: GridFormTextAreaProps<RowType>): ReactElement => {
20
20
  const { field, value: initialVale, data } = useGridPopoverContext<RowType>();
21
21
 
22
22
  const initValue = useMemo(() => (initialVale == null ? "" : `${initialVale}`), [initialVale]);
@@ -9,7 +9,7 @@ export const GridPopoverMessage = <RowType extends GridBaseRow>(
9
9
  ): ColDefT<RowType> =>
10
10
  GridCell(
11
11
  {
12
- resizable: false,
12
+ resizable: true,
13
13
  ...colDef,
14
14
  cellRendererParams: {
15
15
  singleClickEdit: true,
@@ -5,6 +5,7 @@ import {
5
5
  ValueFormatterParams,
6
6
  ValueGetterParams,
7
7
  } from "ag-grid-community/dist/lib/entities/colDef";
8
+ import { ReactElement } from "react";
8
9
 
9
10
  import { GridBaseRow } from "../Grid";
10
11
  import { ColDefT } from "../GridCell";
@@ -40,7 +41,7 @@ export interface GenericCellColDef<RowType extends GridBaseRow> extends ColDefT<
40
41
 
41
42
  export interface GenericCellRendererParams<RowType extends GridBaseRow> {
42
43
  singleClickEdit?: boolean;
43
- rightHoverElement?: JSX.Element | undefined;
44
+ rightHoverElement?: ReactElement | undefined;
44
45
  editAction?: (selectedRows: RowType[]) => void;
45
46
  shortcutKeys?: Record<string, ((params: SuppressKeyboardEventParams) => boolean | void) | undefined>;
46
47
  warning?: (props: RowICellRendererParams<RowType>) => string | string[] | boolean | null | undefined;
@@ -1,10 +1,10 @@
1
- import { ColDef, ColumnApi, GridApi, RowNode } from "ag-grid-community";
1
+ import { ColDef, ColumnApi, GridApi, IRowNode } from "ag-grid-community";
2
2
  import { CsvExportParams } from "ag-grid-community/dist/lib/interfaces/exportParams";
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: RowNode) => boolean;
7
+ export type GridFilterExternal<RowType extends GridBaseRow> = (data: RowType, rowNode: IRowNode) => boolean;
8
8
 
9
9
  export interface AutoSizeColumnsProps {
10
10
  skipHeader?: boolean;
@@ -36,7 +36,7 @@ export interface GridContextType<RowType extends GridBaseRow> {
36
36
  selectRowsByIdWithFlash: (rowIds?: number[]) => void;
37
37
  flashRows: (rowIds?: number[]) => void;
38
38
  flashRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
39
- focusByRowById: (rowId: number) => void;
39
+ focusByRowById: (rowId: number, ifNoCellFocused?: boolean) => void;
40
40
  ensureRowVisible: (id: number | string) => boolean;
41
41
  ensureSelectedRowIsVisible: () => void;
42
42
  getFirstRowId: () => number;
@@ -51,14 +51,14 @@ export interface GridContextType<RowType extends GridBaseRow> {
51
51
  setSaving?: (saving: boolean) => void,
52
52
  tabDirection?: 1 | 0 | -1,
53
53
  ) => Promise<boolean>;
54
- redrawRows: (rowNodes?: RowNode[]) => void;
54
+ redrawRows: (rowNodes?: IRowNode[]) => void;
55
55
  externallySelectedItemsAreInSync: boolean;
56
56
  setExternallySelectedItemsAreInSync: (inSync: boolean) => void;
57
57
  waitForExternallySelectedItemsToBeInSync: () => Promise<void>;
58
58
  addExternalFilter: (filter: GridFilterExternal<RowType>) => void;
59
59
  removeExternalFilter: (filter: GridFilterExternal<RowType>) => void;
60
60
  isExternalFilterPresent: () => boolean;
61
- doesExternalFilterPass: (node: RowNode) => boolean;
61
+ doesExternalFilterPass: (node: IRowNode) => boolean;
62
62
  invisibleColumnIds: string[] | undefined;
63
63
  setInvisibleColumnIds: (colIds: string[]) => void;
64
64
  downloadCsv: (csvExportParams?: CsvExportParams) => void;
@@ -1,10 +1,9 @@
1
- import { ColDef, ColumnApi, GridApi, RowNode } from "ag-grid-community";
2
- import { CellPosition } from "ag-grid-community/dist/lib/entities/cellPosition";
1
+ import { CellPosition, ColDef, ColumnApi, GridApi, IRowNode, RowNode } from "ag-grid-community";
3
2
  import { ValueFormatterParams } from "ag-grid-community/dist/lib/entities/colDef";
4
3
  import { CsvExportParams, ProcessCellForExportParams } from "ag-grid-community/dist/lib/interfaces/exportParams";
5
4
  import debounce from "debounce-promise";
6
5
  import { compact, defer, delay, difference, filter, isEmpty, last, pull, remove, sortBy, sumBy } from "lodash-es";
7
- import { ReactElement, ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
6
+ import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
8
7
 
9
8
  import { ColDefT, GridBaseRow } from "../components";
10
9
  import { GridCellFillerColId, isGridCellFiller } from "../components/GridCellFiller";
@@ -13,16 +12,12 @@ import { isNotEmpty, sanitiseFileName, wait } from "../utils/util";
13
12
  import { AutoSizeColumnsProps, AutoSizeColumnsResult, GridContext, GridFilterExternal } from "./GridContext";
14
13
  import { GridUpdatingContext } from "./GridUpdatingContext";
15
14
 
16
- interface GridContextProps {
17
- children: ReactNode;
18
- }
19
-
20
15
  /**
21
16
  * Context for AgGrid operations.
22
17
  * Make sure you wrap AgGrid in this.
23
18
  * Also, make sure the provider is created in a separate component, otherwise it won't be found.
24
19
  */
25
- export const GridContextProvider = <RowType extends GridBaseRow>(props: GridContextProps): ReactElement => {
20
+ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWithChildren): ReactElement => {
26
21
  const { modifyUpdating, checkUpdating } = useContext(GridUpdatingContext);
27
22
  const [gridApi, setGridApi] = useState<GridApi>();
28
23
  const [columnApi, setColumnApi] = useState<ColumnApi>();
@@ -167,7 +162,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
167
162
  * Find new row ids
168
163
  * Uses beforeUpdate ids to find new nodes.
169
164
  */
170
- const _getNewNodes = useCallback((): RowNode[] => {
165
+ const _getNewNodes = useCallback((): IRowNode[] => {
171
166
  return gridApiOp(
172
167
  (gridApi) =>
173
168
  compact(difference(_getAllRowIds(), idsBeforeUpdate.current).map((rowId) => gridApi.getRowNode("" + rowId))),
@@ -182,7 +177,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
182
177
  * @param rowIds Row ids to get from grid.
183
178
  */
184
179
  const _rowIdsToNodes = useCallback(
185
- (rowIds: number[]): RowNode[] => {
180
+ (rowIds: number[]): IRowNode[] => {
186
181
  return gridApiOp(
187
182
  (gridApi) => compact(rowIds.map((rowId) => gridApi.getRowNode("" + rowId))),
188
183
  () => [] as RowNode[],
@@ -218,10 +213,19 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
218
213
  */
219
214
  const _selectRowsWithOptionalFlash = useCallback(
220
215
  (
221
- rowIds: number[] | undefined,
222
- select: boolean,
223
- flash: boolean,
224
- retryCount = 15, // We retry for approximately 5x200ms=1s
216
+ {
217
+ rowIds,
218
+ select,
219
+ flash,
220
+ ifNoCellFocused = false,
221
+ retryCount = 15,
222
+ }: {
223
+ rowIds: number[] | undefined;
224
+ select: boolean;
225
+ flash: boolean;
226
+ ifNoCellFocused?: boolean;
227
+ retryCount?: number;
228
+ }, // We retry for approximately 5x200ms=1s
225
229
  ) => {
226
230
  return gridApiOp((gridApi) => {
227
231
  const rowNodes = rowIds ? _rowIdsToNodes(rowIds) : _getNewNodes();
@@ -230,7 +234,17 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
230
234
  const gridHasNotUpdated = gridRowIdsNotUpdatedYet || gridRowIdsNotChangedYet;
231
235
  // After retry count expires we give-up and deselect all rows, then select any subset of rows that have updated
232
236
  if (gridHasNotUpdated && retryCount > 0) {
233
- delay(() => _selectRowsWithOptionalFlash(rowIds, select, flash, retryCount - 1), 250);
237
+ delay(
238
+ () =>
239
+ _selectRowsWithOptionalFlash({
240
+ rowIds,
241
+ select,
242
+ flash,
243
+ ifNoCellFocused,
244
+ retryCount: retryCount - 1,
245
+ }),
246
+ 250,
247
+ );
234
248
  return;
235
249
  }
236
250
 
@@ -249,7 +263,13 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
249
263
  const colId = col.colId;
250
264
  // We need to make sure we aren't currently editing a cell otherwise tests will fail
251
265
  // as they will start to edit the cell before this stuff has a chance to run
252
- colId && defer(() => isEmpty(gridApi.getEditingCells()) && gridApi.setFocusedCell(rowIndex, colId));
266
+ colId &&
267
+ delay(() => {
268
+ if (isEmpty(gridApi.getEditingCells()) && (!ifNoCellFocused || gridApi.getFocusedCell() == null)) {
269
+ // ifNoCellFocused
270
+ gridApi.setFocusedCell(rowIndex, colId);
271
+ }
272
+ }, 100);
253
273
  }
254
274
  }
255
275
  }
@@ -278,17 +298,17 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
278
298
  );
279
299
 
280
300
  const selectRowsById = useCallback(
281
- (rowIds?: number[]) => _selectRowsWithOptionalFlash(rowIds, true, false),
301
+ (rowIds?: number[]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: false }),
282
302
  [_selectRowsWithOptionalFlash],
283
303
  );
284
304
 
285
305
  const selectRowsByIdWithFlash = useCallback(
286
- (rowIds?: number[]) => _selectRowsWithOptionalFlash(rowIds, true, true),
306
+ (rowIds?: number[]) => _selectRowsWithOptionalFlash({ rowIds, select: true, flash: true }),
287
307
  [_selectRowsWithOptionalFlash],
288
308
  );
289
309
 
290
310
  const flashRows = useCallback(
291
- (rowIds?: number[]) => _selectRowsWithOptionalFlash(rowIds, false, true),
311
+ (rowIds?: number[]) => _selectRowsWithOptionalFlash({ rowIds, select: false, flash: true }),
292
312
  [_selectRowsWithOptionalFlash],
293
313
  );
294
314
 
@@ -296,7 +316,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
296
316
  async (fn: () => Promise<any>) => {
297
317
  beforeUpdate();
298
318
  await fn();
299
- _selectRowsWithOptionalFlash(undefined, true, false);
319
+ _selectRowsWithOptionalFlash({ rowIds: undefined, select: true, flash: false });
300
320
  },
301
321
  [_selectRowsWithOptionalFlash, beforeUpdate],
302
322
  );
@@ -305,7 +325,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
305
325
  async (fn: () => Promise<any>) => {
306
326
  beforeUpdate();
307
327
  await fn();
308
- _selectRowsWithOptionalFlash(undefined, true, true);
328
+ _selectRowsWithOptionalFlash({ rowIds: undefined, select: true, flash: true });
309
329
  },
310
330
  [_selectRowsWithOptionalFlash, beforeUpdate],
311
331
  );
@@ -314,13 +334,14 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
314
334
  async (fn: () => Promise<any>) => {
315
335
  beforeUpdate();
316
336
  await fn();
317
- _selectRowsWithOptionalFlash(undefined, false, true);
337
+ _selectRowsWithOptionalFlash({ rowIds: undefined, select: false, flash: true });
318
338
  },
319
339
  [_selectRowsWithOptionalFlash, beforeUpdate],
320
340
  );
321
341
 
322
342
  const focusByRowById = useCallback(
323
- (rowId: number) => _selectRowsWithOptionalFlash([rowId], false, false),
343
+ (rowId: number, ifNoCellFocused?: boolean) =>
344
+ _selectRowsWithOptionalFlash({ rowIds: [rowId], select: false, flash: false, ifNoCellFocused }),
324
345
  [_selectRowsWithOptionalFlash],
325
346
  );
326
347
 
@@ -375,13 +396,17 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
375
396
  const autoSizeColumns = useCallback(
376
397
  ({ skipHeader, colIds, userSizedColIds }: AutoSizeColumnsProps = {}): AutoSizeColumnsResult => {
377
398
  if (!columnApi) return null;
378
- const colIdsSet = colIds instanceof Set ? colIds : new Set<string>(colIds ?? []);
379
- columnApi.getColumnState().forEach((col) => {
380
- const colId = col.colId;
381
- if ((isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId)) {
382
- columnApi.autoSizeColumn(colId, skipHeader);
383
- }
399
+ const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
400
+ const colsToResize = columnApi.getColumnState().filter((colState) => {
401
+ const colId = colState.colId;
402
+ return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId) && !colState.flex;
384
403
  });
404
+ if (!isEmpty(colsToResize)) {
405
+ columnApi.autoSizeColumns(
406
+ colsToResize.map((colState) => colState.colId),
407
+ skipHeader,
408
+ );
409
+ }
385
410
  return {
386
411
  width: sumBy(
387
412
  columnApi.getColumnState().filter((col) => !col.hide),
@@ -396,7 +421,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
396
421
  * Resize columns to fit container
397
422
  */
398
423
  const sizeColumnsToFit = useCallback((): void => {
399
- gridApi && gridApi.sizeColumnsToFit();
424
+ gridApi?.sizeColumnsToFit();
400
425
  }, [gridApi]);
401
426
 
402
427
  const stopEditing = useCallback((): void => {
@@ -565,7 +590,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
565
590
  );
566
591
 
567
592
  const redrawRows = useCallback(
568
- (rowNodes?: RowNode[]) => {
593
+ (rowNodes?: IRowNode[]) => {
569
594
  gridApiOp((gridApi) => gridApi.redrawRows(rowNodes ? { rowNodes } : undefined));
570
595
  },
571
596
  [gridApiOp],
@@ -604,7 +629,7 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: GridCont
604
629
 
605
630
  const isExternalFilterPresent = (): boolean => !isEmpty(externalFilters.current);
606
631
 
607
- const doesExternalFilterPass = (node: RowNode): boolean =>
632
+ const doesExternalFilterPass = (node: IRowNode): boolean =>
608
633
  externalFilters.current.every((filter) => filter(node.data, node));
609
634
 
610
635
  const getColDef = useCallback(
@@ -1,6 +1,6 @@
1
1
  import { ICellEditorParams } from "ag-grid-community";
2
2
  import { sortBy } from "lodash-es";
3
- import { ReactNode, RefObject, useCallback, useContext, useMemo, useRef, useState } from "react";
3
+ import { PropsWithChildren, RefObject, useCallback, useContext, useMemo, useRef, useState } from "react";
4
4
 
5
5
  import { GridBaseRow } from "../components/Grid";
6
6
  import { GridContext } from "./GridContext";
@@ -8,10 +8,9 @@ import { GridPopoverContext } from "./GridPopoverContext";
8
8
 
9
9
  interface GridPopoverContextProps {
10
10
  props: ICellEditorParams;
11
- children: ReactNode;
12
11
  }
13
12
 
14
- export const GridPopoverContextProvider = ({ props, children }: GridPopoverContextProps) => {
13
+ export const GridPopoverContextProvider = ({ props, children }: PropsWithChildren<GridPopoverContextProps>) => {
15
14
  const { getFilteredSelectedRows, updatingCells } = useContext(GridContext);
16
15
  const anchorRef = useRef<Element>(props.eGridCell);
17
16
 
@@ -1,19 +1,15 @@
1
1
  import { castArray, flatten, remove } from "lodash-es";
2
- import { ReactNode, useRef, useState } from "react";
2
+ import { PropsWithChildren, useRef, useState } from "react";
3
3
 
4
4
  import { GridUpdatingContext } from "./GridUpdatingContext";
5
5
 
6
- interface UpdatingContextProviderProps {
7
- children: ReactNode;
8
- }
9
-
10
6
  export type GridUpdatingContextStatus = Record<string, (number | string)[] | undefined>;
11
7
 
12
8
  type FieldName = string;
13
9
  type IdList = (number | string)[];
14
10
  type UpdatingBlock = Record<FieldName, IdList[]>;
15
11
 
16
- export const GridUpdatingContextProvider = (props: UpdatingContextProviderProps) => {
12
+ export const GridUpdatingContextProvider = (props: PropsWithChildren) => {
17
13
  const updatingBlocks = useRef<UpdatingBlock>({});
18
14
  const updating = useRef<GridUpdatingContextStatus>({});
19
15
  const [updatedDep, setUpdatedDep] = useState(0);
@@ -1,11 +1,12 @@
1
+ import "./ActionButton.scss";
2
+
1
3
  import clsx from "clsx";
2
- import { CSSProperties, useEffect, useState } from "react";
4
+ import { CSSProperties, ReactElement, useEffect, useState } from "react";
3
5
 
4
6
  import { LuiButton, LuiIcon, LuiMiniSpinner } from "@linzjs/lui";
5
7
  import { LuiButtonProps } from "@linzjs/lui/dist/components/LuiButton/LuiButton";
6
8
  import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
7
9
 
8
- import "./ActionButton.scss";
9
10
  import { usePrevious } from "./reactUtils";
10
11
  import { useStateDeferred } from "./stateDeferredHook";
11
12
 
@@ -42,7 +43,7 @@ export const ActionButton = ({
42
43
  iconPosition = "left",
43
44
  level = "tertiary",
44
45
  "aria-label": ariaLabel,
45
- }: ActionButtonProps): JSX.Element => {
46
+ }: ActionButtonProps): ReactElement => {
46
47
  const [inProgress, setInProgress] = useState(false);
47
48
  const lastInProgress = usePrevious(inProgress ?? false);
48
49
  const [localInProgress, setLocalInProgress, setLocalInProgressDeferred] = useStateDeferred<boolean>(inProgress);
@@ -1,8 +1,10 @@
1
1
  import "./FormError.scss";
2
2
 
3
+ import { ReactElement } from "react";
4
+
3
5
  export interface FormErrorProps {
4
6
  helpText?: string;
5
- error?: JSX.Element | string | boolean | null;
7
+ error?: ReactElement | string | boolean | null;
6
8
  }
7
9
 
8
10
  export const FormError = (props: FormErrorProps) => {
@@ -1,6 +1,6 @@
1
1
  import clsx from "clsx";
2
2
  import { omit } from "lodash-es";
3
- import { InputHTMLAttributes, useState } from "react";
3
+ import { InputHTMLAttributes, ReactElement, useState } from "react";
4
4
  import { v4 as uuidVersion4 } from "uuid";
5
5
 
6
6
  import { FormError } from "./FormError";
@@ -15,10 +15,10 @@ export interface LuiTextAreaInputProps extends InputHTMLAttributes<HTMLTextAreaE
15
15
  value: string;
16
16
 
17
17
  // Custom fields
18
- label?: JSX.Element | string;
18
+ label?: ReactElement | string;
19
19
  mandatory?: boolean;
20
20
  helpText?: string;
21
- error?: JSX.Element | string | boolean | null;
21
+ error?: ReactElement | string | boolean | null;
22
22
  allowTabToSave?: boolean;
23
23
  }
24
24
 
@@ -1,9 +1,10 @@
1
+ import "./TextInputFormatted.scss";
2
+
1
3
  import clsx from "clsx";
2
4
  import { omit } from "lodash-es";
3
- import { DetailedHTMLProps, InputHTMLAttributes } from "react";
5
+ import { DetailedHTMLProps, InputHTMLAttributes, ReactElement } from "react";
4
6
 
5
7
  import { FormError } from "./FormError";
6
- import "./TextInputFormatted.scss";
7
8
 
8
9
  export interface LuiTextInputProps extends DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
9
10
  // overrides value in base class to be string type only
@@ -11,12 +12,12 @@ export interface LuiTextInputProps extends DetailedHTMLProps<InputHTMLAttributes
11
12
 
12
13
  // Custom fields
13
14
  helpText?: string;
14
- error?: JSX.Element | string | boolean | null;
15
+ error?: ReactElement | string | boolean | null;
15
16
  formatted?: string;
16
17
  allowTabToSave?: boolean;
17
18
  }
18
19
 
19
- export const TextInputFormatted = (props: LuiTextInputProps): JSX.Element => {
20
+ export const TextInputFormatted = (props: LuiTextInputProps): ReactElement => {
20
21
  return (
21
22
  <div className={clsx("LuiTextInput Grid-popoverContainer", props.error && "hasError", props.className)}>
22
23
  <span className="LuiTextInput-inputWrapper">
@@ -1,6 +1,7 @@
1
1
  import { screen } from "@testing-library/dom";
2
- import { act, render } from "@testing-library/react";
3
- import { useEffect, useState } from "react";
2
+ import { render } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import { ReactElement, useEffect, useState } from "react";
4
5
 
5
6
  import { usePrevious } from "./reactUtils";
6
7
 
@@ -10,7 +11,7 @@ interface WrapperProps {
10
11
 
11
12
  let extPrevious: boolean | undefined = undefined;
12
13
 
13
- const UsePreviousWrapper = ({ value }: WrapperProps): JSX.Element => {
14
+ const UsePreviousWrapper = ({ value }: WrapperProps): ReactElement => {
14
15
  const previous = usePrevious<boolean>(value);
15
16
  useEffect(() => {
16
17
  extPrevious = previous;
@@ -19,7 +20,7 @@ const UsePreviousWrapper = ({ value }: WrapperProps): JSX.Element => {
19
20
  return <div />;
20
21
  };
21
22
 
22
- const TestComponent = (): JSX.Element => {
23
+ const TestComponent = (): ReactElement => {
23
24
  const [value, setValue] = useState(false);
24
25
 
25
26
  const toggleValue = () => setValue((value) => !value);
@@ -39,10 +40,10 @@ describe("usePrevious", () => {
39
40
 
40
41
  expect(extPrevious).toBeUndefined();
41
42
 
42
- act(() => button.click());
43
+ await userEvent.click(button);
43
44
  expect(extPrevious).toBe(false);
44
45
 
45
- act(() => button.click());
46
+ await userEvent.click(button);
46
47
  expect(extPrevious).toBe(true);
47
48
  });
48
49
  });
@@ -1,4 +1,4 @@
1
- import { LegacyRef, useContext, useMemo, useRef } from "react";
1
+ import { LegacyRef, ReactElement, useContext, useMemo, useRef } from "react";
2
2
 
3
3
  import { EventHandlersContext } from "../contexts/EventHandlersContext";
4
4
  import { useBEM, useCombinedRef, useItemState } from "../hooks";
@@ -8,7 +8,7 @@ import { withHoveringResultProps } from "../utils/withHovering";
8
8
 
9
9
  export interface FocusableItemProps extends BaseProps, withHoveringResultProps {
10
10
  disabled?: boolean;
11
- children: (ref: LegacyRef<any>) => JSX.Element;
11
+ children: (ref: LegacyRef<any>) => ReactElement;
12
12
  }
13
13
 
14
14
  export const FocusableItemFr = ({
@@ -25,7 +25,7 @@ export function safeCall<T, R>(fn: (arg?: T) => R, arg?: T): T | R {
25
25
 
26
26
  const internalKey = "_szhsinMenu";
27
27
  export const getName = (component: Record<string, any | undefined>) => component[internalKey];
28
- //export const defineName = <T extends any[]>(name: string, component: (...args: T) => JSX.Element) =>
28
+ //export const defineName = <T extends any[]>(name: string, component: (...args: T) => ReactElement) =>
29
29
  // Object.defineProperty(component, internalKey, { value: name });
30
30
 
31
31
  export const defineName = (
@@ -1,4 +1,4 @@
1
- import { MutableRefObject, PropsWithRef, forwardRef, memo, useContext, useRef } from "react";
1
+ import { MutableRefObject, PropsWithRef, ReactElement, forwardRef, memo, useContext, useRef } from "react";
2
2
 
3
3
  import { HoverItemContext } from "../contexts/HoverItemContext";
4
4
 
@@ -8,7 +8,7 @@ export interface withHoveringResultProps {
8
8
  menuItemRef?: MutableRefObject<HTMLLIElement>;
9
9
  }
10
10
 
11
- export const withHovering = <T,>(name: string, WrappedComponent: (props: T) => JSX.Element) => {
11
+ export const withHovering = <T,>(name: string, WrappedComponent: (props: T) => ReactElement) => {
12
12
  const Component = memo(WrappedComponent);
13
13
  const WithHovering = forwardRef((props: PropsWithRef<T>, ref) => {
14
14
  const menuItemRef = useRef<any>(null);
@@ -1,8 +1,9 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+
1
3
  import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
2
4
  import { useCallback } from "react";
3
5
 
4
6
  import "@linzjs/lui/dist/fonts";
5
- import "@linzjs/lui/dist/scss/base.scss";
6
7
 
7
8
  import { ActionButton } from "../../lui/ActionButton";
8
9
  import { wait } from "../../utils/util";
@@ -1,9 +1,10 @@
1
- import { useCallback, useState } from "react";
1
+ import "./FormTest.scss";
2
+
3
+ import { ReactElement, useCallback, useState } from "react";
2
4
 
3
5
  import { LuiAlertModal, LuiAlertModalButtons, LuiButton, LuiTextInput } from "@linzjs/lui";
4
6
 
5
7
  import { CellEditorCommon, FormError, useGridPopoverContext, useGridPopoverHook, wait } from "../..";
6
- import "./FormTest.scss";
7
8
 
8
9
  export interface IFormTestRow {
9
10
  id: number;
@@ -14,7 +15,7 @@ export interface IFormTestRow {
14
15
  distance: number | null;
15
16
  }
16
17
 
17
- export const FormTest = (props: CellEditorCommon): JSX.Element => {
18
+ export const FormTest = (props: CellEditorCommon): ReactElement => {
18
19
  const { value } = useGridPopoverContext<IFormTestRow>();
19
20
  const [v1, ...v2] = value.split(" ");
20
21
 
@@ -1,8 +1,13 @@
1
+ import "../../styles/GridTheme.scss";
2
+ import "../../styles/index.scss";
3
+ import "@linzjs/lui/dist/scss/base.scss";
4
+
5
+ import { expect } from "@storybook/jest";
1
6
  import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
7
+ import { waitFor } from "@storybook/testing-library";
2
8
  import { useMemo, useState } from "react";
3
9
 
4
10
  import "@linzjs/lui/dist/fonts";
5
- import "@linzjs/lui/dist/scss/base.scss";
6
11
 
7
12
  import {
8
13
  ColDefT,
@@ -16,26 +21,13 @@ import {
16
21
  GridUpdatingContextProvider,
17
22
  GridWrapper,
18
23
  } from "../..";
19
- import "../../styles/GridTheme.scss";
20
- import "../../styles/index.scss";
21
24
 
22
25
  export default {
23
26
  title: "Components / Grids",
24
27
  component: Grid,
25
28
  decorators: [
26
29
  (Story) => (
27
- <div
28
- style={{
29
- border: "1px solid #eee",
30
- display: "flex",
31
- flexDirection: "column",
32
- height: "100%",
33
- maxHeight: 500,
34
- maxWidth: "100%",
35
- minWidth: "480px",
36
- padding: "1em",
37
- }}
38
- >
30
+ <div style={{ width: 1024, height: 400, display: "flex" }}>
39
31
  <GridUpdatingContextProvider>
40
32
  <GridContextProvider>
41
33
  <Story />
@@ -113,4 +105,9 @@ const GridFilterButtonsTemplate: ComponentStory<typeof Grid> = (props: GridProps
113
105
  );
114
106
  };
115
107
 
116
- export const FilterButtonsExample = GridFilterButtonsTemplate.bind({});
108
+ export const _FilterButtonsExample = GridFilterButtonsTemplate.bind({});
109
+ _FilterButtonsExample.play = async ({ canvasElement }) => {
110
+ await waitFor(() => {
111
+ expect(canvasElement.querySelector(".Grid-ready")).toBeInTheDocument();
112
+ });
113
+ };