@linzjs/step-ag-grid 29.1.2 → 29.1.4

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 (29) hide show
  1. package/dist/src/components/Grid.d.ts +1 -1
  2. package/dist/src/components/GridPopoverHook.d.ts +2 -0
  3. package/dist/src/contexts/GridContext.d.ts +2 -2
  4. package/dist/src/utils/waitForCondition.d.ts +1 -1
  5. package/dist/step-ag-grid.cjs +147 -114
  6. package/dist/step-ag-grid.cjs.map +1 -1
  7. package/dist/step-ag-grid.esm.js +147 -115
  8. package/dist/step-ag-grid.esm.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/components/Grid.tsx +1 -1
  11. package/src/components/GridCell.tsx +34 -14
  12. package/src/components/GridPopoverHook.tsx +10 -15
  13. package/src/components/gridForm/GridFormDropDown.tsx +73 -49
  14. package/src/components/gridForm/GridFormMultiSelect.tsx +12 -4
  15. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +1 -0
  16. package/src/contexts/GridContext.tsx +2 -2
  17. package/src/contexts/GridContextProvider.tsx +31 -23
  18. package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +1 -1
  19. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +1 -1
  20. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +1 -1
  21. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +1 -1
  22. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +2 -1
  23. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +1 -1
  24. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +2 -1
  25. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +2 -2
  26. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +1 -1
  27. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +1 -1
  28. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +56 -13
  29. package/src/utils/waitForCondition.tsx +6 -2
@@ -5,7 +5,7 @@ import '@linzjs/lui/dist/fonts';
5
5
 
6
6
  import { Meta, StoryFn } from '@storybook/react-vite';
7
7
  import { useMemo, useState } from 'react';
8
- import { expect } from 'storybook/test';
8
+ import { expect, within } from 'storybook/test';
9
9
  import { fn } from 'storybook/test';
10
10
  import { userEvent, waitFor } from 'storybook/test';
11
11
 
@@ -19,6 +19,7 @@ import {
19
19
  GridIcon,
20
20
  GridPopoverMenu,
21
21
  GridPopoverMessage,
22
+ GridPopoverTextArea,
22
23
  GridProps,
23
24
  GridUpdatingContextProvider,
24
25
  MenuOption,
@@ -75,6 +76,10 @@ const eAction = fn(() => {
75
76
  return true;
76
77
  });
77
78
 
79
+ const bulkEditingCallback = fn(() => {
80
+ console.log('bulkEditingCallback');
81
+ });
82
+
78
83
  const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITestRow>) => {
79
84
  const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
80
85
  const columnDefs: ColDefT<ITestRow>[] = useMemo(
@@ -95,12 +100,16 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid<ITestRow>> = (props:
95
100
  field: 'age',
96
101
  headerName: 'Age',
97
102
  }),
98
- GridCell({
99
- field: 'desc',
100
- headerName: 'Description',
101
- }),
103
+ GridPopoverTextArea(
104
+ {
105
+ field: 'desc',
106
+ headerName: 'Description',
107
+ },
108
+ {},
109
+ ),
102
110
  GridPopoverMessage(
103
111
  {
112
+ colId: 'popout_message',
104
113
  headerName: 'Popout message',
105
114
  maxWidth: 150,
106
115
  cellRenderer: () => <>Single Click me!</>,
@@ -116,6 +125,7 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid<ITestRow>> = (props:
116
125
  },
117
126
  ),
118
127
  GridCell({
128
+ colId: 'custom_edit',
119
129
  headerName: 'Custom edit',
120
130
  maxWidth: 100,
121
131
  editable: true,
@@ -219,15 +229,18 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid<ITestRow>> = (props:
219
229
  rowData={rowData}
220
230
  domLayout={'autoHeight'}
221
231
  autoSelectFirstRow={true}
232
+ onBulkEditingComplete={bulkEditingCallback}
222
233
  />
223
234
  );
224
235
  };
225
236
 
226
237
  export const GridKeyboardInteractions: StoryFn<typeof Grid<ITestRow>> = GridKeyboardInteractionsTemplate.bind({});
227
238
  GridKeyboardInteractions.play = async ({ canvasElement }) => {
239
+ const canvas = within(document.body);
240
+
228
241
  multiEditAction.mockClear();
229
242
  eAction.mockClear();
230
-
243
+ bulkEditingCallback.mockClear();
231
244
  await waitForGridReady({ canvasElement });
232
245
 
233
246
  // Ensure first row/cell is selected on render
@@ -237,7 +250,9 @@ GridKeyboardInteractions.play = async ({ canvasElement }) => {
237
250
  expect(activeCell).toHaveAttribute('aria-colindex', '1');
238
251
  expect(activeCell?.parentElement).toHaveAttribute('row-index', '0');
239
252
  });
253
+ console.log('arrow down to 3rd row');
240
254
  await userEvent.keyboard('{arrowdown}{arrowdown}');
255
+ console.log('arrow right to first popup menu');
241
256
  await userEvent.keyboard('{arrowright}{arrowright}{arrowright}{arrowright}{arrowright}{arrowright}{arrowright}');
242
257
 
243
258
  // Test enter post focus
@@ -246,9 +261,6 @@ GridKeyboardInteractions.play = async ({ canvasElement }) => {
246
261
  await wait(1000);
247
262
  await userEvent.keyboard('{arrowdown}{arrowdown}');
248
263
  fn();
249
- await waitFor(() => {
250
- expect(multiEditAction).toHaveBeenCalled();
251
- });
252
264
 
253
265
  await waitFor(() => {
254
266
  const activeCell = canvasElement.ownerDocument.activeElement;
@@ -259,19 +271,50 @@ GridKeyboardInteractions.play = async ({ canvasElement }) => {
259
271
  await wait(200);
260
272
  };
261
273
 
274
+ console.log('At 2nd to last cell open the popup menu and select 2nd option');
262
275
  await test(() => userEvent.keyboard('{Enter}'), '8', '2');
276
+ expect(multiEditAction).toHaveBeenCalled();
277
+
278
+ console.log('Open 2nd to last popup menu, tab to next disabled popup');
263
279
  await test(() => userEvent.tab(), '9', '2');
280
+ expect(bulkEditingCallback).toHaveBeenCalled();
281
+ bulkEditingCallback.mockClear();
282
+
283
+ console.log('Fail to edit last popup menu, tab back to 2nd to last popup menu');
264
284
  await userEvent.tab({ shift: true });
265
- await test(() => userEvent.tab({ shift: true }), '6', '2');
285
+ console.log('Open 2nd to last popup menu, tab to desc cell');
286
+ await test(() => userEvent.tab({ shift: true }), '5', '2');
287
+ console.log('Cancel edit');
288
+ await wait(500);
266
289
  await userEvent.keyboard('{Esc}');
290
+ expect(bulkEditingCallback).toHaveBeenCalled();
291
+ bulkEditingCallback.mockClear();
292
+ await wait(500);
293
+
294
+ console.log('Open desc cell');
295
+ await userEvent.keyboard('{Enter}');
296
+ const textInput = await canvas.findByRole('textbox');
297
+ expect(textInput).toBeInTheDocument();
298
+ await userEvent.clear(textInput);
299
+ await userEvent.type(textInput, 'foo');
300
+
267
301
  await userEvent.tab();
302
+ await userEvent.keyboard('{arrowleft}{arrowleft}{arrowleft}');
268
303
 
269
304
  await userEvent.keyboard('{Enter}');
270
- await wait(250);
271
- expect(eAction).not.toHaveBeenCalled();
305
+ await waitFor(
306
+ async () => {
307
+ await canvas.findByText(/There are 1 row/);
308
+ },
309
+ { timeout: 5000 },
310
+ );
311
+ await userEvent.keyboard('{Esc}');
312
+ await userEvent.tab();
272
313
 
314
+ expect(eAction).not.toHaveBeenCalled();
315
+ /*await userEvent.keyboard('{Enter}');
273
316
  await userEvent.keyboard('e');
274
317
  await waitFor(() => {
275
318
  expect(eAction).toHaveBeenCalled();
276
- });
319
+ });*/
277
320
  };
@@ -1,6 +1,10 @@
1
1
  import { wait } from '../utils/util';
2
2
 
3
- export const waitForCondition = async (condition: () => boolean, timeoutMs: number): Promise<boolean> => {
3
+ export const waitForCondition = async (
4
+ error: string,
5
+ condition: () => boolean,
6
+ timeoutMs: number,
7
+ ): Promise<boolean> => {
4
8
  const endTime = Date.now() + timeoutMs;
5
9
  while (Date.now() < endTime) {
6
10
  if (condition()) {
@@ -8,6 +12,6 @@ export const waitForCondition = async (condition: () => boolean, timeoutMs: numb
8
12
  }
9
13
  await wait(100);
10
14
  }
11
- console.warn('waitForCondition failed');
15
+ console.warn(error);
12
16
  return false;
13
17
  };