@linzjs/step-ag-grid 7.2.0 → 7.3.1

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "7.2.0",
5
+ "version": "7.3.1",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -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
- {item.subComponent ? "..." : ""}
303
+ {(item.label ?? (item.value == null ? `<${item.value}>` : `${item.value}`)) +
304
+ (item.subComponent ? "..." : "")}
305
305
  </MenuItem>
306
306
 
307
307
  {item.subComponent && selectedSubComponent === item && (
@@ -328,7 +328,9 @@ export const GridFormDropDown = <RowType extends GridBaseRow>(props: GridFormPop
328
328
  }}
329
329
  >
330
330
  {item.subComponent && (
331
- <item.subComponent key={`${fieldToString(field)}-${index}_subcomponent_inner`} />
331
+ <div className={"subComponent"}>
332
+ <item.subComponent key={`${fieldToString(field)}-${index}_subcomponent_inner`} />
333
+ </div>
332
334
  )}
333
335
  </GridSubComponentContext.Provider>
334
336
  )}
@@ -414,7 +414,9 @@ const MenuSubComponent = (props: {
414
414
  triggerSave,
415
415
  }}
416
416
  >
417
- <item.subComponent />
417
+ <div className={"subComponent"}>
418
+ <item.subComponent />
419
+ </div>
418
420
  </GridSubComponentContext.Provider>
419
421
  )
420
422
  }
@@ -149,7 +149,9 @@ export const GridFormPopoverMenu = <RowType extends GridBaseRow>(props: GridForm
149
149
  triggerSave,
150
150
  }}
151
151
  >
152
- <item.subComponent />
152
+ <div className={"subComponent"}>
153
+ <item.subComponent />
154
+ </div>
153
155
  </GridSubComponentContext.Provider>
154
156
  )
155
157
  }
@@ -35,7 +35,7 @@ export const GridFormSubComponentTextArea = <RowType extends GridBaseRow>(
35
35
  }, [setValid, invalid, value]);
36
36
 
37
37
  return (
38
- <div className={clsx("FreeTextInput LuiDeprecatedForms", props.className)}>
38
+ <div className={clsx("FreeTextInput", props.className)}>
39
39
  <TextAreaInput
40
40
  className={"free-text-input"}
41
41
  value={value}
@@ -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}
@@ -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
- textEquals?: string;
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
- const textMatch = lastIQueryQuick.textEquals?.toLowerCase();
61
- if (textMatch != null) {
62
- els = els.filter((el) => el.innerHTML.toLowerCase() === textMatch || el.innerText.toLowerCase() === textMatch);
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
  };
@@ -1,6 +1,7 @@
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
+ import { wait } from "./util";
4
5
 
5
6
  export const findRow = async (rowId: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
6
7
  return findQuick<HTMLDivElement>({ tagName: `div[row-id='${rowId}']:not(:empty)` }, within);
@@ -35,6 +36,18 @@ export const findCell = async (rowId: number | string, colId: string, within?: H
35
36
  return await findQuick({ tagName: `[col-id='${colId}']` }, row);
36
37
  };
37
38
 
39
+ export const cellContains = async (
40
+ rowId: number | string,
41
+ colId: string,
42
+ text: string | RegExp,
43
+ within?: HTMLElement,
44
+ ) => {
45
+ return await waitFor(async () => {
46
+ const row = await findRow(rowId, within);
47
+ return await findQuick({ tagName: `[col-id='${colId}']`, text }, row);
48
+ });
49
+ };
50
+
38
51
  export const selectCell = async (rowId: string | number, colId: string, within?: HTMLElement): Promise<void> => {
39
52
  await act(async () => {
40
53
  const cell = await findCell(rowId, colId, within);
@@ -46,30 +59,34 @@ export const editCell = async (rowId: number | string, colId: string, within?: H
46
59
  await act(async () => {
47
60
  const cell = await findCell(rowId, colId, within);
48
61
  userEvent.dblClick(cell);
49
- await findOpenMenu();
50
62
  });
63
+ await findOpenMenu();
51
64
  };
52
65
 
53
66
  const findOpenMenu = async (): Promise<HTMLElement> => findQuick({ classes: ".szh-menu--state-open" });
54
67
 
55
- export const queryMenuOption = async (menuOptionText: string): Promise<HTMLElement | null> => {
68
+ export const queryMenuOption = async (menuOptionText: string | RegExp): Promise<HTMLElement | null> => {
56
69
  const openMenu = await findOpenMenu();
57
70
  const els = await within(openMenu).findAllByRole("menuitem");
58
- const result = els.find(
59
- (e: HTMLElement) => e.innerHTML?.trim() === menuOptionText || e.innerText?.trim() === menuOptionText,
60
- );
71
+ const matcher = getMatcher(menuOptionText);
72
+ const result = els.find(matcher);
61
73
  return result ?? null;
62
74
  };
63
75
 
64
- export const findMenuOption = async (menuOptionText: string): Promise<HTMLElement> => {
65
- const menuOption = await queryMenuOption(menuOptionText);
66
- if (menuOption == null) {
67
- throw Error(`Unable to find menu option ${menuOptionText}`);
68
- }
69
- return menuOption;
76
+ export const findMenuOption = async (menuOptionText: string | RegExp): Promise<HTMLElement> => {
77
+ return await waitFor(
78
+ async () => {
79
+ const menuOption = await queryMenuOption(menuOptionText);
80
+ if (menuOption == null) {
81
+ throw Error(`Unable to find menu option ${menuOptionText}`);
82
+ }
83
+ return menuOption;
84
+ },
85
+ { timeout: 10000 },
86
+ );
70
87
  };
71
88
 
72
- export const clickMenuOption = async (menuOptionText: string): Promise<void> => {
89
+ export const clickMenuOption = async (menuOptionText: string | RegExp): Promise<void> => {
73
90
  await act(async () => {
74
91
  const menuOption = await findMenuOption(menuOptionText);
75
92
  menuOption && userEvent.click(menuOption);
@@ -79,10 +96,11 @@ export const clickMenuOption = async (menuOptionText: string): Promise<void> =>
79
96
  export const openAndClickMenuOption = async (
80
97
  rowId: number | string,
81
98
  colId: string,
82
- menuOptionText: string,
99
+ menuOptionText: string | RegExp,
83
100
  within?: HTMLElement,
84
101
  ): Promise<void> => {
85
102
  await editCell(rowId, colId, within);
103
+ await wait(100);
86
104
  await clickMenuOption(menuOptionText);
87
105
  };
88
106
 
@@ -110,13 +128,13 @@ export const clickMultiSelectOption = async (value: string): Promise<void> => {
110
128
 
111
129
  export const typeOtherInput = async (value: string): Promise<void> => {
112
130
  const openMenu = await findOpenMenu();
113
- const otherInput = await findQuick({ tagName: "input[type='text']" }, openMenu);
131
+ const otherInput = await findQuick({ classes: ".subComponent", child: { tagName: "input[type='text']" } }, openMenu);
114
132
  userEvent.type(otherInput, value);
115
133
  };
116
134
 
117
135
  export const typeOtherTextArea = async (value: string): Promise<void> => {
118
136
  const openMenu = await findOpenMenu();
119
- const otherTextArea = await findQuick({ tagName: "textarea" }, openMenu);
137
+ const otherTextArea = await findQuick({ classes: ".subComponent", child: { tagName: "textarea" } }, openMenu);
120
138
  userEvent.type(otherTextArea, value);
121
139
  };
122
140
 
@@ -125,7 +143,7 @@ export const closeMenu = (): void => {
125
143
  };
126
144
 
127
145
  export const findActionButton = (text: string, container: HTMLElement): Promise<HTMLElement> =>
128
- findQuick({ tagName: "button", child: { classes: ".ActionButton-minimalAreaDisplay", textEquals: text } }, container);
146
+ findQuick({ tagName: "button", child: { classes: ".ActionButton-minimalAreaDisplay", text: text } }, container);
129
147
 
130
148
  export const clickActionButton = async (text: string, container: HTMLElement): Promise<void> => {
131
149
  await act(async () => {