@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,5 +1,5 @@
1
1
  import { LuiMessagingContextProvider } from '@linzjs/lui';
2
- import { Meta, StoryFn } from '@storybook/react-vite';
2
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
3
3
  import { useMemo, useState } from 'react';
4
4
 
5
5
  import {
@@ -19,38 +19,7 @@ import { GridFilterColumnsToggle, GridFilterDownloadCsvButton } from '../../comp
19
19
  import { GridCellFiller } from '../../components/GridCellFiller';
20
20
  import { SeededRandomForTests } from '../../utils/__tests__/random';
21
21
  import { waitForGridReady } 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: 'multiple',
32
- }, // Storybook hangs otherwise
33
- parameters: {
34
- docs: {
35
- source: {
36
- type: 'code',
37
- },
38
- },
39
- },
40
- decorators: [
41
- (Story) => (
42
- <LuiMessagingContextProvider version="v2">
43
- <div style={{ width: 1024, height: '80vh', display: 'flex', flexDirection: 'column' }}>
44
- <GridUpdatingContextProvider>
45
- <GridContextProvider>
46
- <Story />
47
- </GridContextProvider>
48
- </GridUpdatingContextProvider>
49
- </div>
50
- </LuiMessagingContextProvider>
51
- ),
52
- ],
53
- } as Meta<typeof Grid>;
22
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
54
23
 
55
24
  interface ITestRow {
56
25
  id: number;
@@ -155,5 +124,39 @@ const GridCopyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITest
155
124
  );
156
125
  };
157
126
 
158
- export const GridCopy = GridCopyTemplate.bind({});
159
- GridCopy.play = waitForGridReady;
127
+ const meta: Meta<typeof GridCopyTemplate> = {
128
+ title: 'Components / Grids',
129
+ component: GridCopyTemplate,
130
+ args: {
131
+ selectable: false,
132
+ rowSelection: 'multiple',
133
+ }, // Storybook hangs otherwise
134
+ parameters: {
135
+ docs: {
136
+ source: {
137
+ type: 'code',
138
+ },
139
+ },
140
+ },
141
+ decorators: [
142
+ (Story) => (
143
+ <LuiMessagingContextProvider version="v2">
144
+ <div style={{ width: 1024, height: '80vh', display: 'flex', flexDirection: 'column' }}>
145
+ <GridUpdatingContextProvider>
146
+ <GridContextProvider>
147
+ <Story />
148
+ </GridContextProvider>
149
+ </GridUpdatingContextProvider>
150
+ </div>
151
+ </LuiMessagingContextProvider>
152
+ ),
153
+ withOpenInPanelDecorator,
154
+ ],
155
+ };
156
+ export default meta;
157
+
158
+ type Story = StoryObj<typeof meta>;
159
+
160
+ export const GridCopy: Story = {
161
+ play: waitForGridReady,
162
+ };
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { useCallback, useMemo, useState } from 'react';
3
3
 
4
4
  import {
@@ -13,37 +13,7 @@ import {
13
13
  reorderRows,
14
14
  } from '../..';
15
15
  import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
16
-
17
- export default {
18
- title: 'Components / Grids',
19
- component: Grid,
20
- args: {
21
- quickFilter: true,
22
- quickFilterValue: '',
23
- quickFilterPlaceholder: 'Quick filter...',
24
- selectable: false,
25
- rowSelection: 'single',
26
- },
27
- // Storybook hangs otherwise
28
- parameters: {
29
- docs: {
30
- source: {
31
- type: 'code',
32
- },
33
- },
34
- },
35
- decorators: [
36
- (Story) => (
37
- <div style={{ width: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
38
- <GridUpdatingContextProvider>
39
- <GridContextProvider>
40
- <Story />
41
- </GridContextProvider>
42
- </GridUpdatingContextProvider>
43
- </div>
44
- ),
45
- ],
46
- } as Meta<typeof Grid>;
16
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
47
17
 
48
18
  interface ITestRow {
49
19
  id: number;
@@ -116,8 +86,41 @@ const GridDragRowTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<IT
116
86
  );
117
87
  };
118
88
 
119
- export const DragRowSingleSelection = GridDragRowTemplate.bind({});
120
- DragRowSingleSelection.play = waitForGridReady;
89
+ const meta: Meta<typeof GridDragRowTemplate> = {
90
+ title: 'Components / Grids',
91
+ component: GridDragRowTemplate,
92
+ args: {
93
+ selectable: false,
94
+ rowSelection: 'single',
95
+ },
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 DragRowSingleSelection: Story = {
122
+ play: waitForGridReady,
123
+ };
121
124
 
122
125
  const GridDragRowMultiTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITestRow>) => {
123
126
  const columnDefs: ColDefT<ITestRow>[] = useMemo(
@@ -174,5 +177,7 @@ const GridDragRowMultiTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridPro
174
177
  );
175
178
  };
176
179
 
177
- export const DragRowMultiSelection = GridDragRowMultiTemplate.bind({});
178
- DragRowMultiSelection.play = waitForGridReady;
180
+ export const DragRowMultiSelection: Story = {
181
+ render: GridDragRowMultiTemplate,
182
+ play: waitForGridReady,
183
+ };
@@ -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 {
@@ -14,22 +14,7 @@ import {
14
14
  GridWrapper,
15
15
  } from '../..';
16
16
  import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
17
-
18
- export default {
19
- title: 'Components / Grids',
20
- component: Grid,
21
- decorators: [
22
- (Story) => (
23
- <div style={{ width: 1024, height: 400, display: 'flex' }}>
24
- <GridUpdatingContextProvider>
25
- <GridContextProvider>
26
- <Story />
27
- </GridContextProvider>
28
- </GridUpdatingContextProvider>
29
- </div>
30
- ),
31
- ],
32
- } as Meta<typeof Grid>;
17
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
33
18
 
34
19
  interface ITestRow {
35
20
  id: number;
@@ -104,5 +89,26 @@ const GridFilterButtonsTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridPr
104
89
  );
105
90
  };
106
91
 
107
- export const _FilterButtonsExample = GridFilterButtonsTemplate.bind({});
108
- _FilterButtonsExample.play = waitForGridReady;
92
+ const meta: Meta<typeof GridFilterButtonsTemplate> = {
93
+ title: 'Components / Grids',
94
+ component: GridFilterButtonsTemplate,
95
+ decorators: [
96
+ (Story) => (
97
+ <div style={{ width: 1024, height: 400, display: 'flex' }}>
98
+ <GridUpdatingContextProvider>
99
+ <GridContextProvider>
100
+ <Story />
101
+ </GridContextProvider>
102
+ </GridUpdatingContextProvider>
103
+ </div>
104
+ ),
105
+ withOpenInPanelDecorator,
106
+ ],
107
+ };
108
+ export default meta;
109
+
110
+ type Story = StoryObj<typeof meta>;
111
+
112
+ export const _FilterButtonsExample: Story = {
113
+ play: waitForGridReady,
114
+ };
@@ -1,9 +1,9 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import {
3
3
  createCheckboxMultiFilterParams,
4
4
  GridFilterColumnsMultiSelect,
5
5
  } from '../../components/gridFilter/GridFilterColumnsMultiSelect';
6
- import { useMemo, useState } from 'react';
6
+ import { useMemo, useState, ComponentType } from 'react';
7
7
  import { expect, userEvent, within } from 'storybook/test';
8
8
 
9
9
  import {
@@ -26,22 +26,7 @@ import {
26
26
  waitForGridRows,
27
27
  } from '../../utils/__tests__/storybookTestUtil';
28
28
  import { findQuick } from '../../utils/__tests__/testQuick';
29
-
30
- export default {
31
- title: 'Components / Grids',
32
- component: Grid,
33
- decorators: [
34
- (Story) => (
35
- <div style={{ width: 1024, height: 400, display: 'flex' }}>
36
- <GridUpdatingContextProvider>
37
- <GridContextProvider>
38
- <Story />
39
- </GridContextProvider>
40
- </GridUpdatingContextProvider>
41
- </div>
42
- ),
43
- ],
44
- } as Meta<typeof Grid>;
29
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
45
30
 
46
31
  interface ITestRow {
47
32
  id: number;
@@ -49,7 +34,7 @@ interface ITestRow {
49
34
  desc: string;
50
35
  }
51
36
 
52
- const GridFilterColumnsMultiSelectTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITestRow>) => {
37
+ const GridFilterColumnsMultiSelectTemplate = (props: GridProps<ITestRow>) => {
53
38
  const columnDefs: ColDefT<ITestRow>[] = useMemo(
54
39
  () => [
55
40
  GridCell({
@@ -126,26 +111,46 @@ const GridFilterColumnsMultiSelectTemplate: StoryFn<typeof Grid<ITestRow>> = (pr
126
111
  );
127
112
  };
128
113
 
129
- export const _FilterColumnsMultiSelectExample = GridFilterColumnsMultiSelectTemplate.bind({});
130
- _FilterColumnsMultiSelectExample.play = async (context) => {
131
- const { canvasElement } = context;
132
- await waitForGridReady(context);
133
- await waitForGridRows({ grid: canvasElement });
114
+ const meta: Meta<typeof GridFilterColumnsMultiSelectTemplate> = {
115
+ title: 'Components / Grids',
116
+ component: GridFilterColumnsMultiSelectTemplate,
117
+ decorators: [
118
+ (Story: ComponentType) => (
119
+ <div style={{ width: 1024, height: 400, display: 'flex' }}>
120
+ <GridUpdatingContextProvider>
121
+ <GridContextProvider>
122
+ <Story />
123
+ </GridContextProvider>
124
+ </GridUpdatingContextProvider>
125
+ </div>
126
+ ),
127
+ withOpenInPanelDecorator,
128
+ ],
129
+ };
130
+ export default meta;
131
+
132
+ type Story = StoryObj<typeof meta>;
133
+
134
+ export const FilterColumnsMultiSelectExample: Story = {
135
+ play: async ({ canvasElement }) => {
136
+ await waitForGridReady({ canvasElement });
137
+ await waitForGridRows({ grid: canvasElement });
134
138
 
135
- const setGridFilterAndCheckResultingRows = async (filterString: string, expected: string[] | null) => {
136
- await filterGridUsingColumnFilter(filterString);
137
- await wait(500);
138
- if (expected !== null) {
139
- expect(gridColumnValues('id', canvasElement)).toEqual(expected);
140
- return;
141
- }
142
- await waitForGridReady(context);
143
- expect(getNumberOfGridRows()).toEqual(0);
144
- };
139
+ const setGridFilterAndCheckResultingRows = async (filterString: string, expected: string[] | null) => {
140
+ await filterGridUsingColumnFilter(filterString);
141
+ await wait(500);
142
+ if (expected !== null) {
143
+ await expect(gridColumnValues('id', canvasElement)).toEqual(expected);
144
+ return;
145
+ }
146
+ await waitForGridReady({ canvasElement });
147
+ await expect(getNumberOfGridRows()).toEqual(0);
148
+ };
145
149
 
146
- await setGridFilterAndCheckResultingRows('Tester', ['1001', '1002', '1004', '1005', '1006']);
147
- await setGridFilterAndCheckResultingRows('Select All', ['1000', '1001', '1002', '1003', '1004', '1005', '1006']);
148
- await setGridFilterAndCheckResultingRows('Select All', null); // Check that deselecting Select All filters out all rows
150
+ await setGridFilterAndCheckResultingRows('Tester', ['1001', '1002', '1004', '1005', '1006']);
151
+ await setGridFilterAndCheckResultingRows('Select All', ['1000', '1001', '1002', '1003', '1004', '1005', '1006']);
152
+ await setGridFilterAndCheckResultingRows('Select All', null); // Check that deselecting Select All filters out all rows
153
+ },
149
154
  };
150
155
 
151
156
  const filterGridUsingColumnFilter = async (filterString: string): Promise<void> => {
@@ -1,4 +1,4 @@
1
- import type { Meta, StoryFn } from '@storybook/react-vite';
1
+ import type { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { useCallback, useContext, useMemo, useState } from 'react';
3
3
  import { expect, screen, userEvent, within } from 'storybook/test';
4
4
 
@@ -16,6 +16,7 @@ import {
16
16
  wait,
17
17
  } from '../..';
18
18
  import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
19
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
19
20
 
20
21
  interface IFormTestRow {
21
22
  id: number;
@@ -28,26 +29,6 @@ const initialRows: IFormTestRow[] = [
28
29
  { id: 1001, text1: 'b text1', text2: 'b text2' },
29
30
  ];
30
31
 
31
- export default {
32
- title: 'Components / Grids',
33
- component: Grid,
34
- args: {
35
- quickFilterValue: '',
36
- selectable: true,
37
- },
38
- decorators: [
39
- (Story) => (
40
- <div style={{ width: 1024, height: 400 }}>
41
- <GridUpdatingContextProvider>
42
- <GridContextProvider>
43
- <Story />
44
- </GridContextProvider>
45
- </GridUpdatingContextProvider>
46
- </div>
47
- ),
48
- ],
49
- } as Meta<typeof Grid>;
50
-
51
32
  const GridInlineTextTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props: GridProps<IFormTestRow>) => {
52
33
  const { selectRowsWithFlashDiff } = useContext(GridContext);
53
34
  const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
@@ -166,8 +147,32 @@ const GridInlineTextTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props: GridP
166
147
  );
167
148
  };
168
149
 
169
- export const _EditInlineText = GridInlineTextTemplate.bind({});
170
- _EditInlineText.play = waitForGridReady;
150
+ const meta: Meta<typeof GridInlineTextTemplate> = {
151
+ title: 'Components / Grids',
152
+ component: GridInlineTextTemplate,
153
+ args: {
154
+ selectable: true,
155
+ },
156
+ decorators: [
157
+ (Story) => (
158
+ <div style={{ width: 1024, height: 400 }}>
159
+ <GridUpdatingContextProvider>
160
+ <GridContextProvider>
161
+ <Story />
162
+ </GridContextProvider>
163
+ </GridUpdatingContextProvider>
164
+ </div>
165
+ ),
166
+ withOpenInPanelDecorator,
167
+ ],
168
+ };
169
+ export default meta;
170
+
171
+ type Story = StoryObj<typeof meta>;
172
+
173
+ export const _EditInlineText: Story = {
174
+ play: waitForGridReady,
175
+ };
171
176
 
172
177
  const InlineText_ChangeEventsTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props: GridProps<IFormTestRow>) => {
173
178
  const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
@@ -246,16 +251,18 @@ const InlineText_ChangeEventsTemplate: StoryFn<typeof Grid<IFormTestRow>> = (pro
246
251
  );
247
252
  };
248
253
 
249
- export const _InlineText_ChangeEvents = InlineText_ChangeEventsTemplate.bind({});
250
- _InlineText_ChangeEvents.play = async (context) => {
251
- await waitForGridReady(context);
252
- const canvas = within(context.canvasElement);
253
- const saveButtons = canvas.getAllByTestId('inline-edit-save');
254
- const saveButton = saveButtons[0];
255
- await expect(saveButton).toBeDisabled();
256
- const textCells = canvas.getAllByText('a text1');
257
- await userEvent.click(textCells[0]);
258
- const input = await screen.findByPlaceholderText('Enter some text...');
259
- await userEvent.type(input, 'X');
260
- await expect(saveButton).toBeEnabled();
254
+ export const _InlineText_ChangeEvents: Story = {
255
+ render: InlineText_ChangeEventsTemplate,
256
+ play: async ({ canvasElement }) => {
257
+ await waitForGridReady({ canvasElement });
258
+ const canvas = within(canvasElement);
259
+ const saveButtons = canvas.getAllByTestId('inline-edit-save');
260
+ const saveButton = saveButtons[0];
261
+ await expect(saveButton).toBeDisabled();
262
+ const textCells = canvas.getAllByText('a text1');
263
+ await userEvent.click(textCells[0]);
264
+ const input = await screen.findByPlaceholderText('Enter some text...');
265
+ await userEvent.type(input, 'X');
266
+ await expect(saveButton).toBeEnabled();
267
+ },
261
268
  };
@@ -1,34 +1,39 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { expect, within } from 'storybook/test';
3
3
 
4
4
  import { GridNoRowsOverlay, GridNoRowsOverlayProps } from '../../components';
5
5
 
6
- export default {
7
- title: 'Components / Grids / GridNoRowsOverlay',
8
- component: GridNoRowsOverlay,
9
- args: {},
10
- } as Meta<typeof GridNoRowsOverlay>;
11
-
12
- const GridNoRowsOverlayTemplate: StoryFn<typeof GridNoRowsOverlay> = (params: GridNoRowsOverlayProps) => {
6
+ const GridNoRowsOverlayTemplate = (params: GridNoRowsOverlayProps) => {
13
7
  return <GridNoRowsOverlay {...params} />;
14
8
  };
15
9
 
16
- export const _GridNoRowsEmpty = GridNoRowsOverlayTemplate.bind({});
17
- _GridNoRowsEmpty.args = {
18
- rowCount: 0,
19
- filteredRowCount: 0,
20
- };
21
- _GridNoRowsEmpty.play = async ({ canvasElement }) => {
22
- const canvas = within(canvasElement);
23
- expect(await canvas.findByText('There are currently no rows')).toBeInTheDocument();
10
+ const meta: Meta<typeof GridNoRowsOverlayTemplate> = {
11
+ title: 'Components / Grids / GridNoRowsOverlay',
12
+ component: GridNoRowsOverlayTemplate,
13
+ args: {},
24
14
  };
15
+ export default meta;
25
16
 
26
- export const _GridNoRowsFiltered = GridNoRowsOverlayTemplate.bind({});
27
- _GridNoRowsFiltered.args = {
28
- rowCount: 1,
29
- filteredRowCount: 0,
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ export const _GridNoRowsEmpty: Story = {
20
+ args: {
21
+ rowCount: 0,
22
+ filteredRowCount: 0,
23
+ },
24
+ play: async ({ canvasElement }) => {
25
+ const canvas = within(canvasElement);
26
+ await expect(await canvas.findByText('There are currently no rows')).toBeInTheDocument();
27
+ },
30
28
  };
31
- _GridNoRowsFiltered.play = async ({ canvasElement }) => {
32
- const canvas = within(canvasElement);
33
- expect(await canvas.findByText('All rows have been filtered')).toBeInTheDocument();
29
+
30
+ export const _GridNoRowsFiltered: Story = {
31
+ args: {
32
+ rowCount: 1,
33
+ filteredRowCount: 0,
34
+ },
35
+ play: async ({ canvasElement }) => {
36
+ const canvas = within(canvasElement);
37
+ await expect(await canvas.findByText('All rows have been filtered')).toBeInTheDocument();
38
+ },
34
39
  };
@@ -1,4 +1,4 @@
1
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
2
2
  import { GridPopoverEditDropDown } from '../../components/gridPopoverEdit/GridPopoverEditDropDown';
3
3
  import { GridPopoverTextArea } from '../../components/gridPopoverEdit/GridPopoverTextArea';
4
4
  import { useMemo, useState } from 'react';
@@ -18,27 +18,7 @@ import {
18
18
  wait,
19
19
  } from '../..';
20
20
  import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
21
-
22
- export default {
23
- title: 'Components / Grids',
24
- component: Grid,
25
- args: {
26
- selectable: true,
27
- rowSelection: 'single',
28
- autoSelectFirstRow: true,
29
- },
30
- decorators: [
31
- (Story) => (
32
- <div style={{ width: 1024, height: 400 }}>
33
- <GridUpdatingContextProvider>
34
- <GridContextProvider>
35
- <Story />
36
- </GridContextProvider>
37
- </GridUpdatingContextProvider>
38
- </div>
39
- ),
40
- ],
41
- } as Meta<typeof Grid>;
21
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
42
22
 
43
23
  interface ITestRow {
44
24
  id: number;
@@ -169,5 +149,31 @@ const GridNonEditableRowTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridP
169
149
  );
170
150
  };
171
151
 
172
- export const _NonEditableRow = GridNonEditableRowTemplate.bind({});
173
- _NonEditableRow.play = waitForGridReady;
152
+ const meta: Meta<typeof GridNonEditableRowTemplate> = {
153
+ title: 'Components / Grids',
154
+ component: GridNonEditableRowTemplate,
155
+ args: {
156
+ selectable: true,
157
+ rowSelection: 'single',
158
+ autoSelectFirstRow: true,
159
+ },
160
+ decorators: [
161
+ (Story) => (
162
+ <div style={{ width: 1024, height: 400 }}>
163
+ <GridUpdatingContextProvider>
164
+ <GridContextProvider>
165
+ <Story />
166
+ </GridContextProvider>
167
+ </GridUpdatingContextProvider>
168
+ </div>
169
+ ),
170
+ withOpenInPanelDecorator,
171
+ ],
172
+ };
173
+ export default meta;
174
+
175
+ type Story = StoryObj<typeof meta>;
176
+
177
+ export const _NonEditableRow: Story = {
178
+ play: waitForGridReady,
179
+ };
@@ -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
 
4
4
  import {
@@ -11,33 +11,7 @@ import {
11
11
  GridWrapper,
12
12
  } from '../..';
13
13
  import { waitForGridReady } from '../../utils/__tests__/storybookTestUtil';
14
-
15
- export default {
16
- title: 'Components / Grids',
17
- component: Grid,
18
- args: {
19
- selectable: false,
20
- },
21
- // Storybook hangs otherwise
22
- parameters: {
23
- docs: {
24
- source: {
25
- type: 'code',
26
- },
27
- },
28
- },
29
- decorators: [
30
- (Story) => (
31
- <div style={{ width: 1024, height: 260, display: 'flex', flexDirection: 'column' }}>
32
- <GridUpdatingContextProvider>
33
- <GridContextProvider>
34
- <Story />
35
- </GridContextProvider>
36
- </GridUpdatingContextProvider>
37
- </div>
38
- ),
39
- ],
40
- } as Meta<typeof Grid>;
14
+ import { withOpenInPanelDecorator } from '../decorators/withOpenInPanelDecorator';
41
15
 
42
16
  interface ITestRow {
43
17
  id: number;
@@ -52,7 +26,7 @@ interface ITestPinnedRow {
52
26
  age: number;
53
27
  }
54
28
 
55
- const PinnedRowTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITestRow>) => {
29
+ const PinnedRowTemplate = (props: GridProps<ITestRow>) => {
56
30
  const columnDefs: ColDefT<ITestRow>[] = useMemo(
57
31
  () => [
58
32
  GridCell({
@@ -95,5 +69,37 @@ const PinnedRowTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITes
95
69
  </GridWrapper>
96
70
  );
97
71
  };
98
- export const PinnedRow = PinnedRowTemplate.bind({});
99
- PinnedRow.play = waitForGridReady;
72
+ const meta: Meta<typeof PinnedRowTemplate> = {
73
+ title: 'Components / Grids',
74
+ component: PinnedRowTemplate,
75
+ args: {
76
+ selectable: false,
77
+ },
78
+ // Storybook hangs otherwise
79
+ parameters: {
80
+ docs: {
81
+ source: {
82
+ type: 'code',
83
+ },
84
+ },
85
+ },
86
+ decorators: [
87
+ (Story) => (
88
+ <div style={{ width: 1024, height: 260, display: 'flex', flexDirection: 'column' }}>
89
+ <GridUpdatingContextProvider>
90
+ <GridContextProvider>
91
+ <Story />
92
+ </GridContextProvider>
93
+ </GridUpdatingContextProvider>
94
+ </div>
95
+ ),
96
+ withOpenInPanelDecorator,
97
+ ],
98
+ };
99
+ export default meta;
100
+
101
+ type Story = StoryObj<typeof meta>;
102
+
103
+ export const PinnedRow: Story = {
104
+ play: waitForGridReady,
105
+ };