inclusive-elements 0.5.5 → 0.6.1

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.
@@ -0,0 +1,94 @@
1
+ # Popover
2
+
3
+ **A native-first popover pattern using the Popover API.**
4
+
5
+ ## Example
6
+
7
+ ```html
8
+ <button popovertarget="info-popover">More info</button>
9
+
10
+ <div id="info-popover" popover data-placement="bottom-start">
11
+ This pattern no longer needs a library wrapper. Use the platform directly.
12
+ </div>
13
+ ```
14
+
15
+ ## Platform Requirements
16
+
17
+ - Requires modern browser support for the Popover API.
18
+ - The styling examples use CSS anchor positioning.
19
+
20
+ ## Behavior
21
+
22
+ - The button uses `popovertarget` to control the popover surface.
23
+ - The browser manages opening, closing, and light dismiss behavior for the popover.
24
+ - CSS anchor positioning can be used to place the popover relative to its trigger.
25
+
26
+ ## Accessibility Notes
27
+
28
+ - `popover` gives you a surface and lifecycle, not a semantic role. Choose markup and ARIA that match the actual pattern, such as menu, tooltip, or generic descriptive content.
29
+ - Make sure the trigger has an accessible name and clearly communicates what will open.
30
+ - Keep the content structure appropriate to the job. A simple help popover can stay plain, while interactive or decision-heavy content may be better served by a dialog.
31
+
32
+ ## Styling
33
+
34
+ As a simple recommendation, you can style all popover surfaces with the `popover` attribute and control placement with a `data-placement` attribute:
35
+
36
+ ```css
37
+ [popover] {
38
+ position: fixed;
39
+ position-anchor: auto;
40
+ }
41
+
42
+ [popover][data-placement='bottom'] {
43
+ position-area: block-end;
44
+ }
45
+
46
+ [popover][data-placement='bottom-start'] {
47
+ position-area: block-end span-inline-start;
48
+ }
49
+
50
+ [popover][data-placement='bottom-end'] {
51
+ position-area: block-end span-inline-end;
52
+ }
53
+
54
+ [popover][data-placement='top'] {
55
+ position-area: block-start;
56
+ }
57
+
58
+ [popover][data-placement='top-start'] {
59
+ position-area: block-start span-inline-start;
60
+ }
61
+
62
+ [popover][data-placement='top-end'] {
63
+ position-area: block-start span-inline-end;
64
+ }
65
+
66
+ [popover][data-placement='right'] {
67
+ position-area: inline-end;
68
+ }
69
+
70
+ [popover][data-placement='right-start'] {
71
+ position-area: inline-end span-block-start;
72
+ }
73
+
74
+ [popover][data-placement='right-end'] {
75
+ position-area: inline-end span-block-end;
76
+ }
77
+
78
+ [popover][data-placement='left'] {
79
+ position-area: inline-start;
80
+ }
81
+
82
+ [popover][data-placement='left-start'] {
83
+ position-area: inline-start span-block-start;
84
+ }
85
+
86
+ [popover][data-placement='left-end'] {
87
+ position-area: inline-start span-block-end;
88
+ }
89
+ ```
90
+
91
+ ## Further Reading
92
+
93
+ - [MDN: Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using)
94
+ - [MDN: CSS Anchor Positioning](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_anchor_positioning)
@@ -0,0 +1,90 @@
1
+ # Tabs
2
+
3
+ **An accessible tabs pattern with a supporting custom element.**
4
+
5
+ `ui-tabs` connects tabs and panels, keeps selection and focus state in sync, and adds the keyboard behavior the platform does not provide by itself.
6
+
7
+ ## Example
8
+
9
+ ```js
10
+ import { TabsElement } from 'inclusive-elements';
11
+
12
+ window.customElements.define('ui-tabs', TabsElement);
13
+ ```
14
+
15
+ ```html
16
+ <ui-tabs>
17
+ <div role="tablist" aria-label="Account sections">
18
+ <button type="button" role="tab" aria-selected="true">Profile</button>
19
+ <button type="button" role="tab">Security</button>
20
+ <button type="button" role="tab">Billing</button>
21
+ </div>
22
+
23
+ <section role="tabpanel">
24
+ <h2>Profile</h2>
25
+ <p>Manage your public details.</p>
26
+ </section>
27
+
28
+ <section role="tabpanel" hidden>
29
+ <h2>Security</h2>
30
+ <p>Update your password and sign-in settings.</p>
31
+ </section>
32
+
33
+ <section role="tabpanel" hidden>
34
+ <h2>Billing</h2>
35
+ <p>View invoices and payment methods.</p>
36
+ </section>
37
+ </ui-tabs>
38
+ ```
39
+
40
+ ## Behavior
41
+
42
+ ### Structure
43
+
44
+ - Add one descendant with `role="tablist"`. Use `button` elements with `role="tab"` inside it. Panels are read from owned descendants with `role="tabpanel"`, and `ui-tabs` pairs them strictly by document order.
45
+ - For initialized pairs, `ui-tabs` preserves existing `id` values where present, fills in missing `id` values, and normalizes `aria-controls` and `aria-labelledby` so each ordered pair stays wired together.
46
+
47
+ ### Selection And Panels
48
+
49
+ - Set `aria-selected="true"` on the tab that should be active by default. If none is marked selected, the first tab is selected automatically when the element connects.
50
+ - The active tab gets `aria-selected="true"` and stays in the normal tab order. Inactive tabs get `aria-selected="false"` and `tabindex="-1"`.
51
+ - Only the active panel remains visible. Other panels get `hidden = true`.
52
+ - If the active panel has no tabbable content and no author-provided `tabindex`, `ui-tabs` gives the panel `tabindex="0"` so keyboard users can still reach it.
53
+ - The element dispatches a `change` event on the `<ui-tabs>` element when user interaction or `selectTab()` changes the active tab.
54
+
55
+ ### Keyboard Navigation
56
+
57
+ - In a horizontal tablist, Left and Right move between tabs and wrap at the ends. Home and End jump to the first or last tab.
58
+ - In a vertical tablist, set `aria-orientation="vertical"` on the tablist. Then Up and Down move between tabs instead of Left and Right.
59
+ - Moving focus with the keyboard automatically activates the newly focused tab.
60
+
61
+ ### Dynamic Changes
62
+
63
+ - Adding, removing, or re-roleing tabs and panels after connection automatically re-syncs the ordered pairs. The current selected tab is preserved when its ordered slot still has a matching panel.
64
+
65
+ ## API
66
+
67
+ ```ts
68
+ // Select a tab by index. Returns true when the active tab changed.
69
+ tabs.selectTab(index, {
70
+ // Move focus to the selected tab.
71
+ focus: false,
72
+
73
+ // Emit a `change` event when selection changes.
74
+ emit: true,
75
+ });
76
+ ```
77
+
78
+ ## Styling
79
+
80
+ `ui-tabs` is unstyled. Style the selected tab from its ARIA state:
81
+
82
+ ```css
83
+ [role='tab'][aria-selected='true'] {
84
+ font-weight: 600;
85
+ }
86
+ ```
87
+
88
+ ## Further Reading
89
+
90
+ - [ARIA Authoring Practices Guide: Tabs Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/)
@@ -0,0 +1,68 @@
1
+ # Toolbar
2
+
3
+ **An accessible toolbar pattern with a supporting custom element.**
4
+
5
+ `ui-toolbar` groups a set of controls into a single tab stop and adds the arrow-key focus management the platform does not provide by itself.
6
+
7
+ ## Example
8
+
9
+ ```js
10
+ import { ToolbarElement } from 'inclusive-elements';
11
+
12
+ window.customElements.define('ui-toolbar', ToolbarElement);
13
+ ```
14
+
15
+ ```html
16
+ <ui-toolbar aria-label="Text formatting">
17
+ <button type="button">Bold</button>
18
+ <button type="button">Italic</button>
19
+ <button type="button">Underline</button>
20
+ </ui-toolbar>
21
+
22
+ <ui-toolbar aria-label="Alignment" aria-orientation="vertical">
23
+ <button type="button">Top</button>
24
+ <button type="button">Middle</button>
25
+ <button type="button">Bottom</button>
26
+ </ui-toolbar>
27
+ ```
28
+
29
+ ## Behavior
30
+
31
+ ### Structure
32
+
33
+ - `ui-toolbar` adds `role="toolbar"` if it is not already present.
34
+
35
+ ### Focus Management
36
+
37
+ - The toolbar itself starts as the entry point into the widget. When it receives focus, focus moves to the current managed control inside it.
38
+ - The active control gets `tabindex="0"`. Other controls get `tabindex="-1"` so Tab leaves the toolbar instead of stepping through every control.
39
+
40
+ ### Keyboard Navigation
41
+
42
+ - By default, toolbars are horizontal. Left and Right move focus between controls and wrap at the ends.
43
+ - Set `aria-orientation="vertical"` when the toolbar is arranged vertically. Then Up and Down move focus between controls instead.
44
+ - Home and End move focus to the first or last control.
45
+
46
+ ### Dynamic Changes
47
+
48
+ - Adding or removing controls after connection keeps the roving tabindex state in sync so the toolbar remains a single managed widget in the tab order.
49
+
50
+ ## Styling
51
+
52
+ `ui-toolbar` is unstyled. Lay out the controls however you like:
53
+
54
+ ```css
55
+ ui-toolbar {
56
+ display: inline-flex;
57
+ gap: 0.5rem;
58
+ }
59
+
60
+ ui-toolbar[aria-orientation='vertical'] {
61
+ flex-direction: column;
62
+ align-items: start;
63
+ }
64
+ ```
65
+
66
+ ## Further Reading
67
+
68
+ - [ARIA Authoring Practices Guide: Toolbar Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/)
@@ -0,0 +1,97 @@
1
+ # Tooltip
2
+
3
+ **An accessible tooltip pattern built on native hint popovers with a supporting custom element.**
4
+
5
+ `ui-tooltip` keeps the tooltip surface native and adds the ownership and interaction behavior the platform does not provide by itself.
6
+
7
+ ## Example
8
+
9
+ ```js
10
+ import { TooltipElement } from 'inclusive-elements';
11
+
12
+ window.customElements.define('ui-tooltip', TooltipElement);
13
+ ```
14
+
15
+ ```html
16
+ <!-- Adjacent sibling tooltip -->
17
+ <button type="button">Save</button>
18
+ <ui-tooltip popover="hint" data-placement="top">Save changes</ui-tooltip>
19
+
20
+ <!-- Explicit owner with for -->
21
+ <button id="share-button" type="button">Share</button>
22
+ <ui-tooltip for="share-button" popover="hint" data-placement="top">
23
+ Create a shareable link
24
+ </ui-tooltip>
25
+ ```
26
+
27
+ ## Platform Requirements
28
+
29
+ - Requires modern browser support for the Popover API and hint popovers with `popover="hint"`.
30
+ - The styling examples use CSS anchor positioning.
31
+
32
+ ## Behavior
33
+
34
+ ### Structure
35
+
36
+ - `ui-tooltip` adds `popover="hint"` and `role="tooltip"` if they are not already present.
37
+ - The tooltip ensures it has an `id` and adds that value to the owner's `aria-describedby`.
38
+
39
+ ### Ownership
40
+
41
+ - Use whichever ownership style fits the markup best: if the tooltip has a `for` attribute, it targets the element with that `id`; otherwise, it targets its immediately preceding element sibling.
42
+ - Changing `for`, `id`, or `disabled` re-syncs the owner relationship automatically.
43
+
44
+ ### Visibility And Interaction
45
+
46
+ - The `disabled` attribute, or the reflected `tooltip.disabled` property, prevents the tooltip from showing and clears any current owner relationship.
47
+ - Tooltips do not show while the tooltip itself is `disabled`, or when the resolved owner is `disabled` or `aria-disabled="true"`.
48
+ - The tooltip shows on keyboard focus and pointer hover, hides on blur, pointer exit, click, and Escape, and stays open while the pointer moves between the owner and the tooltip.
49
+
50
+ ### Content Guidance
51
+
52
+ - Tooltip content should stay descriptive, supplemental, and non-interactive.
53
+ - Do not put required instructions or critical information in a tooltip, because hover is not reliably available on touch and other coarse-pointer devices.
54
+ - If you need buttons, links, form controls, or information the user must be able to discover, use a popover or dialog pattern instead.
55
+
56
+ ## API
57
+
58
+ ```ts
59
+ // Default delay in milliseconds before the tooltip shows or hides.
60
+ TooltipElement.delay = 100;
61
+
62
+ // Override the delay for one tooltip instance.
63
+ tooltip.setAttribute('delay', '200');
64
+
65
+ // Reflect the disabled attribute as a property when convenient.
66
+ tooltip.disabled = true;
67
+
68
+ // Convenience methods for programmatic control.
69
+ tooltip.show();
70
+ tooltip.hide();
71
+ ```
72
+
73
+ ## Styling
74
+
75
+ `ui-tooltip` is unstyled. Position the tooltip with native anchor positioning:
76
+
77
+ ```css
78
+ [popover] {
79
+ position: fixed;
80
+ position-anchor: auto;
81
+ }
82
+
83
+ ui-tooltip[popover][data-placement='top'] {
84
+ position-area: block-start;
85
+ max-inline-size: 18rem;
86
+ padding: 0.5rem 0.75rem;
87
+ }
88
+
89
+ ui-tooltip[popover][data-placement='bottom'] {
90
+ position-area: block-end;
91
+ }
92
+ ```
93
+
94
+ ## Further Reading
95
+
96
+ - [ARIA Authoring Practices Guide: Tooltip Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/)
97
+ - [MDN: Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using)
@@ -1,20 +0,0 @@
1
- import { default as o } from "./inclusive-elements2.js";
2
- import { default as r } from "./inclusive-elements3.js";
3
- import { default as f } from "./inclusive-elements4.js";
4
- import { default as s } from "./inclusive-elements5.js";
5
- import { default as u } from "./inclusive-elements6.js";
6
- import { default as n } from "./inclusive-elements7.js";
7
- import { default as E } from "./inclusive-elements8.js";
8
- import { default as i } from "./inclusive-elements9.js";
9
- import { default as b } from "./inclusive-elements10.js";
10
- export {
11
- o as AccordionElement,
12
- r as AlertsElement,
13
- f as DisclosureElement,
14
- s as MenuElement,
15
- u as ModalElement,
16
- n as PopupElement,
17
- E as TabsElement,
18
- i as ToolbarElement,
19
- b as TooltipElement
20
- };
@@ -1,96 +0,0 @@
1
- var l = Object.defineProperty;
2
- var u = (n, s, t) => s in n ? l(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
3
- var e = (n, s, t) => (u(n, typeof s != "symbol" ? s + "" : s, t), t);
4
- import { autoUpdate as p, computePosition as c, shift as v, flip as m } from "@floating-ui/dom";
5
- import { hello as f, goodbye as b } from "hello-goodbye";
6
- const o = class o extends HTMLElement {
7
- constructor() {
8
- super(...arguments);
9
- e(this, "parent");
10
- e(this, "tooltip");
11
- e(this, "timeout");
12
- e(this, "disabledObserver");
13
- e(this, "showing", !1);
14
- e(this, "cleanup");
15
- e(this, "prevInnerHTML");
16
- e(this, "focusKeyPressed", !1);
17
- e(this, "onMouseEnter", () => {
18
- window.matchMedia("(hover: hover) and (pointer: fine)").matches && this.afterDelay(this.show);
19
- });
20
- e(this, "onFocus", () => {
21
- this.focusKeyPressed && this.show();
22
- });
23
- e(this, "onMouseLeave", this.afterDelay.bind(this, this.hide));
24
- e(this, "onBlur", this.hide.bind(this));
25
- e(this, "onKeyDown", (t) => {
26
- this.isFocusTriggerKey(t.key) && (this.focusKeyPressed = !0), t.key === "Escape" && this.hide();
27
- });
28
- e(this, "onKeyUp", (t) => {
29
- this.isFocusTriggerKey(t.key) && (this.focusKeyPressed = !1);
30
- });
31
- }
32
- connectedCallback() {
33
- 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("click", this.onBlur), this.disabledObserver = new MutationObserver((t) => {
34
- t.forEach((i) => {
35
- i.attributeName === "disabled" && this.hide();
36
- });
37
- }), this.disabledObserver.observe(this.parent, { attributes: !0 })), document.addEventListener("keydown", this.onKeyDown), document.addEventListener("keyup", this.onKeyUp), document.addEventListener("scroll", this.onBlur);
38
- }
39
- disconnectedCallback() {
40
- var t, i;
41
- (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("click", this.onBlur), this.parent = void 0), document.removeEventListener("keydown", this.onKeyDown), document.removeEventListener("keyup", this.onKeyUp), document.removeEventListener("scroll", this.onBlur), (i = this.disabledObserver) == null || i.disconnect(), clearTimeout(this.timeout);
42
- }
43
- get disabled() {
44
- return this.hasAttribute("disabled");
45
- }
46
- set disabled(t) {
47
- t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
48
- }
49
- isFocusTriggerKey(t) {
50
- return t === "Tab" || t === "ArrowUp" || t === "ArrowDown" || t === "ArrowLeft" || t === "ArrowRight";
51
- }
52
- show() {
53
- var i;
54
- if (this.disabled)
55
- return;
56
- const t = this.createTooltip();
57
- clearTimeout(this.timeout), this.showing || (t.hidden = !1, f(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(
58
- this.parent,
59
- t,
60
- () => c(this.parent, t, {
61
- placement: this.getAttribute("placement") || o.placement,
62
- middleware: [v(), m()]
63
- }).then(({ x: h, y: a, placement: d }) => {
64
- Object.assign(t.style, {
65
- left: `${h}px`,
66
- top: `${a}px`
67
- }), t.dataset.placement = d;
68
- })
69
- ), this.dispatchEvent(new Event("open"));
70
- }
71
- hide() {
72
- var t;
73
- clearTimeout(this.timeout), (t = this.cleanup) == null || t.call(this), this.showing && (this.showing = !1, this.tooltip && b(this.tooltip).then(() => {
74
- this.tooltip && (this.tooltip.hidden = !0);
75
- }), this.dispatchEvent(new Event("close")));
76
- }
77
- afterDelay(t) {
78
- clearTimeout(this.timeout);
79
- const i = parseInt(this.getAttribute("delay") || "");
80
- this.timeout = window.setTimeout(
81
- t.bind(this),
82
- isNaN(i) ? o.delay : i
83
- );
84
- }
85
- createTooltip() {
86
- return this.tooltip || (this.tooltip = document.createElement("div"), this.tooltip.hidden = !0, this.tooltip.addEventListener("mouseenter", this.show.bind(this)), this.tooltip.addEventListener(
87
- "mouseleave",
88
- this.afterDelay.bind(this, this.hide)
89
- ), document.body.appendChild(this.tooltip)), this.tooltip.className = this.getAttribute("tooltip-class") || o.tooltipClass, this.tooltip;
90
- }
91
- };
92
- e(o, "delay", 100), e(o, "placement", "top"), e(o, "tooltipClass", "tooltip");
93
- let r = o;
94
- export {
95
- r as default
96
- };
@@ -1,6 +0,0 @@
1
- function n(t) {
2
- return t.altKey || t.ctrlKey || t.metaKey || t.shiftKey || t.button !== void 0 && t.button !== 0;
3
- }
4
- export {
5
- n as shouldOpenInNewTab
6
- };
@@ -1,28 +0,0 @@
1
- var n = Object.defineProperty;
2
- var l = (r, e, t) => e in r ? n(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var s = (r, e, t) => (l(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- class a extends HTMLElement {
5
- constructor() {
6
- super(...arguments);
7
- s(this, "onToggle", (t) => {
8
- const o = t.target;
9
- o.open && this.querySelectorAll(
10
- ":scope > :is(ui-disclosure, details)"
11
- ).forEach((i) => {
12
- i.toggleAttribute("open", i === o), this.required && i.toggleAttribute("disabled", i === o);
13
- });
14
- });
15
- }
16
- connectedCallback() {
17
- this.addEventListener("toggle", this.onToggle, { capture: !0 });
18
- }
19
- disconnectedCallback() {
20
- this.removeEventListener("toggle", this.onToggle, { capture: !0 });
21
- }
22
- get required() {
23
- return this.hasAttribute("required");
24
- }
25
- }
26
- export {
27
- a as default
28
- };
@@ -1,71 +0,0 @@
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
- constructor() {
6
- super(...arguments);
7
- o(this, "timeouts", /* @__PURE__ */ new Map());
8
- o(this, "index", 0);
9
- }
10
- connectedCallback() {
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");
12
- for (const t of this.children)
13
- this.show(t);
14
- }
15
- show(t, i = {}) {
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
20
- );
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(
22
- "mouseleave",
23
- this.startTimeout.bind(this, t, a)
24
- ), t.addEventListener(
25
- "focusout",
26
- this.startTimeout.bind(this, t, a)
27
- )), h;
28
- }
29
- dismiss(t) {
30
- if (typeof t == "string") {
31
- this.querySelectorAll(
32
- `[data-key="${t}"]`
33
- ).forEach((i) => this.dismiss(i));
34
- return;
35
- }
36
- t.remove(), this.clearTimeout(t);
37
- }
38
- clear() {
39
- Array.from(this.children).forEach((t) => {
40
- this.dismiss(t);
41
- });
42
- }
43
- speak(t) {
44
- const i = document.createElement("div");
45
- Object.assign(i.style, {
46
- clip: "rect(0 0 0 0)",
47
- clipPath: "inset(50%)",
48
- height: "1px",
49
- overflow: "hidden",
50
- position: "absolute",
51
- whiteSpace: "nowrap",
52
- width: "1px"
53
- }), i.textContent = t, this.show(i);
54
- }
55
- startTimeout(t, i) {
56
- this.clearTimeout(t), this.timeouts.set(
57
- t,
58
- window.setTimeout(() => {
59
- this.dismiss(t);
60
- }, i)
61
- );
62
- }
63
- clearTimeout(t) {
64
- this.timeouts.has(t) && clearTimeout(this.timeouts.get(t));
65
- }
66
- };
67
- o(r, "duration", 1e4);
68
- let n = r;
69
- export {
70
- n as default
71
- };
@@ -1,49 +0,0 @@
1
- var o = Object.defineProperty;
2
- var r = (n, e, t) => e in n ? o(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var i = (n, e, t) => (r(n, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { cancel as h, hello as d, goodbye as a } from "hello-goodbye";
5
- import { shouldOpenInNewTab as l } from "./inclusive-elements11.js";
6
- class f extends HTMLElement {
7
- constructor() {
8
- super(...arguments);
9
- i(this, "onButtonClick", (t) => {
10
- !l(t) && !this.disabled && (this.open = !this.open, t.preventDefault());
11
- });
12
- }
13
- static get observedAttributes() {
14
- return ["open"];
15
- }
16
- connectedCallback() {
17
- this.content.hidden = !this.open, this.button.setAttribute("aria-expanded", String(this.open)), this.button.addEventListener("click", this.onButtonClick);
18
- }
19
- disconnectedCallback() {
20
- h(this.content), this.button.removeAttribute("aria-expanded"), this.button.removeEventListener("click", this.onButtonClick);
21
- }
22
- get open() {
23
- return this.hasAttribute("open");
24
- }
25
- set open(t) {
26
- t ? this.setAttribute("open", "") : this.removeAttribute("open");
27
- }
28
- get disabled() {
29
- return this.hasAttribute("disabled");
30
- }
31
- attributeChangedCallback(t, u, s) {
32
- t === "open" && (s !== null ? this.wasOpened() : this.wasClosed());
33
- }
34
- wasOpened() {
35
- this.content.hidden && (this.content.hidden = !1, d(this.content)), this.button.setAttribute("aria-expanded", "true"), this.dispatchEvent(new Event("toggle"));
36
- }
37
- wasClosed() {
38
- this.content.hidden || a(this.content).then(() => this.content.hidden = !0), this.button.setAttribute("aria-expanded", "false"), this.dispatchEvent(new Event("toggle"));
39
- }
40
- get button() {
41
- return this.querySelector("button, [role=button]");
42
- }
43
- get content() {
44
- return this.children[1];
45
- }
46
- }
47
- export {
48
- f as default
49
- };