@stonecrop/utilities 0.2.33 → 0.2.34
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/src/composables/visibility/index.d.ts +1 -1
- package/dist/src/composables/visibility/index.d.ts.map +1 -1
- package/dist/utilities/src/tsdoc-metadata.json +1 -1
- package/dist/utilities.js +101 -101
- package/dist/utilities.js.map +1 -1
- package/dist/utilities.umd.cjs +1 -1
- package/dist/utilities.umd.cjs.map +1 -1
- package/package.json +6 -6
|
@@ -19,5 +19,5 @@ export interface UseElementVisibilityOptions extends ConfigurableWindow {
|
|
|
19
19
|
* @param element
|
|
20
20
|
* @param options
|
|
21
21
|
*/
|
|
22
|
-
export declare function useElementVisibility(element: MaybeComputedElementRef, { window, scrollTarget }?: UseElementVisibilityOptions): import("vue").Ref<boolean>;
|
|
22
|
+
export declare function useElementVisibility(element: MaybeComputedElementRef, { window, scrollTarget }?: UseElementVisibilityOptions): import("vue").Ref<boolean, boolean>;
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/composables/visibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAIrB,MAAM,cAAc,CAAA;AAGrB,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACtE,YAAY,CAAC,EAAE,gBAAgB,CAAC,WAAW,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;CAC/D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,uBAAuB,EAChC,EAAE,MAAsB,EAAE,YAAY,EAAE,GAAE,2BAAgC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/composables/visibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EAIrB,MAAM,cAAc,CAAA;AAGrB,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACtE,YAAY,CAAC,EAAE,gBAAgB,CAAC,WAAW,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;CAC/D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,uBAAuB,EAChC,EAAE,MAAsB,EAAE,YAAY,EAAE,GAAE,2BAAgC,uCAmC1E"}
|
package/dist/utilities.js
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { getCurrentScope as W, onScopeDispose as K, unref as V, computed as b, ref as y, watch as T, getCurrentInstance as F, onMounted as U, onBeforeUnmount as j } from "vue";
|
|
2
|
+
function I(e) {
|
|
3
|
+
return W() ? (K(e), !0) : !1;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
return typeof e == "function" ? e() :
|
|
5
|
+
function A(e) {
|
|
6
|
+
return typeof e == "function" ? e() : V(e);
|
|
7
7
|
}
|
|
8
|
-
const
|
|
8
|
+
const B = typeof window < "u" && typeof document < "u";
|
|
9
9
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
10
10
|
const q = (e) => e != null, G = Object.prototype.toString, z = (e) => G.call(e) === "[object Object]", J = () => {
|
|
11
|
-
};
|
|
11
|
+
}, w = B ? window : void 0;
|
|
12
12
|
function C(e) {
|
|
13
13
|
var t;
|
|
14
|
-
const n =
|
|
14
|
+
const n = A(e);
|
|
15
15
|
return (t = n == null ? void 0 : n.$el) != null ? t : n;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (typeof e[0] == "string" || Array.isArray(e[0]) ? ([n, o, c] = e, t = b) : [t, n, o, c] = e, !t)
|
|
17
|
+
function h(...e) {
|
|
18
|
+
let t, n, o, i;
|
|
19
|
+
if (typeof e[0] == "string" || Array.isArray(e[0]) ? ([n, o, i] = e, t = w) : [t, n, o, i] = e, !t)
|
|
21
20
|
return J;
|
|
22
21
|
Array.isArray(n) || (n = [n]), Array.isArray(o) || (o = [o]);
|
|
23
22
|
const l = [], r = () => {
|
|
24
|
-
l.forEach((
|
|
25
|
-
}, s = (
|
|
26
|
-
() => [C(t),
|
|
27
|
-
([
|
|
28
|
-
if (r(), !
|
|
23
|
+
l.forEach((c) => c()), l.length = 0;
|
|
24
|
+
}, s = (c, p, u, d) => (c.addEventListener(p, u, d), () => c.removeEventListener(p, u, d)), a = T(
|
|
25
|
+
() => [C(t), A(i)],
|
|
26
|
+
([c, p]) => {
|
|
27
|
+
if (r(), !c)
|
|
29
28
|
return;
|
|
30
29
|
const u = z(p) ? { ...p } : p;
|
|
31
30
|
l.push(
|
|
32
|
-
...n.flatMap((d) => o.map((
|
|
31
|
+
...n.flatMap((d) => o.map(($) => s(c, d, $, u)))
|
|
33
32
|
);
|
|
34
33
|
},
|
|
35
34
|
{ immediate: !0, flush: "post" }
|
|
36
35
|
), f = () => {
|
|
37
36
|
a(), r();
|
|
38
37
|
};
|
|
39
|
-
return
|
|
38
|
+
return I(f), f;
|
|
40
39
|
}
|
|
41
40
|
function Q() {
|
|
42
|
-
const e =
|
|
43
|
-
return t &&
|
|
41
|
+
const e = y(!1), t = F();
|
|
42
|
+
return t && U(() => {
|
|
44
43
|
e.value = !0;
|
|
45
44
|
}, t), e;
|
|
46
45
|
}
|
|
47
46
|
function X(e) {
|
|
48
47
|
const t = Q();
|
|
49
|
-
return
|
|
48
|
+
return b(() => (t.value, !!e()));
|
|
50
49
|
}
|
|
51
50
|
function Y(e, t, n = {}) {
|
|
52
|
-
const { window: o =
|
|
51
|
+
const { window: o = w, ...i } = n;
|
|
53
52
|
let l;
|
|
54
53
|
const r = X(() => o && "MutationObserver" in o), s = () => {
|
|
55
54
|
l && (l.disconnect(), l = void 0);
|
|
56
|
-
}, a =
|
|
57
|
-
const u =
|
|
55
|
+
}, a = b(() => {
|
|
56
|
+
const u = A(e), d = (Array.isArray(u) ? u : [u]).map(C).filter(q);
|
|
58
57
|
return new Set(d);
|
|
59
|
-
}), f =
|
|
58
|
+
}), f = T(
|
|
60
59
|
() => a.value,
|
|
61
60
|
(u) => {
|
|
62
|
-
s(), r.value && u.size && (l = new MutationObserver(t), u.forEach((d) => l.observe(d,
|
|
61
|
+
s(), r.value && u.size && (l = new MutationObserver(t), u.forEach((d) => l.observe(d, i)));
|
|
63
62
|
},
|
|
64
63
|
{ immediate: !0, flush: "post" }
|
|
65
|
-
),
|
|
66
|
-
|
|
64
|
+
), c = () => l == null ? void 0 : l.takeRecords(), p = () => {
|
|
65
|
+
f(), s();
|
|
67
66
|
};
|
|
68
|
-
return
|
|
67
|
+
return I(p), {
|
|
69
68
|
isSupported: r,
|
|
70
69
|
stop: p,
|
|
71
|
-
takeRecords:
|
|
70
|
+
takeRecords: c
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
function Z(e = {}) {
|
|
75
74
|
var t;
|
|
76
75
|
const {
|
|
77
|
-
window: n =
|
|
76
|
+
window: n = w,
|
|
78
77
|
deep: o = !0,
|
|
79
|
-
triggerOnRemoval:
|
|
78
|
+
triggerOnRemoval: i = !1
|
|
80
79
|
} = e, l = (t = e.document) != null ? t : n == null ? void 0 : n.document, r = () => {
|
|
81
80
|
var f;
|
|
82
|
-
let
|
|
81
|
+
let c = l == null ? void 0 : l.activeElement;
|
|
83
82
|
if (o)
|
|
84
|
-
for (;
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
-
}, s =
|
|
83
|
+
for (; c != null && c.shadowRoot; )
|
|
84
|
+
c = (f = c == null ? void 0 : c.shadowRoot) == null ? void 0 : f.activeElement;
|
|
85
|
+
return c;
|
|
86
|
+
}, s = y(), a = () => {
|
|
88
87
|
s.value = r();
|
|
89
88
|
};
|
|
90
|
-
return n && (
|
|
89
|
+
return n && (h(n, "blur", (f) => {
|
|
91
90
|
f.relatedTarget === null && a();
|
|
92
|
-
}, !0),
|
|
93
|
-
f.filter((
|
|
94
|
-
|
|
91
|
+
}, !0), h(n, "focus", a, !0)), i && Y(l, (f) => {
|
|
92
|
+
f.filter((c) => c.removedNodes.length).map((c) => Array.from(c.removedNodes)).flat().forEach((c) => {
|
|
93
|
+
c === s.value && a();
|
|
95
94
|
});
|
|
96
95
|
}, {
|
|
97
96
|
childList: !0,
|
|
98
97
|
subtree: !0
|
|
99
98
|
}), a(), s;
|
|
100
99
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
const ee = "focusin", te = "focusout";
|
|
101
|
+
function ne(e, t = {}) {
|
|
102
|
+
const { window: n = w } = t, o = b(() => C(e)), i = y(!1), l = b(() => i.value), r = Z(t);
|
|
103
|
+
return !n || !r.value ? { focused: l } : (h(o, ee, () => i.value = !0), h(o, te, () => i.value = !1), { focused: l });
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
const o =
|
|
105
|
+
function oe(e, { window: t = w, scrollTarget: n } = {}) {
|
|
106
|
+
const o = y(!1), i = () => {
|
|
107
107
|
if (!t) return;
|
|
108
108
|
const l = t.document, r = C(e);
|
|
109
109
|
if (!r)
|
|
@@ -113,17 +113,17 @@ function te(e, { window: t = b, scrollTarget: n } = {}) {
|
|
|
113
113
|
o.value = s.top <= (t.innerHeight || l.documentElement.clientHeight) && s.left <= (t.innerWidth || l.documentElement.clientWidth) && s.bottom >= 0 && s.right >= 0;
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
return
|
|
116
|
+
return T(
|
|
117
117
|
() => C(e),
|
|
118
|
-
() =>
|
|
118
|
+
() => i(),
|
|
119
119
|
{ immediate: !0, flush: "post" }
|
|
120
|
-
), t &&
|
|
120
|
+
), t && h(n || t, "scroll", i, {
|
|
121
121
|
capture: !1,
|
|
122
122
|
passive: !0
|
|
123
123
|
}), o;
|
|
124
124
|
}
|
|
125
125
|
const m = (e) => {
|
|
126
|
-
let t =
|
|
126
|
+
let t = oe(e).value;
|
|
127
127
|
return t = t && e.offsetHeight > 0, t;
|
|
128
128
|
}, g = (e) => e.tabIndex >= 0, x = (e) => {
|
|
129
129
|
const t = e.target;
|
|
@@ -142,20 +142,20 @@ const m = (e) => {
|
|
|
142
142
|
o && (t = o);
|
|
143
143
|
}
|
|
144
144
|
return t && (!g(t) || !m(t)) ? M(t) : t;
|
|
145
|
-
},
|
|
145
|
+
}, re = (e) => {
|
|
146
146
|
var o;
|
|
147
147
|
const t = e.target;
|
|
148
148
|
let n;
|
|
149
149
|
if (t instanceof HTMLTableCellElement) {
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
const r =
|
|
150
|
+
const i = (o = t.parentElement) == null ? void 0 : o.parentElement;
|
|
151
|
+
if (i) {
|
|
152
|
+
const r = i.firstElementChild.children[t.cellIndex];
|
|
153
153
|
r && (n = r);
|
|
154
154
|
}
|
|
155
155
|
} else if (t instanceof HTMLTableRowElement) {
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const l =
|
|
156
|
+
const i = t.parentElement;
|
|
157
|
+
if (i) {
|
|
158
|
+
const l = i.firstElementChild;
|
|
159
159
|
l && (n = l);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -177,20 +177,20 @@ const m = (e) => {
|
|
|
177
177
|
o && (t = o);
|
|
178
178
|
}
|
|
179
179
|
return t && (!g(t) || !m(t)) ? k(t) : t;
|
|
180
|
-
},
|
|
180
|
+
}, le = (e) => {
|
|
181
181
|
var o;
|
|
182
182
|
const t = e.target;
|
|
183
183
|
let n;
|
|
184
184
|
if (t instanceof HTMLTableCellElement) {
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
const r =
|
|
185
|
+
const i = (o = t.parentElement) == null ? void 0 : o.parentElement;
|
|
186
|
+
if (i) {
|
|
187
|
+
const r = i.lastElementChild.children[t.cellIndex];
|
|
188
188
|
r && (n = r);
|
|
189
189
|
}
|
|
190
190
|
} else if (t instanceof HTMLTableRowElement) {
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
const l =
|
|
191
|
+
const i = t.parentElement;
|
|
192
|
+
if (i) {
|
|
193
|
+
const l = i.lastElementChild;
|
|
194
194
|
l && (n = l);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -221,18 +221,18 @@ const m = (e) => {
|
|
|
221
221
|
t = o == null ? void 0 : o.firstElementChild;
|
|
222
222
|
}
|
|
223
223
|
return t && (!g(t) || !m(t)) ? R(t) : t;
|
|
224
|
-
},
|
|
224
|
+
}, _ = (e) => {
|
|
225
225
|
const o = e.target.parentElement.firstElementChild;
|
|
226
226
|
return o && (!g(o) || !m(o)) ? R(o) : o;
|
|
227
|
-
},
|
|
227
|
+
}, N = (e) => {
|
|
228
228
|
const o = e.target.parentElement.lastElementChild;
|
|
229
229
|
return o && (!g(o) || !m(o)) ? L(o) : o;
|
|
230
|
-
},
|
|
230
|
+
}, v = ["alt", "control", "shift", "meta"], se = {
|
|
231
231
|
ArrowUp: "up",
|
|
232
232
|
ArrowDown: "down",
|
|
233
233
|
ArrowLeft: "left",
|
|
234
234
|
ArrowRight: "right"
|
|
235
|
-
},
|
|
235
|
+
}, ie = {
|
|
236
236
|
"keydown.up": (e) => {
|
|
237
237
|
const t = x(e);
|
|
238
238
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
@@ -250,23 +250,23 @@ const m = (e) => {
|
|
|
250
250
|
e.preventDefault(), e.stopPropagation(), t && t.focus();
|
|
251
251
|
},
|
|
252
252
|
"keydown.control.up": (e) => {
|
|
253
|
-
const t =
|
|
253
|
+
const t = re(e);
|
|
254
254
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
255
255
|
},
|
|
256
256
|
"keydown.control.down": (e) => {
|
|
257
|
-
const t =
|
|
257
|
+
const t = le(e);
|
|
258
258
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
259
259
|
},
|
|
260
260
|
"keydown.control.left": (e) => {
|
|
261
|
-
const t =
|
|
261
|
+
const t = _(e);
|
|
262
262
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
263
263
|
},
|
|
264
264
|
"keydown.control.right": (e) => {
|
|
265
|
-
const t =
|
|
265
|
+
const t = N(e);
|
|
266
266
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
267
267
|
},
|
|
268
268
|
"keydown.end": (e) => {
|
|
269
|
-
const t =
|
|
269
|
+
const t = N(e);
|
|
270
270
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
271
271
|
},
|
|
272
272
|
"keydown.enter": (e) => {
|
|
@@ -284,7 +284,7 @@ const m = (e) => {
|
|
|
284
284
|
}
|
|
285
285
|
},
|
|
286
286
|
"keydown.home": (e) => {
|
|
287
|
-
const t =
|
|
287
|
+
const t = _(e);
|
|
288
288
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
289
289
|
},
|
|
290
290
|
"keydown.tab": (e) => {
|
|
@@ -296,7 +296,7 @@ const m = (e) => {
|
|
|
296
296
|
t && (e.preventDefault(), e.stopPropagation(), t.focus());
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
|
-
function
|
|
299
|
+
function ae(e) {
|
|
300
300
|
const t = (r) => {
|
|
301
301
|
let s = null;
|
|
302
302
|
return r.parent && (typeof r.parent == "string" ? s = document.querySelector(r.parent) : r.parent instanceof HTMLElement ? s = r.parent : s = r.parent.value), s;
|
|
@@ -319,24 +319,24 @@ function ie(e) {
|
|
|
319
319
|
}, o = (r) => {
|
|
320
320
|
const s = t(r);
|
|
321
321
|
let a = [];
|
|
322
|
-
return r.selectors ? a = n(r) : s && (a = Array.from(s.children).filter((
|
|
323
|
-
},
|
|
324
|
-
const a =
|
|
325
|
-
if (
|
|
326
|
-
const f = r.handlers ||
|
|
327
|
-
for (const
|
|
328
|
-
const [p, ...u] =
|
|
322
|
+
return r.selectors ? a = n(r) : s && (a = Array.from(s.children).filter((c) => g(c) && m(c))), a;
|
|
323
|
+
}, i = (r) => (s) => {
|
|
324
|
+
const a = se[s.key] || s.key.toLowerCase();
|
|
325
|
+
if (v.includes(a)) return;
|
|
326
|
+
const f = r.handlers || ie;
|
|
327
|
+
for (const c of Object.keys(f)) {
|
|
328
|
+
const [p, ...u] = c.split(".");
|
|
329
329
|
if (p === "keydown" && u.includes(a)) {
|
|
330
|
-
const d = f[
|
|
331
|
-
const
|
|
332
|
-
return s.getModifierState(
|
|
330
|
+
const d = f[c], $ = u.filter((E) => v.includes(E)), H = v.some((E) => {
|
|
331
|
+
const S = E.charAt(0).toUpperCase() + E.slice(1);
|
|
332
|
+
return s.getModifierState(S);
|
|
333
333
|
});
|
|
334
|
-
if (
|
|
334
|
+
if ($.length > 0) {
|
|
335
335
|
if (H) {
|
|
336
|
-
for (const
|
|
337
|
-
if (u.includes(
|
|
338
|
-
const
|
|
339
|
-
s.getModifierState(
|
|
336
|
+
for (const E of v)
|
|
337
|
+
if (u.includes(E)) {
|
|
338
|
+
const S = E.charAt(0).toUpperCase() + E.slice(1);
|
|
339
|
+
s.getModifierState(S) && d(s);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
} else
|
|
@@ -344,26 +344,26 @@ function ie(e) {
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}, l = [];
|
|
347
|
-
|
|
347
|
+
U(() => {
|
|
348
348
|
for (const r of e) {
|
|
349
|
-
const s = t(r), a = o(r), f =
|
|
350
|
-
for (const p of
|
|
351
|
-
const { focused: u } =
|
|
352
|
-
|
|
349
|
+
const s = t(r), a = o(r), f = i(r), c = s ? [s] : a;
|
|
350
|
+
for (const p of c) {
|
|
351
|
+
const { focused: u } = ne(y(p)), d = T(u, ($) => {
|
|
352
|
+
$ ? p.addEventListener("keydown", f) : p.removeEventListener("keydown", f);
|
|
353
353
|
});
|
|
354
354
|
l.push(d);
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
}),
|
|
357
|
+
}), j(() => {
|
|
358
358
|
for (const r of l)
|
|
359
359
|
r();
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function fe(e) {
|
|
363
363
|
}
|
|
364
364
|
export {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
ie as defaultKeypressHandlers,
|
|
366
|
+
fe as install,
|
|
367
|
+
ae as useKeyboardNav
|
|
368
368
|
};
|
|
369
369
|
//# sourceMappingURL=utilities.js.map
|