@linzjs/step-ag-grid 32.7.1 → 34.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.
- package/dist/src/components/PostSortRowsHook.test.d.ts +1 -0
- package/dist/src/components/gridFilter/GridFilterColumnsMultiSelect.d.ts +6 -25
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +2 -1
- package/dist/src/utils/__tests__/storybookTestUtil.ts +1 -1
- package/dist/step-ag-grid.cjs +190 -206
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +190 -206
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +17 -17
- package/src/components/Grid.tsx +8 -10
- package/src/components/PostSortRowsHook.test.ts +300 -0
- package/src/components/PostSortRowsHook.ts +127 -24
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.tsx +110 -199
- package/src/components/gridForm/GridFormTextInput.tsx +2 -1
- package/src/components/gridHook/useGridRangeSelection.ts +8 -6
- package/src/contexts/GridContextProvider.tsx +5 -9
- package/src/react-menu3/components/ControlledMenu.tsx +5 -3
- package/src/react-menu3/components/MenuList.tsx +7 -3
- package/src/react-menu3/hooks/useItems.ts +1 -1
- package/src/stories/components/ActionButton.stories.tsx +12 -11
- package/src/stories/decorators/withOpenInPanelDecorator.tsx +35 -0
- package/src/stories/grid/GridCopy.stories.tsx +38 -35
- package/src/stories/grid/GridDragRow.stories.tsx +41 -36
- package/src/stories/grid/GridFilterButtons.stories.tsx +25 -19
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +42 -37
- package/src/stories/grid/GridInlineText.stories.tsx +62 -49
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +28 -23
- package/src/stories/grid/GridNonEditableRow.stories.tsx +30 -24
- package/src/stories/grid/GridPinnedRow.stories.tsx +37 -31
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +29 -24
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +89 -82
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +27 -22
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +30 -25
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +29 -24
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -24
- package/src/stories/grid/GridReadOnly.stories.tsx +56 -52
- package/src/stories/grid/GridSorting.stories.tsx +498 -86
- package/src/stories/grid/GridViewList.stories.tsx +31 -26
- package/src/stories/grid/GridViewSelectableList.stories.tsx +31 -26
- package/src/stories/grid/gridAutosize/GridAutoSize.stories.tsx +41 -37
- package/src/stories/grid/gridAutosize/GridFitSize.stories.tsx +40 -36
- package/src/stories/grid/gridAutosize/GridFitSizeFlex.stories.tsx +40 -36
- package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx +14 -6
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +74 -74
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +59 -59
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +58 -58
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +62 -62
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +118 -118
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +107 -105
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +72 -64
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +82 -73
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +12 -13
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +12 -13
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +11 -13
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +11 -13
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +110 -107
- package/src/stories/react-menu/ReactMenu.stories.tsx +70 -73
- package/src/styles/GridLoadableCell.scss +1 -1
- package/src/utils/__tests__/storybookTestUtil.ts +1 -1
- package/src/utils/useSharedInterval.ts +3 -3
package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
|
|
5
|
-
import { StoryFn } from '@storybook/react-vite';
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
|
|
6
2
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
7
3
|
import { useRef } from 'react';
|
|
8
4
|
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
@@ -14,12 +10,6 @@ import {
|
|
|
14
10
|
GridPopoverEditBearingCorrectionEditorParams,
|
|
15
11
|
} from '../../..';
|
|
16
12
|
|
|
17
|
-
export default {
|
|
18
|
-
title: 'GridForm / Interactions',
|
|
19
|
-
component: GridFormEditBearing,
|
|
20
|
-
args: {},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
13
|
const updateValue = fn();
|
|
24
14
|
|
|
25
15
|
const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearingProps<any>) => {
|
|
@@ -51,52 +41,62 @@ const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearin
|
|
|
51
41
|
);
|
|
52
42
|
};
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
44
|
+
const meta: Meta<typeof Template> = {
|
|
45
|
+
title: 'GridForm / Interactions',
|
|
46
|
+
component: Template,
|
|
47
|
+
args: {},
|
|
48
|
+
};
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const GridFormEditBearingCorrectionInteractions_: Story = {
|
|
54
|
+
play: async ({ canvasElement }) => {
|
|
55
|
+
const canvas = within(canvasElement);
|
|
56
|
+
|
|
57
|
+
await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
|
|
58
|
+
|
|
59
|
+
const inputField = canvas.getByPlaceholderText('Enter bearing correction');
|
|
60
|
+
|
|
61
|
+
// Test formatting null
|
|
62
|
+
await expect(await canvas.findByText('–')).toBeInTheDocument();
|
|
63
|
+
|
|
64
|
+
// Test formatting a bearing
|
|
65
|
+
await expect(inputField).toBeInTheDocument();
|
|
66
|
+
await userEvent.type(inputField, '1.2345');
|
|
67
|
+
await expect(await canvas.findByText('+1° 23\' 45"')).toBeInTheDocument();
|
|
68
|
+
|
|
69
|
+
// Test enter to save
|
|
70
|
+
updateValue.mockClear();
|
|
71
|
+
await userEvent.type(inputField, '{Enter}');
|
|
72
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
|
|
73
|
+
|
|
74
|
+
// Test tab to save
|
|
75
|
+
updateValue.mockClear();
|
|
76
|
+
await userEvent.tab();
|
|
77
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
78
|
+
|
|
79
|
+
// Test shift+tab to save
|
|
80
|
+
updateValue.mockClear();
|
|
81
|
+
await userEvent.tab({ shift: true });
|
|
82
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
83
|
+
|
|
84
|
+
// Test escape not to save
|
|
85
|
+
updateValue.mockClear();
|
|
86
|
+
await userEvent.type(inputField, '{Escape}');
|
|
87
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
88
|
+
|
|
89
|
+
// Test invalid value doesn't save
|
|
90
|
+
updateValue.mockClear();
|
|
91
|
+
await userEvent.type(inputField, 'xxx');
|
|
92
|
+
await expect(await canvas.findByText('?')).toBeInTheDocument();
|
|
93
|
+
|
|
94
|
+
await expect(canvas.getByText('Bearing must be a number in D.MMSSS format')).toBeInTheDocument();
|
|
95
|
+
await userEvent.type(inputField, '{Enter}');
|
|
96
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
97
|
+
await userEvent.tab();
|
|
98
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
99
|
+
await userEvent.tab({ shift: true });
|
|
100
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
101
|
+
},
|
|
102
102
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
|
|
5
|
-
import { StoryFn } from '@storybook/react-vite';
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
|
|
6
2
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
7
3
|
import { useRef } from 'react';
|
|
8
4
|
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
@@ -14,12 +10,6 @@ import {
|
|
|
14
10
|
GridPopoverEditBearingEditorParams,
|
|
15
11
|
} from '../../..';
|
|
16
12
|
|
|
17
|
-
export default {
|
|
18
|
-
title: 'GridForm / Interactions',
|
|
19
|
-
component: GridFormEditBearing,
|
|
20
|
-
args: {},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
13
|
const updateValue = fn();
|
|
24
14
|
|
|
25
15
|
const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearingProps<any>) => {
|
|
@@ -51,51 +41,61 @@ const Template: StoryFn<typeof GridFormEditBearing> = (props: GridFormEditBearin
|
|
|
51
41
|
);
|
|
52
42
|
};
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
44
|
+
const meta: Meta<typeof Template> = {
|
|
45
|
+
title: 'GridForm / Interactions',
|
|
46
|
+
component: Template,
|
|
47
|
+
args: {},
|
|
48
|
+
};
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
type Story = StoryObj<typeof meta>;
|
|
52
|
+
|
|
53
|
+
export const GridFormEditBearingInteractions_: Story = {
|
|
54
|
+
play: async ({ canvasElement }) => {
|
|
55
|
+
const canvas = within(canvasElement);
|
|
56
|
+
|
|
57
|
+
await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
|
|
58
|
+
|
|
59
|
+
const inputField = canvas.getByPlaceholderText('Enter bearing');
|
|
60
|
+
|
|
61
|
+
// Test formatting null
|
|
62
|
+
await expect(await canvas.findByText('–')).toBeInTheDocument();
|
|
63
|
+
|
|
64
|
+
// Test formatting a bearing
|
|
65
|
+
await expect(inputField).toBeInTheDocument();
|
|
66
|
+
await userEvent.type(inputField, '1.2345');
|
|
67
|
+
await expect(await canvas.findByText('1° 23\' 45"')).toBeInTheDocument();
|
|
68
|
+
|
|
69
|
+
// Test enter to save
|
|
70
|
+
updateValue.mockClear();
|
|
71
|
+
await userEvent.type(inputField, '{Enter}');
|
|
72
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
|
|
73
|
+
|
|
74
|
+
// Test tab to save
|
|
75
|
+
updateValue.mockClear();
|
|
76
|
+
await userEvent.tab();
|
|
77
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
78
|
+
|
|
79
|
+
// Test shift+tab to save
|
|
80
|
+
updateValue.mockClear();
|
|
81
|
+
await userEvent.tab({ shift: true });
|
|
82
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
83
|
+
|
|
84
|
+
// Test escape not to save
|
|
85
|
+
updateValue.mockClear();
|
|
86
|
+
await userEvent.type(inputField, '{Escape}');
|
|
87
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
88
|
+
|
|
89
|
+
// Test invalid value doesn't save
|
|
90
|
+
updateValue.mockClear();
|
|
91
|
+
await userEvent.type(inputField, 'xxx');
|
|
92
|
+
await expect(await canvas.findByText('?')).toBeInTheDocument();
|
|
93
|
+
await expect(canvas.getByText('Bearing must be a number in D.MMSSS format')).toBeInTheDocument();
|
|
94
|
+
await userEvent.type(inputField, '{Enter}');
|
|
95
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
96
|
+
await userEvent.tab();
|
|
97
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
98
|
+
await userEvent.tab({ shift: true });
|
|
99
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
100
|
+
},
|
|
101
101
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
|
|
5
|
-
import { StoryFn } from '@storybook/react-vite';
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
|
|
6
2
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
7
3
|
import { useRef } from 'react';
|
|
8
4
|
import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
|
|
@@ -14,12 +10,6 @@ import {
|
|
|
14
10
|
MultiSelectGridOption,
|
|
15
11
|
} from '../../..';
|
|
16
12
|
|
|
17
|
-
export default {
|
|
18
|
-
title: 'GridForm / Interactions',
|
|
19
|
-
component: GridFormMultiSelectGrid,
|
|
20
|
-
args: {},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
13
|
const updateValue = fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => saveFn([]));
|
|
24
14
|
|
|
25
15
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
@@ -70,55 +60,65 @@ const Template: StoryFn<typeof GridFormMultiSelectGrid> = (props: GridFormMultiS
|
|
|
70
60
|
);
|
|
71
61
|
};
|
|
72
62
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
expect(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
63
|
+
const meta: Meta<typeof Template> = {
|
|
64
|
+
title: 'GridForm / Interactions',
|
|
65
|
+
component: Template,
|
|
66
|
+
args: {},
|
|
67
|
+
};
|
|
68
|
+
export default meta;
|
|
69
|
+
|
|
70
|
+
type Story = StoryObj<typeof meta>;
|
|
71
|
+
|
|
72
|
+
export const GridFormMultiSelectGridInteractions_: Story = {
|
|
73
|
+
play: async ({ canvasElement }) => {
|
|
74
|
+
updateValue.mockClear();
|
|
75
|
+
onSave.mockClear();
|
|
76
|
+
onSelectFilter.mockClear();
|
|
77
|
+
|
|
78
|
+
const canvas = within(canvasElement);
|
|
79
|
+
|
|
80
|
+
const getOption = (name: RegExp | string) => canvas.findByRole('menuitem', { name });
|
|
81
|
+
|
|
82
|
+
// Check enabled menu handles click
|
|
83
|
+
const zeroMenuOption = await getOption(/Zero/);
|
|
84
|
+
await expect(zeroMenuOption).toBeInTheDocument();
|
|
85
|
+
|
|
86
|
+
await userEvent.click(zeroMenuOption);
|
|
87
|
+
await userEvent.keyboard('{Tab}');
|
|
88
|
+
await expect(updateValue).toHaveBeenCalled();
|
|
89
|
+
await waitFor(() => expect(onSave).toHaveBeenCalledWith({ selectedRows: [], addValues: [0], removeValues: [] }));
|
|
90
|
+
|
|
91
|
+
const check = async (label: string) => {
|
|
92
|
+
const activeCell = canvasElement.ownerDocument.activeElement as HTMLElement | null;
|
|
93
|
+
await expect(activeCell?.innerText).toBe(label);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Test left/right arrow
|
|
97
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
98
|
+
await check('Three');
|
|
99
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
100
|
+
await check('Zero');
|
|
101
|
+
await userEvent.keyboard('{ArrowLeft}');
|
|
102
|
+
await check('Three');
|
|
103
|
+
await userEvent.keyboard('{ArrowLeft}');
|
|
104
|
+
await check('Zero');
|
|
105
|
+
|
|
106
|
+
// Test tab to save
|
|
107
|
+
updateValue.mockClear();
|
|
108
|
+
onSave.mockClear();
|
|
109
|
+
await userEvent.tab();
|
|
110
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
111
|
+
await expect(onSave).toHaveBeenCalledWith({
|
|
112
|
+
selectedRows: [],
|
|
113
|
+
addValues: [0],
|
|
114
|
+
removeValues: [],
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Test shift+tab to save
|
|
118
|
+
updateValue.mockClear();
|
|
119
|
+
onSave.mockClear();
|
|
120
|
+
await userEvent.tab({ shift: true });
|
|
121
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
122
|
+
await expect(onSave).toHaveBeenCalled();
|
|
123
|
+
},
|
|
124
124
|
};
|