@linzjs/step-ag-grid 29.11.4 → 29.13.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 (87) hide show
  1. package/dist/src/components/Grid.d.ts +7 -12
  2. package/dist/src/components/GridCell.d.ts +2 -19
  3. package/dist/src/components/GridCellFiller.d.ts +1 -1
  4. package/dist/src/components/GridCellMultiEditor.d.ts +1 -2
  5. package/dist/src/components/GridPopoverHook.d.ts +1 -1
  6. package/dist/src/components/gridFilter/GridFilterButtons.d.ts +1 -1
  7. package/dist/src/components/gridFilter/useGridFilter.d.ts +1 -1
  8. package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
  9. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -1
  10. package/dist/src/components/gridForm/GridFormMessage.d.ts +1 -1
  11. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +1 -1
  12. package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +1 -1
  13. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +1 -1
  14. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +1 -1
  15. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +1 -1
  16. package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -1
  17. package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
  18. package/dist/src/components/gridHook/useGridContextMenu.d.ts +1 -1
  19. package/dist/src/components/gridPopoverEdit/GridButton.d.ts +1 -2
  20. package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +2 -2
  21. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +2 -2
  22. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +2 -2
  23. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +2 -2
  24. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +2 -2
  25. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +2 -2
  26. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +2 -2
  27. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +2 -2
  28. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +2 -2
  29. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +1 -2
  30. package/dist/src/components/index.d.ts +1 -0
  31. package/dist/src/components/types.d.ts +26 -0
  32. package/dist/src/contexts/GridContext.d.ts +12 -12
  33. package/dist/src/contexts/GridPopoverContext.d.ts +1 -1
  34. package/dist/src/utils/__tests__/storybookTestUtil.ts +28 -1
  35. package/dist/src/utils/__tests__/testQuick.ts +2 -0
  36. package/dist/src/utils/textValidator.d.ts +1 -1
  37. package/dist/src/utils/util.d.ts +1 -0
  38. package/dist/step-ag-grid.cjs +326 -214
  39. package/dist/step-ag-grid.cjs.map +1 -1
  40. package/dist/step-ag-grid.esm.js +327 -216
  41. package/dist/step-ag-grid.esm.js.map +1 -1
  42. package/package.json +5 -2
  43. package/src/components/Grid.tsx +130 -65
  44. package/src/components/GridCell.tsx +1 -25
  45. package/src/components/GridCellFiller.tsx +1 -1
  46. package/src/components/GridCellMultiEditor.tsx +2 -2
  47. package/src/components/GridPopoverHook.tsx +1 -1
  48. package/src/components/gridFilter/GridFilterButtons.tsx +1 -1
  49. package/src/components/gridFilter/useGridFilter.ts +1 -1
  50. package/src/components/gridForm/GridFormDropDown.tsx +1 -1
  51. package/src/components/gridForm/GridFormEditBearing.tsx +1 -1
  52. package/src/components/gridForm/GridFormMessage.tsx +1 -1
  53. package/src/components/gridForm/GridFormMultiSelect.tsx +1 -1
  54. package/src/components/gridForm/GridFormMultiSelectGrid.tsx +1 -1
  55. package/src/components/gridForm/GridFormPopoverMenu.tsx +1 -1
  56. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -1
  57. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -1
  58. package/src/components/gridForm/GridFormTextArea.tsx +1 -1
  59. package/src/components/gridForm/GridFormTextInput.tsx +1 -1
  60. package/src/components/gridHook/useGridContextMenu.tsx +1 -1
  61. package/src/components/gridPopoverEdit/GridButton.tsx +2 -2
  62. package/src/components/gridPopoverEdit/GridEditBoolean.tsx +2 -2
  63. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +2 -2
  64. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +2 -2
  65. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +2 -2
  66. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +2 -2
  67. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +2 -2
  68. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +2 -2
  69. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +2 -2
  70. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +2 -2
  71. package/src/components/gridRender/GridRenderGenericCell.tsx +1 -2
  72. package/src/components/index.ts +1 -0
  73. package/src/components/types.ts +32 -0
  74. package/src/contexts/GridContext.tsx +55 -148
  75. package/src/contexts/GridContextProvider.tsx +61 -56
  76. package/src/contexts/GridPopoverContext.tsx +1 -1
  77. package/src/contexts/GridPopoverContextProvider.tsx +1 -1
  78. package/src/react-menu3/components/MenuButton.tsx +2 -2
  79. package/src/react-menu3/hooks/useItemState.ts +1 -1
  80. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +3 -3
  81. package/src/stories/grid/GridReadOnly.stories.tsx +3 -3
  82. package/src/stories/grid/GridSorting.stories.tsx +189 -0
  83. package/src/utils/__tests__/storybookTestUtil.ts +28 -1
  84. package/src/utils/__tests__/testQuick.ts +2 -0
  85. package/src/utils/textValidator.test.ts +1 -1
  86. package/src/utils/textValidator.ts +1 -1
  87. package/src/utils/util.ts +19 -0
@@ -1,14 +1,7 @@
1
1
  import { ColDef, ColGroupDef, GridOptions, RowClickedEvent, RowDoubleClickedEvent } from 'ag-grid-community';
2
2
  import { ReactElement } from 'react';
3
3
  import { GridContextMenuComponent } from './gridHook';
4
- export interface GridBaseRow {
5
- id: string | number;
6
- }
7
- export interface GridOnRowDragEndProps<TData extends GridBaseRow> {
8
- movedRow: TData;
9
- targetRow: TData;
10
- direction: -1 | 1;
11
- }
4
+ import { GridBaseRow, GridOnRowDragEndProps } from './types';
12
5
  export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
13
6
  readOnly?: boolean;
14
7
  defaultPostSort?: boolean;
@@ -19,8 +12,10 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
19
12
  theme?: string;
20
13
  ['data-testid']?: string;
21
14
  domLayout?: GridOptions['domLayout'];
22
- externalSelectedItems?: any[];
23
- setExternalSelectedItems?: (items: any[]) => void;
15
+ externalSelectedItems?: TData[];
16
+ externalSelectedIds?: TData['id'][];
17
+ setExternalSelectedItems?: (items: TData[]) => void;
18
+ setExternalSelectedIds?: (ids: TData['id'][]) => void;
24
19
  defaultColDef?: GridOptions['defaultColDef'];
25
20
  columnDefs: ColDef<TData>[] | ColGroupDef<TData>[];
26
21
  rowData: GridOptions['rowData'];
@@ -74,7 +69,7 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
74
69
  /**
75
70
  * Context menu definition if required.
76
71
  */
77
- contextMenu?: GridContextMenuComponent<any>;
72
+ contextMenu?: GridContextMenuComponent<TData>;
78
73
  /**
79
74
  * Whether to select row on context menu.
80
75
  */
@@ -93,4 +88,4 @@ export interface GridProps<TData extends GridBaseRow = GridBaseRow> {
93
88
  /**
94
89
  * Wrapper for AgGrid to add commonly used functionality.
95
90
  */
96
- export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, onCellFocused: paramsOnCellFocused, maxInitialWidth, suppressReadOnlyStyle, ...params }: GridProps<TData>) => ReactElement;
91
+ export declare const Grid: <TData extends GridBaseRow = GridBaseRow>({ "data-testid": dataTestId, defaultPostSort, rowSelection, suppressColumnVirtualization, theme, sizeColumns, selectColumnPinned, contextMenuSelectRow, singleClickEdit, rowData, rowHeight, selectable, autoSelectFirstRow, onCellFocused: paramsOnCellFocused, maxInitialWidth, suppressReadOnlyStyle, externalSelectedItems, setExternalSelectedItems, externalSelectedIds, setExternalSelectedIds, ...params }: GridProps<TData>) => ReactElement;
@@ -1,30 +1,13 @@
1
- import { ColDef, EditableCallback, GetQuickFilterTextParams, ICellEditorParams, ICellRendererParams } from 'ag-grid-community';
2
- import { SuppressKeyboardEventParams, ValueFormatterFunc, ValueFormatterParams, ValueGetterFunc } from 'ag-grid-community';
1
+ import { GetQuickFilterTextParams, ICellEditorParams, ICellRendererParams, SuppressKeyboardEventParams, ValueFormatterFunc, ValueFormatterParams } from 'ag-grid-community';
3
2
  import { ReactElement } from 'react';
4
- import { GridBaseRow } from './Grid';
5
3
  import { GenericCellColDef } from './gridRender';
4
+ import { ColDefT, GridBaseRow } from './types';
6
5
  export interface GenericCellEditorProps<E> {
7
6
  multiEdit?: boolean;
8
7
  editor?: (editorProps: E) => ReactElement;
9
8
  editorParams?: E;
10
9
  }
11
10
  export declare const GridCellRenderer: (props: ICellRendererParams) => import("react/jsx-runtime").JSX.Element;
12
- export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends ColDef<TData, ValueType> {
13
- editable?: boolean | EditableCallback<TData, ValueType>;
14
- valueGetter?: string | ValueGetterFunc<TData, ValueType>;
15
- valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
16
- cellRenderer?: ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined) | string;
17
- cellRendererParams?: {
18
- rightHoverElement?: ReactElement;
19
- originalCellRenderer?: any;
20
- editAction?: (selectedRows: TData[]) => void;
21
- shortcutKeys?: Record<string, () => void>;
22
- error?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
23
- warning?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
24
- info?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
25
- };
26
- editor?: (editorProps: any) => ReactElement;
27
- }
28
11
  export declare const suppressCellKeyboardEvents: (e: SuppressKeyboardEventParams) => any;
29
12
  export declare const generateFilterGetter: <TData extends GridBaseRow, ValueType>(valueFormatter: string | ValueFormatterFunc<TData, ValueType> | undefined) => string | ((params: GetQuickFilterTextParams<TData, ValueType>) => string) | undefined;
30
13
  export declare const defaultValueFormatter: ({ value }: ValueFormatterParams) => string;
@@ -1,5 +1,5 @@
1
1
  import { ColDef } from 'ag-grid-community';
2
- import { GridBaseRow } from './Grid';
2
+ import { GridBaseRow } from './types';
3
3
  export declare const GridCellFillerColId = "gridCellFiller";
4
4
  export declare const isGridCellFiller: (col: ColDef) => boolean;
5
5
  export declare const GridCellFiller: <TData extends GridBaseRow>() => ColDef<TData, any>;
@@ -1,9 +1,8 @@
1
1
  import { CellEditorSelectorResult } from 'ag-grid-community';
2
2
  import { ICellEditorParams } from 'ag-grid-community';
3
3
  import { ComponentProps, ReactElement } from 'react';
4
- import { GridBaseRow } from './Grid';
5
- import { ColDefT } from './GridCell';
6
4
  import { GenericCellColDef } from './gridRender';
5
+ import { ColDefT, GridBaseRow } from './types';
7
6
  export declare const Editor: <FN extends (param: any) => ReactElement>(props: {
8
7
  multiEdit: boolean;
9
8
  editor: FN;
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { GridBaseRow } from './Grid';
2
+ import { GridBaseRow } from './types';
3
3
  export interface GridPopoverHookProps<TData> {
4
4
  className: string | undefined;
5
5
  invalid?: () => Promise<ReactElement | boolean | string | null | undefined> | ReactElement | boolean | string | null | undefined;
@@ -2,7 +2,7 @@ import { LuiButtonProps } from '@linzjs/lui/dist/components/LuiButton/LuiButton'
2
2
  import { ClassValue } from 'clsx';
3
3
  import { ReactElement } from 'react';
4
4
  import { GridFilterExternal } from '../../contexts/GridContext';
5
- import { GridBaseRow } from '../Grid';
5
+ import { GridBaseRow } from '../types';
6
6
  export interface GridFilterButtonsOption<TData extends GridBaseRow> {
7
7
  defaultSelected?: boolean;
8
8
  filter?: GridFilterExternal<TData>;
@@ -1,3 +1,3 @@
1
1
  import { GridFilterExternal } from '../../contexts/GridContext';
2
- import { GridBaseRow } from '../Grid';
2
+ import { GridBaseRow } from '../types';
3
3
  export declare const useGridFilter: <TData extends GridBaseRow>(filter: GridFilterExternal<TData> | undefined) => void;
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
- import { GridBaseRow } from '../Grid';
3
2
  import { CellEditorCommon } from '../GridCell';
3
+ import { GridBaseRow } from '../types';
4
4
  export interface GridPopoutEditDropDownSelectedItem<TData extends GridBaseRow, TOption> {
5
5
  selectedRows: TData[];
6
6
  selectedRowIds: TData['id'][];
@@ -1,5 +1,5 @@
1
- import { GridBaseRow } from '../Grid';
2
1
  import { CellEditorCommon } from '../GridCell';
2
+ import { GridBaseRow } from '../types';
3
3
  export interface GridFormEditBearingProps<TData extends GridBaseRow> extends CellEditorCommon {
4
4
  formatValue?: (value: any) => string;
5
5
  placeHolder?: string;
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
- import { GridBaseRow } from '../Grid';
3
2
  import { CellEditorCommon } from '../GridCell';
3
+ import { GridBaseRow } from '../types';
4
4
  export interface GridFormMessageProps<TData extends GridBaseRow> extends CellEditorCommon {
5
5
  message: (selectedRows: TData[]) => Promise<string | ReactElement> | string | ReactElement;
6
6
  }
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
- import { GridBaseRow } from '../Grid';
3
2
  import { CellEditorCommon } from '../GridCell';
3
+ import { GridBaseRow } from '../types';
4
4
  export interface MultiSelectOption {
5
5
  value: any;
6
6
  label?: string;
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
- import { GridBaseRow } from '../Grid';
3
2
  import { CellEditorCommon } from '../GridCell';
3
+ import { GridBaseRow } from '../types';
4
4
  export interface MultiSelectGridOption {
5
5
  value: any;
6
6
  label?: string | ReactElement;
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
- import { GridBaseRow } from '../Grid';
3
2
  import { CellEditorCommon } from '../GridCell';
3
+ import { GridBaseRow } from '../types';
4
4
  export interface GridFormPopoverMenuProps<TData extends GridBaseRow> extends CellEditorCommon {
5
5
  options: (selectedRows: TData[]) => Promise<MenuOption<TData>[]> | MenuOption<TData>[];
6
6
  defaultAction?: (props: {
@@ -1,7 +1,7 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { TextInputValidatorProps } from '../../utils/textValidator';
3
- import { GridBaseRow } from '../Grid';
4
3
  import { CellEditorCommon } from '../GridCell';
4
+ import { GridBaseRow } from '../types';
5
5
  export interface GridSubComponentTextAreaProps<TData extends GridBaseRow> extends TextInputValidatorProps<TData>, CellEditorCommon {
6
6
  placeholder?: string;
7
7
  width?: string | number;
@@ -1,7 +1,7 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { TextInputValidatorProps } from '../../utils/textValidator';
3
- import { GridBaseRow } from '../Grid';
4
3
  import { CellEditorCommon } from '../GridCell';
4
+ import { GridBaseRow } from '../types';
5
5
  export interface GridFormSubComponentTextInputProps<TData extends GridBaseRow> extends TextInputValidatorProps<TData>, CellEditorCommon {
6
6
  placeholder?: string;
7
7
  width?: string | number;
@@ -1,7 +1,7 @@
1
1
  import { ReactElement } from 'react';
2
2
  import { TextInputValidatorProps } from '../../utils/textValidator';
3
- import { GridBaseRow } from '../Grid';
4
3
  import { CellEditorCommon } from '../GridCell';
4
+ import { GridBaseRow } from '../types';
5
5
  export interface GridFormTextAreaProps<TData extends GridBaseRow> extends TextInputValidatorProps<TData>, CellEditorCommon {
6
6
  placeholder?: string;
7
7
  width?: string | number;
@@ -1,6 +1,6 @@
1
1
  import { TextInputValidatorProps } from '../../utils/textValidator';
2
- import { GridBaseRow } from '../Grid';
3
2
  import { CellEditorCommon } from '../GridCell';
3
+ import { GridBaseRow } from '../types';
4
4
  export interface GridFormTextInputProps<TData extends GridBaseRow> extends TextInputValidatorProps<TData>, CellEditorCommon {
5
5
  placeholder?: string;
6
6
  units?: string;
@@ -1,7 +1,7 @@
1
1
  import { ColDef } from 'ag-grid-community';
2
2
  import { CellContextMenuEvent } from 'ag-grid-community';
3
3
  import { ReactElement } from 'react';
4
- import { GridBaseRow } from '../Grid';
4
+ import { GridBaseRow } from '../types';
5
5
  export interface GridContextMenuComponentProps<TData extends GridBaseRow> {
6
6
  selectedRows: TData[];
7
7
  clickedRow: TData;
@@ -1,7 +1,6 @@
1
1
  import { ICellEditorParams } from 'ag-grid-community';
2
- import { GridBaseRow } from '../Grid';
3
- import { ColDefT } from '../GridCell';
4
2
  import { GenericCellColDef } from '../gridRender';
3
+ import { ColDefT, GridBaseRow } from '../types';
5
4
  export interface GridButtonProps<TData extends GridBaseRow> {
6
5
  visible?: (cellEditorParams: ICellEditorParams) => boolean;
7
6
  onClick?: (props: {
@@ -1,6 +1,6 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { CellEditorCommon, ColDefT } from '../GridCell';
1
+ import { CellEditorCommon } from '../GridCell';
3
2
  import { GenericCellColDef } from '../gridRender';
3
+ import { ColDefT, GridBaseRow } from '../types';
4
4
  export interface GridEditBooleanEditorProps<TData extends GridBaseRow> extends CellEditorCommon {
5
5
  onClick: (props: {
6
6
  selectedRows: TData[];
@@ -1,5 +1,5 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormMultiSelectProps } from '../gridForm/GridFormMultiSelect';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  export declare const GridPopoutEditMultiSelect: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormMultiSelectProps<TData>>) => ColDefT<TData, TValue>;
@@ -1,5 +1,5 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormMultiSelectGridProps } from '../gridForm/GridFormMultiSelectGrid';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  export declare const GridPopoutEditMultiSelectGrid: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormMultiSelectGridProps<TData>>) => ColDefT<TData, TValue>;
@@ -1,7 +1,7 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormEditBearingProps } from '../gridForm/GridFormEditBearing';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  export declare const GridPopoverEditBearingEditorParams: {
6
6
  placeHolder: string;
7
7
  formatValue: (value: any) => string;
@@ -1,5 +1,5 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormDropDownProps } from '../gridForm/GridFormDropDown';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  export declare const GridPopoverEditDropDown: <TData extends GridBaseRow, TValue = any, TOptionValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormDropDownProps<TData, TOptionValue>>) => ColDefT<TData, TValue>;
@@ -1,7 +1,7 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormPopoverMenuProps } from '../gridForm/GridFormPopoverMenu';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  /**
6
6
  * Popout burger menu
7
7
  */
@@ -1,5 +1,5 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormMessageProps } from '../gridForm/GridFormMessage';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  export declare const GridPopoverMessage: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, props: GenericCellEditorProps<GridFormMessageProps<TData>>) => ColDefT<TData, TValue>;
@@ -1,5 +1,5 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormTextAreaProps } from '../gridForm/GridFormTextArea';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  export declare const GridPopoverTextArea: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, params: GenericCellEditorProps<GridFormTextAreaProps<TData>>) => ColDefT<TData, TValue>;
@@ -1,5 +1,5 @@
1
- import { GridBaseRow } from '../Grid';
2
- import { ColDefT, GenericCellEditorProps } from '../GridCell';
1
+ import { GenericCellEditorProps } from '../GridCell';
3
2
  import { GridFormTextInputProps } from '../gridForm/GridFormTextInput';
4
3
  import { GenericCellColDef } from '../gridRender/GridRenderGenericCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
5
5
  export declare const GridPopoverTextInput: <TData extends GridBaseRow, TValue = any>(colDef: GenericCellColDef<TData, TValue>, params: GenericCellEditorProps<GridFormTextInputProps<TData>>) => ColDefT<TData, TValue>;
@@ -1,8 +1,7 @@
1
1
  import { ICellRendererParams } from 'ag-grid-community';
2
2
  import { SuppressKeyboardEventParams } from 'ag-grid-community';
3
3
  import { ReactElement } from 'react';
4
- import { GridBaseRow } from '../Grid';
5
- import { ColDefT } from '../GridCell';
4
+ import { ColDefT, GridBaseRow } from '../types';
6
5
  export interface GenericCellColDef<TData extends GridBaseRow, TValue = any> extends ColDefT<TData, TValue> {
7
6
  exportable?: boolean;
8
7
  }
@@ -15,3 +15,4 @@ export * from './GridPopoverHook';
15
15
  export * from './gridRender';
16
16
  export * from './GridWrapper';
17
17
  export * from './PostSortRowsHook';
18
+ export * from './types';
@@ -0,0 +1,26 @@
1
+ import { ColDef, EditableCallback, ICellRendererParams, ValueFormatterFunc, ValueGetterFunc } from 'ag-grid-community';
2
+ import { ReactElement } from 'react';
3
+ export interface GridBaseRow {
4
+ id: string | number;
5
+ }
6
+ export interface GridOnRowDragEndProps<TData extends GridBaseRow> {
7
+ movedRow: TData;
8
+ targetRow: TData;
9
+ direction: -1 | 1;
10
+ }
11
+ export interface ColDefT<TData extends GridBaseRow, ValueType = any> extends ColDef<TData, ValueType> {
12
+ editable?: boolean | EditableCallback<TData, ValueType>;
13
+ valueGetter?: string | ValueGetterFunc<TData, ValueType>;
14
+ valueFormatter?: string | ValueFormatterFunc<TData, ValueType>;
15
+ cellRenderer?: ((props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined) | string;
16
+ cellRendererParams?: {
17
+ rightHoverElement?: ReactElement;
18
+ originalCellRenderer?: any;
19
+ editAction?: (selectedRows: TData[]) => void;
20
+ shortcutKeys?: Record<string, () => void>;
21
+ error?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
22
+ warning?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
23
+ info?: (props: ICellRendererParams<TData, ValueType>) => ReactElement | string | false | null | undefined;
24
+ };
25
+ editor?: (editorProps: any) => ReactElement;
26
+ }
@@ -1,6 +1,6 @@
1
1
  import { ColDef, GridApi, IRowNode, ISizeColumnsToFitParams } from 'ag-grid-community';
2
2
  import { CsvExportParams } from 'ag-grid-community';
3
- import { ColDefT, GridBaseRow } from '../components';
3
+ import { ColDefT, GridBaseRow } from '../components/types';
4
4
  export type GridFilterExternal<TData extends GridBaseRow> = (data: TData, rowNode: IRowNode) => boolean;
5
5
  export interface AutoSizeColumnsProps {
6
6
  skipHeader?: boolean;
@@ -10,8 +10,8 @@ export interface AutoSizeColumnsProps {
10
10
  export type AutoSizeColumnsResult = {
11
11
  width: number;
12
12
  } | null;
13
- export interface StartCellEditingProps {
14
- rowId: number;
13
+ export interface StartCellEditingProps<TData extends GridBaseRow> {
14
+ rowId: TData['id'];
15
15
  colId: string;
16
16
  }
17
17
  export interface GridContextType<TData extends GridBaseRow> {
@@ -26,21 +26,21 @@ export interface GridContextType<TData extends GridBaseRow> {
26
26
  editingCells: () => boolean;
27
27
  getSelectedRows: <T extends GridBaseRow>() => T[];
28
28
  getFilteredSelectedRows: <T extends GridBaseRow>() => T[];
29
- getSelectedRowIds: () => number[];
30
- getFilteredSelectedRowIds: () => number[];
29
+ getSelectedRowIds: () => TData['id'][];
30
+ getFilteredSelectedRowIds: () => TData['id'][];
31
31
  selectRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
32
32
  selectRowsWithFlashDiff: (updateFn: () => Promise<any>) => Promise<void>;
33
- selectRowsById: (rowIds?: number[]) => void;
34
- selectRowsByIdWithFlash: (rowIds?: number[]) => void;
35
- flashRows: (rowIds?: number[]) => void;
33
+ selectRowsById: (rowIds?: TData['id'][]) => void;
34
+ selectRowsByIdWithFlash: (rowIds?: TData['id'][]) => void;
35
+ flashRows: (rowIds?: TData['id'][]) => void;
36
36
  flashRowsDiff: (updateFn: () => Promise<any>) => Promise<void>;
37
- focusByRowById: (rowId: number, ifNoCellFocused?: boolean) => void;
38
- ensureRowVisible: (id: number | string) => boolean;
37
+ focusByRowById: (rowId: TData['id'], ifNoCellFocused?: boolean) => void;
38
+ ensureRowVisible: (id: TData['id'] | string) => boolean;
39
39
  ensureSelectedRowIsVisible: () => void;
40
- getFirstRowId: () => number;
40
+ getFirstRowId: () => TData['id'];
41
41
  autoSizeColumns: (props?: AutoSizeColumnsProps) => Promise<AutoSizeColumnsResult>;
42
42
  sizeColumnsToFit: (paramsOrGridWidth?: ISizeColumnsToFitParams) => void;
43
- startCellEditing: ({ rowId, colId }: StartCellEditingProps) => Promise<void>;
43
+ startCellEditing: ({ rowId, colId }: StartCellEditingProps<TData>) => Promise<void>;
44
44
  resetFocusedCellAfterCellEditing: () => void;
45
45
  updatingCells: (props: {
46
46
  selectedRows: GridBaseRow[];
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- import { GridBaseRow } from '../components/Grid';
2
+ import { GridBaseRow } from '../components/types';
3
3
  export interface GridPopoverContextType<TData extends GridBaseRow> {
4
4
  anchorRef: RefObject<Element>;
5
5
  saving: boolean;
@@ -1,4 +1,31 @@
1
- import { expect, waitFor } from 'storybook/test';
1
+ import { sortBy } from 'lodash-es';
2
+ import { expect, userEvent, waitFor } from 'storybook/test';
3
+
4
+ import { findQuick, getAllQuick } from './testQuick';
2
5
 
3
6
  export const waitForGridReady = ({ canvasElement }: { canvasElement: HTMLElement }) =>
4
7
  waitFor(() => expect(canvasElement.querySelector('.Grid-ready')).toBeInTheDocument(), { timeout: 5000 });
8
+
9
+ export const waitForGridRows = async (props?: { grid?: HTMLElement; timeout?: number }) =>
10
+ waitFor(() => expect(getAllQuick({ classes: '.ag-row' }, props?.grid).length > 0).toBe(true), {
11
+ timeout: props?.timeout ?? 4000,
12
+ });
13
+
14
+ export const clickColumnHeaderToSort = async (colId: string, within: HTMLElement): Promise<void> => {
15
+ const user = userEvent.setup({
16
+ delay: 100,
17
+ });
18
+ const header = await findQuick({ selector: `.ag-header-cell[col-id="${colId}"]` }, within);
19
+ await expect(header).toBeInTheDocument();
20
+ // For some reason clicks in storybook don't trigger ag-grid, but manual clicks do
21
+ await user.click(header);
22
+ await user.keyboard('{Enter}');
23
+ };
24
+
25
+ export const gridColumnValues = (colId: string, within: HTMLElement): string[] => {
26
+ return sortBy(
27
+ getAllQuick({ tagName: `[col-id="${colId}"]`, classes: `.ag-cell` }, within),
28
+ // @ts-expect-error css style type
29
+ (el) => el.parentElement?.attributeStyleMap.get('transform')?.[0]?.y.value,
30
+ ).map((cell) => cell.innerText);
31
+ };
@@ -25,6 +25,7 @@ export interface IQueryQuick {
25
25
  role?: string;
26
26
  classes?: string;
27
27
  child?: IQueryQuick;
28
+ selector?: string;
28
29
  }
29
30
 
30
31
  const escapeSelectorParam = (param: string): string => param.replace(/["\\]/g, '\\$&');
@@ -51,6 +52,7 @@ const quickSelector = <T extends HTMLElement>(
51
52
  let lastIQueryQuick = props;
52
53
  for (let loop: IQueryQuick | undefined = props; loop; loop = loop.child) {
53
54
  lastIQueryQuick = loop;
55
+ loop.selector && (selector += loop.selector);
54
56
  loop.tagName && (selector += loop.tagName);
55
57
  loop.ariaLabel && (selector += `[aria-label='${escapeSelectorParam(loop.ariaLabel)}']`);
56
58
  loop.role && (selector += `[role="${escapeSelectorParam(loop.role)}"]`);
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { GridBaseRow } from '../components/Grid';
2
+ import { GridBaseRow } from '../components/types';
3
3
  export interface TextInputValidatorProps<TData extends GridBaseRow> {
4
4
  required?: boolean;
5
5
  maxLength?: number;
@@ -6,3 +6,4 @@ export declare const hasParentClass: (className: string, child: Node) => boolean
6
6
  export declare const stringByteLengthIsInvalid: (str: string, maxBytes: number) => boolean;
7
7
  export declare const fnOrVar: (fn: any, param?: any) => any;
8
8
  export declare const sanitiseFileName: (filename: string) => string;
9
+ export declare const compareNaturalInsensitive: (a?: object | string | number | null, b?: object | string | number | null) => number;