@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.
@@ -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,8BAmC1E"}
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"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.0"
8
+ "packageVersion": "7.47.9"
9
9
  }
10
10
  ]
11
11
  }
package/dist/utilities.js CHANGED
@@ -1,109 +1,109 @@
1
- import { unref as N, getCurrentScope as U, onScopeDispose as j, computed as y, ref as v, watch as w, getCurrentInstance as B, onMounted as K, onBeforeUnmount as V } from "vue";
2
- function _(e) {
3
- return U() ? (j(e), !0) : !1;
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 T(e) {
6
- return typeof e == "function" ? e() : N(e);
5
+ function A(e) {
6
+ return typeof e == "function" ? e() : V(e);
7
7
  }
8
- const F = typeof window < "u" && typeof document < "u";
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 = T(e);
14
+ const n = A(e);
15
15
  return (t = n == null ? void 0 : n.$el) != null ? t : n;
16
16
  }
17
- const b = F ? window : void 0;
18
- function S(...e) {
19
- let t, n, o, c;
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((i) => i()), l.length = 0;
25
- }, s = (i, p, u, d) => (i.addEventListener(p, u, d), () => i.removeEventListener(p, u, d)), a = w(
26
- () => [C(t), T(c)],
27
- ([i, p]) => {
28
- if (r(), !i)
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((E) => s(i, d, E, u)))
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 _(f), f;
38
+ return I(f), f;
40
39
  }
41
40
  function Q() {
42
- const e = v(!1), t = B();
43
- return t && K(() => {
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 y(() => (t.value, !!e()));
48
+ return b(() => (t.value, !!e()));
50
49
  }
51
50
  function Y(e, t, n = {}) {
52
- const { window: o = b, ...c } = n;
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 = y(() => {
57
- const u = T(e), d = (Array.isArray(u) ? u : [u]).map(C).filter(q);
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 = w(
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, c)));
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
- ), i = () => l == null ? void 0 : l.takeRecords(), p = () => {
66
- s(), f();
64
+ ), c = () => l == null ? void 0 : l.takeRecords(), p = () => {
65
+ f(), s();
67
66
  };
68
- return _(p), {
67
+ return I(p), {
69
68
  isSupported: r,
70
69
  stop: p,
71
- takeRecords: i
70
+ takeRecords: c
72
71
  };
73
72
  }
74
73
  function Z(e = {}) {
75
74
  var t;
76
75
  const {
77
- window: n = b,
76
+ window: n = w,
78
77
  deep: o = !0,
79
- triggerOnRemoval: c = !1
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 i = l == null ? void 0 : l.activeElement;
81
+ let c = l == null ? void 0 : l.activeElement;
83
82
  if (o)
84
- for (; i != null && i.shadowRoot; )
85
- i = (f = i == null ? void 0 : i.shadowRoot) == null ? void 0 : f.activeElement;
86
- return i;
87
- }, s = v(), a = () => {
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 && (S(n, "blur", (f) => {
89
+ return n && (h(n, "blur", (f) => {
91
90
  f.relatedTarget === null && a();
92
- }, !0), S(n, "focus", a, !0)), c && Y(l, (f) => {
93
- f.filter((i) => i.removedNodes.length).map((i) => Array.from(i.removedNodes)).flat().forEach((i) => {
94
- i === s.value && a();
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
- function ee(e, t = {}) {
102
- const n = Z(t), o = y(() => C(e));
103
- return { focused: y(() => o.value && n.value ? o.value.contains(n.value) : !1) };
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 te(e, { window: t = b, scrollTarget: n } = {}) {
106
- const o = v(!1), c = () => {
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 w(
116
+ return T(
117
117
  () => C(e),
118
- () => c(),
118
+ () => i(),
119
119
  { immediate: !0, flush: "post" }
120
- ), t && S(n || t, "scroll", c, {
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 = te(e).value;
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
- }, ne = (e) => {
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 c = (o = t.parentElement) == null ? void 0 : o.parentElement;
151
- if (c) {
152
- const r = c.firstElementChild.children[t.cellIndex];
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 c = t.parentElement;
157
- if (c) {
158
- const l = c.firstElementChild;
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
- }, oe = (e) => {
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 c = (o = t.parentElement) == null ? void 0 : o.parentElement;
186
- if (c) {
187
- const r = c.lastElementChild.children[t.cellIndex];
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 c = t.parentElement;
192
- if (c) {
193
- const l = c.lastElementChild;
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
- }, W = (e) => {
224
+ }, _ = (e) => {
225
225
  const o = e.target.parentElement.firstElementChild;
226
226
  return o && (!g(o) || !m(o)) ? R(o) : o;
227
- }, I = (e) => {
227
+ }, N = (e) => {
228
228
  const o = e.target.parentElement.lastElementChild;
229
229
  return o && (!g(o) || !m(o)) ? L(o) : o;
230
- }, h = ["alt", "control", "shift", "meta"], re = {
230
+ }, v = ["alt", "control", "shift", "meta"], se = {
231
231
  ArrowUp: "up",
232
232
  ArrowDown: "down",
233
233
  ArrowLeft: "left",
234
234
  ArrowRight: "right"
235
- }, le = {
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 = ne(e);
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 = oe(e);
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 = W(e);
261
+ const t = _(e);
262
262
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
263
263
  },
264
264
  "keydown.control.right": (e) => {
265
- const t = I(e);
265
+ const t = N(e);
266
266
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
267
267
  },
268
268
  "keydown.end": (e) => {
269
- const t = I(e);
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 = W(e);
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 ie(e) {
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((i) => g(i) && m(i))), a;
323
- }, c = (r) => (s) => {
324
- const a = re[s.key] || s.key.toLowerCase();
325
- if (h.includes(a)) return;
326
- const f = r.handlers || le;
327
- for (const i of Object.keys(f)) {
328
- const [p, ...u] = i.split(".");
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[i], E = u.filter(($) => h.includes($)), H = h.some(($) => {
331
- const A = $.charAt(0).toUpperCase() + $.slice(1);
332
- return s.getModifierState(A);
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 (E.length > 0) {
334
+ if ($.length > 0) {
335
335
  if (H) {
336
- for (const $ of h)
337
- if (u.includes($)) {
338
- const A = $.charAt(0).toUpperCase() + $.slice(1);
339
- s.getModifierState(A) && d(s);
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
- K(() => {
347
+ U(() => {
348
348
  for (const r of e) {
349
- const s = t(r), a = o(r), f = c(r), i = s ? [s] : a;
350
- for (const p of i) {
351
- const { focused: u } = ee(v(p)), d = w(u, (E) => {
352
- E ? p.addEventListener("keydown", f) : p.removeEventListener("keydown", f);
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
- }), V(() => {
357
+ }), j(() => {
358
358
  for (const r of l)
359
359
  r();
360
360
  });
361
361
  }
362
- function ce(e) {
362
+ function fe(e) {
363
363
  }
364
364
  export {
365
- le as defaultKeypressHandlers,
366
- ce as install,
367
- ie as useKeyboardNav
365
+ ie as defaultKeypressHandlers,
366
+ fe as install,
367
+ ae as useKeyboardNav
368
368
  };
369
369
  //# sourceMappingURL=utilities.js.map