@linzjs/step-ag-grid 32.7.0 → 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 +115 -181
  3. package/dist/step-ag-grid.cjs.map +1 -1
  4. package/dist/step-ag-grid.esm.js +115 -181
  5. package/dist/step-ag-grid.esm.js.map +1 -1
  6. package/package.json +17 -17
  7. package/src/components/Grid.tsx +6 -4
  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,8 +1,4 @@
1
- import '../../../react-menu3/styles/index.scss';
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 * as test from 'storybook/test';
@@ -17,12 +13,6 @@ import {
17
13
  PopoutMenuSeparator,
18
14
  } from '../../..';
19
15
 
20
- export default {
21
- title: 'GridForm / Interactions',
22
- component: GridFormPopoverMenu,
23
- args: {},
24
- };
25
-
26
16
  const updateValue = test.fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) =>
27
17
  saveFn([]),
28
18
  );
@@ -82,93 +72,103 @@ const Template: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMen
82
72
  );
83
73
  };
84
74
 
85
- export const GridFormPopoverMenuInteractions_: typeof Template = Template.bind({});
86
- GridFormPopoverMenuInteractions_.play = async ({ canvasElement }) => {
87
- const canvas = within(canvasElement);
88
-
89
- const getOption = (name: string) => canvas.findByRole('menuitem', { name });
90
-
91
- const enabledMenuOption = await getOption('Enabled');
92
- expect(enabledMenuOption).toBeInTheDocument();
93
- await userEvent.click(enabledMenuOption);
94
- expect(enabledAction).toHaveBeenCalled();
95
-
96
- enabledAction.mockClear();
97
- const disabledMenuOption = await getOption('Disabled');
98
- expect(disabledMenuOption).toBeInTheDocument();
99
- await userEvent.click(disabledMenuOption);
100
- expect(disabledAction).not.toHaveBeenCalled();
101
-
102
- // Sub input tests
103
- const subTextInput = await getOption('Sub text input');
104
- expect(subTextInput).toBeInTheDocument();
105
- expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
106
-
107
- const subTextArea = await getOption('Sub text area');
108
- expect(subTextArea).toBeInTheDocument();
109
- expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
110
-
111
- await userEvent.click(subTextInput);
112
- const textInput = await canvas.findByPlaceholderText('Text input');
113
- expect(textInput).toBeInTheDocument();
114
- expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
115
- expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
116
-
117
- await userEvent.type(textInput, 'Hello');
118
- expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
119
-
120
- // Test tab to save
121
- updateValue.mockClear();
122
- await userEvent.tab();
123
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
124
-
125
- // Test shift+tab to save
126
- updateValue.mockClear();
127
- await userEvent.tab({ shift: true });
128
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
129
-
130
- // Test escape to not save
131
- updateValue.mockClear();
132
- await userEvent.type(textInput, '{Escape}');
133
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
134
-
135
- // Test invalid value doesn't save
136
- updateValue.mockClear();
137
- await userEvent.clear(textInput);
138
- await userEvent.type(textInput, '{Enter}');
139
- expect(updateValue).not.toHaveBeenCalled();
140
-
141
- // Sub text area tests
142
- subTextArea.click();
143
-
144
- const textArea = await canvas.findByPlaceholderText('Text area');
145
- expect(textArea).toBeInTheDocument();
146
- expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
147
- expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
148
-
149
- await userEvent.type(textArea, 'Hello');
150
- expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
151
-
152
- // Test tab to save
153
- updateValue.mockClear();
154
- await userEvent.tab();
155
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
156
-
157
- // Test shift+tab to save
158
- updateValue.mockClear();
159
- await userEvent.tab({ shift: true });
160
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
161
-
162
- // Test escape to not save
163
- updateValue.mockClear();
164
- await userEvent.type(textArea, '{Escape}');
165
- expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
166
-
167
- // Test invalid value doesn't save
168
- updateValue.mockClear();
169
- await userEvent.clear(textArea);
170
- await userEvent.type(textArea, '{Enter}');
171
- expect(updateValue).not.toHaveBeenCalled();
75
+ const meta: Meta<typeof Template> = {
76
+ title: 'GridForm / Interactions',
77
+ component: Template,
78
+ args: {},
79
+ };
80
+ export default meta;
81
+
82
+ type Story = StoryObj<typeof meta>;
83
+
84
+ export const GridFormPopoverMenuInteractions_: Story = {
85
+ play: async ({ canvasElement }) => {
86
+ const canvas = within(canvasElement);
87
+
88
+ const getOption = (name: string) => canvas.findByRole('menuitem', { name });
89
+
90
+ const enabledMenuOption = await getOption('Enabled');
91
+ await expect(enabledMenuOption).toBeInTheDocument();
92
+ await userEvent.click(enabledMenuOption);
93
+ await expect(enabledAction).toHaveBeenCalled();
94
+
95
+ enabledAction.mockClear();
96
+ const disabledMenuOption = await getOption('Disabled');
97
+ await expect(disabledMenuOption).toBeInTheDocument();
98
+ await userEvent.click(disabledMenuOption);
99
+ await expect(disabledAction).not.toHaveBeenCalled();
100
+
101
+ // Sub input tests
102
+ const subTextInput = await getOption('Sub text input');
103
+ await expect(subTextInput).toBeInTheDocument();
104
+ await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
105
+
106
+ const subTextArea = await getOption('Sub text area');
107
+ await expect(subTextArea).toBeInTheDocument();
108
+ await expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
109
+
110
+ await userEvent.click(subTextInput);
111
+ const textInput = await canvas.findByPlaceholderText('Text input');
112
+ await expect(textInput).toBeInTheDocument();
113
+ await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
114
+ await expect(canvas.queryByPlaceholderText('Text area')).not.toBeInTheDocument();
115
+
116
+ await userEvent.type(textInput, 'Hello');
117
+ await expect(await canvas.findByText('Press enter or tab to save')).toBeInTheDocument();
118
+
119
+ // Test tab to save
120
+ updateValue.mockClear();
121
+ await userEvent.tab();
122
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
123
+
124
+ // Test shift+tab to save
125
+ updateValue.mockClear();
126
+ await userEvent.tab({ shift: true });
127
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
128
+
129
+ // Test escape to not save
130
+ updateValue.mockClear();
131
+ await userEvent.type(textInput, '{Escape}');
132
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
133
+
134
+ // Test invalid value doesn't save
135
+ updateValue.mockClear();
136
+ await userEvent.clear(textInput);
137
+ await userEvent.type(textInput, '{Enter}');
138
+ await expect(updateValue).not.toHaveBeenCalled();
139
+
140
+ // Sub text area tests
141
+ subTextArea.click();
142
+
143
+ const textArea = await canvas.findByPlaceholderText('Text area');
144
+ await expect(textArea).toBeInTheDocument();
145
+ await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
146
+ await expect(canvas.queryByPlaceholderText('Text input')).not.toBeInTheDocument();
147
+
148
+ await userEvent.type(textArea, 'Hello');
149
+ await expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
150
+
151
+ // Test tab to save
152
+ updateValue.mockClear();
153
+ await userEvent.tab();
154
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
155
+
156
+ // Test shift+tab to save
157
+ updateValue.mockClear();
158
+ await userEvent.tab({ shift: true });
159
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
160
+
161
+ // Test escape to not save
162
+ updateValue.mockClear();
163
+ await userEvent.type(textArea, '{Escape}');
164
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
165
+
166
+ // Test invalid value doesn't save
167
+ updateValue.mockClear();
168
+ await userEvent.clear(textArea);
169
+ await userEvent.type(textArea, '{Enter}');
170
+ await expect(updateValue).not.toHaveBeenCalled();
171
+ },
172
172
  };
173
173
 
174
174
  const AllHiddenTemplate: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMenuProps<any>) => {
@@ -209,11 +209,13 @@ const AllHiddenTemplate: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormP
209
209
  // Regression test: when every option resolves to hidden, the menu must show "No actions"
210
210
  // rather than an empty menu body (isEmpty(options) alone doesn't catch this — the array is
211
211
  // non-empty, just every item is hidden).
212
- export const GridFormPopoverMenuAllOptionsHidden_ = AllHiddenTemplate.bind({});
213
- GridFormPopoverMenuAllOptionsHidden_.play = async ({ canvasElement }) => {
214
- const canvas = within(canvasElement);
215
-
216
- expect(await canvas.findByText('No actions')).toBeInTheDocument();
217
- expect(canvas.queryByRole('menuitem', { name: 'Hidden one' })).not.toBeInTheDocument();
218
- expect(canvas.queryByRole('menuitem', { name: 'Hidden two' })).not.toBeInTheDocument();
212
+ export const GridFormPopoverMenuAllOptionsHidden_: Story = {
213
+ render: AllHiddenTemplate,
214
+ play: async ({ canvasElement }) => {
215
+ const canvas = within(canvasElement);
216
+
217
+ await expect(await canvas.findByText('No actions')).toBeInTheDocument();
218
+ await expect(canvas.queryByRole('menuitem', { name: 'Hidden one' })).not.toBeInTheDocument();
219
+ await expect(canvas.queryByRole('menuitem', { name: 'Hidden two' })).not.toBeInTheDocument();
220
+ },
219
221
  };
@@ -1,17 +1,11 @@
1
1
  import { LuiFilterCharactersProvider } from '@linzjs/lui';
2
- import { StoryFn } from '@storybook/react-vite';
2
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-vite';
3
3
  import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
4
4
  import { useRef } from 'react';
5
5
  import { expect, fn, userEvent, within } from 'storybook/test';
6
6
 
7
7
  import { GridContextProvider, GridFormTextArea, GridFormTextAreaProps } from '../../..';
8
8
 
9
- export default {
10
- title: 'GridForm / Interactions',
11
- component: GridFormTextArea,
12
- args: {},
13
- };
14
-
15
9
  const updateValue = fn();
16
10
 
17
11
  const Template: StoryFn<typeof GridFormTextArea> = (props: GridFormTextAreaProps<any>) => {
@@ -43,43 +37,6 @@ const Template: StoryFn<typeof GridFormTextArea> = (props: GridFormTextAreaProps
43
37
  );
44
38
  };
45
39
 
46
- export const GridFormTextAreaInteractions_: typeof Template = Template.bind({});
47
- GridFormTextAreaInteractions_.play = async ({ canvasElement }) => {
48
- const canvas = within(canvasElement);
49
-
50
- await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
51
-
52
- const inputField = canvas.getByPlaceholderText('Type here');
53
- await userEvent.type(inputField, 'Hello');
54
-
55
- await expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
56
-
57
- // Test tab to save
58
- updateValue.mockClear();
59
- await userEvent.tab();
60
- await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
61
-
62
- // Test shift+tab to save
63
- updateValue.mockClear();
64
- await userEvent.tab({ shift: true });
65
- await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
66
-
67
- // Test escape not to save
68
- updateValue.mockClear();
69
- await userEvent.type(inputField, '{Escape}');
70
- await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
71
-
72
- // Test invalid value doesn't save
73
- updateValue.mockClear();
74
- await userEvent.clear(inputField);
75
-
76
- await expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
77
- await userEvent.tab();
78
- await expect(updateValue).not.toHaveBeenCalled();
79
- await userEvent.tab({ shift: true });
80
- await expect(updateValue).not.toHaveBeenCalled();
81
- };
82
-
83
40
  const FilterTemplate: StoryFn<typeof GridFormTextArea> = (props: GridFormTextAreaProps<any>) => {
84
41
  const anchorRef = useRef<HTMLHeadingElement>(null);
85
42
 
@@ -111,29 +68,80 @@ const FilterTemplate: StoryFn<typeof GridFormTextArea> = (props: GridFormTextAre
111
68
  );
112
69
  };
113
70
 
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);
71
+ const meta: Meta<typeof Template> = {
72
+ title: 'GridForm / Interactions',
73
+ component: Template,
74
+ args: {},
75
+ };
76
+ export default meta;
119
77
 
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 Ω');
78
+ type Story = StoryObj<typeof meta>;
124
79
 
125
- await expect(inputField).toHaveValue("It's-cool ");
126
- };
80
+ export const GridFormTextAreaInteractions_: Story = {
81
+ play: async ({ canvasElement }) => {
82
+ const canvas = within(canvasElement);
127
83
 
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);
84
+ await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
85
+
86
+ const inputField = canvas.getByPlaceholderText('Type here');
87
+ await userEvent.type(inputField, 'Hello');
88
+
89
+ await expect(await canvas.findByText('Press tab to save')).toBeInTheDocument();
90
+
91
+ // Test tab to save
92
+ updateValue.mockClear();
93
+ await userEvent.tab();
94
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
95
+
96
+ // Test shift+tab to save
97
+ updateValue.mockClear();
98
+ await userEvent.tab({ shift: true });
99
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
133
100
 
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 Ω');
101
+ // Test escape not to save
102
+ updateValue.mockClear();
103
+ await userEvent.type(inputField, '{Escape}');
104
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
137
105
 
138
- await expect(inputField).toHaveValue('It’s—cool Ω');
106
+ // Test invalid value doesn't save
107
+ updateValue.mockClear();
108
+ await userEvent.clear(inputField);
109
+
110
+ await expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
111
+ await userEvent.tab();
112
+ await expect(updateValue).not.toHaveBeenCalled();
113
+ await userEvent.tab({ shift: true });
114
+ await expect(updateValue).not.toHaveBeenCalled();
115
+ },
116
+ };
117
+
118
+ // By default (disableUnicodeCharacterFilter unset) invalid unicode characters are silently
119
+ // converted or stripped as the user types, matching LuiTextAreaInput's behaviour.
120
+ export const GridFormTextAreaUnicodeFilter_: Story = {
121
+ render: FilterTemplate,
122
+ play: async ({ canvasElement }) => {
123
+ const canvas = within(canvasElement);
124
+
125
+ // The popover mounts asynchronously (GridPopoverHook opens on a post-mount effect), so wait for it.
126
+ const inputField = await canvas.findByPlaceholderText('Type here');
127
+ // ’ (U+2019 right single quote) -> ' , — (U+2014 em dash) -> - , Ω (U+03A9, out of range) -> removed
128
+ await userEvent.type(inputField, 'It’s—cool Ω');
129
+
130
+ await expect(inputField).toHaveValue("It's-cool ");
131
+ },
132
+ };
133
+
134
+ // disableUnicodeCharacterFilter=true opts out of filtering, leaving invalid characters intact.
135
+ export const GridFormTextAreaUnicodeFilterDisabled_: Story = {
136
+ render: FilterTemplate,
137
+ args: { disableUnicodeCharacterFilter: true },
138
+ 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 Ω');
146
+ },
139
147
  };
@@ -1,20 +1,14 @@
1
1
  import { LuiFilterCharactersProvider } from '@linzjs/lui';
2
- import { StoryFn } from '@storybook/react-vite';
2
+ import { Meta, StoryObj } from '@storybook/react-vite';
3
3
  import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
4
4
  import { useRef } from 'react';
5
5
  import { expect, fn, userEvent, within } from 'storybook/test';
6
6
 
7
7
  import { GridContextProvider, GridFormTextInput, GridFormTextInputProps } from '../../..';
8
8
 
9
- export default {
10
- title: 'GridForm / Interactions',
11
- component: GridFormTextInput,
12
- args: {},
13
- };
14
-
15
9
  const updateValue = fn();
16
10
 
17
- const Template: StoryFn<typeof GridFormTextInput> = (props: GridFormTextInputProps<any>) => {
11
+ const Template = (props: GridFormTextInputProps<any>) => {
18
12
  const anchorRef = useRef<HTMLHeadingElement>(null);
19
13
 
20
14
  return (
@@ -43,51 +37,7 @@ const Template: StoryFn<typeof GridFormTextInput> = (props: GridFormTextInputPro
43
37
  );
44
38
  };
45
39
 
46
- export const GridFormTextInputInteractions_: typeof Template = Template.bind({});
47
- GridFormTextInputInteractions_.play = async ({ canvasElement }) => {
48
- const canvas = within(canvasElement);
49
-
50
- await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
51
-
52
- const inputField = canvas.getByPlaceholderText('Type here');
53
- await userEvent.type(inputField, 'Hello');
54
-
55
- await expect(canvas.getByText('Press enter or tab to save')).toBeInTheDocument();
56
-
57
- // Test enter to save
58
- updateValue.mockClear();
59
- await userEvent.type(inputField, '{Enter}');
60
- await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
61
-
62
- // Test tab to save
63
- updateValue.mockClear();
64
- await userEvent.tab();
65
- await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
66
-
67
- // Test shift+tab to save
68
- updateValue.mockClear();
69
- await userEvent.tab({ shift: true });
70
- await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
71
-
72
- // Test escape not to save
73
- updateValue.mockClear();
74
- await userEvent.type(inputField, '{Escape}');
75
- await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
76
-
77
- // Test invalid value doesn't save
78
- updateValue.mockClear();
79
- await userEvent.clear(inputField);
80
-
81
- await expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
82
- await userEvent.type(inputField, '{Enter}');
83
- await expect(updateValue).not.toHaveBeenCalled();
84
- await userEvent.tab();
85
- await expect(updateValue).not.toHaveBeenCalled();
86
- await userEvent.tab({ shift: true });
87
- await expect(updateValue).not.toHaveBeenCalled();
88
- };
89
-
90
- const FilterTemplate: StoryFn<typeof GridFormTextInput> = (props: GridFormTextInputProps<any>) => {
40
+ const FilterTemplate = (props: GridFormTextInputProps<any>) => {
91
41
  const anchorRef = useRef<HTMLHeadingElement>(null);
92
42
 
93
43
  return (
@@ -118,29 +68,88 @@ const FilterTemplate: StoryFn<typeof GridFormTextInput> = (props: GridFormTextIn
118
68
  );
119
69
  };
120
70
 
71
+ const meta: Meta<typeof GridFormTextInput> = {
72
+ title: 'GridForm / Interactions',
73
+ component: GridFormTextInput,
74
+ args: {},
75
+ };
76
+ export default meta;
77
+
78
+ type Story = StoryObj<typeof meta>;
79
+
80
+ export const GridFormTextInputInteractions_: Story = {
81
+ render: Template,
82
+ play: async ({ canvasElement }) => {
83
+ const canvas = within(canvasElement);
84
+
85
+ await expect(await canvas.findByText('Must not be empty')).toBeInTheDocument();
86
+
87
+ const inputField = canvas.getByPlaceholderText('Type here');
88
+ await userEvent.type(inputField, 'Hello');
89
+
90
+ await expect(canvas.getByText('Press enter or tab to save')).toBeInTheDocument();
91
+
92
+ // Test enter to save
93
+ updateValue.mockClear();
94
+ await userEvent.type(inputField, '{Enter}');
95
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
96
+
97
+ // Test tab to save
98
+ updateValue.mockClear();
99
+ await userEvent.tab();
100
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
101
+
102
+ // Test shift+tab to save
103
+ updateValue.mockClear();
104
+ await userEvent.tab({ shift: true });
105
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
106
+
107
+ // Test escape not to save
108
+ updateValue.mockClear();
109
+ await userEvent.type(inputField, '{Escape}');
110
+ await expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0);
111
+
112
+ // Test invalid value doesn't save
113
+ updateValue.mockClear();
114
+ await userEvent.clear(inputField);
115
+
116
+ await expect(canvas.getByText('Must not be empty')).toBeInTheDocument();
117
+ await userEvent.type(inputField, '{Enter}');
118
+ await expect(updateValue).not.toHaveBeenCalled();
119
+ await userEvent.tab();
120
+ await expect(updateValue).not.toHaveBeenCalled();
121
+ await userEvent.tab({ shift: true });
122
+ await expect(updateValue).not.toHaveBeenCalled();
123
+ },
124
+ };
125
+
121
126
  // By default (disableUnicodeCharacterFilter unset) invalid unicode characters are silently
122
127
  // 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 ");
128
+ export const GridFormTextInputUnicodeFilter_: Story = {
129
+ render: FilterTemplate,
130
+ play: async ({ canvasElement }) => {
131
+ const canvas = within(canvasElement);
132
+
133
+ // The popover mounts asynchronously (GridPopoverHook opens on a post-mount effect), so wait for it.
134
+ const inputField = await canvas.findByPlaceholderText('Type here');
135
+ // ’ (U+2019 right single quote) -> ' , — (U+2014 em dash) -> - , Ω (U+03A9, out of range) -> removed
136
+ await userEvent.type(inputField, 'It’s—cool Ω');
137
+
138
+ await expect(inputField).toHaveValue("It's-cool ");
139
+ },
133
140
  };
134
141
 
135
142
  // 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 Ω');
143
+ export const GridFormTextInputUnicodeFilterDisabled_: Story = {
144
+ render: FilterTemplate,
145
+ args: { disableUnicodeCharacterFilter: true },
146
+ play: async ({ canvasElement }) => {
147
+ const canvas = within(canvasElement);
148
+
149
+ const inputField = await canvas.findByPlaceholderText('Type here');
150
+ // Same chars as above, but left untouched since filtering is disabled
151
+ await userEvent.type(inputField, 'It’s—cool Ω');
152
+
153
+ await expect(inputField).toHaveValue('It’s—cool Ω');
154
+ },
146
155
  };
@@ -1,20 +1,10 @@
1
- import '../../../react-menu3/styles/index.scss';
2
- import '../../../styles/index.scss';
3
- import '@linzjs/lui/dist/scss/base.scss';
4
-
5
- import { Meta, StoryFn } from '@storybook/react-vite';
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
6
2
  import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
7
3
  import { useRef } from 'react';
8
4
 
9
5
  import { GridBaseRow, GridContextProvider, GridFormDropDown, GridFormDropDownProps, MenuHeaderItem } from '../../..';
10
6
 
11
- export default {
12
- title: 'GridForm / Static Tests',
13
- component: GridFormDropDown,
14
- args: {},
15
- } as Meta<typeof GridFormDropDown>;
16
-
17
- const Template: StoryFn<typeof GridFormDropDown> = (props: GridFormDropDownProps<GridBaseRow, unknown>) => {
7
+ const Template = (props: GridFormDropDownProps<GridBaseRow, unknown>) => {
18
8
  const configs: [string, GridFormDropDownProps<GridBaseRow, unknown>, string?][] = [
19
9
  ['No options', { options: [] }],
20
10
  ['Custom no options', { options: [], noOptionsMessage: 'Custom no options' }],
@@ -102,4 +92,13 @@ const Template: StoryFn<typeof GridFormDropDown> = (props: GridFormDropDownProps
102
92
  );
103
93
  };
104
94
 
105
- export const GridFormDropDown_ = Template.bind({});
95
+ const meta: Meta<typeof Template> = {
96
+ title: 'GridForm / Static Tests',
97
+ component: Template,
98
+ args: {},
99
+ };
100
+ export default meta;
101
+
102
+ type Story = StoryObj<typeof meta>;
103
+
104
+ export const GridFormDropDown_: Story = {};