@react-aria/test-utils 1.0.0-beta.1 → 1.0.0-beta.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 (133) hide show
  1. package/dist/import.mjs +5 -5
  2. package/dist/main.js +9 -9
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +5 -5
  5. package/dist/module.js.map +1 -1
  6. package/dist/private/checkboxgroup.cjs +104 -0
  7. package/dist/private/checkboxgroup.cjs.map +1 -0
  8. package/dist/private/checkboxgroup.js +99 -0
  9. package/dist/private/checkboxgroup.js.map +1 -0
  10. package/dist/{combobox.main.js → private/combobox.cjs} +35 -35
  11. package/dist/private/combobox.cjs.map +1 -0
  12. package/dist/{combobox.mjs → private/combobox.js} +35 -35
  13. package/dist/private/combobox.js.map +1 -0
  14. package/dist/private/dialog.cjs +105 -0
  15. package/dist/private/dialog.cjs.map +1 -0
  16. package/dist/private/dialog.js +100 -0
  17. package/dist/private/dialog.js.map +1 -0
  18. package/dist/{events.main.js → private/events.cjs} +32 -34
  19. package/dist/private/events.cjs.map +1 -0
  20. package/dist/{events.mjs → private/events.js} +29 -31
  21. package/dist/private/events.js.map +1 -0
  22. package/dist/{gridlist.main.js → private/gridlist.cjs} +27 -28
  23. package/dist/private/gridlist.cjs.map +1 -0
  24. package/dist/{gridlist.mjs → private/gridlist.js} +27 -28
  25. package/dist/private/gridlist.js.map +1 -0
  26. package/dist/{listbox.main.js → private/listbox.cjs} +24 -24
  27. package/dist/private/listbox.cjs.map +1 -0
  28. package/dist/{listbox.mjs → private/listbox.js} +24 -24
  29. package/dist/private/listbox.js.map +1 -0
  30. package/dist/{menu.main.js → private/menu.cjs} +46 -48
  31. package/dist/private/menu.cjs.map +1 -0
  32. package/dist/{menu.mjs → private/menu.js} +46 -48
  33. package/dist/private/menu.js.map +1 -0
  34. package/dist/private/radiogroup.cjs +120 -0
  35. package/dist/private/radiogroup.cjs.map +1 -0
  36. package/dist/private/radiogroup.js +115 -0
  37. package/dist/private/radiogroup.js.map +1 -0
  38. package/dist/{select.main.js → private/select.cjs} +31 -29
  39. package/dist/private/select.cjs.map +1 -0
  40. package/dist/{select.mjs → private/select.js} +31 -29
  41. package/dist/private/select.js.map +1 -0
  42. package/dist/{table.main.js → private/table.cjs} +82 -57
  43. package/dist/private/table.cjs.map +1 -0
  44. package/dist/{table.module.js → private/table.js} +82 -57
  45. package/dist/private/table.js.map +1 -0
  46. package/dist/{tabs.main.js → private/tabs.cjs} +24 -26
  47. package/dist/private/tabs.cjs.map +1 -0
  48. package/dist/{tabs.mjs → private/tabs.js} +24 -26
  49. package/dist/private/tabs.js.map +1 -0
  50. package/dist/private/testSetup.cjs +87 -0
  51. package/dist/private/testSetup.cjs.map +1 -0
  52. package/dist/private/testSetup.js +81 -0
  53. package/dist/private/testSetup.js.map +1 -0
  54. package/dist/{tree.main.js → private/tree.cjs} +34 -35
  55. package/dist/private/tree.cjs.map +1 -0
  56. package/dist/{tree.mjs → private/tree.js} +34 -35
  57. package/dist/private/tree.js.map +1 -0
  58. package/dist/private/user.cjs +85 -0
  59. package/dist/private/user.cjs.map +1 -0
  60. package/dist/private/user.js +76 -0
  61. package/dist/private/user.js.map +1 -0
  62. package/dist/{userEventMaps.main.js → private/userEventMaps.cjs} +3 -3
  63. package/dist/{userEventMaps.main.js.map → private/userEventMaps.cjs.map} +1 -1
  64. package/dist/{userEventMaps.mjs → private/userEventMaps.js} +3 -3
  65. package/dist/{userEventMaps.module.js.map → private/userEventMaps.js.map} +1 -1
  66. package/dist/types/src/checkboxgroup.d.ts +45 -0
  67. package/dist/types/src/combobox.d.ts +75 -0
  68. package/dist/types/src/dialog.d.ts +36 -0
  69. package/dist/types/src/events.d.ts +25 -0
  70. package/dist/types/src/gridlist.d.ts +51 -0
  71. package/dist/types/src/index.d.ts +16 -0
  72. package/dist/types/src/listbox.d.ts +80 -0
  73. package/dist/types/src/menu.d.ts +102 -0
  74. package/dist/types/src/radiogroup.d.ts +46 -0
  75. package/dist/types/src/select.d.ts +67 -0
  76. package/dist/types/src/table.d.ts +104 -0
  77. package/dist/types/src/tabs.d.ts +58 -0
  78. package/dist/types/src/testSetup.d.ts +6 -0
  79. package/dist/types/src/tree.d.ts +57 -0
  80. package/dist/types/src/types.d.ts +136 -0
  81. package/dist/types/src/user.d.ts +47 -0
  82. package/dist/types/src/userEventMaps.d.ts +2 -0
  83. package/package.json +7 -7
  84. package/src/checkboxgroup.ts +158 -0
  85. package/src/dialog.ts +143 -0
  86. package/src/index.ts +11 -0
  87. package/src/radiogroup.ts +176 -0
  88. package/src/select.ts +10 -2
  89. package/src/table.ts +46 -1
  90. package/src/tabs.ts +7 -2
  91. package/src/testSetup.ts +30 -28
  92. package/src/types.ts +21 -0
  93. package/src/user.ts +25 -7
  94. package/dist/combobox.main.js.map +0 -1
  95. package/dist/combobox.module.js +0 -167
  96. package/dist/combobox.module.js.map +0 -1
  97. package/dist/events.main.js.map +0 -1
  98. package/dist/events.module.js +0 -112
  99. package/dist/events.module.js.map +0 -1
  100. package/dist/gridlist.main.js.map +0 -1
  101. package/dist/gridlist.module.js +0 -149
  102. package/dist/gridlist.module.js.map +0 -1
  103. package/dist/listbox.main.js.map +0 -1
  104. package/dist/listbox.module.js +0 -138
  105. package/dist/listbox.module.js.map +0 -1
  106. package/dist/menu.main.js.map +0 -1
  107. package/dist/menu.module.js +0 -269
  108. package/dist/menu.module.js.map +0 -1
  109. package/dist/select.main.js.map +0 -1
  110. package/dist/select.module.js +0 -158
  111. package/dist/select.module.js.map +0 -1
  112. package/dist/table.main.js.map +0 -1
  113. package/dist/table.mjs +0 -290
  114. package/dist/table.module.js.map +0 -1
  115. package/dist/tabs.main.js.map +0 -1
  116. package/dist/tabs.module.js +0 -128
  117. package/dist/tabs.module.js.map +0 -1
  118. package/dist/testSetup.main.js +0 -78
  119. package/dist/testSetup.main.js.map +0 -1
  120. package/dist/testSetup.mjs +0 -72
  121. package/dist/testSetup.module.js +0 -72
  122. package/dist/testSetup.module.js.map +0 -1
  123. package/dist/tree.main.js.map +0 -1
  124. package/dist/tree.module.js +0 -179
  125. package/dist/tree.module.js.map +0 -1
  126. package/dist/types.d.ts +0 -694
  127. package/dist/types.d.ts.map +0 -1
  128. package/dist/user.main.js +0 -76
  129. package/dist/user.main.js.map +0 -1
  130. package/dist/user.mjs +0 -67
  131. package/dist/user.module.js +0 -67
  132. package/dist/user.module.js.map +0 -1
  133. package/dist/userEventMaps.module.js +0 -38
package/dist/types.d.ts DELETED
@@ -1,694 +0,0 @@
1
- import { pointerKey } from "@testing-library/user-event";
2
- type Direction = 'ltr' | 'rtl';
3
- export interface UserOpts {
4
- /**
5
- * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting with a component. This can be overridden
6
- * at the aria pattern tester level if needed.
7
- * @default mouse
8
- */
9
- interactionType?: 'mouse' | 'touch' | 'keyboard';
10
- /**
11
- * A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table). This can be overridden
12
- * at the aria pattern tester level if needed.
13
- */
14
- advanceTimer?: (time: number) => unknown | Promise<unknown>;
15
- }
16
- interface BaseTesterOpts extends UserOpts {
17
- /** @private */
18
- user?: any;
19
- /** The base element for the given tester (e.g. the table, menu trigger button, etc). */
20
- root: HTMLElement;
21
- }
22
- interface ComboBoxTesterOpts extends BaseTesterOpts {
23
- /**
24
- * The base element for the combobox. If provided the wrapping element around the target combobox (as is the the case with a ref provided to RSP ComboBox),
25
- * will automatically search for the combobox element within.
26
- */
27
- root: HTMLElement;
28
- /**
29
- * The node of the combobox trigger button if any. If not provided, we will try to automatically use any button
30
- * within the `root` provided or that the `root` serves as the trigger.
31
- */
32
- trigger?: HTMLElement;
33
- }
34
- interface GridListTesterOpts extends BaseTesterOpts {
35
- }
36
- interface ListBoxTesterOpts extends BaseTesterOpts {
37
- /**
38
- * A function used by the test utils to advance timers during interactions.
39
- */
40
- advanceTimer?: UserOpts['advanceTimer'];
41
- }
42
- interface MenuTesterOpts extends BaseTesterOpts {
43
- /**
44
- * The trigger element for the menu.
45
- */
46
- root: HTMLElement;
47
- /**
48
- * Whether the current menu is a submenu.
49
- */
50
- isSubmenu?: boolean;
51
- /**
52
- * The root menu of the menu tree. Only available if the menu is a submenu.
53
- */
54
- rootMenu?: HTMLElement;
55
- }
56
- interface SelectTesterOpts extends BaseTesterOpts {
57
- /**
58
- * The trigger element for the select. If provided the wrapping element around the target select (as is the case with a ref provided to RSP Select),
59
- * will automatically search for the select's trigger element within.
60
- */
61
- root: HTMLElement;
62
- }
63
- interface TableTesterOpts extends BaseTesterOpts {
64
- /**
65
- * A function used by the test utils to advance timers during interactions.
66
- */
67
- advanceTimer?: UserOpts['advanceTimer'];
68
- }
69
- interface TabsTesterOpts extends BaseTesterOpts {
70
- /**
71
- * The horizontal layout direction, typically affected by locale.
72
- * @default 'ltr'
73
- */
74
- direction?: Direction;
75
- }
76
- interface TreeTesterOpts extends BaseTesterOpts {
77
- /**
78
- * A function used by the test utils to advance timers during interactions.
79
- */
80
- advanceTimer?: UserOpts['advanceTimer'];
81
- }
82
- interface BaseGridRowInteractionOpts {
83
- /**
84
- * The index, text, or node of the row to target.
85
- */
86
- row: number | string | HTMLElement;
87
- /**
88
- * What interaction type to use when interacting with the row. Defaults to the interaction type set on the tester.
89
- */
90
- interactionType?: UserOpts['interactionType'];
91
- }
92
- interface ToggleGridRowOpts extends BaseGridRowInteractionOpts {
93
- /**
94
- * Whether the row needs to be long pressed to be selected. Depends on the components implementation.
95
- */
96
- needsLongPress?: boolean;
97
- /**
98
- * Whether the checkbox should be used to select the row. If false, will attempt to select the row via press.
99
- * @default 'true'
100
- */
101
- checkboxSelection?: boolean;
102
- /**
103
- * Whether the grid has a selectionBehavior of "toggle" or "replace" (aka highlight selection). This affects the user operations
104
- * required to toggle row selection by adding modifier keys during user actions, useful when performing multi-row selection in a "selectionBehavior: 'replace'" grid.
105
- * If you would like to still simulate user actions (aka press) without these modifiers keys for a "selectionBehavior: replace" grid, simply omit this option.
106
- * See the "Selection Behavior" section of the appropriate React Aria Component docs for more information (e.g. https://react-spectrum.adobe.com/react-aria/Tree.html#selection-behavior).
107
- *
108
- * @default 'toggle'
109
- */
110
- selectionBehavior?: 'toggle' | 'replace';
111
- }
112
- interface GridRowActionOpts extends BaseGridRowInteractionOpts {
113
- /**
114
- * Whether or not the row needs a double click to trigger the row action. Depends on the components implementation.
115
- */
116
- needsDoubleClick?: boolean;
117
- }
118
- /**
119
- * Simulates a "long press" event on a element.
120
- * @param opts - Options for the long press.
121
- * @param opts.element - Element to long press.
122
- * @param opts.advanceTimer - Function that when called advances the timers in your test suite by a specific amount of time(ms).
123
- * @param opts.pointeropts - Options to pass to the simulated event. Defaults to mouse. See https://testing-library.com/docs/dom-testing-library/api-events/#fireevent for more info.
124
- */
125
- export function triggerLongPress(opts: {
126
- element: HTMLElement;
127
- advanceTimer: (time: number) => unknown | Promise<unknown>;
128
- pointerOpts?: Record<string, any>;
129
- }): Promise<void>;
130
- /**
131
- * Enables reading pageX/pageY from fireEvent.mouse*(..., {pageX: ..., pageY: ...}).
132
- */
133
- export function installMouseEvent(): void;
134
- export function installPointerEvent(): void;
135
- export let pointerMap: pointerKey[];
136
- interface ComboBoxOpenOpts {
137
- /**
138
- * Whether the combobox opens on focus or needs to be manually opened via user action.
139
- * @default 'manual'
140
- */
141
- triggerBehavior?: 'focus' | 'manual';
142
- /**
143
- * What interaction type to use when opening the combobox. Defaults to the interaction type set on the tester.
144
- */
145
- interactionType?: UserOpts['interactionType'];
146
- }
147
- interface ComboBoxSelectOpts extends ComboBoxOpenOpts {
148
- /**
149
- * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
150
- */
151
- option: number | string | HTMLElement;
152
- }
153
- declare class ComboBoxTester {
154
- constructor(opts: ComboBoxTesterOpts);
155
- /**
156
- * Set the interaction type used by the combobox tester.
157
- */
158
- setInteractionType(type: UserOpts['interactionType']): void;
159
- /**
160
- * Opens the combobox dropdown. Defaults to using the interaction type set on the combobox tester.
161
- */
162
- open(opts?: ComboBoxOpenOpts): Promise<void>;
163
- /**
164
- * Returns an option matching the specified index or text content.
165
- */
166
- findOption(opts: {
167
- optionIndexOrText: number | string;
168
- }): HTMLElement;
169
- /**
170
- * Selects the desired combobox option. Defaults to using the interaction type set on the combobox tester. If necessary, will open the combobox dropdown beforehand.
171
- * The desired option can be targeted via the option's node, the option's text, or the option's index.
172
- */
173
- selectOption(opts: ComboBoxSelectOpts): Promise<void>;
174
- /**
175
- * Closes the combobox dropdown.
176
- */
177
- close(): Promise<void>;
178
- /**
179
- * Returns the combobox.
180
- */
181
- get combobox(): HTMLElement;
182
- /**
183
- * Returns the combobox trigger button.
184
- */
185
- get trigger(): HTMLElement;
186
- /**
187
- * Returns the combobox's listbox if present.
188
- */
189
- get listbox(): HTMLElement | null;
190
- /**
191
- * Returns the combobox's sections if present.
192
- */
193
- get sections(): HTMLElement[];
194
- /**
195
- * Returns the combobox's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
196
- */
197
- options(opts?: {
198
- element?: HTMLElement;
199
- }): HTMLElement[];
200
- /**
201
- * Returns the currently focused option in the combobox's dropdown if any.
202
- */
203
- get focusedOption(): HTMLElement | null;
204
- }
205
- interface GridListToggleRowOpts extends ToggleGridRowOpts {
206
- }
207
- interface GridListRowActionOpts extends GridRowActionOpts {
208
- }
209
- declare class GridListTester {
210
- constructor(opts: GridListTesterOpts);
211
- /**
212
- * Set the interaction type used by the gridlist tester.
213
- */
214
- setInteractionType(type: UserOpts['interactionType']): void;
215
- /**
216
- * Returns a row matching the specified index or text content.
217
- */
218
- findRow(opts: {
219
- rowIndexOrText: number | string;
220
- }): HTMLElement;
221
- /**
222
- * Toggles the selection for the specified gridlist row. Defaults to using the interaction type set on the gridlist tester.
223
- * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
224
- */
225
- toggleRowSelection(opts: GridListToggleRowOpts): Promise<void>;
226
- /**
227
- * Triggers the action for the specified gridlist row. Defaults to using the interaction type set on the gridlist tester.
228
- */
229
- triggerRowAction(opts: GridListRowActionOpts): Promise<void>;
230
- /**
231
- * Returns the gridlist.
232
- */
233
- get gridlist(): HTMLElement;
234
- /**
235
- * Returns the gridlist's rows if any.
236
- */
237
- get rows(): HTMLElement[];
238
- /**
239
- * Returns the gridlist's selected rows if any.
240
- */
241
- get selectedRows(): HTMLElement[];
242
- /**
243
- * Returns the gridlist's cells if any. Can be filtered against a specific row if provided via `element`.
244
- */
245
- cells(opts?: {
246
- element?: HTMLElement;
247
- }): HTMLElement[];
248
- }
249
- interface ListBoxToggleOptionOpts {
250
- /**
251
- * What interaction type to use when toggling selection for an option. Defaults to the interaction type set on the tester.
252
- */
253
- interactionType?: UserOpts['interactionType'];
254
- /**
255
- * The index, text, or node of the option to toggle selection for.
256
- */
257
- option: number | string | HTMLElement;
258
- /**
259
- * Whether the option should be triggered by Space or Enter in keyboard modality.
260
- * @default 'Enter'
261
- */
262
- keyboardActivation?: 'Space' | 'Enter';
263
- /**
264
- * Whether the option needs to be long pressed to be selected. Depends on the listbox's implementation.
265
- */
266
- needsLongPress?: boolean;
267
- /**
268
- * Whether the listbox has a selectionBehavior of "toggle" or "replace" (aka highlight selection). This affects the user operations
269
- * required to toggle option selection by adding modifier keys during user actions, useful when performing multi-option selection in a "selectionBehavior: 'replace'" listbox.
270
- * If you would like to still simulate user actions (aka press) without these modifiers keys for a "selectionBehavior: replace" listbox, simply omit this option.
271
- * See the [RAC Listbox docs](https://react-spectrum.adobe.com/react-aria/ListBox.html#selection-behavior) for more info on this behavior.
272
- *
273
- * @default 'toggle'
274
- */
275
- selectionBehavior?: 'toggle' | 'replace';
276
- }
277
- interface ListBoxOptionActionOpts extends Omit<ListBoxToggleOptionOpts, 'keyboardActivation' | 'needsLongPress'> {
278
- /**
279
- * Whether or not the option needs a double click to trigger the option action. Depends on the listbox's implementation.
280
- */
281
- needsDoubleClick?: boolean;
282
- }
283
- declare class ListBoxTester {
284
- constructor(opts: ListBoxTesterOpts);
285
- /**
286
- * Set the interaction type used by the listbox tester.
287
- */
288
- setInteractionType(type: UserOpts['interactionType']): void;
289
- /**
290
- * Returns a option matching the specified index or text content.
291
- */
292
- findOption(opts: {
293
- optionIndexOrText: number | string;
294
- }): HTMLElement;
295
- /**
296
- * Toggles the selection for the specified listbox option. Defaults to using the interaction type set on the listbox tester.
297
- */
298
- toggleOptionSelection(opts: ListBoxToggleOptionOpts): Promise<void>;
299
- /**
300
- * Triggers the action for the specified listbox option. Defaults to using the interaction type set on the listbox tester.
301
- */
302
- triggerOptionAction(opts: ListBoxOptionActionOpts): Promise<void>;
303
- /**
304
- * Returns the listbox.
305
- */
306
- get listbox(): HTMLElement;
307
- /**
308
- * Returns the listbox options. Can be filtered to a subsection of the listbox if provided via `element`.
309
- */
310
- options(opts?: {
311
- element?: HTMLElement;
312
- }): HTMLElement[];
313
- /**
314
- * Returns the listbox's selected options if any.
315
- */
316
- get selectedOptions(): HTMLElement[];
317
- /**
318
- * Returns the listbox's sections if any.
319
- */
320
- get sections(): HTMLElement[];
321
- }
322
- interface MenuOpenOpts {
323
- /**
324
- * Whether the menu needs to be long pressed to open.
325
- */
326
- needsLongPress?: boolean;
327
- /**
328
- * What interaction type to use when opening the menu. Defaults to the interaction type set on the tester.
329
- */
330
- interactionType?: UserOpts['interactionType'];
331
- /**
332
- * Whether to open the menu via ArrowUp or ArrowDown if in keyboard modality.
333
- */
334
- direction?: 'up' | 'down';
335
- }
336
- interface MenuSelectOpts extends MenuOpenOpts {
337
- /**
338
- * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
339
- */
340
- option: number | string | HTMLElement;
341
- /**
342
- * The menu's selection mode. Will affect whether or not the menu is expected to be closed upon option selection.
343
- * @default 'single'
344
- */
345
- menuSelectionMode?: 'single' | 'multiple';
346
- /**
347
- * Whether or not the menu closes on select. Depends on menu implementation and configuration.
348
- * @default true
349
- */
350
- closesOnSelect?: boolean;
351
- /**
352
- * Whether the option should be triggered by Space or Enter in keyboard modality.
353
- * @default 'Enter'
354
- */
355
- keyboardActivation?: 'Space' | 'Enter';
356
- }
357
- interface MenuOpenSubmenuOpts extends MenuOpenOpts {
358
- /**
359
- * The text or node of the submenu trigger to open. Available submenu trigger nodes can be sourced via `submenuTriggers`.
360
- */
361
- submenuTrigger: string | HTMLElement;
362
- }
363
- declare class MenuTester {
364
- constructor(opts: MenuTesterOpts);
365
- /**
366
- * Set the interaction type used by the menu tester.
367
- */
368
- setInteractionType(type: UserOpts['interactionType']): void;
369
- /**
370
- * Opens the menu. Defaults to using the interaction type set on the menu tester.
371
- */
372
- open(opts?: MenuOpenOpts): Promise<void>;
373
- /**
374
- * Returns a option matching the specified index or text content.
375
- */
376
- findOption(opts: {
377
- optionIndexOrText: number | string;
378
- }): HTMLElement;
379
- /**
380
- * Selects the desired menu option. Defaults to using the interaction type set on the menu tester. If necessary, will open the menu dropdown beforehand.
381
- * The desired option can be targeted via the option's node, the option's text, or the option's index.
382
- */
383
- selectOption(opts: MenuSelectOpts): Promise<void>;
384
- /**
385
- * Opens the submenu. Defaults to using the interaction type set on the menu tester. The submenu trigger can be targeted via the trigger's node or the trigger's text.
386
- */
387
- openSubmenu(opts: MenuOpenSubmenuOpts): Promise<MenuTester | null>;
388
- /**
389
- * Closes the menu.
390
- */
391
- close(): Promise<void>;
392
- /**
393
- * Returns the menu's trigger.
394
- */
395
- get trigger(): HTMLElement;
396
- /**
397
- * Returns the menu if present.
398
- */
399
- get menu(): HTMLElement | null;
400
- /**
401
- * Returns the menu's sections if any.
402
- */
403
- get sections(): HTMLElement[];
404
- /**
405
- * Returns the menu's options if present. Can be filtered to a subsection of the menu if provided via `element`.
406
- */
407
- options(opts?: {
408
- element?: HTMLElement;
409
- }): HTMLElement[];
410
- /**
411
- * Returns the menu's submenu triggers if any.
412
- */
413
- get submenuTriggers(): HTMLElement[];
414
- }
415
- interface SelectOpenOpts {
416
- /**
417
- * What interaction type to use when opening the select. Defaults to the interaction type set on the tester.
418
- */
419
- interactionType?: UserOpts['interactionType'];
420
- }
421
- interface SelectTriggerOptionOpts extends SelectOpenOpts {
422
- /**
423
- * The index, text, or node of the option to select. Option nodes can be sourced via `options()`.
424
- */
425
- option: number | string | HTMLElement;
426
- }
427
- declare class SelectTester {
428
- constructor(opts: SelectTesterOpts);
429
- /**
430
- * Set the interaction type used by the select tester.
431
- */
432
- setInteractionType(type: UserOpts['interactionType']): void;
433
- /**
434
- * Opens the select. Defaults to using the interaction type set on the select tester.
435
- */
436
- open(opts?: SelectOpenOpts): Promise<void>;
437
- /**
438
- * Closes the select.
439
- */
440
- close(): Promise<void>;
441
- /**
442
- * Returns a option matching the specified index or text content.
443
- */
444
- findOption(opts: {
445
- optionIndexOrText: number | string;
446
- }): HTMLElement;
447
- /**
448
- * Selects the desired select option. Defaults to using the interaction type set on the select tester. If necessary, will open the select dropdown beforehand.
449
- * The desired option can be targeted via the option's node, the option's text, or the option's index.
450
- */
451
- selectOption(opts: SelectTriggerOptionOpts): Promise<void>;
452
- /**
453
- * Returns the select's options if present. Can be filtered to a subsection of the listbox if provided via `element`.
454
- */
455
- options(opts?: {
456
- element?: HTMLElement;
457
- }): HTMLElement[];
458
- /**
459
- * Returns the select's trigger.
460
- */
461
- get trigger(): HTMLElement;
462
- /**
463
- * Returns the select's listbox if present.
464
- */
465
- get listbox(): HTMLElement | null;
466
- /**
467
- * Returns the select's sections if present.
468
- */
469
- get sections(): HTMLElement[];
470
- }
471
- interface TableToggleRowOpts extends ToggleGridRowOpts {
472
- }
473
- interface TableToggleSortOpts {
474
- /**
475
- * The index, text, or node of the column to toggle selection for.
476
- */
477
- column: number | string | HTMLElement;
478
- /**
479
- * What interaction type to use when sorting the column. Defaults to the interaction type set on the tester.
480
- */
481
- interactionType?: UserOpts['interactionType'];
482
- }
483
- interface TableColumnHeaderActionOpts extends TableToggleSortOpts {
484
- /**
485
- * The index of the column header action to trigger.
486
- */
487
- action: number;
488
- }
489
- interface TableRowActionOpts extends GridRowActionOpts {
490
- }
491
- declare class TableTester {
492
- constructor(opts: TableTesterOpts);
493
- /**
494
- * Set the interaction type used by the table tester.
495
- */
496
- setInteractionType(type: UserOpts['interactionType']): void;
497
- /**
498
- * Toggles the selection for the specified table row. Defaults to using the interaction type set on the table tester.
499
- */
500
- toggleRowSelection(opts: TableToggleRowOpts): Promise<void>;
501
- /**
502
- * Toggles the sort order for the specified table column. Defaults to using the interaction type set on the table tester.
503
- */
504
- toggleSort(opts: TableToggleSortOpts): Promise<void>;
505
- /**
506
- * Triggers an action for the specified table column menu. Defaults to using the interaction type set on the table tester.
507
- */
508
- triggerColumnHeaderAction(opts: TableColumnHeaderActionOpts): Promise<void>;
509
- /**
510
- * Triggers the action for the specified table row. Defaults to using the interaction type set on the table tester.
511
- */
512
- triggerRowAction(opts: TableRowActionOpts): Promise<void>;
513
- /**
514
- * Toggle selection for all rows in the table. Defaults to using the interaction type set on the table tester.
515
- */
516
- toggleSelectAll(opts?: {
517
- interactionType?: UserOpts['interactionType'];
518
- }): Promise<void>;
519
- /**
520
- * Returns a row matching the specified index or text content.
521
- */
522
- findRow(opts: {
523
- rowIndexOrText: number | string;
524
- }): HTMLElement;
525
- /**
526
- * Returns a cell matching the specified text content.
527
- */
528
- findCell(opts: {
529
- text: string;
530
- }): HTMLElement;
531
- /**
532
- * Returns the table.
533
- */
534
- get table(): HTMLElement;
535
- /**
536
- * Returns the row groups within the table.
537
- */
538
- get rowGroups(): HTMLElement[];
539
- /**
540
- * Returns the columns within the table.
541
- */
542
- get columns(): HTMLElement[];
543
- /**
544
- * Returns the rows within the table if any.
545
- */
546
- get rows(): HTMLElement[];
547
- /**
548
- * Returns the currently selected rows within the table if any.
549
- */
550
- get selectedRows(): HTMLElement[];
551
- /**
552
- * Returns the row headers within the table if any.
553
- */
554
- get rowHeaders(): HTMLElement[];
555
- /**
556
- * Returns the cells within the table if any. Can be filtered against a specific row if provided via `element`.
557
- */
558
- cells(opts?: {
559
- element?: HTMLElement;
560
- }): HTMLElement[];
561
- }
562
- interface TriggerTabOptions {
563
- /**
564
- * What interaction type to use when triggering a tab. Defaults to the interaction type set on the tester.
565
- */
566
- interactionType?: UserOpts['interactionType'];
567
- /**
568
- * The index, text, or node of the tab to toggle selection for.
569
- */
570
- tab: number | string | HTMLElement;
571
- /**
572
- * Whether the tab needs to be activated manually rather than on focus.
573
- */
574
- manualActivation?: boolean;
575
- }
576
- declare class TabsTester {
577
- constructor(opts: TabsTesterOpts);
578
- /**
579
- * Set the interaction type used by the tabs tester.
580
- */
581
- setInteractionType(type: UserOpts['interactionType']): void;
582
- /**
583
- * Returns a tab matching the specified index or text content.
584
- */
585
- findTab(opts: {
586
- tabIndexOrText: number | string;
587
- }): HTMLElement;
588
- /**
589
- * Triggers the specified tab. Defaults to using the interaction type set on the tabs tester.
590
- */
591
- triggerTab(opts: TriggerTabOptions): Promise<void>;
592
- /**
593
- * Returns the tablist.
594
- */
595
- get tablist(): HTMLElement;
596
- /**
597
- * Returns the tabpanels.
598
- */
599
- get tabpanels(): HTMLElement[];
600
- /**
601
- * Returns the tabs in the tablist.
602
- */
603
- get tabs(): HTMLElement[];
604
- /**
605
- * Returns the currently selected tab in the tablist if any.
606
- */
607
- get selectedTab(): HTMLElement | null;
608
- /**
609
- * Returns the currently active tabpanel if any.
610
- */
611
- get activeTabpanel(): HTMLElement | null;
612
- }
613
- interface TreeToggleExpansionOpts extends BaseGridRowInteractionOpts {
614
- }
615
- interface TreeToggleRowOpts extends ToggleGridRowOpts {
616
- }
617
- interface TreeRowActionOpts extends GridRowActionOpts {
618
- }
619
- declare class TreeTester {
620
- constructor(opts: TreeTesterOpts);
621
- /**
622
- * Set the interaction type used by the tree tester.
623
- */
624
- setInteractionType(type: UserOpts['interactionType']): void;
625
- /**
626
- * Returns a row matching the specified index or text content.
627
- */
628
- findRow(opts: {
629
- rowIndexOrText: number | string;
630
- }): HTMLElement;
631
- /**
632
- * Toggles the selection for the specified tree row. Defaults to using the interaction type set on the tree tester.
633
- * Note that this will endevor to always add/remove JUST the provided row to the set of selected rows.
634
- */
635
- toggleRowSelection(opts: TreeToggleRowOpts): Promise<void>;
636
- /**
637
- * Toggles the expansion for the specified tree row. Defaults to using the interaction type set on the tree tester.
638
- */
639
- toggleRowExpansion(opts: TreeToggleExpansionOpts): Promise<void>;
640
- /**
641
- * Triggers the action for the specified tree row. Defaults to using the interaction type set on the tree tester.
642
- */
643
- triggerRowAction(opts: TreeRowActionOpts): Promise<void>;
644
- /**
645
- * Returns the tree.
646
- */
647
- get tree(): HTMLElement;
648
- /**
649
- * Returns the tree's rows if any.
650
- */
651
- get rows(): HTMLElement[];
652
- /**
653
- * Returns the tree's selected rows if any.
654
- */
655
- get selectedRows(): HTMLElement[];
656
- /**
657
- * Returns the tree's cells if any. Can be filtered against a specific row if provided via `element`.
658
- */
659
- cells(opts?: {
660
- element?: HTMLElement;
661
- }): HTMLElement[];
662
- }
663
- declare let keyToUtil: {
664
- 'Select': typeof SelectTester;
665
- 'Table': typeof TableTester;
666
- 'Menu': typeof MenuTester;
667
- 'ComboBox': typeof ComboBoxTester;
668
- 'GridList': typeof GridListTester;
669
- 'ListBox': typeof ListBoxTester;
670
- 'Tabs': typeof TabsTester;
671
- 'Tree': typeof TreeTester;
672
- };
673
- type PatternNames = keyof typeof keyToUtil;
674
- type Tester<T> = T extends 'ComboBox' ? ComboBoxTester : T extends 'GridList' ? GridListTester : T extends 'ListBox' ? ListBoxTester : T extends 'Menu' ? MenuTester : T extends 'Select' ? SelectTester : T extends 'Table' ? TableTester : T extends 'Tabs' ? TabsTester : T extends 'Tree' ? TreeTester : never;
675
- type TesterOpts<T> = T extends 'ComboBox' ? ComboBoxTesterOpts : T extends 'GridList' ? GridListTesterOpts : T extends 'ListBox' ? ListBoxTesterOpts : T extends 'Menu' ? MenuTesterOpts : T extends 'Select' ? SelectTesterOpts : T extends 'Table' ? TableTesterOpts : T extends 'Tabs' ? TabsTesterOpts : T extends 'Tree' ? TreeTesterOpts : never;
676
- export class User {
677
- /**
678
- * The interaction type (mouse, touch, keyboard) that the test util user will use when interacting with a component. This can be overridden
679
- * at the aria pattern util level if needed.
680
- * @default mouse
681
- */
682
- interactionType: UserOpts['interactionType'];
683
- /**
684
- * A function used by the test utils to advance timers during interactions. Required for certain aria patterns (e.g. table).
685
- */
686
- advanceTimer: UserOpts['advanceTimer'];
687
- constructor(opts?: UserOpts);
688
- /**
689
- * Creates an aria pattern tester, inheriting the options provided to the original user.
690
- */
691
- createTester<T extends PatternNames>(patternName: T, opts: TesterOpts<T>): Tester<T>;
692
- }
693
-
694
- //# sourceMappingURL=types.d.ts.map