@ariakit/test 0.2.5 → 0.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.
Files changed (187) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/cjs/__chunks/2KXSRUIV.cjs +205 -0
  3. package/cjs/__chunks/747HORQZ.cjs +30 -0
  4. package/cjs/__chunks/A5IFXY4J.cjs +33 -0
  5. package/cjs/__chunks/DAHHEUOU.cjs +95 -0
  6. package/cjs/__chunks/{2V5PIRJZ.cjs → ESE7QHAQ.cjs} +71 -70
  7. package/cjs/__chunks/FU2U6RZL.cjs +57 -0
  8. package/cjs/__chunks/I2BROIQW.cjs +1 -0
  9. package/cjs/__chunks/KVNENCXT.cjs +36 -0
  10. package/cjs/__chunks/LYOKT276.cjs +69 -0
  11. package/cjs/__chunks/NIEATM7R.cjs +20 -0
  12. package/cjs/__chunks/{PKWBCPZU.cjs → OVN5OYWK.cjs} +2 -1
  13. package/cjs/__chunks/{LUIPCXQX.cjs → PJWPDIUX.cjs} +48 -44
  14. package/cjs/__chunks/SDUGTL2N.cjs +13 -0
  15. package/cjs/__chunks/SEWCIANI.cjs +14 -0
  16. package/cjs/__chunks/T5KVOIJT.cjs +58 -0
  17. package/cjs/__chunks/VZINRVVH.cjs +126 -0
  18. package/cjs/__chunks/ZMMVJ3OT.cjs +72 -0
  19. package/cjs/__tests__/use-all-events.d.cts +1 -0
  20. package/cjs/__utils.d.cts +11 -0
  21. package/cjs/__utils.d.ts +6 -3
  22. package/cjs/blur.cjs +7 -8
  23. package/cjs/blur.d.cts +2 -0
  24. package/cjs/blur.d.ts +1 -2
  25. package/cjs/click.cjs +13 -14
  26. package/cjs/click.d.cts +1 -0
  27. package/cjs/click.d.ts +1 -2
  28. package/cjs/dispatch.cjs +9 -0
  29. package/cjs/dispatch.d.cts +9 -0
  30. package/cjs/dispatch.d.ts +9 -0
  31. package/cjs/focus.cjs +7 -8
  32. package/cjs/focus.d.cts +1 -0
  33. package/cjs/focus.d.ts +1 -2
  34. package/cjs/hover.cjs +8 -9
  35. package/cjs/hover.d.cts +1 -0
  36. package/cjs/hover.d.ts +1 -2
  37. package/cjs/index.cjs +19 -76
  38. package/cjs/index.d.cts +14 -0
  39. package/cjs/index.d.ts +2 -5
  40. package/cjs/mouse-down.cjs +9 -10
  41. package/cjs/mouse-down.d.cts +1 -0
  42. package/cjs/mouse-down.d.ts +1 -2
  43. package/cjs/mouse-up.cjs +7 -7
  44. package/cjs/mouse-up.d.cts +1 -0
  45. package/cjs/mouse-up.d.ts +1 -2
  46. package/cjs/press.cjs +11 -12
  47. package/cjs/press.d.cts +18 -0
  48. package/cjs/press.d.ts +0 -1
  49. package/cjs/query.cjs +10 -0
  50. package/cjs/query.d.cts +3989 -0
  51. package/cjs/query.d.ts +3989 -0
  52. package/cjs/react.cjs +90 -0
  53. package/cjs/react.d.cts +7 -0
  54. package/cjs/react.d.ts +7 -0
  55. package/cjs/select.cjs +13 -14
  56. package/cjs/select.d.cts +1 -0
  57. package/cjs/select.d.ts +1 -2
  58. package/cjs/sleep.cjs +6 -6
  59. package/cjs/sleep.d.cts +1 -0
  60. package/cjs/tap.cjs +14 -15
  61. package/cjs/tap.d.cts +1 -0
  62. package/cjs/tap.d.ts +1 -2
  63. package/cjs/type.cjs +9 -10
  64. package/cjs/type.d.cts +2 -0
  65. package/cjs/type.d.ts +0 -1
  66. package/cjs/wait-for.cjs +6 -4
  67. package/cjs/wait-for.d.cts +2 -0
  68. package/cjs/wait-for.d.ts +2 -1
  69. package/dispatch/package.json +8 -0
  70. package/esm/__chunks/{SWUQE4WB.js → 5DPK2YAQ.js} +48 -44
  71. package/esm/__chunks/7JP5HWUW.js +57 -0
  72. package/esm/__chunks/ANPGABTJ.js +69 -0
  73. package/esm/__chunks/H3BXHZTZ.js +95 -0
  74. package/esm/__chunks/HUBUFZ3U.js +205 -0
  75. package/esm/__chunks/HVRX3U4O.js +126 -0
  76. package/esm/__chunks/LHKK7Y5F.js +72 -0
  77. package/esm/__chunks/LSH2PT34.js +30 -0
  78. package/esm/__chunks/MKNCAN2F.js +13 -0
  79. package/esm/__chunks/{6XO5G2QR.js → Q65FZOE2.js} +1 -0
  80. package/esm/__chunks/RG2JKALK.js +58 -0
  81. package/esm/__chunks/RHBNMDK4.js +1 -0
  82. package/esm/__chunks/{6PY4HXVO.js → UJCT5GXS.js} +71 -70
  83. package/esm/__chunks/WAYMNUAF.js +33 -0
  84. package/esm/__chunks/WLDGXXGP.js +14 -0
  85. package/esm/__chunks/YNAZUNNE.js +20 -0
  86. package/esm/__chunks/ZIWQZF7I.js +36 -0
  87. package/esm/__utils.d.ts +6 -3
  88. package/esm/blur.d.ts +1 -2
  89. package/esm/blur.js +5 -6
  90. package/esm/click.d.ts +1 -2
  91. package/esm/click.js +11 -12
  92. package/esm/dispatch.d.ts +9 -0
  93. package/esm/dispatch.js +9 -0
  94. package/esm/focus.d.ts +1 -2
  95. package/esm/focus.js +5 -6
  96. package/esm/hover.d.ts +1 -2
  97. package/esm/hover.js +6 -7
  98. package/esm/index.d.ts +2 -5
  99. package/esm/index.js +31 -88
  100. package/esm/mouse-down.d.ts +1 -2
  101. package/esm/mouse-down.js +7 -8
  102. package/esm/mouse-up.d.ts +1 -2
  103. package/esm/mouse-up.js +5 -5
  104. package/esm/press.d.ts +0 -1
  105. package/esm/press.js +9 -10
  106. package/esm/query.d.ts +3989 -0
  107. package/esm/query.js +10 -0
  108. package/esm/react.d.ts +7 -0
  109. package/esm/react.js +90 -0
  110. package/esm/select.d.ts +1 -2
  111. package/esm/select.js +11 -12
  112. package/esm/sleep.js +4 -4
  113. package/esm/tap.d.ts +1 -2
  114. package/esm/tap.js +12 -13
  115. package/esm/type.d.ts +0 -1
  116. package/esm/type.js +7 -8
  117. package/esm/wait-for.d.ts +2 -1
  118. package/esm/wait-for.js +4 -2
  119. package/package.json +85 -40
  120. package/query/package.json +8 -0
  121. package/react/package.json +8 -0
  122. package/act/package.json +0 -8
  123. package/cjs/__chunks/3NIZQX5J.cjs +0 -6
  124. package/cjs/__chunks/3WW644T7.cjs +0 -20
  125. package/cjs/__chunks/5F5PNQCC.cjs +0 -22
  126. package/cjs/__chunks/7BZFO6FC.cjs +0 -12
  127. package/cjs/__chunks/7RUXTAPP.cjs +0 -16
  128. package/cjs/__chunks/AYRPODWR.cjs +0 -1
  129. package/cjs/__chunks/B4VP2LEU.cjs +0 -28
  130. package/cjs/__chunks/BHNBCXUN.cjs +0 -33
  131. package/cjs/__chunks/EGF4KWUK.cjs +0 -64
  132. package/cjs/__chunks/HGTTGPFK.cjs +0 -54
  133. package/cjs/__chunks/JY5DGPUE.cjs +0 -14
  134. package/cjs/__chunks/KRQVK4KQ.cjs +0 -38
  135. package/cjs/__chunks/LFNIGEB6.cjs +0 -50
  136. package/cjs/__chunks/MQA5IB4L.cjs +0 -6
  137. package/cjs/__chunks/Q7PN3HIB.cjs +0 -121
  138. package/cjs/__chunks/SYQ5J5KP.cjs +0 -32
  139. package/cjs/__chunks/VIKUJSTX.cjs +0 -83
  140. package/cjs/act.cjs +0 -8
  141. package/cjs/act.d.ts +0 -1
  142. package/cjs/fire-event.cjs +0 -9
  143. package/cjs/fire-event.d.ts +0 -3
  144. package/cjs/polyfills.cjs +0 -3
  145. package/cjs/render.cjs +0 -9
  146. package/cjs/render.d.ts +0 -5
  147. package/cjs/screen.cjs +0 -55
  148. package/cjs/screen.d.ts +0 -26
  149. package/cjs/tsconfig.build.tsbuildinfo +0 -1
  150. package/cjs/within.cjs +0 -7
  151. package/cjs/within.d.ts +0 -1
  152. package/esm/__chunks/2OZA4WAZ.js +0 -50
  153. package/esm/__chunks/2RHTJFSK.js +0 -38
  154. package/esm/__chunks/3C72DPE2.js +0 -54
  155. package/esm/__chunks/4A3YKZRA.js +0 -121
  156. package/esm/__chunks/5JPM5LQX.js +0 -6
  157. package/esm/__chunks/5PINJ4MD.js +0 -16
  158. package/esm/__chunks/AEOE57TZ.js +0 -33
  159. package/esm/__chunks/EVYPE6ZJ.js +0 -32
  160. package/esm/__chunks/EX5WPJOU.js +0 -64
  161. package/esm/__chunks/JTFRQL3H.js +0 -83
  162. package/esm/__chunks/LJWZLI6L.js +0 -14
  163. package/esm/__chunks/OQYWQML5.js +0 -12
  164. package/esm/__chunks/OSCTTZUZ.js +0 -28
  165. package/esm/__chunks/PNBZ5NXH.js +0 -0
  166. package/esm/__chunks/QA3ZS6S2.js +0 -6
  167. package/esm/__chunks/R7IYW63J.js +0 -22
  168. package/esm/__chunks/ZEO5Q6UD.js +0 -20
  169. package/esm/act.d.ts +0 -1
  170. package/esm/act.js +0 -8
  171. package/esm/fire-event.d.ts +0 -3
  172. package/esm/fire-event.js +0 -9
  173. package/esm/polyfills.d.ts +0 -1
  174. package/esm/polyfills.js +0 -3
  175. package/esm/render.d.ts +0 -5
  176. package/esm/render.js +0 -9
  177. package/esm/screen.d.ts +0 -26
  178. package/esm/screen.js +0 -55
  179. package/esm/tsconfig.build.tsbuildinfo +0 -1
  180. package/esm/within.d.ts +0 -1
  181. package/esm/within.js +0 -7
  182. package/fire-event/package.json +0 -8
  183. package/polyfills/package.json +0 -8
  184. package/render/package.json +0 -8
  185. package/screen/package.json +0 -8
  186. package/within/package.json +0 -8
  187. /package/cjs/{polyfills.d.ts → __tests__/blur-test.d.cts} +0 -0
@@ -0,0 +1,57 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+
5
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
6
+
7
+ // src/dispatch.ts
8
+ var _misc = require('@ariakit/core/utils/misc');
9
+ var _dom = require('@testing-library/dom');
10
+ var pointerEvents = [
11
+ "mousemove",
12
+ "mouseover",
13
+ "mouseenter",
14
+ "mouseout",
15
+ "mouseleave",
16
+ "mousedown",
17
+ "mouseup",
18
+ "pointermove",
19
+ "pointerover",
20
+ "pointerenter",
21
+ "pointerout",
22
+ "pointerleave",
23
+ "pointerdown",
24
+ "pointerup",
25
+ "click"
26
+ ];
27
+ function baseDispatch(element, event) {
28
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
29
+ _misc.invariant.call(void 0, element, `Unable to dispatch ${event.type} on null element`);
30
+ const eventName = event.type.toLowerCase();
31
+ if (pointerEvents.includes(eventName) && "classList" in element) {
32
+ const { pointerEvents: pointerEvents2 } = getComputedStyle(element);
33
+ if (pointerEvents2 === "none") {
34
+ if (element.parentElement) {
35
+ return baseDispatch(element.parentElement, event);
36
+ }
37
+ return true;
38
+ }
39
+ }
40
+ const defaultAllowed = _dom.fireEvent.call(void 0, element, event);
41
+ await _ZMMVJ3OTcjs.flushMicrotasks.call(void 0, );
42
+ return defaultAllowed;
43
+ });
44
+ }
45
+ var events = _misc.getKeys.call(void 0, _dom.fireEvent).reduce((events2, eventName) => {
46
+ events2[eventName] = (element, options) => {
47
+ _misc.invariant.call(void 0, element, `Unable to dispatch ${eventName} on null element`);
48
+ const event = _dom.createEvent[eventName](element, options);
49
+ return baseDispatch(element, event);
50
+ };
51
+ return events2;
52
+ }, {});
53
+ var dispatch = Object.assign(baseDispatch, events);
54
+
55
+
56
+
57
+ exports.dispatch = dispatch;
@@ -0,0 +1 @@
1
+ "use strict";"use client";
@@ -0,0 +1,36 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _FU2U6RZLcjs = require('./FU2U6RZL.cjs');
5
+
6
+
7
+
8
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
9
+
10
+ // src/blur.ts
11
+ var _dom = require('@ariakit/core/utils/dom');
12
+ function blur(element) {
13
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
14
+ if (element == null) {
15
+ element = document.activeElement;
16
+ }
17
+ if (!element)
18
+ return;
19
+ if (element.tagName === "BODY")
20
+ return;
21
+ if (_dom.getActiveElement.call(void 0, element) !== element)
22
+ return;
23
+ if (element.dirty) {
24
+ await _FU2U6RZLcjs.dispatch.change(element);
25
+ element.dirty = false;
26
+ }
27
+ if (element instanceof HTMLElement || element instanceof SVGElement) {
28
+ element.blur();
29
+ await _ZMMVJ3OTcjs.flushMicrotasks.call(void 0, );
30
+ }
31
+ });
32
+ }
33
+
34
+
35
+
36
+ exports.blur = blur;
@@ -0,0 +1,69 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _FU2U6RZLcjs = require('./FU2U6RZL.cjs');
5
+
6
+
7
+ var _NIEATM7Rcjs = require('./NIEATM7R.cjs');
8
+
9
+
10
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
11
+
12
+
13
+
14
+ var _OVN5OYWKcjs = require('./OVN5OYWK.cjs');
15
+
16
+ // src/hover.ts
17
+ var _dom = require('@ariakit/core/utils/dom');
18
+ var _misc = require('@ariakit/core/utils/misc');
19
+ function isPointerEventsEnabled(element) {
20
+ return getComputedStyle(element).pointerEvents !== "none";
21
+ }
22
+ function hover(element, options) {
23
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
24
+ _misc.invariant.call(void 0, element, "Unable to hover on null element");
25
+ if (!_dom.isVisible.call(void 0, element))
26
+ return;
27
+ const document = element.ownerDocument;
28
+ const { lastHovered } = document;
29
+ const { disabled } = element;
30
+ const pointerEventsEnabled = isPointerEventsEnabled(element);
31
+ if (lastHovered && lastHovered !== element && _dom.isVisible.call(void 0, lastHovered)) {
32
+ await _FU2U6RZLcjs.dispatch.pointerMove(lastHovered, options);
33
+ await _FU2U6RZLcjs.dispatch.mouseMove(lastHovered, options);
34
+ if (isPointerEventsEnabled(lastHovered)) {
35
+ const isElementWithinLastHovered = lastHovered.contains(element);
36
+ const relatedTarget = pointerEventsEnabled ? element : null;
37
+ const leaveOptions = _OVN5OYWKcjs.__spreadProps.call(void 0, _OVN5OYWKcjs.__spreadValues.call(void 0, {}, options), { relatedTarget });
38
+ await _FU2U6RZLcjs.dispatch.pointerOut(lastHovered, leaveOptions);
39
+ if (!isElementWithinLastHovered) {
40
+ await _FU2U6RZLcjs.dispatch.pointerLeave(lastHovered, leaveOptions);
41
+ }
42
+ await _FU2U6RZLcjs.dispatch.mouseOut(lastHovered, leaveOptions);
43
+ if (!isElementWithinLastHovered) {
44
+ await _FU2U6RZLcjs.dispatch.mouseLeave(lastHovered, leaveOptions);
45
+ }
46
+ }
47
+ }
48
+ await _NIEATM7Rcjs.sleep.call(void 0, );
49
+ if (pointerEventsEnabled) {
50
+ const enterOptions = lastHovered ? _OVN5OYWKcjs.__spreadValues.call(void 0, { relatedTarget: lastHovered }, options) : options;
51
+ await _FU2U6RZLcjs.dispatch.pointerOver(element, enterOptions);
52
+ await _FU2U6RZLcjs.dispatch.pointerEnter(element, enterOptions);
53
+ if (!disabled) {
54
+ await _FU2U6RZLcjs.dispatch.mouseOver(element, enterOptions);
55
+ await _FU2U6RZLcjs.dispatch.mouseEnter(element, enterOptions);
56
+ }
57
+ }
58
+ await _FU2U6RZLcjs.dispatch.pointerMove(element, options);
59
+ if (!disabled) {
60
+ await _FU2U6RZLcjs.dispatch.mouseMove(element, options);
61
+ }
62
+ document.lastHovered = element;
63
+ await _NIEATM7Rcjs.sleep.call(void 0, );
64
+ });
65
+ }
66
+
67
+
68
+
69
+ exports.hover = hover;
@@ -0,0 +1,20 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+
5
+
6
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
7
+
8
+ // src/sleep.ts
9
+ var defaultMs = _ZMMVJ3OTcjs.isBrowser ? 150 : 10;
10
+ function sleep(ms = defaultMs) {
11
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
12
+ await _ZMMVJ3OTcjs.nextFrame.call(void 0, );
13
+ await new Promise((resolve) => setTimeout(resolve, ms));
14
+ await _ZMMVJ3OTcjs.nextFrame.call(void 0, );
15
+ });
16
+ }
17
+
18
+
19
+
20
+ exports.sleep = sleep;
@@ -1,4 +1,5 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+ var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
5
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -1,31 +1,33 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- var _5F5PNQCCcjs = require('./5F5PNQCC.cjs');
4
3
 
4
+ var _747HORQZcjs = require('./747HORQZ.cjs');
5
5
 
6
- var _LFNIGEB6cjs = require('./LFNIGEB6.cjs');
7
6
 
7
+ var _T5KVOIJTcjs = require('./T5KVOIJT.cjs');
8
8
 
9
- var _EGF4KWUKcjs = require('./EGF4KWUK.cjs');
10
9
 
10
+ var _LYOKT276cjs = require('./LYOKT276.cjs');
11
11
 
12
- var _B4VP2LEUcjs = require('./B4VP2LEU.cjs');
13
12
 
13
+ var _A5IFXY4Jcjs = require('./A5IFXY4J.cjs');
14
14
 
15
- var _KRQVK4KQcjs = require('./KRQVK4KQ.cjs');
16
15
 
16
+ var _FU2U6RZLcjs = require('./FU2U6RZL.cjs');
17
17
 
18
- var _7RUXTAPPcjs = require('./7RUXTAPP.cjs');
19
18
 
19
+ var _NIEATM7Rcjs = require('./NIEATM7R.cjs');
20
20
 
21
- var _3WW644T7cjs = require('./3WW644T7.cjs');
22
21
 
22
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
23
23
 
24
- var _PKWBCPZUcjs = require('./PKWBCPZU.cjs');
24
+
25
+ var _OVN5OYWKcjs = require('./OVN5OYWK.cjs');
25
26
 
26
27
  // src/click.ts
27
28
  var _dom = require('@ariakit/core/utils/dom');
28
29
  var _focus = require('@ariakit/core/utils/focus');
30
+ var _misc = require('@ariakit/core/utils/misc');
29
31
  function getClosestLabel(element) {
30
32
  if (!_focus.isFocusable.call(void 0, element)) {
31
33
  return _dom.closest.call(void 0, element, "label");
@@ -37,18 +39,18 @@ function getInputFromLabel(element) {
37
39
  const input = element.htmlFor ? (_a = element.ownerDocument) == null ? void 0 : _a.getElementById(element.htmlFor) : element.querySelector("input,textarea,select");
38
40
  return input;
39
41
  }
40
- function clickLabel(element, options) {
42
+ async function clickLabel(element, options) {
41
43
  const input = getInputFromLabel(element);
42
44
  const isInputDisabled = Boolean(input == null ? void 0 : input.disabled);
43
45
  if (input) {
44
46
  input.disabled = true;
45
47
  }
46
- const defaultAllowed = _KRQVK4KQcjs.fireEvent.click(element, options);
48
+ const defaultAllowed = await _FU2U6RZLcjs.dispatch.click(element, options);
47
49
  if (input) {
48
50
  input.disabled = isInputDisabled;
49
51
  if (defaultAllowed && _focus.isFocusable.call(void 0, input)) {
50
- _B4VP2LEUcjs.focus.call(void 0, input);
51
- _KRQVK4KQcjs.fireEvent.click(input);
52
+ await _A5IFXY4Jcjs.focus.call(void 0, input);
53
+ await _FU2U6RZLcjs.dispatch.click(input);
52
54
  }
53
55
  }
54
56
  }
@@ -56,10 +58,10 @@ function setSelected(element, selected) {
56
58
  element.setAttribute("selected", selected ? "selected" : "");
57
59
  element.selected = selected;
58
60
  }
59
- function clickOption(element, eventOptions) {
61
+ async function clickOption(element, eventOptions) {
60
62
  const select = _dom.closest.call(void 0, element, "select");
61
63
  if (!select) {
62
- _KRQVK4KQcjs.fireEvent.click(element, eventOptions);
64
+ await _FU2U6RZLcjs.dispatch.click(element, eventOptions);
63
65
  return;
64
66
  }
65
67
  if (select.multiple) {
@@ -94,37 +96,39 @@ function clickOption(element, eventOptions) {
94
96
  } else {
95
97
  setSelected(element, true);
96
98
  }
97
- _KRQVK4KQcjs.fireEvent.input(select);
98
- _KRQVK4KQcjs.fireEvent.change(select);
99
- _KRQVK4KQcjs.fireEvent.click(element, eventOptions);
99
+ await _FU2U6RZLcjs.dispatch.input(select);
100
+ await _FU2U6RZLcjs.dispatch.change(select);
101
+ await _FU2U6RZLcjs.dispatch.click(element, eventOptions);
100
102
  }
101
- async function click(element, options, tap = false) {
102
- if (!_dom.isVisible.call(void 0, element))
103
- return;
104
- await _EGF4KWUKcjs.hover.call(void 0, element, options);
105
- _LFNIGEB6cjs.mouseDown.call(void 0, element, options);
106
- await _3WW644T7cjs.queuedMicrotasks.call(void 0, );
107
- while (!_dom.isVisible.call(void 0, element)) {
108
- if (!element.parentElement)
103
+ function click(element, options, tap = false) {
104
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
105
+ _misc.invariant.call(void 0, element, "Unable to click on null element");
106
+ if (!_dom.isVisible.call(void 0, element))
109
107
  return;
110
- element = element.parentElement;
111
- }
112
- if (!tap) {
113
- await _7RUXTAPPcjs.sleep.call(void 0, );
114
- }
115
- _5F5PNQCCcjs.mouseUp.call(void 0, element, options);
116
- const { disabled } = element;
117
- if (disabled)
118
- return;
119
- const label = getClosestLabel(element);
120
- if (label) {
121
- clickLabel(label, _PKWBCPZUcjs.__spreadValues.call(void 0, { detail: 1 }, options));
122
- } else if (element instanceof HTMLOptionElement) {
123
- clickOption(element, _PKWBCPZUcjs.__spreadValues.call(void 0, { detail: 1 }, options));
124
- } else {
125
- _KRQVK4KQcjs.fireEvent.click(element, _PKWBCPZUcjs.__spreadValues.call(void 0, { detail: 1 }, options));
126
- }
127
- await _7RUXTAPPcjs.sleep.call(void 0, );
108
+ await _LYOKT276cjs.hover.call(void 0, element, options);
109
+ await _T5KVOIJTcjs.mouseDown.call(void 0, element, options);
110
+ while (!_dom.isVisible.call(void 0, element)) {
111
+ if (!element.parentElement)
112
+ return;
113
+ element = element.parentElement;
114
+ }
115
+ if (!tap) {
116
+ await _NIEATM7Rcjs.sleep.call(void 0, );
117
+ }
118
+ await _747HORQZcjs.mouseUp.call(void 0, element, options);
119
+ const { disabled } = element;
120
+ if (disabled)
121
+ return;
122
+ const label = getClosestLabel(element);
123
+ if (label) {
124
+ await clickLabel(label, _OVN5OYWKcjs.__spreadValues.call(void 0, { detail: 1 }, options));
125
+ } else if (element instanceof HTMLOptionElement) {
126
+ await clickOption(element, _OVN5OYWKcjs.__spreadValues.call(void 0, { detail: 1 }, options));
127
+ } else {
128
+ await _FU2U6RZLcjs.dispatch.click(element, _OVN5OYWKcjs.__spreadValues.call(void 0, { detail: 1 }, options));
129
+ }
130
+ await _NIEATM7Rcjs.sleep.call(void 0, );
131
+ });
128
132
  }
129
133
 
130
134
 
@@ -0,0 +1,13 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _PJWPDIUXcjs = require('./PJWPDIUX.cjs');
5
+
6
+ // src/tap.ts
7
+ function tap(element, options) {
8
+ return _PJWPDIUXcjs.click.call(void 0, element, options, true);
9
+ }
10
+
11
+
12
+
13
+ exports.tap = tap;
@@ -0,0 +1,14 @@
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; } }"use client";
2
+
3
+
4
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
5
+
6
+ // src/wait-for.ts
7
+ var _dom = require('@testing-library/dom'); var DOMTestingLibrary = _interopRequireWildcard(_dom);
8
+ function waitFor2(callback, options) {
9
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, () => DOMTestingLibrary.waitFor(callback, options));
10
+ }
11
+
12
+
13
+
14
+ exports.waitFor = waitFor2;
@@ -0,0 +1,58 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _KVNENCXTcjs = require('./KVNENCXT.cjs');
5
+
6
+
7
+ var _A5IFXY4Jcjs = require('./A5IFXY4J.cjs');
8
+
9
+
10
+ var _FU2U6RZLcjs = require('./FU2U6RZL.cjs');
11
+
12
+
13
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
14
+
15
+
16
+ var _OVN5OYWKcjs = require('./OVN5OYWK.cjs');
17
+
18
+ // src/mouse-down.ts
19
+ var _dom = require('@ariakit/core/utils/dom');
20
+ var _focus = require('@ariakit/core/utils/focus');
21
+ var _misc = require('@ariakit/core/utils/misc');
22
+ function mouseDown(element, options) {
23
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
24
+ _misc.invariant.call(void 0, element, "Unable to mouseDown on null element");
25
+ if (!_dom.isVisible.call(void 0, element))
26
+ return;
27
+ const { disabled } = element;
28
+ let defaultAllowed = await _FU2U6RZLcjs.dispatch.pointerDown(element, options);
29
+ if (!disabled) {
30
+ if (!await _FU2U6RZLcjs.dispatch.mouseDown(element, _OVN5OYWKcjs.__spreadValues.call(void 0, { detail: 1 }, options))) {
31
+ defaultAllowed = false;
32
+ }
33
+ }
34
+ if (defaultAllowed) {
35
+ const selection = _dom.getDocument.call(void 0, element).getSelection();
36
+ if (selection && selection.rangeCount) {
37
+ const range = selection.getRangeAt(0);
38
+ if (!range.collapsed) {
39
+ selection.removeAllRanges();
40
+ }
41
+ }
42
+ if (_focus.isFocusable.call(void 0, element) && getComputedStyle(element).pointerEvents !== "none") {
43
+ await _A5IFXY4Jcjs.focus.call(void 0, element);
44
+ } else if (element.parentElement) {
45
+ const closestFocusable = _focus.getClosestFocusable.call(void 0, element.parentElement);
46
+ if (closestFocusable) {
47
+ await _A5IFXY4Jcjs.focus.call(void 0, closestFocusable);
48
+ } else {
49
+ await _KVNENCXTcjs.blur.call(void 0, );
50
+ }
51
+ }
52
+ }
53
+ });
54
+ }
55
+
56
+
57
+
58
+ exports.mouseDown = mouseDown;
@@ -0,0 +1,126 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+ var _A5IFXY4Jcjs = require('./A5IFXY4J.cjs');
5
+
6
+
7
+ var _FU2U6RZLcjs = require('./FU2U6RZL.cjs');
8
+
9
+
10
+ var _NIEATM7Rcjs = require('./NIEATM7R.cjs');
11
+
12
+
13
+ var _ZMMVJ3OTcjs = require('./ZMMVJ3OT.cjs');
14
+
15
+
16
+ var _OVN5OYWKcjs = require('./OVN5OYWK.cjs');
17
+
18
+ // src/type.ts
19
+ var _dom = require('@ariakit/core/utils/dom');
20
+ var _focus = require('@ariakit/core/utils/focus');
21
+ function getKeyFromChar(key) {
22
+ if (key === "\x7F")
23
+ return "Delete";
24
+ if (key === "\b")
25
+ return "Backspace";
26
+ if (key === "\n")
27
+ return "Enter";
28
+ if (key === " ")
29
+ return "Tab";
30
+ return key;
31
+ }
32
+ function workAroundEmailInput(element) {
33
+ const input = element;
34
+ if (input.tagName !== "INPUT" || input.type !== "email")
35
+ return () => {
36
+ };
37
+ input.type = "text";
38
+ return () => {
39
+ input.type = "email";
40
+ };
41
+ }
42
+ function type(text, element, options = {}) {
43
+ return _ZMMVJ3OTcjs.wrapAsync.call(void 0, async () => {
44
+ var _a, _b;
45
+ if (element == null) {
46
+ element = document.activeElement;
47
+ }
48
+ if (!element)
49
+ return;
50
+ if (!_focus.isFocusable.call(void 0, element))
51
+ return;
52
+ await _A5IFXY4Jcjs.focus.call(void 0, element);
53
+ element.dirty = true;
54
+ const restoreEmailInput = workAroundEmailInput(element);
55
+ for (const char of text) {
56
+ const key = getKeyFromChar(char);
57
+ let value = "";
58
+ let inputType = options.isComposing ? "insertCompositionText" : "insertText";
59
+ let defaultAllowed = await _FU2U6RZLcjs.dispatch.keyDown(element, _OVN5OYWKcjs.__spreadValues.call(void 0, { key }, options));
60
+ element = _dom.getActiveElement.call(void 0, element) || element;
61
+ if (_dom.isTextField.call(void 0, element)) {
62
+ const input = element;
63
+ const [start, end] = [
64
+ (_a = input.selectionStart) != null ? _a : 0,
65
+ (_b = input.selectionEnd) != null ? _b : 0
66
+ ];
67
+ const collapsed = start === end;
68
+ let nextCaretPosition = start;
69
+ if (char === "\x7F") {
70
+ const firstPart = input.value.slice(0, start);
71
+ const secondPart = input.value.slice(collapsed ? end + 1 : end);
72
+ value = `${firstPart}${secondPart}`;
73
+ inputType = "deleteContentForward";
74
+ } else if (char === "\b") {
75
+ nextCaretPosition = collapsed ? Math.max(start - 1, 0) : start;
76
+ const firstPart = input.value.slice(0, nextCaretPosition);
77
+ const lastPart = input.value.slice(end, input.value.length);
78
+ value = `${firstPart}${lastPart}`;
79
+ inputType = "deleteContentBackward";
80
+ } else {
81
+ const firstPartEnd = options.isComposing ? start - 1 : start;
82
+ const firstPart = input.value.slice(0, firstPartEnd);
83
+ const lastPart = input.value.slice(end, input.value.length);
84
+ nextCaretPosition = start + 1;
85
+ value = `${firstPart}${char}${lastPart}`;
86
+ }
87
+ if (defaultAllowed && !input.readOnly) {
88
+ if (inputType === "insertText") {
89
+ defaultAllowed = await _FU2U6RZLcjs.dispatch.keyPress(input, _OVN5OYWKcjs.__spreadValues.call(void 0, {
90
+ key,
91
+ charCode: key.charCodeAt(0)
92
+ }, options));
93
+ }
94
+ if (inputType === "insertCompositionText") {
95
+ defaultAllowed = await _FU2U6RZLcjs.dispatch.compositionUpdate(input, _OVN5OYWKcjs.__spreadValues.call(void 0, {
96
+ data: char,
97
+ target: { value }
98
+ }, options));
99
+ }
100
+ if (defaultAllowed) {
101
+ await _FU2U6RZLcjs.dispatch.input(input, _OVN5OYWKcjs.__spreadValues.call(void 0, {
102
+ data: char,
103
+ target: {
104
+ value,
105
+ selectionStart: nextCaretPosition,
106
+ selectionEnd: nextCaretPosition
107
+ },
108
+ inputType
109
+ }, options));
110
+ if (input.selectionStart !== nextCaretPosition) {
111
+ input.setSelectionRange(nextCaretPosition, nextCaretPosition);
112
+ }
113
+ }
114
+ }
115
+ }
116
+ await _NIEATM7Rcjs.sleep.call(void 0, );
117
+ await _FU2U6RZLcjs.dispatch.keyUp(element, _OVN5OYWKcjs.__spreadValues.call(void 0, { key }, options));
118
+ await _NIEATM7Rcjs.sleep.call(void 0, );
119
+ }
120
+ restoreEmailInput();
121
+ });
122
+ }
123
+
124
+
125
+
126
+ exports.type = type;
@@ -0,0 +1,72 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+ // src/__utils.ts
4
+ var _focus = require('@ariakit/core/utils/focus');
5
+ var _misc = require('@ariakit/core/utils/misc');
6
+ var isBrowser = typeof navigator !== "undefined" && !navigator.userAgent.includes("jsdom") && typeof window !== "undefined" && !("happyDOM" in window);
7
+ async function flushMicrotasks() {
8
+ await Promise.resolve();
9
+ await Promise.resolve();
10
+ await Promise.resolve();
11
+ }
12
+ function nextFrame() {
13
+ return new Promise(requestAnimationFrame);
14
+ }
15
+ function setActEnvironment(value) {
16
+ const scope = globalThis;
17
+ const previousValue = scope.IS_REACT_ACT_ENVIRONMENT;
18
+ scope.IS_REACT_ACT_ENVIRONMENT = value;
19
+ const restoreActEnvironment = () => {
20
+ scope.IS_REACT_ACT_ENVIRONMENT = previousValue;
21
+ };
22
+ return restoreActEnvironment;
23
+ }
24
+ function applyBrowserPolyfills() {
25
+ if (isBrowser)
26
+ return _misc.noop;
27
+ const originalFocus = HTMLElement.prototype.focus;
28
+ HTMLElement.prototype.focus = function focus(options) {
29
+ if (!_focus.isFocusable.call(void 0, this))
30
+ return;
31
+ return originalFocus.call(this, options);
32
+ };
33
+ const originalGetClientRects = Element.prototype.getClientRects;
34
+ Element.prototype.getClientRects = function getClientRects() {
35
+ const isHidden = (element) => {
36
+ if (!element.isConnected)
37
+ return true;
38
+ if (element.parentElement && isHidden(element.parentElement))
39
+ return true;
40
+ if (!(element instanceof HTMLElement))
41
+ return false;
42
+ if (element.hidden)
43
+ return true;
44
+ const style = getComputedStyle(element);
45
+ return style.display === "none" || style.visibility === "hidden";
46
+ };
47
+ if (isHidden(this))
48
+ return [];
49
+ return [{ width: 1, height: 1 }];
50
+ };
51
+ return () => {
52
+ HTMLElement.prototype.focus = originalFocus;
53
+ Element.prototype.getClientRects = originalGetClientRects;
54
+ };
55
+ }
56
+ async function wrapAsync(fn) {
57
+ const restoreActEnvironment = setActEnvironment(false);
58
+ const removeBrowserPolyfills = applyBrowserPolyfills();
59
+ try {
60
+ return await fn();
61
+ } finally {
62
+ restoreActEnvironment();
63
+ removeBrowserPolyfills();
64
+ }
65
+ }
66
+
67
+
68
+
69
+
70
+
71
+
72
+ exports.isBrowser = isBrowser; exports.flushMicrotasks = flushMicrotasks; exports.nextFrame = nextFrame; exports.wrapAsync = wrapAsync;
@@ -0,0 +1 @@
1
+ export declare function useAllEvents(ref: React.RefObject<Element>, stack: string[]): void;
@@ -0,0 +1,11 @@
1
+ import { noop } from "@ariakit/core/utils/misc";
2
+ export type DirtiableElement = Element & {
3
+ dirty?: boolean;
4
+ };
5
+ export type TextField = HTMLInputElement | HTMLTextAreaElement;
6
+ export declare const isBrowser: boolean;
7
+ export declare function flushMicrotasks(): Promise<void>;
8
+ export declare function nextFrame(): Promise<number>;
9
+ export declare function setActEnvironment(value: boolean): () => void;
10
+ export declare function applyBrowserPolyfills(): typeof noop;
11
+ export declare function wrapAsync<T>(fn: () => Promise<T>): Promise<T>;
package/cjs/__utils.d.ts CHANGED
@@ -1,8 +1,11 @@
1
+ import { noop } from "@ariakit/core/utils/misc";
1
2
  export type DirtiableElement = Element & {
2
3
  dirty?: boolean;
3
4
  };
4
5
  export type TextField = HTMLInputElement | HTMLTextAreaElement;
5
6
  export declare const isBrowser: boolean;
6
- export declare const act: typeof import("react-dom/test-utils").act;
7
- export declare function queuedMicrotasks(): Promise<void>;
8
- export declare function nextFrame(): Promise<void>;
7
+ export declare function flushMicrotasks(): Promise<void>;
8
+ export declare function nextFrame(): Promise<number>;
9
+ export declare function setActEnvironment(value: boolean): () => void;
10
+ export declare function applyBrowserPolyfills(): typeof noop;
11
+ export declare function wrapAsync<T>(fn: () => Promise<T>): Promise<T>;