@thednp/shorty 2.0.0-alpha10 → 2.0.0-alpha11

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/shorty.mjs CHANGED
@@ -54,31 +54,53 @@ const fe = "aria-checked", me = "aria-description", ge = "aria-describedby", ve
54
54
  end: "mouseup",
55
55
  move: "mousemove",
56
56
  cancel: "mouseleave"
57
- }, He = { down: "mousedown", up: "mouseup" }, Pe = "onmouseleave" in document ? ["mouseenter", "mouseleave"] : ["mouseover", "mouseout"], Ue = {
57
+ }, He = { down: "mousedown", up: "mouseup" }, Pe = "onmouseleave" in document ? ["mouseenter", "mouseleave"] : (
58
+ /* istanbul ignore next */
59
+ ["mouseover", "mouseout"]
60
+ ), Ue = {
58
61
  start: "touchstart",
59
62
  end: "touchend",
60
63
  move: "touchmove",
61
64
  cancel: "touchcancel"
62
65
  }, Fe = { in: "focusin", out: "focusout" }, We = {
63
66
  Backspace: "Backspace",
67
+ // 8
64
68
  Tab: "Tab",
69
+ // 9
65
70
  Enter: "Enter",
71
+ // 13
66
72
  Shift: "Shift",
73
+ // 16
67
74
  Control: "Control",
75
+ // 17
68
76
  Alt: "Alt",
77
+ // 18
69
78
  Pause: "Pause",
79
+ // 19
70
80
  CapsLock: "CapsLock",
81
+ // 20
71
82
  Escape: "Escape",
83
+ // 27
72
84
  Scape: "Space",
85
+ // 32
73
86
  ArrowLeft: "ArrowLeft",
87
+ // 37
74
88
  ArrowUp: "ArrowUp",
89
+ // 38
75
90
  ArrowRight: "ArrowRight",
91
+ // 39
76
92
  ArrowDown: "ArrowDown",
93
+ // 40
77
94
  Insert: "Insert",
95
+ // 45
78
96
  Delete: "Delete",
97
+ // 46
79
98
  Meta: "Meta",
99
+ // 91 windows key
80
100
  ContextMenu: "ContextMenu",
101
+ // 93
81
102
  ScrollLock: "ScrollLock"
103
+ // 145
82
104
  }, Re = "Alt", Qe = "ArrowDown", qe = "ArrowUp", Ge = "ArrowLeft", je = "ArrowRight", Je = "Backspace", Ke = "CapsLock", Xe = "Control", Ye = "Delete", Ze = "Enter", $e = "Escape", _e = "Insert", tn = "Meta", en = "Pause", nn = "ScrollLock", on = "Shift", sn = "Space", cn = "Tab", Wt = "animationDuration", Rt = "animationDelay", P = "animationName", T = "animationend", Qt = "transitionDuration", qt = "transitionDelay", D = "transitionend", U = "transitionProperty", rn = "addEventListener", an = "removeEventListener", un = {
83
105
  linear: "linear",
84
106
  easingSinusoidalIn: "cubic-bezier(0.47,0,0.745,0.715)",
@@ -108,7 +130,13 @@ const fe = "aria-checked", me = "aria-description", ge = "aria-describedby", ve
108
130
  }, ln = "offsetHeight", dn = "offsetWidth", pn = "scrollHeight", fn = "scrollWidth", mn = "tabindex", Gt = navigator.userAgentData, S = Gt, { userAgent: jt } = navigator, M = jt, I = /iPhone|iPad|iPod|Android/i;
109
131
  let C = !1;
110
132
  S ? C = S.brands.some((t) => I.test(t.brand)) : C = I.test(M);
111
- const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.brand)) : z.test(M), En = M ? M.includes("Firefox") : !1, { head: N } = document, bn = ["webkitPerspective", "perspective"].some((t) => t in N.style), Jt = (t, e, n, o) => {
133
+ const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.brand)) : (
134
+ /* istanbul ignore next */
135
+ z.test(M)
136
+ ), En = M ? M.includes("Firefox") : (
137
+ /* istanbul ignore next */
138
+ !1
139
+ ), { head: N } = document, bn = ["webkitPerspective", "perspective"].some((t) => t in N.style), Jt = (t, e, n, o) => {
112
140
  const s = o || !1;
113
141
  t.addEventListener(e, n, s);
114
142
  }, Kt = (t, e, n, o) => {
@@ -130,23 +158,50 @@ const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.b
130
158
  } catch {
131
159
  }
132
160
  return t;
133
- })(), yn = ["webkitTransform", "transform"].some((t) => t in N.style), wn = "ontouchstart" in window || "msMaxTouchPoints" in navigator, An = ["webkitAnimation", "animation"].some((t) => t in N.style), Sn = ["webkitTransition", "transition"].some((t) => t in N.style), Zt = (t, e) => t.getAttribute(e), Mn = (t, e, n) => e.getAttributeNS(t, n), Nn = (t, e) => t.hasAttribute(e), kn = (t, e, n) => e.hasAttributeNS(t, n), F = (t, e, n) => t.setAttribute(e, n), Tn = (t, e, n, o) => e.setAttributeNS(t, n, o), Dn = (t, e) => t.removeAttribute(e), Cn = (t, e, n) => e.removeAttributeNS(t, n), Ln = (t, ...e) => {
161
+ })(), yn = ["webkitTransform", "transform"].some((t) => t in N.style), wn = "ontouchstart" in window || /* istanbul ignore next */
162
+ "msMaxTouchPoints" in navigator, An = ["webkitAnimation", "animation"].some((t) => t in N.style), Sn = ["webkitTransition", "transition"].some((t) => t in N.style), Zt = (t, e) => t.getAttribute(e), Mn = (t, e, n) => e.getAttributeNS(t, n), Nn = (t, e) => t.hasAttribute(e), kn = (t, e, n) => e.hasAttributeNS(t, n), F = (t, e, n) => t.setAttribute(e, n), Tn = (t, e, n, o) => e.setAttributeNS(t, n, o), Dn = (t, e) => t.removeAttribute(e), Cn = (t, e, n) => e.removeAttributeNS(t, n), Ln = (t, ...e) => {
134
163
  t.classList.add(...e);
135
164
  }, On = (t, ...e) => {
136
165
  t.classList.remove(...e);
137
166
  }, In = (t, e) => t.classList.contains(e), { body: zn } = document, { documentElement: xn } = document, Vn = (t) => Array.from(t), E = (t) => t != null && typeof t == "object" || !1, i = (t) => E(t) && typeof t.nodeType == "number" && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].some((e) => t.nodeType === e) || !1, u = (t) => i(t) && t.nodeType === 1 || !1, y = /* @__PURE__ */ new Map(), L = {
167
+ /**
168
+ * Sets web components data.
169
+ *
170
+ * @param element target element
171
+ * @param component the component's name or a unique key
172
+ * @param instance the component instance
173
+ */
138
174
  set: (t, e, n) => {
139
175
  if (!u(t))
140
176
  return;
141
177
  y.has(e) || y.set(e, /* @__PURE__ */ new Map()), y.get(e).set(t, n);
142
178
  },
179
+ /**
180
+ * Returns all instances for specified component.
181
+ *
182
+ * @param component the component's name or a unique key
183
+ * @returns all the component instances
184
+ */
143
185
  getAllFor: (t) => y.get(t) || null,
186
+ /**
187
+ * Returns the instance associated with the target.
188
+ *
189
+ * @param element target element
190
+ * @param component the component's name or a unique key
191
+ * @returns the instance
192
+ */
144
193
  get: (t, e) => {
145
194
  if (!u(t) || !e)
146
195
  return null;
147
196
  const n = L.getAllFor(e);
148
197
  return t && n && n.get(t) || null;
149
198
  },
199
+ /**
200
+ * Removes web components data.
201
+ *
202
+ * @param element target element
203
+ * @param component the component's name or a unique key
204
+ */
150
205
  remove: (t, e) => {
151
206
  const n = L.getAllFor(e);
152
207
  !n || !u(t) || (n.delete(t), n.size === 0 && y.delete(e));
@@ -179,11 +234,23 @@ const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.b
179
234
  const n = getComputedStyle(t), o = e.replace("webkit", "Webkit").replace(/([A-Z])/g, "-$1").toLowerCase();
180
235
  return n.getPropertyValue(o);
181
236
  }, te = (t) => {
182
- const e = v(t, P), n = v(t, Rt), o = n.includes("ms") ? 1 : 1e3, s = e && e !== "none" ? parseFloat(n) * o : 0;
183
- return Number.isNaN(s) ? 0 : s;
237
+ const e = v(t, P), n = v(t, Rt), o = n.includes("ms") ? (
238
+ /* istanbul ignore next */
239
+ 1
240
+ ) : 1e3, s = e && e !== "none" ? parseFloat(n) * o : 0;
241
+ return Number.isNaN(s) ? (
242
+ /* istanbul ignore next */
243
+ 0
244
+ ) : s;
184
245
  }, ee = (t) => {
185
- const e = v(t, P), n = v(t, Wt), o = n.includes("ms") ? 1 : 1e3, s = e && e !== "none" ? parseFloat(n) * o : 0;
186
- return Number.isNaN(s) ? 0 : s;
246
+ const e = v(t, P), n = v(t, Wt), o = n.includes("ms") ? (
247
+ /* istanbul ignore next */
248
+ 1
249
+ ) : 1e3, s = e && e !== "none" ? parseFloat(n) * o : 0;
250
+ return Number.isNaN(s) ? (
251
+ /* istanbul ignore next */
252
+ 0
253
+ ) : s;
187
254
  }, Pn = (t, e) => {
188
255
  let n = 0;
189
256
  const o = new Event(T), s = ee(t), c = te(t);
@@ -197,11 +264,29 @@ const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.b
197
264
  } else
198
265
  e.apply(t, [o]);
199
266
  }, ne = (t) => {
200
- const e = v(t, U), n = v(t, qt), o = n.includes("ms") ? 1 : 1e3, s = e && e !== "none" ? parseFloat(n) * o : 0;
201
- return Number.isNaN(s) ? 0 : s;
267
+ const e = v(t, U), n = v(t, qt), o = n.includes("ms") ? (
268
+ /* istanbul ignore next */
269
+ 1
270
+ ) : 1e3, s = e && e !== "none" ? parseFloat(n) * o : (
271
+ /* istanbul ignore next */
272
+ 0
273
+ );
274
+ return Number.isNaN(s) ? (
275
+ /* istanbul ignore next */
276
+ 0
277
+ ) : s;
202
278
  }, oe = (t) => {
203
- const e = v(t, U), n = v(t, Qt), o = n.includes("ms") ? 1 : 1e3, s = e && e !== "none" ? parseFloat(n) * o : 0;
204
- return Number.isNaN(s) ? 0 : s;
279
+ const e = v(t, U), n = v(t, Qt), o = n.includes("ms") ? (
280
+ /* istanbul ignore next */
281
+ 1
282
+ ) : 1e3, s = e && e !== "none" ? parseFloat(n) * o : (
283
+ /* istanbul ignore next */
284
+ 0
285
+ );
286
+ return Number.isNaN(s) ? (
287
+ /* istanbul ignore next */
288
+ 0
289
+ ) : s;
205
290
  }, Un = (t, e) => {
206
291
  let n = 0;
207
292
  const o = new Event(D), s = oe(t), c = ne(t);
@@ -240,15 +325,37 @@ const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.b
240
325
  }
241
326
  });
242
327
  }, O = (t) => E(t) && t.constructor.name === "Map" || !1, ce = (t) => typeof t == "number" || !1, m = /* @__PURE__ */ new Map(), Zn = {
328
+ /**
329
+ * Sets a new timeout timer for an element, or element -> key association.
330
+ *
331
+ * @param element target element
332
+ * @param callback the callback
333
+ * @param delay the execution delay
334
+ * @param key a unique key
335
+ */
243
336
  set: (t, e, n, o) => {
244
- !u(t) || (o && o.length ? (m.has(t) || m.set(t, /* @__PURE__ */ new Map()), m.get(t).set(o, setTimeout(e, n))) : m.set(t, setTimeout(e, n)));
337
+ u(t) && (o && o.length ? (m.has(t) || m.set(t, /* @__PURE__ */ new Map()), m.get(t).set(o, setTimeout(e, n))) : m.set(t, setTimeout(e, n)));
245
338
  },
339
+ /**
340
+ * Returns the timer associated with the target.
341
+ *
342
+ * @param element target element
343
+ * @param key a unique
344
+ * @returns the timer
345
+ */
246
346
  get: (t, e) => {
247
347
  if (!u(t))
248
348
  return null;
249
349
  const n = m.get(t);
250
- return e && n && O(n) ? n.get(e) || null : ce(n) ? n : null;
350
+ return e && n && O(n) ? n.get(e) || /* istanbul ignore next */
351
+ null : ce(n) ? n : null;
251
352
  },
353
+ /**
354
+ * Clears the element's timer.
355
+ *
356
+ * @param element target element
357
+ * @param key a unique key
358
+ */
252
359
  clear: (t, e) => {
253
360
  if (!u(t))
254
361
  return;
@@ -260,7 +367,13 @@ const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.b
260
367
  let p = 1, r = 1;
261
368
  if (e && u(t)) {
262
369
  const { offsetWidth: f, offsetHeight: A } = t;
263
- p = f > 0 ? Math.round(n) / f : 1, r = A > 0 ? Math.round(o) / A : 1;
370
+ p = f > 0 ? Math.round(n) / f : (
371
+ /* istanbul ignore next */
372
+ 1
373
+ ), r = A > 0 ? Math.round(o) / A : (
374
+ /* istanbul ignore next */
375
+ 1
376
+ );
264
377
  }
265
378
  return {
266
379
  width: n / p,
@@ -275,7 +388,10 @@ const gn = C, z = /(iPhone|iPod|iPad)/, vn = S ? S.brands.some((t) => z.test(t.b
275
388
  }, _n = (t) => d(t).body, k = (t) => d(t).documentElement, to = (t) => d(t).head, eo = (t) => {
276
389
  const e = W(t), n = e ? t.scrollX : t.scrollLeft, o = e ? t.scrollY : t.scrollTop;
277
390
  return { x: n, y: o };
278
- }, re = (t) => i(t) && t.constructor.name === "ShadowRoot" || !1, no = (t) => t.nodeName === "HTML" ? t : u(t) && t.assignedSlot || i(t) && t.parentNode || re(t) && t.host || k(t), ae = (t) => {
391
+ }, re = (t) => i(t) && t.constructor.name === "ShadowRoot" || !1, no = (t) => t.nodeName === "HTML" ? t : u(t) && t.assignedSlot || // step into the shadow DOM of the parent of a slotted node
392
+ i(t) && t.parentNode || // DOM Element detected
393
+ re(t) && t.host || // ShadowRoot detected
394
+ k(t), ae = (t) => {
279
395
  if (!u(t))
280
396
  return !1;
281
397
  const { width: e, height: n } = w(t), { offsetWidth: o, offsetHeight: s } = t;
@@ -326,7 +442,8 @@ const b = /* @__PURE__ */ new Map(), ie = (t, e) => {
326
442
  return !1;
327
443
  }
328
444
  return !0;
329
- }, go = (t) => E(t) && t.constructor.name === "WeakMap" || !1, vo = (t) => i(t) && ["SVG", "Image", "Video", "Canvas"].some((e) => t.constructor.name.includes(e)) || !1, Eo = (t) => E(t) && t.constructor.name === "NodeList" || !1, bo = (t) => k(t).dir === "rtl", ho = (t) => i(t) && t.constructor.name.includes("SVG") || !1, yo = (t) => i(t) && ["TABLE", "TD", "TH"].includes(t.nodeName) || !1, de = (t, e) => t ? t.closest(e) || de(t.getRootNode().host, e) : null, wo = (t, e) => u(t) ? t : (i(e) ? e : d()).querySelector(t), pe = (t, e) => (i(e) ? e : d()).getElementsByTagName(t), Ao = (t) => [...pe("*", t)].filter(le), So = (t, e) => d(e).getElementById(t) || null, Mo = (t, e) => (i(e) ? e : d()).querySelectorAll(t), No = (t, e) => (e && i(e) ? e : d()).getElementsByClassName(
445
+ }, go = (t) => E(t) && t.constructor.name === "WeakMap" || !1, vo = (t) => i(t) && ["SVG", "Image", "Video", "Canvas"].some((e) => t.constructor.name.includes(e)) || !1, Eo = (t) => E(t) && t.constructor.name === "NodeList" || !1, bo = (t) => k(t).dir === "rtl", ho = (t) => i(t) && t.constructor.name.includes("SVG") || !1, yo = (t) => i(t) && ["TABLE", "TD", "TH"].includes(t.nodeName) || !1, de = (t, e) => t ? t.closest(e) || // break out of `ShadowRoot`
446
+ de(t.getRootNode().host, e) : null, wo = (t, e) => u(t) ? t : (i(e) ? e : d()).querySelector(t), pe = (t, e) => (i(e) ? e : d()).getElementsByTagName(t), Ao = (t) => [...pe("*", t)].filter(le), So = (t, e) => d(e).getElementById(t) || null, Mo = (t, e) => (i(e) ? e : d()).querySelectorAll(t), No = (t, e) => (e && i(e) ? e : d()).getElementsByClassName(
330
447
  t
331
448
  ), ko = (t, e) => t.matches(e);
332
449
  export {