@aurodesignsystem/auro-dialog 4.2.0 → 4.2.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +3 -19
  2. package/README.md +8 -9
  3. package/demo/accessibility.html +42 -0
  4. package/demo/accessibility.js +21 -0
  5. package/demo/accessibility.md +129 -0
  6. package/demo/accessibility.min.js +3969 -0
  7. package/demo/api.html +16 -40
  8. package/demo/api.md +0 -750
  9. package/demo/customize.html +45 -0
  10. package/demo/{api.js → customize.js} +2 -14
  11. package/demo/customize.md +226 -0
  12. package/demo/customize.min.js +3974 -0
  13. package/demo/demo-nav.css +32 -0
  14. package/demo/design.html +42 -0
  15. package/demo/design.js +23 -0
  16. package/demo/design.md +306 -0
  17. package/demo/design.min.js +4041 -0
  18. package/demo/getting-started.html +38 -0
  19. package/demo/getting-started.md +295 -0
  20. package/demo/index.html +17 -36
  21. package/demo/index.js +2 -3
  22. package/demo/index.md +220 -144
  23. package/demo/index.min.js +3984 -7
  24. package/demo/keyboard-behavior.html +38 -0
  25. package/demo/keyboard-behavior.md +51 -0
  26. package/demo/pages.json +1 -0
  27. package/demo/readme.html +42 -0
  28. package/demo/readme.js +24 -0
  29. package/demo/readme.md +176 -0
  30. package/demo/{auro-dialog.min.js → readme.min.js} +434 -281
  31. package/demo/support/demo-support.js +140 -0
  32. package/demo/voiceover.html +38 -0
  33. package/demo/voiceover.md +19 -0
  34. package/demo/why-dialog.html +38 -0
  35. package/demo/why-dialog.md +36 -0
  36. package/dist/{auro-dialog-CWkXz5VA.js → auro-dialog-T9I85UZL.js} +20 -20
  37. package/dist/index.d.ts +198 -98
  38. package/dist/index.js +1 -1
  39. package/dist/registered.js +1 -1
  40. package/package.json +6 -6
  41. package/demo/api.min.js +0 -219
@@ -0,0 +1,140 @@
1
+ // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
2
+ // See LICENSE in the project root for license information.
3
+ //
4
+ // Local-demo renderer for auro-dialog. Vendored from the Auro formkit
5
+ // `@aurodesignsystem/utils/demo-support` module (which is a private, unpublished
6
+ // workspace package and cannot be installed here). Renders demo pages with the
7
+ // same unified/remark/rehype pipeline AuroDocsSite uses — NOT marked.js — so the
8
+ // rich `docs/pages` markup (HTML + tables + fenced code) renders correctly. Also
9
+ // injects the top page-nav from `pages.json`.
10
+ //
11
+ // The remark/rehype stack is loaded from the jsDelivr ESM CDN, consistent with
12
+ // the other CDN imports in the demo HTML files.
13
+
14
+ import { unified } from 'https://cdn.jsdelivr.net/npm/unified@11/+esm';
15
+ import remarkParse from 'https://cdn.jsdelivr.net/npm/remark-parse@11/+esm';
16
+ import remarkGfm from 'https://cdn.jsdelivr.net/npm/remark-gfm@4/+esm';
17
+ import remarkRehype from 'https://cdn.jsdelivr.net/npm/remark-rehype@11/+esm';
18
+ import rehypeRaw from 'https://cdn.jsdelivr.net/npm/rehype-raw@7/+esm';
19
+ import rehypeHighlight from 'https://cdn.jsdelivr.net/npm/rehype-highlight@7/+esm';
20
+ import rehypeStringify from 'https://cdn.jsdelivr.net/npm/rehype-stringify@10/+esm';
21
+
22
+ /**
23
+ * Fetches `pages.json`, builds a top nav bar with a link to each page, and
24
+ * prepends it to <body>.
25
+ * @param {string} pagesDir - Directory containing pages.json (relative to the HTML file).
26
+ * @param {string} [activeFile] - Filename (e.g. "index.md") of the current page.
27
+ */
28
+ export async function injectPageNav(pagesDir, activeFile) {
29
+ let files = [];
30
+ try {
31
+ const res = await fetch(`${pagesDir}pages.json`);
32
+ if (!res.ok) {
33
+ return;
34
+ }
35
+ files = await res.json();
36
+ } catch {
37
+ return;
38
+ }
39
+
40
+ if (!files.length || document.getElementById('page-nav')) {
41
+ return;
42
+ }
43
+
44
+ const nav = document.createElement('nav');
45
+ nav.id = 'page-nav';
46
+
47
+ files.forEach((file) => {
48
+ const label = file.replace(/\.md$/, '').replace(/-/g, ' ');
49
+ const a = document.createElement('auro-hyperlink');
50
+ a.textContent = label;
51
+ a.setAttribute('href', `./${file.replace(/\.md$/, '.html')}`);
52
+ a.setAttribute('type', 'cta');
53
+ a.setAttribute('variant', 'ghost');
54
+ a.setAttribute('size', 'sm');
55
+ a.dataset.page = file;
56
+
57
+ if (file === activeFile) {
58
+ a.setAttribute('variant', 'tertiary');
59
+ }
60
+
61
+ nav.appendChild(a);
62
+ });
63
+
64
+ document.body.prepend(nav);
65
+ }
66
+
67
+ export async function renderPage(mdPath) {
68
+ const pagesDir = mdPath.substring(0, mdPath.lastIndexOf('/') + 1);
69
+ const activeFile = mdPath.split('/').pop().split('?')[0];
70
+ await injectPageNav(pagesDir, activeFile);
71
+
72
+ try {
73
+ const response = await fetch(mdPath);
74
+ if (!response.ok) {
75
+ console.error(`Failed to load "${mdPath}": ${response.status} ${response.statusText}`);
76
+ return;
77
+ }
78
+
79
+ const text = await response.text();
80
+ const result = await unified()
81
+ .use(remarkParse)
82
+ .use(remarkGfm)
83
+ .use(remarkRehype, { allowDangerousHtml: true })
84
+ .use(rehypeRaw)
85
+ .use(rehypeHighlight)
86
+ .use(rehypeStringify)
87
+ .process(text);
88
+
89
+ // Parse the rendered HTML into detached nodes and move them into <main>.
90
+ // Content is the repo's own trusted docs markdown; avoiding innerHTML keeps
91
+ // the write explicit and lets custom elements upgrade on connection.
92
+ const parsed = new DOMParser().parseFromString(String(result), 'text/html');
93
+ const main = document.querySelector('main');
94
+ if (!main) {
95
+ console.error('renderPage: no <main> element found; cannot render page content.');
96
+ return;
97
+ }
98
+ main.replaceChildren(...parsed.body.childNodes);
99
+ addCopyButtons();
100
+ } catch (err) {
101
+ console.error('Error rendering markdown page:', err);
102
+ }
103
+ }
104
+
105
+ function addCopyButtons() {
106
+ document.querySelectorAll('pre code[class*="language-"], pre code[class*="hljs"]').forEach((code) => {
107
+ const pre = code.parentElement;
108
+ const wrapper = document.createElement('div');
109
+ wrapper.className = 'pre-wrapper';
110
+ pre.parentNode.insertBefore(wrapper, pre);
111
+ wrapper.appendChild(pre);
112
+ const btn = document.createElement('button');
113
+ btn.className = 'copy-btn';
114
+ btn.textContent = 'Copy';
115
+ btn.addEventListener('click', () => {
116
+ const raw = code.textContent;
117
+ const text = raw.replace(/​/g, '').replace(/^\n+/, '').replace(/\n+$/, '\n').replace(/^\$ /, '');
118
+ navigator.clipboard.writeText(text).then(() => {
119
+ btn.textContent = 'Copied!';
120
+ setTimeout(() => { btn.textContent = 'Copy'; }, 1500);
121
+ });
122
+ });
123
+ wrapper.appendChild(btn);
124
+ });
125
+ }
126
+
127
+ export function openAccordion(id) {
128
+ document.querySelectorAll('auro-accordion').forEach((accordion) => {
129
+ accordion.removeAttribute('expanded');
130
+ });
131
+ const target = document.getElementById(id);
132
+ if (target) {
133
+ target.setAttribute('expanded', '');
134
+ setTimeout(() => {
135
+ target.scrollIntoView({ behavior: 'smooth', block: 'start' });
136
+ }, 550);
137
+ }
138
+ }
139
+
140
+ window.openAccordion = openAccordion;
@@ -0,0 +1,38 @@
1
+ <!--
2
+ Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
3
+ See LICENSE in the project root for license information.
4
+
5
+ Demo shell. Content authored in ../docs/pages/voiceover.md → ./voiceover.md.
6
+ Rendered by ./demo-support.js (remark/rehype) with the top page-nav from ./pages.json.
7
+ -->
8
+ <!DOCTYPE html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="UTF-8" />
12
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13
+ <title>Auro Web Component Demo | auro-dialog | VoiceOver</title>
14
+
15
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/styles/github.min.css"/>
16
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/design-tokens@latest/dist/legacy/auro-classic/CSSCustomProperties.css"/>
17
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/design-tokens@latest/dist/themes/alaska/CSSCustomProperties--alaska.min.css"/>
18
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/bundled/themes/alaska.global.min.css" />
19
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/demoWrapper.css" />
20
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/elementDemoStyles.css" />
21
+ <link rel="stylesheet" type="text/css" href="./demo-nav.css" />
22
+ </head>
23
+ <body class="auro-markdown">
24
+ <main></main>
25
+
26
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/+esm" type="module"></script>
27
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-nav@latest/+esm" type="module"></script>
28
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-header@latest/+esm" type="module"></script>
29
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest/+esm" type="module"></script>
30
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-hyperlink@latest/+esm" type="module"></script>
31
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-button@latest/+esm" type="module"></script>
32
+
33
+ <script type="module">
34
+ import { renderPage } from './support/demo-support.js';
35
+ await renderPage('./voiceover.md');
36
+ </script>
37
+ </body>
38
+ </html>
@@ -0,0 +1,19 @@
1
+ <auro-header level="1" id="overview">Dialog - VoiceOver Behavior</auro-header>
2
+ <p>This page documents the screen reader experience when using the <code>&lt;auro-dialog&gt;</code> component. Because the component is built on the native <code>&lt;dialog&gt;</code> element, announcements follow the platform's standard dialog conventions.</p>
3
+ <auro-header level="2" id="openAnnouncement">Opening the Dialog</auro-header>
4
+ <p>When the dialog opens, focus is moved into it and the screen reader announces:</p>
5
+ <ol>
6
+ <li><strong>Role:</strong> <em>"dialog"</em> (from the native <code>&lt;dialog&gt;</code> element).</li>
7
+ <li><strong>Accessible name:</strong> the <code>header</code> slot content, via <code>aria-labelledby</code>.</li>
8
+ <li><strong>Description:</strong> the <code>content</code> slot, via <code>aria-describedby</code>.</li>
9
+ <li><strong>First control:</strong> the first focusable element inside the dialog receives focus and is announced.</li>
10
+ </ol>
11
+ <auro-header level="2" id="navigatingContent">Navigating Content</auro-header>
12
+ <p>Within the dialog, the user navigates with the standard reading and Tab commands. Focus is trapped, so swiping or tabbing past the last element wraps back to the first and never lands on the obscured page behind the dialog. For a modal dialog, the rest of the page is <code>inert</code>, so the screen reader's virtual cursor cannot reach it either.</p>
13
+ <auro-header level="2" id="closeGesture">Closing the Dialog</auro-header>
14
+ <ul>
15
+ <li><strong>Non-modal:</strong> the dialog can be dismissed with the close button (announced using the <code>ariaLabel.dialog.close</code> slot text, or <em>"Close"</em> by default), the <code>Esc</code> key, or the platform dismiss gesture.</li>
16
+ <li><strong>Modal:</strong> passive dismissal is disabled. The dismiss gesture and <code>Esc</code> have no effect — the user must activate the explicit action in the footer.</li>
17
+ </ul>
18
+ <div class="note"><strong>iOS VoiceOver:</strong> the two-finger <em>"scrub"</em> (a <em>"Z"</em> shape) acts as the <code>Esc</code> key. <strong>Android TalkBack:</strong> the back gesture (swipe inward from a screen edge) dismisses a non-modal dialog.</div>
19
+ <p>When the dialog closes, focus returns to the triggering element, so the screen reader resumes from where the user left off on the page.</p>
@@ -0,0 +1,38 @@
1
+ <!--
2
+ Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
3
+ See LICENSE in the project root for license information.
4
+
5
+ Demo shell. Content authored in ../docs/pages/why-dialog.md → ./why-dialog.md.
6
+ Rendered by ./demo-support.js (remark/rehype) with the top page-nav from ./pages.json.
7
+ -->
8
+ <!DOCTYPE html>
9
+ <html lang="en">
10
+ <head>
11
+ <meta charset="UTF-8" />
12
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13
+ <title>Auro Web Component Demo | auro-dialog | Why auro-dialog</title>
14
+
15
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/styles/github.min.css"/>
16
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/design-tokens@latest/dist/legacy/auro-classic/CSSCustomProperties.css"/>
17
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/design-tokens@latest/dist/themes/alaska/CSSCustomProperties--alaska.min.css"/>
18
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/bundled/themes/alaska.global.min.css" />
19
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/demoWrapper.css" />
20
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@aurodesignsystem/webcorestylesheets@latest/dist/elementDemoStyles.css" />
21
+ <link rel="stylesheet" type="text/css" href="./demo-nav.css" />
22
+ </head>
23
+ <body class="auro-markdown">
24
+ <main></main>
25
+
26
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/+esm" type="module"></script>
27
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-nav@latest/+esm" type="module"></script>
28
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-header@latest/+esm" type="module"></script>
29
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest/+esm" type="module"></script>
30
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-hyperlink@latest/+esm" type="module"></script>
31
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-button@latest/+esm" type="module"></script>
32
+
33
+ <script type="module">
34
+ import { renderPage } from './support/demo-support.js';
35
+ await renderPage('./why-dialog.md');
36
+ </script>
37
+ </body>
38
+ </html>
@@ -0,0 +1,36 @@
1
+ <auro-header level="1" id="overview">Dialog - Why auro-dialog?</auro-header>
2
+ <p>The native HTML <code>&lt;dialog&gt;</code> element provides the foundation for overlays, but building a production-ready, accessible, on-brand dialog on top of it requires a substantial amount of repeated work. <code>&lt;auro-dialog&gt;</code> is built on the native element and layers on the behavior, styling, and accessibility that Alaska experiences need. This page explains what the component adds.</p>
3
+ <auro-header level="2" id="modalControl">Unified modal and non-modal modes</auro-header>
4
+ <p>Native <code>&lt;dialog&gt;</code> exposes two very different entry points — <code>show()</code> for non-modal and <code>showModal()</code> for modal — with different dismissal semantics you must wire up yourself.</p>
5
+ <p><code>&lt;auro-dialog&gt;</code> exposes a single <code>open</code> attribute plus a <code>modal</code> toggle, and handles the rest:</p>
6
+ <ul>
7
+ <li>Non-modal dialogs use the Popover API and dismiss on close button, <code>Esc</code>, or backdrop click.</li>
8
+ <li>Modal dialogs use <code>showModal()</code>, suppress passive dismissal, and hide the close button so the user must take an explicit action.</li>
9
+ </ul>
10
+ <auro-header level="2" id="focusManagement">Focus management</auro-header>
11
+ <p>With the native element you are responsible for moving focus into the dialog, trapping it, and restoring it afterward. <code>&lt;auro-dialog&gt;</code> does all three automatically: it focuses the first element on open, traps <code>Tab</code> focus while open, and restores focus to the triggering element (or a configurable <code>triggerElement</code>) on close.</p>
12
+ <auro-header level="2" id="responsiveLayout">Responsive layout</auro-header>
13
+ <p>Native dialogs have no built-in responsive behavior. <code>&lt;auro-dialog&gt;</code> adapts to the viewport — presenting as a full-width, size-scaled panel below the mobile breakpoint — and offers <code>sm</code>, <code>md</code>, and <code>lg</code> sizes that can be decoupled between desktop and mobile.</p>
14
+ <auro-header level="2" id="theming">Styling &amp; theming</auro-header>
15
+ <p>Styling a native <code>&lt;dialog&gt;</code> and its <code>::backdrop</code> from scratch is tedious and easy to get wrong. <code>&lt;auro-dialog&gt;</code> ships with Auro Design System styling out of the box, plus <code>::part()</code> selectors (<code>dialog</code>, <code>dialog-header</code>, <code>dialog-content</code>, <code>dialog-footer</code>, <code>close-button</code>) and design tokens for backdrop and surface colors.</p>
16
+ <auro-header level="2" id="accessibility">Accessibility</auro-header>
17
+ <p>The component wires up <code>aria-labelledby</code> and <code>aria-describedby</code> from the header and content slots, renders an accessible close button with a customizable label, and manages the <code>inert</code> background for modal dialogs — the details that are easy to omit when hand-rolling a dialog.</p>
18
+ <auro-header level="2" id="layeredComponents">Layered components</auro-header>
19
+ <p>Placing other floating UI (popovers, dropdowns) inside a native dialog can lead to top-layer stacking conflicts. <code>&lt;auro-dialog&gt;</code> coordinates with the shared Auro floating-UI runtime so layered components stack and dismiss correctly.</p>
20
+ <auro-header level="2" id="summary">Summary</auro-header>
21
+ <table>
22
+ <thead>
23
+ <tr><th>Capability</th><th><code>&lt;dialog&gt;</code></th><th><code>auro-dialog</code></th></tr>
24
+ </thead>
25
+ <tbody>
26
+ <tr><td>Modal / non-modal API</td><td>Two separate methods</td><td>Single <code>open</code> + <code>modal</code></td></tr>
27
+ <tr><td>Focus trap &amp; restore</td><td>Manual</td><td>Automatic</td></tr>
28
+ <tr><td>Responsive / mobile presentation</td><td>No</td><td>Automatic at breakpoint</td></tr>
29
+ <tr><td>Size options</td><td>No</td><td><code>sm</code> / <code>md</code> / <code>lg</code>, decoupled by breakpoint</td></tr>
30
+ <tr><td>Design system styling</td><td>Unstyled</td><td>On-brand, themeable</td></tr>
31
+ <tr><td>Backdrop styling</td><td>Manual <code>::backdrop</code></td><td>Design tokens</td></tr>
32
+ <tr><td>Accessible close button</td><td>Build your own</td><td>Built-in, labelable</td></tr>
33
+ <tr><td>ARIA labelling</td><td>Manual</td><td>Wired from slots</td></tr>
34
+ <tr><td>Layered floating components</td><td>Stacking conflicts</td><td>Coordinated top-layer</td></tr>
35
+ </tbody>
36
+ </table>