@linzjs/step-ag-grid 32.7.1 → 33.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 (58) hide show
  1. package/dist/src/components/gridFilter/GridFilterColumnsMultiSelect.d.ts +6 -25
  2. package/dist/step-ag-grid.cjs +117 -186
  3. package/dist/step-ag-grid.cjs.map +1 -1
  4. package/dist/step-ag-grid.esm.js +117 -186
  5. package/dist/step-ag-grid.esm.js.map +1 -1
  6. package/package.json +17 -17
  7. package/src/components/Grid.tsx +8 -10
  8. package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +110 -199
  9. package/src/components/gridHook/useGridRangeSelection.ts +8 -6
  10. package/src/react-menu3/components/ControlledMenu.tsx +5 -3
  11. package/src/react-menu3/components/MenuList.tsx +6 -3
  12. package/src/react-menu3/hooks/useItems.ts +1 -1
  13. package/src/stories/components/ActionButton.stories.tsx +12 -11
  14. package/src/stories/decorators/withOpenInPanelDecorator.tsx +35 -0
  15. package/src/stories/grid/GridCopy.stories.tsx +38 -35
  16. package/src/stories/grid/GridDragRow.stories.tsx +41 -36
  17. package/src/stories/grid/GridFilterButtons.stories.tsx +25 -19
  18. package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +42 -37
  19. package/src/stories/grid/GridInlineText.stories.tsx +42 -35
  20. package/src/stories/grid/GridNoRowsOverlay.stories.tsx +28 -23
  21. package/src/stories/grid/GridNonEditableRow.stories.tsx +30 -24
  22. package/src/stories/grid/GridPinnedRow.stories.tsx +37 -31
  23. package/src/stories/grid/GridPopoutContextMenu.stories.tsx +29 -24
  24. package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +89 -82
  25. package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +27 -22
  26. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +29 -24
  27. package/src/stories/grid/GridPopoverEditBearing.stories.tsx +30 -25
  28. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +29 -24
  29. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +29 -24
  30. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -24
  31. package/src/stories/grid/GridReadOnly.stories.tsx +56 -52
  32. package/src/stories/grid/GridSorting.stories.tsx +81 -79
  33. package/src/stories/grid/GridViewList.stories.tsx +31 -26
  34. package/src/stories/grid/GridViewSelectableList.stories.tsx +31 -26
  35. package/src/stories/grid/gridAutosize/GridAutoSize.stories.tsx +41 -37
  36. package/src/stories/grid/gridAutosize/GridFitSize.stories.tsx +40 -36
  37. package/src/stories/grid/gridAutosize/GridFitSizeFlex.stories.tsx +40 -36
  38. package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +14 -6
  39. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +74 -74
  40. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +59 -59
  41. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +58 -58
  42. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +62 -62
  43. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +118 -118
  44. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +107 -105
  45. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +72 -64
  46. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +82 -73
  47. package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +12 -13
  48. package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +12 -13
  49. package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +11 -13
  50. package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +11 -13
  51. package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +11 -13
  52. package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +11 -13
  53. package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +11 -13
  54. package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +11 -13
  55. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +110 -107
  56. package/src/stories/react-menu/ReactMenu.stories.tsx +70 -73
  57. package/src/styles/GridLoadableCell.scss +1 -1
  58. package/src/utils/useSharedInterval.ts +3 -3
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { countBy, mergeWith, pull, range, union } from 'lodash-es';
3
3
  import { useMemo, useState } from 'react';
4
4
 
@@ -6,27 +6,7 @@ import { ColDefT, Grid, GridCell, GridContextProvider, GridProps, GridUpdatingCo
6
6
  import { MultiSelectGridOption } from '../../components/gridForm/GridFormMultiSelectGrid';
7
7
  import { GridPopoutEditMultiSelectGrid } from '../../components/gridPopoverEdit/GridPopoutEditMultiSelectGrid';
8
8
  import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
9
- import { EditMultiSelect } from './GridPopoverEditMultiSelect.stories';
10
-
11
- export default {
12
- title: 'Components / Grids',
13
- component: Grid,
14
- args: {
15
- quickFilterValue: '',
16
- selectable: true,
17
- },
18
- decorators: [
19
- (Story) => (
20
- <div style={{ width: 1024, height: 400 }}>
21
- <GridUpdatingContextProvider>
22
- <GridContextProvider>
23
- <Story />
24
- </GridContextProvider>
25
- </GridUpdatingContextProvider>
26
- </div>
27
- ),
28
- ],
29
- } as Meta<typeof Grid>;
9
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
30
10
 
31
11
  interface ITestRow {
32
12
  id: number;
@@ -104,5 +84,29 @@ const GridEditMultiSelectGridTemplate: StoryFn<typeof Grid<ITestRow>> = (props:
104
84
  );
105
85
  };
106
86
 
107
- export const EditMultiSelectGrid = GridEditMultiSelectGridTemplate.bind({});
108
- EditMultiSelect.play = waitForGridReady;
87
+ const meta: Meta<typeof GridEditMultiSelectGridTemplate> = {
88
+ title: 'Components / Grids',
89
+ component: GridEditMultiSelectGridTemplate,
90
+ args: {
91
+ selectable: true,
92
+ },
93
+ decorators: [
94
+ (Story) => (
95
+ <div style={{ width: 1024, height: 400 }}>
96
+ <GridUpdatingContextProvider>
97
+ <GridContextProvider>
98
+ <Story />
99
+ </GridContextProvider>
100
+ </GridUpdatingContextProvider>
101
+ </div>
102
+ ),
103
+ withOpenInPanelDecorator,
104
+ ],
105
+ };
106
+ export default meta;
107
+
108
+ type Story = StoryObj<typeof meta>;
109
+
110
+ export const EditMultiSelectGrid: Story = {
111
+ play: waitForGridReady,
112
+ };
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { ReactElement, useCallback, useMemo, useState } from 'react';
3
3
  import { expect, fn, screen, userEvent } from 'storybook/test';
4
4
 
@@ -25,37 +25,7 @@ import {
25
25
  import { GridFilterColumnsToggle, GridFilterDownloadCsvButton } from '../../components';
26
26
  import { GridCellFiller } from '../../components/GridCellFiller';
27
27
  import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
28
-
29
- export default {
30
- title: 'Components / Grids',
31
- component: Grid,
32
- args: {
33
- quickFilter: true,
34
- quickFilterValue: '',
35
- quickFilterPlaceholder: 'Quick filter...',
36
- selectable: false,
37
- rowSelection: 'single',
38
- },
39
- // Storybook hangs otherwise
40
- parameters: {
41
- docs: {
42
- source: {
43
- type: 'code',
44
- },
45
- },
46
- },
47
- decorators: [
48
- (Story) => (
49
- <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
50
- <GridUpdatingContextProvider>
51
- <GridContextProvider>
52
- <Story />
53
- </GridContextProvider>
54
- </GridUpdatingContextProvider>
55
- </div>
56
- ),
57
- ],
58
- } as Meta<typeof Grid>;
28
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
59
29
 
60
30
  interface ITestRow {
61
31
  id: number;
@@ -288,8 +258,41 @@ const GridFilterLessThan = (props: {
288
258
  );
289
259
  };
290
260
 
291
- export const ReadOnlySingleSelection = GridReadOnlyTemplate.bind({});
292
- ReadOnlySingleSelection.play = waitForGridReady;
261
+ const meta: Meta<typeof GridReadOnlyTemplate> = {
262
+ title: 'Components / Grids',
263
+ component: GridReadOnlyTemplate,
264
+ args: {
265
+ selectable: false,
266
+ rowSelection: 'single',
267
+ },
268
+ // Storybook hangs otherwise
269
+ parameters: {
270
+ docs: {
271
+ source: {
272
+ type: 'code',
273
+ },
274
+ },
275
+ },
276
+ decorators: [
277
+ (Story) => (
278
+ <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
279
+ <GridUpdatingContextProvider>
280
+ <GridContextProvider>
281
+ <Story />
282
+ </GridContextProvider>
283
+ </GridUpdatingContextProvider>
284
+ </div>
285
+ ),
286
+ withOpenInPanelDecorator,
287
+ ],
288
+ };
289
+ export default meta;
290
+
291
+ type Story = StoryObj<typeof meta>;
292
+
293
+ export const ReadOnlySingleSelection: Story = {
294
+ play: waitForGridReady,
295
+ };
293
296
 
294
297
  interface IIgnoreReadOnlyRow {
295
298
  id: number;
@@ -298,7 +301,7 @@ interface IIgnoreReadOnlyRow {
298
301
 
299
302
  const disabledMenuItemAction = fn();
300
303
 
301
- const IgnoreGridReadOnlyTemplate: StoryFn<typeof Grid<IIgnoreReadOnlyRow>> = () => {
304
+ const IgnoreGridReadOnlyTemplate = () => {
302
305
  const columnDefs: ColDefT<IIgnoreReadOnlyRow>[] = useMemo(
303
306
  () => [
304
307
  GridCell<IIgnoreReadOnlyRow, IIgnoreReadOnlyRow['name']>({ field: 'name', headerName: 'Name' }),
@@ -336,25 +339,26 @@ const IgnoreGridReadOnlyTemplate: StoryFn<typeof Grid<IIgnoreReadOnlyRow>> = ()
336
339
  );
337
340
  };
338
341
 
339
- export const ReadOnlyIgnoreGridReadOnlyColumn = IgnoreGridReadOnlyTemplate.bind({});
340
- ReadOnlyIgnoreGridReadOnlyColumn.play = async (context) => {
341
- await waitForGridReady(context);
342
- const { canvasElement } = context;
342
+ export const ReadOnlyIgnoreGridReadOnlyColumn: Story = {
343
+ render: IgnoreGridReadOnlyTemplate,
344
+ play: async ({ canvasElement }) => {
345
+ await waitForGridReady({ canvasElement });
343
346
 
344
- const alwaysEnabledCell = canvasElement.querySelector('.ag-cell[col-id="alwaysEnabledActions"]');
345
- await expect(alwaysEnabledCell).toBeInTheDocument();
346
- await userEvent.click(alwaysEnabledCell as HTMLElement);
347
- await expect(await screen.findByRole('menuitem', { name: 'Locate feature' })).toBeInTheDocument();
347
+ const alwaysEnabledCell = canvasElement.querySelector('.ag-cell[col-id="alwaysEnabledActions"]');
348
+ await expect(alwaysEnabledCell).toBeInTheDocument();
349
+ await userEvent.click(alwaysEnabledCell as HTMLElement);
350
+ await expect(await screen.findByRole('menuitem', { name: 'Locate feature' })).toBeInTheDocument();
348
351
 
349
- const disabledItem = await screen.findByRole('menuitem', { name: 'Other action' });
350
- await expect(disabledItem).toHaveAttribute('aria-disabled', 'true');
351
- await userEvent.click(disabledItem);
352
- await expect(disabledMenuItemAction).not.toHaveBeenCalled();
352
+ const disabledItem = await screen.findByRole('menuitem', { name: 'Other action' });
353
+ await expect(disabledItem).toHaveAttribute('aria-disabled', 'true');
354
+ await userEvent.click(disabledItem);
355
+ await expect(disabledMenuItemAction).not.toHaveBeenCalled();
353
356
 
354
- await userEvent.keyboard('{Escape}');
357
+ await userEvent.keyboard('{Escape}');
355
358
 
356
- const blockedCell = canvasElement.querySelector('.ag-cell[col-id="blockedActions"]');
357
- await expect(blockedCell).toBeInTheDocument();
358
- await userEvent.click(blockedCell as HTMLElement);
359
- await expect(screen.queryByRole('menuitem', { name: 'Should not open' })).not.toBeInTheDocument();
359
+ const blockedCell = canvasElement.querySelector('.ag-cell[col-id="blockedActions"]');
360
+ await expect(blockedCell).toBeInTheDocument();
361
+ await userEvent.click(blockedCell as HTMLElement);
362
+ await expect(screen.queryByRole('menuitem', { name: 'Should not open' })).not.toBeInTheDocument();
363
+ },
360
364
  };
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { useMemo, useState } from 'react';
3
3
  import { expect } from 'storybook/test';
4
4
 
@@ -19,36 +19,7 @@ import {
19
19
  waitForGridReady,
20
20
  waitForGridRows,
21
21
  } from '../../utils/__tests__/storybookTestUtil';
22
-
23
- export default {
24
- title: 'Components / Grids',
25
- component: Grid,
26
- args: {
27
- quickFilter: true,
28
- quickFilterValue: '',
29
- quickFilterPlaceholder: 'Quick filter...',
30
- selectable: false,
31
- rowSelection: 'single',
32
- }, // Storybook hangs otherwise
33
- parameters: {
34
- docs: {
35
- source: {
36
- type: 'code',
37
- },
38
- },
39
- },
40
- decorators: [
41
- (Story) => (
42
- <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
43
- <GridUpdatingContextProvider>
44
- <GridContextProvider>
45
- <Story />
46
- </GridContextProvider>
47
- </GridUpdatingContextProvider>
48
- </div>
49
- ),
50
- ],
51
- } as Meta<typeof Grid>;
22
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
52
23
 
53
24
  interface ITestRow {
54
25
  id: number;
@@ -122,59 +93,90 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<I
122
93
  );
123
94
  };
124
95
 
125
- export const Sorting = GridReadOnlyTemplate.bind({});
126
- Sorting.play = async (context) => {
127
- const { canvasElement } = context;
128
- await waitForGridReady(context);
129
- await waitForGridRows({ grid: canvasElement });
96
+ const meta: Meta<typeof GridReadOnlyTemplate> = {
97
+ title: 'Components / Grids',
98
+ component: GridReadOnlyTemplate,
99
+ args: {
100
+ selectable: false,
101
+ rowSelection: 'single',
102
+ }, // Storybook hangs otherwise
103
+ parameters: {
104
+ docs: {
105
+ source: {
106
+ type: 'code',
107
+ },
108
+ },
109
+ },
110
+ decorators: [
111
+ (Story) => (
112
+ <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
113
+ <GridUpdatingContextProvider>
114
+ <GridContextProvider>
115
+ <Story />
116
+ </GridContextProvider>
117
+ </GridUpdatingContextProvider>
118
+ </div>
119
+ ),
120
+ withOpenInPanelDecorator,
121
+ ],
122
+ };
123
+ export default meta;
124
+
125
+ type Story = StoryObj<typeof meta>;
126
+
127
+ export const Sorting: Story = {
128
+ play: async ({ canvasElement }) => {
129
+ await waitForGridReady({ canvasElement });
130
+ await waitForGridRows({ grid: canvasElement });
130
131
 
131
- const test = async (colId: string | null, expected: string[] | null, idExpected?: string[]) => {
132
- if (colId !== null) {
133
- await clickColumnHeaderToSort(colId, canvasElement);
134
- await wait(500);
135
- if (expected) {
136
- expect(gridColumnValues(colId, canvasElement)).toEqual(expected);
132
+ const test = async (colId: string | null, expected: string[] | null, idExpected?: string[]) => {
133
+ if (colId !== null) {
134
+ await clickColumnHeaderToSort(colId, canvasElement);
135
+ await wait(500);
136
+ if (expected) {
137
+ await expect(gridColumnValues(colId, canvasElement)).toEqual(expected);
138
+ }
139
+ }
140
+ if (idExpected) {
141
+ await expect(gridColumnValues('id', canvasElement)).toEqual(idExpected);
137
142
  }
138
- }
139
- if (idExpected) {
140
- expect(gridColumnValues('id', canvasElement)).toEqual(idExpected);
141
- }
142
- };
143
+ };
143
144
 
144
- // Default sort order
145
- await test(null, null, ['1009', '1000', '1001', '1002', '1003', '1004', '1005', '1006', '1008', '1007']);
145
+ // Default sort order
146
+ await test(null, null, ['1009', '1000', '1001', '1002', '1003', '1004', '1005', '1006', '1008', '1007']);
146
147
 
147
- await test('numeric', ['–', '-1.1', '1', '2.01', '2.1', '2.21', '3', '3', '11', '21']);
148
- await test('numeric', ['21', '11', '3', '3', '2.21', '2.1', '2.01', '1', '-1.1', '–']);
148
+ await test('numeric', ['–', '-1.1', '1', '2.01', '2.1', '2.21', '3', '3', '11', '21']);
149
+ await test('numeric', ['21', '11', '3', '3', '2.21', '2.1', '2.01', '1', '-1.1', '–']);
149
150
 
150
- await test('text', ['–', '2', '10', 'ade', 'ade', 'b', 'b', 'cdc', 'e', 'e']);
151
- await test('text', ['e', 'e', 'cdc', 'b', 'b', 'ade', 'ade', '10', '2', '–']);
151
+ await test('text', ['–', '2', '10', 'ade', 'ade', 'b', 'b', 'cdc', 'e', 'e']);
152
+ await test('text', ['e', 'e', 'cdc', 'b', 'b', 'ade', 'ade', '10', '2', '–']);
152
153
 
153
- await test('customComparatorText', null, [
154
- '1000',
155
- '1001',
156
- '1002',
157
- '1003',
158
- '1004',
159
- '1005',
160
- '1006',
161
- '1007',
162
- '1008',
163
- '1009',
164
- ]);
165
- await test('customComparatorText', null, [
166
- '1009',
167
- '1008',
168
- '1007',
169
- '1006',
170
- '1005',
171
- '1004',
172
- '1003',
173
- '1002',
174
- '1001',
175
- '1000',
176
- ]);
154
+ await test('customComparatorText', null, [
155
+ '1000',
156
+ '1001',
157
+ '1002',
158
+ '1003',
159
+ '1004',
160
+ '1005',
161
+ '1006',
162
+ '1007',
163
+ '1008',
164
+ '1009',
165
+ ]);
166
+ await test('customComparatorText', null, [
167
+ '1009',
168
+ '1008',
169
+ '1007',
170
+ '1006',
171
+ '1005',
172
+ '1004',
173
+ '1003',
174
+ '1002',
175
+ '1001',
176
+ '1000',
177
+ ]);
177
178
 
178
- await test('customComparatorNumeric', ['–', '-1.1', '1', '2.01', '2.1', '2.21', '3', '3', '11', '21']);
179
- await test('customComparatorNumeric', ['21', '11', '3', '3', '2.21', '2.1', '2.01', '1', '-1.1', '–']);
179
+ await test('customComparatorNumeric', ['–', '-1.1', '1', '2.01', '2.1', '2.21', '3', '3', '11', '21']);
180
+ await test('customComparatorNumeric', ['21', '11', '3', '3', '2.21', '2.1', '2.01', '1', '-1.1', '–']);
181
+ },
180
182
  };
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { useMemo, useState } from 'react';
3
3
 
4
4
  import {
@@ -10,30 +10,7 @@ import {
10
10
  GridUpdatingContextProvider,
11
11
  GridWrapper,
12
12
  } from '../..';
13
-
14
- export default {
15
- title: 'Components / Grids',
16
- component: Grid,
17
- // Storybook hangs otherwise
18
- parameters: {
19
- docs: {
20
- source: {
21
- type: 'code',
22
- },
23
- },
24
- },
25
- decorators: [
26
- (Story) => (
27
- <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
28
- <GridUpdatingContextProvider>
29
- <GridContextProvider>
30
- <Story />
31
- </GridContextProvider>
32
- </GridUpdatingContextProvider>
33
- </div>
34
- ),
35
- ],
36
- } as Meta<typeof Grid>;
13
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
37
14
 
38
15
  interface ITestRow {
39
16
  id: number;
@@ -113,4 +90,32 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<I
113
90
  </GridWrapper>
114
91
  );
115
92
  };
116
- export const ListViewGrid = GridReadOnlyTemplate.bind({});
93
+ const meta: Meta<typeof GridReadOnlyTemplate> = {
94
+ title: 'Components / Grids',
95
+ component: GridReadOnlyTemplate,
96
+ // Storybook hangs otherwise
97
+ parameters: {
98
+ docs: {
99
+ source: {
100
+ type: 'code',
101
+ },
102
+ },
103
+ },
104
+ decorators: [
105
+ (Story) => (
106
+ <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
107
+ <GridUpdatingContextProvider>
108
+ <GridContextProvider>
109
+ <Story />
110
+ </GridContextProvider>
111
+ </GridUpdatingContextProvider>
112
+ </div>
113
+ ),
114
+ withOpenInPanelDecorator,
115
+ ],
116
+ };
117
+ export default meta;
118
+
119
+ type Story = StoryObj<typeof meta>;
120
+
121
+ export const ListViewGrid: Story = {};
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { useMemo, useState } from 'react';
3
3
 
4
4
  import {
@@ -10,30 +10,7 @@ import {
10
10
  GridUpdatingContextProvider,
11
11
  GridWrapper,
12
12
  } from '../..';
13
-
14
- export default {
15
- title: 'Components / Grids',
16
- component: Grid,
17
- // Storybook hangs otherwise
18
- parameters: {
19
- docs: {
20
- source: {
21
- type: 'code',
22
- },
23
- },
24
- },
25
- decorators: [
26
- (Story) => (
27
- <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
28
- <GridUpdatingContextProvider>
29
- <GridContextProvider>
30
- <Story />
31
- </GridContextProvider>
32
- </GridUpdatingContextProvider>
33
- </div>
34
- ),
35
- ],
36
- } as Meta<typeof Grid>;
13
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
37
14
 
38
15
  interface ITestRow {
39
16
  id: number;
@@ -113,4 +90,32 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<I
113
90
  </GridWrapper>
114
91
  );
115
92
  };
116
- export const SelectableListViewGrid = GridReadOnlyTemplate.bind({});
93
+ const meta: Meta<typeof GridReadOnlyTemplate> = {
94
+ title: 'Components / Grids',
95
+ component: GridReadOnlyTemplate,
96
+ // Storybook hangs otherwise
97
+ parameters: {
98
+ docs: {
99
+ source: {
100
+ type: 'code',
101
+ },
102
+ },
103
+ },
104
+ decorators: [
105
+ (Story) => (
106
+ <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
107
+ <GridUpdatingContextProvider>
108
+ <GridContextProvider>
109
+ <Story />
110
+ </GridContextProvider>
111
+ </GridUpdatingContextProvider>
112
+ </div>
113
+ ),
114
+ withOpenInPanelDecorator,
115
+ ],
116
+ };
117
+ export default meta;
118
+
119
+ type Story = StoryObj<typeof meta>;
120
+
121
+ export const SelectableListViewGrid: Story = {};
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { useMemo, useState } from 'react';
3
3
  import { expect } from 'storybook/test';
4
4
 
@@ -7,29 +7,9 @@ import { ChromaticAllowGridAutosize } from '../../../utils/isChromatic';
7
7
  import { findQuick } from '../../../utils/__tests__/testQuick';
8
8
  import { waitForGridReady } from '../../../utils/__tests__/storybookTestUtil';
9
9
  import { FormTest, IFormTestRow } from '../FormTest';
10
+ import { withOpenInPanelDecorator } from '../../decorators/withOpenInPanelDecorator';
10
11
 
11
- export default {
12
- title: 'Components / Grid Size',
13
- component: Grid,
14
- args: {
15
- quickFilterValue: '',
16
- selectable: true,
17
- },
18
- decorators: [
19
- (Story) => (
20
- <div style={{ width: 1024, height: 600, display: 'flex', flexDirection: 'column' }}>
21
- <GridUpdatingContextProvider>
22
- <GridContextProvider>
23
- <Story />
24
- </GridContextProvider>
25
- </GridUpdatingContextProvider>
26
- </div>
27
- ),
28
- ChromaticAllowGridAutosize,
29
- ],
30
- } as Meta<typeof Grid>;
31
-
32
- const GridPopoutEditGenericTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props: GridProps<IFormTestRow>) => {
12
+ const GridPopoutEditGenericTemplate = (props: GridProps<IFormTestRow>) => {
33
13
  const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
34
14
  const columnDefs: ColDefT<IFormTestRow>[] = useMemo(
35
15
  () => [
@@ -81,21 +61,45 @@ const GridPopoutEditGenericTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props
81
61
  );
82
62
  };
83
63
 
84
- export const _AutoSize = GridPopoutEditGenericTemplate.bind({});
85
- _AutoSize.play = async (context) => {
86
- await waitForGridReady(context);
87
- const { canvasElement } = context;
64
+ const meta: Meta<typeof GridPopoutEditGenericTemplate> = {
65
+ title: 'Components / Grid Size',
66
+ component: GridPopoutEditGenericTemplate,
67
+ args: {
68
+ selectable: true,
69
+ },
70
+ decorators: [
71
+ (Story) => (
72
+ <div style={{ width: 1024, height: 600, display: 'flex', flexDirection: 'column' }}>
73
+ <GridUpdatingContextProvider>
74
+ <GridContextProvider>
75
+ <Story />
76
+ </GridContextProvider>
77
+ </GridUpdatingContextProvider>
78
+ </div>
79
+ ),
80
+ ChromaticAllowGridAutosize,
81
+ withOpenInPanelDecorator,
82
+ ],
83
+ };
84
+ export default meta;
85
+
86
+ type Story = StoryObj<typeof meta>;
88
87
 
89
- const idHeader = await findQuick({ selector: '.ag-header-cell[col-id="id"]' }, canvasElement);
90
- const nameHeader = await findQuick({ selector: '.ag-header-cell[col-id="name"]' }, canvasElement);
91
- const headerViewport = await findQuick({ selector: '.ag-header-viewport' }, canvasElement);
88
+ export const _AutoSize: Story = {
89
+ play: async ({ canvasElement }) => {
90
+ await waitForGridReady({ canvasElement });
92
91
 
93
- const idWidth = idHeader.getBoundingClientRect().width;
94
- const nameWidth = nameHeader.getBoundingClientRect().width;
95
- const availableWidth = headerViewport.getBoundingClientRect().width;
92
+ const idHeader = await findQuick({ selector: '.ag-header-cell[col-id="id"]' }, canvasElement);
93
+ const nameHeader = await findQuick({ selector: '.ag-header-cell[col-id="name"]' }, canvasElement);
94
+ const headerViewport = await findQuick({ selector: '.ag-header-viewport' }, canvasElement);
96
95
 
97
- // id has no flex, so it autosizes to its short content ("Id" / "1000") rather than filling space
98
- await expect(idWidth).toBeLessThan(150);
99
- // name has flex: 1, so it flexes to consume all remaining space
100
- await expect(Math.abs(idWidth + nameWidth - availableWidth)).toBeLessThan(4);
96
+ const idWidth = idHeader.getBoundingClientRect().width;
97
+ const nameWidth = nameHeader.getBoundingClientRect().width;
98
+ const availableWidth = headerViewport.getBoundingClientRect().width;
99
+
100
+ // id has no flex, so it autosizes to its short content ("Id" / "1000") rather than filling space
101
+ await expect(idWidth).toBeLessThan(150);
102
+ // name has flex: 1, so it flexes to consume all remaining space
103
+ await expect(Math.abs(idWidth + nameWidth - availableWidth)).toBeLessThan(4);
104
+ },
101
105
  };