@linzjs/step-ag-grid 18.1.0 → 19.1.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.
@@ -2,19 +2,17 @@ import "../../../react-menu3/styles/index.scss";
2
2
  import "../../../styles/index.scss";
3
3
  import "@linzjs/lui/dist/scss/base.scss";
4
4
 
5
- import { expect, jest } from "@storybook/jest";
6
- import { Meta, StoryFn } from "@storybook/react";
7
- import { userEvent, within } from "@storybook/testing-library";
8
- import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
5
+ import { StoryFn } from "@storybook/react";
6
+ import { expect, fn, userEvent, within } from "@storybook/test";
7
+ import { GridPopoverContext } from "contexts/GridPopoverContext";
9
8
  import { useRef } from "react";
10
9
 
11
10
  import "@linzjs/lui/dist/fonts";
12
11
 
13
12
  import {
14
- GridContextProvider,
13
+ GridContext,
15
14
  GridFormMultiSelect,
16
15
  GridFormMultiSelectProps,
17
- GridFormMultiSelectSaveProps,
18
16
  GridFormSubComponentTextInput,
19
17
  MultiSelectOption,
20
18
  wait,
@@ -24,14 +22,12 @@ export default {
24
22
  title: "GridForm / Interactions",
25
23
  component: GridFormMultiSelect,
26
24
  args: {},
27
- } as Meta<typeof GridFormMultiSelect>;
25
+ };
28
26
 
29
- const updateValue = jest
30
- .fn<void, [saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1]>()
31
- .mockImplementation((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => saveFn([]));
27
+ const updateValue = fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => saveFn([]));
32
28
 
33
- const onSave = jest.fn<Promise<boolean>, [GridFormMultiSelectSaveProps<any>]>().mockImplementation(async () => true);
34
- const onSelectFilter = jest.fn();
29
+ const onSave = fn();
30
+ const onSelectFilter = fn();
35
31
 
36
32
  let options: MultiSelectOption[] = [];
37
33
  const Template: StoryFn<typeof GridFormMultiSelect> = (props: GridFormMultiSelectProps<any>) => {
@@ -58,30 +54,36 @@ const Template: StoryFn<typeof GridFormMultiSelect> = (props: GridFormMultiSelec
58
54
 
59
55
  return (
60
56
  <div className={"react-menu-inline-test"}>
61
- <GridContextProvider>
62
- <div>
63
- <h6 ref={anchorRef}>Interaction test</h6>
64
- <GridPopoverContext.Provider
65
- value={
66
- {
67
- anchorRef: anchorRef,
68
- updateValue,
69
- data: { value: "" },
70
- value: "",
71
- field: "value",
72
- selectedRows: [],
73
- } as any as GridPopoverContextType<any>
74
- }
75
- >
76
- <GridFormMultiSelect {...props} {...config} />
77
- </GridPopoverContext.Provider>
78
- </div>
79
- </GridContextProvider>
57
+ <GridContext.Provider
58
+ value={
59
+ {
60
+ stopEditing: () => {},
61
+ cancelEdit: () => {},
62
+ } as any
63
+ }
64
+ >
65
+ <h6 ref={anchorRef}>Interaction test</h6>
66
+ <GridPopoverContext.Provider
67
+ value={{
68
+ anchorRef,
69
+ updateValue,
70
+ data: { value: "" },
71
+ value: "",
72
+ field: "value",
73
+ selectedRows: [],
74
+ saving: false,
75
+ setSaving: () => {},
76
+ formatValue: (value) => value,
77
+ }}
78
+ >
79
+ <GridFormMultiSelect {...props} {...config} />
80
+ </GridPopoverContext.Provider>
81
+ </GridContext.Provider>
80
82
  </div>
81
83
  );
82
84
  };
83
85
 
84
- export const GridFormMultiSelectInteractions_ = Template.bind({});
86
+ export const GridFormMultiSelectInteractions_: typeof Template = Template.bind({});
85
87
  GridFormMultiSelectInteractions_.play = async ({ canvasElement }) => {
86
88
  updateValue.mockClear();
87
89
  onSave.mockClear();
@@ -2,17 +2,17 @@ import "../../../react-menu3/styles/index.scss";
2
2
  import "../../../styles/index.scss";
3
3
  import "@linzjs/lui/dist/scss/base.scss";
4
4
 
5
- import { expect, jest } from "@storybook/jest";
6
- import { Meta, StoryFn } from "@storybook/react";
7
- import { userEvent, within } from "@storybook/testing-library";
8
- import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
5
+ import { StoryFn } from "@storybook/react";
6
+ import * as test from "@storybook/test";
7
+ import { expect, userEvent, within } from "@storybook/test";
8
+ import { GridPopoverContext } from "contexts/GridPopoverContext";
9
9
  import { useRef } from "react";
10
10
 
11
11
  import "@linzjs/lui/dist/fonts";
12
12
 
13
13
  import {
14
14
  GridBaseRow,
15
- GridContextProvider,
15
+ GridContext,
16
16
  GridFormPopoverMenu,
17
17
  GridFormPopoverMenuProps,
18
18
  GridFormSubComponentTextArea,
@@ -25,20 +25,18 @@ export default {
25
25
  title: "GridForm / Interactions",
26
26
  component: GridFormPopoverMenu,
27
27
  args: {},
28
- } as Meta<typeof GridFormPopoverMenu>;
28
+ };
29
29
 
30
- const updateValue = jest
31
- .fn<void, [saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1]>()
32
- .mockImplementation(async (saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) => {
33
- await saveFn([]);
34
- });
30
+ const updateValue = test.fn((saveFn: (selectedRows: any[]) => Promise<boolean>, _tabDirection: 1 | 0 | -1) =>
31
+ saveFn([]),
32
+ );
35
33
 
36
- const enabledAction = jest
37
- .fn<Promise<void>, [{ selectedRows: GridBaseRow[]; menuOption: SelectedMenuOptionResult<GridBaseRow> }]>()
34
+ const enabledAction = test
35
+ .fn<[{ selectedRows: GridBaseRow[]; menuOption: SelectedMenuOptionResult<GridBaseRow> }], Promise<void>>()
38
36
  .mockResolvedValue(undefined);
39
37
 
40
- const disabledAction = jest
41
- .fn<Promise<void>, [{ selectedRows: GridBaseRow[]; menuOption: SelectedMenuOptionResult<GridBaseRow> }]>()
38
+ const disabledAction = test
39
+ .fn<[{ selectedRows: GridBaseRow[]; menuOption: SelectedMenuOptionResult<GridBaseRow> }], Promise<void>>()
42
40
  .mockResolvedValue(undefined);
43
41
 
44
42
  const Template: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMenuProps<any>) => {
@@ -46,16 +44,27 @@ const Template: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMen
46
44
 
47
45
  return (
48
46
  <div className={"react-menu-inline-test"}>
49
- <GridContextProvider>
47
+ <GridContext.Provider
48
+ value={
49
+ {
50
+ stopEditing: () => {},
51
+ cancelEdit: () => {},
52
+ } as any
53
+ }
54
+ >
50
55
  <h6 ref={anchorRef}>Interaction Test</h6>
51
56
  <GridPopoverContext.Provider
52
- value={
53
- {
54
- anchorRef,
55
- value: null,
56
- updateValue,
57
- } as any as GridPopoverContextType<any>
58
- }
57
+ value={{
58
+ anchorRef,
59
+ value: null,
60
+ updateValue,
61
+ data: { value: "" },
62
+ field: "value",
63
+ selectedRows: [],
64
+ saving: false,
65
+ setSaving: () => {},
66
+ formatValue: (value) => value,
67
+ }}
59
68
  >
60
69
  <GridFormPopoverMenu
61
70
  {...props}
@@ -81,12 +90,12 @@ const Template: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMen
81
90
  ]}
82
91
  />
83
92
  </GridPopoverContext.Provider>
84
- </GridContextProvider>
93
+ </GridContext.Provider>
85
94
  </div>
86
95
  );
87
96
  };
88
97
 
89
- export const GridFormPopoverMenuInteractions_ = Template.bind({});
98
+ export const GridFormPopoverMenuInteractions_: typeof Template = Template.bind({});
90
99
  GridFormPopoverMenuInteractions_.play = async ({ canvasElement }) => {
91
100
  const canvas = within(canvasElement);
92
101
 
@@ -2,48 +2,58 @@ import "../../../react-menu3/styles/index.scss";
2
2
  import "../../../styles/index.scss";
3
3
  import "@linzjs/lui/dist/scss/base.scss";
4
4
 
5
- import { expect, jest } from "@storybook/jest";
6
- import { Meta, StoryFn } from "@storybook/react";
7
- import { userEvent, within } from "@storybook/testing-library";
8
- import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
5
+ import { StoryFn } from "@storybook/react";
6
+ import { expect, fn, userEvent, within } from "@storybook/test";
7
+ import { GridPopoverContext } from "contexts/GridPopoverContext";
9
8
  import { useRef } from "react";
10
9
 
11
10
  import "@linzjs/lui/dist/fonts";
12
11
 
13
- import { GridContextProvider, GridFormTextArea, GridFormTextAreaProps } from "../../..";
12
+ import { GridContext, GridFormTextArea, GridFormTextAreaProps } from "../../..";
14
13
 
15
14
  export default {
16
15
  title: "GridForm / Interactions",
17
16
  component: GridFormTextArea,
18
17
  args: {},
19
- } as Meta<typeof GridFormTextArea>;
18
+ };
20
19
 
21
- const updateValue = jest.fn();
20
+ const updateValue = fn();
22
21
 
23
22
  const Template: StoryFn<typeof GridFormTextArea> = (props: GridFormTextAreaProps<any>) => {
24
23
  const anchorRef = useRef<HTMLHeadingElement>(null);
25
24
 
26
25
  return (
27
26
  <div className={"react-menu-inline-test"}>
28
- <GridContextProvider>
27
+ <GridContext.Provider
28
+ value={
29
+ {
30
+ stopEditing: () => {},
31
+ cancelEdit: () => {},
32
+ } as any
33
+ }
34
+ >
29
35
  <h6 ref={anchorRef}>Interaction Test</h6>
30
36
  <GridPopoverContext.Provider
31
- value={
32
- {
33
- anchorRef,
34
- value: null,
35
- updateValue,
36
- } as any as GridPopoverContextType<any>
37
- }
37
+ value={{
38
+ anchorRef,
39
+ value: null,
40
+ updateValue,
41
+ data: { value: null },
42
+ field: "value",
43
+ selectedRows: [],
44
+ saving: false,
45
+ setSaving: () => {},
46
+ formatValue: (value) => value,
47
+ }}
38
48
  >
39
49
  <GridFormTextArea {...props} required={true} />
40
50
  </GridPopoverContext.Provider>
41
- </GridContextProvider>
51
+ </GridContext.Provider>
42
52
  </div>
43
53
  );
44
54
  };
45
55
 
46
- export const GridFormTextAreaInteractions_ = Template.bind({});
56
+ export const GridFormTextAreaInteractions_: typeof Template = Template.bind({});
47
57
  GridFormTextAreaInteractions_.play = async ({ canvasElement }) => {
48
58
  const canvas = within(canvasElement);
49
59
 
@@ -2,48 +2,58 @@ import "../../../react-menu3/styles/index.scss";
2
2
  import "../../../styles/index.scss";
3
3
  import "@linzjs/lui/dist/scss/base.scss";
4
4
 
5
- import { expect, jest } from "@storybook/jest";
6
- import { Meta, StoryFn } from "@storybook/react";
7
- import { userEvent, within } from "@storybook/testing-library";
8
- import { GridPopoverContext, GridPopoverContextType } from "contexts/GridPopoverContext";
5
+ import { StoryFn } from "@storybook/react";
6
+ import { expect, fn, userEvent, within } from "@storybook/test";
7
+ import { GridPopoverContext } from "contexts/GridPopoverContext";
9
8
  import { useRef } from "react";
10
9
 
11
10
  import "@linzjs/lui/dist/fonts";
12
11
 
13
- import { GridContextProvider, GridFormTextInput, GridFormTextInputProps } from "../../..";
12
+ import { GridContext, GridFormTextInput, GridFormTextInputProps } from "../../..";
14
13
 
15
14
  export default {
16
15
  title: "GridForm / Interactions",
17
16
  component: GridFormTextInput,
18
17
  args: {},
19
- } as Meta<typeof GridFormTextInput>;
18
+ };
20
19
 
21
- const updateValue = jest.fn();
20
+ const updateValue = fn();
22
21
 
23
22
  const Template: StoryFn<typeof GridFormTextInput> = (props: GridFormTextInputProps<any>) => {
24
23
  const anchorRef = useRef<HTMLHeadingElement>(null);
25
24
 
26
25
  return (
27
26
  <div className={"react-menu-inline-test"}>
28
- <GridContextProvider>
27
+ <GridContext.Provider
28
+ value={
29
+ {
30
+ stopEditing: () => {},
31
+ cancelEdit: () => {},
32
+ } as any
33
+ }
34
+ >
29
35
  <h6 ref={anchorRef}>Interaction Test</h6>
30
36
  <GridPopoverContext.Provider
31
- value={
32
- {
33
- anchorRef,
34
- value: null,
35
- updateValue,
36
- } as any as GridPopoverContextType<any>
37
- }
37
+ value={{
38
+ anchorRef,
39
+ value: null,
40
+ updateValue,
41
+ data: { value: null },
42
+ field: "value",
43
+ selectedRows: [],
44
+ saving: false,
45
+ setSaving: () => {},
46
+ formatValue: (value) => value,
47
+ }}
38
48
  >
39
49
  <GridFormTextInput {...props} required={true} />
40
50
  </GridPopoverContext.Provider>
41
- </GridContextProvider>
51
+ </GridContext.Provider>
42
52
  </div>
43
53
  );
44
54
  };
45
55
 
46
- export const GridFormTextInputInteractions_ = Template.bind({});
56
+ export const GridFormTextInputInteractions_: typeof Template = Template.bind({});
47
57
  GridFormTextInputInteractions_.play = async ({ canvasElement }) => {
48
58
  const canvas = within(canvasElement);
49
59
 
@@ -2,9 +2,10 @@ import "../../../styles/GridTheme.scss";
2
2
  import "../../../styles/index.scss";
3
3
  import "@linzjs/lui/dist/scss/base.scss";
4
4
 
5
- import { expect, jest } from "@storybook/jest";
6
5
  import { Meta, StoryFn } from "@storybook/react";
7
- import { userEvent, waitFor } from "@storybook/testing-library";
6
+ import { expect } from "@storybook/test";
7
+ import * as test from "@storybook/test";
8
+ import { userEvent, waitFor } from "@storybook/test";
8
9
  import { useMemo, useState } from "react";
9
10
 
10
11
  import "@linzjs/lui/dist/fonts";
@@ -65,11 +66,11 @@ interface ITestRow {
65
66
  dd: string;
66
67
  }
67
68
 
68
- const multiEditAction = jest.fn().mockImplementation(async () => {
69
+ const multiEditAction = test.fn().mockImplementation(async () => {
69
70
  await wait(500);
70
71
  });
71
72
 
72
- const eAction = jest.fn<boolean, []>().mockReturnValue(true);
73
+ const eAction = test.fn<[], boolean>().mockReturnValue(true);
73
74
 
74
75
  const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps) => {
75
76
  const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
@@ -221,7 +222,7 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
221
222
  );
222
223
  };
223
224
 
224
- export const GridKeyboardInteractions = GridKeyboardInteractionsTemplate.bind({});
225
+ export const GridKeyboardInteractions: StoryFn<typeof Grid> = GridKeyboardInteractionsTemplate.bind({});
225
226
  GridKeyboardInteractions.play = async ({ canvasElement }) => {
226
227
  multiEditAction.mockReset();
227
228
  eAction.mockReset();
@@ -1,8 +1,9 @@
1
1
  import "../../react-menu3/styles/index.scss";
2
2
 
3
- import { expect, jest } from "@storybook/jest";
4
3
  import { Meta, StoryFn } from "@storybook/react";
5
- import { userEvent, within } from "@storybook/testing-library";
4
+ import { expect } from "@storybook/test";
5
+ import * as test from "@storybook/test";
6
+ import { userEvent, within } from "@storybook/test";
6
7
 
7
8
  import { Grid } from "../../components/Grid";
8
9
  import { Menu, MenuButton, MenuDivider, MenuItem, SubMenu } from "../../react-menu3";
@@ -17,8 +18,8 @@ export default {
17
18
  },
18
19
  } as Meta<typeof Grid>;
19
20
 
20
- const menuItemClickAction = jest.fn();
21
- const newFileAction = jest.fn();
21
+ const menuItemClickAction = test.fn();
22
+ const newFileAction = test.fn();
22
23
 
23
24
  const ReactMenuTemplate: StoryFn<typeof Grid> = () => {
24
25
  return (
@@ -1,5 +1,4 @@
1
- import { expect } from "@storybook/jest";
2
- import { waitFor } from "@storybook/testing-library";
1
+ import { expect, waitFor } from "@storybook/test";
3
2
 
4
3
  export const waitForGridReady = ({ canvasElement }: { canvasElement: HTMLElement }) =>
5
4
  waitFor(() => expect(canvasElement.querySelector(".Grid-ready")).toBeInTheDocument(), { timeout: 5000 });
@@ -28,19 +28,19 @@ export const findRow = async (rowId: number | string, within?: HTMLElement): Pro
28
28
  { tagName: `.ag-center-cols-container div[row-id='${rowId}']:not(:empty)` },
29
29
  within,
30
30
  );
31
- let combineChildren = [...row.children];
31
+ let combineChildren = Array.from(row.children);
32
32
 
33
33
  const leftCols = queryQuick<HTMLDivElement>(
34
34
  { tagName: `.ag-pinned-left-cols-container div[row-id='${rowId}']` },
35
35
  within,
36
36
  );
37
- if (leftCols) combineChildren = [...leftCols.children, ...combineChildren];
37
+ if (leftCols) combineChildren = [...Array.from(row.children), ...combineChildren];
38
38
 
39
39
  const rightCols = queryQuick<HTMLDivElement>(
40
40
  { tagName: `.ag-pinned-right-cols-container div[row-id='${rowId}']` },
41
41
  within,
42
42
  );
43
- if (rightCols) combineChildren = [...rightCols.children, ...combineChildren];
43
+ if (rightCols) combineChildren = [...Array.from(row.children), ...combineChildren];
44
44
 
45
45
  row.replaceChildren(...combineChildren);
46
46
  });