inclusive-elements 0.5.0-beta.1 → 0.5.0-beta.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.
@@ -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()]
58
- }).then(({ x: h, y: a, placement: d }) => {
57
+ middleware: [v(), m()]
58
+ }).then(({ x: r, y: a, placement: d }) => {
59
59
  Object.assign(t.style, {
60
- left: `${h}px`,
60
+ left: `${r}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
- clearTimeout(this.timeout), (t = this.cleanup) == null || t.call(this), this.showing && (this.showing = !1, f(this.tooltip).then(() => {
68
+ clearTimeout(this.timeout), (t = this.cleanup) == null || t.call(this), this.showing && (this.showing = !1, this.tooltip && 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,14 +78,14 @@ 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");
88
- let r = n;
88
+ let h = n;
89
89
  export {
90
- r as default
90
+ h as default
91
91
  };
@@ -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
  };
@@ -1,29 +1,31 @@
1
- var u = Object.defineProperty;
2
- var p = (r, n, t) => n in r ? u(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
- var s = (r, n, t) => (p(r, typeof n != "symbol" ? n + "" : n, t), t);
4
- import { autoUpdate as l, computePosition as f, shift as m, flip as b, size as k } from "@floating-ui/dom";
5
- import { cancel as a, hello as h, goodbye as c } from "hello-goodbye";
6
- import { focusable as g } from "tabbable";
7
- import { shouldOpenInNewTab as v } from "./inclusive-elements11.js";
8
- class A extends HTMLElement {
1
+ var l = Object.defineProperty;
2
+ var f = (a, s, t) => s in a ? l(a, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[s] = t;
3
+ var h = (a, s, t) => (f(a, typeof s != "symbol" ? s + "" : s, t), t);
4
+ import { autoUpdate as b, computePosition as m, shift as k, flip as g, size as v } from "@floating-ui/dom";
5
+ import { cancel as u, hello as d, goodbye as p } from "hello-goodbye";
6
+ import { focusable as w } from "tabbable";
7
+ import { shouldOpenInNewTab as y } from "./inclusive-elements11.js";
8
+ class D extends HTMLElement {
9
9
  constructor() {
10
10
  super();
11
- s(this, "cleanup");
12
- s(this, "onButtonClick", (t) => {
13
- !v(t) && !this.disabled && (this.open = !this.open, t.preventDefault());
11
+ h(this, "cleanup");
12
+ h(this, "onButtonClick", (t) => {
13
+ !y(t) && !this.disabled && (this.open = !this.open, t.preventDefault());
14
14
  });
15
- s(this, "onButtonKeyDown", (t) => {
15
+ h(this, "onButtonKeyDown", (t) => {
16
16
  var e;
17
- t.key === "ArrowDown" && !this.disabled && (t.preventDefault(), this.open = !0, (e = g(this.content)[0]) == null || e.focus());
17
+ t.key === "ArrowDown" && !this.disabled && (t.preventDefault(), this.open = !0, this.content && ((e = w(this.content)[0]) == null || e.focus()));
18
18
  });
19
- s(this, "onKeyDown", (t) => {
20
- t.key === "Escape" && this.open && (t.preventDefault(), t.stopPropagation(), this.open = !1, this.button.focus());
19
+ h(this, "onKeyDown", (t) => {
20
+ var e;
21
+ t.key === "Escape" && this.open && (t.preventDefault(), t.stopPropagation(), this.open = !1, (e = this.button) == null || e.focus());
21
22
  });
22
- s(this, "onFocusOut", (t) => {
23
- (!(t.relatedTarget instanceof Node) || !this.contains(t.relatedTarget)) && (this.open = !1);
23
+ h(this, "onFocusOut", (t) => {
24
+ t.relatedTarget instanceof Node && !this.contains(t.relatedTarget) && (this.open = !1);
24
25
  });
25
- s(this, "onContentClick", (t) => {
26
- t.target instanceof Element && t.target.closest("[role=menuitem], [role=menuitemradio]") && (this.open = !1, this.button.focus());
26
+ h(this, "onContentClick", (t) => {
27
+ var e;
28
+ t.target instanceof Element && t.target.closest("[role=menuitem], [role=menuitemradio]") && (this.open = !1, (e = this.button) == null || e.focus(), t.stopPropagation());
27
29
  });
28
30
  const t = document.createElement("template");
29
31
  t.innerHTML = `
@@ -35,12 +37,18 @@ class A extends HTMLElement {
35
37
  return ["open"];
36
38
  }
37
39
  connectedCallback() {
38
- this.backdrop.hidden = !0, this.content.hidden = !0, this.open = !1, this.button.setAttribute("aria-expanded", "false"), setTimeout(() => {
39
- this.content.getAttribute("role") === "menu" && this.button.setAttribute("aria-haspopup", "true");
40
- }), this.button.addEventListener("click", this.onButtonClick), this.button.addEventListener("keydown", this.onButtonKeyDown), this.addEventListener("keydown", this.onKeyDown), this.addEventListener("focusout", this.onFocusOut), this.content.addEventListener("click", this.onContentClick);
40
+ var t, e, n, o;
41
+ this.backdrop.hidden = !this.open, this.content && (this.content.hidden = !this.open), (t = this.button) == null || t.setAttribute(
42
+ "aria-expanded",
43
+ this.open ? "true" : "false"
44
+ ), setTimeout(() => {
45
+ var i, c;
46
+ ((i = this.content) == null ? void 0 : i.getAttribute("role")) === "menu" && ((c = this.button) == null || c.setAttribute("aria-haspopup", "true"));
47
+ }), (e = this.button) == null || e.addEventListener("click", this.onButtonClick), (n = this.button) == null || n.addEventListener("keydown", this.onButtonKeyDown), this.addEventListener("keydown", this.onKeyDown), this.addEventListener("focusout", this.onFocusOut), (o = this.content) == null || o.addEventListener("click", this.onContentClick);
41
48
  }
42
49
  disconnectedCallback() {
43
- a(this.backdrop), a(this.content), this.button.removeAttribute("aria-expanded"), this.button.removeAttribute("aria-haspopup"), this.button.removeEventListener("click", this.onButtonClick), this.button.removeEventListener("keydown", this.onButtonKeyDown), this.removeEventListener("keydown", this.onKeyDown), this.removeEventListener("focusout", this.onFocusOut), this.content.removeEventListener("click", this.onContentClick);
50
+ var t, e, n, o, i;
51
+ u(this.backdrop), this.content && u(this.content), (t = this.button) == null || t.removeAttribute("aria-expanded"), (e = this.button) == null || e.removeAttribute("aria-haspopup"), (n = this.button) == null || n.removeEventListener("click", this.onButtonClick), (o = this.button) == null || o.removeEventListener("keydown", this.onButtonKeyDown), this.removeEventListener("keydown", this.onKeyDown), this.removeEventListener("focusout", this.onFocusOut), (i = this.content) == null || i.removeEventListener("click", this.onContentClick);
44
52
  }
45
53
  get open() {
46
54
  return this.hasAttribute("open");
@@ -51,52 +59,57 @@ class A extends HTMLElement {
51
59
  get disabled() {
52
60
  return this.hasAttribute("disabled");
53
61
  }
54
- attributeChangedCallback(t, e, i) {
55
- t === "open" && (i !== null ? this.wasOpened() : this.wasClosed());
62
+ attributeChangedCallback(t, e, n) {
63
+ t === "open" && (n !== null ? this.wasOpened() : this.wasClosed());
56
64
  }
57
65
  wasOpened() {
58
- if (!this.content.hidden)
66
+ var e, n;
67
+ if (!((e = this.content) != null && e.hidden))
59
68
  return;
60
- this.content.hidden = !1, this.content.style.position = "fixed", this.backdrop.hidden = !1, h(this.content), h(this.backdrop), this.button.setAttribute("aria-expanded", "true"), this.cleanup = l(
69
+ this.content.hidden = !1, this.content.style.position = "fixed", this.backdrop.hidden = !1, d(this.content), d(this.backdrop), (n = this.button) == null || n.setAttribute("aria-expanded", "true"), this.button && (this.cleanup = b(
61
70
  this.button,
62
71
  this.content,
63
72
  () => {
64
- f(this.button, this.content, {
73
+ !this.button || !this.content || m(this.button, this.content, {
65
74
  strategy: "fixed",
66
75
  placement: this.getAttribute("placement") || "bottom",
67
76
  middleware: [
68
- m(),
69
- b(),
70
- k({
77
+ k(),
78
+ g(),
79
+ v({
71
80
  apply: ({
72
- availableWidth: e,
81
+ availableWidth: o,
73
82
  availableHeight: i,
74
- placement: d
83
+ placement: c
75
84
  }) => {
76
- this.content.dataset.placement = d, Object.assign(this.content.style, {
85
+ if (!this.content)
86
+ return;
87
+ this.content.dataset.placement = c, Object.assign(this.content.style, {
77
88
  maxWidth: "",
78
89
  maxHeight: ""
79
90
  });
80
- const o = getComputedStyle(this.content);
81
- e -= parseInt(o.marginLeft) + parseInt(o.marginRight), (o.maxWidth === "none" || e < parseInt(o.maxWidth)) && (this.content.style.maxWidth = `${e}px`), i -= parseInt(o.marginTop) + parseInt(o.marginBottom), (o.maxHeight === "none" || i < parseInt(o.maxHeight)) && (this.content.style.maxHeight = `${i}px`);
91
+ const r = getComputedStyle(
92
+ this.content
93
+ );
94
+ o -= parseInt(r.marginLeft) + parseInt(r.marginRight), (r.maxWidth === "none" || o < parseInt(r.maxWidth)) && (this.content.style.maxWidth = `${o}px`), i -= parseInt(r.marginTop) + parseInt(r.marginBottom), (r.maxHeight === "none" || i < parseInt(r.maxHeight)) && (this.content.style.maxHeight = `${i}px`);
82
95
  }
83
96
  })
84
97
  ]
85
- }).then(({ x: e, y: i }) => {
86
- Object.assign(this.content.style, {
87
- left: `${e}px`,
98
+ }).then(({ x: o, y: i }) => {
99
+ this.content && Object.assign(this.content.style, {
100
+ left: `${o}px`,
88
101
  top: `${i}px`
89
102
  });
90
103
  });
91
104
  },
92
105
  { ancestorScroll: !1 }
93
- );
106
+ ));
94
107
  const t = this.content.querySelector("[autofocus]");
95
108
  t ? t.focus() : this.content.focus(), this.dispatchEvent(new Event("open"));
96
109
  }
97
110
  wasClosed() {
98
- var t;
99
- this.content.hidden || (this.button.setAttribute("aria-expanded", "false"), (t = this.cleanup) == null || t.call(this), c(this.backdrop).then(() => this.backdrop.hidden = !0), c(this.content).then(() => this.content.hidden = !0), this.dispatchEvent(new Event("close")));
111
+ var t, e, n;
112
+ (t = this.content) != null && t.hidden || ((e = this.button) == null || e.setAttribute("aria-expanded", "false"), (n = this.cleanup) == null || n.call(this), p(this.backdrop).then(() => this.backdrop.hidden = !0), this.content && p(this.content).then(() => this.content.hidden = !0), this.dispatchEvent(new Event("close")));
100
113
  }
101
114
  get backdrop() {
102
115
  var t;
@@ -110,5 +123,5 @@ class A extends HTMLElement {
110
123
  }
111
124
  }
112
125
  export {
113
- A as default
126
+ D as default
114
127
  };
@@ -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.3",
4
4
  "description": "Accessible, lightweight, unstyled implementations of common UI controls.",
5
5
  "module": "dist/inclusive-elements.js",
6
6
  "type": "module",
@@ -18,17 +18,17 @@
18
18
  "release": "release-it"
19
19
  },
20
20
  "dependencies": {
21
- "@floating-ui/dom": "^1.5.3",
22
- "focus-trap": "^7.5.3",
23
- "hello-goodbye": "^0.2.1",
21
+ "@floating-ui/dom": "^1.7.4",
22
+ "focus-trap": "^7.6.5",
23
+ "hello-goodbye": "^0.2.2",
24
24
  "tabbable": "^6.2.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@release-it/conventional-changelog": "^5.1.1",
28
28
  "prettier": "^2.8.8",
29
29
  "release-it": "^15.11.0",
30
- "typescript": "^5.2.2",
31
- "vite": "^4.4.11"
30
+ "typescript": "^5.9.2",
31
+ "vite": "^4.5.14"
32
32
  },
33
33
  "release-it": {
34
34
  "git": {
@@ -52,5 +52,6 @@
52
52
  },
53
53
  "prettier": {
54
54
  "singleQuote": true
55
- }
55
+ },
56
+ "packageManager": "pnpm@10.17.1+sha512.17c560fca4867ae9473a3899ad84a88334914f379be46d455cbf92e5cf4b39d34985d452d2583baf19967fa76cb5c17bc9e245529d0b98745721aa7200ecaf7a"
56
57
  }