@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
|
@@ -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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
export const _AutoSize: Story = {
|
|
89
|
+
play: async ({ canvasElement }) => {
|
|
90
|
+
await waitForGridReady({ canvasElement });
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta,
|
|
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
|
-
|
|
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,20 +61,44 @@ const GridPopoutEditGenericTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props
|
|
|
81
61
|
);
|
|
82
62
|
};
|
|
83
63
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
export const _FitSize: Story = {
|
|
89
|
+
play: async ({ canvasElement }) => {
|
|
90
|
+
await waitForGridReady({ canvasElement });
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
const idWidth = idHeader.getBoundingClientRect().width;
|
|
97
|
+
const nameWidth = nameHeader.getBoundingClientRect().width;
|
|
98
|
+
const availableWidth = headerViewport.getBoundingClientRect().width;
|
|
99
|
+
|
|
100
|
+
// Both columns default to flex: 1 under sizeColumns='fit', so they should split the container evenly
|
|
101
|
+
await expect(Math.abs(idWidth - nameWidth)).toBeLessThanOrEqual(2);
|
|
102
|
+
await expect(Math.abs(idWidth + nameWidth - availableWidth)).toBeLessThanOrEqual(4);
|
|
103
|
+
},
|
|
100
104
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta,
|
|
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
|
-
|
|
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
|
() => [
|
|
@@ -83,20 +63,44 @@ const GridPopoutEditGenericTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props
|
|
|
83
63
|
);
|
|
84
64
|
};
|
|
85
65
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
66
|
+
const meta: Meta<typeof GridPopoutEditGenericTemplate> = {
|
|
67
|
+
title: 'Components / Grid Size',
|
|
68
|
+
component: GridPopoutEditGenericTemplate,
|
|
69
|
+
args: {
|
|
70
|
+
selectable: true,
|
|
71
|
+
},
|
|
72
|
+
decorators: [
|
|
73
|
+
(Story) => (
|
|
74
|
+
<div style={{ width: 1024, height: 600, display: 'flex', flexDirection: 'column' }}>
|
|
75
|
+
<GridUpdatingContextProvider>
|
|
76
|
+
<GridContextProvider>
|
|
77
|
+
<Story />
|
|
78
|
+
</GridContextProvider>
|
|
79
|
+
</GridUpdatingContextProvider>
|
|
80
|
+
</div>
|
|
81
|
+
),
|
|
82
|
+
ChromaticAllowGridAutosize,
|
|
83
|
+
withOpenInPanelDecorator,
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
export default meta;
|
|
87
|
+
|
|
88
|
+
type Story = StoryObj<typeof meta>;
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
export const _FitSizeFlex: Story = {
|
|
91
|
+
play: async ({ canvasElement }) => {
|
|
92
|
+
await waitForGridReady({ canvasElement });
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
const idHeader = await findQuick({ selector: '.ag-header-cell[col-id="id"]' }, canvasElement);
|
|
95
|
+
const nameHeader = await findQuick({ selector: '.ag-header-cell[col-id="name"]' }, canvasElement);
|
|
96
|
+
const headerViewport = await findQuick({ selector: '.ag-header-viewport' }, canvasElement);
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const idWidth = idHeader.getBoundingClientRect().width;
|
|
99
|
+
const nameWidth = nameHeader.getBoundingClientRect().width;
|
|
100
|
+
const availableWidth = headerViewport.getBoundingClientRect().width;
|
|
101
|
+
|
|
102
|
+
// id has flex: 2, name has flex: 1, so id should be twice the width of name
|
|
103
|
+
await expect(Math.abs(idWidth - nameWidth * 2)).toBeLessThan(2);
|
|
104
|
+
await expect(Math.abs(idWidth + nameWidth - availableWidth)).toBeLessThan(4);
|
|
105
|
+
},
|
|
102
106
|
};
|
package/src/stories/grid/gridAutosize/ShowPanelResizingAgGrid/ShowPanelResizingStepAgGrid.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// import '../story.scss';
|
|
2
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
3
2
|
import '../../../../styles/Grid.scss';
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
|
-
OpenPanelButton,
|
|
7
5
|
Panel,
|
|
8
6
|
PanelContent,
|
|
9
7
|
PanelContext,
|
|
10
8
|
PanelHeader,
|
|
11
9
|
PanelsContextProvider,
|
|
10
|
+
RibbonButtonOpenPanel,
|
|
11
|
+
RibbonContainer,
|
|
12
12
|
} from '@linzjs/windows';
|
|
13
13
|
import { useContext, useEffect, useMemo, useState } from 'react';
|
|
14
14
|
|
|
@@ -52,10 +52,18 @@ export const TestPanelResizing = ({ data }: TestPanelProps) => {
|
|
|
52
52
|
|
|
53
53
|
// #Example: Panel Invocation
|
|
54
54
|
export const TestShowPanelResizingAgGrid = () => (
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
<RibbonContainer>
|
|
56
|
+
<RibbonButtonOpenPanel
|
|
57
|
+
title={'TestPanel resizing 1'}
|
|
58
|
+
icon={'ic_launch_modal'}
|
|
59
|
+
componentFn={() => <TestPanelResizing data={1} />}
|
|
60
|
+
/>
|
|
61
|
+
<RibbonButtonOpenPanel
|
|
62
|
+
title={'TestPanel resizing 2'}
|
|
63
|
+
icon={'ic_launch_modal'}
|
|
64
|
+
componentFn={() => <TestPanelResizing data={2} />}
|
|
65
|
+
/>
|
|
66
|
+
</RibbonContainer>
|
|
59
67
|
);
|
|
60
68
|
|
|
61
69
|
/* exclude */
|
|
@@ -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';
|
|
@@ -15,12 +11,6 @@ import {
|
|
|
15
11
|
GridFormSubComponentTextInput,
|
|
16
12
|
} from '../../..';
|
|
17
13
|
|
|
18
|
-
export default {
|
|
19
|
-
title: 'GridForm / Interactions',
|
|
20
|
-
component: GridFormDropDown,
|
|
21
|
-
args: {},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
14
|
const updateValue = fn(async (saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) =>
|
|
25
15
|
saveFn([]),
|
|
26
16
|
);
|
|
@@ -73,67 +63,77 @@ const Template: StoryFn<typeof GridFormDropDown<GridBaseRow, number>> = (
|
|
|
73
63
|
);
|
|
74
64
|
};
|
|
75
65
|
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
66
|
+
const meta: Meta<typeof Template> = {
|
|
67
|
+
title: 'GridForm / Interactions',
|
|
68
|
+
component: Template,
|
|
69
|
+
args: {},
|
|
70
|
+
};
|
|
71
|
+
export default meta;
|
|
72
|
+
|
|
73
|
+
type Story = StoryObj<typeof meta>;
|
|
74
|
+
|
|
75
|
+
export const GridFormDropDownInteractions_: Story = {
|
|
76
|
+
play: async ({ canvasElement }) => {
|
|
77
|
+
const canvas = within(canvasElement);
|
|
78
|
+
|
|
79
|
+
const getOption = (name: string) => canvas.findByRole('menuitem', { name });
|
|
80
|
+
|
|
81
|
+
// Check enabled menu handles click
|
|
82
|
+
const enabledMenuOption = await getOption('Enabled');
|
|
83
|
+
await expect(enabledMenuOption).toBeInTheDocument();
|
|
84
|
+
|
|
85
|
+
await userEvent.click(enabledMenuOption);
|
|
86
|
+
await expect(updateValue).toHaveBeenCalled();
|
|
87
|
+
await expect(onSelectedItem).toHaveBeenCalled();
|
|
88
|
+
|
|
89
|
+
// Check disabled menu ignores click
|
|
90
|
+
updateValue.mockClear();
|
|
91
|
+
onSelectedItem.mockClear();
|
|
92
|
+
const disabledMenuOption = await getOption('Disabled');
|
|
93
|
+
await userEvent.click(disabledMenuOption);
|
|
94
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
95
|
+
await expect(onSelectedItem).not.toHaveBeenCalled();
|
|
96
|
+
|
|
97
|
+
// Check sub menu works
|
|
98
|
+
const subTextInput = await getOption('Sub menu...');
|
|
99
|
+
await expect(subTextInput).toBeInTheDocument();
|
|
100
|
+
|
|
101
|
+
await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
|
|
102
|
+
|
|
103
|
+
await userEvent.click(subTextInput);
|
|
104
|
+
const textInput = await canvas.findByPlaceholderText('Text input');
|
|
105
|
+
await expect(textInput).toBeInTheDocument();
|
|
106
|
+
await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
107
|
+
|
|
108
|
+
await userEvent.type(textInput, 'Hello');
|
|
109
|
+
await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
|
|
110
|
+
|
|
111
|
+
// Test tab to save
|
|
112
|
+
updateValue.mockClear();
|
|
113
|
+
await userEvent.tab();
|
|
114
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = tab
|
|
115
|
+
|
|
116
|
+
// Test shift+tab to save
|
|
117
|
+
updateValue.mockClear();
|
|
118
|
+
await userEvent.tab({ shift: true });
|
|
119
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
120
|
+
|
|
121
|
+
// Test escape to not save
|
|
122
|
+
updateValue.mockClear();
|
|
123
|
+
await userEvent.type(textInput, '{Escape}');
|
|
124
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
125
|
+
|
|
126
|
+
// Test invalid value doesn't save
|
|
127
|
+
updateValue.mockClear();
|
|
128
|
+
await userEvent.clear(textInput);
|
|
129
|
+
await userEvent.type(textInput, '{Enter}');
|
|
130
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
131
|
+
|
|
132
|
+
// Test filter
|
|
133
|
+
const filterText = await canvas.findByPlaceholderText('Filter...');
|
|
134
|
+
await userEvent.type(filterText, 'ena');
|
|
135
|
+
await expect(canvas.queryByText('Enabled')).toBeInTheDocument();
|
|
136
|
+
await expect(canvas.queryByText('Disabled')).not.toBeInTheDocument();
|
|
137
|
+
await expect(canvas.queryByText('Sub menu...')).not.toBeInTheDocument();
|
|
138
|
+
},
|
|
139
139
|
};
|