@linzjs/step-ag-grid 32.4.2 → 32.6.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/gridForm/GridFormTextArea.d.ts +1 -0
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils/isChromatic.d.ts +11 -0
- package/dist/step-ag-grid.cjs +40 -12
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +40 -14
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +16 -16
- package/src/components/Grid.tsx +1 -1
- package/src/components/gridForm/GridFormTextArea.tsx +10 -1
- package/src/components/gridForm/GridFormTextInput.tsx +10 -1
- package/src/contexts/GridContextProvider.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/lui/FormError.scss +1 -0
- package/src/stories/components/ActionButton.stories.tsx +0 -1
- package/src/stories/grid/GridCopy.stories.tsx +1 -6
- package/src/stories/grid/GridDragRow.stories.tsx +1 -6
- package/src/stories/grid/GridFilterButtons.stories.tsx +0 -5
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +0 -5
- package/src/stories/grid/GridInlineText.stories.tsx +0 -5
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +0 -5
- package/src/stories/grid/GridNonEditableRow.stories.tsx +0 -5
- package/src/stories/grid/GridPinnedRow.stories.tsx +1 -6
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +0 -5
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +0 -5
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +0 -5
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +0 -5
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +0 -5
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +0 -5
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +0 -5
- package/src/stories/grid/GridReadOnly.stories.tsx +1 -6
- package/src/stories/grid/GridSorting.stories.tsx +1 -6
- package/src/stories/grid/GridViewList.stories.tsx +1 -6
- package/src/stories/grid/GridViewSelectableList.stories.tsx +1 -6
- package/src/stories/grid/gridAutosize/GridAutoSize.stories.tsx +28 -11
- package/src/stories/grid/gridAutosize/GridFitSize.stories.tsx +27 -11
- package/src/stories/grid/gridAutosize/GridFitSizeFlex.stories.tsx +27 -11
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +0 -1
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +0 -1
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +0 -1
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +0 -1
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +0 -1
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +0 -1
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +67 -13
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +69 -15
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +0 -1
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +0 -1
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +0 -1
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +0 -1
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +0 -1
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +0 -1
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +0 -1
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +0 -1
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +0 -5
- package/src/utils/isChromatic.tsx +30 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
|
-
|
|
1
|
+
import { LuiFilterCharactersProvider } from '@linzjs/lui';
|
|
6
2
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
3
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
8
4
|
import { useRef } from 'react';
|
|
@@ -51,35 +47,93 @@ export const GridFormTextAreaInteractions_: typeof Template = Template.bind({});
|
|
|
51
47
|
GridFormTextAreaInteractions_.play = async ({ canvasElement }) => {
|
|
52
48
|
const canvas = within(canvasElement);
|
|
53
49
|
|
|
54
|
-
expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
50
|
+
await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
55
51
|
|
|
56
52
|
const inputField = canvas.getByPlaceholderText('Type here');
|
|
57
53
|
await userEvent.type(inputField, 'Hello');
|
|
58
54
|
|
|
59
|
-
expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
|
|
55
|
+
await expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
|
|
60
56
|
|
|
61
57
|
// Test tab to save
|
|
62
58
|
updateValue.mockClear();
|
|
63
59
|
await userEvent.tab();
|
|
64
|
-
expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
60
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
65
61
|
|
|
66
62
|
// Test shift+tab to save
|
|
67
63
|
updateValue.mockClear();
|
|
68
64
|
await userEvent.tab({ shift: true });
|
|
69
|
-
expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
65
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
70
66
|
|
|
71
67
|
// Test escape not to save
|
|
72
68
|
updateValue.mockClear();
|
|
73
69
|
await userEvent.type(inputField, '{Escape}');
|
|
74
|
-
expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
70
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
75
71
|
|
|
76
72
|
// Test invalid value doesn't save
|
|
77
73
|
updateValue.mockClear();
|
|
78
74
|
await userEvent.clear(inputField);
|
|
79
75
|
|
|
80
|
-
expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
|
|
76
|
+
await expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
|
|
81
77
|
await userEvent.tab();
|
|
82
|
-
expect(updateValue).not.toHaveBeenCalled();
|
|
78
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
83
79
|
await userEvent.tab({ shift: true });
|
|
84
|
-
expect(updateValue).not.toHaveBeenCalled();
|
|
80
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const FilterTemplate: StoryFn<typeof GridFormTextArea> = (props: GridFormTextAreaProps<any>) => {
|
|
84
|
+
const anchorRef = useRef<HTMLHeadingElement>(null);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div className={'react-menu-inline-test'}>
|
|
88
|
+
<LuiFilterCharactersProvider>
|
|
89
|
+
<GridContextProvider>
|
|
90
|
+
<h6 ref={anchorRef}>Interaction Test</h6>
|
|
91
|
+
<GridPopoverContext.Provider
|
|
92
|
+
value={{
|
|
93
|
+
anchorRef,
|
|
94
|
+
value: null,
|
|
95
|
+
updateValue,
|
|
96
|
+
data: { value: null },
|
|
97
|
+
colId: '',
|
|
98
|
+
field: 'value',
|
|
99
|
+
selectedRows: [],
|
|
100
|
+
saving: false,
|
|
101
|
+
setSaving: () => {},
|
|
102
|
+
formatValue: (value) => value,
|
|
103
|
+
stopEditing: () => {},
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
<GridFormTextArea {...props} />
|
|
107
|
+
</GridPopoverContext.Provider>
|
|
108
|
+
</GridContextProvider>
|
|
109
|
+
</LuiFilterCharactersProvider>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// By default (disableUnicodeCharacterFilter unset) invalid unicode characters are silently
|
|
115
|
+
// converted or stripped as the user types, matching LuiTextAreaInput's behaviour.
|
|
116
|
+
export const GridFormTextAreaUnicodeFilter_ = FilterTemplate.bind({});
|
|
117
|
+
GridFormTextAreaUnicodeFilter_.play = async ({ canvasElement }) => {
|
|
118
|
+
const canvas = within(canvasElement);
|
|
119
|
+
|
|
120
|
+
// The popover mounts asynchronously (GridPopoverHook opens on a post-mount effect), so wait for it.
|
|
121
|
+
const inputField = await canvas.findByPlaceholderText('Type here');
|
|
122
|
+
// ’ (U+2019 right single quote) -> ' , — (U+2014 em dash) -> - , Ω (U+03A9, out of range) -> removed
|
|
123
|
+
await userEvent.type(inputField, 'It’s—cool Ω');
|
|
124
|
+
|
|
125
|
+
await expect(inputField).toHaveValue("It's-cool ");
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// disableUnicodeCharacterFilter=true opts out of filtering, leaving invalid characters intact.
|
|
129
|
+
export const GridFormTextAreaUnicodeFilterDisabled_ = FilterTemplate.bind({});
|
|
130
|
+
GridFormTextAreaUnicodeFilterDisabled_.args = { disableUnicodeCharacterFilter: true };
|
|
131
|
+
GridFormTextAreaUnicodeFilterDisabled_.play = async ({ canvasElement }) => {
|
|
132
|
+
const canvas = within(canvasElement);
|
|
133
|
+
|
|
134
|
+
const inputField = await canvas.findByPlaceholderText('Type here');
|
|
135
|
+
// Same chars as above, but left untouched since filtering is disabled
|
|
136
|
+
await userEvent.type(inputField, 'It’s—cool Ω');
|
|
137
|
+
|
|
138
|
+
await expect(inputField).toHaveValue('It’s—cool Ω');
|
|
85
139
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
|
-
|
|
1
|
+
import { LuiFilterCharactersProvider } from '@linzjs/lui';
|
|
6
2
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
3
|
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
8
4
|
import { useRef } from 'react';
|
|
@@ -51,42 +47,100 @@ export const GridFormTextInputInteractions_: typeof Template = Template.bind({})
|
|
|
51
47
|
GridFormTextInputInteractions_.play = async ({ canvasElement }) => {
|
|
52
48
|
const canvas = within(canvasElement);
|
|
53
49
|
|
|
54
|
-
expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
50
|
+
await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
|
|
55
51
|
|
|
56
52
|
const inputField = canvas.getByPlaceholderText('Type here');
|
|
57
53
|
await userEvent.type(inputField, 'Hello');
|
|
58
54
|
|
|
59
|
-
expect(canvas.getByText('Press enter or tab to save')).toBeInTheDocument();
|
|
55
|
+
await expect(canvas.getByText('Press enter or tab to save')).toBeInTheDocument();
|
|
60
56
|
|
|
61
57
|
// Test enter to save
|
|
62
58
|
updateValue.mockClear();
|
|
63
59
|
await userEvent.type(inputField, '{Enter}');
|
|
64
|
-
expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
|
|
60
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
|
|
65
61
|
|
|
66
62
|
// Test tab to save
|
|
67
63
|
updateValue.mockClear();
|
|
68
64
|
await userEvent.tab();
|
|
69
|
-
expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
65
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
|
|
70
66
|
|
|
71
67
|
// Test shift+tab to save
|
|
72
68
|
updateValue.mockClear();
|
|
73
69
|
await userEvent.tab({ shift: true });
|
|
74
|
-
expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
70
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
|
|
75
71
|
|
|
76
72
|
// Test escape not to save
|
|
77
73
|
updateValue.mockClear();
|
|
78
74
|
await userEvent.type(inputField, '{Escape}');
|
|
79
|
-
expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
75
|
+
await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
|
|
80
76
|
|
|
81
77
|
// Test invalid value doesn't save
|
|
82
78
|
updateValue.mockClear();
|
|
83
79
|
await userEvent.clear(inputField);
|
|
84
80
|
|
|
85
|
-
expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
|
|
81
|
+
await expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
|
|
86
82
|
await userEvent.type(inputField, '{Enter}');
|
|
87
|
-
expect(updateValue).not.toHaveBeenCalled();
|
|
83
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
88
84
|
await userEvent.tab();
|
|
89
|
-
expect(updateValue).not.toHaveBeenCalled();
|
|
85
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
90
86
|
await userEvent.tab({ shift: true });
|
|
91
|
-
expect(updateValue).not.toHaveBeenCalled();
|
|
87
|
+
await expect(updateValue).not.toHaveBeenCalled();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const FilterTemplate: StoryFn<typeof GridFormTextInput> = (props: GridFormTextInputProps<any>) => {
|
|
91
|
+
const anchorRef = useRef<HTMLHeadingElement>(null);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className={'react-menu-inline-test'}>
|
|
95
|
+
<LuiFilterCharactersProvider>
|
|
96
|
+
<GridContextProvider>
|
|
97
|
+
<h6 ref={anchorRef}>Interaction Test</h6>
|
|
98
|
+
<GridPopoverContext.Provider
|
|
99
|
+
value={{
|
|
100
|
+
anchorRef,
|
|
101
|
+
value: null,
|
|
102
|
+
updateValue,
|
|
103
|
+
data: { value: null },
|
|
104
|
+
colId: '',
|
|
105
|
+
field: 'value',
|
|
106
|
+
selectedRows: [],
|
|
107
|
+
saving: false,
|
|
108
|
+
setSaving: () => {},
|
|
109
|
+
formatValue: (value) => value,
|
|
110
|
+
stopEditing: () => {},
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
<GridFormTextInput {...props} />
|
|
114
|
+
</GridPopoverContext.Provider>
|
|
115
|
+
</GridContextProvider>
|
|
116
|
+
</LuiFilterCharactersProvider>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// By default (disableUnicodeCharacterFilter unset) invalid unicode characters are silently
|
|
122
|
+
// converted or stripped as the user types, matching LuiTextInput's behaviour.
|
|
123
|
+
export const GridFormTextInputUnicodeFilter_ = FilterTemplate.bind({});
|
|
124
|
+
GridFormTextInputUnicodeFilter_.play = async ({ canvasElement }) => {
|
|
125
|
+
const canvas = within(canvasElement);
|
|
126
|
+
|
|
127
|
+
// The popover mounts asynchronously (GridPopoverHook opens on a post-mount effect), so wait for it.
|
|
128
|
+
const inputField = await canvas.findByPlaceholderText('Type here');
|
|
129
|
+
// ’ (U+2019 right single quote) -> ' , — (U+2014 em dash) -> - , Ω (U+03A9, out of range) -> removed
|
|
130
|
+
await userEvent.type(inputField, 'It’s—cool Ω');
|
|
131
|
+
|
|
132
|
+
await expect(inputField).toHaveValue("It's-cool ");
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// disableUnicodeCharacterFilter=true opts out of filtering, leaving invalid characters intact.
|
|
136
|
+
export const GridFormTextInputUnicodeFilterDisabled_ = FilterTemplate.bind({});
|
|
137
|
+
GridFormTextInputUnicodeFilterDisabled_.args = { disableUnicodeCharacterFilter: true };
|
|
138
|
+
GridFormTextInputUnicodeFilterDisabled_.play = async ({ canvasElement }) => {
|
|
139
|
+
const canvas = within(canvasElement);
|
|
140
|
+
|
|
141
|
+
const inputField = await canvas.findByPlaceholderText('Type here');
|
|
142
|
+
// Same chars as above, but left untouched since filtering is disabled
|
|
143
|
+
await userEvent.type(inputField, 'It’s—cool Ω');
|
|
144
|
+
|
|
145
|
+
await expect(inputField).toHaveValue('It’s—cool Ω');
|
|
92
146
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import '../../../react-menu3/styles/index.scss';
|
|
2
2
|
import '../../../styles/index.scss';
|
|
3
3
|
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
4
|
|
|
6
5
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
6
|
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import '../../../styles/GridTheme.scss';
|
|
2
|
-
import '../../../styles/index.scss';
|
|
3
|
-
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
-
import '@linzjs/lui/dist/fonts';
|
|
5
|
-
|
|
6
1
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
2
|
import { useMemo, useState } from 'react';
|
|
8
3
|
import { expect, within } from 'storybook/test';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Decorator } from '@storybook/react-vite';
|
|
2
|
+
import chromaticIsChromatic from 'chromatic/isChromatic';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
export interface WindowChromaticProps {
|
|
6
|
+
FORCE_IS_CHROMATIC?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Wraps chromatic's isChromatic(). If window.FORCE_IS_CHROMATIC is set, returns that;
|
|
11
|
+
* otherwise returns whatever the real chromaticIsChromatic() reports.
|
|
12
|
+
*/
|
|
13
|
+
export const isChromatic = (): boolean => {
|
|
14
|
+
const forced = (window as WindowChromaticProps).FORCE_IS_CHROMATIC;
|
|
15
|
+
return forced ?? chromaticIsChromatic();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Story decorator that forces isChromatic() to false for the story's lifetime. */
|
|
19
|
+
export const ChromaticAllowGridAutosize: Decorator = (Story) => {
|
|
20
|
+
// Set during render (not in useEffect) so it's already in place before Story
|
|
21
|
+
// renders in this same pass — Grid reads isChromatic() synchronously while rendering.
|
|
22
|
+
// oxlint-disable-next-line react/immutability
|
|
23
|
+
(window as WindowChromaticProps).FORCE_IS_CHROMATIC = false;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
return () => {
|
|
26
|
+
delete (window as WindowChromaticProps).FORCE_IS_CHROMATIC;
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
return <Story />;
|
|
30
|
+
};
|