@linzjs/step-ag-grid 7.2.0 → 7.3.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/index.js +52 -25
- package/dist/index.js.map +1 -1
- package/dist/src/utils/testQuick.d.ts +2 -2
- package/dist/src/utils/testUtil.d.ts +5 -4
- package/dist/step-ag-grid.esm.js +52 -26
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/gridForm/GridFormDropDown.tsx +2 -2
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +1 -28
- package/src/utils/testQuick.ts +15 -14
- package/src/utils/testUtil.ts +28 -15
package/package.json
CHANGED
|
@@ -300,8 +300,8 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormPop
|
|
|
300
300
|
}
|
|
301
301
|
}}
|
|
302
302
|
>
|
|
303
|
-
{item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)
|
|
304
|
-
|
|
303
|
+
{(item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)) +
|
|
304
|
+
(item.subComponent ? "..." : "")}
|
|
305
305
|
</MenuItem>
|
|
306
306
|
|
|
307
307
|
{item.subComponent && selectedSubComponent === item && (
|
|
@@ -56,11 +56,6 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
|
|
|
56
56
|
appB: "B",
|
|
57
57
|
other: "Other",
|
|
58
58
|
};
|
|
59
|
-
const positionTwoMap: Record<string, string> = {
|
|
60
|
-
"1": "One",
|
|
61
|
-
"2": "Two",
|
|
62
|
-
"3": "Three",
|
|
63
|
-
};
|
|
64
59
|
return [
|
|
65
60
|
GridCell({
|
|
66
61
|
field: "id",
|
|
@@ -177,29 +172,6 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
|
|
|
177
172
|
},
|
|
178
173
|
},
|
|
179
174
|
),
|
|
180
|
-
GridPopoutEditMultiSelect(
|
|
181
|
-
{
|
|
182
|
-
field: "position2",
|
|
183
|
-
initialWidth: 65,
|
|
184
|
-
maxWidth: 150,
|
|
185
|
-
headerName: "Initial editor values ",
|
|
186
|
-
valueGetter: (props) => positionTwoMap[props.data.position2],
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
multiEdit: false,
|
|
190
|
-
editorParams: {
|
|
191
|
-
filtered: true,
|
|
192
|
-
filterPlaceholder: "Filter position",
|
|
193
|
-
options: Object.entries(positionTwoMap).map(([k, v]) => ({ value: k, label: v })),
|
|
194
|
-
onSave: async (selectedRows, selectedOptions) => {
|
|
195
|
-
// eslint-disable-next-line no-console
|
|
196
|
-
console.log("multiSelect result", { selectedRows, selectedOptions });
|
|
197
|
-
await wait(1000);
|
|
198
|
-
return true;
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
),
|
|
203
175
|
];
|
|
204
176
|
}, []);
|
|
205
177
|
|
|
@@ -211,6 +183,7 @@ const GridEditMultiSelectTemplate: ComponentStory<typeof Grid> = (props: GridPro
|
|
|
211
183
|
return (
|
|
212
184
|
<Grid
|
|
213
185
|
{...props}
|
|
186
|
+
animateRows={true}
|
|
214
187
|
externalSelectedItems={externalSelectedItems}
|
|
215
188
|
setExternalSelectedItems={setExternalSelectedItems}
|
|
216
189
|
columnDefs={columnDefs}
|
package/src/utils/testQuick.ts
CHANGED
|
@@ -17,8 +17,7 @@ const queryAllBySelector = <T extends HTMLElement>(selector: string, container:
|
|
|
17
17
|
export interface IQueryQuick {
|
|
18
18
|
testId?: string;
|
|
19
19
|
tagName?: "button" | "span" | "div" | "input" | "textarea" | any;
|
|
20
|
-
|
|
21
|
-
textContains?: string;
|
|
20
|
+
text?: string | RegExp;
|
|
22
21
|
icon?: IconName;
|
|
23
22
|
ariaLabel?: string;
|
|
24
23
|
role?: string;
|
|
@@ -28,6 +27,14 @@ export interface IQueryQuick {
|
|
|
28
27
|
|
|
29
28
|
const escapeSelectorParam = (param: string): string => param.replace(/["\\]/g, "\\$&");
|
|
30
29
|
|
|
30
|
+
export const getMatcher = (matcherText: string | RegExp) => {
|
|
31
|
+
const textMatcher =
|
|
32
|
+
typeof matcherText === "string"
|
|
33
|
+
? (text?: string) => text != null && text.toLowerCase() === matcherText.toLowerCase()
|
|
34
|
+
: (text?: string) => text != null && matcherText.test(text);
|
|
35
|
+
return (e: HTMLElement) => textMatcher(e.innerHTML?.trim()) || textMatcher(e.innerText?.trim());
|
|
36
|
+
};
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Build selector for quick operations.
|
|
33
40
|
*
|
|
@@ -57,17 +64,9 @@ const quickSelector = <T extends HTMLElement>(
|
|
|
57
64
|
|
|
58
65
|
let els = queryAllBySelector<T>(selector, container);
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
els = els.filter(
|
|
63
|
-
}
|
|
64
|
-
const textContains = lastIQueryQuick.textContains?.toLowerCase();
|
|
65
|
-
if (textContains != null) {
|
|
66
|
-
els = els.filter(
|
|
67
|
-
(el) =>
|
|
68
|
-
el.innerHTML.toLowerCase().indexOf(textContains) != -1 ||
|
|
69
|
-
el.innerText.toLowerCase().indexOf(textContains) != -1,
|
|
70
|
-
);
|
|
67
|
+
if (lastIQueryQuick.text != null) {
|
|
68
|
+
const matcher = getMatcher(lastIQueryQuick.text);
|
|
69
|
+
els = els.filter(matcher);
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
return { selector, els };
|
|
@@ -83,7 +82,9 @@ const quickSelector = <T extends HTMLElement>(
|
|
|
83
82
|
export const queryQuick = <T extends HTMLElement>(filter: IQueryQuick, container?: HTMLElement): T | null => {
|
|
84
83
|
const { els, selector } = quickSelector<T>(filter, container);
|
|
85
84
|
if (els.length > 1) {
|
|
86
|
-
throw `Found multiple(${els.length}) elements by selector ${selector}
|
|
85
|
+
throw `Found multiple(${els.length}) elements by selector ${selector}\n${els.map(
|
|
86
|
+
(el, index) => `${index}: ${el.parentElement?.innerHTML}\n\n`,
|
|
87
|
+
)}`;
|
|
87
88
|
}
|
|
88
89
|
return els[0] ?? null;
|
|
89
90
|
};
|
package/src/utils/testUtil.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { act, within } from "@testing-library/react";
|
|
1
|
+
import { act, waitFor, within } from "@testing-library/react";
|
|
2
2
|
import userEvent from "@testing-library/user-event";
|
|
3
|
-
import { findQuick, getAllQuick, getQuick, queryQuick } from "./testQuick";
|
|
3
|
+
import { findQuick, getAllQuick, getMatcher, getQuick, queryQuick } from "./testQuick";
|
|
4
4
|
|
|
5
5
|
export const findRow = async (rowId: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
|
|
6
6
|
return findQuick<HTMLDivElement>({ tagName: `div[row-id='${rowId}']:not(:empty)` }, within);
|
|
@@ -35,6 +35,18 @@ export const findCell = async (rowId: number | string, colId: string, within?: H
|
|
|
35
35
|
return await findQuick({ tagName: `[col-id='${colId}']` }, row);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
export const cellContains = async (
|
|
39
|
+
rowId: number | string,
|
|
40
|
+
colId: string,
|
|
41
|
+
text: string | RegExp,
|
|
42
|
+
within?: HTMLElement,
|
|
43
|
+
) => {
|
|
44
|
+
return await waitFor(async () => {
|
|
45
|
+
const row = await findRow(rowId, within);
|
|
46
|
+
return await findQuick({ tagName: `[col-id='${colId}']`, text }, row);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
38
50
|
export const selectCell = async (rowId: string | number, colId: string, within?: HTMLElement): Promise<void> => {
|
|
39
51
|
await act(async () => {
|
|
40
52
|
const cell = await findCell(rowId, colId, within);
|
|
@@ -52,24 +64,25 @@ export const editCell = async (rowId: number | string, colId: string, within?: H
|
|
|
52
64
|
|
|
53
65
|
const findOpenMenu = async (): Promise<HTMLElement> => findQuick({ classes: ".szh-menu--state-open" });
|
|
54
66
|
|
|
55
|
-
export const queryMenuOption = async (menuOptionText: string): Promise<HTMLElement | null> => {
|
|
67
|
+
export const queryMenuOption = async (menuOptionText: string | RegExp): Promise<HTMLElement | null> => {
|
|
56
68
|
const openMenu = await findOpenMenu();
|
|
57
69
|
const els = await within(openMenu).findAllByRole("menuitem");
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
);
|
|
70
|
+
const matcher = getMatcher(menuOptionText);
|
|
71
|
+
const result = els.find(matcher);
|
|
61
72
|
return result ?? null;
|
|
62
73
|
};
|
|
63
74
|
|
|
64
|
-
export const findMenuOption = async (menuOptionText: string): Promise<HTMLElement> => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
export const findMenuOption = async (menuOptionText: string | RegExp): Promise<HTMLElement> => {
|
|
76
|
+
return await waitFor(async () => {
|
|
77
|
+
const menuOption = await queryMenuOption(menuOptionText);
|
|
78
|
+
if (menuOption == null) {
|
|
79
|
+
throw Error(`Unable to find menu option ${menuOptionText}`);
|
|
80
|
+
}
|
|
81
|
+
return menuOption;
|
|
82
|
+
});
|
|
70
83
|
};
|
|
71
84
|
|
|
72
|
-
export const clickMenuOption = async (menuOptionText: string): Promise<void> => {
|
|
85
|
+
export const clickMenuOption = async (menuOptionText: string | RegExp): Promise<void> => {
|
|
73
86
|
await act(async () => {
|
|
74
87
|
const menuOption = await findMenuOption(menuOptionText);
|
|
75
88
|
menuOption && userEvent.click(menuOption);
|
|
@@ -79,7 +92,7 @@ export const clickMenuOption = async (menuOptionText: string): Promise<void> =>
|
|
|
79
92
|
export const openAndClickMenuOption = async (
|
|
80
93
|
rowId: number | string,
|
|
81
94
|
colId: string,
|
|
82
|
-
menuOptionText: string,
|
|
95
|
+
menuOptionText: string | RegExp,
|
|
83
96
|
within?: HTMLElement,
|
|
84
97
|
): Promise<void> => {
|
|
85
98
|
await editCell(rowId, colId, within);
|
|
@@ -125,7 +138,7 @@ export const closeMenu = (): void => {
|
|
|
125
138
|
};
|
|
126
139
|
|
|
127
140
|
export const findActionButton = (text: string, container: HTMLElement): Promise<HTMLElement> =>
|
|
128
|
-
findQuick({ tagName: "button", child: { classes: ".ActionButton-minimalAreaDisplay",
|
|
141
|
+
findQuick({ tagName: "button", child: { classes: ".ActionButton-minimalAreaDisplay", text: text } }, container);
|
|
129
142
|
|
|
130
143
|
export const clickActionButton = async (text: string, container: HTMLElement): Promise<void> => {
|
|
131
144
|
await act(async () => {
|