@linzjs/step-ag-grid 8.4.2 → 8.4.3

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 (35) hide show
  1. package/dist/src/lui/TextAreaInput.d.ts +1 -0
  2. package/dist/src/lui/TextInputFormatted.d.ts +1 -0
  3. package/dist/src/react-menu3/components/FocusableItem.d.ts +1 -1
  4. package/dist/src/react-menu3/components/MenuItem.d.ts +3 -1
  5. package/dist/src/react-menu3/components/SubMenu.d.ts +1 -1
  6. package/dist/src/react-menu3/utils/withHovering.d.ts +2 -2
  7. package/dist/step-ag-grid.esm.js +46 -54
  8. package/dist/step-ag-grid.esm.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/components/gridForm/GridFormDropDown.tsx +10 -12
  11. package/src/components/gridForm/GridFormMultiSelect.tsx +19 -23
  12. package/src/components/gridForm/GridFormPopoverMenu.tsx +18 -22
  13. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -0
  14. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -0
  15. package/src/components/gridForm/GridFormTextArea.tsx +1 -1
  16. package/src/components/gridForm/GridFormTextInput.tsx +1 -1
  17. package/src/lui/TextAreaInput.tsx +2 -0
  18. package/src/lui/TextInputFormatted.tsx +2 -0
  19. package/src/react-menu3/components/MenuItem.tsx +1 -1
  20. package/src/react-menu3/utils/withHovering.tsx +3 -3
  21. package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +10 -2
  22. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +128 -0
  23. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +92 -0
  24. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +91 -0
  25. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +171 -0
  26. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +78 -0
  27. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +85 -0
  28. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormDropDown.stories.tsx +1 -1
  29. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormEditBearing.stories.tsx +1 -1
  30. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormEditBearingCorrection.stories.tsx +1 -1
  31. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormMessage.stories.tsx +1 -1
  32. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormMultiSelect.stories.tsx +1 -1
  33. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormPopoverMenu.stories.tsx +1 -1
  34. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormTextArea.stories.tsx +1 -1
  35. package/src/stories/grid/{gridForm → gridFormStatic}/GridFormTextInput.stories.tsx +1 -1
@@ -0,0 +1,171 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import {
6
+ GridFormPopoverMenu,
7
+ PopoutMenuSeparator,
8
+ SelectedMenuOptionResult,
9
+ } from "../../../components/gridForm/GridFormPopoverMenu";
10
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
11
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
12
+ import { useRef } from "react";
13
+ import { userEvent, within } from "@storybook/testing-library";
14
+ import { expect, jest } from "@storybook/jest";
15
+ import { GridBaseRow } from "../../../components/Grid";
16
+ import { GridFormSubComponentTextInput } from "../../../components/gridForm/GridFormSubComponentTextInput";
17
+ import { GridFormSubComponentTextArea } from "../../../components/gridForm/GridFormSubComponentTextArea";
18
+
19
+ export default {
20
+ title: "GridForm / Interactions",
21
+ component: GridFormPopoverMenu,
22
+ args: {},
23
+ } as ComponentMeta<typeof GridFormPopoverMenu>;
24
+
25
+ const updateValue = jest
26
+ .fn<void, [saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1]>()
27
+ .mockImplementation(async (saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => {
28
+ await saveFn([]);
29
+ });
30
+
31
+ const enabledAction = jest
32
+ .fn<Promise<void>, [{ selectedRows: GridBaseRow[]; menuOption: SelectedMenuOptionResult<GridBaseRow> }]>()
33
+ .mockResolvedValue(undefined);
34
+
35
+ const disabledAction = jest
36
+ .fn<Promise<void>, [{ selectedRows: GridBaseRow[]; menuOption: SelectedMenuOptionResult<GridBaseRow> }]>()
37
+ .mockResolvedValue(undefined);
38
+
39
+ const Template: ComponentStory<typeof GridFormPopoverMenu> = (props) => {
40
+ const anchorRef = useRef<HTMLHeadingElement>(null);
41
+
42
+ return (
43
+ <div className={"react-menu-inline-test"}>
44
+ <GridContextProvider>
45
+ <h6 ref={anchorRef}>Test</h6>
46
+ <GridPopoverContext.Provider
47
+ value={
48
+ {
49
+ anchorRef,
50
+ value: null,
51
+ updateValue,
52
+ } as any as GridPopoverContextType<any>
53
+ }
54
+ >
55
+ <GridFormPopoverMenu
56
+ {...props}
57
+ options={async () => [
58
+ { label: "Enabled", value: 1, action: enabledAction },
59
+ PopoutMenuSeparator,
60
+ { label: "Disabled", value: 0, disabled: true, action: disabledAction },
61
+ {
62
+ label: "Sub text input",
63
+ value: 0,
64
+ subComponent: () => (
65
+ <GridFormSubComponentTextInput placeholder={"Text input"} maxLength={5} required defaultValue={""} />
66
+ ),
67
+ },
68
+ {
69
+ label: "Sub text area",
70
+ value: 0,
71
+ subComponent: () => (
72
+ <GridFormSubComponentTextArea placeholder={"Text area"} maxLength={5} required defaultValue={""} />
73
+ ),
74
+ },
75
+ { label: "ERROR! this should be hidden", value: 3, hidden: true },
76
+ ]}
77
+ />
78
+ </GridPopoverContext.Provider>
79
+ </GridContextProvider>
80
+ </div>
81
+ );
82
+ };
83
+
84
+ export const GridFormPopoverMenuInteractions_ = Template.bind({});
85
+ GridFormPopoverMenuInteractions_.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
+ expect(enabledMenuOption).toBeInTheDocument();
92
+ userEvent.click(enabledMenuOption);
93
+ expect(enabledAction).toHaveBeenCalled();
94
+
95
+ enabledAction.mockClear();
96
+ const disabledMenuOption = await getOption("Disabled");
97
+ expect(disabledMenuOption).toBeInTheDocument();
98
+ userEvent.click(disabledMenuOption);
99
+ expect(disabledAction).not.toHaveBeenCalled();
100
+
101
+ // Sub input tests
102
+ const subTextInput = await getOption("Sub text input");
103
+ expect(subTextInput).toBeInTheDocument();
104
+ expect(canvas.queryByPlaceholderText("Text input")).not.toBeInTheDocument();
105
+
106
+ const subTextArea = await getOption("Sub text area");
107
+ expect(subTextArea).toBeInTheDocument();
108
+ expect(canvas.queryByPlaceholderText("Text area")).not.toBeInTheDocument();
109
+
110
+ userEvent.click(subTextInput);
111
+ const textInput = await canvas.findByPlaceholderText("Text input");
112
+ expect(textInput).toBeInTheDocument();
113
+ expect(await canvas.findByText("Must not be empty")).toBeInTheDocument();
114
+ expect(canvas.queryByPlaceholderText("Text area")).not.toBeInTheDocument();
115
+
116
+ userEvent.type(textInput, "Hello");
117
+ expect(await canvas.findByText("Press enter or tab to save")).toBeInTheDocument();
118
+
119
+ // Test tab to save
120
+ updateValue.mockClear();
121
+ userEvent.tab();
122
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
123
+
124
+ // Test shift+tab to save
125
+ updateValue.mockClear();
126
+ userEvent.tab({ shift: true });
127
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
128
+
129
+ // Test escape to not save
130
+ updateValue.mockClear();
131
+ userEvent.type(textInput, "{Escape}");
132
+ expect(updateValue).not.toHaveBeenCalled();
133
+
134
+ // Test invalid value doesn't save
135
+ updateValue.mockClear();
136
+ userEvent.clear(textInput);
137
+ userEvent.type(textInput, "{Enter}");
138
+ expect(updateValue).not.toHaveBeenCalled();
139
+
140
+ // Sub text area tests
141
+ subTextArea.click();
142
+
143
+ const textArea = await canvas.findByPlaceholderText("Text area");
144
+ expect(textArea).toBeInTheDocument();
145
+ expect(await canvas.findByText("Must not be empty")).toBeInTheDocument();
146
+ expect(canvas.queryByPlaceholderText("Text input")).not.toBeInTheDocument();
147
+
148
+ userEvent.type(textArea, "Hello");
149
+ expect(await canvas.findByText("Press tab to save")).toBeInTheDocument();
150
+
151
+ // Test tab to save
152
+ updateValue.mockClear();
153
+ userEvent.tab();
154
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
155
+
156
+ // Test shift+tab to save
157
+ updateValue.mockClear();
158
+ userEvent.tab({ shift: true });
159
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
160
+
161
+ // Test escape to not save
162
+ updateValue.mockClear();
163
+ userEvent.type(textArea, "{Escape}");
164
+ expect(updateValue).not.toHaveBeenCalled();
165
+
166
+ // Test invalid value doesn't save
167
+ updateValue.mockClear();
168
+ userEvent.clear(textArea);
169
+ userEvent.type(textArea, "{Enter}");
170
+ expect(updateValue).not.toHaveBeenCalled();
171
+ };
@@ -0,0 +1,78 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import { GridFormTextArea } from "../../../components/gridForm/GridFormTextArea";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+ import { userEvent, within } from "@storybook/testing-library";
10
+ import { expect, jest } from "@storybook/jest";
11
+
12
+ export default {
13
+ title: "GridForm / Interactions",
14
+ component: GridFormTextArea,
15
+ args: {},
16
+ } as ComponentMeta<typeof GridFormTextArea>;
17
+
18
+ const updateValue = jest.fn();
19
+
20
+ const Template: ComponentStory<typeof GridFormTextArea> = (props) => {
21
+ const anchorRef = useRef<HTMLHeadingElement>(null);
22
+
23
+ return (
24
+ <div className={"react-menu-inline-test"}>
25
+ <GridContextProvider>
26
+ <h6 ref={anchorRef}>Test</h6>
27
+ <GridPopoverContext.Provider
28
+ value={
29
+ {
30
+ anchorRef,
31
+ value: null,
32
+ updateValue,
33
+ } as any as GridPopoverContextType<any>
34
+ }
35
+ >
36
+ <GridFormTextArea {...props} required={true} />
37
+ </GridPopoverContext.Provider>
38
+ </GridContextProvider>
39
+ </div>
40
+ );
41
+ };
42
+
43
+ export const GridFormTextAreaInteractions_ = Template.bind({});
44
+ GridFormTextAreaInteractions_.play = async ({ canvasElement }) => {
45
+ const canvas = within(canvasElement);
46
+
47
+ expect(await canvas.findByText("Must not be empty")).toBeInTheDocument();
48
+
49
+ const inputField = canvas.getByPlaceholderText("Type here");
50
+ userEvent.type(inputField, "Hello");
51
+
52
+ expect(await canvas.findByText("Press tab to save")).toBeInTheDocument();
53
+
54
+ // Test tab to save
55
+ updateValue.mockClear();
56
+ userEvent.tab();
57
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
58
+
59
+ // Test shift+tab to save
60
+ updateValue.mockClear();
61
+ userEvent.tab({ shift: true });
62
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
63
+
64
+ // Test escape not to save
65
+ updateValue.mockClear();
66
+ userEvent.type(inputField, "{Escape}");
67
+ expect(updateValue).not.toHaveBeenCalled();
68
+
69
+ // Test invalid value doesn't save
70
+ updateValue.mockClear();
71
+ userEvent.clear(inputField);
72
+
73
+ expect(canvas.getByText("Must not be empty")).toBeInTheDocument();
74
+ userEvent.tab();
75
+ expect(updateValue).not.toHaveBeenCalled();
76
+ userEvent.tab({ shift: true });
77
+ expect(updateValue).not.toHaveBeenCalled();
78
+ };
@@ -0,0 +1,85 @@
1
+ import "@linzjs/lui/dist/scss/base.scss";
2
+ import "@linzjs/lui/dist/fonts";
3
+
4
+ import { ComponentMeta, ComponentStory } from "@storybook/react/dist/ts3.9/client/preview/types-6-3";
5
+ import { GridFormTextInput } from "../../../components/gridForm/GridFormTextInput";
6
+ import { GridContextProvider } from "../../../contexts/GridContextProvider";
7
+ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
8
+ import { useRef } from "react";
9
+ import { userEvent, within } from "@storybook/testing-library";
10
+ import { expect, jest } from "@storybook/jest";
11
+
12
+ export default {
13
+ title: "GridForm / Interactions",
14
+ component: GridFormTextInput,
15
+ args: {},
16
+ } as ComponentMeta<typeof GridFormTextInput>;
17
+
18
+ const updateValue = jest.fn();
19
+
20
+ const Template: ComponentStory<typeof GridFormTextInput> = (props) => {
21
+ const anchorRef = useRef<HTMLHeadingElement>(null);
22
+
23
+ return (
24
+ <div className={"react-menu-inline-test"}>
25
+ <GridContextProvider>
26
+ <h6 ref={anchorRef}>Test</h6>
27
+ <GridPopoverContext.Provider
28
+ value={
29
+ {
30
+ anchorRef,
31
+ value: null,
32
+ updateValue,
33
+ } as any as GridPopoverContextType<any>
34
+ }
35
+ >
36
+ <GridFormTextInput {...props} required={true} />
37
+ </GridPopoverContext.Provider>
38
+ </GridContextProvider>
39
+ </div>
40
+ );
41
+ };
42
+
43
+ export const GridFormTextInputInteractions_ = Template.bind({});
44
+ GridFormTextInputInteractions_.play = async ({ canvasElement }) => {
45
+ const canvas = within(canvasElement);
46
+
47
+ expect(await canvas.findByText("Must not be empty")).toBeInTheDocument();
48
+
49
+ const inputField = canvas.getByPlaceholderText("Type here");
50
+ userEvent.type(inputField, "Hello");
51
+
52
+ expect(canvas.getByText("Press enter or tab to save")).toBeInTheDocument();
53
+
54
+ // Test enter to save
55
+ updateValue.mockClear();
56
+ userEvent.type(inputField, "{Enter}");
57
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), 0); // 0 = Enter
58
+
59
+ // Test tab to save
60
+ updateValue.mockClear();
61
+ userEvent.tab();
62
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), 1); // 1 = Tab
63
+
64
+ // Test shift+tab to save
65
+ updateValue.mockClear();
66
+ userEvent.tab({ shift: true });
67
+ expect(updateValue).toHaveBeenCalledWith(expect.anything(), -1); // -1 = Shift + tab
68
+
69
+ // Test escape not to save
70
+ updateValue.mockClear();
71
+ userEvent.type(inputField, "{Escape}");
72
+ expect(updateValue).not.toHaveBeenCalled();
73
+
74
+ // Test invalid value doesn't save
75
+ updateValue.mockClear();
76
+ userEvent.clear(inputField);
77
+
78
+ expect(canvas.getByText("Must not be empty")).toBeInTheDocument();
79
+ userEvent.type(inputField, "{Enter}");
80
+ expect(updateValue).not.toHaveBeenCalled();
81
+ userEvent.tab();
82
+ expect(updateValue).not.toHaveBeenCalled();
83
+ userEvent.tab({ shift: true });
84
+ expect(updateValue).not.toHaveBeenCalled();
85
+ };
@@ -9,7 +9,7 @@ import { useRef } from "react";
9
9
  import { GridBaseRow } from "../../../components/Grid";
10
10
 
11
11
  export default {
12
- title: "GridForm / Testing",
12
+ title: "GridForm / Static Tests",
13
13
  component: GridFormDropDown,
14
14
  args: {},
15
15
  } as ComponentMeta<typeof GridFormDropDown>;
@@ -9,7 +9,7 @@ import { useRef } from "react";
9
9
  import { GridPopoverEditBearingEditorParams } from "../../../components/gridPopoverEdit/GridPopoverEditBearing";
10
10
 
11
11
  export default {
12
- title: "GridForm / Testing",
12
+ title: "GridForm / Static Tests",
13
13
  component: GridFormEditBearing,
14
14
  args: {},
15
15
  } as ComponentMeta<typeof GridFormEditBearing>;
@@ -9,7 +9,7 @@ import { useRef } from "react";
9
9
  import { GridPopoverEditBearingCorrectionEditorParams } from "../../../components/gridPopoverEdit/GridPopoverEditBearing";
10
10
 
11
11
  export default {
12
- title: "GridForm / Testing",
12
+ title: "GridForm / Static Tests",
13
13
  component: GridFormEditBearing,
14
14
  args: {},
15
15
  } as ComponentMeta<typeof GridFormEditBearing>;
@@ -8,7 +8,7 @@ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopover
8
8
  import { useRef } from "react";
9
9
 
10
10
  export default {
11
- title: "GridForm / Testing",
11
+ title: "GridForm / Static Tests",
12
12
  component: GridFormMessage,
13
13
  args: {},
14
14
  } as ComponentMeta<typeof GridFormMessage>;
@@ -9,7 +9,7 @@ import { useRef } from "react";
9
9
  import { GridBaseRow } from "../../../components/Grid";
10
10
 
11
11
  export default {
12
- title: "GridForm / Testing",
12
+ title: "GridForm / Static Tests",
13
13
  component: GridFormMultiSelect,
14
14
  args: {},
15
15
  } as ComponentMeta<typeof GridFormMultiSelect>;
@@ -13,7 +13,7 @@ import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopover
13
13
  import { GridBaseRow } from "../../../components/Grid";
14
14
 
15
15
  export default {
16
- title: "GridForm / Testing",
16
+ title: "GridForm / Static Tests",
17
17
  component: GridFormPopoverMenu,
18
18
  args: {},
19
19
  } as ComponentMeta<typeof GridFormPopoverMenu>;
@@ -9,7 +9,7 @@ import { useRef } from "react";
9
9
  import { GridBaseRow } from "../../../components/Grid";
10
10
 
11
11
  export default {
12
- title: "GridForm / Testing",
12
+ title: "GridForm / Static Tests",
13
13
  component: GridFormTextArea,
14
14
  args: {},
15
15
  } as ComponentMeta<typeof GridFormTextArea>;
@@ -9,7 +9,7 @@ import { useRef } from "react";
9
9
  import { GridBaseRow } from "../../../components/Grid";
10
10
 
11
11
  export default {
12
- title: "GridForm / Testing",
12
+ title: "GridForm / Static Tests",
13
13
  component: GridFormTextInput,
14
14
  args: {},
15
15
  } as ComponentMeta<typeof GridFormTextInput>;