@ariakit/test 0.2.5 → 0.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.
Files changed (165) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/cjs/__chunks/473V5JUA.cjs +19 -0
  3. package/cjs/__chunks/645PZZGM.cjs +13 -0
  4. package/cjs/__chunks/6PJ6QG4X.cjs +204 -0
  5. package/cjs/__chunks/6WHWNYHF.cjs +56 -0
  6. package/cjs/__chunks/CR7E273F.cjs +70 -0
  7. package/cjs/__chunks/{2V5PIRJZ.cjs → CVZQHCPZ.cjs} +67 -67
  8. package/cjs/__chunks/HNXGMK5P.cjs +35 -0
  9. package/cjs/__chunks/J6ZZZ7OL.cjs +12 -0
  10. package/cjs/__chunks/{LUIPCXQX.cjs → MWZXO7MI.cjs} +45 -42
  11. package/cjs/__chunks/NUOZZLPY.cjs +29 -0
  12. package/cjs/__chunks/OUXW5FPV.cjs +125 -0
  13. package/cjs/__chunks/R25SVNFL.cjs +94 -0
  14. package/cjs/__chunks/R7VOUI26.cjs +32 -0
  15. package/cjs/__chunks/SSTGZXPB.cjs +57 -0
  16. package/cjs/__chunks/YJVLDF2F.cjs +68 -0
  17. package/cjs/__utils.d.ts +6 -3
  18. package/cjs/blur.cjs +4 -6
  19. package/cjs/blur.d.ts +1 -2
  20. package/cjs/click.cjs +10 -12
  21. package/cjs/click.d.ts +1 -2
  22. package/cjs/dispatch.cjs +8 -0
  23. package/cjs/dispatch.d.ts +9 -0
  24. package/cjs/focus.cjs +4 -6
  25. package/cjs/focus.d.ts +1 -2
  26. package/cjs/hover.cjs +5 -7
  27. package/cjs/hover.d.ts +1 -2
  28. package/cjs/index.cjs +17 -75
  29. package/cjs/index.d.ts +2 -5
  30. package/cjs/mouse-down.cjs +6 -8
  31. package/cjs/mouse-down.d.ts +1 -2
  32. package/cjs/mouse-up.cjs +4 -5
  33. package/cjs/mouse-up.d.ts +1 -2
  34. package/cjs/press.cjs +8 -10
  35. package/cjs/press.d.ts +0 -1
  36. package/cjs/query.cjs +9 -0
  37. package/cjs/query.d.ts +3989 -0
  38. package/cjs/react.cjs +89 -0
  39. package/cjs/react.d.ts +7 -0
  40. package/cjs/select.cjs +10 -12
  41. package/cjs/select.d.ts +1 -2
  42. package/cjs/sleep.cjs +3 -4
  43. package/cjs/tap.cjs +11 -13
  44. package/cjs/tap.d.ts +1 -2
  45. package/cjs/tsconfig.build.tsbuildinfo +1 -1
  46. package/cjs/type.cjs +6 -8
  47. package/cjs/type.d.ts +0 -1
  48. package/cjs/wait-for.cjs +3 -2
  49. package/cjs/wait-for.d.ts +2 -1
  50. package/dispatch/package.json +8 -0
  51. package/esm/__chunks/{6PY4HXVO.js → 2YBPSAHP.js} +69 -69
  52. package/esm/__chunks/33MQDYWJ.js +125 -0
  53. package/esm/__chunks/45H4QFE4.js +94 -0
  54. package/esm/__chunks/4NZZR22G.js +35 -0
  55. package/esm/__chunks/7I22ZP6R.js +13 -0
  56. package/esm/__chunks/BKSZ7WES.js +204 -0
  57. package/esm/__chunks/MOHPNQYM.js +70 -0
  58. package/esm/__chunks/PGGOW3IT.js +57 -0
  59. package/esm/__chunks/SKXK6BOG.js +29 -0
  60. package/esm/__chunks/WWAF2MEB.js +12 -0
  61. package/esm/__chunks/{SWUQE4WB.js → X5N4V7NJ.js} +46 -43
  62. package/esm/__chunks/Y4VDXWJ6.js +32 -0
  63. package/esm/__chunks/YXZMMBB6.js +19 -0
  64. package/esm/__chunks/ZJJNX53K.js +68 -0
  65. package/esm/__chunks/ZU6UY6LZ.js +56 -0
  66. package/esm/__utils.d.ts +6 -3
  67. package/esm/blur.d.ts +1 -2
  68. package/esm/blur.js +3 -5
  69. package/esm/click.d.ts +1 -2
  70. package/esm/click.js +9 -11
  71. package/esm/dispatch.d.ts +9 -0
  72. package/esm/dispatch.js +8 -0
  73. package/esm/focus.d.ts +1 -2
  74. package/esm/focus.js +3 -5
  75. package/esm/hover.d.ts +1 -2
  76. package/esm/hover.js +4 -6
  77. package/esm/index.d.ts +2 -5
  78. package/esm/index.js +29 -87
  79. package/esm/mouse-down.d.ts +1 -2
  80. package/esm/mouse-down.js +5 -7
  81. package/esm/mouse-up.d.ts +1 -2
  82. package/esm/mouse-up.js +3 -4
  83. package/esm/press.d.ts +0 -1
  84. package/esm/press.js +7 -9
  85. package/esm/query.d.ts +3989 -0
  86. package/esm/query.js +9 -0
  87. package/esm/react.d.ts +7 -0
  88. package/esm/react.js +89 -0
  89. package/esm/select.d.ts +1 -2
  90. package/esm/select.js +9 -11
  91. package/esm/sleep.js +2 -3
  92. package/esm/tap.d.ts +1 -2
  93. package/esm/tap.js +10 -12
  94. package/esm/tsconfig.build.tsbuildinfo +1 -1
  95. package/esm/type.d.ts +0 -1
  96. package/esm/type.js +5 -7
  97. package/esm/wait-for.d.ts +2 -1
  98. package/esm/wait-for.js +2 -1
  99. package/package.json +21 -24
  100. package/query/package.json +8 -0
  101. package/react/package.json +8 -0
  102. package/act/package.json +0 -8
  103. package/cjs/__chunks/3NIZQX5J.cjs +0 -6
  104. package/cjs/__chunks/3WW644T7.cjs +0 -20
  105. package/cjs/__chunks/5F5PNQCC.cjs +0 -22
  106. package/cjs/__chunks/7BZFO6FC.cjs +0 -12
  107. package/cjs/__chunks/7RUXTAPP.cjs +0 -16
  108. package/cjs/__chunks/B4VP2LEU.cjs +0 -28
  109. package/cjs/__chunks/BHNBCXUN.cjs +0 -33
  110. package/cjs/__chunks/EGF4KWUK.cjs +0 -64
  111. package/cjs/__chunks/HGTTGPFK.cjs +0 -54
  112. package/cjs/__chunks/JY5DGPUE.cjs +0 -14
  113. package/cjs/__chunks/KRQVK4KQ.cjs +0 -38
  114. package/cjs/__chunks/LFNIGEB6.cjs +0 -50
  115. package/cjs/__chunks/MQA5IB4L.cjs +0 -6
  116. package/cjs/__chunks/Q7PN3HIB.cjs +0 -121
  117. package/cjs/__chunks/SYQ5J5KP.cjs +0 -32
  118. package/cjs/__chunks/VIKUJSTX.cjs +0 -83
  119. package/cjs/act.cjs +0 -8
  120. package/cjs/act.d.ts +0 -1
  121. package/cjs/fire-event.cjs +0 -9
  122. package/cjs/fire-event.d.ts +0 -3
  123. package/cjs/polyfills.cjs +0 -3
  124. package/cjs/polyfills.d.ts +0 -1
  125. package/cjs/render.cjs +0 -9
  126. package/cjs/render.d.ts +0 -5
  127. package/cjs/screen.cjs +0 -55
  128. package/cjs/screen.d.ts +0 -26
  129. package/cjs/within.cjs +0 -7
  130. package/cjs/within.d.ts +0 -1
  131. package/esm/__chunks/2OZA4WAZ.js +0 -50
  132. package/esm/__chunks/2RHTJFSK.js +0 -38
  133. package/esm/__chunks/3C72DPE2.js +0 -54
  134. package/esm/__chunks/4A3YKZRA.js +0 -121
  135. package/esm/__chunks/5JPM5LQX.js +0 -6
  136. package/esm/__chunks/5PINJ4MD.js +0 -16
  137. package/esm/__chunks/AEOE57TZ.js +0 -33
  138. package/esm/__chunks/EVYPE6ZJ.js +0 -32
  139. package/esm/__chunks/EX5WPJOU.js +0 -64
  140. package/esm/__chunks/JTFRQL3H.js +0 -83
  141. package/esm/__chunks/LJWZLI6L.js +0 -14
  142. package/esm/__chunks/OQYWQML5.js +0 -12
  143. package/esm/__chunks/OSCTTZUZ.js +0 -28
  144. package/esm/__chunks/QA3ZS6S2.js +0 -6
  145. package/esm/__chunks/R7IYW63J.js +0 -22
  146. package/esm/__chunks/ZEO5Q6UD.js +0 -20
  147. package/esm/act.d.ts +0 -1
  148. package/esm/act.js +0 -8
  149. package/esm/fire-event.d.ts +0 -3
  150. package/esm/fire-event.js +0 -9
  151. package/esm/polyfills.d.ts +0 -1
  152. package/esm/polyfills.js +0 -3
  153. package/esm/render.d.ts +0 -5
  154. package/esm/render.js +0 -9
  155. package/esm/screen.d.ts +0 -26
  156. package/esm/screen.js +0 -55
  157. package/esm/within.d.ts +0 -1
  158. package/esm/within.js +0 -7
  159. package/fire-event/package.json +0 -8
  160. package/polyfills/package.json +0 -8
  161. package/render/package.json +0 -8
  162. package/screen/package.json +0 -8
  163. package/within/package.json +0 -8
  164. /package/cjs/__chunks/{AYRPODWR.cjs → IDMD7IDF.cjs} +0 -0
  165. /package/esm/__chunks/{PNBZ5NXH.js → 36HVAQ4Z.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @ariakit/test
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`#2894`](https://github.com/ariakit/ariakit/pull/2894) All `@ariakit/test` functions now disable `global.IS_REACT_ACT_ENVIRONMENT` before running and restore its value at the end.
8
+
9
+ - [`#2894`](https://github.com/ariakit/ariakit/pull/2894) Replaced the synchronous `fireEvent` functions by asynchronous `dispatch` functions.
10
+
11
+ - [`#2894`](https://github.com/ariakit/ariakit/pull/2894) The `act` export has been removed.
12
+
13
+ - [`#2894`](https://github.com/ariakit/ariakit/pull/2894) Exported user event functions that were previously synchronous are now asyncrhonous.
14
+
15
+ - [`#2899`](https://github.com/ariakit/ariakit/pull/2899) The `screen` module and its queries (`getBy*`, `queryBy*`, etc.) have been removed in favor of the `query` module.
16
+
17
+ - [`#2899`](https://github.com/ariakit/ariakit/pull/2899) The `within` module has been removed.
18
+
19
+ - [`#2900`](https://github.com/ariakit/ariakit/pull/2900) The `render` function has been moved to the `@ariakit/test/react` path. It's now asynchronous. The root `@ariakit/test` package does not depend on React or React Testing Library anymore.
20
+
21
+ ### Patch Changes
22
+
23
+ - [`#2892`](https://github.com/ariakit/ariakit/pull/2892) Updated function argument types to support `null` instead of `Element`, but added a runtime error in case `null` is passed.
24
+
25
+ - [`#2892`](https://github.com/ariakit/ariakit/pull/2892) Added a new `query` module that exports a `query`/`q` object with functions to query the DOM.
26
+
27
+ - Updated dependencies: `@ariakit/core@0.3.3`.
28
+
3
29
  ## 0.2.5
4
30
 
5
31
  ### Patch Changes
@@ -0,0 +1,19 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _CR7E273Fcjs = require('./CR7E273F.cjs');
6
+
7
+ // src/sleep.ts
8
+ var defaultMs = _CR7E273Fcjs.isBrowser ? 150 : 10;
9
+ function sleep(ms = defaultMs) {
10
+ return _CR7E273Fcjs.wrapAsync.call(void 0, async () => {
11
+ await _CR7E273Fcjs.nextFrame.call(void 0, );
12
+ await new Promise((resolve) => setTimeout(resolve, ms));
13
+ await _CR7E273Fcjs.nextFrame.call(void 0, );
14
+ });
15
+ }
16
+
17
+
18
+
19
+ exports.sleep = sleep;
@@ -0,0 +1,13 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
2
+
3
+ var _CR7E273Fcjs = require('./CR7E273F.cjs');
4
+
5
+ // src/wait-for.ts
6
+ var _dom = require('@testing-library/dom'); var DOMTestingLibrary = _interopRequireWildcard(_dom);
7
+ function waitFor2(callback, options) {
8
+ return _CR7E273Fcjs.wrapAsync.call(void 0, () => DOMTestingLibrary.waitFor(callback, options));
9
+ }
10
+
11
+
12
+
13
+ exports.waitFor = waitFor2;
@@ -0,0 +1,204 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _PKWBCPZUcjs = require('./PKWBCPZU.cjs');
5
+
6
+ // src/query.ts
7
+ var _dom = require('@testing-library/dom');
8
+ var roles = [
9
+ "alert",
10
+ "alertdialog",
11
+ "application",
12
+ "article",
13
+ "banner",
14
+ "blockquote",
15
+ "button",
16
+ "caption",
17
+ "cell",
18
+ "checkbox",
19
+ "code",
20
+ "columnheader",
21
+ "combobox",
22
+ "complementary",
23
+ "contentinfo",
24
+ "definition",
25
+ "deletion",
26
+ "dialog",
27
+ "directory",
28
+ "document",
29
+ "emphasis",
30
+ "feed",
31
+ "figure",
32
+ "form",
33
+ "generic",
34
+ "grid",
35
+ "gridcell",
36
+ "group",
37
+ "heading",
38
+ "img",
39
+ "insertion",
40
+ "link",
41
+ "list",
42
+ "listbox",
43
+ "listitem",
44
+ "log",
45
+ "main",
46
+ "marquee",
47
+ "math",
48
+ "menu",
49
+ "menubar",
50
+ "menuitem",
51
+ "menuitemcheckbox",
52
+ "menuitemradio",
53
+ "meter",
54
+ "navigation",
55
+ "none",
56
+ "note",
57
+ "option",
58
+ "paragraph",
59
+ "presentation",
60
+ "progressbar",
61
+ "radio",
62
+ "radiogroup",
63
+ "region",
64
+ "row",
65
+ "rowgroup",
66
+ "rowheader",
67
+ "scrollbar",
68
+ "search",
69
+ "searchbox",
70
+ "separator",
71
+ "slider",
72
+ "spinbutton",
73
+ "status",
74
+ "strong",
75
+ "subscript",
76
+ "superscript",
77
+ "switch",
78
+ "tab",
79
+ "table",
80
+ "tablist",
81
+ "tabpanel",
82
+ "term",
83
+ "textbox",
84
+ "time",
85
+ "timer",
86
+ "toolbar",
87
+ "tooltip",
88
+ "tree",
89
+ "treegrid",
90
+ "treeitem"
91
+ ];
92
+ var queries = Object.entries(_dom.queries).reduce((queries2, [key, query2]) => {
93
+ queries2[key] = (...args) => query2(document.body, ...args);
94
+ return queries2;
95
+ }, {});
96
+ function matchName(name, accessibleName) {
97
+ if (accessibleName == null)
98
+ return false;
99
+ if (typeof name === "string") {
100
+ return accessibleName === name;
101
+ }
102
+ return name.test(accessibleName);
103
+ }
104
+ function getNameOption(name) {
105
+ return (accessibleName, element) => {
106
+ if (matchName(name, accessibleName))
107
+ return true;
108
+ if (element.getAttribute("aria-label"))
109
+ return false;
110
+ const labeledBy = element.getAttribute("aria-labelledby");
111
+ if (!labeledBy) {
112
+ const content = "placeholder" in element && element.placeholder != null ? element.placeholder : element.textContent;
113
+ return matchName(name, content);
114
+ }
115
+ const label = document.getElementById(labeledBy);
116
+ if (!(label == null ? void 0 : label.textContent))
117
+ return false;
118
+ return matchName(name, label.textContent);
119
+ };
120
+ }
121
+ function createRoleQuery(role) {
122
+ const createQuery = (query3) => {
123
+ return (name, options) => {
124
+ if (!name) {
125
+ return query3(role, options);
126
+ }
127
+ return query3(role, _PKWBCPZUcjs.__spreadValues.call(void 0, { name: getNameOption(name) }, options));
128
+ };
129
+ };
130
+ const createIncludesHidden = (query3) => (name, options) => query3(name, _PKWBCPZUcjs.__spreadValues.call(void 0, { hidden: true }, options));
131
+ const query2 = createQuery(queries.queryByRole);
132
+ const allQuery = createQuery(queries.queryAllByRole);
133
+ const waitQuery = createQuery(queries.findByRole);
134
+ const waitAllQuery = createQuery(queries.findAllByRole);
135
+ const ensureQuery = createQuery(queries.getByRole);
136
+ const ensureAllQuery = createQuery(queries.getAllByRole);
137
+ const all = Object.assign(allQuery, {
138
+ includesHidden: createIncludesHidden(allQuery),
139
+ wait: Object.assign(waitAllQuery, {
140
+ includesHidden: createIncludesHidden(waitAllQuery)
141
+ }),
142
+ ensure: Object.assign(ensureAllQuery, {
143
+ includesHidden: createIncludesHidden(ensureAllQuery)
144
+ })
145
+ });
146
+ const wait = Object.assign(waitQuery, {
147
+ includesHidden: createIncludesHidden(waitQuery),
148
+ all: Object.assign(waitAllQuery, {
149
+ includesHidden: createIncludesHidden(waitAllQuery)
150
+ })
151
+ });
152
+ const ensure = Object.assign(ensureQuery, {
153
+ includesHidden: createIncludesHidden(ensureQuery),
154
+ all: Object.assign(ensureAllQuery, {
155
+ includesHidden: createIncludesHidden(ensureAllQuery)
156
+ })
157
+ });
158
+ return Object.assign(query2, {
159
+ includesHidden: createIncludesHidden(query2),
160
+ all,
161
+ wait,
162
+ ensure
163
+ });
164
+ }
165
+ function createTextQuery() {
166
+ const all = Object.assign(queries.queryAllByText, {
167
+ wait: queries.findAllByText,
168
+ ensure: queries.getAllByText
169
+ });
170
+ const wait = Object.assign(queries.findByText, {
171
+ all: queries.findAllByText
172
+ });
173
+ const ensure = Object.assign(queries.getByText, {
174
+ all: queries.getAllByText
175
+ });
176
+ return Object.assign(queries.queryByText, { all, wait, ensure });
177
+ }
178
+ function createLabeledQuery() {
179
+ const all = Object.assign(queries.queryAllByLabelText, {
180
+ wait: queries.findAllByLabelText,
181
+ ensure: queries.getAllByLabelText
182
+ });
183
+ const wait = Object.assign(queries.findByLabelText, {
184
+ all: queries.findAllByLabelText
185
+ });
186
+ const ensure = Object.assign(queries.getByLabelText, {
187
+ all: queries.getAllByLabelText
188
+ });
189
+ return Object.assign(queries.queryByLabelText, { all, wait, ensure });
190
+ }
191
+ var roleQueries = roles.reduce((acc, role) => {
192
+ acc[role] = createRoleQuery(role);
193
+ return acc;
194
+ }, {});
195
+ var query = _PKWBCPZUcjs.__spreadProps.call(void 0, _PKWBCPZUcjs.__spreadValues.call(void 0, {}, roleQueries), {
196
+ text: createTextQuery(),
197
+ labeled: createLabeledQuery()
198
+ });
199
+ var q = query;
200
+
201
+
202
+
203
+
204
+ exports.query = query; exports.q = q;
@@ -0,0 +1,56 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _CR7E273Fcjs = require('./CR7E273F.cjs');
5
+
6
+ // src/dispatch.ts
7
+ var _misc = require('@ariakit/core/utils/misc');
8
+ var _dom = require('@testing-library/dom');
9
+ var pointerEvents = [
10
+ "mousemove",
11
+ "mouseover",
12
+ "mouseenter",
13
+ "mouseout",
14
+ "mouseleave",
15
+ "mousedown",
16
+ "mouseup",
17
+ "pointermove",
18
+ "pointerover",
19
+ "pointerenter",
20
+ "pointerout",
21
+ "pointerleave",
22
+ "pointerdown",
23
+ "pointerup",
24
+ "click"
25
+ ];
26
+ function baseDispatch(element, event) {
27
+ return _CR7E273Fcjs.wrapAsync.call(void 0, async () => {
28
+ _misc.invariant.call(void 0, element, `Unable to dispatch ${event.type} on null element`);
29
+ const eventName = event.type.toLowerCase();
30
+ if (pointerEvents.includes(eventName) && "classList" in element) {
31
+ const { pointerEvents: pointerEvents2 } = getComputedStyle(element);
32
+ if (pointerEvents2 === "none") {
33
+ if (element.parentElement) {
34
+ return baseDispatch(element.parentElement, event);
35
+ }
36
+ return true;
37
+ }
38
+ }
39
+ const defaultAllowed = _dom.fireEvent.call(void 0, element, event);
40
+ await _CR7E273Fcjs.flushMicrotasks.call(void 0, );
41
+ return defaultAllowed;
42
+ });
43
+ }
44
+ var events = _misc.getKeys.call(void 0, _dom.fireEvent).reduce((events2, eventName) => {
45
+ events2[eventName] = (element, options) => {
46
+ _misc.invariant.call(void 0, element, `Unable to dispatch ${eventName} on null element`);
47
+ const event = _dom.createEvent[eventName](element, options);
48
+ return baseDispatch(element, event);
49
+ };
50
+ return events2;
51
+ }, {});
52
+ var dispatch = Object.assign(baseDispatch, events);
53
+
54
+
55
+
56
+ exports.dispatch = dispatch;
@@ -0,0 +1,70 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/__utils.ts
2
+ var _focus = require('@ariakit/core/utils/focus');
3
+ var _misc = require('@ariakit/core/utils/misc');
4
+ var isBrowser = typeof navigator !== "undefined" && !navigator.userAgent.includes("jsdom") && typeof window !== "undefined" && !("happyDOM" in window);
5
+ async function flushMicrotasks() {
6
+ await Promise.resolve();
7
+ await Promise.resolve();
8
+ await Promise.resolve();
9
+ }
10
+ function nextFrame() {
11
+ return new Promise(requestAnimationFrame);
12
+ }
13
+ function setActEnvironment(value) {
14
+ const scope = globalThis;
15
+ const previousValue = scope.IS_REACT_ACT_ENVIRONMENT;
16
+ scope.IS_REACT_ACT_ENVIRONMENT = value;
17
+ const restoreActEnvironment = () => {
18
+ scope.IS_REACT_ACT_ENVIRONMENT = previousValue;
19
+ };
20
+ return restoreActEnvironment;
21
+ }
22
+ function applyBrowserPolyfills() {
23
+ if (isBrowser)
24
+ return _misc.noop;
25
+ const originalFocus = HTMLElement.prototype.focus;
26
+ HTMLElement.prototype.focus = function focus(options) {
27
+ if (!_focus.isFocusable.call(void 0, this))
28
+ return;
29
+ return originalFocus.call(this, options);
30
+ };
31
+ const originalGetClientRects = Element.prototype.getClientRects;
32
+ Element.prototype.getClientRects = function getClientRects() {
33
+ const isHidden = (element) => {
34
+ if (!element.isConnected)
35
+ return true;
36
+ if (element.parentElement && isHidden(element.parentElement))
37
+ return true;
38
+ if (!(element instanceof HTMLElement))
39
+ return false;
40
+ if (element.hidden)
41
+ return true;
42
+ const style = getComputedStyle(element);
43
+ return style.display === "none" || style.visibility === "hidden";
44
+ };
45
+ if (isHidden(this))
46
+ return [];
47
+ return [{ width: 1, height: 1 }];
48
+ };
49
+ return () => {
50
+ HTMLElement.prototype.focus = originalFocus;
51
+ Element.prototype.getClientRects = originalGetClientRects;
52
+ };
53
+ }
54
+ async function wrapAsync(fn) {
55
+ const restoreActEnvironment = setActEnvironment(false);
56
+ const removeBrowserPolyfills = applyBrowserPolyfills();
57
+ try {
58
+ return await fn();
59
+ } finally {
60
+ restoreActEnvironment();
61
+ removeBrowserPolyfills();
62
+ }
63
+ }
64
+
65
+
66
+
67
+
68
+
69
+
70
+ exports.isBrowser = isBrowser; exports.flushMicrotasks = flushMicrotasks; exports.nextFrame = nextFrame; exports.wrapAsync = wrapAsync;
@@ -1,21 +1,21 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _Q7PN3HIBcjs = require('./Q7PN3HIB.cjs');
3
+ var _OUXW5FPVcjs = require('./OUXW5FPV.cjs');
4
4
 
5
5
 
6
- var _BHNBCXUNcjs = require('./BHNBCXUN.cjs');
6
+ var _HNXGMK5Pcjs = require('./HNXGMK5P.cjs');
7
7
 
8
8
 
9
- var _B4VP2LEUcjs = require('./B4VP2LEU.cjs');
9
+ var _R7VOUI26cjs = require('./R7VOUI26.cjs');
10
10
 
11
11
 
12
- var _KRQVK4KQcjs = require('./KRQVK4KQ.cjs');
12
+ var _6WHWNYHFcjs = require('./6WHWNYHF.cjs');
13
13
 
14
14
 
15
- var _7RUXTAPPcjs = require('./7RUXTAPP.cjs');
15
+ var _473V5JUAcjs = require('./473V5JUA.cjs');
16
16
 
17
17
 
18
- var _3WW644T7cjs = require('./3WW644T7.cjs');
18
+ var _CR7E273Fcjs = require('./CR7E273F.cjs');
19
19
 
20
20
 
21
21
  var _PKWBCPZUcjs = require('./PKWBCPZU.cjs');
@@ -35,7 +35,7 @@ var clickableInputTypes = [
35
35
  "reset",
36
36
  "submit"
37
37
  ];
38
- function submitFormByPressingEnterOn(element, options) {
38
+ async function submitFormByPressingEnterOn(element, options) {
39
39
  const { form } = element;
40
40
  if (!form)
41
41
  return;
@@ -47,40 +47,40 @@ function submitFormByPressingEnterOn(element, options) {
47
47
  (el) => (el instanceof HTMLInputElement || el instanceof HTMLButtonElement) && el.type === "submit"
48
48
  );
49
49
  if (validInputs.length === 1 || submitButton) {
50
- _KRQVK4KQcjs.fireEvent.submit(form, options);
50
+ await _6WHWNYHFcjs.dispatch.submit(form, options);
51
51
  }
52
52
  }
53
53
  function isNumberInput(element) {
54
54
  return element instanceof HTMLInputElement && element.type === "number";
55
55
  }
56
- function incrementNumberInput(element, by = 1) {
56
+ async function incrementNumberInput(element, by = 1) {
57
57
  const value = +element.value + by;
58
58
  const max = element.max ? +element.max : Number.MAX_SAFE_INTEGER;
59
59
  const min = element.min ? +element.min : Number.MIN_SAFE_INTEGER;
60
60
  if (value > max || value < min)
61
61
  return;
62
62
  element.value = value.toString();
63
- _KRQVK4KQcjs.fireEvent.input(element);
64
- _KRQVK4KQcjs.fireEvent.change(element);
63
+ await _6WHWNYHFcjs.dispatch.input(element);
64
+ await _6WHWNYHFcjs.dispatch.change(element);
65
65
  }
66
66
  var keyDownMap = {
67
- Tab(_, { shiftKey }) {
67
+ async Tab(_, { shiftKey }) {
68
68
  const nextElement = shiftKey ? _focus.getPreviousTabbable.call(void 0, ) : _focus.getNextTabbable.call(void 0, );
69
69
  if (nextElement) {
70
- _B4VP2LEUcjs.focus.call(void 0, nextElement);
70
+ await _R7VOUI26cjs.focus.call(void 0, nextElement);
71
71
  }
72
72
  },
73
- Enter(element, options) {
73
+ async Enter(element, options) {
74
74
  const nonSubmittableTypes = [...clickableInputTypes, "hidden"];
75
75
  const isClickable = element.tagName === "BUTTON" || element instanceof HTMLInputElement && clickableInputTypes.includes(element.type);
76
76
  const isSubmittable = element instanceof HTMLInputElement && !nonSubmittableTypes.includes(element.type);
77
77
  if (isClickable) {
78
- _KRQVK4KQcjs.fireEvent.click(element, options);
78
+ await _6WHWNYHFcjs.dispatch.click(element, options);
79
79
  } else if (isSubmittable) {
80
- submitFormByPressingEnterOn(element, options);
80
+ await submitFormByPressingEnterOn(element, options);
81
81
  }
82
82
  },
83
- ArrowLeft(element, { shiftKey }) {
83
+ async ArrowLeft(element, { shiftKey }) {
84
84
  if (_dom.isTextField.call(void 0, element)) {
85
85
  const { value, selectionStart, selectionEnd, selectionDirection } = element;
86
86
  const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
@@ -94,7 +94,7 @@ var keyDownMap = {
94
94
  );
95
95
  }
96
96
  },
97
- ArrowRight(element, { shiftKey }) {
97
+ async ArrowRight(element, { shiftKey }) {
98
98
  if (_dom.isTextField.call(void 0, element)) {
99
99
  const { value, selectionStart, selectionEnd, selectionDirection } = element;
100
100
  const [start, end] = [selectionStart != null ? selectionStart : 0, selectionEnd != null ? selectionEnd : 0];
@@ -108,7 +108,7 @@ var keyDownMap = {
108
108
  );
109
109
  }
110
110
  },
111
- ArrowUp(element, { shiftKey }) {
111
+ async ArrowUp(element, { shiftKey }) {
112
112
  if (_dom.isTextField.call(void 0, element)) {
113
113
  if (!shiftKey) {
114
114
  return element.setSelectionRange(0, 0);
@@ -122,10 +122,10 @@ var keyDownMap = {
122
122
  }
123
123
  }
124
124
  } else if (isNumberInput(element)) {
125
- incrementNumberInput(element);
125
+ await incrementNumberInput(element);
126
126
  }
127
127
  },
128
- ArrowDown(element, { shiftKey }) {
128
+ async ArrowDown(element, { shiftKey }) {
129
129
  if (_dom.isTextField.call(void 0, element)) {
130
130
  const length = element.value.length;
131
131
  if (!shiftKey) {
@@ -140,65 +140,65 @@ var keyDownMap = {
140
140
  }
141
141
  }
142
142
  } else if (isNumberInput(element)) {
143
- incrementNumberInput(element, -1);
143
+ await incrementNumberInput(element, -1);
144
144
  }
145
145
  }
146
146
  };
147
147
  var keyUpMap = {
148
148
  // Space
149
- " ": (element, options) => {
149
+ " ": async (element, options) => {
150
150
  const spaceableTypes = [...clickableInputTypes, "checkbox", "radio"];
151
151
  const isSpaceable = element.tagName === "BUTTON" || element instanceof HTMLInputElement && spaceableTypes.includes(element.type);
152
152
  if (isSpaceable) {
153
- _KRQVK4KQcjs.fireEvent.click(element, options);
153
+ await _6WHWNYHFcjs.dispatch.click(element, options);
154
154
  }
155
155
  }
156
156
  };
157
- async function press(key, element, options = {}) {
158
- var _a, _b, _c, _d;
159
- if (element == null) {
160
- element = document.activeElement || document.body;
161
- }
162
- if (!element)
163
- return;
164
- if (!_focus.isFocusable.call(void 0, element) && element.tagName !== "BODY")
165
- return;
166
- if (_dom.isTextField.call(void 0, element)) {
167
- if (key.length === 1) {
168
- return _Q7PN3HIBcjs.type.call(void 0, key, element, options);
169
- } else if (key === "Delete") {
170
- return _Q7PN3HIBcjs.type.call(void 0, "\x7F", element, options);
171
- } else if (key === "Backspace") {
172
- return _Q7PN3HIBcjs.type.call(void 0, "\b", element, options);
173
- } else if (key === "Enter" && element.tagName === "TEXTAREA") {
174
- return _Q7PN3HIBcjs.type.call(void 0, "\n", element, options);
157
+ function press(key, element, options = {}) {
158
+ return _CR7E273Fcjs.wrapAsync.call(void 0, async () => {
159
+ var _a, _b, _c, _d;
160
+ if (element == null) {
161
+ element = document.activeElement || document.body;
175
162
  }
176
- }
177
- if (((_a = element.ownerDocument) == null ? void 0 : _a.activeElement) !== element) {
178
- if (element.tagName === "BODY") {
179
- _BHNBCXUNcjs.blur.call(void 0, );
180
- } else {
181
- _B4VP2LEUcjs.focus.call(void 0, element);
163
+ if (!element)
164
+ return;
165
+ if (!_focus.isFocusable.call(void 0, element) && element.tagName !== "BODY")
166
+ return;
167
+ if (_dom.isTextField.call(void 0, element)) {
168
+ if (key.length === 1) {
169
+ return _OUXW5FPVcjs.type.call(void 0, key, element, options);
170
+ } else if (key === "Delete") {
171
+ return _OUXW5FPVcjs.type.call(void 0, "\x7F", element, options);
172
+ } else if (key === "Backspace") {
173
+ return _OUXW5FPVcjs.type.call(void 0, "\b", element, options);
174
+ } else if (key === "Enter" && element.tagName === "TEXTAREA") {
175
+ return _OUXW5FPVcjs.type.call(void 0, "\n", element, options);
176
+ }
182
177
  }
183
- }
184
- await _7RUXTAPPcjs.sleep.call(void 0, );
185
- let defaultAllowed = _KRQVK4KQcjs.fireEvent.keyDown(element, _PKWBCPZUcjs.__spreadValues.call(void 0, { key }, options));
186
- await _3WW644T7cjs.queuedMicrotasks.call(void 0, );
187
- if (defaultAllowed && key in keyDownMap && !options.metaKey) {
188
- (_b = keyDownMap[key]) == null ? void 0 : _b.call(keyDownMap, element, options);
189
- }
190
- await _7RUXTAPPcjs.sleep.call(void 0, );
191
- if (((_c = element.ownerDocument) == null ? void 0 : _c.activeElement) !== element) {
192
- element = element.ownerDocument.activeElement;
193
- }
194
- if (!_KRQVK4KQcjs.fireEvent.keyUp(element, _PKWBCPZUcjs.__spreadValues.call(void 0, { key }, options))) {
195
- defaultAllowed = false;
196
- }
197
- await _3WW644T7cjs.queuedMicrotasks.call(void 0, );
198
- if (defaultAllowed && key in keyUpMap && !options.metaKey) {
199
- (_d = keyUpMap[key]) == null ? void 0 : _d.call(keyUpMap, element, options);
200
- }
201
- await _7RUXTAPPcjs.sleep.call(void 0, );
178
+ if (((_a = element.ownerDocument) == null ? void 0 : _a.activeElement) !== element) {
179
+ if (element.tagName === "BODY") {
180
+ await _HNXGMK5Pcjs.blur.call(void 0, );
181
+ } else {
182
+ await _R7VOUI26cjs.focus.call(void 0, element);
183
+ }
184
+ }
185
+ await _473V5JUAcjs.sleep.call(void 0, );
186
+ let defaultAllowed = await _6WHWNYHFcjs.dispatch.keyDown(element, _PKWBCPZUcjs.__spreadValues.call(void 0, { key }, options));
187
+ if (defaultAllowed && key in keyDownMap && !options.metaKey) {
188
+ await ((_b = keyDownMap[key]) == null ? void 0 : _b.call(keyDownMap, element, options));
189
+ }
190
+ await _473V5JUAcjs.sleep.call(void 0, );
191
+ if (((_c = element.ownerDocument) == null ? void 0 : _c.activeElement) !== element) {
192
+ element = element.ownerDocument.activeElement;
193
+ }
194
+ if (!await _6WHWNYHFcjs.dispatch.keyUp(element, _PKWBCPZUcjs.__spreadValues.call(void 0, { key }, options))) {
195
+ defaultAllowed = false;
196
+ }
197
+ if (defaultAllowed && key in keyUpMap && !options.metaKey) {
198
+ await ((_d = keyUpMap[key]) == null ? void 0 : _d.call(keyUpMap, element, options));
199
+ }
200
+ await _473V5JUAcjs.sleep.call(void 0, );
201
+ });
202
202
  }
203
203
  function createPress(key, defaultOptions = {}) {
204
204
  return (element, options = {}) => press(key, element, _PKWBCPZUcjs.__spreadValues.call(void 0, _PKWBCPZUcjs.__spreadValues.call(void 0, {}, defaultOptions), options));
@@ -0,0 +1,35 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _6WHWNYHFcjs = require('./6WHWNYHF.cjs');
4
+
5
+
6
+
7
+ var _CR7E273Fcjs = require('./CR7E273F.cjs');
8
+
9
+ // src/blur.ts
10
+ var _dom = require('@ariakit/core/utils/dom');
11
+ function blur(element) {
12
+ return _CR7E273Fcjs.wrapAsync.call(void 0, async () => {
13
+ if (element == null) {
14
+ element = document.activeElement;
15
+ }
16
+ if (!element)
17
+ return;
18
+ if (element.tagName === "BODY")
19
+ return;
20
+ if (_dom.getActiveElement.call(void 0, element) !== element)
21
+ return;
22
+ if (element.dirty) {
23
+ await _6WHWNYHFcjs.dispatch.change(element);
24
+ element.dirty = false;
25
+ }
26
+ if (element instanceof HTMLElement || element instanceof SVGElement) {
27
+ element.blur();
28
+ await _CR7E273Fcjs.flushMicrotasks.call(void 0, );
29
+ }
30
+ });
31
+ }
32
+
33
+
34
+
35
+ exports.blur = blur;
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _MWZXO7MIcjs = require('./MWZXO7MI.cjs');
4
+
5
+ // src/tap.ts
6
+ function tap(element, options) {
7
+ return _MWZXO7MIcjs.click.call(void 0, element, options, true);
8
+ }
9
+
10
+
11
+
12
+ exports.tap = tap;