import { isPreventScrollSupported, modal_default } from "./chunk.EAHZ6VJU.js"; import { lockBodyScrolling, unlockBodyScrolling } from "./chunk.XAZN5AQ5.js"; import { animateTo, stopAnimations, waitForEvent } from "./chunk.CTCDC263.js"; import { getAnimation, setDefaultAnimation } from "./chunk.NC36RJW4.js"; import { hasSlot } from "./chunk.FMCX45AD.js"; import { l } from "./chunk.5MED2A3H.js"; import { event, watch } from "./chunk.XX234VRK.js"; import { e as e2 } from "./chunk.YXKHB4AC.js"; import { T, e, h, n, o, r, r2 } from "./chunk.5PIDMFOE.js"; import { __decorateClass } from "./chunk.IHGPZX35.js"; // _uyihdawu1:/Users/claviska/Projects/shoelace/src/components/dialog/dialog.scss var dialog_default = ":host {\n position: relative;\n box-sizing: border-box;\n}\n:host *, :host *:before, :host *:after {\n box-sizing: inherit;\n}\n\n[hidden] {\n display: none !important;\n}\n\n:host {\n --width: 31rem;\n --header-spacing: var(--sl-spacing-large);\n --body-spacing: var(--sl-spacing-large);\n --footer-spacing: var(--sl-spacing-large);\n display: contents;\n}\n\n.dialog {\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: var(--sl-z-index-dialog);\n}\n\n.dialog__panel {\n display: flex;\n flex-direction: column;\n z-index: 2;\n width: var(--width);\n max-width: calc(100% - var(--sl-spacing-xx-large));\n max-height: calc(100% - var(--sl-spacing-xx-large));\n background-color: var(--sl-panel-background-color);\n border-radius: var(--sl-border-radius-medium);\n box-shadow: var(--sl-shadow-x-large);\n}\n.dialog__panel:focus {\n outline: none;\n}\n\n@media screen and (max-width: 420px) {\n .dialog__panel {\n max-height: 80vh;\n }\n}\n.dialog--open .dialog__panel {\n display: flex;\n opacity: 1;\n transform: none;\n}\n\n.dialog__header {\n flex: 0 0 auto;\n display: flex;\n}\n\n.dialog__title {\n flex: 1 1 auto;\n font-size: var(--sl-font-size-large);\n line-height: var(--sl-line-height-dense);\n padding: var(--header-spacing);\n}\n\n.dialog__close {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n font-size: var(--sl-font-size-x-large);\n padding: 0 var(--header-spacing);\n}\n\n.dialog__body {\n flex: 1 1 auto;\n padding: var(--body-spacing);\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n}\n\n.dialog__footer {\n flex: 0 0 auto;\n text-align: right;\n padding: var(--footer-spacing);\n}\n.dialog__footer ::slotted(sl-button:not(:first-of-type)) {\n margin-left: var(--sl-spacing-x-small);\n}\n\n.dialog:not(.dialog--has-footer) .dialog__footer {\n display: none;\n}\n\n.dialog__overlay {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: var(--sl-overlay-background-color);\n}"; // src/components/dialog/dialog.ts var hasPreventScroll = isPreventScrollSupported(); var id = 0; var SlDialog = class extends h { constructor() { super(...arguments); this.componentId = `dialog-${++id}`; this.hasInitialized = false; this.hasFooter = false; this.open = false; this.label = ""; this.noHeader = false; } connectedCallback() { super.connectedCallback(); this.modal = new modal_default(this); this.handleSlotChange(); } firstUpdated() { this.dialog.hidden = !this.open; this.updateComplete.then(() => this.hasInitialized = true); } disconnectedCallback() { super.disconnectedCallback(); unlockBodyScrolling(this); } async show() { if (this.open) { return; } this.open = true; return waitForEvent(this, "sl-after-show"); } async hide() { if (!this.open) { return; } this.open = false; return waitForEvent(this, "sl-after-hide"); } handleCloseClick() { this.hide(); } handleKeyDown(event2) { if (event2.key === "Escape") { event2.stopPropagation(); this.hide(); } } async handleOpenChange() { if (!this.hasInitialized) { return; } if (this.open) { this.slShow.emit(); this.originalTrigger = document.activeElement; this.modal.activate(); lockBodyScrolling(this); await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]); this.dialog.hidden = false; if (hasPreventScroll) { const slInitialFocus = this.slInitialFocus.emit({ cancelable: true }); if (!slInitialFocus.defaultPrevented) { this.panel.focus({ preventScroll: true }); } } const panelAnimation = getAnimation(this, "dialog.show"); const overlayAnimation = getAnimation(this, "dialog.overlay.show"); await Promise.all([ animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options), animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options) ]); if (!hasPreventScroll) { const slInitialFocus = this.slInitialFocus.emit({ cancelable: true }); if (!slInitialFocus.defaultPrevented) { this.panel.focus({ preventScroll: true }); } } this.slAfterShow.emit(); } else { this.slHide.emit(); this.modal.deactivate(); await Promise.all([stopAnimations(this.dialog), stopAnimations(this.overlay)]); const panelAnimation = getAnimation(this, "dialog.hide"); const overlayAnimation = getAnimation(this, "dialog.overlay.hide"); await Promise.all([ animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options), animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options) ]); this.dialog.hidden = true; unlockBodyScrolling(this); const trigger = this.originalTrigger; if (trigger && typeof trigger.focus === "function") { setTimeout(() => trigger.focus()); } this.slAfterHide.emit(); } } handleOverlayClick() { const slOverlayDismiss = this.slOverlayDismiss.emit({ cancelable: true }); if (!slOverlayDismiss.defaultPrevented) { this.hide(); } } handleSlotChange() { this.hasFooter = hasSlot(this, "footer"); } render() { return T`