@redvars/peacock 3.14.0 → 3.15.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.
@@ -5799,7 +5799,9 @@
5799
5799
  "tag": "wc-modal",
5800
5800
  "rawTag": "modal",
5801
5801
  "summary": "A dialog/modal for displaying content in a layer above the page, with optional header, body, and footer slots.",
5802
+ "overview": "<p>The modal opens a native <code>&lt;dialog&gt;</code> with <code>showModal()</code>, so it renders in the\nbrowser's top layer: above sticky headers, app bars, cards and any stacking context on the page,\nwhatever their z-index. Menus, selects and tooltips opened inside the modal render above it.</p>",
5802
5803
  "cssprop": "--modal-max-height - Maximum height of the dialog.",
5804
+ "fires": "modal-close - Fired when the modal closes. `detail.reason` is `\"close-button\"`, `\"scrim\"`, `\"escape\"` or `\"programmatic\"`.",
5803
5805
  "example": "```html\nMODAL\n```",
5804
5806
  "tags": "overlay, dialog, feedback",
5805
5807
  "customElement": {
@@ -5836,7 +5838,8 @@
5836
5838
  "name": "modal-close",
5837
5839
  "type": {
5838
5840
  "text": "CustomEvent"
5839
- }
5841
+ },
5842
+ "description": "Fired when the modal closes. `detail.reason` is `\"close-button\"`, `\"scrim\"`, `\"escape\"` or `\"programmatic\"`."
5840
5843
  }
5841
5844
  ],
5842
5845
  "attributes": [
@@ -27386,20 +27386,35 @@
27386
27386
  },
27387
27387
  {
27388
27388
  "kind": "field",
27389
- "name": "_visible",
27389
+ "name": "_dialog",
27390
27390
  "type": {
27391
- "text": "boolean"
27391
+ "text": "HTMLDialogElement | undefined"
27392
27392
  },
27393
- "privacy": "private",
27394
- "default": "false"
27393
+ "privacy": "private"
27394
+ },
27395
+ {
27396
+ "kind": "field",
27397
+ "name": "_panel",
27398
+ "type": {
27399
+ "text": "HTMLElement | undefined"
27400
+ },
27401
+ "privacy": "private"
27395
27402
  },
27396
27403
  {
27397
27404
  "kind": "method",
27398
- "name": "show"
27405
+ "name": "show",
27406
+ "description": "Opens the modal."
27399
27407
  },
27400
27408
  {
27401
27409
  "kind": "method",
27402
- "name": "hide"
27410
+ "name": "hide",
27411
+ "description": "Closes the modal."
27412
+ },
27413
+ {
27414
+ "kind": "method",
27415
+ "name": "_syncDialog",
27416
+ "privacy": "private",
27417
+ "description": "Opens the native dialog in the top layer, or closes it once the exit animation ends."
27403
27418
  },
27404
27419
  {
27405
27420
  "kind": "method",
@@ -27416,32 +27431,47 @@
27416
27431
  },
27417
27432
  {
27418
27433
  "kind": "method",
27419
- "name": "_handleScrimClick",
27420
- "privacy": "private"
27434
+ "name": "_handleCancel",
27435
+ "privacy": "private",
27436
+ "parameters": [
27437
+ {
27438
+ "name": "event",
27439
+ "type": {
27440
+ "text": "Event"
27441
+ }
27442
+ }
27443
+ ],
27444
+ "description": "Escape: close through `open` so the property stays the source of truth."
27421
27445
  },
27422
27446
  {
27423
27447
  "kind": "method",
27424
- "name": "_handleCloseClick",
27425
- "privacy": "private"
27426
- },
27427
- {
27428
- "kind": "field",
27429
- "name": "_handleKeydown",
27448
+ "name": "_handleNativeClose",
27430
27449
  "privacy": "private",
27431
- "readonly": true
27450
+ "description": "The browser closed the dialog by itself (for example a forced Escape): keep `open` in step."
27432
27451
  },
27433
27452
  {
27434
27453
  "kind": "method",
27435
- "name": "_handleAnimationEnd",
27454
+ "name": "_handleDialogClick",
27436
27455
  "privacy": "private",
27437
27456
  "parameters": [
27438
27457
  {
27439
- "name": "e",
27458
+ "name": "event",
27440
27459
  "type": {
27441
- "text": "AnimationEvent"
27460
+ "text": "MouseEvent"
27442
27461
  }
27443
27462
  }
27444
- ]
27463
+ ],
27464
+ "description": "A click that lands outside the dialog container, not on its content, is a scrim click."
27465
+ },
27466
+ {
27467
+ "kind": "method",
27468
+ "name": "_handleCloseClick",
27469
+ "privacy": "private"
27470
+ },
27471
+ {
27472
+ "kind": "method",
27473
+ "name": "_renderHeader",
27474
+ "privacy": "private"
27445
27475
  }
27446
27476
  ],
27447
27477
  "events": [
@@ -27449,7 +27479,8 @@
27449
27479
  "name": "modal-close",
27450
27480
  "type": {
27451
27481
  "text": "CustomEvent"
27452
- }
27482
+ },
27483
+ "description": "Fired when the modal closes. `detail.reason` is `\"close-button\"`, `\"scrim\"`, `\"escape\"` or `\"programmatic\"`."
27453
27484
  }
27454
27485
  ],
27455
27486
  "attributes": [
package/dist/modal.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { i, _ as __decorate, I as IndividualComponent, a as i$1, A, b } from './IndividualComponent-Bdwyrvd6.js';
2
2
  import { n } from './property-B49QQ8pS.js';
3
- import { r } from './state-DkTK9EGF.js';
4
- import { e } from './class-map-DG7CA1et.js';
3
+ import { e } from './query-CHb9Ft_d.js';
4
+ import { e as e$1 } from './class-map-DG7CA1et.js';
5
+ import './base-Cl6v8-BZ.js';
5
6
  import './directive-ZPhl09Yt.js';
6
7
 
7
8
  var css_248z = i`@charset "UTF-8";
@@ -35,32 +36,52 @@ var css_248z = i`@charset "UTF-8";
35
36
  --modal-elevation: var(--elevation-level3);
36
37
  }
37
38
 
39
+ /*
40
+ * Native dialog opened with showModal(): it renders in the browser's top layer, so no page
41
+ * z-index or stacking context can draw above it. It covers the viewport and stays transparent;
42
+ * the scrim and the container below are drawn inside it, in DOM order, without z-index.
43
+ */
44
+ .native-dialog {
45
+ background: transparent;
46
+ block-size: 100%;
47
+ border: 0;
48
+ color: inherit;
49
+ inline-size: 100%;
50
+ inset: 0;
51
+ margin: 0;
52
+ max-block-size: none;
53
+ max-inline-size: none;
54
+ overflow: hidden;
55
+ padding: 0;
56
+ position: fixed;
57
+ }
58
+ .native-dialog::backdrop {
59
+ background: transparent;
60
+ }
61
+
38
62
  /* Scrim backdrop */
39
63
  .scrim {
40
64
  background-color: var(--modal-scrim-color);
41
65
  inset: 0;
42
66
  opacity: 0;
43
- pointer-events: none;
44
- position: fixed;
67
+ position: absolute;
45
68
  transition: opacity var(--modal-transition-duration) var(--modal-transition-easing);
46
- z-index: 1000;
47
69
  }
48
70
 
49
71
  .scrim.visible {
50
72
  opacity: 1;
51
- pointer-events: auto;
52
73
  }
53
74
 
54
- /* Dialog wrapper — centres the dialog on screen */
75
+ /* Dialog wrapper — centres the dialog on screen; a click on it (not the container) is a scrim click */
55
76
  .dialog-wrapper {
56
77
  align-items: center;
78
+ box-sizing: border-box;
57
79
  display: flex;
58
80
  inset: 0;
59
81
  justify-content: center;
60
82
  overflow-y: auto;
61
83
  padding: var(--spacing-400, 2rem) var(--spacing-200, 1rem);
62
- position: fixed;
63
- z-index: 1001;
84
+ position: absolute;
64
85
  }
65
86
 
66
87
  /* Dialog container */
@@ -72,16 +93,18 @@ var css_248z = i`@charset "UTF-8";
72
93
  flex-direction: column;
73
94
  max-height: var(--modal-max-height);
74
95
  max-width: var(--modal-max-width);
75
- min-width: var(--modal-min-width);
76
- opacity: 0;
96
+ min-width: min(var(--modal-min-width), 100%);
77
97
  outline: none;
78
98
  overflow: hidden;
79
99
  position: relative;
80
- transform: scale(0.9);
81
100
  width: 100%;
101
+ /*
102
+ * The open state keeps no transform: a transformed ancestor would become the containing
103
+ * block of fixed-position menus, selects and tooltips opened inside the modal.
104
+ */
82
105
  }
83
106
  .dialog.open {
84
- animation: modal-enter var(--modal-transition-duration) var(--modal-transition-easing) forwards;
107
+ animation: modal-enter var(--modal-transition-duration) var(--modal-transition-easing) backwards;
85
108
  }
86
109
  .dialog:not(.open) {
87
110
  animation: modal-exit var(--modal-transition-duration) var(--modal-transition-easing) forwards;
@@ -195,6 +218,15 @@ var css_248z = i`@charset "UTF-8";
195
218
  position: absolute;
196
219
  }
197
220
 
221
+ @media (prefers-reduced-motion: reduce) {
222
+ .scrim {
223
+ transition: none;
224
+ }
225
+ .dialog.open,
226
+ .dialog:not(.open) {
227
+ animation: none;
228
+ }
229
+ }
198
230
  /* Animations */
199
231
  @keyframes modal-enter {
200
232
  from {
@@ -222,6 +254,10 @@ var css_248z = i`@charset "UTF-8";
222
254
  * @tag wc-modal
223
255
  * @rawTag modal
224
256
  * @summary A dialog/modal for displaying content in a layer above the page, with optional header, body, and footer slots.
257
+ * @overview
258
+ * <p>The modal opens a native <code>&lt;dialog&gt;</code> with <code>showModal()</code>, so it renders in the
259
+ * browser's top layer: above sticky headers, app bars, cards and any stacking context on the page,
260
+ * whatever their z-index. Menus, selects and tooltips opened inside the modal render above it.</p>
225
261
  *
226
262
  * @cssprop --modal-container-color - Background color of the dialog container.
227
263
  * @cssprop --modal-scrim-color - Color of the scrim backdrop.
@@ -230,6 +266,8 @@ var css_248z = i`@charset "UTF-8";
230
266
  * @cssprop --modal-max-width - Maximum width of the dialog.
231
267
  * @cssprop --modal-max-height - Maximum height of the dialog.
232
268
  *
269
+ * @fires modal-close - Fired when the modal closes. `detail.reason` is `"close-button"`, `"scrim"`, `"escape"` or `"programmatic"`.
270
+ *
233
271
  * @example
234
272
  * ```html
235
273
  * MODAL
@@ -238,7 +276,9 @@ var css_248z = i`@charset "UTF-8";
238
276
  */
239
277
  let Modal = class Modal extends i$1 {
240
278
  constructor() {
279
+ // ── Static ───────────────────────────────────────────────────────────────
241
280
  super(...arguments);
281
+ // ── Properties ───────────────────────────────────────────────────────────
242
282
  /** Whether the modal is open. */
243
283
  this.open = false;
244
284
  /** Heading text shown in the modal header. */
@@ -260,19 +300,54 @@ let Modal = class Modal extends i$1 {
260
300
  this.showLoader = false;
261
301
  /** When true, clicking the scrim will not close the modal. */
262
302
  this.noScrimClose = false;
263
- this._visible = false;
264
- this._handleKeydown = (e) => {
265
- if (e.key === 'Escape') {
266
- this._close('escape');
267
- }
268
- };
269
303
  }
304
+ // ── Lifecycle ────────────────────────────────────────────────────────────
305
+ disconnectedCallback() {
306
+ super.disconnectedCallback();
307
+ document.body.style.overflow = '';
308
+ if (this._dialog?.open)
309
+ this._dialog.close();
310
+ }
311
+ updated(changedProperties) {
312
+ if (changedProperties.has('open'))
313
+ this._syncDialog();
314
+ }
315
+ // ── Public methods ───────────────────────────────────────────────────────
316
+ /** Opens the modal. */
270
317
  show() {
271
318
  this.open = true;
272
319
  }
320
+ /** Closes the modal. */
273
321
  hide() {
274
322
  this._close('programmatic');
275
323
  }
324
+ // ── Private methods ──────────────────────────────────────────────────────
325
+ /** Opens the native dialog in the top layer, or closes it once the exit animation ends. */
326
+ _syncDialog() {
327
+ const dialog = this._dialog;
328
+ if (!dialog)
329
+ return;
330
+ if (this.open) {
331
+ if (!dialog.open)
332
+ dialog.showModal();
333
+ document.body.style.overflow = 'hidden';
334
+ return;
335
+ }
336
+ document.body.style.overflow = '';
337
+ if (!dialog.open)
338
+ return;
339
+ const animations = this._panel?.getAnimations() ?? [];
340
+ if (animations.length === 0) {
341
+ dialog.close();
342
+ return;
343
+ }
344
+ Promise.all(animations.map(animation => animation.finished))
345
+ .catch(() => undefined)
346
+ .then(() => {
347
+ if (!this.open && dialog.open)
348
+ dialog.close();
349
+ });
350
+ }
276
351
  _close(reason) {
277
352
  if (!this.open)
278
353
  return;
@@ -283,105 +358,106 @@ let Modal = class Modal extends i$1 {
283
358
  composed: true,
284
359
  }));
285
360
  }
286
- _handleScrimClick() {
287
- if (!this.noScrimClose) {
361
+ /** Escape: close through `open` so the property stays the source of truth. */
362
+ _handleCancel(event) {
363
+ event.preventDefault();
364
+ this._close('escape');
365
+ }
366
+ /** The browser closed the dialog by itself (for example a forced Escape): keep `open` in step. */
367
+ _handleNativeClose() {
368
+ if (this.open)
369
+ this._close('escape');
370
+ }
371
+ /** A click that lands outside the dialog container, not on its content, is a scrim click. */
372
+ _handleDialogClick(event) {
373
+ const target = event.target;
374
+ if (!target.classList?.contains('dialog-wrapper'))
375
+ return;
376
+ if (!this.noScrimClose)
288
377
  this._close('scrim');
289
- }
290
378
  }
291
379
  _handleCloseClick() {
292
380
  this._close('close-button');
293
381
  }
294
- updated(changedProperties) {
295
- if (changedProperties.has('open')) {
296
- if (this.open) {
297
- this._visible = true;
298
- document.body.style.overflow = 'hidden';
299
- document.addEventListener('keydown', this._handleKeydown);
300
- }
301
- else {
302
- document.body.style.overflow = '';
303
- document.removeEventListener('keydown', this._handleKeydown);
304
- }
305
- }
306
- }
307
- disconnectedCallback() {
308
- super.disconnectedCallback();
309
- document.body.style.overflow = '';
310
- document.removeEventListener('keydown', this._handleKeydown);
311
- }
312
- _handleAnimationEnd(e) {
313
- if (e.animationName === 'modal-exit') {
314
- this._visible = false;
315
- }
382
+ // ── Render helpers ───────────────────────────────────────────────────────
383
+ _renderHeader() {
384
+ const hasHeader = this.heading || this.subheading || !this.hideClose;
385
+ if (!hasHeader)
386
+ return A;
387
+ return b `
388
+ <div class="dialog-header">
389
+ <div class="dialog-heading-section">
390
+ ${this.subheading
391
+ ? b `<p class="dialog-subheading">${this.subheading}</p>`
392
+ : A}
393
+ ${this.heading
394
+ ? b `<h2 id="modal-heading" class="dialog-heading">
395
+ ${this.heading}
396
+ </h2>`
397
+ : A}
398
+ </div>
399
+ ${!this.hideClose
400
+ ? b `<wc-icon-button
401
+ class="dialog-close"
402
+ variant="text"
403
+ aria-label="Close dialog"
404
+ @click=${this._handleCloseClick}
405
+ >
406
+ <wc-icon name="close"></wc-icon>
407
+ </wc-icon-button>`
408
+ : A}
409
+ </div>
410
+ `;
316
411
  }
412
+ // ── Render ───────────────────────────────────────────────────────────────
317
413
  render() {
318
- if (!this.open && !this._visible)
319
- return A;
320
- const hasHeader = this.heading || this.subheading || !this.hideClose;
414
+ // The scrim click has its keyboard equivalent in Escape, which the native dialog reports as
415
+ // `cancel`; lit-a11y does not count that as a key listener.
416
+ /* eslint-disable lit-a11y/click-events-have-key-events */
321
417
  return b `
322
- <div
323
- class=${e({ scrim: true, visible: this.open })}
324
- @click=${this._handleScrimClick}
325
- aria-hidden="true"
326
- ></div>
327
-
328
- <div class="dialog-wrapper" role="presentation">
418
+ <dialog
419
+ class="native-dialog"
420
+ part="dialog"
421
+ aria-labelledby=${this.heading ? 'modal-heading' : A}
422
+ @cancel=${this._handleCancel}
423
+ @close=${this._handleNativeClose}
424
+ @click=${this._handleDialogClick}
425
+ >
329
426
  <div
330
- class=${e({
427
+ class=${e$1({ scrim: true, visible: this.open })}
428
+ aria-hidden="true"
429
+ ></div>
430
+
431
+ <div class="dialog-wrapper">
432
+ <div
433
+ class=${e$1({
331
434
  dialog: true,
332
435
  open: this.open,
333
436
  [`size-${this.size}`]: true,
334
437
  'show-loader': this.showLoader,
335
438
  })}
336
- role="dialog"
337
- aria-modal="true"
338
- aria-labelledby=${this.heading ? 'modal-heading' : A}
339
- @animationend=${this._handleAnimationEnd}
340
- >
341
- ${hasHeader
342
- ? b `
343
- <div class="dialog-header">
344
- <div class="dialog-heading-section">
345
- ${this.subheading
346
- ? b `<p class="dialog-subheading">${this.subheading}</p>`
347
- : A}
348
- ${this.heading
349
- ? b `<h2 id="modal-heading" class="dialog-heading">
350
- ${this.heading}
351
- </h2>`
352
- : A}
353
- </div>
354
- ${!this.hideClose
355
- ? b `<wc-icon-button
356
- class="dialog-close"
357
- variant="text"
358
- aria-label="Close dialog"
359
- @click=${this._handleCloseClick}
360
- >
361
- <wc-icon name="close"></wc-icon>
362
- </wc-icon-button>`
363
- : A}
364
- </div>
365
- `
366
- : A}
439
+ >
440
+ ${this._renderHeader()}
367
441
 
368
- <div class="dialog-content">
369
- <slot></slot>
370
- </div>
442
+ <div class="dialog-content">
443
+ <slot></slot>
444
+ </div>
371
445
 
372
- <div class="dialog-footer">
373
- <slot name="footer"></slot>
374
- </div>
446
+ <div class="dialog-footer">
447
+ <slot name="footer"></slot>
448
+ </div>
375
449
 
376
- ${this.showLoader
450
+ ${this.showLoader
377
451
  ? b `<div class="dialog-loader" aria-hidden="true">
378
- <div class="dialog-loader-scrim"></div>
379
- <wc-spinner></wc-spinner>
380
- </div>`
452
+ <div class="dialog-loader-scrim"></div>
453
+ <wc-spinner></wc-spinner>
454
+ </div>`
381
455
  : A}
456
+ </div>
382
457
  </div>
383
- </div>
458
+ </dialog>
384
459
  `;
460
+ /* eslint-enable lit-a11y/click-events-have-key-events */
385
461
  }
386
462
  };
387
463
  Modal.styles = [css_248z];
@@ -407,8 +483,11 @@ __decorate([
407
483
  n({ type: Boolean, attribute: 'no-scrim-close' })
408
484
  ], Modal.prototype, "noScrimClose", void 0);
409
485
  __decorate([
410
- r()
411
- ], Modal.prototype, "_visible", void 0);
486
+ e('dialog')
487
+ ], Modal.prototype, "_dialog", void 0);
488
+ __decorate([
489
+ e('.dialog')
490
+ ], Modal.prototype, "_panel", void 0);
412
491
  Modal = __decorate([
413
492
  IndividualComponent
414
493
  ], Modal);
package/dist/modal.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"modal.js","sources":["../../src/modal/modal.ts"],"sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport IndividualComponent from '../IndividualComponent.js';\nimport styles from './modal.scss';\n\ntype ModalSize = 'xs' | 'sm' | 'md' | 'lg' | 'fullscreen';\n\n/**\n * @label Modal\n * @tag wc-modal\n * @rawTag modal\n * @summary A dialog/modal for displaying content in a layer above the page, with optional header, body, and footer slots.\n *\n * @cssprop --modal-container-color - Background color of the dialog container.\n * @cssprop --modal-scrim-color - Color of the scrim backdrop.\n * @cssprop --modal-shape - Corner radius of the dialog container.\n * @cssprop --modal-min-width - Minimum width of the dialog.\n * @cssprop --modal-max-width - Maximum width of the dialog.\n * @cssprop --modal-max-height - Maximum height of the dialog.\n *\n * @example\n * ```html\n * MODAL\n * ```\n * @tags overlay, dialog, feedback\n */\n@IndividualComponent\nexport class Modal extends LitElement {\n static styles = [styles];\n\n /** Whether the modal is open. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Heading text shown in the modal header. */\n @property({ type: String, reflect: true }) heading = '';\n\n /** Optional subheading / label text shown above the heading. */\n @property({ type: String, reflect: true }) subheading = '';\n\n /**\n * Size of the modal dialog.\n * - `\"xs\"`: Extra-small.\n * - `\"sm\"`: Small.\n * - `\"md\"`: Medium (default).\n * - `\"lg\"`: Large.\n * - `\"fullscreen\"`: Full-screen dialog.\n */\n @property({ type: String, reflect: true }) size: ModalSize = 'md';\n\n /** When true, hides the close button in the header. */\n @property({ type: Boolean, reflect: true, attribute: 'hide-close' })\n hideClose = false;\n\n /** When true, renders a loading overlay inside the modal. */\n @property({ type: Boolean, reflect: true, attribute: 'show-loader' })\n showLoader = false;\n\n /** When true, clicking the scrim will not close the modal. */\n @property({ type: Boolean, attribute: 'no-scrim-close' }) noScrimClose = false;\n\n @state() private _visible = false;\n\n show() {\n this.open = true;\n }\n\n hide() {\n this._close('programmatic');\n }\n\n private _close(reason: string) {\n if (!this.open) return;\n this.open = false;\n this.dispatchEvent(\n new CustomEvent('modal-close', {\n detail: { reason },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _handleScrimClick() {\n if (!this.noScrimClose) {\n this._close('scrim');\n }\n }\n\n private _handleCloseClick() {\n this._close('close-button');\n }\n\n private readonly _handleKeydown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n this._close('escape');\n }\n };\n\n protected updated(changedProperties: Map<string, unknown>) {\n if (changedProperties.has('open')) {\n if (this.open) {\n this._visible = true;\n document.body.style.overflow = 'hidden';\n document.addEventListener('keydown', this._handleKeydown);\n } else {\n document.body.style.overflow = '';\n document.removeEventListener('keydown', this._handleKeydown);\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n document.body.style.overflow = '';\n document.removeEventListener('keydown', this._handleKeydown);\n }\n\n private _handleAnimationEnd(e: AnimationEvent) {\n if (e.animationName === 'modal-exit') {\n this._visible = false;\n }\n }\n\n render() {\n if (!this.open && !this._visible) return nothing;\n\n const hasHeader = this.heading || this.subheading || !this.hideClose;\n\n return html`\n <div\n class=${classMap({ scrim: true, visible: this.open })}\n @click=${this._handleScrimClick}\n aria-hidden=\"true\"\n ></div>\n\n <div class=\"dialog-wrapper\" role=\"presentation\">\n <div\n class=${classMap({\n dialog: true,\n open: this.open,\n [`size-${this.size}`]: true,\n 'show-loader': this.showLoader,\n })}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby=${this.heading ? 'modal-heading' : nothing}\n @animationend=${this._handleAnimationEnd}\n >\n ${hasHeader\n ? html`\n <div class=\"dialog-header\">\n <div class=\"dialog-heading-section\">\n ${this.subheading\n ? html`<p class=\"dialog-subheading\">${this.subheading}</p>`\n : nothing}\n ${this.heading\n ? html`<h2 id=\"modal-heading\" class=\"dialog-heading\">\n ${this.heading}\n </h2>`\n : nothing}\n </div>\n ${!this.hideClose\n ? html`<wc-icon-button\n class=\"dialog-close\"\n variant=\"text\"\n aria-label=\"Close dialog\"\n @click=${this._handleCloseClick}\n >\n <wc-icon name=\"close\"></wc-icon>\n </wc-icon-button>`\n : nothing}\n </div>\n `\n : nothing}\n\n <div class=\"dialog-content\">\n <slot></slot>\n </div>\n\n <div class=\"dialog-footer\">\n <slot name=\"footer\"></slot>\n </div>\n\n ${this.showLoader\n ? html`<div class=\"dialog-loader\" aria-hidden=\"true\">\n <div class=\"dialog-loader-scrim\"></div>\n <wc-spinner></wc-spinner>\n </div>`\n : nothing}\n </div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","nothing","html","classMap","styles","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;;;AAkBG;AAEI,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQA,GAAU,CAAA;AAA9B,IAAA,WAAA,GAAA;;;QAIuC,IAAA,CAAA,IAAI,GAAG,KAAK;;QAGb,IAAA,CAAA,OAAO,GAAG,EAAE;;QAGZ,IAAA,CAAA,UAAU,GAAG,EAAE;AAE1D;;;;;;;AAOG;QACwC,IAAA,CAAA,IAAI,GAAc,IAAI;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,IAAI,EAAE;AAAyB,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAIlE,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE;AACjD,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAIlB,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE;AACjD,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AAGuC,UAAA,CAAA;IAAzDA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE;AAAuB,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAE9D,UAAA,CAAA;AAAhB,IAAAC,CAAK;AAA4B,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAjCvB,KAAK,GAAA,UAAA,CAAA;IADjB;AACY,CAAA,EAAA,KAAK,CAsKjB;;;;"}
1
+ {"version":3,"file":"modal.js","sources":["../../src/modal/modal.ts"],"sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport IndividualComponent from '../IndividualComponent.js';\nimport styles from './modal.scss';\n\ntype ModalSize = 'xs' | 'sm' | 'md' | 'lg' | 'fullscreen';\n\n/**\n * @label Modal\n * @tag wc-modal\n * @rawTag modal\n * @summary A dialog/modal for displaying content in a layer above the page, with optional header, body, and footer slots.\n * @overview\n * <p>The modal opens a native <code>&lt;dialog&gt;</code> with <code>showModal()</code>, so it renders in the\n * browser's top layer: above sticky headers, app bars, cards and any stacking context on the page,\n * whatever their z-index. Menus, selects and tooltips opened inside the modal render above it.</p>\n *\n * @cssprop --modal-container-color - Background color of the dialog container.\n * @cssprop --modal-scrim-color - Color of the scrim backdrop.\n * @cssprop --modal-shape - Corner radius of the dialog container.\n * @cssprop --modal-min-width - Minimum width of the dialog.\n * @cssprop --modal-max-width - Maximum width of the dialog.\n * @cssprop --modal-max-height - Maximum height of the dialog.\n *\n * @fires modal-close - Fired when the modal closes. `detail.reason` is `\"close-button\"`, `\"scrim\"`, `\"escape\"` or `\"programmatic\"`.\n *\n * @example\n * ```html\n * MODAL\n * ```\n * @tags overlay, dialog, feedback\n */\n@IndividualComponent\nexport class Modal extends LitElement {\n // ── Static ───────────────────────────────────────────────────────────────\n\n static styles = [styles];\n\n // ── Properties ───────────────────────────────────────────────────────────\n\n /** Whether the modal is open. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Heading text shown in the modal header. */\n @property({ type: String, reflect: true }) heading = '';\n\n /** Optional subheading / label text shown above the heading. */\n @property({ type: String, reflect: true }) subheading = '';\n\n /**\n * Size of the modal dialog.\n * - `\"xs\"`: Extra-small.\n * - `\"sm\"`: Small.\n * - `\"md\"`: Medium (default).\n * - `\"lg\"`: Large.\n * - `\"fullscreen\"`: Full-screen dialog.\n */\n @property({ type: String, reflect: true }) size: ModalSize = 'md';\n\n /** When true, hides the close button in the header. */\n @property({ type: Boolean, reflect: true, attribute: 'hide-close' })\n hideClose = false;\n\n /** When true, renders a loading overlay inside the modal. */\n @property({ type: Boolean, reflect: true, attribute: 'show-loader' })\n showLoader = false;\n\n /** When true, clicking the scrim will not close the modal. */\n @property({ type: Boolean, attribute: 'no-scrim-close' }) noScrimClose =\n false;\n\n // ── Queries ──────────────────────────────────────────────────────────────\n\n @query('dialog') private _dialog?: HTMLDialogElement;\n\n @query('.dialog') private _panel?: HTMLElement;\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n disconnectedCallback() {\n super.disconnectedCallback();\n document.body.style.overflow = '';\n if (this._dialog?.open) this._dialog.close();\n }\n\n protected updated(changedProperties: Map<string, unknown>) {\n if (changedProperties.has('open')) this._syncDialog();\n }\n\n // ── Public methods ───────────────────────────────────────────────────────\n\n /** Opens the modal. */\n show() {\n this.open = true;\n }\n\n /** Closes the modal. */\n hide() {\n this._close('programmatic');\n }\n\n // ── Private methods ──────────────────────────────────────────────────────\n\n /** Opens the native dialog in the top layer, or closes it once the exit animation ends. */\n private _syncDialog() {\n const dialog = this._dialog;\n if (!dialog) return;\n\n if (this.open) {\n if (!dialog.open) dialog.showModal();\n document.body.style.overflow = 'hidden';\n return;\n }\n\n document.body.style.overflow = '';\n if (!dialog.open) return;\n const animations = this._panel?.getAnimations() ?? [];\n if (animations.length === 0) {\n dialog.close();\n return;\n }\n Promise.all(animations.map(animation => animation.finished))\n .catch(() => undefined)\n .then(() => {\n if (!this.open && dialog.open) dialog.close();\n });\n }\n\n private _close(reason: string) {\n if (!this.open) return;\n this.open = false;\n this.dispatchEvent(\n new CustomEvent('modal-close', {\n detail: { reason },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n /** Escape: close through `open` so the property stays the source of truth. */\n private _handleCancel(event: Event) {\n event.preventDefault();\n this._close('escape');\n }\n\n /** The browser closed the dialog by itself (for example a forced Escape): keep `open` in step. */\n private _handleNativeClose() {\n if (this.open) this._close('escape');\n }\n\n /** A click that lands outside the dialog container, not on its content, is a scrim click. */\n private _handleDialogClick(event: MouseEvent) {\n const target = event.target as Element;\n if (!target.classList?.contains('dialog-wrapper')) return;\n if (!this.noScrimClose) this._close('scrim');\n }\n\n private _handleCloseClick() {\n this._close('close-button');\n }\n\n // ── Render helpers ───────────────────────────────────────────────────────\n\n private _renderHeader() {\n const hasHeader = this.heading || this.subheading || !this.hideClose;\n if (!hasHeader) return nothing;\n\n return html`\n <div class=\"dialog-header\">\n <div class=\"dialog-heading-section\">\n ${this.subheading\n ? html`<p class=\"dialog-subheading\">${this.subheading}</p>`\n : nothing}\n ${this.heading\n ? html`<h2 id=\"modal-heading\" class=\"dialog-heading\">\n ${this.heading}\n </h2>`\n : nothing}\n </div>\n ${!this.hideClose\n ? html`<wc-icon-button\n class=\"dialog-close\"\n variant=\"text\"\n aria-label=\"Close dialog\"\n @click=${this._handleCloseClick}\n >\n <wc-icon name=\"close\"></wc-icon>\n </wc-icon-button>`\n : nothing}\n </div>\n `;\n }\n\n // ── Render ───────────────────────────────────────────────────────────────\n\n render() {\n // The scrim click has its keyboard equivalent in Escape, which the native dialog reports as\n // `cancel`; lit-a11y does not count that as a key listener.\n /* eslint-disable lit-a11y/click-events-have-key-events */\n return html`\n <dialog\n class=\"native-dialog\"\n part=\"dialog\"\n aria-labelledby=${this.heading ? 'modal-heading' : nothing}\n @cancel=${this._handleCancel}\n @close=${this._handleNativeClose}\n @click=${this._handleDialogClick}\n >\n <div\n class=${classMap({ scrim: true, visible: this.open })}\n aria-hidden=\"true\"\n ></div>\n\n <div class=\"dialog-wrapper\">\n <div\n class=${classMap({\n dialog: true,\n open: this.open,\n [`size-${this.size}`]: true,\n 'show-loader': this.showLoader,\n })}\n >\n ${this._renderHeader()}\n\n <div class=\"dialog-content\">\n <slot></slot>\n </div>\n\n <div class=\"dialog-footer\">\n <slot name=\"footer\"></slot>\n </div>\n\n ${this.showLoader\n ? html`<div class=\"dialog-loader\" aria-hidden=\"true\">\n <div class=\"dialog-loader-scrim\"></div>\n <wc-spinner></wc-spinner>\n </div>`\n : nothing}\n </div>\n </div>\n </dialog>\n `;\n /* eslint-enable lit-a11y/click-events-have-key-events */\n }\n}\n"],"names":["LitElement","nothing","html","classMap","styles","property","query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE;AACjD,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AAGuC,UAAA,CAAA;IAAzDA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE;AAChD,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAIiB,UAAA,CAAA;IAAxBC,CAAK,CAAC,QAAQ;AAAsC,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAE3B,UAAA,CAAA;IAAzBA,CAAK,CAAC,SAAS;AAA+B,CAAA,EAAA,KAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AA1CpC,KAAK,GAAA,UAAA,CAAA;IADjB;AACY,CAAA,EAAA,KAAK,CAoNjB;;;;"}
@@ -1,10 +1,14 @@
1
- import { LitElement, nothing } from 'lit';
1
+ import { LitElement } from 'lit';
2
2
  type ModalSize = 'xs' | 'sm' | 'md' | 'lg' | 'fullscreen';
3
3
  /**
4
4
  * @label Modal
5
5
  * @tag wc-modal
6
6
  * @rawTag modal
7
7
  * @summary A dialog/modal for displaying content in a layer above the page, with optional header, body, and footer slots.
8
+ * @overview
9
+ * <p>The modal opens a native <code>&lt;dialog&gt;</code> with <code>showModal()</code>, so it renders in the
10
+ * browser's top layer: above sticky headers, app bars, cards and any stacking context on the page,
11
+ * whatever their z-index. Menus, selects and tooltips opened inside the modal render above it.</p>
8
12
  *
9
13
  * @cssprop --modal-container-color - Background color of the dialog container.
10
14
  * @cssprop --modal-scrim-color - Color of the scrim backdrop.
@@ -13,6 +17,8 @@ type ModalSize = 'xs' | 'sm' | 'md' | 'lg' | 'fullscreen';
13
17
  * @cssprop --modal-max-width - Maximum width of the dialog.
14
18
  * @cssprop --modal-max-height - Maximum height of the dialog.
15
19
  *
20
+ * @fires modal-close - Fired when the modal closes. `detail.reason` is `"close-button"`, `"scrim"`, `"escape"` or `"programmatic"`.
21
+ *
16
22
  * @example
17
23
  * ```html
18
24
  * MODAL
@@ -42,16 +48,25 @@ export declare class Modal extends LitElement {
42
48
  showLoader: boolean;
43
49
  /** When true, clicking the scrim will not close the modal. */
44
50
  noScrimClose: boolean;
45
- private _visible;
51
+ private _dialog?;
52
+ private _panel?;
53
+ disconnectedCallback(): void;
54
+ protected updated(changedProperties: Map<string, unknown>): void;
55
+ /** Opens the modal. */
46
56
  show(): void;
57
+ /** Closes the modal. */
47
58
  hide(): void;
59
+ /** Opens the native dialog in the top layer, or closes it once the exit animation ends. */
60
+ private _syncDialog;
48
61
  private _close;
49
- private _handleScrimClick;
62
+ /** Escape: close through `open` so the property stays the source of truth. */
63
+ private _handleCancel;
64
+ /** The browser closed the dialog by itself (for example a forced Escape): keep `open` in step. */
65
+ private _handleNativeClose;
66
+ /** A click that lands outside the dialog container, not on its content, is a scrim click. */
67
+ private _handleDialogClick;
50
68
  private _handleCloseClick;
51
- private readonly _handleKeydown;
52
- protected updated(changedProperties: Map<string, unknown>): void;
53
- disconnectedCallback(): void;
54
- private _handleAnimationEnd;
55
- render(): typeof nothing | import("lit-html").TemplateResult<1>;
69
+ private _renderHeader;
70
+ render(): import("lit-html").TemplateResult<1>;
56
71
  }
57
72
  export {};
@@ -0,0 +1 @@
1
+ export {};