inclusive-elements 0.5.0-beta.1 → 0.5.0-beta.2

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,7 +1,7 @@
1
1
  var l = Object.defineProperty;
2
- var u = (o, s, t) => s in o ? l(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
- var e = (o, s, t) => (u(o, typeof s != "symbol" ? s + "" : s, t), t);
4
- import { autoUpdate as p, computePosition as c, shift as m, flip as v } from "@floating-ui/dom";
2
+ var p = (o, s, t) => s in o ? l(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
+ var e = (o, s, t) => (p(o, typeof s != "symbol" ? s + "" : s, t), t);
4
+ import { autoUpdate as u, computePosition as c, shift as v, flip as m } from "@floating-ui/dom";
5
5
  import { hello as b, goodbye as f } from "hello-goodbye";
6
6
  const n = class n extends HTMLElement {
7
7
  constructor() {
@@ -49,25 +49,25 @@ const n = class n extends HTMLElement {
49
49
  if (this.disabled)
50
50
  return;
51
51
  const t = this.createTooltip();
52
- clearTimeout(this.timeout), this.showing || (t.hidden = !1, b(t), this.showing = !0), this.innerHTML !== this.prevInnerHTML && (this.prevInnerHTML = t.innerHTML = this.innerHTML), t.style.position = "absolute", (i = this.cleanup) == null || i.call(this), this.cleanup = p(
52
+ clearTimeout(this.timeout), this.showing || (t.hidden = !1, b(t), this.showing = !0), this.innerHTML !== this.prevInnerHTML && (this.prevInnerHTML = t.innerHTML = this.innerHTML), t.style.position = "absolute", (i = this.cleanup) == null || i.call(this), this.cleanup = u(
53
53
  this.parent,
54
54
  t,
55
55
  () => c(this.parent, t, {
56
56
  placement: this.getAttribute("placement") || n.placement,
57
- middleware: [m(), v()]
57
+ middleware: [v(), m()]
58
58
  }).then(({ x: h, y: a, placement: d }) => {
59
59
  Object.assign(t.style, {
60
60
  left: `${h}px`,
61
61
  top: `${a}px`
62
62
  }), t.dataset.placement = d;
63
63
  })
64
- );
64
+ ), this.dispatchEvent(new Event("open"));
65
65
  }
66
66
  hide() {
67
67
  var t;
68
68
  clearTimeout(this.timeout), (t = this.cleanup) == null || t.call(this), this.showing && (this.showing = !1, f(this.tooltip).then(() => {
69
69
  this.tooltip && (this.tooltip.hidden = !0);
70
- }));
70
+ }), this.dispatchEvent(new Event("close")));
71
71
  }
72
72
  afterDelay(t) {
73
73
  clearTimeout(this.timeout);
@@ -78,10 +78,10 @@ const n = class n extends HTMLElement {
78
78
  );
79
79
  }
80
80
  createTooltip() {
81
- return this.tooltip || (this.tooltip = document.createElement("div"), this.tooltip.className = this.getAttribute("tooltip-class") || n.tooltipClass, this.tooltip.hidden = !0, this.tooltip.addEventListener("mouseenter", this.show.bind(this)), this.tooltip.addEventListener(
81
+ return this.tooltip || (this.tooltip = document.createElement("div"), this.tooltip.hidden = !0, this.tooltip.addEventListener("mouseenter", this.show.bind(this)), this.tooltip.addEventListener(
82
82
  "mouseleave",
83
83
  this.afterDelay.bind(this, this.hide)
84
- ), document.body.appendChild(this.tooltip)), this.tooltip;
84
+ ), document.body.appendChild(this.tooltip)), this.tooltip.className = this.getAttribute("tooltip-class") || n.tooltipClass, this.tooltip;
85
85
  }
86
86
  };
87
87
  e(n, "delay", 100), e(n, "placement", "top"), e(n, "tooltipClass", "tooltip");
@@ -1,19 +1,11 @@
1
- var n = Object.defineProperty;
2
- var u = (a, s, t) => s in a ? n(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
3
- var o = (a, s, t) => (u(a, typeof s != "symbol" ? s + "" : s, t), t);
4
- const d = class d extends HTMLElement {
1
+ var d = Object.defineProperty;
2
+ var u = (e, s, t) => s in e ? d(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var o = (e, s, t) => (u(e, typeof s != "symbol" ? s + "" : s, t), t);
4
+ const r = class r extends HTMLElement {
5
5
  constructor() {
6
- super();
7
- o(this, "added", /* @__PURE__ */ new Set());
6
+ super(...arguments);
8
7
  o(this, "timeouts", /* @__PURE__ */ new Map());
9
8
  o(this, "index", 0);
10
- new MutationObserver((i) => {
11
- i.forEach((r) => {
12
- r.addedNodes.forEach((e) => {
13
- e instanceof HTMLElement && !this.added.has(e) && this.show(e);
14
- });
15
- });
16
- }).observe(this, { childList: !0 });
17
9
  }
18
10
  connectedCallback() {
19
11
  this.hasAttribute("role") || this.setAttribute("role", "status"), this.hasAttribute("aria-live") || this.setAttribute("aria-live", "polite"), this.hasAttribute("aria-relevant") || this.setAttribute("aria-relevant", "additions");
@@ -21,18 +13,18 @@ const d = class d extends HTMLElement {
21
13
  this.show(t);
22
14
  }
23
15
  show(t, i = {}) {
24
- const r = i.key || t.dataset.key || String(this.index++);
25
- this.dismiss(r), t.dataset.key = r, this.contains(t) || this.append(t), this.added.add(t);
26
- const e = Number(
27
- i.duration !== void 0 ? i.duration : t.dataset.duration || d.duration
16
+ const h = i.key || t.dataset.key || String(this.index++);
17
+ this.dismiss(h), t.dataset.key = h, this.contains(t) || this.append(t);
18
+ const a = Number(
19
+ i.duration !== void 0 ? i.duration : t.dataset.duration || r.duration
28
20
  );
29
- 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(
21
+ return a > 0 && (this.startTimeout(t, a), t.addEventListener("mouseenter", this.clearTimeout.bind(this, t)), t.addEventListener("focusin", this.clearTimeout.bind(this, t)), t.addEventListener(
30
22
  "mouseleave",
31
- this.startTimeout.bind(this, t, e)
23
+ this.startTimeout.bind(this, t, a)
32
24
  ), t.addEventListener(
33
25
  "focusout",
34
- this.startTimeout.bind(this, t, e)
35
- )), r;
26
+ this.startTimeout.bind(this, t, a)
27
+ )), h;
36
28
  }
37
29
  dismiss(t) {
38
30
  if (typeof t == "string") {
@@ -41,7 +33,7 @@ const d = class d extends HTMLElement {
41
33
  ).forEach((i) => this.dismiss(i));
42
34
  return;
43
35
  }
44
- this.added.delete(t), t.remove(), this.clearTimeout(t);
36
+ t.remove(), this.clearTimeout(t);
45
37
  }
46
38
  clear() {
47
39
  Array.from(this.children).forEach((t) => {
@@ -72,8 +64,8 @@ const d = class d extends HTMLElement {
72
64
  this.timeouts.has(t) && clearTimeout(this.timeouts.get(t));
73
65
  }
74
66
  };
75
- o(d, "duration", 1e4);
76
- let h = d;
67
+ o(r, "duration", 1e4);
68
+ let n = r;
77
69
  export {
78
- h as default
70
+ n as default
79
71
  };
@@ -4,10 +4,8 @@ export type AlertOptions = {
4
4
  };
5
5
  export default class AlertsElement extends HTMLElement {
6
6
  static duration: number;
7
- private added;
8
7
  private timeouts;
9
8
  private index;
10
- constructor();
11
9
  connectedCallback(): void;
12
10
  show(el: HTMLElement, options?: AlertOptions): string;
13
11
  dismiss(el: HTMLElement): void;
@@ -20,8 +20,8 @@ export default class TooltipElement extends HTMLElement {
20
20
  set disabled(val: boolean);
21
21
  private onKeyDown;
22
22
  private onKeyUp;
23
- private show;
24
- private hide;
23
+ show(): void;
24
+ hide(): void;
25
25
  private afterDelay;
26
26
  private createTooltip;
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inclusive-elements",
3
- "version": "0.5.0-beta.1",
3
+ "version": "0.5.0-beta.2",
4
4
  "description": "Accessible, lightweight, unstyled implementations of common UI controls.",
5
5
  "module": "dist/inclusive-elements.js",
6
6
  "type": "module",