inclusive-elements 0.4.3 → 0.4.5

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.
@@ -1,6 +1,6 @@
1
1
  var d = Object.defineProperty;
2
- var l = (o, i, t) => i in o ? d(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
- var e = (o, i, t) => (l(o, typeof i != "symbol" ? i + "" : i, t), t);
2
+ var l = (o, s, t) => s in o ? d(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
+ var e = (o, s, t) => (l(o, typeof s != "symbol" ? s + "" : s, t), t);
4
4
  import { autoUpdate as p, computePosition as u, shift as c, flip as m } from "@floating-ui/dom";
5
5
  import { hello as v, goodbye as b } from "hello-goodbye";
6
6
  const r = class extends HTMLElement {
@@ -26,14 +26,14 @@ const r = class extends HTMLElement {
26
26
  }
27
27
  connectedCallback() {
28
28
  this.parent = this.parentNode, this.parent && (this.parent.addEventListener("mouseenter", this.onMouseEnter), this.parent.addEventListener("focus", this.onFocus), this.parent.addEventListener("mouseleave", this.onMouseLeave), this.parent.addEventListener("blur", this.onBlur), this.parent.addEventListener("pointerup", this.onPointerUp), this.disabledObserver = new MutationObserver((t) => {
29
- t.forEach((s) => {
30
- s.attributeName === "disabled" && this.hide();
29
+ t.forEach((i) => {
30
+ i.attributeName === "disabled" && this.hide();
31
31
  });
32
32
  }), this.disabledObserver.observe(this.parent, { attributes: !0 })), document.addEventListener("keydown", this.onKeyDown), document.addEventListener("scroll", this.onBlur);
33
33
  }
34
34
  disconnectedCallback() {
35
- var t;
36
- this.tooltip && (this.tooltip.remove(), this.tooltip = void 0), this.parent && (this.parent.removeEventListener("mouseenter", this.onMouseEnter), this.parent.removeEventListener("focus", this.onFocus), this.parent.removeEventListener("mouseleave", this.onMouseLeave), this.parent.removeEventListener("blur", this.onBlur), this.parent.removeEventListener("pointerup", this.onPointerUp), this.parent = void 0), document.removeEventListener("keydown", this.onKeyDown), document.removeEventListener("scroll", this.onBlur), (t = this.disabledObserver) == null || t.disconnect(), clearTimeout(this.timeout);
35
+ var t, i;
36
+ (t = this.cleanup) == null || t.call(this), this.tooltip && (this.tooltip.remove(), this.tooltip = void 0), this.parent && (this.parent.removeEventListener("mouseenter", this.onMouseEnter), this.parent.removeEventListener("focus", this.onFocus), this.parent.removeEventListener("mouseleave", this.onMouseLeave), this.parent.removeEventListener("blur", this.onBlur), this.parent.removeEventListener("pointerup", this.onPointerUp), this.parent = void 0), document.removeEventListener("keydown", this.onKeyDown), document.removeEventListener("scroll", this.onBlur), (i = this.disabledObserver) == null || i.disconnect(), clearTimeout(this.timeout);
37
37
  }
38
38
  get disabled() {
39
39
  return this.hasAttribute("disabled");
@@ -51,9 +51,9 @@ const r = class extends HTMLElement {
51
51
  () => u(this.parent, t, {
52
52
  placement: this.getAttribute("placement") || r.placement,
53
53
  middleware: [c(), m()]
54
- }).then(({ x: s, y: h, placement: a }) => {
54
+ }).then(({ x: i, y: h, placement: a }) => {
55
55
  Object.assign(t.style, {
56
- left: `${s}px`,
56
+ left: `${i}px`,
57
57
  top: `${h}px`
58
58
  }), t.dataset.placement = a;
59
59
  })
@@ -67,10 +67,10 @@ const r = class extends HTMLElement {
67
67
  }
68
68
  afterDelay(t) {
69
69
  clearTimeout(this.timeout);
70
- const s = parseInt(this.getAttribute("delay") || "");
70
+ const i = parseInt(this.getAttribute("delay") || "");
71
71
  this.timeout = window.setTimeout(
72
72
  t.bind(this),
73
- isNaN(s) ? r.delay : s
73
+ isNaN(i) ? r.delay : i
74
74
  );
75
75
  }
76
76
  createTooltip() {
@@ -1,16 +1,17 @@
1
1
  var c = Object.defineProperty;
2
2
  var m = (a, s, t) => s in a ? c(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
3
3
  var o = (a, s, t) => (m(a, typeof s != "symbol" ? s + "" : s, t), t);
4
- import { move as d, hello as u, goodbye as f } from "hello-goodbye";
5
- const n = class extends HTMLElement {
4
+ import { move as n, hello as u, goodbye as f } from "hello-goodbye";
5
+ const h = class extends HTMLElement {
6
6
  constructor() {
7
7
  super();
8
+ o(this, "added", /* @__PURE__ */ new Set());
8
9
  o(this, "timeouts", /* @__PURE__ */ new Map());
9
10
  o(this, "index", 0);
10
11
  new MutationObserver((i) => {
11
12
  i.forEach((r) => {
12
13
  r.addedNodes.forEach((e) => {
13
- e instanceof HTMLElement && this.show(e);
14
+ e instanceof HTMLElement && !this.added.has(e) && this.show(e);
14
15
  });
15
16
  });
16
17
  }).observe(this, { childList: !0 });
@@ -22,11 +23,11 @@ const n = class extends HTMLElement {
22
23
  }
23
24
  show(t, i = {}) {
24
25
  const r = i.key || t.dataset.key || String(this.index++);
25
- this.dismiss(r), t.dataset.key = r, this.contains(t) ? u(t) : i.animate === !1 ? this.append(t) : d(this.children, () => {
26
+ this.dismiss(r), t.dataset.key = r, this.contains(t) ? u(t) : i.animate === !1 ? this.append(t) : n(this.children, () => {
26
27
  this.append(t), u(t);
27
- });
28
+ }), this.added.add(t);
28
29
  const e = Number(
29
- i.duration !== void 0 ? i.duration : t.dataset.duration || n.duration
30
+ i.duration !== void 0 ? i.duration : t.dataset.duration || h.duration
30
31
  );
31
32
  return e > 0 && (this.startTimeout(t, e), t.addEventListener("mouseenter", this.clearTimeout.bind(this, t)), t.addEventListener("focusin", this.clearTimeout.bind(this, t)), t.addEventListener(
32
33
  "mouseleave",
@@ -40,14 +41,13 @@ const n = class extends HTMLElement {
40
41
  if (typeof t == "string") {
41
42
  this.querySelectorAll(
42
43
  `[data-key="${t}"]`
43
- ).forEach((i) => {
44
- this.dismiss(i);
45
- });
44
+ ).forEach((i) => this.dismiss(i));
46
45
  return;
47
46
  }
48
- d(this.children, () => {
49
- f(t).then(() => this.removeChild(t));
50
- }), this.clearTimeout(t);
47
+ this.added.delete(t), n(
48
+ this.children,
49
+ () => f(t).then(() => t.remove())
50
+ ), this.clearTimeout(t);
51
51
  }
52
52
  clear() {
53
53
  Array.from(this.children).forEach((t) => {
@@ -78,8 +78,8 @@ const n = class extends HTMLElement {
78
78
  this.timeouts.has(t) && clearTimeout(this.timeouts.get(t));
79
79
  }
80
80
  };
81
- let h = n;
82
- o(h, "duration", 1e4);
81
+ let d = h;
82
+ o(d, "duration", 1e4);
83
83
  export {
84
- h as default
84
+ d as default
85
85
  };
@@ -5,6 +5,7 @@ export type AlertOptions = {
5
5
  };
6
6
  export default class AlertsElement extends HTMLElement {
7
7
  static duration: number;
8
+ private added;
8
9
  private timeouts;
9
10
  private index;
10
11
  constructor();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inclusive-elements",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Accessible, lightweight, unstyled implementations of common UI controls.",
5
5
  "module": "dist/inclusive-elements.js",
6
6
  "type": "module",