@ariakit/test 0.4.6 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/cjs/query.d.cts +2 -2
- package/cjs/query.d.ts +2 -2
- package/esm/query.d.ts +2 -2
- package/package.json +2 -2
- package/cjs/__chunks/3L4XZQN6.cjs +0 -118
- package/cjs/__chunks/5USXAKSO.cjs +0 -32
- package/cjs/__chunks/72WSX5BL.cjs +0 -201
- package/cjs/__chunks/7LFSIKVW.cjs +0 -134
- package/cjs/__chunks/AA4DRZPS.cjs +0 -19
- package/cjs/__chunks/ANKVPRYL.cjs +0 -27
- package/cjs/__chunks/C6KLLVD3.cjs +0 -90
- package/cjs/__chunks/CAAOBH77.cjs +0 -89
- package/cjs/__chunks/E4OOGVMW.cjs +0 -24
- package/cjs/__chunks/IDMD7IDF.cjs +0 -1
- package/cjs/__chunks/IWR6DHL3.cjs +0 -13
- package/cjs/__chunks/ML4UXKC3.cjs +0 -56
- package/cjs/__chunks/OYUSBKO4.cjs +0 -235
- package/cjs/__chunks/Q3ZREZK3.cjs +0 -67
- package/cjs/__chunks/RHX5DDWS.cjs +0 -83
- package/cjs/__chunks/SMHVZDHR.cjs +0 -33
- package/cjs/__chunks/W5TVXVBK.cjs +0 -133
- package/cjs/__chunks/Y4FGMHAT.cjs +0 -12
- package/cjs/blur.cjs +0 -9
- package/cjs/click.cjs +0 -15
- package/cjs/dispatch.cjs +0 -8
- package/cjs/focus.cjs +0 -9
- package/cjs/hover.cjs +0 -10
- package/cjs/index.cjs +0 -64
- package/cjs/mouse-down.cjs +0 -11
- package/cjs/mouse-up.cjs +0 -9
- package/cjs/playwright.cjs +0 -19
- package/cjs/press.cjs +0 -13
- package/cjs/query.cjs +0 -10
- package/cjs/react.cjs +0 -103
- package/cjs/select.cjs +0 -15
- package/cjs/sleep.cjs +0 -8
- package/cjs/tap.cjs +0 -16
- package/cjs/type.cjs +0 -11
- package/cjs/wait-for.cjs +0 -8
- package/esm/__chunks/3TAKJKL3.js +0 -135
- package/esm/__chunks/4SG6SLGL.js +0 -34
- package/esm/__chunks/BQA4OBCC.js +0 -13
- package/esm/__chunks/CNNB7B4V.js +0 -236
- package/esm/__chunks/CWTUOQ5Z.js +0 -91
- package/esm/__chunks/DZ24E43J.js +0 -20
- package/esm/__chunks/G32GEXRJ.js +0 -134
- package/esm/__chunks/HFG3HB6M.js +0 -85
- package/esm/__chunks/LK25WCYN.js +0 -202
- package/esm/__chunks/NR24PD4G.js +0 -28
- package/esm/__chunks/PVRUCEXU.js +0 -68
- package/esm/__chunks/RHBNMDK4.js +0 -1
- package/esm/__chunks/SB7WYA2U.js +0 -14
- package/esm/__chunks/SM5ASDQ3.js +0 -25
- package/esm/__chunks/SOWA2DKF.js +0 -33
- package/esm/__chunks/UG25M3QN.js +0 -91
- package/esm/__chunks/YVVGFTRB.js +0 -119
- package/esm/__chunks/Z7WVAAXJ.js +0 -57
- package/esm/blur.js +0 -10
- package/esm/click.js +0 -16
- package/esm/dispatch.js +0 -9
- package/esm/focus.js +0 -10
- package/esm/hover.js +0 -11
- package/esm/index.js +0 -65
- package/esm/mouse-down.js +0 -12
- package/esm/mouse-up.js +0 -10
- package/esm/playwright.js +0 -20
- package/esm/press.js +0 -14
- package/esm/query.js +0 -11
- package/esm/react.js +0 -104
- package/esm/select.js +0 -16
- package/esm/sleep.js +0 -9
- package/esm/tap.js +0 -17
- package/esm/type.js +0 -12
- package/esm/wait-for.js +0 -9
package/esm/__chunks/LK25WCYN.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
flushMicrotasks,
|
|
4
|
-
wrapAsync
|
|
5
|
-
} from "./HFG3HB6M.js";
|
|
6
|
-
|
|
7
|
-
// src/dispatch.ts
|
|
8
|
-
import { getKeys, invariant } from "@ariakit/core/utils/misc";
|
|
9
|
-
import { createEvent, fireEvent } from "@testing-library/dom";
|
|
10
|
-
function assignProps(obj, props) {
|
|
11
|
-
for (const [key, value] of Object.entries(props)) {
|
|
12
|
-
Object.defineProperty(obj, key, { get: () => value != null ? value : null });
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function sanitizeNumber(n) {
|
|
16
|
-
return Number(n != null ? n : 0);
|
|
17
|
-
}
|
|
18
|
-
function initClipboardEvent(event, { clipboardData }) {
|
|
19
|
-
assignProps(event, {
|
|
20
|
-
clipboardData
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function initInputEvent(event, { data, inputType, isComposing }) {
|
|
24
|
-
assignProps(event, {
|
|
25
|
-
data,
|
|
26
|
-
isComposing: !!isComposing,
|
|
27
|
-
inputType: String(inputType)
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function initUIEvent(event, { view, detail }) {
|
|
31
|
-
assignProps(event, {
|
|
32
|
-
view,
|
|
33
|
-
detail: sanitizeNumber(detail != null ? detail : 0)
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function initUIEventModififiers(event, {
|
|
37
|
-
altKey,
|
|
38
|
-
ctrlKey,
|
|
39
|
-
metaKey,
|
|
40
|
-
shiftKey,
|
|
41
|
-
modifierAltGraph,
|
|
42
|
-
modifierCapsLock,
|
|
43
|
-
modifierFn,
|
|
44
|
-
modifierFnLock,
|
|
45
|
-
modifierNumLock,
|
|
46
|
-
modifierScrollLock,
|
|
47
|
-
modifierSymbol,
|
|
48
|
-
modifierSymbolLock
|
|
49
|
-
}) {
|
|
50
|
-
assignProps(event, {
|
|
51
|
-
altKey: !!altKey,
|
|
52
|
-
ctrlKey: !!ctrlKey,
|
|
53
|
-
metaKey: !!metaKey,
|
|
54
|
-
shiftKey: !!shiftKey,
|
|
55
|
-
getModifierState(k) {
|
|
56
|
-
return Boolean(
|
|
57
|
-
{
|
|
58
|
-
Alt: altKey,
|
|
59
|
-
AltGraph: modifierAltGraph,
|
|
60
|
-
CapsLock: modifierCapsLock,
|
|
61
|
-
Control: ctrlKey,
|
|
62
|
-
Fn: modifierFn,
|
|
63
|
-
FnLock: modifierFnLock,
|
|
64
|
-
Meta: metaKey,
|
|
65
|
-
NumLock: modifierNumLock,
|
|
66
|
-
ScrollLock: modifierScrollLock,
|
|
67
|
-
Shift: shiftKey,
|
|
68
|
-
Symbol: modifierSymbol,
|
|
69
|
-
SymbolLock: modifierSymbolLock
|
|
70
|
-
}[k]
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function initKeyboardEvent(event, { key, code, location, repeat, isComposing }) {
|
|
76
|
-
assignProps(event, {
|
|
77
|
-
key: String(key),
|
|
78
|
-
code: String(code),
|
|
79
|
-
location: sanitizeNumber(location),
|
|
80
|
-
repeat: !!repeat,
|
|
81
|
-
isComposing: !!isComposing
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function initMouseEvent(event, {
|
|
85
|
-
x,
|
|
86
|
-
y,
|
|
87
|
-
screenX,
|
|
88
|
-
screenY,
|
|
89
|
-
clientX = x,
|
|
90
|
-
clientY = y,
|
|
91
|
-
button,
|
|
92
|
-
buttons,
|
|
93
|
-
relatedTarget
|
|
94
|
-
}) {
|
|
95
|
-
assignProps(event, {
|
|
96
|
-
screenX: sanitizeNumber(screenX),
|
|
97
|
-
screenY: sanitizeNumber(screenY),
|
|
98
|
-
clientX: sanitizeNumber(clientX),
|
|
99
|
-
x: sanitizeNumber(clientX),
|
|
100
|
-
clientY: sanitizeNumber(clientY),
|
|
101
|
-
y: sanitizeNumber(clientY),
|
|
102
|
-
button: sanitizeNumber(button),
|
|
103
|
-
buttons: sanitizeNumber(buttons),
|
|
104
|
-
relatedTarget
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function initPointerEvent(event, {
|
|
108
|
-
pointerId,
|
|
109
|
-
width,
|
|
110
|
-
height,
|
|
111
|
-
pressure,
|
|
112
|
-
tangentialPressure,
|
|
113
|
-
tiltX,
|
|
114
|
-
tiltY,
|
|
115
|
-
twist,
|
|
116
|
-
isPrimary,
|
|
117
|
-
pointerType = "mouse"
|
|
118
|
-
}) {
|
|
119
|
-
assignProps(event, {
|
|
120
|
-
pointerId: sanitizeNumber(pointerId),
|
|
121
|
-
width: sanitizeNumber(width),
|
|
122
|
-
height: sanitizeNumber(height),
|
|
123
|
-
pressure: sanitizeNumber(pressure),
|
|
124
|
-
tangentialPressure: sanitizeNumber(tangentialPressure),
|
|
125
|
-
tiltX: sanitizeNumber(tiltX),
|
|
126
|
-
tiltY: sanitizeNumber(tiltY),
|
|
127
|
-
twist: sanitizeNumber(twist),
|
|
128
|
-
isPrimary: !!isPrimary,
|
|
129
|
-
pointerType: String(pointerType)
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function initEvent(event, options = {}) {
|
|
133
|
-
if (event instanceof ClipboardEvent) {
|
|
134
|
-
initClipboardEvent(event, options);
|
|
135
|
-
}
|
|
136
|
-
if (event instanceof InputEvent) {
|
|
137
|
-
initInputEvent(event, options);
|
|
138
|
-
}
|
|
139
|
-
if (event instanceof UIEvent) {
|
|
140
|
-
initUIEvent(event, options);
|
|
141
|
-
}
|
|
142
|
-
if (event instanceof KeyboardEvent) {
|
|
143
|
-
initKeyboardEvent(event, options);
|
|
144
|
-
initUIEventModififiers(event, options);
|
|
145
|
-
}
|
|
146
|
-
if (event instanceof MouseEvent) {
|
|
147
|
-
initMouseEvent(event, options);
|
|
148
|
-
initUIEventModififiers(event, options);
|
|
149
|
-
}
|
|
150
|
-
if (event instanceof PointerEvent) {
|
|
151
|
-
initPointerEvent(event, options);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
var pointerEvents = [
|
|
155
|
-
"mousemove",
|
|
156
|
-
"mouseover",
|
|
157
|
-
"mouseenter",
|
|
158
|
-
"mouseout",
|
|
159
|
-
"mouseleave",
|
|
160
|
-
"mousedown",
|
|
161
|
-
"mouseup",
|
|
162
|
-
"pointermove",
|
|
163
|
-
"pointerover",
|
|
164
|
-
"pointerenter",
|
|
165
|
-
"pointerout",
|
|
166
|
-
"pointerleave",
|
|
167
|
-
"pointerdown",
|
|
168
|
-
"pointerup",
|
|
169
|
-
"click"
|
|
170
|
-
];
|
|
171
|
-
function baseDispatch(element, event) {
|
|
172
|
-
return wrapAsync(async () => {
|
|
173
|
-
invariant(element, `Unable to dispatch ${event.type} on null element`);
|
|
174
|
-
const eventName = event.type.toLowerCase();
|
|
175
|
-
if (pointerEvents.includes(eventName) && "classList" in element) {
|
|
176
|
-
const { pointerEvents: pointerEvents2 } = getComputedStyle(element);
|
|
177
|
-
if (pointerEvents2 === "none") {
|
|
178
|
-
if (element.parentElement) {
|
|
179
|
-
return baseDispatch(element.parentElement, event);
|
|
180
|
-
}
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const defaultAllowed = fireEvent(element, event);
|
|
185
|
-
await flushMicrotasks();
|
|
186
|
-
return defaultAllowed;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
var events = getKeys(fireEvent).reduce((events2, eventName) => {
|
|
190
|
-
events2[eventName] = (element, options) => {
|
|
191
|
-
invariant(element, `Unable to dispatch ${eventName} on null element`);
|
|
192
|
-
const event = createEvent[eventName](element, options);
|
|
193
|
-
initEvent(event, options);
|
|
194
|
-
return baseDispatch(element, event);
|
|
195
|
-
};
|
|
196
|
-
return events2;
|
|
197
|
-
}, {});
|
|
198
|
-
var dispatch = Object.assign(baseDispatch, events);
|
|
199
|
-
|
|
200
|
-
export {
|
|
201
|
-
dispatch
|
|
202
|
-
};
|
package/esm/__chunks/NR24PD4G.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
dispatch
|
|
4
|
-
} from "./LK25WCYN.js";
|
|
5
|
-
import {
|
|
6
|
-
wrapAsync
|
|
7
|
-
} from "./HFG3HB6M.js";
|
|
8
|
-
import {
|
|
9
|
-
__spreadValues
|
|
10
|
-
} from "./SM5ASDQ3.js";
|
|
11
|
-
|
|
12
|
-
// src/mouse-up.ts
|
|
13
|
-
import { isVisible } from "@ariakit/core/utils/dom";
|
|
14
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
15
|
-
function mouseUp(element, options) {
|
|
16
|
-
return wrapAsync(async () => {
|
|
17
|
-
invariant(element, "Unable to mouseUp on null element");
|
|
18
|
-
if (!isVisible(element)) return;
|
|
19
|
-
const { disabled } = element;
|
|
20
|
-
await dispatch.pointerUp(element, options);
|
|
21
|
-
if (disabled) return;
|
|
22
|
-
await dispatch.mouseUp(element, __spreadValues({ detail: 1 }, options));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
mouseUp
|
|
28
|
-
};
|
package/esm/__chunks/PVRUCEXU.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
dispatch
|
|
4
|
-
} from "./LK25WCYN.js";
|
|
5
|
-
import {
|
|
6
|
-
sleep
|
|
7
|
-
} from "./DZ24E43J.js";
|
|
8
|
-
import {
|
|
9
|
-
wrapAsync
|
|
10
|
-
} from "./HFG3HB6M.js";
|
|
11
|
-
import {
|
|
12
|
-
__spreadProps,
|
|
13
|
-
__spreadValues
|
|
14
|
-
} from "./SM5ASDQ3.js";
|
|
15
|
-
|
|
16
|
-
// src/hover.ts
|
|
17
|
-
import { isVisible } from "@ariakit/core/utils/dom";
|
|
18
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
19
|
-
function isPointerEventsEnabled(element) {
|
|
20
|
-
return getComputedStyle(element).pointerEvents !== "none";
|
|
21
|
-
}
|
|
22
|
-
function hover(element, options) {
|
|
23
|
-
return wrapAsync(async () => {
|
|
24
|
-
invariant(element, "Unable to hover on null element");
|
|
25
|
-
if (!isVisible(element)) return;
|
|
26
|
-
const document = element.ownerDocument;
|
|
27
|
-
const { lastHovered } = document;
|
|
28
|
-
const { disabled } = element;
|
|
29
|
-
const pointerEventsEnabled = isPointerEventsEnabled(element);
|
|
30
|
-
if (lastHovered && lastHovered !== element && isVisible(lastHovered)) {
|
|
31
|
-
await dispatch.pointerMove(lastHovered, options);
|
|
32
|
-
await dispatch.mouseMove(lastHovered, options);
|
|
33
|
-
if (isPointerEventsEnabled(lastHovered)) {
|
|
34
|
-
const isElementWithinLastHovered = lastHovered.contains(element);
|
|
35
|
-
const relatedTarget = pointerEventsEnabled ? element : null;
|
|
36
|
-
const leaveOptions = __spreadProps(__spreadValues({}, options), { relatedTarget });
|
|
37
|
-
await dispatch.pointerOut(lastHovered, leaveOptions);
|
|
38
|
-
if (!isElementWithinLastHovered) {
|
|
39
|
-
await dispatch.pointerLeave(lastHovered, leaveOptions);
|
|
40
|
-
}
|
|
41
|
-
await dispatch.mouseOut(lastHovered, leaveOptions);
|
|
42
|
-
if (!isElementWithinLastHovered) {
|
|
43
|
-
await dispatch.mouseLeave(lastHovered, leaveOptions);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
await sleep();
|
|
48
|
-
if (pointerEventsEnabled) {
|
|
49
|
-
const enterOptions = lastHovered ? __spreadValues({ relatedTarget: lastHovered }, options) : options;
|
|
50
|
-
await dispatch.pointerOver(element, enterOptions);
|
|
51
|
-
await dispatch.pointerEnter(element, enterOptions);
|
|
52
|
-
if (!disabled) {
|
|
53
|
-
await dispatch.mouseOver(element, enterOptions);
|
|
54
|
-
await dispatch.mouseEnter(element, enterOptions);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
await dispatch.pointerMove(element, options);
|
|
58
|
-
if (!disabled) {
|
|
59
|
-
await dispatch.mouseMove(element, options);
|
|
60
|
-
}
|
|
61
|
-
document.lastHovered = element;
|
|
62
|
-
await sleep();
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export {
|
|
67
|
-
hover
|
|
68
|
-
};
|
package/esm/__chunks/RHBNMDK4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";
|
package/esm/__chunks/SB7WYA2U.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
wrapAsync
|
|
4
|
-
} from "./HFG3HB6M.js";
|
|
5
|
-
|
|
6
|
-
// src/wait-for.ts
|
|
7
|
-
import * as DOMTestingLibrary from "@testing-library/dom";
|
|
8
|
-
function waitFor2(callback, options) {
|
|
9
|
-
return wrapAsync(() => DOMTestingLibrary.waitFor(callback, options));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
waitFor2 as waitFor
|
|
14
|
-
};
|
package/esm/__chunks/SM5ASDQ3.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
__spreadValues,
|
|
24
|
-
__spreadProps
|
|
25
|
-
};
|
package/esm/__chunks/SOWA2DKF.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
dispatch
|
|
4
|
-
} from "./LK25WCYN.js";
|
|
5
|
-
import {
|
|
6
|
-
flushMicrotasks,
|
|
7
|
-
wrapAsync
|
|
8
|
-
} from "./HFG3HB6M.js";
|
|
9
|
-
|
|
10
|
-
// src/blur.ts
|
|
11
|
-
import { getActiveElement } from "@ariakit/core/utils/dom";
|
|
12
|
-
function blur(element) {
|
|
13
|
-
return wrapAsync(async () => {
|
|
14
|
-
if (element == null) {
|
|
15
|
-
element = document.activeElement;
|
|
16
|
-
}
|
|
17
|
-
if (!element) return;
|
|
18
|
-
if (element.tagName === "BODY") return;
|
|
19
|
-
if (getActiveElement(element) !== element) return;
|
|
20
|
-
if (element.dirty) {
|
|
21
|
-
await dispatch.change(element);
|
|
22
|
-
element.dirty = false;
|
|
23
|
-
}
|
|
24
|
-
if (element instanceof HTMLElement || element instanceof SVGElement) {
|
|
25
|
-
element.blur();
|
|
26
|
-
await flushMicrotasks();
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
blur
|
|
33
|
-
};
|
package/esm/__chunks/UG25M3QN.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
mouseUp
|
|
4
|
-
} from "./NR24PD4G.js";
|
|
5
|
-
import {
|
|
6
|
-
mouseDown
|
|
7
|
-
} from "./Z7WVAAXJ.js";
|
|
8
|
-
import {
|
|
9
|
-
hover
|
|
10
|
-
} from "./PVRUCEXU.js";
|
|
11
|
-
import {
|
|
12
|
-
dispatch
|
|
13
|
-
} from "./LK25WCYN.js";
|
|
14
|
-
import {
|
|
15
|
-
sleep
|
|
16
|
-
} from "./DZ24E43J.js";
|
|
17
|
-
import {
|
|
18
|
-
wrapAsync
|
|
19
|
-
} from "./HFG3HB6M.js";
|
|
20
|
-
import {
|
|
21
|
-
__spreadValues
|
|
22
|
-
} from "./SM5ASDQ3.js";
|
|
23
|
-
|
|
24
|
-
// src/select.ts
|
|
25
|
-
import { isVisible } from "@ariakit/core/utils/dom";
|
|
26
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
27
|
-
function select(text, element = document.body, options) {
|
|
28
|
-
return wrapAsync(async () => {
|
|
29
|
-
var _a, _b;
|
|
30
|
-
invariant(element, "Unable to select text on null element");
|
|
31
|
-
if (!isVisible(element)) return;
|
|
32
|
-
const document2 = element.ownerDocument;
|
|
33
|
-
await hover(element, options);
|
|
34
|
-
await mouseDown(element, options);
|
|
35
|
-
await dispatch(
|
|
36
|
-
element,
|
|
37
|
-
new Event("selectstart", {
|
|
38
|
-
bubbles: true,
|
|
39
|
-
cancelable: true,
|
|
40
|
-
composed: false
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
const startIndex = (_b = (_a = element.textContent) == null ? void 0 : _a.indexOf(text)) != null ? _b : -1;
|
|
44
|
-
const selection = document2.getSelection();
|
|
45
|
-
const range = document2.createRange();
|
|
46
|
-
for (let i = 1; i <= text.length; i++) {
|
|
47
|
-
const iterator = document2.createNodeIterator(
|
|
48
|
-
element,
|
|
49
|
-
NodeFilter.SHOW_TEXT
|
|
50
|
-
);
|
|
51
|
-
const textSlice = text.slice(0, i);
|
|
52
|
-
const endIndex = startIndex + textSlice.length;
|
|
53
|
-
let index = startIndex;
|
|
54
|
-
let node = null;
|
|
55
|
-
let charCount = 0;
|
|
56
|
-
let startContainer = null;
|
|
57
|
-
let startOffset = -1;
|
|
58
|
-
let endContainer = null;
|
|
59
|
-
let endOffset = -1;
|
|
60
|
-
while (index >= 0 && index < endIndex && charCount < endIndex && (node = iterator.nextNode())) {
|
|
61
|
-
const textContent = node.textContent;
|
|
62
|
-
if (!textContent) continue;
|
|
63
|
-
charCount += textContent.length;
|
|
64
|
-
if (index > charCount) continue;
|
|
65
|
-
if (!startContainer) {
|
|
66
|
-
startContainer = node;
|
|
67
|
-
startOffset = index - charCount + textContent.length;
|
|
68
|
-
}
|
|
69
|
-
endContainer = node;
|
|
70
|
-
endOffset = endIndex - charCount + textContent.length;
|
|
71
|
-
index++;
|
|
72
|
-
}
|
|
73
|
-
if (!startContainer || !endContainer) continue;
|
|
74
|
-
await hover(element, options);
|
|
75
|
-
range.setStart(startContainer, startOffset);
|
|
76
|
-
range.setEnd(endContainer, endOffset);
|
|
77
|
-
selection == null ? void 0 : selection.removeAllRanges();
|
|
78
|
-
selection == null ? void 0 : selection.addRange(range);
|
|
79
|
-
}
|
|
80
|
-
await sleep();
|
|
81
|
-
await mouseUp(element, options);
|
|
82
|
-
await dispatch.click(element, __spreadValues({ detail: 1 }, options));
|
|
83
|
-
selection == null ? void 0 : selection.removeAllRanges();
|
|
84
|
-
selection == null ? void 0 : selection.addRange(range);
|
|
85
|
-
await sleep();
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export {
|
|
90
|
-
select
|
|
91
|
-
};
|
package/esm/__chunks/YVVGFTRB.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
focus
|
|
4
|
-
} from "./4SG6SLGL.js";
|
|
5
|
-
import {
|
|
6
|
-
dispatch
|
|
7
|
-
} from "./LK25WCYN.js";
|
|
8
|
-
import {
|
|
9
|
-
sleep
|
|
10
|
-
} from "./DZ24E43J.js";
|
|
11
|
-
import {
|
|
12
|
-
wrapAsync
|
|
13
|
-
} from "./HFG3HB6M.js";
|
|
14
|
-
import {
|
|
15
|
-
__spreadValues
|
|
16
|
-
} from "./SM5ASDQ3.js";
|
|
17
|
-
|
|
18
|
-
// src/type.ts
|
|
19
|
-
import { getActiveElement, isTextField } from "@ariakit/core/utils/dom";
|
|
20
|
-
import { isFocusable } from "@ariakit/core/utils/focus";
|
|
21
|
-
function getKeyFromChar(key) {
|
|
22
|
-
if (key === "\x7F") return "Delete";
|
|
23
|
-
if (key === "\b") return "Backspace";
|
|
24
|
-
if (key === "\n") return "Enter";
|
|
25
|
-
if (key === " ") return "Tab";
|
|
26
|
-
return key;
|
|
27
|
-
}
|
|
28
|
-
function workAroundEmailInput(element) {
|
|
29
|
-
const input = element;
|
|
30
|
-
if (input.tagName !== "INPUT" || input.type !== "email") return () => {
|
|
31
|
-
};
|
|
32
|
-
input.type = "text";
|
|
33
|
-
return () => {
|
|
34
|
-
input.type = "email";
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function type(text, element, options = {}) {
|
|
38
|
-
return wrapAsync(async () => {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
if (element == null) {
|
|
41
|
-
element = document.activeElement;
|
|
42
|
-
}
|
|
43
|
-
if (!element) return;
|
|
44
|
-
if (!isFocusable(element)) return;
|
|
45
|
-
await focus(element);
|
|
46
|
-
element.dirty = true;
|
|
47
|
-
const restoreEmailInput = workAroundEmailInput(element);
|
|
48
|
-
for (const char of text) {
|
|
49
|
-
const key = getKeyFromChar(char);
|
|
50
|
-
let value = "";
|
|
51
|
-
let inputType = options.isComposing ? "insertCompositionText" : "insertText";
|
|
52
|
-
let defaultAllowed = await dispatch.keyDown(element, __spreadValues({ key }, options));
|
|
53
|
-
element = getActiveElement(element) || element;
|
|
54
|
-
if (isTextField(element)) {
|
|
55
|
-
const input = element;
|
|
56
|
-
const [start, end] = [
|
|
57
|
-
(_a = input.selectionStart) != null ? _a : 0,
|
|
58
|
-
(_b = input.selectionEnd) != null ? _b : 0
|
|
59
|
-
];
|
|
60
|
-
const collapsed = start === end;
|
|
61
|
-
let nextCaretPosition = start;
|
|
62
|
-
if (char === "\x7F") {
|
|
63
|
-
const firstPart = input.value.slice(0, start);
|
|
64
|
-
const secondPart = input.value.slice(collapsed ? end + 1 : end);
|
|
65
|
-
value = `${firstPart}${secondPart}`;
|
|
66
|
-
inputType = "deleteContentForward";
|
|
67
|
-
} else if (char === "\b") {
|
|
68
|
-
nextCaretPosition = collapsed ? Math.max(start - 1, 0) : start;
|
|
69
|
-
const firstPart = input.value.slice(0, nextCaretPosition);
|
|
70
|
-
const lastPart = input.value.slice(end, input.value.length);
|
|
71
|
-
value = `${firstPart}${lastPart}`;
|
|
72
|
-
inputType = "deleteContentBackward";
|
|
73
|
-
} else {
|
|
74
|
-
const firstPartEnd = options.isComposing ? start - 1 : start;
|
|
75
|
-
const firstPart = input.value.slice(0, firstPartEnd);
|
|
76
|
-
const lastPart = input.value.slice(end, input.value.length);
|
|
77
|
-
nextCaretPosition = start + 1;
|
|
78
|
-
value = `${firstPart}${char}${lastPart}`;
|
|
79
|
-
}
|
|
80
|
-
if (defaultAllowed && !input.readOnly) {
|
|
81
|
-
if (inputType === "insertText") {
|
|
82
|
-
defaultAllowed = await dispatch.keyPress(input, __spreadValues({
|
|
83
|
-
key,
|
|
84
|
-
charCode: key.charCodeAt(0)
|
|
85
|
-
}, options));
|
|
86
|
-
}
|
|
87
|
-
if (inputType === "insertCompositionText") {
|
|
88
|
-
defaultAllowed = await dispatch.compositionUpdate(input, __spreadValues({
|
|
89
|
-
data: char,
|
|
90
|
-
target: { value }
|
|
91
|
-
}, options));
|
|
92
|
-
}
|
|
93
|
-
if (defaultAllowed) {
|
|
94
|
-
await dispatch.input(input, __spreadValues({
|
|
95
|
-
data: char,
|
|
96
|
-
target: {
|
|
97
|
-
value,
|
|
98
|
-
selectionStart: nextCaretPosition,
|
|
99
|
-
selectionEnd: nextCaretPosition
|
|
100
|
-
},
|
|
101
|
-
inputType
|
|
102
|
-
}, options));
|
|
103
|
-
if (input.selectionStart !== nextCaretPosition) {
|
|
104
|
-
input.setSelectionRange(nextCaretPosition, nextCaretPosition);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
await sleep();
|
|
110
|
-
await dispatch.keyUp(element, __spreadValues({ key }, options));
|
|
111
|
-
await sleep();
|
|
112
|
-
}
|
|
113
|
-
restoreEmailInput();
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
type
|
|
119
|
-
};
|
package/esm/__chunks/Z7WVAAXJ.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
blur
|
|
4
|
-
} from "./SOWA2DKF.js";
|
|
5
|
-
import {
|
|
6
|
-
focus
|
|
7
|
-
} from "./4SG6SLGL.js";
|
|
8
|
-
import {
|
|
9
|
-
dispatch
|
|
10
|
-
} from "./LK25WCYN.js";
|
|
11
|
-
import {
|
|
12
|
-
wrapAsync
|
|
13
|
-
} from "./HFG3HB6M.js";
|
|
14
|
-
import {
|
|
15
|
-
__spreadValues
|
|
16
|
-
} from "./SM5ASDQ3.js";
|
|
17
|
-
|
|
18
|
-
// src/mouse-down.ts
|
|
19
|
-
import { getDocument, isVisible } from "@ariakit/core/utils/dom";
|
|
20
|
-
import { getClosestFocusable, isFocusable } from "@ariakit/core/utils/focus";
|
|
21
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
22
|
-
function mouseDown(element, options) {
|
|
23
|
-
return wrapAsync(async () => {
|
|
24
|
-
invariant(element, "Unable to mouseDown on null element");
|
|
25
|
-
if (!isVisible(element)) return;
|
|
26
|
-
const { disabled } = element;
|
|
27
|
-
let defaultAllowed = await dispatch.pointerDown(element, options);
|
|
28
|
-
if (!disabled) {
|
|
29
|
-
if (!await dispatch.mouseDown(element, __spreadValues({ detail: 1 }, options))) {
|
|
30
|
-
defaultAllowed = false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (defaultAllowed) {
|
|
34
|
-
const selection = getDocument(element).getSelection();
|
|
35
|
-
if (selection == null ? void 0 : selection.rangeCount) {
|
|
36
|
-
const range = selection.getRangeAt(0);
|
|
37
|
-
if (!range.collapsed) {
|
|
38
|
-
selection.removeAllRanges();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (isFocusable(element) && getComputedStyle(element).pointerEvents !== "none") {
|
|
42
|
-
await focus(element);
|
|
43
|
-
} else if (element.parentElement) {
|
|
44
|
-
const closestFocusable = getClosestFocusable(element.parentElement);
|
|
45
|
-
if (closestFocusable) {
|
|
46
|
-
await focus(closestFocusable);
|
|
47
|
-
} else {
|
|
48
|
-
await blur();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
mouseDown
|
|
57
|
-
};
|
package/esm/blur.js
DELETED
package/esm/click.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
click
|
|
4
|
-
} from "./__chunks/3TAKJKL3.js";
|
|
5
|
-
import "./__chunks/NR24PD4G.js";
|
|
6
|
-
import "./__chunks/Z7WVAAXJ.js";
|
|
7
|
-
import "./__chunks/PVRUCEXU.js";
|
|
8
|
-
import "./__chunks/SOWA2DKF.js";
|
|
9
|
-
import "./__chunks/4SG6SLGL.js";
|
|
10
|
-
import "./__chunks/LK25WCYN.js";
|
|
11
|
-
import "./__chunks/DZ24E43J.js";
|
|
12
|
-
import "./__chunks/HFG3HB6M.js";
|
|
13
|
-
import "./__chunks/SM5ASDQ3.js";
|
|
14
|
-
export {
|
|
15
|
-
click
|
|
16
|
-
};
|
package/esm/dispatch.js
DELETED