@stonecrop/utilities 0.2.10 → 0.2.11
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/dist/utilities.js +333 -0
- package/dist/utilities.js.map +1 -0
- package/dist/utilities.umd.cjs +2 -0
- package/dist/utilities.umd.cjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { unref as Q, getCurrentScope as U, onScopeDispose as K, ref as B, watch as D, onMounted as W, onBeforeUnmount as V } from "vue";
|
|
2
|
+
var v;
|
|
3
|
+
const M = typeof window < "u", F = (e) => typeof e == "string", j = () => {
|
|
4
|
+
};
|
|
5
|
+
M && ((v = window == null ? void 0 : window.navigator) != null && v.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
6
|
+
function H(e) {
|
|
7
|
+
return typeof e == "function" ? e() : Q(e);
|
|
8
|
+
}
|
|
9
|
+
function q(e) {
|
|
10
|
+
return e;
|
|
11
|
+
}
|
|
12
|
+
function G(e) {
|
|
13
|
+
return U() ? (K(e), !0) : !1;
|
|
14
|
+
}
|
|
15
|
+
function y(e) {
|
|
16
|
+
var t;
|
|
17
|
+
const r = H(e);
|
|
18
|
+
return (t = r == null ? void 0 : r.$el) != null ? t : r;
|
|
19
|
+
}
|
|
20
|
+
const N = M ? window : void 0;
|
|
21
|
+
function z(...e) {
|
|
22
|
+
let t, r, n, o;
|
|
23
|
+
if (F(e[0]) || Array.isArray(e[0]) ? ([r, n, o] = e, t = N) : [t, r, n, o] = e, !t)
|
|
24
|
+
return j;
|
|
25
|
+
Array.isArray(r) || (r = [r]), Array.isArray(n) || (n = [n]);
|
|
26
|
+
const l = [], s = () => {
|
|
27
|
+
l.forEach((c) => c()), l.length = 0;
|
|
28
|
+
}, a = (c, g, p, i) => (c.addEventListener(g, p, i), () => c.removeEventListener(g, p, i)), C = D(() => [y(t), H(o)], ([c, g]) => {
|
|
29
|
+
s(), c && l.push(...r.flatMap((p) => n.map((i) => a(c, p, i, g))));
|
|
30
|
+
}, { immediate: !0, flush: "post" }), d = () => {
|
|
31
|
+
C(), s();
|
|
32
|
+
};
|
|
33
|
+
return G(d), d;
|
|
34
|
+
}
|
|
35
|
+
const O = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, T = "__vueuse_ssr_handlers__";
|
|
36
|
+
O[T] = O[T] || {};
|
|
37
|
+
function J(e, { window: t = N, scrollTarget: r } = {}) {
|
|
38
|
+
const n = B(!1), o = () => {
|
|
39
|
+
if (!t)
|
|
40
|
+
return;
|
|
41
|
+
const l = t.document, s = y(e);
|
|
42
|
+
if (!s)
|
|
43
|
+
n.value = !1;
|
|
44
|
+
else {
|
|
45
|
+
const a = s.getBoundingClientRect();
|
|
46
|
+
n.value = a.top <= (t.innerHeight || l.documentElement.clientHeight) && a.left <= (t.innerWidth || l.documentElement.clientWidth) && a.bottom >= 0 && a.right >= 0;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return D(() => y(e), () => o(), { immediate: !0, flush: "post" }), t && z(r || t, "scroll", o, {
|
|
50
|
+
capture: !1,
|
|
51
|
+
passive: !0
|
|
52
|
+
}), n;
|
|
53
|
+
}
|
|
54
|
+
var P;
|
|
55
|
+
(function(e) {
|
|
56
|
+
e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
|
|
57
|
+
})(P || (P = {}));
|
|
58
|
+
var X = Object.defineProperty, I = Object.getOwnPropertySymbols, Y = Object.prototype.hasOwnProperty, Z = Object.prototype.propertyIsEnumerable, _ = (e, t, r) => t in e ? X(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, ee = (e, t) => {
|
|
59
|
+
for (var r in t || (t = {}))
|
|
60
|
+
Y.call(t, r) && _(e, r, t[r]);
|
|
61
|
+
if (I)
|
|
62
|
+
for (var r of I(t))
|
|
63
|
+
Z.call(t, r) && _(e, r, t[r]);
|
|
64
|
+
return e;
|
|
65
|
+
};
|
|
66
|
+
const te = {
|
|
67
|
+
easeInSine: [0.12, 0, 0.39, 0],
|
|
68
|
+
easeOutSine: [0.61, 1, 0.88, 1],
|
|
69
|
+
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
70
|
+
easeInQuad: [0.11, 0, 0.5, 0],
|
|
71
|
+
easeOutQuad: [0.5, 1, 0.89, 1],
|
|
72
|
+
easeInOutQuad: [0.45, 0, 0.55, 1],
|
|
73
|
+
easeInCubic: [0.32, 0, 0.67, 0],
|
|
74
|
+
easeOutCubic: [0.33, 1, 0.68, 1],
|
|
75
|
+
easeInOutCubic: [0.65, 0, 0.35, 1],
|
|
76
|
+
easeInQuart: [0.5, 0, 0.75, 0],
|
|
77
|
+
easeOutQuart: [0.25, 1, 0.5, 1],
|
|
78
|
+
easeInOutQuart: [0.76, 0, 0.24, 1],
|
|
79
|
+
easeInQuint: [0.64, 0, 0.78, 0],
|
|
80
|
+
easeOutQuint: [0.22, 1, 0.36, 1],
|
|
81
|
+
easeInOutQuint: [0.83, 0, 0.17, 1],
|
|
82
|
+
easeInExpo: [0.7, 0, 0.84, 0],
|
|
83
|
+
easeOutExpo: [0.16, 1, 0.3, 1],
|
|
84
|
+
easeInOutExpo: [0.87, 0, 0.13, 1],
|
|
85
|
+
easeInCirc: [0.55, 0, 1, 0.45],
|
|
86
|
+
easeOutCirc: [0, 0.55, 0.45, 1],
|
|
87
|
+
easeInOutCirc: [0.85, 0, 0.15, 1],
|
|
88
|
+
easeInBack: [0.36, 0, 0.66, -0.56],
|
|
89
|
+
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
90
|
+
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
91
|
+
};
|
|
92
|
+
ee({
|
|
93
|
+
linear: q
|
|
94
|
+
}, te);
|
|
95
|
+
const f = (e) => {
|
|
96
|
+
let t = J(e).value;
|
|
97
|
+
return t = t && e.offsetHeight > 0, t;
|
|
98
|
+
}, u = (e) => e.tabIndex >= 0, A = (e) => {
|
|
99
|
+
const t = e.target;
|
|
100
|
+
return E(t);
|
|
101
|
+
}, E = (e) => {
|
|
102
|
+
var r;
|
|
103
|
+
let t;
|
|
104
|
+
if (e instanceof HTMLTableCellElement) {
|
|
105
|
+
const n = (r = e.parentElement) == null ? void 0 : r.previousElementSibling;
|
|
106
|
+
if (n) {
|
|
107
|
+
const l = Array.from(n.children)[e.cellIndex];
|
|
108
|
+
l && (t = l);
|
|
109
|
+
}
|
|
110
|
+
} else if (e instanceof HTMLTableRowElement) {
|
|
111
|
+
const n = e.previousElementSibling;
|
|
112
|
+
n && (t = n);
|
|
113
|
+
}
|
|
114
|
+
return t && (!u(t) || !f(t)) ? E(t) : t;
|
|
115
|
+
}, ne = (e) => {
|
|
116
|
+
var n;
|
|
117
|
+
const t = e.target;
|
|
118
|
+
let r;
|
|
119
|
+
if (t instanceof HTMLTableCellElement) {
|
|
120
|
+
const o = (n = t.parentElement) == null ? void 0 : n.parentElement;
|
|
121
|
+
if (o) {
|
|
122
|
+
const s = o.firstElementChild.children[t.cellIndex];
|
|
123
|
+
s && (r = s);
|
|
124
|
+
}
|
|
125
|
+
} else if (t instanceof HTMLTableRowElement) {
|
|
126
|
+
const o = t.parentElement;
|
|
127
|
+
if (o) {
|
|
128
|
+
const l = o.firstElementChild;
|
|
129
|
+
l && (r = l);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return r && (!u(r) || !f(r)) ? w(r) : r;
|
|
133
|
+
}, x = (e) => {
|
|
134
|
+
const t = e.target;
|
|
135
|
+
return w(t);
|
|
136
|
+
}, w = (e) => {
|
|
137
|
+
var r;
|
|
138
|
+
let t;
|
|
139
|
+
if (e instanceof HTMLTableCellElement) {
|
|
140
|
+
const n = (r = e.parentElement) == null ? void 0 : r.nextElementSibling;
|
|
141
|
+
if (n) {
|
|
142
|
+
const l = Array.from(n.children)[e.cellIndex];
|
|
143
|
+
l && (t = l);
|
|
144
|
+
}
|
|
145
|
+
} else if (e instanceof HTMLTableRowElement) {
|
|
146
|
+
const n = e.nextElementSibling;
|
|
147
|
+
n && (t = n);
|
|
148
|
+
}
|
|
149
|
+
return t && (!u(t) || !f(t)) ? w(t) : t;
|
|
150
|
+
}, re = (e) => {
|
|
151
|
+
var n;
|
|
152
|
+
const t = e.target;
|
|
153
|
+
let r;
|
|
154
|
+
if (t instanceof HTMLTableCellElement) {
|
|
155
|
+
const o = (n = t.parentElement) == null ? void 0 : n.parentElement;
|
|
156
|
+
if (o) {
|
|
157
|
+
const s = o.lastElementChild.children[t.cellIndex];
|
|
158
|
+
s && (r = s);
|
|
159
|
+
}
|
|
160
|
+
} else if (t instanceof HTMLTableRowElement) {
|
|
161
|
+
const o = t.parentElement;
|
|
162
|
+
if (o) {
|
|
163
|
+
const l = o.lastElementChild;
|
|
164
|
+
l && (r = l);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return r && (!u(r) || !f(r)) ? E(r) : r;
|
|
168
|
+
}, k = (e) => {
|
|
169
|
+
const t = e.target;
|
|
170
|
+
return h(t);
|
|
171
|
+
}, h = (e) => {
|
|
172
|
+
var r;
|
|
173
|
+
let t;
|
|
174
|
+
if (e.previousElementSibling)
|
|
175
|
+
t = e.previousElementSibling;
|
|
176
|
+
else {
|
|
177
|
+
const n = (r = e.parentElement) == null ? void 0 : r.previousElementSibling;
|
|
178
|
+
t = n == null ? void 0 : n.lastElementChild;
|
|
179
|
+
}
|
|
180
|
+
return t && (!u(t) || !f(t)) ? h(t) : t;
|
|
181
|
+
}, S = (e) => {
|
|
182
|
+
const t = e.target;
|
|
183
|
+
return b(t);
|
|
184
|
+
}, b = (e) => {
|
|
185
|
+
var r;
|
|
186
|
+
let t;
|
|
187
|
+
if (e.nextElementSibling)
|
|
188
|
+
t = e.nextElementSibling;
|
|
189
|
+
else {
|
|
190
|
+
const n = (r = e.parentElement) == null ? void 0 : r.nextElementSibling;
|
|
191
|
+
t = n == null ? void 0 : n.firstElementChild;
|
|
192
|
+
}
|
|
193
|
+
return t && (!u(t) || !f(t)) ? b(t) : t;
|
|
194
|
+
}, L = (e) => {
|
|
195
|
+
const n = e.target.parentElement.firstElementChild;
|
|
196
|
+
return n && (!u(n) || !f(n)) ? b(n) : n;
|
|
197
|
+
}, R = (e) => {
|
|
198
|
+
const n = e.target.parentElement.lastElementChild;
|
|
199
|
+
return n && (!u(n) || !f(n)) ? h(n) : n;
|
|
200
|
+
}, m = ["alt", "control", "shift", "meta"], oe = {
|
|
201
|
+
ArrowUp: "up",
|
|
202
|
+
ArrowDown: "down",
|
|
203
|
+
ArrowLeft: "left",
|
|
204
|
+
ArrowRight: "right"
|
|
205
|
+
}, le = {
|
|
206
|
+
"keydown.up": (e) => {
|
|
207
|
+
const t = A(e);
|
|
208
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
209
|
+
},
|
|
210
|
+
"keydown.down": (e) => {
|
|
211
|
+
const t = x(e);
|
|
212
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
213
|
+
},
|
|
214
|
+
"keydown.left": (e) => {
|
|
215
|
+
const t = k(e);
|
|
216
|
+
e.preventDefault(), e.stopPropagation(), t && t.focus();
|
|
217
|
+
},
|
|
218
|
+
"keydown.right": (e) => {
|
|
219
|
+
const t = S(e);
|
|
220
|
+
e.preventDefault(), e.stopPropagation(), t && t.focus();
|
|
221
|
+
},
|
|
222
|
+
"keydown.control.up": (e) => {
|
|
223
|
+
const t = ne(e);
|
|
224
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
225
|
+
},
|
|
226
|
+
"keydown.control.down": (e) => {
|
|
227
|
+
const t = re(e);
|
|
228
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
229
|
+
},
|
|
230
|
+
"keydown.control.left": (e) => {
|
|
231
|
+
const t = L(e);
|
|
232
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
233
|
+
},
|
|
234
|
+
"keydown.control.right": (e) => {
|
|
235
|
+
const t = R(e);
|
|
236
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
237
|
+
},
|
|
238
|
+
"keydown.end": (e) => {
|
|
239
|
+
const t = R(e);
|
|
240
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
241
|
+
},
|
|
242
|
+
"keydown.enter": (e) => {
|
|
243
|
+
if (e.target instanceof HTMLTableCellElement) {
|
|
244
|
+
e.preventDefault(), e.stopPropagation();
|
|
245
|
+
const r = x(e);
|
|
246
|
+
r && r.focus();
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
"keydown.shift.enter": (e) => {
|
|
250
|
+
if (e.target instanceof HTMLTableCellElement) {
|
|
251
|
+
e.preventDefault(), e.stopPropagation();
|
|
252
|
+
const r = A(e);
|
|
253
|
+
r && r.focus();
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"keydown.home": (e) => {
|
|
257
|
+
const t = L(e);
|
|
258
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
259
|
+
},
|
|
260
|
+
"keydown.tab": (e) => {
|
|
261
|
+
const t = S(e);
|
|
262
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
263
|
+
},
|
|
264
|
+
"keydown.shift.tab": (e) => {
|
|
265
|
+
const t = k(e);
|
|
266
|
+
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
function ie(e) {
|
|
270
|
+
const t = (n) => {
|
|
271
|
+
let o = null;
|
|
272
|
+
n.parent && (typeof n.parent == "string" ? o = document.querySelector(n.parent) : n.parent instanceof Element ? o = n.parent : o = n.parent.value);
|
|
273
|
+
let l = [];
|
|
274
|
+
if (n.selectors)
|
|
275
|
+
if (typeof n.selectors == "string")
|
|
276
|
+
l = o ? Array.from(o.querySelectorAll(n.selectors)) : Array.from(document.querySelectorAll(n.selectors));
|
|
277
|
+
else if (n.selectors instanceof Element)
|
|
278
|
+
l.push(n.selectors);
|
|
279
|
+
else if (Array.isArray(n.selectors.value))
|
|
280
|
+
for (const s of n.selectors.value)
|
|
281
|
+
s instanceof Element ? l.push(s) : l.push(s.$el);
|
|
282
|
+
else
|
|
283
|
+
l.push(n.selectors.value);
|
|
284
|
+
else
|
|
285
|
+
l = Array.from(o.children).filter((a) => u(a) && f(a));
|
|
286
|
+
return l;
|
|
287
|
+
}, r = (n) => (o) => {
|
|
288
|
+
const l = oe[o.key] || o.key.toLowerCase();
|
|
289
|
+
if (m.includes(l))
|
|
290
|
+
return;
|
|
291
|
+
const s = n.handlers || le;
|
|
292
|
+
for (const a of Object.keys(s)) {
|
|
293
|
+
const [C, ...d] = a.split(".");
|
|
294
|
+
if (C === "keydown" && d.includes(l)) {
|
|
295
|
+
const c = s[a], g = d.filter((i) => m.includes(i)), p = m.some((i) => {
|
|
296
|
+
const $ = i.charAt(0).toUpperCase() + i.slice(1);
|
|
297
|
+
return o.getModifierState($);
|
|
298
|
+
});
|
|
299
|
+
if (g.length > 0) {
|
|
300
|
+
if (p) {
|
|
301
|
+
for (const i of m)
|
|
302
|
+
if (d.includes(i)) {
|
|
303
|
+
const $ = i.charAt(0).toUpperCase() + i.slice(1);
|
|
304
|
+
o.getModifierState($) && c(o);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
} else
|
|
308
|
+
p || c(o);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
W(() => {
|
|
313
|
+
for (const n of e) {
|
|
314
|
+
const o = t(n);
|
|
315
|
+
for (const l of o)
|
|
316
|
+
l.addEventListener("keydown", r(n));
|
|
317
|
+
}
|
|
318
|
+
}), V(() => {
|
|
319
|
+
for (const n of e) {
|
|
320
|
+
const o = t(n);
|
|
321
|
+
for (const l of o)
|
|
322
|
+
l.removeEventListener("keydown", r(n));
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function ae(e) {
|
|
327
|
+
}
|
|
328
|
+
export {
|
|
329
|
+
le as defaultKeypressHandlers,
|
|
330
|
+
ae as install,
|
|
331
|
+
ie as useKeyboardNav
|
|
332
|
+
};
|
|
333
|
+
//# sourceMappingURL=utilities.js.map
|