@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.
- package/CHANGELOG.md +36 -0
- package/cjs/__chunks/2KXSRUIV.cjs +205 -0
- package/cjs/__chunks/747HORQZ.cjs +30 -0
- package/cjs/__chunks/A5IFXY4J.cjs +33 -0
- package/cjs/__chunks/DAHHEUOU.cjs +95 -0
- package/cjs/__chunks/{2V5PIRJZ.cjs → ESE7QHAQ.cjs} +71 -70
- package/cjs/__chunks/FU2U6RZL.cjs +57 -0
- package/cjs/__chunks/I2BROIQW.cjs +1 -0
- package/cjs/__chunks/KVNENCXT.cjs +36 -0
- package/cjs/__chunks/LYOKT276.cjs +69 -0
- package/cjs/__chunks/NIEATM7R.cjs +20 -0
- package/cjs/__chunks/{PKWBCPZU.cjs → OVN5OYWK.cjs} +2 -1
- package/cjs/__chunks/{LUIPCXQX.cjs → PJWPDIUX.cjs} +48 -44
- package/cjs/__chunks/SDUGTL2N.cjs +13 -0
- package/cjs/__chunks/SEWCIANI.cjs +14 -0
- package/cjs/__chunks/T5KVOIJT.cjs +58 -0
- package/cjs/__chunks/VZINRVVH.cjs +126 -0
- package/cjs/__chunks/ZMMVJ3OT.cjs +72 -0
- package/cjs/__tests__/use-all-events.d.cts +1 -0
- package/cjs/__utils.d.cts +11 -0
- package/cjs/__utils.d.ts +6 -3
- package/cjs/blur.cjs +7 -8
- package/cjs/blur.d.cts +2 -0
- package/cjs/blur.d.ts +1 -2
- package/cjs/click.cjs +13 -14
- package/cjs/click.d.cts +1 -0
- package/cjs/click.d.ts +1 -2
- package/cjs/dispatch.cjs +9 -0
- package/cjs/dispatch.d.cts +9 -0
- package/cjs/dispatch.d.ts +9 -0
- package/cjs/focus.cjs +7 -8
- package/cjs/focus.d.cts +1 -0
- package/cjs/focus.d.ts +1 -2
- package/cjs/hover.cjs +8 -9
- package/cjs/hover.d.cts +1 -0
- package/cjs/hover.d.ts +1 -2
- package/cjs/index.cjs +19 -76
- package/cjs/index.d.cts +14 -0
- package/cjs/index.d.ts +2 -5
- package/cjs/mouse-down.cjs +9 -10
- package/cjs/mouse-down.d.cts +1 -0
- package/cjs/mouse-down.d.ts +1 -2
- package/cjs/mouse-up.cjs +7 -7
- package/cjs/mouse-up.d.cts +1 -0
- package/cjs/mouse-up.d.ts +1 -2
- package/cjs/press.cjs +11 -12
- package/cjs/press.d.cts +18 -0
- package/cjs/press.d.ts +0 -1
- package/cjs/query.cjs +10 -0
- package/cjs/query.d.cts +3989 -0
- package/cjs/query.d.ts +3989 -0
- package/cjs/react.cjs +90 -0
- package/cjs/react.d.cts +7 -0
- package/cjs/react.d.ts +7 -0
- package/cjs/select.cjs +13 -14
- package/cjs/select.d.cts +1 -0
- package/cjs/select.d.ts +1 -2
- package/cjs/sleep.cjs +6 -6
- package/cjs/sleep.d.cts +1 -0
- package/cjs/tap.cjs +14 -15
- package/cjs/tap.d.cts +1 -0
- package/cjs/tap.d.ts +1 -2
- package/cjs/type.cjs +9 -10
- package/cjs/type.d.cts +2 -0
- package/cjs/type.d.ts +0 -1
- package/cjs/wait-for.cjs +6 -4
- package/cjs/wait-for.d.cts +2 -0
- package/cjs/wait-for.d.ts +2 -1
- package/dispatch/package.json +8 -0
- package/esm/__chunks/{SWUQE4WB.js → 5DPK2YAQ.js} +48 -44
- package/esm/__chunks/7JP5HWUW.js +57 -0
- package/esm/__chunks/ANPGABTJ.js +69 -0
- package/esm/__chunks/H3BXHZTZ.js +95 -0
- package/esm/__chunks/HUBUFZ3U.js +205 -0
- package/esm/__chunks/HVRX3U4O.js +126 -0
- package/esm/__chunks/LHKK7Y5F.js +72 -0
- package/esm/__chunks/LSH2PT34.js +30 -0
- package/esm/__chunks/MKNCAN2F.js +13 -0
- package/esm/__chunks/{6XO5G2QR.js → Q65FZOE2.js} +1 -0
- package/esm/__chunks/RG2JKALK.js +58 -0
- package/esm/__chunks/RHBNMDK4.js +1 -0
- package/esm/__chunks/{6PY4HXVO.js → UJCT5GXS.js} +71 -70
- package/esm/__chunks/WAYMNUAF.js +33 -0
- package/esm/__chunks/WLDGXXGP.js +14 -0
- package/esm/__chunks/YNAZUNNE.js +20 -0
- package/esm/__chunks/ZIWQZF7I.js +36 -0
- package/esm/__utils.d.ts +6 -3
- package/esm/blur.d.ts +1 -2
- package/esm/blur.js +5 -6
- package/esm/click.d.ts +1 -2
- package/esm/click.js +11 -12
- package/esm/dispatch.d.ts +9 -0
- package/esm/dispatch.js +9 -0
- package/esm/focus.d.ts +1 -2
- package/esm/focus.js +5 -6
- package/esm/hover.d.ts +1 -2
- package/esm/hover.js +6 -7
- package/esm/index.d.ts +2 -5
- package/esm/index.js +31 -88
- package/esm/mouse-down.d.ts +1 -2
- package/esm/mouse-down.js +7 -8
- package/esm/mouse-up.d.ts +1 -2
- package/esm/mouse-up.js +5 -5
- package/esm/press.d.ts +0 -1
- package/esm/press.js +9 -10
- package/esm/query.d.ts +3989 -0
- package/esm/query.js +10 -0
- package/esm/react.d.ts +7 -0
- package/esm/react.js +90 -0
- package/esm/select.d.ts +1 -2
- package/esm/select.js +11 -12
- package/esm/sleep.js +4 -4
- package/esm/tap.d.ts +1 -2
- package/esm/tap.js +12 -13
- package/esm/type.d.ts +0 -1
- package/esm/type.js +7 -8
- package/esm/wait-for.d.ts +2 -1
- package/esm/wait-for.js +4 -2
- package/package.json +85 -40
- package/query/package.json +8 -0
- package/react/package.json +8 -0
- package/act/package.json +0 -8
- package/cjs/__chunks/3NIZQX5J.cjs +0 -6
- package/cjs/__chunks/3WW644T7.cjs +0 -20
- package/cjs/__chunks/5F5PNQCC.cjs +0 -22
- package/cjs/__chunks/7BZFO6FC.cjs +0 -12
- package/cjs/__chunks/7RUXTAPP.cjs +0 -16
- package/cjs/__chunks/AYRPODWR.cjs +0 -1
- package/cjs/__chunks/B4VP2LEU.cjs +0 -28
- package/cjs/__chunks/BHNBCXUN.cjs +0 -33
- package/cjs/__chunks/EGF4KWUK.cjs +0 -64
- package/cjs/__chunks/HGTTGPFK.cjs +0 -54
- package/cjs/__chunks/JY5DGPUE.cjs +0 -14
- package/cjs/__chunks/KRQVK4KQ.cjs +0 -38
- package/cjs/__chunks/LFNIGEB6.cjs +0 -50
- package/cjs/__chunks/MQA5IB4L.cjs +0 -6
- package/cjs/__chunks/Q7PN3HIB.cjs +0 -121
- package/cjs/__chunks/SYQ5J5KP.cjs +0 -32
- package/cjs/__chunks/VIKUJSTX.cjs +0 -83
- package/cjs/act.cjs +0 -8
- package/cjs/act.d.ts +0 -1
- package/cjs/fire-event.cjs +0 -9
- package/cjs/fire-event.d.ts +0 -3
- package/cjs/polyfills.cjs +0 -3
- package/cjs/render.cjs +0 -9
- package/cjs/render.d.ts +0 -5
- package/cjs/screen.cjs +0 -55
- package/cjs/screen.d.ts +0 -26
- package/cjs/tsconfig.build.tsbuildinfo +0 -1
- package/cjs/within.cjs +0 -7
- package/cjs/within.d.ts +0 -1
- package/esm/__chunks/2OZA4WAZ.js +0 -50
- package/esm/__chunks/2RHTJFSK.js +0 -38
- package/esm/__chunks/3C72DPE2.js +0 -54
- package/esm/__chunks/4A3YKZRA.js +0 -121
- package/esm/__chunks/5JPM5LQX.js +0 -6
- package/esm/__chunks/5PINJ4MD.js +0 -16
- package/esm/__chunks/AEOE57TZ.js +0 -33
- package/esm/__chunks/EVYPE6ZJ.js +0 -32
- package/esm/__chunks/EX5WPJOU.js +0 -64
- package/esm/__chunks/JTFRQL3H.js +0 -83
- package/esm/__chunks/LJWZLI6L.js +0 -14
- package/esm/__chunks/OQYWQML5.js +0 -12
- package/esm/__chunks/OSCTTZUZ.js +0 -28
- package/esm/__chunks/PNBZ5NXH.js +0 -0
- package/esm/__chunks/QA3ZS6S2.js +0 -6
- package/esm/__chunks/R7IYW63J.js +0 -22
- package/esm/__chunks/ZEO5Q6UD.js +0 -20
- package/esm/act.d.ts +0 -1
- package/esm/act.js +0 -8
- package/esm/fire-event.d.ts +0 -3
- package/esm/fire-event.js +0 -9
- package/esm/polyfills.d.ts +0 -1
- package/esm/polyfills.js +0 -3
- package/esm/render.d.ts +0 -5
- package/esm/render.js +0 -9
- package/esm/screen.d.ts +0 -26
- package/esm/screen.js +0 -55
- package/esm/tsconfig.build.tsbuildinfo +0 -1
- package/esm/within.d.ts +0 -1
- package/esm/within.js +0 -7
- package/fire-event/package.json +0 -8
- package/polyfills/package.json +0 -8
- package/render/package.json +0 -8
- package/screen/package.json +0 -8
- package/within/package.json +0 -8
- /package/cjs/{polyfills.d.ts → __tests__/blur-test.d.cts} +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "./Q65FZOE2.js";
|
|
6
|
+
|
|
7
|
+
// src/query.ts
|
|
8
|
+
import { queries as baseQueries } from "@testing-library/dom";
|
|
9
|
+
var roles = [
|
|
10
|
+
"alert",
|
|
11
|
+
"alertdialog",
|
|
12
|
+
"application",
|
|
13
|
+
"article",
|
|
14
|
+
"banner",
|
|
15
|
+
"blockquote",
|
|
16
|
+
"button",
|
|
17
|
+
"caption",
|
|
18
|
+
"cell",
|
|
19
|
+
"checkbox",
|
|
20
|
+
"code",
|
|
21
|
+
"columnheader",
|
|
22
|
+
"combobox",
|
|
23
|
+
"complementary",
|
|
24
|
+
"contentinfo",
|
|
25
|
+
"definition",
|
|
26
|
+
"deletion",
|
|
27
|
+
"dialog",
|
|
28
|
+
"directory",
|
|
29
|
+
"document",
|
|
30
|
+
"emphasis",
|
|
31
|
+
"feed",
|
|
32
|
+
"figure",
|
|
33
|
+
"form",
|
|
34
|
+
"generic",
|
|
35
|
+
"grid",
|
|
36
|
+
"gridcell",
|
|
37
|
+
"group",
|
|
38
|
+
"heading",
|
|
39
|
+
"img",
|
|
40
|
+
"insertion",
|
|
41
|
+
"link",
|
|
42
|
+
"list",
|
|
43
|
+
"listbox",
|
|
44
|
+
"listitem",
|
|
45
|
+
"log",
|
|
46
|
+
"main",
|
|
47
|
+
"marquee",
|
|
48
|
+
"math",
|
|
49
|
+
"menu",
|
|
50
|
+
"menubar",
|
|
51
|
+
"menuitem",
|
|
52
|
+
"menuitemcheckbox",
|
|
53
|
+
"menuitemradio",
|
|
54
|
+
"meter",
|
|
55
|
+
"navigation",
|
|
56
|
+
"none",
|
|
57
|
+
"note",
|
|
58
|
+
"option",
|
|
59
|
+
"paragraph",
|
|
60
|
+
"presentation",
|
|
61
|
+
"progressbar",
|
|
62
|
+
"radio",
|
|
63
|
+
"radiogroup",
|
|
64
|
+
"region",
|
|
65
|
+
"row",
|
|
66
|
+
"rowgroup",
|
|
67
|
+
"rowheader",
|
|
68
|
+
"scrollbar",
|
|
69
|
+
"search",
|
|
70
|
+
"searchbox",
|
|
71
|
+
"separator",
|
|
72
|
+
"slider",
|
|
73
|
+
"spinbutton",
|
|
74
|
+
"status",
|
|
75
|
+
"strong",
|
|
76
|
+
"subscript",
|
|
77
|
+
"superscript",
|
|
78
|
+
"switch",
|
|
79
|
+
"tab",
|
|
80
|
+
"table",
|
|
81
|
+
"tablist",
|
|
82
|
+
"tabpanel",
|
|
83
|
+
"term",
|
|
84
|
+
"textbox",
|
|
85
|
+
"time",
|
|
86
|
+
"timer",
|
|
87
|
+
"toolbar",
|
|
88
|
+
"tooltip",
|
|
89
|
+
"tree",
|
|
90
|
+
"treegrid",
|
|
91
|
+
"treeitem"
|
|
92
|
+
];
|
|
93
|
+
var queries = Object.entries(baseQueries).reduce((queries2, [key, query2]) => {
|
|
94
|
+
queries2[key] = (...args) => query2(document.body, ...args);
|
|
95
|
+
return queries2;
|
|
96
|
+
}, {});
|
|
97
|
+
function matchName(name, accessibleName) {
|
|
98
|
+
if (accessibleName == null)
|
|
99
|
+
return false;
|
|
100
|
+
if (typeof name === "string") {
|
|
101
|
+
return accessibleName === name;
|
|
102
|
+
}
|
|
103
|
+
return name.test(accessibleName);
|
|
104
|
+
}
|
|
105
|
+
function getNameOption(name) {
|
|
106
|
+
return (accessibleName, element) => {
|
|
107
|
+
if (matchName(name, accessibleName))
|
|
108
|
+
return true;
|
|
109
|
+
if (element.getAttribute("aria-label"))
|
|
110
|
+
return false;
|
|
111
|
+
const labeledBy = element.getAttribute("aria-labelledby");
|
|
112
|
+
if (!labeledBy) {
|
|
113
|
+
const content = "placeholder" in element && element.placeholder != null ? element.placeholder : element.textContent;
|
|
114
|
+
return matchName(name, content);
|
|
115
|
+
}
|
|
116
|
+
const label = document.getElementById(labeledBy);
|
|
117
|
+
if (!(label == null ? void 0 : label.textContent))
|
|
118
|
+
return false;
|
|
119
|
+
return matchName(name, label.textContent);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function createRoleQuery(role) {
|
|
123
|
+
const createQuery = (query3) => {
|
|
124
|
+
return (name, options) => {
|
|
125
|
+
if (!name) {
|
|
126
|
+
return query3(role, options);
|
|
127
|
+
}
|
|
128
|
+
return query3(role, __spreadValues({ name: getNameOption(name) }, options));
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
const createIncludesHidden = (query3) => (name, options) => query3(name, __spreadValues({ hidden: true }, options));
|
|
132
|
+
const query2 = createQuery(queries.queryByRole);
|
|
133
|
+
const allQuery = createQuery(queries.queryAllByRole);
|
|
134
|
+
const waitQuery = createQuery(queries.findByRole);
|
|
135
|
+
const waitAllQuery = createQuery(queries.findAllByRole);
|
|
136
|
+
const ensureQuery = createQuery(queries.getByRole);
|
|
137
|
+
const ensureAllQuery = createQuery(queries.getAllByRole);
|
|
138
|
+
const all = Object.assign(allQuery, {
|
|
139
|
+
includesHidden: createIncludesHidden(allQuery),
|
|
140
|
+
wait: Object.assign(waitAllQuery, {
|
|
141
|
+
includesHidden: createIncludesHidden(waitAllQuery)
|
|
142
|
+
}),
|
|
143
|
+
ensure: Object.assign(ensureAllQuery, {
|
|
144
|
+
includesHidden: createIncludesHidden(ensureAllQuery)
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
const wait = Object.assign(waitQuery, {
|
|
148
|
+
includesHidden: createIncludesHidden(waitQuery),
|
|
149
|
+
all: Object.assign(waitAllQuery, {
|
|
150
|
+
includesHidden: createIncludesHidden(waitAllQuery)
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
const ensure = Object.assign(ensureQuery, {
|
|
154
|
+
includesHidden: createIncludesHidden(ensureQuery),
|
|
155
|
+
all: Object.assign(ensureAllQuery, {
|
|
156
|
+
includesHidden: createIncludesHidden(ensureAllQuery)
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
return Object.assign(query2, {
|
|
160
|
+
includesHidden: createIncludesHidden(query2),
|
|
161
|
+
all,
|
|
162
|
+
wait,
|
|
163
|
+
ensure
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function createTextQuery() {
|
|
167
|
+
const all = Object.assign(queries.queryAllByText, {
|
|
168
|
+
wait: queries.findAllByText,
|
|
169
|
+
ensure: queries.getAllByText
|
|
170
|
+
});
|
|
171
|
+
const wait = Object.assign(queries.findByText, {
|
|
172
|
+
all: queries.findAllByText
|
|
173
|
+
});
|
|
174
|
+
const ensure = Object.assign(queries.getByText, {
|
|
175
|
+
all: queries.getAllByText
|
|
176
|
+
});
|
|
177
|
+
return Object.assign(queries.queryByText, { all, wait, ensure });
|
|
178
|
+
}
|
|
179
|
+
function createLabeledQuery() {
|
|
180
|
+
const all = Object.assign(queries.queryAllByLabelText, {
|
|
181
|
+
wait: queries.findAllByLabelText,
|
|
182
|
+
ensure: queries.getAllByLabelText
|
|
183
|
+
});
|
|
184
|
+
const wait = Object.assign(queries.findByLabelText, {
|
|
185
|
+
all: queries.findAllByLabelText
|
|
186
|
+
});
|
|
187
|
+
const ensure = Object.assign(queries.getByLabelText, {
|
|
188
|
+
all: queries.getAllByLabelText
|
|
189
|
+
});
|
|
190
|
+
return Object.assign(queries.queryByLabelText, { all, wait, ensure });
|
|
191
|
+
}
|
|
192
|
+
var roleQueries = roles.reduce((acc, role) => {
|
|
193
|
+
acc[role] = createRoleQuery(role);
|
|
194
|
+
return acc;
|
|
195
|
+
}, {});
|
|
196
|
+
var query = __spreadProps(__spreadValues({}, roleQueries), {
|
|
197
|
+
text: createTextQuery(),
|
|
198
|
+
labeled: createLabeledQuery()
|
|
199
|
+
});
|
|
200
|
+
var q = query;
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
query,
|
|
204
|
+
q
|
|
205
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
focus
|
|
4
|
+
} from "./WAYMNUAF.js";
|
|
5
|
+
import {
|
|
6
|
+
dispatch
|
|
7
|
+
} from "./7JP5HWUW.js";
|
|
8
|
+
import {
|
|
9
|
+
sleep
|
|
10
|
+
} from "./YNAZUNNE.js";
|
|
11
|
+
import {
|
|
12
|
+
wrapAsync
|
|
13
|
+
} from "./LHKK7Y5F.js";
|
|
14
|
+
import {
|
|
15
|
+
__spreadValues
|
|
16
|
+
} from "./Q65FZOE2.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")
|
|
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 wrapAsync(async () => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
if (element == null) {
|
|
46
|
+
element = document.activeElement;
|
|
47
|
+
}
|
|
48
|
+
if (!element)
|
|
49
|
+
return;
|
|
50
|
+
if (!isFocusable(element))
|
|
51
|
+
return;
|
|
52
|
+
await focus(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 dispatch.keyDown(element, __spreadValues({ key }, options));
|
|
60
|
+
element = getActiveElement(element) || element;
|
|
61
|
+
if (isTextField(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 dispatch.keyPress(input, __spreadValues({
|
|
90
|
+
key,
|
|
91
|
+
charCode: key.charCodeAt(0)
|
|
92
|
+
}, options));
|
|
93
|
+
}
|
|
94
|
+
if (inputType === "insertCompositionText") {
|
|
95
|
+
defaultAllowed = await dispatch.compositionUpdate(input, __spreadValues({
|
|
96
|
+
data: char,
|
|
97
|
+
target: { value }
|
|
98
|
+
}, options));
|
|
99
|
+
}
|
|
100
|
+
if (defaultAllowed) {
|
|
101
|
+
await dispatch.input(input, __spreadValues({
|
|
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 sleep();
|
|
117
|
+
await dispatch.keyUp(element, __spreadValues({ key }, options));
|
|
118
|
+
await sleep();
|
|
119
|
+
}
|
|
120
|
+
restoreEmailInput();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
type
|
|
126
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/__utils.ts
|
|
4
|
+
import { isFocusable } from "@ariakit/core/utils/focus";
|
|
5
|
+
import { noop } from "@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 noop;
|
|
27
|
+
const originalFocus = HTMLElement.prototype.focus;
|
|
28
|
+
HTMLElement.prototype.focus = function focus(options) {
|
|
29
|
+
if (!isFocusable(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
|
+
export {
|
|
68
|
+
isBrowser,
|
|
69
|
+
flushMicrotasks,
|
|
70
|
+
nextFrame,
|
|
71
|
+
wrapAsync
|
|
72
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
dispatch
|
|
4
|
+
} from "./7JP5HWUW.js";
|
|
5
|
+
import {
|
|
6
|
+
wrapAsync
|
|
7
|
+
} from "./LHKK7Y5F.js";
|
|
8
|
+
import {
|
|
9
|
+
__spreadValues
|
|
10
|
+
} from "./Q65FZOE2.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))
|
|
19
|
+
return;
|
|
20
|
+
const { disabled } = element;
|
|
21
|
+
await dispatch.pointerUp(element, options);
|
|
22
|
+
if (disabled)
|
|
23
|
+
return;
|
|
24
|
+
await dispatch.mouseUp(element, __spreadValues({ detail: 1 }, options));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
mouseUp
|
|
30
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
blur
|
|
4
|
+
} from "./ZIWQZF7I.js";
|
|
5
|
+
import {
|
|
6
|
+
focus
|
|
7
|
+
} from "./WAYMNUAF.js";
|
|
8
|
+
import {
|
|
9
|
+
dispatch
|
|
10
|
+
} from "./7JP5HWUW.js";
|
|
11
|
+
import {
|
|
12
|
+
wrapAsync
|
|
13
|
+
} from "./LHKK7Y5F.js";
|
|
14
|
+
import {
|
|
15
|
+
__spreadValues
|
|
16
|
+
} from "./Q65FZOE2.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))
|
|
26
|
+
return;
|
|
27
|
+
const { disabled } = element;
|
|
28
|
+
let defaultAllowed = await dispatch.pointerDown(element, options);
|
|
29
|
+
if (!disabled) {
|
|
30
|
+
if (!await dispatch.mouseDown(element, __spreadValues({ detail: 1 }, options))) {
|
|
31
|
+
defaultAllowed = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (defaultAllowed) {
|
|
35
|
+
const selection = getDocument(element).getSelection();
|
|
36
|
+
if (selection && selection.rangeCount) {
|
|
37
|
+
const range = selection.getRangeAt(0);
|
|
38
|
+
if (!range.collapsed) {
|
|
39
|
+
selection.removeAllRanges();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (isFocusable(element) && getComputedStyle(element).pointerEvents !== "none") {
|
|
43
|
+
await focus(element);
|
|
44
|
+
} else if (element.parentElement) {
|
|
45
|
+
const closestFocusable = getClosestFocusable(element.parentElement);
|
|
46
|
+
if (closestFocusable) {
|
|
47
|
+
await focus(closestFocusable);
|
|
48
|
+
} else {
|
|
49
|
+
await blur();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
mouseDown
|
|
58
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|