@stonecrop/utilities 0.16.1 → 0.16.3

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.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.7"
8
+ "packageVersion": "7.58.11"
9
9
  }
10
10
  ]
11
11
  }
package/dist/utilities.js CHANGED
@@ -1,176 +1,45 @@
1
- import { watch as y, getCurrentScope as V, onScopeDispose as j, computed as T, shallowRef as H, toValue as h, watchEffect as B, getCurrentInstance as _, onMounted as W, unref as q, ref as F, onBeforeUnmount as G } from "vue";
2
- function K(e, t) {
3
- return V() ? (j(e, t), !0) : !1;
4
- }
5
- const z = typeof window < "u" && typeof document < "u";
6
- typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
7
- const J = (e) => e != null, Q = Object.prototype.toString, X = (e) => Q.call(e) === "[object Object]", Y = () => {
8
- };
9
- function b(e) {
10
- return Array.isArray(e) ? e : [e];
11
- }
12
- function Z(e, t, n) {
13
- return y(e, t, {
14
- ...n,
15
- immediate: !0
16
- });
17
- }
18
- const $ = z ? window : void 0;
19
- function v(e) {
20
- var t;
21
- const n = h(e);
22
- return (t = n?.$el) !== null && t !== void 0 ? t : n;
23
- }
24
- function C(...e) {
25
- const t = (l, r, o, s) => (l.addEventListener(r, o, s), () => l.removeEventListener(r, o, s)), n = T(() => {
26
- const l = b(h(e[0])).filter((r) => r != null);
27
- return l.every((r) => typeof r != "string") ? l : void 0;
28
- });
29
- return Z(() => {
30
- var l, r;
31
- return [
32
- (l = (r = n.value) === null || r === void 0 ? void 0 : r.map((o) => v(o))) !== null && l !== void 0 ? l : [$].filter((o) => o != null),
33
- b(h(n.value ? e[1] : e[0])),
34
- b(q(n.value ? e[2] : e[1])),
35
- h(n.value ? e[3] : e[2])
36
- ];
37
- }, ([l, r, o, s], i, a) => {
38
- if (!l?.length || !r?.length || !o?.length) return;
39
- const c = X(s) ? { ...s } : s, f = l.flatMap((u) => r.flatMap((d) => o.map((p) => t(u, d, p, c))));
40
- a(() => {
41
- f.forEach((u) => u());
42
- });
43
- }, { flush: "post" });
44
- }
45
- // @__NO_SIDE_EFFECTS__
46
- function ee() {
47
- const e = H(!1), t = _();
48
- return t && W(() => {
49
- e.value = !0;
50
- }, t), e;
51
- }
52
- // @__NO_SIDE_EFFECTS__
53
- function te(e) {
54
- const t = /* @__PURE__ */ ee();
55
- return T(() => (t.value, !!e()));
56
- }
57
- function ne(e, t, n = {}) {
58
- const { window: l = $, ...r } = n;
59
- let o;
60
- const s = /* @__PURE__ */ te(() => l && "MutationObserver" in l), i = () => {
61
- o && (o.disconnect(), o = void 0);
62
- }, a = y(T(() => {
63
- const u = b(h(e)).map(v).filter(J);
64
- return new Set(u);
65
- }), (u) => {
66
- i(), s.value && u.size && (o = new MutationObserver(t), u.forEach((d) => o.observe(d, r)));
67
- }, {
68
- immediate: !0,
69
- flush: "post"
70
- }), c = () => o?.takeRecords(), f = () => {
71
- a(), i();
72
- };
73
- return K(f), {
74
- isSupported: s,
75
- stop: f,
76
- takeRecords: c
77
- };
78
- }
79
- function oe(e, t, n = {}) {
80
- const { window: l = $, document: r = l?.document, flush: o = "sync" } = n;
81
- if (!l || !r) return Y;
82
- let s;
83
- const i = (f) => {
84
- s?.(), s = f;
85
- }, a = B(() => {
86
- const f = v(e);
87
- if (f) {
88
- const { stop: u } = ne(r, (d) => {
89
- d.map((p) => [...p.removedNodes]).flat().some((p) => p === f || p.contains(f)) && t(d);
90
- }, {
91
- window: l,
92
- childList: !0,
93
- subtree: !0
94
- });
95
- i(u);
96
- }
97
- }, { flush: o }), c = () => {
98
- a(), i();
99
- };
100
- return K(c), c;
101
- }
102
- // @__NO_SIDE_EFFECTS__
103
- function le(e = {}) {
104
- var t;
105
- const { window: n = $, deep: l = !0, triggerOnRemoval: r = !1 } = e, o = (t = e.document) !== null && t !== void 0 ? t : n?.document, s = () => {
106
- let c = o?.activeElement;
107
- if (l)
108
- for (var f; c?.shadowRoot; ) c = c == null || (f = c.shadowRoot) === null || f === void 0 ? void 0 : f.activeElement;
109
- return c;
110
- }, i = H(), a = () => {
111
- i.value = s();
112
- };
113
- if (n) {
114
- const c = {
115
- capture: !0,
116
- passive: !0
117
- };
118
- C(n, "blur", (f) => {
119
- f.relatedTarget === null && a();
120
- }, c), C(n, "focus", a, c);
121
- }
122
- return r && oe(i, a, { document: o }), a(), i;
123
- }
124
- const re = "focusin", se = "focusout", ie = ":focus-within";
125
- function ce(e, t = {}) {
126
- const { window: n = $ } = t, l = T(() => v(e)), r = H(!1), o = T(() => r.value);
127
- if (!n || !(/* @__PURE__ */ le(t)).value) return { focused: o };
128
- const i = { passive: !0 };
129
- return C(l, re, () => r.value = !0, i), C(l, se, () => {
130
- var a, c, f;
131
- return r.value = (a = (c = l.value) === null || c === void 0 || (f = c.matches) === null || f === void 0 ? void 0 : f.call(c, ie)) !== null && a !== void 0 ? a : !1;
132
- }, i), { focused: o };
133
- }
134
- function ae(e, { window: t = $, scrollTarget: n } = {}) {
135
- const l = F(!1), r = () => {
1
+ import { ref as D, watch as P, onMounted as v, onBeforeUnmount as K } from "vue";
2
+ import { unrefElement as y, defaultWindow as I, useEventListener as U, useFocusWithin as B } from "@vueuse/core";
3
+ function F(e, { window: t = I, scrollTarget: n } = {}) {
4
+ const l = D(!1), s = () => {
136
5
  if (!t) return;
137
- const o = t.document, s = v(e);
138
- if (!s)
6
+ const o = t.document, i = y(e);
7
+ if (!i)
139
8
  l.value = !1;
140
9
  else {
141
- const i = s.getBoundingClientRect();
142
- l.value = i.top <= (t.innerHeight || o.documentElement.clientHeight) && i.left <= (t.innerWidth || o.documentElement.clientWidth) && i.bottom >= 0 && i.right >= 0;
10
+ const r = i.getBoundingClientRect();
11
+ l.value = r.top <= (t.innerHeight || o.documentElement.clientHeight) && r.left <= (t.innerWidth || o.documentElement.clientWidth) && r.bottom >= 0 && r.right >= 0;
143
12
  }
144
13
  };
145
- return y(
146
- () => v(e),
147
- () => r(),
14
+ return P(
15
+ () => y(e),
16
+ () => s(),
148
17
  { immediate: !0, flush: "post" }
149
- ), t && C(n || t, "scroll", r, {
18
+ ), t && U(n || t, "scroll", s, {
150
19
  capture: !1,
151
20
  passive: !0
152
21
  }), l;
153
22
  }
154
- const m = (e) => {
155
- let t = ae(e).value;
23
+ const f = (e) => {
24
+ let t = F(e).value;
156
25
  return t = t && e.offsetHeight > 0, t;
157
- }, E = (e) => e.tabIndex >= 0, D = (e) => {
26
+ }, u = (e) => e.tabIndex >= 0, b = (e) => {
158
27
  if (e.target instanceof HTMLElement)
159
- return S(e.target);
160
- }, S = (e) => {
28
+ return H(e.target);
29
+ }, H = (e) => {
161
30
  let t;
162
31
  if (e instanceof HTMLTableCellElement) {
163
32
  const n = e.parentElement?.previousElementSibling;
164
33
  if (n instanceof HTMLTableRowElement) {
165
- const r = Array.from(n.children)[e.cellIndex];
166
- r instanceof HTMLElement && (t = r);
34
+ const s = Array.from(n.children)[e.cellIndex];
35
+ s instanceof HTMLElement && (t = s);
167
36
  }
168
37
  } else if (e instanceof HTMLTableRowElement) {
169
38
  const n = e.previousElementSibling;
170
39
  n instanceof HTMLTableRowElement && (t = n);
171
40
  }
172
- return t && (!E(t) || !m(t)) ? S(t) : t;
173
- }, fe = (e) => {
41
+ return t && (!u(t) || !f(t)) ? H(t) : t;
42
+ }, W = (e) => {
174
43
  if (!(e.target instanceof HTMLElement)) return;
175
44
  const t = e.target;
176
45
  let n;
@@ -183,28 +52,28 @@ const m = (e) => {
183
52
  } else if (t instanceof HTMLTableRowElement) {
184
53
  const l = t.parentElement;
185
54
  if (l) {
186
- const r = l.firstElementChild;
187
- r instanceof HTMLTableRowElement && (n = r);
55
+ const s = l.firstElementChild;
56
+ s instanceof HTMLTableRowElement && (n = s);
188
57
  }
189
58
  }
190
- return n && (!E(n) || !m(n)) ? R(n) : n;
191
- }, P = (e) => {
192
- if (e.target instanceof HTMLElement)
193
- return R(e.target);
59
+ return n && (!u(n) || !f(n)) ? L(n) : n;
194
60
  }, R = (e) => {
61
+ if (e.target instanceof HTMLElement)
62
+ return L(e.target);
63
+ }, L = (e) => {
195
64
  let t;
196
65
  if (e instanceof HTMLTableCellElement) {
197
66
  const n = e.parentElement?.nextElementSibling;
198
67
  if (n) {
199
- const r = Array.from(n.children)[e.cellIndex];
200
- r instanceof HTMLElement && (t = r);
68
+ const s = Array.from(n.children)[e.cellIndex];
69
+ s instanceof HTMLElement && (t = s);
201
70
  }
202
71
  } else if (e instanceof HTMLTableRowElement) {
203
72
  const n = e.nextElementSibling;
204
73
  n instanceof HTMLTableRowElement && (t = n);
205
74
  }
206
- return t && (!E(t) || !m(t)) ? R(t) : t;
207
- }, ue = (e) => {
75
+ return t && (!u(t) || !f(t)) ? L(t) : t;
76
+ }, q = (e) => {
208
77
  if (!(e.target instanceof HTMLElement)) return;
209
78
  const t = e.target;
210
79
  let n;
@@ -217,92 +86,92 @@ const m = (e) => {
217
86
  } else if (t instanceof HTMLTableRowElement) {
218
87
  const l = t.parentElement;
219
88
  if (l) {
220
- const r = l.lastElementChild;
221
- r instanceof HTMLTableRowElement && (n = r);
89
+ const s = l.lastElementChild;
90
+ s instanceof HTMLTableRowElement && (n = s);
222
91
  }
223
92
  }
224
- return n && (!E(n) || !m(n)) ? S(n) : n;
225
- }, O = (e) => {
93
+ return n && (!u(n) || !f(n)) ? H(n) : n;
94
+ }, x = (e) => {
226
95
  if (e.target instanceof HTMLElement)
227
- return k(e.target);
228
- }, k = (e) => {
96
+ return h(e.target);
97
+ }, h = (e) => {
229
98
  let t;
230
99
  const n = e.previousElementSibling;
231
100
  if (n instanceof HTMLElement)
232
101
  t = n;
233
102
  else {
234
- const r = e.parentElement?.previousElementSibling?.lastElementChild;
235
- r instanceof HTMLElement && (t = r);
103
+ const s = e.parentElement?.previousElementSibling?.lastElementChild;
104
+ s instanceof HTMLElement && (t = s);
236
105
  }
237
- return t && (!E(t) || !m(t)) ? k(t) : t;
238
- }, U = (e) => {
106
+ return t && (!u(t) || !f(t)) ? h(t) : t;
107
+ }, S = (e) => {
239
108
  if (e.target instanceof HTMLElement)
240
- return A(e.target);
241
- }, A = (e) => {
109
+ return M(e.target);
110
+ }, M = (e) => {
242
111
  let t;
243
112
  const n = e.nextElementSibling;
244
113
  if (n instanceof HTMLElement)
245
114
  t = n;
246
115
  else {
247
- const r = e.parentElement?.nextElementSibling?.firstElementChild;
248
- r instanceof HTMLElement && (t = r);
116
+ const s = e.parentElement?.nextElementSibling?.firstElementChild;
117
+ s instanceof HTMLElement && (t = s);
249
118
  }
250
- return t && (!E(t) || !m(t)) ? A(t) : t;
251
- }, I = (e) => {
119
+ return t && (!u(t) || !f(t)) ? M(t) : t;
120
+ }, k = (e) => {
252
121
  if (!(e.target instanceof HTMLElement)) return;
253
122
  const n = e.target.parentElement?.firstElementChild, l = n instanceof HTMLElement ? n : null;
254
- return l && (!E(l) || !m(l)) ? A(l) : l;
255
- }, N = (e) => {
123
+ return l && (!u(l) || !f(l)) ? M(l) : l;
124
+ }, A = (e) => {
256
125
  if (!(e.target instanceof HTMLElement)) return;
257
126
  const n = e.target.parentElement?.lastElementChild, l = n instanceof HTMLElement ? n : null;
258
- return l && (!E(l) || !m(l)) ? k(l) : l;
259
- }, w = ["alt", "control", "shift", "meta"], de = {
127
+ return l && (!u(l) || !f(l)) ? h(l) : l;
128
+ }, d = ["alt", "control", "shift", "meta"], N = {
260
129
  ArrowUp: "up",
261
130
  ArrowDown: "down",
262
131
  ArrowLeft: "left",
263
132
  ArrowRight: "right"
264
- }, pe = {
133
+ }, V = {
265
134
  "keydown.up": (e) => {
266
- const t = D(e);
135
+ const t = b(e);
267
136
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
268
137
  },
269
138
  "keydown.down": (e) => {
270
- const t = P(e);
139
+ const t = R(e);
271
140
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
272
141
  },
273
142
  "keydown.left": (e) => {
274
- const t = O(e);
143
+ const t = x(e);
275
144
  e.preventDefault(), e.stopPropagation(), t && t.focus();
276
145
  },
277
146
  "keydown.right": (e) => {
278
- const t = U(e);
147
+ const t = S(e);
279
148
  e.preventDefault(), e.stopPropagation(), t && t.focus();
280
149
  },
281
150
  "keydown.control.up": (e) => {
282
- const t = fe(e);
151
+ const t = W(e);
283
152
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
284
153
  },
285
154
  "keydown.control.down": (e) => {
286
- const t = ue(e);
155
+ const t = q(e);
287
156
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
288
157
  },
289
158
  "keydown.control.left": (e) => {
290
- const t = I(e);
159
+ const t = k(e);
291
160
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
292
161
  },
293
162
  "keydown.control.right": (e) => {
294
- const t = N(e);
163
+ const t = A(e);
295
164
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
296
165
  },
297
166
  "keydown.end": (e) => {
298
- const t = N(e);
167
+ const t = A(e);
299
168
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
300
169
  },
301
170
  "keydown.enter": (e) => {
302
171
  if (!(e.target instanceof HTMLElement)) return;
303
172
  if (e.target instanceof HTMLTableCellElement) {
304
173
  e.preventDefault(), e.stopPropagation();
305
- const n = P(e);
174
+ const n = R(e);
306
175
  n && n.focus();
307
176
  }
308
177
  },
@@ -310,93 +179,93 @@ const m = (e) => {
310
179
  if (!(e.target instanceof HTMLElement)) return;
311
180
  if (e.target instanceof HTMLTableCellElement) {
312
181
  e.preventDefault(), e.stopPropagation();
313
- const n = D(e);
182
+ const n = b(e);
314
183
  n && n.focus();
315
184
  }
316
185
  },
317
186
  "keydown.home": (e) => {
318
- const t = I(e);
187
+ const t = k(e);
319
188
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
320
189
  },
321
190
  "keydown.tab": (e) => {
322
- const t = U(e);
191
+ const t = S(e);
323
192
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
324
193
  },
325
194
  "keydown.shift.tab": (e) => {
326
- const t = O(e);
195
+ const t = x(e);
327
196
  t && (e.preventDefault(), e.stopPropagation(), t.focus());
328
197
  }
329
198
  };
330
- function L(e) {
199
+ function C(e) {
331
200
  let t = null;
332
201
  return e.parent && (typeof e.parent == "string" ? t = document.querySelector(e.parent) : e.parent instanceof HTMLElement ? t = e.parent : t = e.parent.value), t;
333
202
  }
334
- function Ee(e) {
203
+ function _(e) {
335
204
  const t = (o) => {
336
- const s = L(o);
337
- let i = [];
205
+ const i = C(o);
206
+ let r = [];
338
207
  if (typeof o.selectors == "string")
339
- i = Array.from(s ? s.querySelectorAll(o.selectors) : document.querySelectorAll(o.selectors));
208
+ r = Array.from(i ? i.querySelectorAll(o.selectors) : document.querySelectorAll(o.selectors));
340
209
  else if (Array.isArray(o.selectors))
341
210
  for (const a of o.selectors)
342
- a instanceof HTMLElement ? i.push(a) : i.push(a.$el);
211
+ a instanceof HTMLElement ? r.push(a) : r.push(a.$el);
343
212
  else if (o.selectors instanceof HTMLElement)
344
- i.push(o.selectors);
213
+ r.push(o.selectors);
345
214
  else if (o.selectors?.value)
346
215
  if (Array.isArray(o.selectors.value))
347
216
  for (const a of o.selectors.value)
348
- a instanceof HTMLElement ? i.push(a) : i.push(a.$el);
217
+ a instanceof HTMLElement ? r.push(a) : r.push(a.$el);
349
218
  else
350
- i.push(o.selectors.value);
351
- return i;
219
+ r.push(o.selectors.value);
220
+ return r;
352
221
  }, n = (o) => {
353
- const s = L(o);
354
- let i = [];
355
- return o.selectors ? i = t(o) : s && (i = Array.from(s.children).filter((c) => c instanceof HTMLElement).filter((c) => E(c) && m(c))), i;
356
- }, l = (o) => (s) => {
357
- const i = de[s.key] || s.key.toLowerCase();
358
- if (w.includes(i)) return;
359
- const a = o.handlers || pe;
222
+ const i = C(o);
223
+ let r = [];
224
+ return o.selectors ? r = t(o) : i && (r = Array.from(i.children).filter((c) => c instanceof HTMLElement).filter((c) => u(c) && f(c))), r;
225
+ }, l = (o) => (i) => {
226
+ const r = N[i.key] || i.key.toLowerCase();
227
+ if (d.includes(r)) return;
228
+ const a = o.handlers || V;
360
229
  for (const c of Object.keys(a)) {
361
- const [f, ...u] = c.split(".");
362
- if (f === "keydown" && u.includes(i)) {
363
- const d = a[c], p = u.filter((g) => w.includes(g)), x = w.some((g) => {
364
- const M = g.charAt(0).toUpperCase() + g.slice(1);
365
- return s.getModifierState(M);
230
+ const [m, ...E] = c.split(".");
231
+ if (m === "keydown" && E.includes(r)) {
232
+ const g = a[c], $ = E.filter((p) => d.includes(p)), w = d.some((p) => {
233
+ const T = p.charAt(0).toUpperCase() + p.slice(1);
234
+ return i.getModifierState(T);
366
235
  });
367
- if (p.length > 0) {
368
- if (x) {
369
- for (const g of w)
370
- if (u.includes(g)) {
371
- const M = g.charAt(0).toUpperCase() + g.slice(1);
372
- s.getModifierState(M) && d(s);
236
+ if ($.length > 0) {
237
+ if (w) {
238
+ for (const p of d)
239
+ if (E.includes(p)) {
240
+ const T = p.charAt(0).toUpperCase() + p.slice(1);
241
+ i.getModifierState(T) && g(i);
373
242
  }
374
243
  }
375
244
  } else
376
- x || d(s);
245
+ w || g(i);
377
246
  }
378
247
  }
379
- }, r = [];
380
- W(() => {
248
+ }, s = [];
249
+ v(() => {
381
250
  for (const o of e) {
382
- const s = L(o), i = n(o), a = l(o), c = s ? [s] : i;
383
- for (const f of c) {
384
- const { focused: u } = ce(F(f)), d = y(u, (p) => {
385
- p ? f.addEventListener("keydown", a) : f.removeEventListener("keydown", a);
251
+ const i = C(o), r = n(o), a = l(o), c = i ? [i] : r;
252
+ for (const m of c) {
253
+ const { focused: E } = B(D(m)), g = P(E, ($) => {
254
+ $ ? m.addEventListener("keydown", a) : m.removeEventListener("keydown", a);
386
255
  });
387
- r.push(d);
256
+ s.push(g);
388
257
  }
389
258
  }
390
- }), G(() => {
391
- for (const o of r)
259
+ }), K(() => {
260
+ for (const o of s)
392
261
  o();
393
262
  });
394
263
  }
395
- function ge(e) {
264
+ function z(e) {
396
265
  }
397
266
  export {
398
- pe as defaultKeypressHandlers,
399
- ge as install,
400
- Ee as useKeyboardNav
267
+ V as defaultKeypressHandlers,
268
+ z as install,
269
+ _ as useKeyboardNav
401
270
  };
402
271
  //# sourceMappingURL=utilities.js.map