@magic-spells/dialog-panel 0.1.0 → 0.2.0

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,492 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DialogPanel = {}));
5
+ })(this, (function (exports) { 'use strict';
6
+
7
+ /**
8
+ * Retrieves all focusable elements within a given container.
9
+ *
10
+ * @param {HTMLElement} container - The container element to search for focusable elements.
11
+ * @returns {HTMLElement[]} An array of focusable elements found within the container.
12
+ */
13
+ const getFocusableElements = (container) => {
14
+ const focusableSelectors =
15
+ 'summary, a[href], button:not(:disabled), [tabindex]:not([tabindex^="-"]):not(focus-trap-start):not(focus-trap-end), [draggable], area, input:not([type=hidden]):not(:disabled), select:not(:disabled), textarea:not(:disabled), object, iframe';
16
+ return Array.from(container.querySelectorAll(focusableSelectors));
17
+ };
18
+
19
+ class FocusTrap extends HTMLElement {
20
+ /** @type {boolean} Indicates whether the styles have been injected into the DOM. */
21
+ static styleInjected = false;
22
+
23
+ constructor() {
24
+ super();
25
+ this.trapStart = null;
26
+ this.trapEnd = null;
27
+
28
+ // Inject styles only once, when the first FocusTrap instance is created.
29
+ if (!FocusTrap.styleInjected) {
30
+ this.injectStyles();
31
+ FocusTrap.styleInjected = true;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Injects necessary styles for the focus trap into the document's head.
37
+ * This ensures that focus-trap-start and focus-trap-end elements are hidden.
38
+ */
39
+ injectStyles() {
40
+ const style = document.createElement('style');
41
+ style.textContent = `
42
+ focus-trap-start,
43
+ focus-trap-end {
44
+ position: absolute;
45
+ width: 1px;
46
+ height: 1px;
47
+ margin: -1px;
48
+ padding: 0;
49
+ border: 0;
50
+ clip: rect(0, 0, 0, 0);
51
+ overflow: hidden;
52
+ white-space: nowrap;
53
+ }
54
+ `;
55
+ document.head.appendChild(style);
56
+ }
57
+
58
+ /**
59
+ * Called when the element is connected to the DOM.
60
+ * Sets up the focus trap and adds the keydown event listener.
61
+ */
62
+ connectedCallback() {
63
+ this.setupTrap();
64
+ this.addEventListener('keydown', this.handleKeyDown);
65
+ }
66
+
67
+ /**
68
+ * Called when the element is disconnected from the DOM.
69
+ * Removes the keydown event listener.
70
+ */
71
+ disconnectedCallback() {
72
+ this.removeEventListener('keydown', this.handleKeyDown);
73
+ }
74
+
75
+ /**
76
+ * Sets up the focus trap by adding trap start and trap end elements.
77
+ * Focuses the trap start element to initiate the focus trap.
78
+ */
79
+ setupTrap() {
80
+ // check to see it there are any focusable children
81
+ const focusableElements = getFocusableElements(this);
82
+ // exit if there aren't any
83
+ if (focusableElements.length === 0) return;
84
+
85
+ // create trap start and end elements
86
+ this.trapStart = document.createElement('focus-trap-start');
87
+ this.trapEnd = document.createElement('focus-trap-end');
88
+
89
+ // add to DOM
90
+ this.prepend(this.trapStart);
91
+ this.append(this.trapEnd);
92
+ }
93
+
94
+ /**
95
+ * Handles the keydown event. If the Escape key is pressed, the focus trap is exited.
96
+ *
97
+ * @param {KeyboardEvent} e - The keyboard event object.
98
+ */
99
+ handleKeyDown = (e) => {
100
+ if (e.key === 'Escape') {
101
+ e.preventDefault();
102
+ this.exitTrap();
103
+ }
104
+ };
105
+
106
+ /**
107
+ * Exits the focus trap by hiding the current container and shifting focus
108
+ * back to the trigger element that opened the trap.
109
+ */
110
+ exitTrap() {
111
+ const container = this.closest('[aria-hidden="false"]');
112
+ if (!container) return;
113
+
114
+ container.setAttribute('aria-hidden', 'true');
115
+
116
+ const trigger = document.querySelector(
117
+ `[aria-expanded="true"][aria-controls="${container.id}"]`
118
+ );
119
+ if (trigger) {
120
+ trigger.setAttribute('aria-expanded', 'false');
121
+ trigger.focus();
122
+ }
123
+ }
124
+ }
125
+
126
+ class FocusTrapStart extends HTMLElement {
127
+ /**
128
+ * Called when the element is connected to the DOM.
129
+ * Sets the tabindex and adds the focus event listener.
130
+ */
131
+ connectedCallback() {
132
+ this.setAttribute('tabindex', '0');
133
+ this.addEventListener('focus', this.handleFocus);
134
+ }
135
+
136
+ /**
137
+ * Called when the element is disconnected from the DOM.
138
+ * Removes the focus event listener.
139
+ */
140
+ disconnectedCallback() {
141
+ this.removeEventListener('focus', this.handleFocus);
142
+ }
143
+
144
+ /**
145
+ * Handles the focus event. If focus moves backwards from the first focusable element,
146
+ * it is cycled to the last focusable element, and vice versa.
147
+ *
148
+ * @param {FocusEvent} e - The focus event object.
149
+ */
150
+ handleFocus = (e) => {
151
+ const trap = this.closest('focus-trap');
152
+ const focusableElements = getFocusableElements(trap);
153
+
154
+ if (focusableElements.length === 0) return;
155
+
156
+ const firstElement = focusableElements[0];
157
+ const lastElement =
158
+ focusableElements[focusableElements.length - 1];
159
+
160
+ if (e.relatedTarget === firstElement) {
161
+ lastElement.focus();
162
+ } else {
163
+ firstElement.focus();
164
+ }
165
+ };
166
+ }
167
+
168
+ class FocusTrapEnd extends HTMLElement {
169
+ /**
170
+ * Called when the element is connected to the DOM.
171
+ * Sets the tabindex and adds the focus event listener.
172
+ */
173
+ connectedCallback() {
174
+ this.setAttribute('tabindex', '0');
175
+ this.addEventListener('focus', this.handleFocus);
176
+ }
177
+
178
+ /**
179
+ * Called when the element is disconnected from the DOM.
180
+ * Removes the focus event listener.
181
+ */
182
+ disconnectedCallback() {
183
+ this.removeEventListener('focus', this.handleFocus);
184
+ }
185
+
186
+ /**
187
+ * Handles the focus event. When the trap end is focused, focus is shifted back to the trap start.
188
+ */
189
+ handleFocus = () => {
190
+ const trap = this.closest('focus-trap');
191
+ const trapStart = trap.querySelector('focus-trap-start');
192
+ trapStart.focus();
193
+ };
194
+ }
195
+
196
+ customElements.define('focus-trap', FocusTrap);
197
+ customElements.define('focus-trap-start', FocusTrapStart);
198
+ customElements.define('focus-trap-end', FocusTrapEnd);
199
+
200
+ /**
201
+ * Custom element that creates an accessible modal dialog panel with focus management
202
+ * @extends HTMLElement
203
+ */
204
+ class DialogPanel extends HTMLElement {
205
+ #handleTransitionEnd;
206
+ #scrollPosition = 0;
207
+
208
+ /**
209
+ * Clean up event listeners when component is removed from DOM
210
+ */
211
+ disconnectedCallback() {
212
+ const _ = this;
213
+ if (_.contentPanel) {
214
+ _.contentPanel.removeEventListener('transitionend', _.#handleTransitionEnd);
215
+ }
216
+
217
+ // Ensure body scroll is restored if component is removed while open
218
+ document.body.classList.remove('overflow-hidden');
219
+ this.#restoreScroll();
220
+ }
221
+
222
+ /**
223
+ * Saves current scroll position and locks body scrolling
224
+ * @private
225
+ */
226
+ #lockScroll() {
227
+ const _ = this;
228
+ // Save current scroll position
229
+ _.#scrollPosition = window.pageYOffset;
230
+
231
+ // Apply fixed position to body
232
+ document.body.classList.add('overflow-hidden');
233
+ document.body.style.top = `-${_.#scrollPosition}px`;
234
+ }
235
+
236
+ /**
237
+ * Restores scroll position when dialog is closed
238
+ * @private
239
+ */
240
+ #restoreScroll() {
241
+ const _ = this;
242
+ // Remove fixed positioning
243
+ document.body.classList.remove('overflow-hidden');
244
+ document.body.style.removeProperty('top');
245
+
246
+ // Restore scroll position
247
+ window.scrollTo(0, _.#scrollPosition);
248
+ }
249
+ /**
250
+ * Initializes the dialog panel, sets up focus trap and overlay
251
+ */
252
+ constructor() {
253
+ super();
254
+ const _ = this;
255
+ _.id = _.getAttribute('id');
256
+ _.setAttribute('role', 'dialog');
257
+ _.setAttribute('aria-modal', 'true');
258
+ _.setAttribute('aria-hidden', 'true');
259
+
260
+ _.contentPanel = _.querySelector('dialog-content');
261
+ _.focusTrap = document.createElement('focus-trap');
262
+ _.triggerEl = null;
263
+
264
+ // Create a handler for transition end events
265
+ _.#handleTransitionEnd = (e) => {
266
+ if (e.propertyName === 'opacity' && _.getAttribute('aria-hidden') === 'true') {
267
+ _.contentPanel.classList.add('hidden');
268
+
269
+ // Dispatch afterHide event - dialog has completed its transition
270
+ _.dispatchEvent(new CustomEvent('afterHide', {
271
+ bubbles: true,
272
+ detail: { triggerElement: _.triggerEl }
273
+ }));
274
+ }
275
+ };
276
+
277
+ // Ensure we have labelledby and describedby references
278
+ if (!_.getAttribute('aria-labelledby')) {
279
+ const heading = _.querySelector('h1, h2, h3');
280
+ if (heading && !heading.id) {
281
+ heading.id = `${_.id}-title`;
282
+ }
283
+ if (heading?.id) {
284
+ _.setAttribute('aria-labelledby', heading.id);
285
+ }
286
+ }
287
+
288
+ _.contentPanel.parentNode.insertBefore(
289
+ _.focusTrap,
290
+ _.contentPanel
291
+ );
292
+ _.focusTrap.appendChild(_.contentPanel);
293
+
294
+ _.focusTrap.setupTrap();
295
+
296
+ // Add modal overlay
297
+ _.prepend(document.createElement('dialog-overlay'));
298
+ _.#bindUI();
299
+ _.#bindKeyboard();
300
+ }
301
+
302
+ /**
303
+ * Binds click events for showing and hiding the dialog
304
+ * @private
305
+ */
306
+ #bindUI() {
307
+ const _ = this;
308
+
309
+ // Handle trigger buttons
310
+ document.addEventListener('click', (e) => {
311
+ const trigger = e.target.closest(
312
+ `[aria-controls="${_.id}"]`
313
+ );
314
+ if (!trigger) return;
315
+
316
+ if (trigger.getAttribute('data-prevent-default') === 'true') {
317
+ e.preventDefault();
318
+ }
319
+
320
+ _.show(trigger);
321
+ });
322
+
323
+ // Handle close buttons
324
+ _.addEventListener('click', (e) => {
325
+ if (!e.target.closest('[data-action="hide-dialog"]')) return;
326
+ _.hide();
327
+ });
328
+
329
+ // Add transition end listener
330
+ _.contentPanel.addEventListener('transitionend', _.#handleTransitionEnd);
331
+ }
332
+
333
+ /**
334
+ * Binds keyboard events for accessibility
335
+ * @private
336
+ */
337
+ #bindKeyboard() {
338
+ this.addEventListener('keydown', (e) => {
339
+ if (e.key === 'Escape') {
340
+ this.hide();
341
+ }
342
+ });
343
+ }
344
+
345
+ /**
346
+ * Shows the dialog and traps focus within it
347
+ * @param {HTMLElement} [triggerEl=null] - The element that triggered the dialog
348
+ * @fires DialogPanel#beforeShow - Fired before the dialog starts to show
349
+ * @fires DialogPanel#show - Fired when the dialog has been shown
350
+ * @returns {boolean} False if the show was prevented by a beforeShow event handler
351
+ */
352
+ show(triggerEl = null) {
353
+ const _ = this;
354
+ _.triggerEl = triggerEl || false;
355
+
356
+ // Dispatch beforeShow event - allows preventing the dialog from opening
357
+ const beforeShowEvent = new CustomEvent('beforeShow', {
358
+ bubbles: true,
359
+ cancelable: true,
360
+ detail: { triggerElement: _.triggerEl }
361
+ });
362
+
363
+ const showAllowed = _.dispatchEvent(beforeShowEvent);
364
+
365
+ // If event was canceled (preventDefault was called), don't show the dialog
366
+ if (!showAllowed) return false;
367
+
368
+ // Remove the hidden class first to ensure content is rendered
369
+ _.contentPanel.classList.remove('hidden');
370
+
371
+ // Give the browser a moment to process before starting animation
372
+ requestAnimationFrame(() => {
373
+ // Update ARIA states
374
+ _.setAttribute('aria-hidden', 'false');
375
+ if (_.triggerEl) {
376
+ _.triggerEl.setAttribute('aria-expanded', 'true');
377
+ }
378
+
379
+ // Lock body scrolling and save scroll position
380
+ _.#lockScroll();
381
+
382
+ // Focus management
383
+ const firstFocusable = _.querySelector(
384
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
385
+ );
386
+ if (firstFocusable) {
387
+ requestAnimationFrame(() => {
388
+ firstFocusable.focus();
389
+ });
390
+ }
391
+
392
+ // Dispatch show event - dialog is now visible
393
+ _.dispatchEvent(new CustomEvent('show', {
394
+ bubbles: true,
395
+ detail: { triggerElement: _.triggerEl }
396
+ }));
397
+ });
398
+
399
+ return true;
400
+ }
401
+
402
+ /**
403
+ * Hides the dialog and restores focus
404
+ * @fires DialogPanel#beforeHide - Fired before the dialog starts to hide
405
+ * @fires DialogPanel#hide - Fired when the dialog has started hiding (transition begins)
406
+ * @fires DialogPanel#afterHide - Fired when the dialog has completed its hide transition
407
+ * @returns {boolean} False if the hide was prevented by a beforeHide event handler
408
+ */
409
+ hide() {
410
+ const _ = this;
411
+
412
+ // Dispatch beforeHide event - allows preventing the dialog from closing
413
+ const beforeHideEvent = new CustomEvent('beforeHide', {
414
+ bubbles: true,
415
+ cancelable: true,
416
+ detail: { triggerElement: _.triggerEl }
417
+ });
418
+
419
+ const hideAllowed = _.dispatchEvent(beforeHideEvent);
420
+
421
+ // If event was canceled (preventDefault was called), don't hide the dialog
422
+ if (!hideAllowed) return false;
423
+
424
+ // Restore body scroll and scroll position
425
+ _.#restoreScroll();
426
+
427
+ // Update ARIA states
428
+ if (_.triggerEl) {
429
+ // remove focus from modal panel first
430
+ _.triggerEl.focus();
431
+ // mark trigger as no longer expanded
432
+ _.triggerEl.setAttribute('aria-expanded', 'false');
433
+ }
434
+
435
+ // Set aria-hidden to start transition
436
+ // The transitionend event handler will add display:none when complete
437
+ _.setAttribute('aria-hidden', 'true');
438
+
439
+ // Dispatch hide event - dialog is now starting to hide
440
+ _.dispatchEvent(new CustomEvent('hide', {
441
+ bubbles: true,
442
+ detail: { triggerElement: _.triggerEl }
443
+ }));
444
+
445
+ return true;
446
+ }
447
+ }
448
+
449
+ /**
450
+ * Custom element that creates a clickable overlay for the dialog
451
+ * @extends HTMLElement
452
+ */
453
+ class DialogOverlay extends HTMLElement {
454
+ constructor() {
455
+ super();
456
+ this.setAttribute('tabindex', '-1'); // Changed to -1 as it shouldn't be focusable
457
+ this.setAttribute('aria-hidden', 'true');
458
+ this.dialogPanel = this.closest('dialog-panel');
459
+ this.#bindUI();
460
+ }
461
+
462
+ #bindUI() {
463
+ this.addEventListener('click', () => {
464
+ this.dialogPanel.hide();
465
+ });
466
+ }
467
+ }
468
+
469
+ /**
470
+ * Custom element that wraps the content of the dialog
471
+ * @extends HTMLElement
472
+ */
473
+ class DialogContent extends HTMLElement {
474
+ constructor() {
475
+ super();
476
+ this.setAttribute('role', 'document'); // Optional: helps with document structure
477
+ }
478
+ }
479
+
480
+ customElements.define('dialog-panel', DialogPanel);
481
+ customElements.define('dialog-overlay', DialogOverlay);
482
+ customElements.define('dialog-content', DialogContent);
483
+
484
+ exports.DialogContent = DialogContent;
485
+ exports.DialogOverlay = DialogOverlay;
486
+ exports.DialogPanel = DialogPanel;
487
+ exports.default = DialogPanel;
488
+
489
+ Object.defineProperty(exports, '__esModule', { value: true });
490
+
491
+ }));
492
+ //# sourceMappingURL=dialog-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog-panel.js","sources":["../node_modules/@magic-spells/focus-trap/dist/focus-trap.esm.js","../src/dialog-panel.js"],"sourcesContent":["/**\n * Retrieves all focusable elements within a given container.\n *\n * @param {HTMLElement} container - The container element to search for focusable elements.\n * @returns {HTMLElement[]} An array of focusable elements found within the container.\n */\nconst getFocusableElements = (container) => {\n\tconst focusableSelectors =\n\t\t'summary, a[href], button:not(:disabled), [tabindex]:not([tabindex^=\"-\"]):not(focus-trap-start):not(focus-trap-end), [draggable], area, input:not([type=hidden]):not(:disabled), select:not(:disabled), textarea:not(:disabled), object, iframe';\n\treturn Array.from(container.querySelectorAll(focusableSelectors));\n};\n\nclass FocusTrap extends HTMLElement {\n\t/** @type {boolean} Indicates whether the styles have been injected into the DOM. */\n\tstatic styleInjected = false;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.trapStart = null;\n\t\tthis.trapEnd = null;\n\n\t\t// Inject styles only once, when the first FocusTrap instance is created.\n\t\tif (!FocusTrap.styleInjected) {\n\t\t\tthis.injectStyles();\n\t\t\tFocusTrap.styleInjected = true;\n\t\t}\n\t}\n\n\t/**\n\t * Injects necessary styles for the focus trap into the document's head.\n\t * This ensures that focus-trap-start and focus-trap-end elements are hidden.\n\t */\n\tinjectStyles() {\n\t\tconst style = document.createElement('style');\n\t\tstyle.textContent = `\n focus-trap-start,\n focus-trap-end {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n border: 0;\n clip: rect(0, 0, 0, 0);\n overflow: hidden;\n white-space: nowrap;\n }\n `;\n\t\tdocument.head.appendChild(style);\n\t}\n\n\t/**\n\t * Called when the element is connected to the DOM.\n\t * Sets up the focus trap and adds the keydown event listener.\n\t */\n\tconnectedCallback() {\n\t\tthis.setupTrap();\n\t\tthis.addEventListener('keydown', this.handleKeyDown);\n\t}\n\n\t/**\n\t * Called when the element is disconnected from the DOM.\n\t * Removes the keydown event listener.\n\t */\n\tdisconnectedCallback() {\n\t\tthis.removeEventListener('keydown', this.handleKeyDown);\n\t}\n\n\t/**\n\t * Sets up the focus trap by adding trap start and trap end elements.\n\t * Focuses the trap start element to initiate the focus trap.\n\t */\n\tsetupTrap() {\n\t\t// check to see it there are any focusable children\n\t\tconst focusableElements = getFocusableElements(this);\n\t\t// exit if there aren't any\n\t\tif (focusableElements.length === 0) return;\n\n\t\t// create trap start and end elements\n\t\tthis.trapStart = document.createElement('focus-trap-start');\n\t\tthis.trapEnd = document.createElement('focus-trap-end');\n\n\t\t// add to DOM\n\t\tthis.prepend(this.trapStart);\n\t\tthis.append(this.trapEnd);\n\t}\n\n\t/**\n\t * Handles the keydown event. If the Escape key is pressed, the focus trap is exited.\n\t *\n\t * @param {KeyboardEvent} e - The keyboard event object.\n\t */\n\thandleKeyDown = (e) => {\n\t\tif (e.key === 'Escape') {\n\t\t\te.preventDefault();\n\t\t\tthis.exitTrap();\n\t\t}\n\t};\n\n\t/**\n\t * Exits the focus trap by hiding the current container and shifting focus\n\t * back to the trigger element that opened the trap.\n\t */\n\texitTrap() {\n\t\tconst container = this.closest('[aria-hidden=\"false\"]');\n\t\tif (!container) return;\n\n\t\tcontainer.setAttribute('aria-hidden', 'true');\n\n\t\tconst trigger = document.querySelector(\n\t\t\t`[aria-expanded=\"true\"][aria-controls=\"${container.id}\"]`\n\t\t);\n\t\tif (trigger) {\n\t\t\ttrigger.setAttribute('aria-expanded', 'false');\n\t\t\ttrigger.focus();\n\t\t}\n\t}\n}\n\nclass FocusTrapStart extends HTMLElement {\n\t/**\n\t * Called when the element is connected to the DOM.\n\t * Sets the tabindex and adds the focus event listener.\n\t */\n\tconnectedCallback() {\n\t\tthis.setAttribute('tabindex', '0');\n\t\tthis.addEventListener('focus', this.handleFocus);\n\t}\n\n\t/**\n\t * Called when the element is disconnected from the DOM.\n\t * Removes the focus event listener.\n\t */\n\tdisconnectedCallback() {\n\t\tthis.removeEventListener('focus', this.handleFocus);\n\t}\n\n\t/**\n\t * Handles the focus event. If focus moves backwards from the first focusable element,\n\t * it is cycled to the last focusable element, and vice versa.\n\t *\n\t * @param {FocusEvent} e - The focus event object.\n\t */\n\thandleFocus = (e) => {\n\t\tconst trap = this.closest('focus-trap');\n\t\tconst focusableElements = getFocusableElements(trap);\n\n\t\tif (focusableElements.length === 0) return;\n\n\t\tconst firstElement = focusableElements[0];\n\t\tconst lastElement =\n\t\t\tfocusableElements[focusableElements.length - 1];\n\n\t\tif (e.relatedTarget === firstElement) {\n\t\t\tlastElement.focus();\n\t\t} else {\n\t\t\tfirstElement.focus();\n\t\t}\n\t};\n}\n\nclass FocusTrapEnd extends HTMLElement {\n\t/**\n\t * Called when the element is connected to the DOM.\n\t * Sets the tabindex and adds the focus event listener.\n\t */\n\tconnectedCallback() {\n\t\tthis.setAttribute('tabindex', '0');\n\t\tthis.addEventListener('focus', this.handleFocus);\n\t}\n\n\t/**\n\t * Called when the element is disconnected from the DOM.\n\t * Removes the focus event listener.\n\t */\n\tdisconnectedCallback() {\n\t\tthis.removeEventListener('focus', this.handleFocus);\n\t}\n\n\t/**\n\t * Handles the focus event. When the trap end is focused, focus is shifted back to the trap start.\n\t */\n\thandleFocus = () => {\n\t\tconst trap = this.closest('focus-trap');\n\t\tconst trapStart = trap.querySelector('focus-trap-start');\n\t\ttrapStart.focus();\n\t};\n}\n\ncustomElements.define('focus-trap', FocusTrap);\ncustomElements.define('focus-trap-start', FocusTrapStart);\ncustomElements.define('focus-trap-end', FocusTrapEnd);\n//# sourceMappingURL=focus-trap.esm.js.map\n","import './index.scss';\nimport '@magic-spells/focus-trap';\n\n/**\n * Custom element that creates an accessible modal dialog panel with focus management\n * @extends HTMLElement\n */\nclass DialogPanel extends HTMLElement {\n\t#handleTransitionEnd;\n\t#scrollPosition = 0;\n\t\n\t/**\n\t * Clean up event listeners when component is removed from DOM\n\t */\n\tdisconnectedCallback() {\n\t\tconst _ = this;\n\t\tif (_.contentPanel) {\n\t\t\t_.contentPanel.removeEventListener('transitionend', _.#handleTransitionEnd);\n\t\t}\n\t\t\n\t\t// Ensure body scroll is restored if component is removed while open\n\t\tdocument.body.classList.remove('overflow-hidden');\n\t\tthis.#restoreScroll();\n\t}\n\t\n\t/**\n\t * Saves current scroll position and locks body scrolling\n\t * @private\n\t */\n\t#lockScroll() {\n\t\tconst _ = this;\n\t\t// Save current scroll position\n\t\t_.#scrollPosition = window.pageYOffset;\n\t\t\n\t\t// Apply fixed position to body\n\t\tdocument.body.classList.add('overflow-hidden');\n\t\tdocument.body.style.top = `-${_.#scrollPosition}px`;\n\t}\n\t\n\t/**\n\t * Restores scroll position when dialog is closed\n\t * @private\n\t */\n\t#restoreScroll() {\n\t\tconst _ = this;\n\t\t// Remove fixed positioning\n\t\tdocument.body.classList.remove('overflow-hidden');\n\t\tdocument.body.style.removeProperty('top');\n\t\t\n\t\t// Restore scroll position\n\t\twindow.scrollTo(0, _.#scrollPosition);\n\t}\n\t/**\n\t * Initializes the dialog panel, sets up focus trap and overlay\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tconst _ = this;\n\t\t_.id = _.getAttribute('id');\n\t\t_.setAttribute('role', 'dialog');\n\t\t_.setAttribute('aria-modal', 'true');\n\t\t_.setAttribute('aria-hidden', 'true');\n\n\t\t_.contentPanel = _.querySelector('dialog-content');\n\t\t_.focusTrap = document.createElement('focus-trap');\n\t\t_.triggerEl = null;\n\t\t\n\t\t// Create a handler for transition end events\n\t\t_.#handleTransitionEnd = (e) => {\n\t\t\tif (e.propertyName === 'opacity' && _.getAttribute('aria-hidden') === 'true') {\n\t\t\t\t_.contentPanel.classList.add('hidden');\n\t\t\t\t\n\t\t\t\t// Dispatch afterHide event - dialog has completed its transition\n\t\t\t\t_.dispatchEvent(new CustomEvent('afterHide', {\n\t\t\t\t\tbubbles: true,\n\t\t\t\t\tdetail: { triggerElement: _.triggerEl }\n\t\t\t\t}));\n\t\t\t}\n\t\t};\n\n\t\t// Ensure we have labelledby and describedby references\n\t\tif (!_.getAttribute('aria-labelledby')) {\n\t\t\tconst heading = _.querySelector('h1, h2, h3');\n\t\t\tif (heading && !heading.id) {\n\t\t\t\theading.id = `${_.id}-title`;\n\t\t\t}\n\t\t\tif (heading?.id) {\n\t\t\t\t_.setAttribute('aria-labelledby', heading.id);\n\t\t\t}\n\t\t}\n\n\t\t_.contentPanel.parentNode.insertBefore(\n\t\t\t_.focusTrap,\n\t\t\t_.contentPanel\n\t\t);\n\t\t_.focusTrap.appendChild(_.contentPanel);\n\n\t\t_.focusTrap.setupTrap();\n\n\t\t// Add modal overlay\n\t\t_.prepend(document.createElement('dialog-overlay'));\n\t\t_.#bindUI();\n\t\t_.#bindKeyboard();\n\t}\n\n\t/**\n\t * Binds click events for showing and hiding the dialog\n\t * @private\n\t */\n\t#bindUI() {\n\t\tconst _ = this;\n\t\t\n\t\t// Handle trigger buttons\n\t\tdocument.addEventListener('click', (e) => {\n\t\t\tconst trigger = e.target.closest(\n\t\t\t\t`[aria-controls=\"${_.id}\"]`\n\t\t\t);\n\t\t\tif (!trigger) return;\n\n\t\t\tif (trigger.getAttribute('data-prevent-default') === 'true') {\n\t\t\t\te.preventDefault();\n\t\t\t}\n\n\t\t\t_.show(trigger);\n\t\t});\n\n\t\t// Handle close buttons\n\t\t_.addEventListener('click', (e) => {\n\t\t\tif (!e.target.closest('[data-action=\"hide-dialog\"]')) return;\n\t\t\t_.hide();\n\t\t});\n\t\t\n\t\t// Add transition end listener\n\t\t_.contentPanel.addEventListener('transitionend', _.#handleTransitionEnd);\n\t}\n\n\t/**\n\t * Binds keyboard events for accessibility\n\t * @private\n\t */\n\t#bindKeyboard() {\n\t\tthis.addEventListener('keydown', (e) => {\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\tthis.hide();\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Shows the dialog and traps focus within it\n\t * @param {HTMLElement} [triggerEl=null] - The element that triggered the dialog\n\t * @fires DialogPanel#beforeShow - Fired before the dialog starts to show\n\t * @fires DialogPanel#show - Fired when the dialog has been shown\n\t * @returns {boolean} False if the show was prevented by a beforeShow event handler\n\t */\n\tshow(triggerEl = null) {\n\t\tconst _ = this;\n\t\t_.triggerEl = triggerEl || false;\n\n\t\t// Dispatch beforeShow event - allows preventing the dialog from opening\n\t\tconst beforeShowEvent = new CustomEvent('beforeShow', {\n\t\t\tbubbles: true,\n\t\t\tcancelable: true,\n\t\t\tdetail: { triggerElement: _.triggerEl }\n\t\t});\n\t\t\n\t\tconst showAllowed = _.dispatchEvent(beforeShowEvent);\n\t\t\n\t\t// If event was canceled (preventDefault was called), don't show the dialog\n\t\tif (!showAllowed) return false;\n\n\t\t// Remove the hidden class first to ensure content is rendered\n\t\t_.contentPanel.classList.remove('hidden');\n\t\t\n\t\t// Give the browser a moment to process before starting animation\n\t\trequestAnimationFrame(() => {\n\t\t\t// Update ARIA states\n\t\t\t_.setAttribute('aria-hidden', 'false');\n\t\t\tif (_.triggerEl) {\n\t\t\t\t_.triggerEl.setAttribute('aria-expanded', 'true');\n\t\t\t}\n\t\n\t\t\t// Lock body scrolling and save scroll position\n\t\t\t_.#lockScroll();\n\t\n\t\t\t// Focus management\n\t\t\tconst firstFocusable = _.querySelector(\n\t\t\t\t'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n\t\t\t);\n\t\t\tif (firstFocusable) {\n\t\t\t\trequestAnimationFrame(() => {\n\t\t\t\t\tfirstFocusable.focus();\n\t\t\t\t});\n\t\t\t}\n\t\t\t\n\t\t\t// Dispatch show event - dialog is now visible\n\t\t\t_.dispatchEvent(new CustomEvent('show', {\n\t\t\t\tbubbles: true,\n\t\t\t\tdetail: { triggerElement: _.triggerEl }\n\t\t\t}));\n\t\t});\n\t\t\n\t\treturn true;\n\t}\n\n\t/**\n\t * Hides the dialog and restores focus\n\t * @fires DialogPanel#beforeHide - Fired before the dialog starts to hide\n\t * @fires DialogPanel#hide - Fired when the dialog has started hiding (transition begins)\n\t * @fires DialogPanel#afterHide - Fired when the dialog has completed its hide transition\n\t * @returns {boolean} False if the hide was prevented by a beforeHide event handler\n\t */\n\thide() {\n\t\tconst _ = this;\n\t\t\n\t\t// Dispatch beforeHide event - allows preventing the dialog from closing\n\t\tconst beforeHideEvent = new CustomEvent('beforeHide', {\n\t\t\tbubbles: true,\n\t\t\tcancelable: true,\n\t\t\tdetail: { triggerElement: _.triggerEl }\n\t\t});\n\t\t\n\t\tconst hideAllowed = _.dispatchEvent(beforeHideEvent);\n\t\t\n\t\t// If event was canceled (preventDefault was called), don't hide the dialog\n\t\tif (!hideAllowed) return false;\n\t\t\n\t\t// Restore body scroll and scroll position\n\t\t_.#restoreScroll();\n\n\t\t// Update ARIA states\n\t\tif (_.triggerEl) {\n\t\t\t// remove focus from modal panel first\n\t\t\t_.triggerEl.focus();\n\t\t\t// mark trigger as no longer expanded\n\t\t\t_.triggerEl.setAttribute('aria-expanded', 'false');\n\t\t}\n\n\t\t// Set aria-hidden to start transition\n\t\t// The transitionend event handler will add display:none when complete\n\t\t_.setAttribute('aria-hidden', 'true');\n\t\t\n\t\t// Dispatch hide event - dialog is now starting to hide\n\t\t_.dispatchEvent(new CustomEvent('hide', {\n\t\t\tbubbles: true,\n\t\t\tdetail: { triggerElement: _.triggerEl }\n\t\t}));\n\t\t\n\t\treturn true;\n\t}\n}\n\n/**\n * Custom element that creates a clickable overlay for the dialog\n * @extends HTMLElement\n */\nclass DialogOverlay extends HTMLElement {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.setAttribute('tabindex', '-1'); // Changed to -1 as it shouldn't be focusable\n\t\tthis.setAttribute('aria-hidden', 'true');\n\t\tthis.dialogPanel = this.closest('dialog-panel');\n\t\tthis.#bindUI();\n\t}\n\n\t#bindUI() {\n\t\tthis.addEventListener('click', () => {\n\t\t\tthis.dialogPanel.hide();\n\t\t});\n\t}\n}\n\n/**\n * Custom element that wraps the content of the dialog\n * @extends HTMLElement\n */\nclass DialogContent extends HTMLElement {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.setAttribute('role', 'document'); // Optional: helps with document structure\n\t}\n}\n\ncustomElements.define('dialog-panel', DialogPanel);\ncustomElements.define('dialog-overlay', DialogOverlay);\ncustomElements.define('dialog-content', DialogContent);\n\nexport { DialogPanel, DialogOverlay, DialogContent };\nexport default DialogPanel;"],"names":[],"mappings":";;;;;;CAAA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM,oBAAoB,GAAG,CAAC,SAAS,KAAK;CAC5C,CAAC,MAAM,kBAAkB;CACzB,EAAE,gPAAgP,CAAC;CACnP,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACnE,CAAC,CAAC;AACF;CACA,MAAM,SAAS,SAAS,WAAW,CAAC;CACpC;CACA,CAAC,OAAO,aAAa,GAAG,KAAK,CAAC;AAC9B;CACA,CAAC,WAAW,GAAG;CACf,EAAE,KAAK,EAAE,CAAC;CACV,EAAE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;CACxB,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;AACtB;CACA;CACA,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;CAChC,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;CACvB,GAAG,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC;CAClC,GAAG;CACH,EAAE;AACF;CACA;CACA;CACA;CACA;CACA,CAAC,YAAY,GAAG;CAChB,EAAE,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;CAChD,EAAE,KAAK,CAAC,WAAW,GAAG,CAAC;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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CAAC;CACL,EAAE;CACF,CAAC;AACD;CACA;CACA;CACA;CACA;CACA,MAAM,aAAa,SAAS,WAAW,CAAC;CACxC,CAAC,WAAW,GAAG;CACf,EAAE,KAAK,EAAE,CAAC;CACV,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACxC,EAAE;CACF,CAAC;AACD;CACA,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;CACnD,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;CACvD,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC;;;;;;;;;;;;;","x_google_ignoreList":[0]}
@@ -1 +1 @@
1
- dialog-panel{position:fixed;z-index:10}dialog-overlay,dialog-panel{height:100vh;left:0;pointer-events:none;top:0;width:100vw}dialog-overlay{backdrop-filter:blur(2px) saturate(120%);background-color:rgba(20,23,26,.4);opacity:0;position:absolute;transition:all .3s ease-out}dialog-content{background:#fff;display:block;opacity:0}dialog-panel[aria-hidden=false]{pointer-events:all}dialog-panel[aria-hidden=false] dialog-overlay{filter:blur(0);opacity:1;pointer-events:all;transform:scale(1)}dialog-panel[aria-hidden=false] dialog-content{filter:blur(0);opacity:1;transform:scale(1);z-index:10}
1
+ :root{--dp-panel-top:0;--dp-panel-left:0;--dp-panel-width:100vw;--dp-panel-height:100vh;--dp-panel-z-index:10;--dp-overlay-z-index:1000;--dp-overlay-background:rgba(20,23,26,.4);--dp-overlay-backdrop-filter:blur(2px) saturate(120%);--dp-overlay-transition:all 400ms ease-out;--dp-content-display:block;--dp-content-background:#fff;--dp-content-z-index:1001;--dp-content-shadow:0 10px 25px rgba(0,0,0,.15);--dp-content-border-radius:8px;--dp-transition-duration:400ms;--dp-transition-timing:ease-out}dialog-panel{display:contents}dialog-panel[aria-hidden=false] dialog-content,dialog-panel[aria-hidden=false] dialog-overlay{filter:blur(0);opacity:1;pointer-events:auto;transform:scale(1)}dialog-overlay{backdrop-filter:var(--dp-overlay-backdrop-filter,blur(2px) saturate(120%));background-color:var(--dp-overlay-background,rgba(20,23,26,.4));height:100vh;left:0;top:0;transition:var(--dp-overlay-transition,all .3s ease-out);width:100vw;z-index:var(--dp-overlay-z-index,1000)}dialog-content,dialog-overlay{opacity:0;pointer-events:none;position:fixed}dialog-content{background:var(--dp-content-background,#fff);border-radius:var(--dp-content-border-radius,8px);box-shadow:var(--dp-content-shadow,0 10px 25px rgba(0,0,0,.15));display:var(--dp-content-display,block);left:50%;max-height:85vh;max-width:90vw;overflow:auto;top:50%;transform:translate(-50%,-50%) scale(.95);transition:opacity var(--dp-transition-duration,.3s) var(--dp-transition-timing,ease-out),transform var(--dp-transition-duration,.3s) var(--dp-transition-timing,ease-out);z-index:var(--dp-content-z-index,1001)}dialog-panel[aria-hidden=false] dialog-content{transform:translate(-50%,-50%) scale(1)}dialog-content.hidden{display:none}
@@ -1 +1 @@
1
- var DialogPanel=function(e){"use strict";const t=e=>Array.from(e.querySelectorAll('summary, a[href], button:not(:disabled), [tabindex]:not([tabindex^="-"]):not(focus-trap-start):not(focus-trap-end), [draggable], area, input:not([type=hidden]):not(:disabled), select:not(:disabled), textarea:not(:disabled), object, iframe'));class FocusTrap extends HTMLElement{static styleInjected=!1;constructor(){super(),this.trapStart=null,this.trapEnd=null,FocusTrap.styleInjected||(this.injectStyles(),FocusTrap.styleInjected=!0)}injectStyles(){const e=document.createElement("style");e.textContent="\n focus-trap-start,\n focus-trap-end {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n border: 0;\n clip: rect(0, 0, 0, 0);\n overflow: hidden;\n white-space: nowrap;\n }\n ",document.head.appendChild(e)}connectedCallback(){this.setupTrap(),this.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeyDown)}setupTrap(){0!==t(this).length&&(this.trapStart=document.createElement("focus-trap-start"),this.trapEnd=document.createElement("focus-trap-end"),this.prepend(this.trapStart),this.append(this.trapEnd))}handleKeyDown=e=>{"Escape"===e.key&&(e.preventDefault(),this.exitTrap())};exitTrap(){const e=this.closest('[aria-hidden="false"]');if(!e)return;e.setAttribute("aria-hidden","true");const t=document.querySelector(`[aria-expanded="true"][aria-controls="${e.id}"]`);t&&(t.setAttribute("aria-expanded","false"),t.focus())}}class FocusTrapStart extends HTMLElement{connectedCallback(){this.setAttribute("tabindex","0"),this.addEventListener("focus",this.handleFocus)}disconnectedCallback(){this.removeEventListener("focus",this.handleFocus)}handleFocus=e=>{const n=this.closest("focus-trap"),s=t(n);if(0===s.length)return;const a=s[0],i=s[s.length-1];e.relatedTarget===a?i.focus():a.focus()}}class FocusTrapEnd extends HTMLElement{connectedCallback(){this.setAttribute("tabindex","0"),this.addEventListener("focus",this.handleFocus)}disconnectedCallback(){this.removeEventListener("focus",this.handleFocus)}handleFocus=()=>{this.closest("focus-trap").querySelector("focus-trap-start").focus()}}customElements.define("focus-trap",FocusTrap),customElements.define("focus-trap-start",FocusTrapStart),customElements.define("focus-trap-end",FocusTrapEnd);class DialogPanel extends HTMLElement{constructor(){super();const e=this;if(e.id=e.getAttribute("id"),e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-hidden","true"),e.contentPanel=e.querySelector("dialog-content"),e.focusTrap=document.createElement("focus-trap"),e.triggerEl=null,!e.getAttribute("aria-labelledby")){const t=e.querySelector("h1, h2, h3");t&&!t.id&&(t.id=`${e.id}-title`),t?.id&&e.setAttribute("aria-labelledby",t.id)}e.contentPanel.parentNode.insertBefore(e.focusTrap,e.contentPanel),e.focusTrap.appendChild(e.contentPanel),e.focusTrap.setupTrap(),e.prepend(document.createElement("dialog-overlay")),e.#e(),e.#t()}#e(){document.addEventListener("click",(e=>{const t=e.target.closest(`[aria-controls="${this.id}"]`);t&&("true"===t.getAttribute("data-prevent-default")&&e.preventDefault(),this.show(t))})),this.addEventListener("click",(e=>{e.target.closest('[data-action="hide-dialog"]')&&this.hide()}))}#t(){this.addEventListener("keydown",(e=>{"Escape"===e.key&&this.hide()}))}show(e=null){this.triggerEl=e||!1,this.setAttribute("aria-hidden","false"),this.triggerEl&&this.triggerEl.setAttribute("aria-expanded","true"),document.body.classList.add("overflow-hidden");const t=this.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');t&&requestAnimationFrame((()=>{t.focus()}))}hide(){document.body.classList.remove("overflow-hidden"),this.triggerEl?(this.triggerEl.setAttribute("aria-expanded","false"),this.triggerEl.focus()):console.log("we need to blur focus"),setTimeout((()=>{this.setAttribute("aria-hidden","true")}),1)}}class DialogOverlay extends HTMLElement{constructor(){super(),this.setAttribute("tabindex","-1"),this.setAttribute("aria-hidden","true"),this.dialogPanel=this.closest("dialog-panel"),this.#e()}#e(){this.addEventListener("click",(()=>{this.dialogPanel.hide()}))}}class DialogContent extends HTMLElement{constructor(){super(),this.setAttribute("role","document")}}return customElements.define("dialog-panel",DialogPanel),customElements.define("dialog-overlay",DialogOverlay),customElements.define("dialog-content",DialogContent),e.DialogContent=DialogContent,e.DialogOverlay=DialogOverlay,e.DialogPanel=DialogPanel,e.default=DialogPanel,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).DialogPanel={})}(this,(function(e){"use strict";const t=e=>Array.from(e.querySelectorAll('summary, a[href], button:not(:disabled), [tabindex]:not([tabindex^="-"]):not(focus-trap-start):not(focus-trap-end), [draggable], area, input:not([type=hidden]):not(:disabled), select:not(:disabled), textarea:not(:disabled), object, iframe'));class FocusTrap extends HTMLElement{static styleInjected=!1;constructor(){super(),this.trapStart=null,this.trapEnd=null,FocusTrap.styleInjected||(this.injectStyles(),FocusTrap.styleInjected=!0)}injectStyles(){const e=document.createElement("style");e.textContent="\n focus-trap-start,\n focus-trap-end {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n border: 0;\n clip: rect(0, 0, 0, 0);\n overflow: hidden;\n white-space: nowrap;\n }\n ",document.head.appendChild(e)}connectedCallback(){this.setupTrap(),this.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeyDown)}setupTrap(){0!==t(this).length&&(this.trapStart=document.createElement("focus-trap-start"),this.trapEnd=document.createElement("focus-trap-end"),this.prepend(this.trapStart),this.append(this.trapEnd))}handleKeyDown=e=>{"Escape"===e.key&&(e.preventDefault(),this.exitTrap())};exitTrap(){const e=this.closest('[aria-hidden="false"]');if(!e)return;e.setAttribute("aria-hidden","true");const t=document.querySelector(`[aria-expanded="true"][aria-controls="${e.id}"]`);t&&(t.setAttribute("aria-expanded","false"),t.focus())}}class FocusTrapStart extends HTMLElement{connectedCallback(){this.setAttribute("tabindex","0"),this.addEventListener("focus",this.handleFocus)}disconnectedCallback(){this.removeEventListener("focus",this.handleFocus)}handleFocus=e=>{const n=this.closest("focus-trap"),s=t(n);if(0===s.length)return;const i=s[0],a=s[s.length-1];e.relatedTarget===i?a.focus():i.focus()}}class FocusTrapEnd extends HTMLElement{connectedCallback(){this.setAttribute("tabindex","0"),this.addEventListener("focus",this.handleFocus)}disconnectedCallback(){this.removeEventListener("focus",this.handleFocus)}handleFocus=()=>{this.closest("focus-trap").querySelector("focus-trap-start").focus()}}customElements.define("focus-trap",FocusTrap),customElements.define("focus-trap-start",FocusTrapStart),customElements.define("focus-trap-end",FocusTrapEnd);class DialogPanel extends HTMLElement{#e;#t=0;disconnectedCallback(){const e=this;e.contentPanel&&e.contentPanel.removeEventListener("transitionend",e.#e),document.body.classList.remove("overflow-hidden"),this.#n()}#s(){this.#t=window.pageYOffset,document.body.classList.add("overflow-hidden"),document.body.style.top=`-${this.#t}px`}#n(){document.body.classList.remove("overflow-hidden"),document.body.style.removeProperty("top"),window.scrollTo(0,this.#t)}constructor(){super();const e=this;if(e.id=e.getAttribute("id"),e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-hidden","true"),e.contentPanel=e.querySelector("dialog-content"),e.focusTrap=document.createElement("focus-trap"),e.triggerEl=null,e.#e=t=>{"opacity"===t.propertyName&&"true"===e.getAttribute("aria-hidden")&&(e.contentPanel.classList.add("hidden"),e.dispatchEvent(new CustomEvent("afterHide",{bubbles:!0,detail:{triggerElement:e.triggerEl}})))},!e.getAttribute("aria-labelledby")){const t=e.querySelector("h1, h2, h3");t&&!t.id&&(t.id=`${e.id}-title`),t?.id&&e.setAttribute("aria-labelledby",t.id)}e.contentPanel.parentNode.insertBefore(e.focusTrap,e.contentPanel),e.focusTrap.appendChild(e.contentPanel),e.focusTrap.setupTrap(),e.prepend(document.createElement("dialog-overlay")),e.#i(),e.#a()}#i(){const e=this;document.addEventListener("click",(t=>{const n=t.target.closest(`[aria-controls="${e.id}"]`);n&&("true"===n.getAttribute("data-prevent-default")&&t.preventDefault(),e.show(n))})),e.addEventListener("click",(t=>{t.target.closest('[data-action="hide-dialog"]')&&e.hide()})),e.contentPanel.addEventListener("transitionend",e.#e)}#a(){this.addEventListener("keydown",(e=>{"Escape"===e.key&&this.hide()}))}show(e=null){const t=this;t.triggerEl=e||!1;const n=new CustomEvent("beforeShow",{bubbles:!0,cancelable:!0,detail:{triggerElement:t.triggerEl}});return!!t.dispatchEvent(n)&&(t.contentPanel.classList.remove("hidden"),requestAnimationFrame((()=>{t.setAttribute("aria-hidden","false"),t.triggerEl&&t.triggerEl.setAttribute("aria-expanded","true"),t.#s();const e=t.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');e&&requestAnimationFrame((()=>{e.focus()})),t.dispatchEvent(new CustomEvent("show",{bubbles:!0,detail:{triggerElement:t.triggerEl}}))})),!0)}hide(){const e=this,t=new CustomEvent("beforeHide",{bubbles:!0,cancelable:!0,detail:{triggerElement:e.triggerEl}});return!!e.dispatchEvent(t)&&(e.#n(),e.triggerEl&&(e.triggerEl.focus(),e.triggerEl.setAttribute("aria-expanded","false")),e.setAttribute("aria-hidden","true"),e.dispatchEvent(new CustomEvent("hide",{bubbles:!0,detail:{triggerElement:e.triggerEl}})),!0)}}class DialogOverlay extends HTMLElement{constructor(){super(),this.setAttribute("tabindex","-1"),this.setAttribute("aria-hidden","true"),this.dialogPanel=this.closest("dialog-panel"),this.#i()}#i(){this.addEventListener("click",(()=>{this.dialogPanel.hide()}))}}class DialogContent extends HTMLElement{constructor(){super(),this.setAttribute("role","document")}}customElements.define("dialog-panel",DialogPanel),customElements.define("dialog-overlay",DialogOverlay),customElements.define("dialog-content",DialogContent),e.DialogContent=DialogContent,e.DialogOverlay=DialogOverlay,e.DialogPanel=DialogPanel,e.default=DialogPanel,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -0,0 +1,2 @@
1
+ @forward "scss/variables";
2
+ @forward "scss/dialog-panel";
@@ -0,0 +1,73 @@
1
+ // Import variables using the modern @use rule
2
+ @use 'variables' as vars;
3
+
4
+ dialog-panel {
5
+ /* Make it take no space and be invisible in the document flow */
6
+ display: contents;
7
+
8
+ &[aria-hidden='false'] {
9
+ dialog-overlay,
10
+ dialog-content {
11
+ pointer-events: auto;
12
+ opacity: 1;
13
+ transform: scale(1);
14
+ filter: blur(0px);
15
+ }
16
+ }
17
+ }
18
+
19
+ /* Overlay background */
20
+ dialog-overlay {
21
+ position: fixed;
22
+ top: 0;
23
+ left: 0;
24
+ width: 100vw;
25
+ height: 100vh;
26
+ opacity: 0;
27
+ pointer-events: none;
28
+ z-index: var(--dp-overlay-z-index, 1000);
29
+ transition: var(--dp-overlay-transition, all 300ms ease-out);
30
+ background-color: var(
31
+ --dp-overlay-background,
32
+ rgba(20, 23, 26, 0.4)
33
+ );
34
+ backdrop-filter: var(
35
+ --dp-overlay-backdrop-filter,
36
+ blur(2px) saturate(120%)
37
+ );
38
+ }
39
+
40
+ dialog-content {
41
+ position: fixed;
42
+ top: 50%;
43
+ left: 50%;
44
+ transform: translate(-50%, -50%) scale(0.95);
45
+ max-width: 90vw;
46
+ max-height: 85vh;
47
+ display: var(--dp-content-display, block);
48
+ opacity: 0;
49
+ background: var(--dp-content-background, white);
50
+ pointer-events: none;
51
+ z-index: var(--dp-content-z-index, 1001);
52
+ box-shadow: var(
53
+ --dp-content-shadow,
54
+ 0 10px 25px rgba(0, 0, 0, 0.15)
55
+ );
56
+ border-radius: var(--dp-content-border-radius, 8px);
57
+ overflow: auto;
58
+ transition:
59
+ opacity var(--dp-transition-duration, 300ms)
60
+ var(--dp-transition-timing, ease-out),
61
+ transform var(--dp-transition-duration, 300ms)
62
+ var(--dp-transition-timing, ease-out);
63
+
64
+ /* When shown, reset transform to center */
65
+ dialog-panel[aria-hidden='false'] & {
66
+ transform: translate(-50%, -50%) scale(1);
67
+ }
68
+
69
+ /* When explicitly hidden, remove from layout */
70
+ &.hidden {
71
+ display: none;
72
+ }
73
+ }