@digital-realty/ix-dialog 1.2.20 → 1.3.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.
- package/dist/IxDialog.d.ts +2 -0
- package/dist/IxDialog.js +20 -2
- package/dist/IxDialog.js.map +1 -1
- package/dist/internal/dialog.js +0 -2
- package/dist/internal/dialog.js.map +1 -1
- package/dist/ix-dialog.min.js +496 -34
- package/package.json +11 -17
package/dist/IxDialog.d.ts
CHANGED
|
@@ -33,8 +33,10 @@ export declare class IxDialog extends ixDialogBaseClass {
|
|
|
33
33
|
private removeScrollHandlers?;
|
|
34
34
|
private nativeOnEnd?;
|
|
35
35
|
private mo?;
|
|
36
|
+
private get forwardedAriaAttributes();
|
|
36
37
|
private get nativeDialog();
|
|
37
38
|
private get nativeDialogContainer();
|
|
39
|
+
private get hasPortalHeadline();
|
|
38
40
|
connectedCallback(): void;
|
|
39
41
|
disconnectedCallback(): void;
|
|
40
42
|
updated(changed: Map<string, unknown>): void;
|
package/dist/IxDialog.js
CHANGED
|
@@ -60,6 +60,15 @@ export class IxDialog extends ixDialogBaseClass {
|
|
|
60
60
|
this.requestClose();
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
get forwardedAriaAttributes() {
|
|
64
|
+
const ariaAttributes = { ...this.ariaAttributes };
|
|
65
|
+
for (const attr of Array.from(this.attributes)) {
|
|
66
|
+
if (attr.name.startsWith('aria-')) {
|
|
67
|
+
ariaAttributes[attr.name] = attr.value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return ariaAttributes;
|
|
71
|
+
}
|
|
63
72
|
get nativeDialog() {
|
|
64
73
|
var _a;
|
|
65
74
|
return (_a = this.dialogRef.value) !== null && _a !== void 0 ? _a : null;
|
|
@@ -68,6 +77,9 @@ export class IxDialog extends ixDialogBaseClass {
|
|
|
68
77
|
var _a;
|
|
69
78
|
return (_a = this.containerRef.value) !== null && _a !== void 0 ? _a : null;
|
|
70
79
|
}
|
|
80
|
+
get hasPortalHeadline() {
|
|
81
|
+
return Array.from(this.children).some(child => child instanceof HTMLElement && child.slot === 'headline');
|
|
82
|
+
}
|
|
71
83
|
connectedCallback() {
|
|
72
84
|
super.connectedCallback();
|
|
73
85
|
this.mo = new MutationObserver(() => {
|
|
@@ -374,6 +386,7 @@ export class IxDialog extends ixDialogBaseClass {
|
|
|
374
386
|
this.dispatchEvent(new Event('cancel', { bubbles: true, composed: true }));
|
|
375
387
|
}
|
|
376
388
|
portalTemplate() {
|
|
389
|
+
const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, ...portalAriaAttributes } = this.forwardedAriaAttributes;
|
|
377
390
|
return html `
|
|
378
391
|
<dialog
|
|
379
392
|
${ref(this.dialogRef)}
|
|
@@ -391,8 +404,13 @@ export class IxDialog extends ixDialogBaseClass {
|
|
|
391
404
|
${ref(this.containerRef)}
|
|
392
405
|
role="dialog"
|
|
393
406
|
aria-modal="true"
|
|
407
|
+
aria-label=${ariaLabel || nothing}
|
|
408
|
+
aria-labelledby=${ariaLabel
|
|
409
|
+
? nothing
|
|
410
|
+
: ariaLabelledBy || (this.hasPortalHeadline ? 'headline' : nothing)}
|
|
411
|
+
${spread(portalAriaAttributes)}
|
|
394
412
|
>
|
|
395
|
-
<div class="headline"></div>
|
|
413
|
+
<div class="headline" id="headline"></div>
|
|
396
414
|
<div class="content"></div>
|
|
397
415
|
<div class="actions"></div>
|
|
398
416
|
</div>
|
|
@@ -410,7 +428,7 @@ export class IxDialog extends ixDialogBaseClass {
|
|
|
410
428
|
?preventCloseOnScrimClick=${this.preventCloseOnScrimClick}
|
|
411
429
|
?disableNextClickIsFromContent=${this.disableNextClickIsFromContent}
|
|
412
430
|
?allowOverflow=${this.allowOverflow}
|
|
413
|
-
${spread(this.
|
|
431
|
+
${spread(this.forwardedAriaAttributes)}
|
|
414
432
|
@open=${this.onOpen}
|
|
415
433
|
@opened=${this.onOpened}
|
|
416
434
|
@close=${this.onClose}
|
package/d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ementInternals } from '@material/web/labs/behaviors/element-internals.js';\nimport { AriaForwardMixin } from '@digital-realty/ix-shared-fns/aria-forward-mixin.js';\nimport { spread } from '@open-wc/lit-helpers';\nimport { css, CSSResultGroup, html, LitElement, nothing, render } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { createRef, ref, Ref } from 'lit/directives/ref.js';\nimport { Dialog } from './internal/dialog.js';\nimport { IxDialogStyles } from './ix-dialog-styles.js';\nimport './md-dialog.js';\n\nconst ixDialogBaseClass = AriaForwardMixin(mixinElementInternals(LitElement));\n\nexport class IxDialog extends ixDialogBaseClass {\n /** @nocollapse */\n static styles: CSSResultGroup = [\n IxDialogStyles,\n css`\n :host([use-native-dialog]) dialog[open],\n :host([use-native-dialog][closing]) dialog {\n position: fixed;\n inset: 0;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n display: block;\n inline-size: 100vw;\n block-size: 100dvh;\n pointer-events: none;\n z-index: 99;\n overscroll-behavior: contain;\n }\n\n :host([use-native-dialog]) dialog[open] .scrim,\n :host([use-native-dialog][closing]) .scrim,\n :host([use-native-dialog]) dialog[open] > .container,\n :host([use-native-dialog][closing]) dialog > .container {\n pointer-events: auto;\n }\n\n :host([use-native-dialog]) dialog[open] .scrim,\n :host([use-native-dialog][closing]) .scrim {\n position: fixed;\n inset: 0;\n background: var(--ix-dialog-scrim, rgba(0, 0, 0, 0.32));\n }\n\n :host([use-native-dialog]) dialog[open] .scrim {\n overscroll-behavior: contain;\n touch-action: none;\n }\n\n :host([use-native-dialog]) dialog[open] > .container,\n :host([use-native-dialog][closing]) dialog > .container {\n transform: translate(-50%, -50%);\n width: auto;\n height: auto;\n max-block-size: var(--ix-dialog-max-height, 90dvh);\n border-radius: 0.75rem;\n background: var(--ix-dialog-bg, #fff);\n box-shadow: var(\n --ix-dialog-shadow,\n 0 0.625rem 1.875rem rgba(0, 0, 0, 0.25)\n );\n display: grid;\n grid-template-rows: auto 1fr auto;\n overflow: hidden;\n z-index: 9;\n transform-origin: top center;\n will-change: transform, opacity;\n }\n\n :host([use-native-dialog]) .headline,\n :host([use-native-dialog]) .content,\n :host([use-native-dialog]) .actions {\n padding: var(--ix-dialog-section-padding, 1rem);\n }\n\n :host([use-native-dialog]) .content {\n overflow: auto;\n }\n\n :host([use-native-dialog]) .actions {\n display: inline-flex;\n gap: var(--ix-dialog-actions-gap, 0.5rem);\n justify-content: flex-end;\n align-items: center;\n padding-block: var(--ix-dialog-actions-padding-block, 0.75rem);\n border-top: var(\n --ix-dialog-actions-border,\n 1px solid rgba(0, 0, 0, 0.08)\n );\n }\n\n @keyframes ix-fold-in {\n from {\n transform: translate(-50%, -50%) translateY(-0.5rem) scaleY(0.92);\n opacity: 0;\n }\n to {\n transform: translate(-50%, -50%) translateY(0) scaleY(1);\n opacity: 1;\n }\n }\n @keyframes ix-fold-out {\n from {\n transform: translate(-50%, -50%) translateY(0) scaleY(1);\n opacity: 1;\n }\n to {\n transform: translate(-50%, -50%) translateY(-0.5rem) scaleY(0.98);\n opacity: 0;\n }\n }\n\n :host([use-native-dialog]:not([closing])) dialog[open] > .container {\n animation: ix-fold-in var(--ix-dialog-in-dur, 1000ms)\n cubic-bezier(0.2, 0.7, 0.3, 1) both;\n }\n :host([use-native-dialog][closing]) dialog > .container {\n animation: ix-fold-out var(--ix-dialog-out-dur, 250ms)\n cubic-bezier(0.2, 0.7, 0.3, 1) both;\n }\n\n @media (prefers-reduced-motion: reduce) {\n :host([use-native-dialog]) dialog > .container {\n animation: none !important;\n }\n }\n `,\n ];\n\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n @query('.dialog') readonly component!: Dialog;\n\n @property({ type: Boolean, reflect: true }) open = false;\n\n @property({ type: Boolean, attribute: 'prevent-cancel' }) preventCancel =\n false;\n\n @property({ type: Boolean }) preventCloseOnScrimClick = false;\n\n @property({ type: Boolean }) disableNextClickIsFromContent = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'use-native-dialog' })\n useNativeDialog = false;\n\n @property({ type: Boolean }) allowOverflow = false;\n\n /**\n * Used in conjunction with `useNativeDialog`\n */\n @property({ type: Object }) contentStyles?: CSSResultGroup;\n\n @state() private nativeClosing = false;\n\n private dialogRef: Ref<HTMLDialogElement> = createRef();\n\n private containerRef: Ref<HTMLDivElement> = createRef();\n\n private portalHost?: HTMLElement;\n\n private portalRoot?: ShadowRoot;\n\n private portalStyleEl?: HTMLStyleElement;\n\n private pointerDownInside = false;\n\n private isScrollLocked = false;\n\n private scrollYBackup = 0;\n\n private removeScrollHandlers?: () => void;\n\n private nativeOnEnd?: () => void;\n\n private mo?: MutationObserver;\n\n private get nativeDialog(): HTMLDialogElement | null {\n return this.dialogRef.value ?? null;\n }\n\n private get nativeDialogContainer(): HTMLDivElement | null {\n return this.containerRef.value ?? null;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.mo = new MutationObserver(() => {\n if (this.useNativeDialog && this.open) this.populatePortal();\n });\n this.mo.observe(this, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.mo?.disconnect();\n this.unlockScroll();\n this.teardownPortal();\n }\n\n updated(changed: Map<string, unknown>) {\n if (!this.useNativeDialog) return;\n if (changed.has('open')) {\n if (this.open) {\n this.ensurePortal();\n if (this.portalRoot) {\n this.attachPortalStyles();\n render(this.portalTemplate(), this.portalRoot);\n this.populatePortal();\n }\n if (this.nativeClosing) {\n this.nativeClosing = false;\n this.nativeDialogContainer?.classList.remove('closing');\n if (this.nativeOnEnd && this.nativeDialogContainer) {\n this.nativeDialogContainer.removeEventListener(\n 'animationend',\n this.nativeOnEnd\n );\n }\n this.nativeOnEnd = undefined;\n }\n this.dispatchEvent(\n new Event('open', { bubbles: true, composed: true })\n );\n this.lockScroll();\n requestAnimationFrame(() => {\n this.nativeDialog?.show();\n requestAnimationFrame(() => {\n this.dispatchEvent(\n new Event('opened', { bubbles: true, composed: true })\n );\n });\n });\n } else {\n this.startNativeCloseAnimation();\n }\n }\n }\n\n public dismiss() {\n if (!this.open) return;\n Promise.resolve().then(() => {\n this.requestClose();\n });\n }\n\n private startNativeCloseAnimation() {\n if (this.nativeClosing) return;\n this.nativeClosing = true;\n this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));\n\n const finish = () => {\n this.nativeDialogContainer?.classList.remove('closing');\n this.nativeClosing = false;\n this.nativeDialog?.close();\n this.unlockScroll();\n this.dispatchEvent(\n new Event('closed', { bubbles: true, composed: true })\n );\n this.moveNodesBackFromPortal();\n this.teardownPortal();\n };\n\n const container = this.nativeDialogContainer;\n if (!container) {\n finish();\n return;\n }\n\n container.classList.add('closing');\n\n let done = false;\n const onEnd = () => {\n if (done) return;\n done = true;\n container.removeEventListener('animationend', onEnd);\n finish();\n };\n this.nativeOnEnd = onEnd;\n container.addEventListener('animationend', onEnd, { once: true });\n\n window.setTimeout(onEnd, 1);\n }\n\n private ensurePortal() {\n if (this.portalRoot) return;\n const host = document.createElement('ix-dialog-portal-host');\n const root = host.attachShadow({ mode: 'open' });\n if (this.shadowRoot && 'adoptedStyleSheets' in this.shadowRoot) {\n (root as any).adoptedStyleSheets = (\n this.shadowRoot as any\n ).adoptedStyleSheets;\n }\n document.body.appendChild(host);\n this.portalHost = host;\n this.portalRoot = root;\n }\n\n private attachPortalStyles() {\n if (!this.portalRoot || this.portalStyleEl) return;\n const style = document.createElement('style');\n\n const portalLayoutStyles = `\n dialog {\n position: fixed;\n inset: 0;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n display: grid;\n place-items: center;\n pointer-events: none;\n z-index: 1000;\n max-width: none !important;\n max-height: none !important;\n }\n .scrim {\n position: fixed;\n inset: 0;\n background: var(--ix-dialog-scrim, rgba(0,0,0,0.5));\n pointer-events: auto;\n z-index: 1000;\n touch-action: none;\n border: 0;\n padding: 0;\n appearance: none;\n }\n .container {\n position: relative;\n border-radius: 0.75rem;\n background: var(--ix-dialog-bg, #fff);\n box-shadow: var(--ix-dialog-shadow, 0 10px 30px rgba(0,0,0,0.25));\n display: grid;\n grid-template-rows: auto 1fr auto;\n overflow: visible;\n pointer-events: auto;\n z-index: 1001;\n max-width: none!important;\n }\n .container .content {\n overflow: visible;\n }\n @media (prefers-reduced-motion: reduce) {\n dialog > .container { animation: none !important; }\n }\n `;\n\n if (this.contentStyles) {\n const stylesArray: CSSResultGroup[] = Array.isArray(this.contentStyles)\n ? this.contentStyles\n : [this.contentStyles];\n const customContentStyles = stylesArray\n .map(contentStyle => {\n if (typeof contentStyle === 'object' && 'cssText' in contentStyle) {\n return contentStyle.cssText;\n }\n return '';\n })\n .join('\\n');\n\n style.textContent = customContentStyles + portalLayoutStyles;\n } else {\n style.textContent = portalLayoutStyles;\n }\n\n this.portalRoot.append(style);\n this.portalStyleEl = style;\n }\n\n private teardownPortal() {\n if (!this.portalHost) return;\n if (this.portalRoot) render(nothing, this.portalRoot);\n this.portalStyleEl?.remove();\n this.portalStyleEl = undefined;\n this.portalHost.remove();\n this.portalRoot = undefined;\n this.portalHost = undefined;\n }\n\n private moveNodesToPortal(slotName: string, targetSelector: string) {\n if (!this.nativeDialogContainer) return;\n const target = this.nativeDialogContainer.querySelector(targetSelector);\n if (!target) return;\n const nodes = Array.from(this.children).filter(\n el => el instanceof HTMLElement && el.slot === slotName\n );\n nodes.forEach(n => target.appendChild(n));\n }\n\n private moveNodesBackFromPortal() {\n if (!this.nativeDialogContainer) return;\n const h = this.nativeDialogContainer.querySelector('.headline');\n const b = this.nativeDialogContainer.querySelector('.content');\n const a = this.nativeDialogContainer.querySelector('.actions');\n [h, b, a].forEach(container => {\n if (!container) return;\n const children = Array.from(container.childNodes);\n children.forEach(n => this.appendChild(n));\n });\n }\n\n private populatePortal() {\n this.moveNodesToPortal('headline', '.headline');\n this.moveNodesToPortal('content', '.content');\n this.moveNodesToPortal('actions', '.actions');\n }\n\n private onKeydown = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n if (this.preventCancel) {\n e.preventDefault();\n return;\n }\n const cancelEvt = new Event('cancel', {\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n const prevented = !this.dispatchEvent(cancelEvt);\n if (prevented) {\n e.preventDefault();\n return;\n }\n this.requestClose();\n };\n\n private onNativeCancel = (e: Event) => {\n const forwarded = new Event('cancel', {\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n const prevented = !this.dispatchEvent(forwarded);\n if (prevented) {\n e.preventDefault();\n return;\n }\n this.requestClose();\n };\n\n private requestClose() {\n this.open = false;\n }\n\n private onScrimClick = () => {\n if (!this.preventCloseOnScrimClick) this.requestClose();\n };\n\n private lockScroll() {\n if (this.isScrollLocked) return;\n this.isScrollLocked = true;\n this.scrollYBackup =\n window.scrollY || document.documentElement.scrollTop || 0;\n const { body } = document;\n const scrollbarWidth =\n window.innerWidth - document.documentElement.clientWidth;\n if (scrollbarWidth > 0) {\n body.style.paddingRight = `${scrollbarWidth}px`;\n }\n body.style.overflow = 'hidden';\n body.style.position = 'fixed';\n body.style.top = `-${this.scrollYBackup}px`;\n body.style.left = '0';\n body.style.right = '0';\n body.style.width = '100%';\n const stopIfOutside = (ev: Event) => {\n const t = ev.target as Node | null;\n if (!this.nativeDialogContainer || !t) return;\n if (!this.nativeDialogContainer.contains(t)) ev.preventDefault();\n };\n const onTouchMove = (e: TouchEvent) => stopIfOutside(e);\n const onKeyDown = (e: KeyboardEvent) => {\n const keys = [\n 'PageUp',\n 'PageDown',\n 'Home',\n 'End',\n 'ArrowUp',\n 'ArrowDown',\n ' ',\n ];\n if (!keys.includes(e.key)) return;\n const t = e.target as Node | null;\n if (!this.nativeDialogContainer || !t) return;\n if (!this.nativeDialogContainer.contains(t)) e.preventDefault();\n };\n window.addEventListener('touchmove', onTouchMove, { passive: false });\n window.addEventListener('keydown', onKeyDown, { passive: false });\n this.removeScrollHandlers = () => {\n window.removeEventListener('touchmove', onTouchMove as any);\n window.removeEventListener('keydown', onKeyDown as any);\n };\n }\n\n private unlockScroll() {\n if (!this.isScrollLocked) return;\n this.isScrollLocked = false;\n if (this.removeScrollHandlers) {\n this.removeScrollHandlers();\n this.removeScrollHandlers = undefined;\n }\n const { body } = document;\n body.style.paddingRight = '';\n body.style.position = '';\n body.style.top = '';\n body.style.left = '';\n body.style.right = '';\n body.style.overflow = '';\n body.style.width = '';\n window.scrollTo(0, this.scrollYBackup || 0);\n }\n\n onOpen() {\n this.dispatchEvent(new Event('open'));\n this.lockScroll();\n }\n\n onOpened() {\n this.dispatchEvent(new Event('opened'));\n }\n\n onClose() {\n this.dispatchEvent(new Event('close'));\n }\n\n onClosed() {\n this.dispatchEvent(new Event('closed'));\n this.unlockScroll();\n }\n\n onCancel(e: Event) {\n if (this.preventCancel) e.preventDefault();\n this.dispatchEvent(new Event('cancel', { bubbles: true, composed: true }));\n }\n\n private portalTemplate() {\n return html`\n <dialog\n ${ref(this.dialogRef)}\n @cancel=${this.onNativeCancel}\n @keydown=${this.onKeydown}\n >\n <button\n class=\"scrim\"\n type=\"button\"\n aria-label=\"Close dialog\"\n @click=${this.onScrimClick}\n ></button>\n <div\n class=\"container\"\n ${ref(this.containerRef)}\n role=\"dialog\"\n aria-modal=\"true\"\n >\n <div class=\"headline\"></div>\n <div class=\"content\"></div>\n <div class=\"actions\"></div>\n </div>\n </dialog>\n `;\n }\n\n private renderMdDialog() {\n if (this.portalHost) {\n this.moveNodesBackFromPortal();\n this.teardownPortal();\n }\n return html`<md-dialog\n ?open=${this.open}\n class=\"dialog\"\n ?preventCloseOnScrimClick=${this.preventCloseOnScrimClick}\n ?disableNextClickIsFromContent=${this.disableNextClickIsFromContent}\n ?allowOverflow=${this.allowOverflow}\n ${spread(this.ariaAttributes)}\n @open=${this.onOpen}\n @opened=${this.onOpened}\n @close=${this.onClose}\n @closed=${this.onClosed}\n @cancel=${this.onCancel}\n >\n <slot slot=\"headline\" name=\"headline\"></slot>\n <slot slot=\"content\" name=\"content\"></slot>\n <slot slot=\"actions\" name=\"actions\"></slot>\n </md-dialog>`;\n }\n\n private renderNativeDialog() {\n if (this.portalRoot) {\n render(this.portalTemplate(), this.portalRoot);\n this.populatePortal();\n }\n return nothing;\n }\n\n render() {\n return this.useNativeDialog\n ? this.renderNativeDialog()\n : this.renderMdDialog();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IxDialog.js","sourceRoot":"","sources":["../src/IxDialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAO,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,gBAAgB,CAAC;AAExB,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9E,MAAM,OAAO,QAAS,SAAQ,iBAAiB;IAA/C;;QA+H8C,SAAI,GAAG,KAAK,CAAC;QAEC,kBAAa,GACrE,KAAK,CAAC;QAEqB,6BAAwB,GAAG,KAAK,CAAC;QAEjC,kCAA6B,GAAG,KAAK,CAAC;QAGnE,oBAAe,GAAG,KAAK,CAAC;QAEK,kBAAa,GAAG,KAAK,CAAC;QAOlC,kBAAa,GAAG,KAAK,CAAC;QAE/B,cAAS,GAA2B,SAAS,EAAE,CAAC;QAEhD,iBAAY,GAAwB,SAAS,EAAE,CAAC;QAQhD,sBAAiB,GAAG,KAAK,CAAC;QAE1B,mBAAc,GAAG,KAAK,CAAC;QAEvB,kBAAa,GAAG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AAC;;AA/mBD,kBAAkB;AACX,eAAM,GAAmB;IAC9B,cAAc;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiHF;CACF,CAAC;AAEc,0BAAiB,GAAG;IAClC,GAAG,UAAU,CAAC,iBAAiB;IAC/B,cAAc,EAAE,IAAI;CACrB,CAAC;AAEgB;IAAjB,KAAK,CAAC,SAAS,CAAC;2CAA6B;AAEF;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAAc;AAEC;IAAzD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;+CACjD;AAEqB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAAkC;AAEjC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+DAAuC;AAGnE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;iDACnD;AAEK;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAuB;AAKvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAgC;AAElD;IAAR,KAAK,EAAE;+CAA+B","sourcesContent":["import { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.js';\nimport { AriaForwardMixin } from '@digital-realty/ix-shared-fns/aria-forward-mixin.js';\nimport { spread } from '@open-wc/lit-helpers';\nimport { css, CSSResultGroup, html, LitElement, nothing, render } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { createRef, ref, Ref } from 'lit/directives/ref.js';\nimport { Dialog } from './internal/dialog.js';\nimport { IxDialogStyles } from './ix-dialog-styles.js';\nimport './md-dialog.js';\n\nconst ixDialogBaseClass = AriaForwardMixin(mixinElementInternals(LitElement));\n\nexport class IxDialog extends ixDialogBaseClass {\n /** @nocollapse */\n static styles: CSSResultGroup = [\n IxDialogStyles,\n css`\n :host([use-native-dialog]) dialog[open],\n :host([use-native-dialog][closing]) dialog {\n position: fixed;\n inset: 0;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n display: block;\n inline-size: 100vw;\n block-size: 100dvh;\n pointer-events: none;\n z-index: 99;\n overscroll-behavior: contain;\n }\n\n :host([use-native-dialog]) dialog[open] .scrim,\n :host([use-native-dialog][closing]) .scrim,\n :host([use-native-dialog]) dialog[open] > .container,\n :host([use-native-dialog][closing]) dialog > .container {\n pointer-events: auto;\n }\n\n :host([use-native-dialog]) dialog[open] .scrim,\n :host([use-native-dialog][closing]) .scrim {\n position: fixed;\n inset: 0;\n background: var(--ix-dialog-scrim, rgba(0, 0, 0, 0.32));\n }\n\n :host([use-native-dialog]) dialog[open] .scrim {\n overscroll-behavior: contain;\n touch-action: none;\n }\n\n :host([use-native-dialog]) dialog[open] > .container,\n :host([use-native-dialog][closing]) dialog > .container {\n transform: translate(-50%, -50%);\n width: auto;\n height: auto;\n max-block-size: var(--ix-dialog-max-height, 90dvh);\n border-radius: 0.75rem;\n background: var(--ix-dialog-bg, #fff);\n box-shadow: var(\n --ix-dialog-shadow,\n 0 0.625rem 1.875rem rgba(0, 0, 0, 0.25)\n );\n display: grid;\n grid-template-rows: auto 1fr auto;\n overflow: hidden;\n z-index: 9;\n transform-origin: top center;\n will-change: transform, opacity;\n }\n\n :host([use-native-dialog]) .headline,\n :host([use-native-dialog]) .content,\n :host([use-native-dialog]) .actions {\n padding: var(--ix-dialog-section-padding, 1rem);\n }\n\n :host([use-native-dialog]) .content {\n overflow: auto;\n }\n\n :host([use-native-dialog]) .actions {\n display: inline-flex;\n gap: var(--ix-dialog-actions-gap, 0.5rem);\n justify-content: flex-end;\n align-items: center;\n padding-block: var(--ix-dialog-actions-padding-block, 0.75rem);\n border-top: var(\n --ix-dialog-actions-border,\n 1px solid rgba(0, 0, 0, 0.08)\n );\n }\n\n @keyframes ix-fold-in {\n from {\n transform: translate(-50%, -50%) translateY(-0.5rem) scaleY(0.92);\n opacity: 0;\n }\n to {\n transform: translate(-50%, -50%) translateY(0) scaleY(1);\n opacity: 1;\n }\n }\n @keyframes ix-fold-out {\n from {\n transform: translate(-50%, -50%) translateY(0) scaleY(1);\n opacity: 1;\n }\n to {\n transform: translate(-50%, -50%) translateY(-0.5rem) scaleY(0.98);\n opacity: 0;\n }\n }\n\n :host([use-native-dialog]:not([closing])) dialog[open] > .container {\n animation: ix-fold-in var(--ix-dialog-in-dur, 1000ms)\n cubic-bezier(0.2, 0.7, 0.3, 1) both;\n }\n :host([use-native-dialog][closing]) dialog > .container {\n animation: ix-fold-out var(--ix-dialog-out-dur, 250ms)\n cubic-bezier(0.2, 0.7, 0.3, 1) both;\n }\n\n @media (prefers-reduced-motion: reduce) {\n :host([use-native-dialog]) dialog > .container {\n animation: none !important;\n }\n }\n `,\n ];\n\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n @query('.dialog') readonly component!: Dialog;\n\n @property({ type: Boolean, reflect: true }) open = false;\n\n @property({ type: Boolean, attribute: 'prevent-cancel' }) preventCancel =\n false;\n\n @property({ type: Boolean }) preventCloseOnScrimClick = false;\n\n @property({ type: Boolean }) disableNextClickIsFromContent = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'use-native-dialog' })\n useNativeDialog = false;\n\n @property({ type: Boolean }) allowOverflow = false;\n\n /**\n * Used in conjunction with `useNativeDialog`\n */\n @property({ type: Object }) contentStyles?: CSSResultGroup;\n\n @state() private nativeClosing = false;\n\n private dialogRef: Ref<HTMLDialogElement> = createRef();\n\n private containerRef: Ref<HTMLDivElement> = createRef();\n\n private portalHost?: HTMLElement;\n\n private portalRoot?: ShadowRoot;\n\n private portalStyleEl?: HTMLStyleElement;\n\n private pointerDownInside = false;\n\n private isScrollLocked = false;\n\n private scrollYBackup = 0;\n\n private removeScrollHandlers?: () => void;\n\n private nativeOnEnd?: () => void;\n\n private mo?: MutationObserver;\n\n private get forwardedAriaAttributes() {\n const ariaAttributes = { ...this.ariaAttributes };\n for (const attr of Array.from(this.attributes)) {\n if (attr.name.startsWith('aria-')) {\n ariaAttributes[attr.name] = attr.value;\n }\n }\n return ariaAttributes;\n }\n\n private get nativeDialog(): HTMLDialogElement | null {\n return this.dialogRef.value ?? null;\n }\n\n private get nativeDialogContainer(): HTMLDivElement | null {\n return this.containerRef.value ?? null;\n }\n\n private get hasPortalHeadline() {\n return Array.from(this.children).some(\n child => child instanceof HTMLElement && child.slot === 'headline'\n );\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.mo = new MutationObserver(() => {\n if (this.useNativeDialog && this.open) this.populatePortal();\n });\n this.mo.observe(this, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n });\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.mo?.disconnect();\n this.unlockScroll();\n this.teardownPortal();\n }\n\n updated(changed: Map<string, unknown>) {\n if (!this.useNativeDialog) return;\n if (changed.has('open')) {\n if (this.open) {\n this.ensurePortal();\n if (this.portalRoot) {\n this.attachPortalStyles();\n render(this.portalTemplate(), this.portalRoot);\n this.populatePortal();\n }\n if (this.nativeClosing) {\n this.nativeClosing = false;\n this.nativeDialogContainer?.classList.remove('closing');\n if (this.nativeOnEnd && this.nativeDialogContainer) {\n this.nativeDialogContainer.removeEventListener(\n 'animationend',\n this.nativeOnEnd\n );\n }\n this.nativeOnEnd = undefined;\n }\n this.dispatchEvent(\n new Event('open', { bubbles: true, composed: true })\n );\n this.lockScroll();\n requestAnimationFrame(() => {\n this.nativeDialog?.show();\n requestAnimationFrame(() => {\n this.dispatchEvent(\n new Event('opened', { bubbles: true, composed: true })\n );\n });\n });\n } else {\n this.startNativeCloseAnimation();\n }\n }\n }\n\n public dismiss() {\n if (!this.open) return;\n Promise.resolve().then(() => {\n this.requestClose();\n });\n }\n\n private startNativeCloseAnimation() {\n if (this.nativeClosing) return;\n this.nativeClosing = true;\n this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));\n\n const finish = () => {\n this.nativeDialogContainer?.classList.remove('closing');\n this.nativeClosing = false;\n this.nativeDialog?.close();\n this.unlockScroll();\n this.dispatchEvent(\n new Event('closed', { bubbles: true, composed: true })\n );\n this.moveNodesBackFromPortal();\n this.teardownPortal();\n };\n\n const container = this.nativeDialogContainer;\n if (!container) {\n finish();\n return;\n }\n\n container.classList.add('closing');\n\n let done = false;\n const onEnd = () => {\n if (done) return;\n done = true;\n container.removeEventListener('animationend', onEnd);\n finish();\n };\n this.nativeOnEnd = onEnd;\n container.addEventListener('animationend', onEnd, { once: true });\n\n window.setTimeout(onEnd, 1);\n }\n\n private ensurePortal() {\n if (this.portalRoot) return;\n const host = document.createElement('ix-dialog-portal-host');\n const root = host.attachShadow({ mode: 'open' });\n if (this.shadowRoot && 'adoptedStyleSheets' in this.shadowRoot) {\n (root as any).adoptedStyleSheets = (\n this.shadowRoot as any\n ).adoptedStyleSheets;\n }\n document.body.appendChild(host);\n this.portalHost = host;\n this.portalRoot = root;\n }\n\n private attachPortalStyles() {\n if (!this.portalRoot || this.portalStyleEl) return;\n const style = document.createElement('style');\n\n const portalLayoutStyles = `\n dialog {\n position: fixed;\n inset: 0;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n display: grid;\n place-items: center;\n pointer-events: none;\n z-index: 1000;\n max-width: none !important;\n max-height: none !important;\n }\n .scrim {\n position: fixed;\n inset: 0;\n background: var(--ix-dialog-scrim, rgba(0,0,0,0.5));\n pointer-events: auto;\n z-index: 1000;\n touch-action: none;\n border: 0;\n padding: 0;\n appearance: none;\n }\n .container {\n position: relative;\n border-radius: 0.75rem;\n background: var(--ix-dialog-bg, #fff);\n box-shadow: var(--ix-dialog-shadow, 0 10px 30px rgba(0,0,0,0.25));\n display: grid;\n grid-template-rows: auto 1fr auto;\n overflow: visible;\n pointer-events: auto;\n z-index: 1001;\n max-width: none!important;\n }\n .container .content {\n overflow: visible;\n }\n @media (prefers-reduced-motion: reduce) {\n dialog > .container { animation: none !important; }\n }\n `;\n\n if (this.contentStyles) {\n const stylesArray: CSSResultGroup[] = Array.isArray(this.contentStyles)\n ? this.contentStyles\n : [this.contentStyles];\n const customContentStyles = stylesArray\n .map(contentStyle => {\n if (typeof contentStyle === 'object' && 'cssText' in contentStyle) {\n return contentStyle.cssText;\n }\n return '';\n })\n .join('\\n');\n\n style.textContent = customContentStyles + portalLayoutStyles;\n } else {\n style.textContent = portalLayoutStyles;\n }\n\n this.portalRoot.append(style);\n this.portalStyleEl = style;\n }\n\n private teardownPortal() {\n if (!this.portalHost) return;\n if (this.portalRoot) render(nothing, this.portalRoot);\n this.portalStyleEl?.remove();\n this.portalStyleEl = undefined;\n this.portalHost.remove();\n this.portalRoot = undefined;\n this.portalHost = undefined;\n }\n\n private moveNodesToPortal(slotName: string, targetSelector: string) {\n if (!this.nativeDialogContainer) return;\n const target = this.nativeDialogContainer.querySelector(targetSelector);\n if (!target) return;\n const nodes = Array.from(this.children).filter(\n el => el instanceof HTMLElement && el.slot === slotName\n );\n nodes.forEach(n => target.appendChild(n));\n }\n\n private moveNodesBackFromPortal() {\n if (!this.nativeDialogContainer) return;\n const h = this.nativeDialogContainer.querySelector('.headline');\n const b = this.nativeDialogContainer.querySelector('.content');\n const a = this.nativeDialogContainer.querySelector('.actions');\n [h, b, a].forEach(container => {\n if (!container) return;\n const children = Array.from(container.childNodes);\n children.forEach(n => this.appendChild(n));\n });\n }\n\n private populatePortal() {\n this.moveNodesToPortal('headline', '.headline');\n this.moveNodesToPortal('content', '.content');\n this.moveNodesToPortal('actions', '.actions');\n }\n\n private onKeydown = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n if (this.preventCancel) {\n e.preventDefault();\n return;\n }\n const cancelEvt = new Event('cancel', {\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n const prevented = !this.dispatchEvent(cancelEvt);\n if (prevented) {\n e.preventDefault();\n return;\n }\n this.requestClose();\n };\n\n private onNativeCancel = (e: Event) => {\n const forwarded = new Event('cancel', {\n bubbles: true,\n composed: true,\n cancelable: true,\n });\n const prevented = !this.dispatchEvent(forwarded);\n if (prevented) {\n e.preventDefault();\n return;\n }\n this.requestClose();\n };\n\n private requestClose() {\n this.open = false;\n }\n\n private onScrimClick = () => {\n if (!this.preventCloseOnScrimClick) this.requestClose();\n };\n\n private lockScroll() {\n if (this.isScrollLocked) return;\n this.isScrollLocked = true;\n this.scrollYBackup =\n window.scrollY || document.documentElement.scrollTop || 0;\n const { body } = document;\n const scrollbarWidth =\n window.innerWidth - document.documentElement.clientWidth;\n if (scrollbarWidth > 0) {\n body.style.paddingRight = `${scrollbarWidth}px`;\n }\n body.style.overflow = 'hidden';\n body.style.position = 'fixed';\n body.style.top = `-${this.scrollYBackup}px`;\n body.style.left = '0';\n body.style.right = '0';\n body.style.width = '100%';\n const stopIfOutside = (ev: Event) => {\n const t = ev.target as Node | null;\n if (!this.nativeDialogContainer || !t) return;\n if (!this.nativeDialogContainer.contains(t)) ev.preventDefault();\n };\n const onTouchMove = (e: TouchEvent) => stopIfOutside(e);\n const onKeyDown = (e: KeyboardEvent) => {\n const keys = [\n 'PageUp',\n 'PageDown',\n 'Home',\n 'End',\n 'ArrowUp',\n 'ArrowDown',\n ' ',\n ];\n if (!keys.includes(e.key)) return;\n const t = e.target as Node | null;\n if (!this.nativeDialogContainer || !t) return;\n if (!this.nativeDialogContainer.contains(t)) e.preventDefault();\n };\n window.addEventListener('touchmove', onTouchMove, { passive: false });\n window.addEventListener('keydown', onKeyDown, { passive: false });\n this.removeScrollHandlers = () => {\n window.removeEventListener('touchmove', onTouchMove as any);\n window.removeEventListener('keydown', onKeyDown as any);\n };\n }\n\n private unlockScroll() {\n if (!this.isScrollLocked) return;\n this.isScrollLocked = false;\n if (this.removeScrollHandlers) {\n this.removeScrollHandlers();\n this.removeScrollHandlers = undefined;\n }\n const { body } = document;\n body.style.paddingRight = '';\n body.style.position = '';\n body.style.top = '';\n body.style.left = '';\n body.style.right = '';\n body.style.overflow = '';\n body.style.width = '';\n window.scrollTo(0, this.scrollYBackup || 0);\n }\n\n onOpen() {\n this.dispatchEvent(new Event('open'));\n this.lockScroll();\n }\n\n onOpened() {\n this.dispatchEvent(new Event('opened'));\n }\n\n onClose() {\n this.dispatchEvent(new Event('close'));\n }\n\n onClosed() {\n this.dispatchEvent(new Event('closed'));\n this.unlockScroll();\n }\n\n onCancel(e: Event) {\n if (this.preventCancel) e.preventDefault();\n this.dispatchEvent(new Event('cancel', { bubbles: true, composed: true }));\n }\n\n private portalTemplate() {\n const {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...portalAriaAttributes\n } = this.forwardedAriaAttributes;\n\n return html`\n <dialog\n ${ref(this.dialogRef)}\n @cancel=${this.onNativeCancel}\n @keydown=${this.onKeydown}\n >\n <button\n class=\"scrim\"\n type=\"button\"\n aria-label=\"Close dialog\"\n @click=${this.onScrimClick}\n ></button>\n <div\n class=\"container\"\n ${ref(this.containerRef)}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=${ariaLabel || nothing}\n aria-labelledby=${ariaLabel\n ? nothing\n : ariaLabelledBy || (this.hasPortalHeadline ? 'headline' : nothing)}\n ${spread(portalAriaAttributes)}\n >\n <div class=\"headline\" id=\"headline\"></div>\n <div class=\"content\"></div>\n <div class=\"actions\"></div>\n </div>\n </dialog>\n `;\n }\n\n private renderMdDialog() {\n if (this.portalHost) {\n this.moveNodesBackFromPortal();\n this.teardownPortal();\n }\n return html`<md-dialog\n ?open=${this.open}\n class=\"dialog\"\n ?preventCloseOnScrimClick=${this.preventCloseOnScrimClick}\n ?disableNextClickIsFromContent=${this.disableNextClickIsFromContent}\n ?allowOverflow=${this.allowOverflow}\n ${spread(this.forwardedAriaAttributes)}\n @open=${this.onOpen}\n @opened=${this.onOpened}\n @close=${this.onClose}\n @closed=${this.onClosed}\n @cancel=${this.onCancel}\n >\n <slot slot=\"headline\" name=\"headline\"></slot>\n <slot slot=\"content\" name=\"content\"></slot>\n <slot slot=\"actions\" name=\"actions\"></slot>\n </md-dialog>`;\n }\n\n private renderNativeDialog() {\n if (this.portalRoot) {\n render(this.portalTemplate(), this.portalRoot);\n this.populatePortal();\n }\n return nothing;\n }\n\n render() {\n return this.useNativeDialog\n ? this.renderNativeDialog()\n : this.renderMdDialog();\n }\n}\n"]}
|
package/dist/internal/dialog.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/internal/dialog.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,2CAA2C;AAC3C;;;;GAIG;;AAEH,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAEpF,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,GAG9B,MAAM,6CAA6C,CAAC;AAErD,wCAAwC;AACxC,MAAM,eAAe,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAEvD;;;;;;;;;GASG;AAEH,oBAAoB;AACpB,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC,kEAAkE;IAClE,kBAAkB;IAClB,mEAAmE;IAEnE;;OAEG;IAEH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IAC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,GAAG,uBAAuB,CAAC;IACpD,IACE,OAAO,CAAC,OAAO,CAAC,sBAAsB,GAAG,WAAW,GAAG,mBAAmB,CAAC,EAC3E;QACA,OAAO,IAAI,CAAC;KACb;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;IAED,0EAA0E;IAC1E,2EAA2E;IAC3E,iDAAiD;IACjD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACjC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,MAAA,MAAA,OAAO,CAAC,UAAU,0CAAE,cAAc,mCAAI,KAAK,CAAC;AACrD,CAAC;AACD,mBAAmB","sourcesContent":["/* eslint-disable no-shadow */\n/* eslint-disable class-methods-use-this */\n/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '@material/web/divider/divider.js';\n\nimport { html, isServer, LitElement, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ARIAMixinStrict } from '@material/web/internal/aria/aria.js';\nimport { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';\nimport { redispatchEvent } from '@material/web/internal/events/redispatch-event.js';\n\nimport {\n DIALOG_DEFAULT_CLOSE_ANIMATION,\n DIALOG_DEFAULT_OPEN_ANIMATION,\n DialogAnimation,\n DialogAnimationArgs,\n} from '@material/web/dialog/internal/animations.js';\n\n// Separate variable needed for closure.\nconst dialogBaseClass = mixinDelegatesAria(LitElement);\n\n/**\n * A dialog component.\n *\n * @fires open {Event} Dispatched when the dialog is opening before any animations.\n * @fires opened {Event} Dispatched when the dialog has opened after any animations.\n * @fires close {Event} Dispatched when the dialog is closing before any animations.\n * @fires closed {Event} Dispatched when the dialog has closed after any animations.\n * @fires cancel {Event} Dispatched when the dialog has been canceled by clicking\n * on the scrim or pressing Escape.\n */\n\n/* eslint-disable */\nexport class Dialog extends dialogBaseClass {\n // We do not use `delegatesFocus: true` due to a Chromium bug with\n // selecting text.\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=950357\n\n /**\n * Opens the dialog when set to `true` and closes it when set to `false`.\n */\n @property({ type: Boolean })\n get open() {\n return this.isOpen;\n }\n\n set open(open: boolean) {\n if (open === this.isOpen) {\n return;\n }\n\n this.isOpen = open;\n if (open) {\n this.setAttribute('open', '');\n this.show();\n } else {\n this.removeAttribute('open');\n this.close();\n }\n }\n\n /**\n * Skips the opening and closing animations.\n */\n @property({ type: Boolean }) quick = false;\n\n /**\n * Gets or sets the dialog's return value, usually to indicate which button\n * a user pressed to close it.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue\n */\n @property({ attribute: false }) returnValue = '';\n\n /**\n * The type of dialog for accessibility. Set this to `alert` to announce a\n * dialog as an alert dialog.\n */\n @property() type?: 'alert';\n\n /**\n * Disables focus trapping, which by default keeps keyboard Tab navigation\n * within the dialog.\n *\n * When disabled, after focusing the last element of a dialog, pressing Tab\n * again will release focus from the window back to the browser (such as the\n * URL bar).\n *\n * Focus trapping is recommended for accessibility, and should not typically\n * be disabled. Only turn this off if the use case of a dialog is more\n * accessible without focus trapping.\n */\n @property({ type: Boolean, attribute: 'no-focus-trap' })\n noFocusTrap = false;\n\n @property({ type: Boolean }) allowOverflow = false;\n\n /**\n * Gets the opening animation for a dialog. Set to a new function to customize\n * the animation.\n */\n getOpenAnimation = () => DIALOG_DEFAULT_OPEN_ANIMATION;\n\n /**\n * Gets the closing animation for a dialog. Set to a new function to customize\n * the animation.\n */\n getCloseAnimation = () => DIALOG_DEFAULT_CLOSE_ANIMATION;\n\n private isOpen = false;\n\n private isOpening = false;\n\n // getIsConnectedPromise() immediately sets the resolve property.\n private isConnectedPromiseResolve!: () => void;\n\n private isConnectedPromise = this.getIsConnectedPromise();\n\n @query('dialog') private readonly dialog!: HTMLDialogElement | null;\n\n @query('.scrim') private readonly scrim!: HTMLDialogElement | null;\n\n @query('.container') private readonly container!: HTMLDialogElement | null;\n\n @query('.headline') private readonly headline!: HTMLDialogElement | null;\n\n @query('.content') private readonly content!: HTMLDialogElement | null;\n\n @query('.actions') private readonly actions!: HTMLDialogElement | null;\n\n @state() private isAtScrollTop = false;\n\n @state() private isAtScrollBottom = false;\n\n @query('.scroller') private readonly scroller!: HTMLElement | null;\n\n @query('.top.anchor') private readonly topAnchor!: HTMLElement | null;\n\n @query('.bottom.anchor') private readonly bottomAnchor!: HTMLElement | null;\n\n @query('.focus-trap')\n private readonly firstFocusTrap!: HTMLElement | null;\n\n private nextClickIsFromContent = false;\n\n private intersectionObserver?: IntersectionObserver;\n\n // Dialogs should not be SSR'd while open, so we can just use runtime checks.\n @state() private hasHeadline = false;\n\n @state() private hasActions = false;\n\n @state() private hasIcon = false;\n\n private cancelAnimations?: AbortController;\n\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=1512224\n // Chrome v120 has a bug where escape keys do not trigger cancels. If we get\n // a dialog \"close\" event that is triggered without a \"cancel\" after an escape\n // keydown, then we need to manually trigger our closing logic.\n //\n // This bug occurs when pressing escape to close a dialog without first\n // interacting with the dialog's content.\n //\n // Cleanup tracking:\n // https://github.com/material-components/material-web/issues/5330\n // This can be removed when full CloseWatcher support added and the above bug\n // in Chromium is fixed to fire 'cancel' with one escape press and close with\n // multiple.\n private escapePressedWithoutCancel = false;\n\n // This TreeWalker is used to walk through a dialog's children to find\n // focusable elements. TreeWalker is faster than `querySelectorAll('*')`.\n // We check for isServer because there isn't a \"document\" during an SSR\n // run.\n private readonly treewalker = isServer\n ? null\n : document.createTreeWalker(this, NodeFilter.SHOW_ELEMENT);\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('submit', this.handleSubmit);\n }\n }\n\n /**\n * Opens the dialog and fires a cancelable `open` event. After a dialog's\n * animation, an `opened` event is fired.\n *\n * Add an `autofocus` attribute to a child of the dialog that should\n * receive focus after opening.\n *\n * @return A Promise that resolves after the animation is finished and the\n * `opened` event was fired.\n */\n async show() {\n this.isOpening = true;\n // Dialogs can be opened before being attached to the DOM, so we need to\n // wait until we're connected before calling `showModal()`.\n await this.isConnectedPromise;\n await this.updateComplete;\n const dialog = this.dialog!;\n // Check if already opened or if `dialog.close()` was called while awaiting.\n if (dialog.open || !this.isOpening) {\n this.isOpening = false;\n return;\n }\n\n const preventOpen = !this.dispatchEvent(\n new Event('open', { cancelable: true })\n );\n if (preventOpen) {\n this.open = false;\n this.isOpening = false;\n return;\n }\n\n // All Material dialogs are modal.\n dialog.showModal();\n this.open = true;\n // Reset scroll position if re-opening a dialog with the same content.\n if (this.scroller) {\n this.scroller.scrollTop = 0;\n }\n // Native modal dialogs ignore autofocus and instead force focus to the\n // first focusable child. Override this behavior if there is a child with\n // an autofocus attribute.\n this.querySelector<HTMLElement>('[autofocus]')?.focus();\n\n await this.animateDialog(this.getOpenAnimation());\n this.dispatchEvent(new Event('opened'));\n this.isOpening = false;\n }\n\n /**\n * Closes the dialog and fires a cancelable `close` event. After a dialog's\n * animation, a `closed` event is fired.\n *\n * @param returnValue A return value usually indicating which button was used\n * to close a dialog. If a dialog is canceled by clicking the scrim or\n * pressing Escape, it will not change the return value after closing.\n * @return A Promise that resolves after the animation is finished and the\n * `closed` event was fired.\n */\n async close(returnValue = this.returnValue) {\n this.isOpening = false;\n if (!this.isConnected) {\n // Disconnected dialogs do not fire close events or animate.\n this.open = false;\n return;\n }\n\n await this.updateComplete;\n const dialog = this.dialog!;\n // Check if already closed or if `dialog.show()` was called while awaiting.\n if (!dialog.open || this.isOpening) {\n this.open = false;\n return;\n }\n\n const prevReturnValue = this.returnValue;\n this.returnValue = returnValue;\n const preventClose = !this.dispatchEvent(\n new Event('close', { cancelable: true })\n );\n if (preventClose) {\n this.returnValue = prevReturnValue;\n return;\n }\n\n await this.animateDialog(this.getCloseAnimation());\n dialog.close(returnValue);\n this.open = false;\n this.dispatchEvent(new Event('closed'));\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.isConnectedPromiseResolve();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.isConnectedPromise = this.getIsConnectedPromise();\n }\n\n protected override render() {\n const scrollable =\n this.open && !(this.isAtScrollTop && this.isAtScrollBottom);\n const classes = {\n 'has-headline': this.hasHeadline,\n 'has-actions': this.hasActions,\n 'has-icon': this.hasIcon,\n scrollable: scrollable,\n 'show-top-divider': scrollable && !this.isAtScrollTop,\n 'show-bottom-divider': scrollable && !this.isAtScrollBottom,\n 'allow-overflow': this.allowOverflow,\n };\n\n // The focus trap sentinels are only added after the dialog opens, since\n // dialog.showModal() will try to autofocus them, even with tabindex=\"-1\".\n const showFocusTrap = this.open && !this.noFocusTrap;\n const focusTrap = html`\n <div\n class=\"focus-trap\"\n tabindex=\"0\"\n aria-hidden=\"true\"\n @focus=${this.handleFocusTrapFocus}\n ></div>\n `;\n\n const { ariaLabel } = this as ARIAMixinStrict;\n return html`\n <div class=\"scrim\"></div>\n <dialog\n class=${classMap(classes)}\n aria-label=${ariaLabel || nothing}\n aria-labelledby=${this.hasHeadline ? 'headline' : nothing}\n role=${this.type === 'alert' ? 'alertdialog' : nothing}\n @cancel=${this.handleCancel}\n @click=${this.handleDialogClick}\n @close=${this.handleClose}\n @keydown=${this.handleKeydown}\n .returnValue=${this.returnValue || nothing}\n >\n ${showFocusTrap ? focusTrap : nothing}\n <div class=\"container\" @click=${this.handleContentClick}>\n <div class=\"headline\">\n <div class=\"icon\" aria-hidden=\"true\">\n <slot name=\"icon\" @slotchange=${this.handleIconChange}></slot>\n </div>\n <h2 id=\"headline\" aria-hidden=${!this.hasHeadline || nothing}>\n <slot\n name=\"headline\"\n @slotchange=${this.handleHeadlineChange}\n ></slot>\n </h2>\n <md-divider></md-divider>\n </div>\n <div class=\"scroller\">\n <div class=\"content\">\n <div class=\"top anchor\"></div>\n <slot name=\"content\"></slot>\n <div class=\"bottom anchor\"></div>\n </div>\n </div>\n <div class=\"actions\">\n <md-divider></md-divider>\n <slot name=\"actions\" @slotchange=${this.handleActionsChange}></slot>\n </div>\n </div>\n ${showFocusTrap ? focusTrap : nothing}\n </dialog>\n `;\n }\n\n protected override firstUpdated() {\n this.intersectionObserver = new IntersectionObserver(\n entries => {\n for (const entry of entries) {\n this.handleAnchorIntersection(entry);\n }\n },\n { root: this.scroller! }\n );\n\n this.intersectionObserver.observe(this.topAnchor!);\n this.intersectionObserver.observe(this.bottomAnchor!);\n }\n\n private handleDialogClick() {\n if (this.nextClickIsFromContent) {\n // Avoid doing a layout calculation below if we know the click came from\n // content.\n this.nextClickIsFromContent = false;\n return;\n }\n\n // Click originated on the backdrop. Native `<dialog>`s will not cancel,\n // but Material dialogs do.\n const preventDefault = !this.dispatchEvent(\n new Event('cancel', { cancelable: true })\n );\n if (preventDefault) {\n return;\n }\n\n this.close();\n }\n\n private handleContentClick() {\n this.nextClickIsFromContent = true;\n }\n\n private handleSubmit(event: SubmitEvent) {\n const form = event.target as HTMLFormElement;\n const { submitter } = event;\n if (form.getAttribute('method') !== 'dialog' || !submitter) {\n return;\n }\n\n // Close reason is the submitter's value attribute, or the dialog's\n // `returnValue` if there is no attribute.\n this.close(submitter.getAttribute('value') ?? this.returnValue);\n }\n\n private handleCancel(event: Event) {\n if (event.target !== this.dialog) {\n // Ignore any cancel events dispatched by content.\n return;\n }\n\n this.escapePressedWithoutCancel = false;\n const preventDefault = !redispatchEvent(this, event);\n // We always prevent default on the original dialog event since we'll\n // animate closing it before it actually closes.\n event.preventDefault();\n if (preventDefault) {\n return;\n }\n\n this.close();\n }\n\n private handleClose() {\n if (!this.escapePressedWithoutCancel) {\n return;\n }\n\n this.escapePressedWithoutCancel = false;\n this.dialog?.dispatchEvent(new Event('cancel', { cancelable: true }));\n }\n\n private handleKeydown(event: KeyboardEvent) {\n if (event.key !== 'Escape') {\n return;\n }\n\n // An escape key was pressed. If a \"close\" event fires next without a\n // \"cancel\" event first, then we know we're in the Chrome v120 bug.\n this.escapePressedWithoutCancel = true;\n // Wait a full task for the cancel/close event listeners to fire, then\n // reset the flag.\n setTimeout(() => {\n this.escapePressedWithoutCancel = false;\n });\n }\n\n private async animateDialog(animation: DialogAnimation) {\n // Always cancel the previous animations. Animations can include `fill`\n // modes that need to be cleared when `quick` is toggled. If not, content\n // that faded out will remain hidden when a `quick` dialog re-opens after\n // previously opening and closing without `quick`.\n this.cancelAnimations?.abort();\n this.cancelAnimations = new AbortController();\n if (this.quick) {\n return;\n }\n\n const { dialog, scrim, container, headline, content, actions } = this;\n if (!dialog || !scrim || !container || !headline || !content || !actions) {\n return;\n }\n\n const {\n container: containerAnimate,\n dialog: dialogAnimate,\n scrim: scrimAnimate,\n headline: headlineAnimate,\n content: contentAnimate,\n actions: actionsAnimate,\n } = animation;\n\n const elementAndAnimation: Array<[Element, DialogAnimationArgs[]]> = [\n [dialog, dialogAnimate ?? []],\n [scrim, scrimAnimate ?? []],\n [container, containerAnimate ?? []],\n [headline, headlineAnimate ?? []],\n [content, contentAnimate ?? []],\n [actions, actionsAnimate ?? []],\n ];\n\n const animations: Animation[] = [];\n for (const [element, animation] of elementAndAnimation) {\n for (const animateArgs of animation) {\n const animation = element.animate(...animateArgs);\n this.cancelAnimations.signal.addEventListener('abort', () => {\n animation.cancel();\n });\n\n animations.push(animation);\n }\n }\n\n await Promise.all(\n animations.map(animation =>\n animation.finished.catch(() => {\n // Ignore intentional AbortErrors when calling `animation.cancel()`.\n })\n )\n );\n }\n\n private handleHeadlineChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n this.hasHeadline = slot.assignedElements().length > 0;\n }\n\n private handleActionsChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n this.hasActions = slot.assignedElements().length > 0;\n }\n\n private handleIconChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n this.hasIcon = slot.assignedElements().length > 0;\n }\n\n private handleAnchorIntersection(entry: IntersectionObserverEntry) {\n const { target, isIntersecting } = entry;\n if (target === this.topAnchor) {\n this.isAtScrollTop = isIntersecting;\n }\n\n if (target === this.bottomAnchor) {\n this.isAtScrollBottom = isIntersecting;\n }\n }\n\n private getIsConnectedPromise() {\n return new Promise<void>(resolve => {\n this.isConnectedPromiseResolve = resolve;\n });\n }\n\n private handleFocusTrapFocus(event: FocusEvent) {\n const [firstFocusableChild, lastFocusableChild] =\n this.getFirstAndLastFocusableChildren();\n if (!firstFocusableChild || !lastFocusableChild) {\n // When a dialog does not have focusable children, the dialog itself\n // receives focus.\n this.dialog?.focus();\n return;\n }\n\n // To determine which child to focus, we need to know which focus trap\n // received focus...\n const isFirstFocusTrap = event.target === this.firstFocusTrap;\n const isLastFocusTrap = !isFirstFocusTrap;\n // ...and where the focus came from (what was previously focused).\n const focusCameFromFirstChild = event.relatedTarget === firstFocusableChild;\n const focusCameFromLastChild = event.relatedTarget === lastFocusableChild;\n // Although this is a focus trap, focus can come from outside the trap.\n // This can happen when elements are programmatically `focus()`'d. It also\n // happens when focus leaves and returns to the window, such as clicking on\n // the browser's URL bar and pressing Tab, or switching focus between\n // iframes.\n const focusCameFromOutsideDialog =\n !focusCameFromFirstChild && !focusCameFromLastChild;\n\n // Focus the dialog's first child when we reach the end of the dialog and\n // focus is moving forward. Or, when focus is moving forwards into the\n // dialog from outside of the window.\n const shouldFocusFirstChild =\n (isLastFocusTrap && focusCameFromLastChild) ||\n (isFirstFocusTrap && focusCameFromOutsideDialog);\n if (shouldFocusFirstChild) {\n firstFocusableChild.focus();\n return;\n }\n\n // Focus the dialog's last child when we reach the beginning of the dialog\n // and focus is moving backward. Or, when focus is moving backwards into the\n // dialog from outside of the window.\n const shouldFocusLastChild =\n (isFirstFocusTrap && focusCameFromFirstChild) ||\n (isLastFocusTrap && focusCameFromOutsideDialog);\n if (shouldFocusLastChild) {\n lastFocusableChild.focus();\n }\n\n // The booleans above are verbose for readability, but code executation\n // won't actually reach here.\n }\n\n private getFirstAndLastFocusableChildren():\n | [HTMLElement, HTMLElement]\n | [null, null] {\n if (!this.treewalker) {\n return [null, null];\n }\n\n let firstFocusableChild: HTMLElement | null = null;\n let lastFocusableChild: HTMLElement | null = null;\n\n // Reset the current node back to the root host element.\n this.treewalker.currentNode = this.treewalker.root;\n while (this.treewalker.nextNode()) {\n // Cast as Element since the TreeWalker filter only accepts Elements.\n const nextChild = this.treewalker.currentNode as Element;\n if (!isFocusable(nextChild)) {\n continue;\n }\n\n if (!firstFocusableChild) {\n firstFocusableChild = nextChild;\n }\n\n lastFocusableChild = nextChild;\n }\n\n // We set lastFocusableChild immediately after finding a\n // firstFocusableChild, which means the pair is either both null or both\n // non-null. Cast since TypeScript does not recognize this.\n return [firstFocusableChild, lastFocusableChild] as\n | [HTMLElement, HTMLElement]\n | [null, null];\n }\n}\n\nfunction isFocusable(element: Element): element is HTMLElement {\n // Check if the element is a known built-in focusable element:\n // - <a> and <area> with `href` attributes.\n // - Form controls that are not disabled.\n // - `contenteditable` elements.\n // - Anything with a non-negative `tabindex`.\n const knownFocusableElements =\n ':is(button,input,select,textarea,object,:is(a,area)[href],[tabindex],[contenteditable=true])';\n const notDisabled = ':not(:disabled,[disabled])';\n const notNegativeTabIndex = ':not([tabindex^=\"-\"])';\n if (\n element.matches(knownFocusableElements + notDisabled + notNegativeTabIndex)\n ) {\n return true;\n }\n\n const isCustomElement = element.localName.includes('-');\n if (!isCustomElement) {\n return false;\n }\n\n // If a custom element does not have a tabindex, it may still be focusable\n // if it delegates focus with a shadow root. We also need to check again if\n // the custom element is a disabled form control.\n if (!element.matches(notDisabled)) {\n return false;\n }\n\n return element.shadowRoot?.delegatesFocus ?? false;\n}\n/* eslint-enable */\n"]}
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/internal/dialog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC1D,OAAO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KAAK,EAAE;6CAA+B;AAE9B;IAAR,KAAK,EAAE;gDAAkC;AAEtB;IAAnB,KAAK,CAAC,WAAW,CAAC;wCAAgD;AAE7C;IAArB,KAAK,CAAC,aAAa,CAAC;yCAAiD;AAE7C;IAAxB,KAAK,CAAC,gBAAgB,CAAC;4CAAoD;AAG5E;IADC,KAAK,CAAC,aAAa,CAAC;8CACgC;AAO5C;IAAR,KAAK,EAAE;2CAA6B;AAE5B;IAAR,KAAK,EAAE;0CAA4B;AAE3B;IAAR,KAAK,EAAE;uCAAyB;AAqdnC,SAAS,WAAW,CAAC,OAAgB;;IACnC,8DAA8D;IAC9D,2CAA2C;IAC3C,yCAAyC;IACzC,gCAAgC;IAChC,6CAA6C;IAC7C,MAAM,sBAAsB,GAC1B,8FAA8F,CAAC;IACjG,MAAM,WAAW,GAAG,4BAA4B,CAAC;IACjD,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;IACpD,IACE,OAAO,CAAC,OAAO,CAAC,sBAAsB,GAAG,WAAW,GAAG,mBAAmB,CAAC,EAC3E;QACA,OAAO,IAAI,CAAC;KACb;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,KAAK,CAAC;KACd;IAED,0EAA0E;IAC1E,2EAA2E;IAC3E,iDAAiD;IACjD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACjC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,MAAA,MAAA,OAAO,CAAC,UAAU,0CAAE,cAAc,mCAAI,KAAK,CAAC;AACrD,CAAC;AACD,mBAAmB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '@material/web/divider/divider.js';\n\nimport { html, isServer, LitElement, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ARIAMixinStrict } from '@material/web/internal/aria/aria.js';\nimport { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';\nimport { redispatchEvent } from '@material/web/internal/events/redispatch-event.js';\n\nimport {\n DIALOG_DEFAULT_CLOSE_ANIMATION,\n DIALOG_DEFAULT_OPEN_ANIMATION,\n DialogAnimation,\n DialogAnimationArgs,\n} from '@material/web/dialog/internal/animations.js';\n\n// Separate variable needed for closure.\nconst dialogBaseClass = mixinDelegatesAria(LitElement);\n\n/**\n * A dialog component.\n *\n * @fires open {Event} Dispatched when the dialog is opening before any animations.\n * @fires opened {Event} Dispatched when the dialog has opened after any animations.\n * @fires close {Event} Dispatched when the dialog is closing before any animations.\n * @fires closed {Event} Dispatched when the dialog has closed after any animations.\n * @fires cancel {Event} Dispatched when the dialog has been canceled by clicking\n * on the scrim or pressing Escape.\n */\n\n/* eslint-disable */\nexport class Dialog extends dialogBaseClass {\n // We do not use `delegatesFocus: true` due to a Chromium bug with\n // selecting text.\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=950357\n\n /**\n * Opens the dialog when set to `true` and closes it when set to `false`.\n */\n @property({ type: Boolean })\n get open() {\n return this.isOpen;\n }\n\n set open(open: boolean) {\n if (open === this.isOpen) {\n return;\n }\n\n this.isOpen = open;\n if (open) {\n this.setAttribute('open', '');\n this.show();\n } else {\n this.removeAttribute('open');\n this.close();\n }\n }\n\n /**\n * Skips the opening and closing animations.\n */\n @property({ type: Boolean }) quick = false;\n\n /**\n * Gets or sets the dialog's return value, usually to indicate which button\n * a user pressed to close it.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue\n */\n @property({ attribute: false }) returnValue = '';\n\n /**\n * The type of dialog for accessibility. Set this to `alert` to announce a\n * dialog as an alert dialog.\n */\n @property() type?: 'alert';\n\n /**\n * Disables focus trapping, which by default keeps keyboard Tab navigation\n * within the dialog.\n *\n * When disabled, after focusing the last element of a dialog, pressing Tab\n * again will release focus from the window back to the browser (such as the\n * URL bar).\n *\n * Focus trapping is recommended for accessibility, and should not typically\n * be disabled. Only turn this off if the use case of a dialog is more\n * accessible without focus trapping.\n */\n @property({ type: Boolean, attribute: 'no-focus-trap' })\n noFocusTrap = false;\n\n @property({ type: Boolean }) allowOverflow = false;\n\n /**\n * Gets the opening animation for a dialog. Set to a new function to customize\n * the animation.\n */\n getOpenAnimation = () => DIALOG_DEFAULT_OPEN_ANIMATION;\n\n /**\n * Gets the closing animation for a dialog. Set to a new function to customize\n * the animation.\n */\n getCloseAnimation = () => DIALOG_DEFAULT_CLOSE_ANIMATION;\n\n private isOpen = false;\n\n private isOpening = false;\n\n // getIsConnectedPromise() immediately sets the resolve property.\n private isConnectedPromiseResolve!: () => void;\n\n private isConnectedPromise = this.getIsConnectedPromise();\n\n @query('dialog') private readonly dialog!: HTMLDialogElement | null;\n\n @query('.scrim') private readonly scrim!: HTMLDialogElement | null;\n\n @query('.container') private readonly container!: HTMLDialogElement | null;\n\n @query('.headline') private readonly headline!: HTMLDialogElement | null;\n\n @query('.content') private readonly content!: HTMLDialogElement | null;\n\n @query('.actions') private readonly actions!: HTMLDialogElement | null;\n\n @state() private isAtScrollTop = false;\n\n @state() private isAtScrollBottom = false;\n\n @query('.scroller') private readonly scroller!: HTMLElement | null;\n\n @query('.top.anchor') private readonly topAnchor!: HTMLElement | null;\n\n @query('.bottom.anchor') private readonly bottomAnchor!: HTMLElement | null;\n\n @query('.focus-trap')\n private readonly firstFocusTrap!: HTMLElement | null;\n\n private nextClickIsFromContent = false;\n\n private intersectionObserver?: IntersectionObserver;\n\n // Dialogs should not be SSR'd while open, so we can just use runtime checks.\n @state() private hasHeadline = false;\n\n @state() private hasActions = false;\n\n @state() private hasIcon = false;\n\n private cancelAnimations?: AbortController;\n\n // See https://bugs.chromium.org/p/chromium/issues/detail?id=1512224\n // Chrome v120 has a bug where escape keys do not trigger cancels. If we get\n // a dialog \"close\" event that is triggered without a \"cancel\" after an escape\n // keydown, then we need to manually trigger our closing logic.\n //\n // This bug occurs when pressing escape to close a dialog without first\n // interacting with the dialog's content.\n //\n // Cleanup tracking:\n // https://github.com/material-components/material-web/issues/5330\n // This can be removed when full CloseWatcher support added and the above bug\n // in Chromium is fixed to fire 'cancel' with one escape press and close with\n // multiple.\n private escapePressedWithoutCancel = false;\n\n // This TreeWalker is used to walk through a dialog's children to find\n // focusable elements. TreeWalker is faster than `querySelectorAll('*')`.\n // We check for isServer because there isn't a \"document\" during an SSR\n // run.\n private readonly treewalker = isServer\n ? null\n : document.createTreeWalker(this, NodeFilter.SHOW_ELEMENT);\n\n constructor() {\n super();\n if (!isServer) {\n this.addEventListener('submit', this.handleSubmit);\n }\n }\n\n /**\n * Opens the dialog and fires a cancelable `open` event. After a dialog's\n * animation, an `opened` event is fired.\n *\n * Add an `autofocus` attribute to a child of the dialog that should\n * receive focus after opening.\n *\n * @return A Promise that resolves after the animation is finished and the\n * `opened` event was fired.\n */\n async show() {\n this.isOpening = true;\n // Dialogs can be opened before being attached to the DOM, so we need to\n // wait until we're connected before calling `showModal()`.\n await this.isConnectedPromise;\n await this.updateComplete;\n const dialog = this.dialog!;\n // Check if already opened or if `dialog.close()` was called while awaiting.\n if (dialog.open || !this.isOpening) {\n this.isOpening = false;\n return;\n }\n\n const preventOpen = !this.dispatchEvent(\n new Event('open', { cancelable: true })\n );\n if (preventOpen) {\n this.open = false;\n this.isOpening = false;\n return;\n }\n\n // All Material dialogs are modal.\n dialog.showModal();\n this.open = true;\n // Reset scroll position if re-opening a dialog with the same content.\n if (this.scroller) {\n this.scroller.scrollTop = 0;\n }\n // Native modal dialogs ignore autofocus and instead force focus to the\n // first focusable child. Override this behavior if there is a child with\n // an autofocus attribute.\n this.querySelector<HTMLElement>('[autofocus]')?.focus();\n\n await this.animateDialog(this.getOpenAnimation());\n this.dispatchEvent(new Event('opened'));\n this.isOpening = false;\n }\n\n /**\n * Closes the dialog and fires a cancelable `close` event. After a dialog's\n * animation, a `closed` event is fired.\n *\n * @param returnValue A return value usually indicating which button was used\n * to close a dialog. If a dialog is canceled by clicking the scrim or\n * pressing Escape, it will not change the return value after closing.\n * @return A Promise that resolves after the animation is finished and the\n * `closed` event was fired.\n */\n async close(returnValue = this.returnValue) {\n this.isOpening = false;\n if (!this.isConnected) {\n // Disconnected dialogs do not fire close events or animate.\n this.open = false;\n return;\n }\n\n await this.updateComplete;\n const dialog = this.dialog!;\n // Check if already closed or if `dialog.show()` was called while awaiting.\n if (!dialog.open || this.isOpening) {\n this.open = false;\n return;\n }\n\n const prevReturnValue = this.returnValue;\n this.returnValue = returnValue;\n const preventClose = !this.dispatchEvent(\n new Event('close', { cancelable: true })\n );\n if (preventClose) {\n this.returnValue = prevReturnValue;\n return;\n }\n\n await this.animateDialog(this.getCloseAnimation());\n dialog.close(returnValue);\n this.open = false;\n this.dispatchEvent(new Event('closed'));\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.isConnectedPromiseResolve();\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.isConnectedPromise = this.getIsConnectedPromise();\n }\n\n protected override render() {\n const scrollable =\n this.open && !(this.isAtScrollTop && this.isAtScrollBottom);\n const classes = {\n 'has-headline': this.hasHeadline,\n 'has-actions': this.hasActions,\n 'has-icon': this.hasIcon,\n scrollable: scrollable,\n 'show-top-divider': scrollable && !this.isAtScrollTop,\n 'show-bottom-divider': scrollable && !this.isAtScrollBottom,\n 'allow-overflow': this.allowOverflow,\n };\n\n // The focus trap sentinels are only added after the dialog opens, since\n // dialog.showModal() will try to autofocus them, even with tabindex=\"-1\".\n const showFocusTrap = this.open && !this.noFocusTrap;\n const focusTrap = html`\n <div\n class=\"focus-trap\"\n tabindex=\"0\"\n aria-hidden=\"true\"\n @focus=${this.handleFocusTrapFocus}\n ></div>\n `;\n\n const { ariaLabel } = this as ARIAMixinStrict;\n return html`\n <div class=\"scrim\"></div>\n <dialog\n class=${classMap(classes)}\n aria-label=${ariaLabel || nothing}\n aria-labelledby=${this.hasHeadline ? 'headline' : nothing}\n role=${this.type === 'alert' ? 'alertdialog' : nothing}\n @cancel=${this.handleCancel}\n @click=${this.handleDialogClick}\n @close=${this.handleClose}\n @keydown=${this.handleKeydown}\n .returnValue=${this.returnValue || nothing}\n >\n ${showFocusTrap ? focusTrap : nothing}\n <div class=\"container\" @click=${this.handleContentClick}>\n <div class=\"headline\">\n <div class=\"icon\" aria-hidden=\"true\">\n <slot name=\"icon\" @slotchange=${this.handleIconChange}></slot>\n </div>\n <h2 id=\"headline\" aria-hidden=${!this.hasHeadline || nothing}>\n <slot\n name=\"headline\"\n @slotchange=${this.handleHeadlineChange}\n ></slot>\n </h2>\n <md-divider></md-divider>\n </div>\n <div class=\"scroller\">\n <div class=\"content\">\n <div class=\"top anchor\"></div>\n <slot name=\"content\"></slot>\n <div class=\"bottom anchor\"></div>\n </div>\n </div>\n <div class=\"actions\">\n <md-divider></md-divider>\n <slot name=\"actions\" @slotchange=${this.handleActionsChange}></slot>\n </div>\n </div>\n ${showFocusTrap ? focusTrap : nothing}\n </dialog>\n `;\n }\n\n protected override firstUpdated() {\n this.intersectionObserver = new IntersectionObserver(\n entries => {\n for (const entry of entries) {\n this.handleAnchorIntersection(entry);\n }\n },\n { root: this.scroller! }\n );\n\n this.intersectionObserver.observe(this.topAnchor!);\n this.intersectionObserver.observe(this.bottomAnchor!);\n }\n\n private handleDialogClick() {\n if (this.nextClickIsFromContent) {\n // Avoid doing a layout calculation below if we know the click came from\n // content.\n this.nextClickIsFromContent = false;\n return;\n }\n\n // Click originated on the backdrop. Native `<dialog>`s will not cancel,\n // but Material dialogs do.\n const preventDefault = !this.dispatchEvent(\n new Event('cancel', { cancelable: true })\n );\n if (preventDefault) {\n return;\n }\n\n this.close();\n }\n\n private handleContentClick() {\n this.nextClickIsFromContent = true;\n }\n\n private handleSubmit(event: SubmitEvent) {\n const form = event.target as HTMLFormElement;\n const { submitter } = event;\n if (form.getAttribute('method') !== 'dialog' || !submitter) {\n return;\n }\n\n // Close reason is the submitter's value attribute, or the dialog's\n // `returnValue` if there is no attribute.\n this.close(submitter.getAttribute('value') ?? this.returnValue);\n }\n\n private handleCancel(event: Event) {\n if (event.target !== this.dialog) {\n // Ignore any cancel events dispatched by content.\n return;\n }\n\n this.escapePressedWithoutCancel = false;\n const preventDefault = !redispatchEvent(this, event);\n // We always prevent default on the original dialog event since we'll\n // animate closing it before it actually closes.\n event.preventDefault();\n if (preventDefault) {\n return;\n }\n\n this.close();\n }\n\n private handleClose() {\n if (!this.escapePressedWithoutCancel) {\n return;\n }\n\n this.escapePressedWithoutCancel = false;\n this.dialog?.dispatchEvent(new Event('cancel', { cancelable: true }));\n }\n\n private handleKeydown(event: KeyboardEvent) {\n if (event.key !== 'Escape') {\n return;\n }\n\n // An escape key was pressed. If a \"close\" event fires next without a\n // \"cancel\" event first, then we know we're in the Chrome v120 bug.\n this.escapePressedWithoutCancel = true;\n // Wait a full task for the cancel/close event listeners to fire, then\n // reset the flag.\n setTimeout(() => {\n this.escapePressedWithoutCancel = false;\n });\n }\n\n private async animateDialog(animation: DialogAnimation) {\n // Always cancel the previous animations. Animations can include `fill`\n // modes that need to be cleared when `quick` is toggled. If not, content\n // that faded out will remain hidden when a `quick` dialog re-opens after\n // previously opening and closing without `quick`.\n this.cancelAnimations?.abort();\n this.cancelAnimations = new AbortController();\n if (this.quick) {\n return;\n }\n\n const { dialog, scrim, container, headline, content, actions } = this;\n if (!dialog || !scrim || !container || !headline || !content || !actions) {\n return;\n }\n\n const {\n container: containerAnimate,\n dialog: dialogAnimate,\n scrim: scrimAnimate,\n headline: headlineAnimate,\n content: contentAnimate,\n actions: actionsAnimate,\n } = animation;\n\n const elementAndAnimation: Array<[Element, DialogAnimationArgs[]]> = [\n [dialog, dialogAnimate ?? []],\n [scrim, scrimAnimate ?? []],\n [container, containerAnimate ?? []],\n [headline, headlineAnimate ?? []],\n [content, contentAnimate ?? []],\n [actions, actionsAnimate ?? []],\n ];\n\n const animations: Animation[] = [];\n for (const [element, animation] of elementAndAnimation) {\n for (const animateArgs of animation) {\n const animation = element.animate(...animateArgs);\n this.cancelAnimations.signal.addEventListener('abort', () => {\n animation.cancel();\n });\n\n animations.push(animation);\n }\n }\n\n await Promise.all(\n animations.map(animation =>\n animation.finished.catch(() => {\n // Ignore intentional AbortErrors when calling `animation.cancel()`.\n })\n )\n );\n }\n\n private handleHeadlineChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n this.hasHeadline = slot.assignedElements().length > 0;\n }\n\n private handleActionsChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n this.hasActions = slot.assignedElements().length > 0;\n }\n\n private handleIconChange(event: Event) {\n const slot = event.target as HTMLSlotElement;\n this.hasIcon = slot.assignedElements().length > 0;\n }\n\n private handleAnchorIntersection(entry: IntersectionObserverEntry) {\n const { target, isIntersecting } = entry;\n if (target === this.topAnchor) {\n this.isAtScrollTop = isIntersecting;\n }\n\n if (target === this.bottomAnchor) {\n this.isAtScrollBottom = isIntersecting;\n }\n }\n\n private getIsConnectedPromise() {\n return new Promise<void>(resolve => {\n this.isConnectedPromiseResolve = resolve;\n });\n }\n\n private handleFocusTrapFocus(event: FocusEvent) {\n const [firstFocusableChild, lastFocusableChild] =\n this.getFirstAndLastFocusableChildren();\n if (!firstFocusableChild || !lastFocusableChild) {\n // When a dialog does not have focusable children, the dialog itself\n // receives focus.\n this.dialog?.focus();\n return;\n }\n\n // To determine which child to focus, we need to know which focus trap\n // received focus...\n const isFirstFocusTrap = event.target === this.firstFocusTrap;\n const isLastFocusTrap = !isFirstFocusTrap;\n // ...and where the focus came from (what was previously focused).\n const focusCameFromFirstChild = event.relatedTarget === firstFocusableChild;\n const focusCameFromLastChild = event.relatedTarget === lastFocusableChild;\n // Although this is a focus trap, focus can come from outside the trap.\n // This can happen when elements are programmatically `focus()`'d. It also\n // happens when focus leaves and returns to the window, such as clicking on\n // the browser's URL bar and pressing Tab, or switching focus between\n // iframes.\n const focusCameFromOutsideDialog =\n !focusCameFromFirstChild && !focusCameFromLastChild;\n\n // Focus the dialog's first child when we reach the end of the dialog and\n // focus is moving forward. Or, when focus is moving forwards into the\n // dialog from outside of the window.\n const shouldFocusFirstChild =\n (isLastFocusTrap && focusCameFromLastChild) ||\n (isFirstFocusTrap && focusCameFromOutsideDialog);\n if (shouldFocusFirstChild) {\n firstFocusableChild.focus();\n return;\n }\n\n // Focus the dialog's last child when we reach the beginning of the dialog\n // and focus is moving backward. Or, when focus is moving backwards into the\n // dialog from outside of the window.\n const shouldFocusLastChild =\n (isFirstFocusTrap && focusCameFromFirstChild) ||\n (isLastFocusTrap && focusCameFromOutsideDialog);\n if (shouldFocusLastChild) {\n lastFocusableChild.focus();\n }\n\n // The booleans above are verbose for readability, but code executation\n // won't actually reach here.\n }\n\n private getFirstAndLastFocusableChildren():\n | [HTMLElement, HTMLElement]\n | [null, null] {\n if (!this.treewalker) {\n return [null, null];\n }\n\n let firstFocusableChild: HTMLElement | null = null;\n let lastFocusableChild: HTMLElement | null = null;\n\n // Reset the current node back to the root host element.\n this.treewalker.currentNode = this.treewalker.root;\n while (this.treewalker.nextNode()) {\n // Cast as Element since the TreeWalker filter only accepts Elements.\n const nextChild = this.treewalker.currentNode as Element;\n if (!isFocusable(nextChild)) {\n continue;\n }\n\n if (!firstFocusableChild) {\n firstFocusableChild = nextChild;\n }\n\n lastFocusableChild = nextChild;\n }\n\n // We set lastFocusableChild immediately after finding a\n // firstFocusableChild, which means the pair is either both null or both\n // non-null. Cast since TypeScript does not recognize this.\n return [firstFocusableChild, lastFocusableChild] as\n | [HTMLElement, HTMLElement]\n | [null, null];\n }\n}\n\nfunction isFocusable(element: Element): element is HTMLElement {\n // Check if the element is a known built-in focusable element:\n // - <a> and <area> with `href` attributes.\n // - Form controls that are not disabled.\n // - `contenteditable` elements.\n // - Anything with a non-negative `tabindex`.\n const knownFocusableElements =\n ':is(button,input,select,textarea,object,:is(a,area)[href],[tabindex],[contenteditable=true])';\n const notDisabled = ':not(:disabled,[disabled])';\n const notNegativeTabIndex = ':not([tabindex^=\"-\"])';\n if (\n element.matches(knownFocusableElements + notDisabled + notNegativeTabIndex)\n ) {\n return true;\n }\n\n const isCustomElement = element.localName.includes('-');\n if (!isCustomElement) {\n return false;\n }\n\n // If a custom element does not have a tabindex, it may still be focusable\n // if it delegates focus with a shadow root. We also need to check again if\n // the custom element is a disabled form control.\n if (!element.matches(notDisabled)) {\n return false;\n }\n\n return element.shadowRoot?.delegatesFocus ?? false;\n}\n/* eslint-enable */\n"]}
|
package/dist/ix-dialog.min.js
CHANGED
|
@@ -1,45 +1,507 @@
|
|
|
1
|
-
import{css,LitElement,isServer,html,nothing,render}from"lit";import{__decorate}from"tslib";import{mixinElementInternals}from"@material/web/labs/behaviors/element-internals.js";import{AriaForwardMixin}from"@digital-realty/ix-shared-fns/aria-forward-mixin.js";import{spread}from"@open-wc/lit-helpers";import{property,query,state}from"lit/decorators.js";import{createRef,ref}from"lit/directives/ref.js";import"@material/web/divider/divider.js";import{classMap}from"lit/directives/class-map.js";import{mixinDelegatesAria}from"@material/web/internal/aria/delegate.js";import{redispatchEvent}from"@material/web/internal/events/redispatch-event.js";import{DIALOG_DEFAULT_OPEN_ANIMATION,DIALOG_DEFAULT_CLOSE_ANIMATION}from"@material/web/dialog/internal/animations.js";let IxDialogStyles=css`:host{display:contents}dialog{border:none;padding:0;margin:auto;max-width:90vw;max-height:90dvh;width:auto;background:0 0}dialog::backdrop{background:rgba(0,0,0,.32)}.container{box-sizing:border-box;background:var(--ix-dialog-bg,#fff);color:var(--ix-dialog-fg,inherit);border-radius:var(--ix-dialog-radius,.1875rem);max-width:var(--ix-dialog-max-width,45rem);overflow:hidden;box-shadow:var(--ix-dialog-shadow,0 12px 16px 0 rgba(0,0,0,.58))}.headline{padding:24px 24px 0 24px;font:var(--ix-dialog-headline-font,600 1.125rem/1.2 system-ui,sans-serif)}.content{padding:0;overflow:auto}.actions{display:flex;gap:.5rem;justify-content:flex-end}`,dialogBaseClass=mixinDelegatesAria(LitElement);class Dialog extends dialogBaseClass{get open(){return this.isOpen}set open(e){e!==this.isOpen&&((this.isOpen=e)?(this.setAttribute("open",""),this.show()):(this.removeAttribute("open"),this.close()))}constructor(){super(),this.quick=!1,this.returnValue="",this.noFocusTrap=!1,this.allowOverflow=!1,this.getOpenAnimation=()=>DIALOG_DEFAULT_OPEN_ANIMATION,this.getCloseAnimation=()=>DIALOG_DEFAULT_CLOSE_ANIMATION,this.isOpen=!1,this.isOpening=!1,this.isConnectedPromise=this.getIsConnectedPromise(),this.isAtScrollTop=!1,this.isAtScrollBottom=!1,this.nextClickIsFromContent=!1,this.hasHeadline=!1,this.hasActions=!1,this.hasIcon=!1,this.escapePressedWithoutCancel=!1,this.treewalker=isServer?null:document.createTreeWalker(this,NodeFilter.SHOW_ELEMENT),isServer||this.addEventListener("submit",this.handleSubmit)}async show(){this.isOpening=!0,await this.isConnectedPromise,await this.updateComplete;var e=this.dialog;!e.open&&this.isOpening&&(!this.dispatchEvent(new Event("open",{cancelable:!0}))?this.open=!1:(e.showModal(),this.open=!0,this.scroller&&(this.scroller.scrollTop=0),null!=(e=this.querySelector("[autofocus]"))&&e.focus(),await this.animateDialog(this.getOpenAnimation()),this.dispatchEvent(new Event("opened")))),this.isOpening=!1}async close(e=this.returnValue){var t,o;this.isOpening=!1,!this.isConnected||(await this.updateComplete,!(t=this.dialog).open)||this.isOpening?this.open=!1:(o=this.returnValue,this.returnValue=e,!this.dispatchEvent(new Event("close",{cancelable:!0}))?this.returnValue=o:(await this.animateDialog(this.getCloseAnimation()),t.close(e),this.open=!1,this.dispatchEvent(new Event("closed"))))}connectedCallback(){super.connectedCallback(),this.isConnectedPromiseResolve()}disconnectedCallback(){super.disconnectedCallback(),this.isConnectedPromise=this.getIsConnectedPromise()}render(){var e=this.open&&!(this.isAtScrollTop&&this.isAtScrollBottom),e={"has-headline":this.hasHeadline,"has-actions":this.hasActions,"has-icon":this.hasIcon,scrollable:e,"show-top-divider":e&&!this.isAtScrollTop,"show-bottom-divider":e&&!this.isAtScrollBottom,"allow-overflow":this.allowOverflow},t=this.open&&!this.noFocusTrap,o=html`<div class="focus-trap" tabindex="0" aria-hidden="true" @focus="${this.handleFocusTrapFocus}"></div>`,i=this.ariaLabel;return html`<div class="scrim"></div><dialog class="${classMap(e)}" aria-label="${i||nothing}" aria-labelledby="${this.hasHeadline?"headline":nothing}" role="${"alert"===this.type?"alertdialog":nothing}" @cancel="${this.handleCancel}" @click="${this.handleDialogClick}" @close="${this.handleClose}" @keydown="${this.handleKeydown}" .returnValue="${this.returnValue||nothing}">${t?o:nothing}<div class="container" @click="${this.handleContentClick}"><div class="headline"><div class="icon" aria-hidden="true"><slot name="icon" @slotchange="${this.handleIconChange}"></slot></div><h2 id="headline" aria-hidden="${!this.hasHeadline||nothing}"><slot name="headline" @slotchange="${this.handleHeadlineChange}"></slot></h2><md-divider></md-divider></div><div class="scroller"><div class="content"><div class="top anchor"></div><slot name="content"></slot><div class="bottom anchor"></div></div></div><div class="actions"><md-divider></md-divider><slot name="actions" @slotchange="${this.handleActionsChange}"></slot></div></div>${t?o:nothing}</dialog>`}firstUpdated(){this.intersectionObserver=new IntersectionObserver(e=>{for(var t of e)this.handleAnchorIntersection(t)},{root:this.scroller}),this.intersectionObserver.observe(this.topAnchor),this.intersectionObserver.observe(this.bottomAnchor)}handleDialogClick(){this.nextClickIsFromContent?this.nextClickIsFromContent=!1:this.dispatchEvent(new Event("cancel",{cancelable:!0}))&&this.close()}handleContentClick(){this.nextClickIsFromContent=!0}handleSubmit(e){var t=e.submitter;"dialog"===e.target.getAttribute("method")&&t&&this.close(null!=(e=t.getAttribute("value"))?e:this.returnValue)}handleCancel(e){var t;e.target!==this.dialog||(this.escapePressedWithoutCancel=!1,t=!redispatchEvent(this,e),e.preventDefault(),t)||this.close()}handleClose(){var e;this.escapePressedWithoutCancel&&(this.escapePressedWithoutCancel=!1,null!=(e=this.dialog))&&e.dispatchEvent(new Event("cancel",{cancelable:!0}))}handleKeydown(e){"Escape"===e.key&&(this.escapePressedWithoutCancel=!0,setTimeout(()=>{this.escapePressedWithoutCancel=!1}))}async animateDialog(e){if(null!=(o=this.cancelAnimations)&&o.abort(),this.cancelAnimations=new AbortController,!this.quick){var{dialog:o,scrim:i,container:a,headline:n,content:s,actions:l}=this;if(o&&i&&a&&n&&s&&l){var{container:r,dialog:d,scrim:c,headline:h,content:p,actions:g}=e,v=[];for(let[t,e]of[[o,null!=d?d:[]],[i,null!=c?c:[]],[a,null!=r?r:[]],[n,null!=h?h:[]],[s,null!=p?p:[]],[l,null!=g?g:[]]])for(var m of e){let e=t.animate(...m);this.cancelAnimations.signal.addEventListener("abort",()=>{e.cancel()}),v.push(e)}await Promise.all(v.map(e=>e.finished.catch(()=>{})))}}}handleHeadlineChange(e){e=e.target;this.hasHeadline=0<e.assignedElements().length}handleActionsChange(e){e=e.target;this.hasActions=0<e.assignedElements().length}handleIconChange(e){e=e.target;this.hasIcon=0<e.assignedElements().length}handleAnchorIntersection(e){var{target:e,isIntersecting:t}=e;e===this.topAnchor&&(this.isAtScrollTop=t),e===this.bottomAnchor&&(this.isAtScrollBottom=t)}getIsConnectedPromise(){return new Promise(e=>{this.isConnectedPromiseResolve=e})}handleFocusTrapFocus(e){var t,o,i,a,[n,s]=this.getFirstAndLastFocusableChildren();n&&s?(t=e.target===this.firstFocusTrap,i=e.relatedTarget===s,a=!(e=e.relatedTarget===n)&&!i,(o=!t)&&i||t&&a?n.focus():(t&&e||o&&a)&&s.focus()):null!=(i=this.dialog)&&i.focus()}getFirstAndLastFocusableChildren(){if(!this.treewalker)return[null,null];let e=null,t=null;for(this.treewalker.currentNode=this.treewalker.root;this.treewalker.nextNode();){var o=this.treewalker.currentNode;isFocusable(o)&&(e=e||o,t=o)}return[e,t]}}function isFocusable(e){var t=":not(:disabled,[disabled])";return!!e.matches(":is(button,input,select,textarea,object,:is(a,area)[href],[tabindex],[contenteditable=true])"+t+':not([tabindex^="-"])')||!!e.localName.includes("-")&&!!e.matches(t)&&null!=(e=null==(t=e.shadowRoot)?void 0:t.delegatesFocus)&&e}__decorate([property({type:Boolean})],Dialog.prototype,"open",null),__decorate([property({type:Boolean})],Dialog.prototype,"quick",void 0),__decorate([property({attribute:!1})],Dialog.prototype,"returnValue",void 0),__decorate([property()],Dialog.prototype,"type",void 0),__decorate([property({type:Boolean,attribute:"no-focus-trap"})],Dialog.prototype,"noFocusTrap",void 0),__decorate([property({type:Boolean})],Dialog.prototype,"allowOverflow",void 0),__decorate([query("dialog")],Dialog.prototype,"dialog",void 0),__decorate([query(".scrim")],Dialog.prototype,"scrim",void 0),__decorate([query(".container")],Dialog.prototype,"container",void 0),__decorate([query(".headline")],Dialog.prototype,"headline",void 0),__decorate([query(".content")],Dialog.prototype,"content",void 0),__decorate([query(".actions")],Dialog.prototype,"actions",void 0),__decorate([state()],Dialog.prototype,"isAtScrollTop",void 0),__decorate([state()],Dialog.prototype,"isAtScrollBottom",void 0),__decorate([query(".scroller")],Dialog.prototype,"scroller",void 0),__decorate([query(".top.anchor")],Dialog.prototype,"topAnchor",void 0),__decorate([query(".bottom.anchor")],Dialog.prototype,"bottomAnchor",void 0),__decorate([query(".focus-trap")],Dialog.prototype,"firstFocusTrap",void 0),__decorate([state()],Dialog.prototype,"hasHeadline",void 0),__decorate([state()],Dialog.prototype,"hasActions",void 0),__decorate([state()],Dialog.prototype,"hasIcon",void 0);let styles=css`:host{border-start-start-radius:var(--md-dialog-container-shape-start-start,var(--md-dialog-container-shape,var(--md-sys-shape-corner-extra-large,28px)));border-start-end-radius:var(--md-dialog-container-shape-start-end,var(--md-dialog-container-shape,var(--md-sys-shape-corner-extra-large,28px)));border-end-end-radius:var(--md-dialog-container-shape-end-end,var(--md-dialog-container-shape,var(--md-sys-shape-corner-extra-large,28px)));border-end-start-radius:var(--md-dialog-container-shape-end-start,var(--md-dialog-container-shape,var(--md-sys-shape-corner-extra-large,28px)));display:contents;margin:auto;max-height:min(560px,100% - 48px);max-width:min(560px,100% - 48px);min-width:280px;position:fixed;height:fit-content;width:fit-content}dialog{background:rgba(0,0,0,0);border:none;border-radius:inherit;box-shadow:0 12px 16px 0 rgba(0,0,0,.58);flex-direction:column;height:inherit;margin:inherit;max-height:inherit;max-width:inherit;min-height:inherit;min-width:inherit;outline:0;overflow:visible;padding:0;width:inherit}dialog[open]{display:block}::backdrop{background:rgba(0,0,0,.5)}h2{all:unset;align-self:stretch}.headline{align-items:center;color:var(--md-dialog-headline-color,var(--md-sys-color-on-surface,#1d1b20));display:flex;flex-direction:column;font-family:var(--md-dialog-headline-font,var(--md-sys-typescale-headline-small-font,var(--md-ref-typeface-brand,Roboto)));font-size:var(--md-dialog-headline-size,var(--md-sys-typescale-headline-small-size,1.5rem));line-height:var(--md-dialog-headline-line-height,var(--md-sys-typescale-headline-small-line-height,2rem));font-weight:var(--md-dialog-headline-weight,var(--md-sys-typescale-headline-small-weight,var(--md-ref-typeface-weight-regular,400)));position:relative}slot[name=headline]::slotted(*){align-items:center;align-self:stretch;box-sizing:border-box;display:flex;gap:8px;padding:24px 24px 0}.icon{display:flex}slot[name=icon]::slotted(*){color:var(--md-dialog-icon-color,var(--md-sys-color-secondary,#625b71));fill:currentColor;font-size:var(--md-dialog-icon-size,24px);margin-top:24px;height:var(--md-dialog-icon-size,24px);width:var(--md-dialog-icon-size,24px)}.has-icon slot[name=headline]::slotted(*){justify-content:center;padding-top:16px}.scrollable slot[name=headline]::slotted(*){padding-bottom:16px}.scrollable.has-headline slot[name=content]::slotted(*){padding-top:8px}.container{border-radius:inherit;display:flex;flex-direction:column;flex-grow:1;overflow:hidden;position:relative;transform-origin:top}.allow-overflow .container{overflow:visible}.container::before{background:var(--md-dialog-container-color,var(--md-sys-color-surface-container-high,#ece6f0));border-radius:inherit;content:'';inset:0;position:absolute}.scroller{display:flex;flex:1;flex-direction:column;overflow:initial;z-index:1}.scrollable .scroller{overflow-y:scroll}.content{color:var(--clr-on-surface,#092241);font-family:var(--text-default-font,sans-serif);font-size:var(--text-default-size,16px);letter-spacing:var(--text-default-letter-spacing,.0275em);line-height:var(--text-default-line-height,1.75em);font-weight:var(--text-default-weight,normal);text-transform:var(--text-default-decoration,none);text-decoration:var(--text-default-transform,none);height:min-content;position:relative}slot[name=content]::slotted(*){box-sizing:border-box;padding:24px}.anchor{position:absolute}.top.anchor{top:0}.bottom.anchor{bottom:0}.actions{position:relative}slot[name=actions]::slotted(*){box-sizing:border-box;display:flex;gap:8px;justify-content:flex-end;padding:16px 24px 24px}.has-actions slot[name=content]::slotted(*){padding-bottom:8px}md-divider{display:none;position:absolute}.has-actions.show-bottom-divider .actions md-divider,.has-headline.show-top-divider .headline md-divider{display:flex}.headline md-divider{bottom:0}.actions md-divider{top:0}@media (forced-colors:active){dialog{outline:2px solid WindowText}}`;class MdDialog extends Dialog{}MdDialog.styles=[styles],window.customElements.define("md-dialog",MdDialog);let ixDialogBaseClass=AriaForwardMixin(mixinElementInternals(LitElement));class IxDialog extends ixDialogBaseClass{constructor(){super(...arguments),this.open=!1,this.preventCancel=!1,this.preventCloseOnScrimClick=!1,this.disableNextClickIsFromContent=!1,this.useNativeDialog=!1,this.allowOverflow=!1,this.nativeClosing=!1,this.dialogRef=createRef(),this.containerRef=createRef(),this.pointerDownInside=!1,this.isScrollLocked=!1,this.scrollYBackup=0,this.onKeydown=e=>{var t;"Escape"===e.key&&(this.preventCancel||(t=new Event("cancel",{bubbles:!0,composed:!0,cancelable:!0}),!this.dispatchEvent(t))?e.preventDefault():this.requestClose())},this.onNativeCancel=e=>{var t=new Event("cancel",{bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t)?this.requestClose():e.preventDefault()},this.onScrimClick=()=>{this.preventCloseOnScrimClick||this.requestClose()}}get nativeDialog(){var e;return null!=(e=this.dialogRef.value)?e:null}get nativeDialogContainer(){var e;return null!=(e=this.containerRef.value)?e:null}connectedCallback(){super.connectedCallback(),this.mo=new MutationObserver(()=>{this.useNativeDialog&&this.open&&this.populatePortal()}),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}disconnectedCallback(){var e;super.disconnectedCallback(),null!=(e=this.mo)&&e.disconnect(),this.unlockScroll(),this.teardownPortal()}updated(e){this.useNativeDialog&&e.has("open")&&(this.open?(this.ensurePortal(),this.portalRoot&&(this.attachPortalStyles(),render(this.portalTemplate(),this.portalRoot),this.populatePortal()),this.nativeClosing&&(this.nativeClosing=!1,null!=(e=this.nativeDialogContainer)&&e.classList.remove("closing"),this.nativeOnEnd&&this.nativeDialogContainer&&this.nativeDialogContainer.removeEventListener("animationend",this.nativeOnEnd),this.nativeOnEnd=void 0),this.dispatchEvent(new Event("open",{bubbles:!0,composed:!0})),this.lockScroll(),requestAnimationFrame(()=>{var e;null!=(e=this.nativeDialog)&&e.show(),requestAnimationFrame(()=>{this.dispatchEvent(new Event("opened",{bubbles:!0,composed:!0}))})})):this.startNativeCloseAnimation())}dismiss(){this.open&&Promise.resolve().then(()=>{this.requestClose()})}startNativeCloseAnimation(){if(!this.nativeClosing){this.nativeClosing=!0,this.dispatchEvent(new Event("close",{bubbles:!0,composed:!0}));let o=()=>{var e;null!=(e=this.nativeDialogContainer)&&e.classList.remove("closing"),this.nativeClosing=!1,null!=(e=this.nativeDialog)&&e.close(),this.unlockScroll(),this.dispatchEvent(new Event("closed",{bubbles:!0,composed:!0})),this.moveNodesBackFromPortal(),this.teardownPortal()},i=this.nativeDialogContainer;if(i){i.classList.add("closing");let e=!1,t=()=>{e||(e=!0,i.removeEventListener("animationend",t),o())};this.nativeOnEnd=t,i.addEventListener("animationend",t,{once:!0}),window.setTimeout(t,1)}else o()}}ensurePortal(){var e,t;this.portalRoot||(t=(e=document.createElement("ix-dialog-portal-host")).attachShadow({mode:"open"}),this.shadowRoot&&"adoptedStyleSheets"in this.shadowRoot&&(t.adoptedStyleSheets=this.shadowRoot.adoptedStyleSheets),document.body.appendChild(e),this.portalHost=e,this.portalRoot=t)}attachPortalStyles(){var e,t,o;this.portalRoot&&!this.portalStyleEl&&(e=document.createElement("style"),t=`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import{css as e,LitElement as t,isServer as o,html as i,nothing as n,render as a}from"lit";import{__decorate as s}from"tslib";import{mixinElementInternals as r}from"@material/web/labs/behaviors/element-internals.js";import{AriaForwardMixin as l}from"@digital-realty/ix-shared-fns/aria-forward-mixin.js";import{spread as d}from"@open-wc/lit-helpers";import{property as c,query as h,state as p}from"lit/decorators.js";import{createRef as v,ref as m}from"lit/directives/ref.js";import"@material/web/divider/divider.js";import{classMap as u}from"lit/directives/class-map.js";import{mixinDelegatesAria as g}from"@material/web/internal/aria/delegate.js";import{redispatchEvent as f}from"@material/web/internal/events/redispatch-event.js";import{DIALOG_DEFAULT_OPEN_ANIMATION as b,DIALOG_DEFAULT_CLOSE_ANIMATION as x}from"@material/web/dialog/internal/animations.js";const w=e`
|
|
2
|
+
:host {
|
|
3
|
+
display: contents;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
dialog {
|
|
7
|
+
border: none;
|
|
6
8
|
padding: 0;
|
|
7
|
-
|
|
9
|
+
margin: auto;
|
|
10
|
+
max-width: 90vw;
|
|
11
|
+
max-height: 90dvh;
|
|
12
|
+
width: auto;
|
|
8
13
|
background: transparent;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
dialog::backdrop {
|
|
17
|
+
background: rgba(0, 0, 0, 0.32);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.container {
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
background: var(--ix-dialog-bg, #fff);
|
|
23
|
+
color: var(--ix-dialog-fg, inherit);
|
|
24
|
+
border-radius: var(--ix-dialog-radius, 0.1875rem);
|
|
25
|
+
max-width: var(--ix-dialog-max-width, 45rem);
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
box-shadow: var(--ix-dialog-shadow, 0px 12px 16px 0px rgba(0, 0, 0, 0.58));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.headline {
|
|
31
|
+
padding: 24px 24px 0px 24px;
|
|
32
|
+
font: var(
|
|
33
|
+
--ix-dialog-headline-font,
|
|
34
|
+
600 1.125rem/1.2 system-ui,
|
|
35
|
+
sans-serif
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.content {
|
|
40
|
+
padding: 0;
|
|
41
|
+
overflow: auto;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.actions {
|
|
45
|
+
display: flex;
|
|
46
|
+
gap: 0.5rem;
|
|
47
|
+
justify-content: flex-end;
|
|
48
|
+
}
|
|
49
|
+
`,y=g(t);
|
|
50
|
+
/**
|
|
51
|
+
* @license
|
|
52
|
+
* Copyright 2023 Google LLC
|
|
53
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54
|
+
*/class C extends y{get open(){return this.isOpen}set open(e){e!==this.isOpen&&(this.isOpen=e,e?(this.setAttribute("open",""),this.show()):(this.removeAttribute("open"),this.close()))}constructor(){super(),this.quick=!1,this.returnValue="",this.noFocusTrap=!1,this.allowOverflow=!1,this.getOpenAnimation=()=>b,this.getCloseAnimation=()=>x,this.isOpen=!1,this.isOpening=!1,this.isConnectedPromise=this.getIsConnectedPromise(),this.isAtScrollTop=!1,this.isAtScrollBottom=!1,this.nextClickIsFromContent=!1,this.hasHeadline=!1,this.hasActions=!1,this.hasIcon=!1,this.escapePressedWithoutCancel=!1,this.treewalker=o?null:document.createTreeWalker(this,NodeFilter.SHOW_ELEMENT),o||this.addEventListener("submit",this.handleSubmit)}async show(){var e;this.isOpening=!0,await this.isConnectedPromise,await this.updateComplete;const t=this.dialog;if(t.open||!this.isOpening)return void(this.isOpening=!1);if(!this.dispatchEvent(new Event("open",{cancelable:!0})))return this.open=!1,void(this.isOpening=!1);t.showModal(),this.open=!0,this.scroller&&(this.scroller.scrollTop=0),null===(e=this.querySelector("[autofocus]"))||void 0===e||e.focus(),await this.animateDialog(this.getOpenAnimation()),this.dispatchEvent(new Event("opened")),this.isOpening=!1}async close(e=this.returnValue){if(this.isOpening=!1,!this.isConnected)return void(this.open=!1);await this.updateComplete;const t=this.dialog;if(!t.open||this.isOpening)return void(this.open=!1);const o=this.returnValue;this.returnValue=e;this.dispatchEvent(new Event("close",{cancelable:!0}))?(await this.animateDialog(this.getCloseAnimation()),t.close(e),this.open=!1,this.dispatchEvent(new Event("closed"))):this.returnValue=o}connectedCallback(){super.connectedCallback(),this.isConnectedPromiseResolve()}disconnectedCallback(){super.disconnectedCallback(),this.isConnectedPromise=this.getIsConnectedPromise()}render(){const e=this.open&&!(this.isAtScrollTop&&this.isAtScrollBottom),t={"has-headline":this.hasHeadline,"has-actions":this.hasActions,"has-icon":this.hasIcon,scrollable:e,"show-top-divider":e&&!this.isAtScrollTop,"show-bottom-divider":e&&!this.isAtScrollBottom,"allow-overflow":this.allowOverflow},o=this.open&&!this.noFocusTrap,a=i`
|
|
55
|
+
<div
|
|
56
|
+
class="focus-trap"
|
|
57
|
+
tabindex="0"
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
@focus=${this.handleFocusTrapFocus}
|
|
60
|
+
></div>
|
|
61
|
+
`,{ariaLabel:s}=this;return i`
|
|
62
|
+
<div class="scrim"></div>
|
|
63
|
+
<dialog
|
|
64
|
+
class=${u(t)}
|
|
65
|
+
aria-label=${s||n}
|
|
66
|
+
aria-labelledby=${this.hasHeadline?"headline":n}
|
|
67
|
+
role=${"alert"===this.type?"alertdialog":n}
|
|
68
|
+
@cancel=${this.handleCancel}
|
|
69
|
+
@click=${this.handleDialogClick}
|
|
70
|
+
@close=${this.handleClose}
|
|
71
|
+
@keydown=${this.handleKeydown}
|
|
72
|
+
.returnValue=${this.returnValue||n}
|
|
73
|
+
>
|
|
74
|
+
${o?a:n}
|
|
75
|
+
<div class="container" @click=${this.handleContentClick}>
|
|
76
|
+
<div class="headline">
|
|
77
|
+
<div class="icon" aria-hidden="true">
|
|
78
|
+
<slot name="icon" @slotchange=${this.handleIconChange}></slot>
|
|
79
|
+
</div>
|
|
80
|
+
<h2 id="headline" aria-hidden=${!this.hasHeadline||n}>
|
|
81
|
+
<slot
|
|
82
|
+
name="headline"
|
|
83
|
+
@slotchange=${this.handleHeadlineChange}
|
|
84
|
+
></slot>
|
|
85
|
+
</h2>
|
|
86
|
+
<md-divider></md-divider>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="scroller">
|
|
89
|
+
<div class="content">
|
|
90
|
+
<div class="top anchor"></div>
|
|
91
|
+
<slot name="content"></slot>
|
|
92
|
+
<div class="bottom anchor"></div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
<div class="actions">
|
|
96
|
+
<md-divider></md-divider>
|
|
97
|
+
<slot name="actions" @slotchange=${this.handleActionsChange}></slot>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
${o?a:n}
|
|
101
|
+
</dialog>
|
|
102
|
+
`}firstUpdated(){this.intersectionObserver=new IntersectionObserver(e=>{for(const t of e)this.handleAnchorIntersection(t)},{root:this.scroller}),this.intersectionObserver.observe(this.topAnchor),this.intersectionObserver.observe(this.bottomAnchor)}handleDialogClick(){if(this.nextClickIsFromContent)return void(this.nextClickIsFromContent=!1);!this.dispatchEvent(new Event("cancel",{cancelable:!0}))||this.close()}handleContentClick(){this.nextClickIsFromContent=!0}handleSubmit(e){var t;const o=e.target,{submitter:i}=e;"dialog"===o.getAttribute("method")&&i&&this.close(null!==(t=i.getAttribute("value"))&&void 0!==t?t:this.returnValue)}handleCancel(e){if(e.target!==this.dialog)return;this.escapePressedWithoutCancel=!1;const t=!f(this,e);e.preventDefault(),t||this.close()}handleClose(){var e;this.escapePressedWithoutCancel&&(this.escapePressedWithoutCancel=!1,null===(e=this.dialog)||void 0===e||e.dispatchEvent(new Event("cancel",{cancelable:!0})))}handleKeydown(e){"Escape"===e.key&&(this.escapePressedWithoutCancel=!0,setTimeout(()=>{this.escapePressedWithoutCancel=!1}))}async animateDialog(e){var t;if(null===(t=this.cancelAnimations)||void 0===t||t.abort(),this.cancelAnimations=new AbortController,this.quick)return;const{dialog:o,scrim:i,container:n,headline:a,content:s,actions:r}=this;if(!(o&&i&&n&&a&&s&&r))return;const{container:l,dialog:d,scrim:c,headline:h,content:p,actions:v}=e,m=[[o,null!=d?d:[]],[i,null!=c?c:[]],[n,null!=l?l:[]],[a,null!=h?h:[]],[s,null!=p?p:[]],[r,null!=v?v:[]]],u=[];for(const[e,t]of m)for(const o of t){const t=e.animate(...o);this.cancelAnimations.signal.addEventListener("abort",()=>{t.cancel()}),u.push(t)}await Promise.all(u.map(e=>e.finished.catch(()=>{})))}handleHeadlineChange(e){const t=e.target;this.hasHeadline=t.assignedElements().length>0}handleActionsChange(e){const t=e.target;this.hasActions=t.assignedElements().length>0}handleIconChange(e){const t=e.target;this.hasIcon=t.assignedElements().length>0}handleAnchorIntersection(e){const{target:t,isIntersecting:o}=e;t===this.topAnchor&&(this.isAtScrollTop=o),t===this.bottomAnchor&&(this.isAtScrollBottom=o)}getIsConnectedPromise(){return new Promise(e=>{this.isConnectedPromiseResolve=e})}handleFocusTrapFocus(e){var t;const[o,i]=this.getFirstAndLastFocusableChildren();if(!o||!i)return void(null===(t=this.dialog)||void 0===t||t.focus());const n=e.target===this.firstFocusTrap,a=!n,s=e.relatedTarget===o,r=e.relatedTarget===i,l=!s&&!r;if(a&&r||n&&l)return void o.focus();(n&&s||a&&l)&&i.focus()}getFirstAndLastFocusableChildren(){if(!this.treewalker)return[null,null];let e=null,t=null;for(this.treewalker.currentNode=this.treewalker.root;this.treewalker.nextNode();){const o=this.treewalker.currentNode;k(o)&&(e||(e=o),t=o)}return[e,t]}}function k(e){var t,o;const i=":not(:disabled,[disabled])";if(e.matches(":is(button,input,select,textarea,object,:is(a,area)[href],[tabindex],[contenteditable=true])"+i+':not([tabindex^="-"])'))return!0;return!!e.localName.includes("-")&&(!!e.matches(i)&&(null!==(o=null===(t=e.shadowRoot)||void 0===t?void 0:t.delegatesFocus)&&void 0!==o&&o))}s([c({type:Boolean})],C.prototype,"open",null),s([c({type:Boolean})],C.prototype,"quick",void 0),s([c({attribute:!1})],C.prototype,"returnValue",void 0),s([c()],C.prototype,"type",void 0),s([c({type:Boolean,attribute:"no-focus-trap"})],C.prototype,"noFocusTrap",void 0),s([c({type:Boolean})],C.prototype,"allowOverflow",void 0),s([h("dialog")],C.prototype,"dialog",void 0),s([h(".scrim")],C.prototype,"scrim",void 0),s([h(".container")],C.prototype,"container",void 0),s([h(".headline")],C.prototype,"headline",void 0),s([h(".content")],C.prototype,"content",void 0),s([h(".actions")],C.prototype,"actions",void 0),s([p()],C.prototype,"isAtScrollTop",void 0),s([p()],C.prototype,"isAtScrollBottom",void 0),s([h(".scroller")],C.prototype,"scroller",void 0),s([h(".top.anchor")],C.prototype,"topAnchor",void 0),s([h(".bottom.anchor")],C.prototype,"bottomAnchor",void 0),s([h(".focus-trap")],C.prototype,"firstFocusTrap",void 0),s([p()],C.prototype,"hasHeadline",void 0),s([p()],C.prototype,"hasActions",void 0),s([p()],C.prototype,"hasIcon",void 0);const E=e`
|
|
103
|
+
:host {
|
|
104
|
+
border-start-start-radius: var(
|
|
105
|
+
--md-dialog-container-shape-start-start,
|
|
106
|
+
var(
|
|
107
|
+
--md-dialog-container-shape,
|
|
108
|
+
var(--md-sys-shape-corner-extra-large, 28px)
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
border-start-end-radius: var(
|
|
112
|
+
--md-dialog-container-shape-start-end,
|
|
113
|
+
var(
|
|
114
|
+
--md-dialog-container-shape,
|
|
115
|
+
var(--md-sys-shape-corner-extra-large, 28px)
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
border-end-end-radius: var(
|
|
119
|
+
--md-dialog-container-shape-end-end,
|
|
120
|
+
var(
|
|
121
|
+
--md-dialog-container-shape,
|
|
122
|
+
var(--md-sys-shape-corner-extra-large, 28px)
|
|
123
|
+
)
|
|
124
|
+
);
|
|
125
|
+
border-end-start-radius: var(
|
|
126
|
+
--md-dialog-container-shape-end-start,
|
|
127
|
+
var(
|
|
128
|
+
--md-dialog-container-shape,
|
|
129
|
+
var(--md-sys-shape-corner-extra-large, 28px)
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
display: contents;
|
|
133
|
+
margin: auto;
|
|
134
|
+
max-height: min(560px, 100% - 48px);
|
|
135
|
+
max-width: min(560px, 100% - 48px);
|
|
136
|
+
min-width: 280px;
|
|
17
137
|
position: fixed;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
138
|
+
height: fit-content;
|
|
139
|
+
width: fit-content;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
dialog {
|
|
143
|
+
background: rgba(0, 0, 0, 0);
|
|
144
|
+
border: none;
|
|
145
|
+
border-radius: inherit;
|
|
146
|
+
box-shadow: 0px 12px 16px 0px rgba(0, 0, 0, 0.58);
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
height: inherit;
|
|
149
|
+
margin: inherit;
|
|
150
|
+
max-height: inherit;
|
|
151
|
+
max-width: inherit;
|
|
152
|
+
min-height: inherit;
|
|
153
|
+
min-width: inherit;
|
|
154
|
+
outline: none;
|
|
155
|
+
overflow: visible;
|
|
24
156
|
padding: 0;
|
|
25
|
-
|
|
157
|
+
width: inherit;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
dialog[open] {
|
|
161
|
+
display: block;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
::backdrop {
|
|
165
|
+
background: rgba(0, 0, 0, 0.5);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
h2 {
|
|
169
|
+
all: unset;
|
|
170
|
+
align-self: stretch;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.headline {
|
|
174
|
+
align-items: center;
|
|
175
|
+
color: var(
|
|
176
|
+
--md-dialog-headline-color,
|
|
177
|
+
var(--md-sys-color-on-surface, #1d1b20)
|
|
178
|
+
);
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
font-family: var(
|
|
182
|
+
--md-dialog-headline-font,
|
|
183
|
+
var(
|
|
184
|
+
--md-sys-typescale-headline-small-font,
|
|
185
|
+
var(--md-ref-typeface-brand, Roboto)
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
font-size: var(
|
|
189
|
+
--md-dialog-headline-size,
|
|
190
|
+
var(--md-sys-typescale-headline-small-size, 1.5rem)
|
|
191
|
+
);
|
|
192
|
+
line-height: var(
|
|
193
|
+
--md-dialog-headline-line-height,
|
|
194
|
+
var(--md-sys-typescale-headline-small-line-height, 2rem)
|
|
195
|
+
);
|
|
196
|
+
font-weight: var(
|
|
197
|
+
--md-dialog-headline-weight,
|
|
198
|
+
var(
|
|
199
|
+
--md-sys-typescale-headline-small-weight,
|
|
200
|
+
var(--md-ref-typeface-weight-regular, 400)
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
position: relative;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
slot[name='headline']::slotted(*) {
|
|
207
|
+
align-items: center;
|
|
208
|
+
align-self: stretch;
|
|
209
|
+
box-sizing: border-box;
|
|
210
|
+
display: flex;
|
|
211
|
+
gap: 8px;
|
|
212
|
+
padding: 24px 24px 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.icon {
|
|
216
|
+
display: flex;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
slot[name='icon']::slotted(*) {
|
|
220
|
+
color: var(--md-dialog-icon-color, var(--md-sys-color-secondary, #625b71));
|
|
221
|
+
fill: currentColor;
|
|
222
|
+
font-size: var(--md-dialog-icon-size, 24px);
|
|
223
|
+
margin-top: 24px;
|
|
224
|
+
height: var(--md-dialog-icon-size, 24px);
|
|
225
|
+
width: var(--md-dialog-icon-size, 24px);
|
|
26
226
|
}
|
|
227
|
+
|
|
228
|
+
.has-icon slot[name='headline']::slotted(*) {
|
|
229
|
+
justify-content: center;
|
|
230
|
+
padding-top: 16px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.scrollable slot[name='headline']::slotted(*) {
|
|
234
|
+
padding-bottom: 16px;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.scrollable.has-headline slot[name='content']::slotted(*) {
|
|
238
|
+
padding-top: 8px;
|
|
239
|
+
}
|
|
240
|
+
|
|
27
241
|
.container {
|
|
242
|
+
border-radius: inherit;
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-direction: column;
|
|
245
|
+
flex-grow: 1;
|
|
246
|
+
overflow: hidden;
|
|
28
247
|
position: relative;
|
|
29
|
-
|
|
30
|
-
background: var(--ix-dialog-bg, #fff);
|
|
31
|
-
box-shadow: var(--ix-dialog-shadow, 0 10px 30px rgba(0,0,0,0.25));
|
|
32
|
-
display: grid;
|
|
33
|
-
grid-template-rows: auto 1fr auto;
|
|
34
|
-
overflow: visible;
|
|
35
|
-
pointer-events: auto;
|
|
36
|
-
z-index: 1001;
|
|
37
|
-
max-width: none!important;
|
|
248
|
+
transform-origin: top;
|
|
38
249
|
}
|
|
39
|
-
|
|
250
|
+
|
|
251
|
+
.allow-overflow .container {
|
|
40
252
|
overflow: visible;
|
|
41
253
|
}
|
|
42
|
-
|
|
43
|
-
|
|
254
|
+
|
|
255
|
+
.container::before {
|
|
256
|
+
background: var(
|
|
257
|
+
--md-dialog-container-color,
|
|
258
|
+
var(--md-sys-color-surface-container-high, #ece6f0)
|
|
259
|
+
);
|
|
260
|
+
border-radius: inherit;
|
|
261
|
+
content: '';
|
|
262
|
+
inset: 0;
|
|
263
|
+
position: absolute;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.scroller {
|
|
267
|
+
display: flex;
|
|
268
|
+
flex: 1;
|
|
269
|
+
flex-direction: column;
|
|
270
|
+
overflow: initial;
|
|
271
|
+
z-index: 1;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.scrollable .scroller {
|
|
275
|
+
overflow-y: scroll;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.content {
|
|
279
|
+
color: var(--clr-on-surface, #092241);
|
|
280
|
+
font-family: var(--text-default-font, sans-serif);
|
|
281
|
+
font-size: var(--text-default-size, 16px);
|
|
282
|
+
letter-spacing: var(--text-default-letter-spacing, 0.0275em);
|
|
283
|
+
line-height: var(--text-default-line-height, 1.75em);
|
|
284
|
+
font-weight: var(--text-default-weight, normal);
|
|
285
|
+
text-transform: var(--text-default-decoration, none);
|
|
286
|
+
text-decoration: var(--text-default-transform, none);
|
|
287
|
+
height: min-content;
|
|
288
|
+
position: relative;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
slot[name='content']::slotted(*) {
|
|
292
|
+
box-sizing: border-box;
|
|
293
|
+
padding: 24px;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.anchor {
|
|
297
|
+
position: absolute;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.top.anchor {
|
|
301
|
+
top: 0;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.bottom.anchor {
|
|
305
|
+
bottom: 0;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.actions {
|
|
309
|
+
position: relative;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
slot[name='actions']::slotted(*) {
|
|
313
|
+
box-sizing: border-box;
|
|
314
|
+
display: flex;
|
|
315
|
+
gap: 8px;
|
|
316
|
+
justify-content: flex-end;
|
|
317
|
+
padding: 16px 24px 24px;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.has-actions slot[name='content']::slotted(*) {
|
|
321
|
+
padding-bottom: 8px;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
md-divider {
|
|
325
|
+
display: none;
|
|
326
|
+
position: absolute;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.has-headline.show-top-divider .headline md-divider,
|
|
330
|
+
.has-actions.show-bottom-divider .actions md-divider {
|
|
331
|
+
display: flex;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.headline md-divider {
|
|
335
|
+
bottom: 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.actions md-divider {
|
|
339
|
+
top: 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
@media (forced-colors: active) {
|
|
343
|
+
dialog {
|
|
344
|
+
outline: 2px solid WindowText;
|
|
345
|
+
}
|
|
44
346
|
}
|
|
45
|
-
|
|
347
|
+
`;class S extends C{}S.styles=[E],window.customElements.define("md-dialog",S);const A=l(r(t));class D extends A{constructor(){super(...arguments),this.open=!1,this.preventCancel=!1,this.preventCloseOnScrimClick=!1,this.disableNextClickIsFromContent=!1,this.useNativeDialog=!1,this.allowOverflow=!1,this.nativeClosing=!1,this.dialogRef=v(),this.containerRef=v(),this.pointerDownInside=!1,this.isScrollLocked=!1,this.scrollYBackup=0,this.onKeydown=e=>{if("Escape"!==e.key)return;if(this.preventCancel)return void e.preventDefault();const t=new Event("cancel",{bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t)?this.requestClose():e.preventDefault()},this.onNativeCancel=e=>{const t=new Event("cancel",{bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t)?this.requestClose():e.preventDefault()},this.onScrimClick=()=>{this.preventCloseOnScrimClick||this.requestClose()}}get forwardedAriaAttributes(){const e={...this.ariaAttributes};for(const t of Array.from(this.attributes))t.name.startsWith("aria-")&&(e[t.name]=t.value);return e}get nativeDialog(){var e;return null!==(e=this.dialogRef.value)&&void 0!==e?e:null}get nativeDialogContainer(){var e;return null!==(e=this.containerRef.value)&&void 0!==e?e:null}get hasPortalHeadline(){return Array.from(this.children).some(e=>e instanceof HTMLElement&&"headline"===e.slot)}connectedCallback(){super.connectedCallback(),this.mo=new MutationObserver(()=>{this.useNativeDialog&&this.open&&this.populatePortal()}),this.mo.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this.mo)||void 0===e||e.disconnect(),this.unlockScroll(),this.teardownPortal()}updated(e){var t;this.useNativeDialog&&e.has("open")&&(this.open?(this.ensurePortal(),this.portalRoot&&(this.attachPortalStyles(),a(this.portalTemplate(),this.portalRoot),this.populatePortal()),this.nativeClosing&&(this.nativeClosing=!1,null===(t=this.nativeDialogContainer)||void 0===t||t.classList.remove("closing"),this.nativeOnEnd&&this.nativeDialogContainer&&this.nativeDialogContainer.removeEventListener("animationend",this.nativeOnEnd),this.nativeOnEnd=void 0),this.dispatchEvent(new Event("open",{bubbles:!0,composed:!0})),this.lockScroll(),requestAnimationFrame(()=>{var e;null===(e=this.nativeDialog)||void 0===e||e.show(),requestAnimationFrame(()=>{this.dispatchEvent(new Event("opened",{bubbles:!0,composed:!0}))})})):this.startNativeCloseAnimation())}dismiss(){this.open&&Promise.resolve().then(()=>{this.requestClose()})}startNativeCloseAnimation(){if(this.nativeClosing)return;this.nativeClosing=!0,this.dispatchEvent(new Event("close",{bubbles:!0,composed:!0}));const e=()=>{var e,t;null===(e=this.nativeDialogContainer)||void 0===e||e.classList.remove("closing"),this.nativeClosing=!1,null===(t=this.nativeDialog)||void 0===t||t.close(),this.unlockScroll(),this.dispatchEvent(new Event("closed",{bubbles:!0,composed:!0})),this.moveNodesBackFromPortal(),this.teardownPortal()},t=this.nativeDialogContainer;if(!t)return void e();t.classList.add("closing");let o=!1;const i=()=>{o||(o=!0,t.removeEventListener("animationend",i),e())};this.nativeOnEnd=i,t.addEventListener("animationend",i,{once:!0}),window.setTimeout(i,1)}ensurePortal(){if(this.portalRoot)return;const e=document.createElement("ix-dialog-portal-host"),t=e.attachShadow({mode:"open"});this.shadowRoot&&"adoptedStyleSheets"in this.shadowRoot&&(t.adoptedStyleSheets=this.shadowRoot.adoptedStyleSheets),document.body.appendChild(e),this.portalHost=e,this.portalRoot=t}attachPortalStyles(){if(!this.portalRoot||this.portalStyleEl)return;const e=document.createElement("style"),t="\n dialog {\n position: fixed;\n inset: 0;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n display: grid;\n place-items: center;\n pointer-events: none;\n z-index: 1000;\n max-width: none !important;\n max-height: none !important;\n }\n .scrim {\n position: fixed;\n inset: 0;\n background: var(--ix-dialog-scrim, rgba(0,0,0,0.5));\n pointer-events: auto;\n z-index: 1000;\n touch-action: none;\n border: 0;\n padding: 0;\n appearance: none;\n }\n .container {\n position: relative;\n border-radius: 0.75rem;\n background: var(--ix-dialog-bg, #fff);\n box-shadow: var(--ix-dialog-shadow, 0 10px 30px rgba(0,0,0,0.25));\n display: grid;\n grid-template-rows: auto 1fr auto;\n overflow: visible;\n pointer-events: auto;\n z-index: 1001;\n max-width: none!important;\n }\n .container .content {\n overflow: visible;\n }\n @media (prefers-reduced-motion: reduce) {\n dialog > .container { animation: none !important; }\n }\n ";if(this.contentStyles){const o=(Array.isArray(this.contentStyles)?this.contentStyles:[this.contentStyles]).map(e=>"object"==typeof e&&"cssText"in e?e.cssText:"").join("\n");e.textContent=o+t}else e.textContent=t;this.portalRoot.append(e),this.portalStyleEl=e}teardownPortal(){var e;this.portalHost&&(this.portalRoot&&a(n,this.portalRoot),null===(e=this.portalStyleEl)||void 0===e||e.remove(),this.portalStyleEl=void 0,this.portalHost.remove(),this.portalRoot=void 0,this.portalHost=void 0)}moveNodesToPortal(e,t){if(!this.nativeDialogContainer)return;const o=this.nativeDialogContainer.querySelector(t);if(!o)return;Array.from(this.children).filter(t=>t instanceof HTMLElement&&t.slot===e).forEach(e=>o.appendChild(e))}moveNodesBackFromPortal(){if(!this.nativeDialogContainer)return;[this.nativeDialogContainer.querySelector(".headline"),this.nativeDialogContainer.querySelector(".content"),this.nativeDialogContainer.querySelector(".actions")].forEach(e=>{if(!e)return;Array.from(e.childNodes).forEach(e=>this.appendChild(e))})}populatePortal(){this.moveNodesToPortal("headline",".headline"),this.moveNodesToPortal("content",".content"),this.moveNodesToPortal("actions",".actions")}requestClose(){this.open=!1}lockScroll(){if(this.isScrollLocked)return;this.isScrollLocked=!0,this.scrollYBackup=window.scrollY||document.documentElement.scrollTop||0;const{body:e}=document,t=window.innerWidth-document.documentElement.clientWidth;t>0&&(e.style.paddingRight=`${t}px`),e.style.overflow="hidden",e.style.position="fixed",e.style.top=`-${this.scrollYBackup}px`,e.style.left="0",e.style.right="0",e.style.width="100%";const o=e=>{const t=e.target;this.nativeDialogContainer&&t&&(this.nativeDialogContainer.contains(t)||e.preventDefault())},i=e=>o(e),n=e=>{if(!["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"," "].includes(e.key))return;const t=e.target;this.nativeDialogContainer&&t&&(this.nativeDialogContainer.contains(t)||e.preventDefault())};window.addEventListener("touchmove",i,{passive:!1}),window.addEventListener("keydown",n,{passive:!1}),this.removeScrollHandlers=()=>{window.removeEventListener("touchmove",i),window.removeEventListener("keydown",n)}}unlockScroll(){if(!this.isScrollLocked)return;this.isScrollLocked=!1,this.removeScrollHandlers&&(this.removeScrollHandlers(),this.removeScrollHandlers=void 0);const{body:e}=document;e.style.paddingRight="",e.style.position="",e.style.top="",e.style.left="",e.style.right="",e.style.overflow="",e.style.width="",window.scrollTo(0,this.scrollYBackup||0)}onOpen(){this.dispatchEvent(new Event("open")),this.lockScroll()}onOpened(){this.dispatchEvent(new Event("opened"))}onClose(){this.dispatchEvent(new Event("close"))}onClosed(){this.dispatchEvent(new Event("closed")),this.unlockScroll()}onCancel(e){this.preventCancel&&e.preventDefault(),this.dispatchEvent(new Event("cancel",{bubbles:!0,composed:!0}))}portalTemplate(){const{"aria-label":e,"aria-labelledby":t,...o}=this.forwardedAriaAttributes;return i`
|
|
348
|
+
<dialog
|
|
349
|
+
${m(this.dialogRef)}
|
|
350
|
+
@cancel=${this.onNativeCancel}
|
|
351
|
+
@keydown=${this.onKeydown}
|
|
352
|
+
>
|
|
353
|
+
<button
|
|
354
|
+
class="scrim"
|
|
355
|
+
type="button"
|
|
356
|
+
aria-label="Close dialog"
|
|
357
|
+
@click=${this.onScrimClick}
|
|
358
|
+
></button>
|
|
359
|
+
<div
|
|
360
|
+
class="container"
|
|
361
|
+
${m(this.containerRef)}
|
|
362
|
+
role="dialog"
|
|
363
|
+
aria-modal="true"
|
|
364
|
+
aria-label=${e||n}
|
|
365
|
+
aria-labelledby=${e?n:t||(this.hasPortalHeadline?"headline":n)}
|
|
366
|
+
${d(o)}
|
|
367
|
+
>
|
|
368
|
+
<div class="headline" id="headline"></div>
|
|
369
|
+
<div class="content"></div>
|
|
370
|
+
<div class="actions"></div>
|
|
371
|
+
</div>
|
|
372
|
+
</dialog>
|
|
373
|
+
`}renderMdDialog(){return this.portalHost&&(this.moveNodesBackFromPortal(),this.teardownPortal()),i`<md-dialog
|
|
374
|
+
?open=${this.open}
|
|
375
|
+
class="dialog"
|
|
376
|
+
?preventCloseOnScrimClick=${this.preventCloseOnScrimClick}
|
|
377
|
+
?disableNextClickIsFromContent=${this.disableNextClickIsFromContent}
|
|
378
|
+
?allowOverflow=${this.allowOverflow}
|
|
379
|
+
${d(this.forwardedAriaAttributes)}
|
|
380
|
+
@open=${this.onOpen}
|
|
381
|
+
@opened=${this.onOpened}
|
|
382
|
+
@close=${this.onClose}
|
|
383
|
+
@closed=${this.onClosed}
|
|
384
|
+
@cancel=${this.onCancel}
|
|
385
|
+
>
|
|
386
|
+
<slot slot="headline" name="headline"></slot>
|
|
387
|
+
<slot slot="content" name="content"></slot>
|
|
388
|
+
<slot slot="actions" name="actions"></slot>
|
|
389
|
+
</md-dialog>`}renderNativeDialog(){return this.portalRoot&&(a(this.portalTemplate(),this.portalRoot),this.populatePortal()),n}render(){return this.useNativeDialog?this.renderNativeDialog():this.renderMdDialog()}}var O,P;D.styles=[w,e`
|
|
390
|
+
:host([use-native-dialog]) dialog[open],
|
|
391
|
+
:host([use-native-dialog][closing]) dialog {
|
|
392
|
+
position: fixed;
|
|
393
|
+
inset: 0;
|
|
394
|
+
margin: 0;
|
|
395
|
+
padding: 0;
|
|
396
|
+
border: 0;
|
|
397
|
+
background: transparent;
|
|
398
|
+
display: block;
|
|
399
|
+
inline-size: 100vw;
|
|
400
|
+
block-size: 100dvh;
|
|
401
|
+
pointer-events: none;
|
|
402
|
+
z-index: 99;
|
|
403
|
+
overscroll-behavior: contain;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
:host([use-native-dialog]) dialog[open] .scrim,
|
|
407
|
+
:host([use-native-dialog][closing]) .scrim,
|
|
408
|
+
:host([use-native-dialog]) dialog[open] > .container,
|
|
409
|
+
:host([use-native-dialog][closing]) dialog > .container {
|
|
410
|
+
pointer-events: auto;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
:host([use-native-dialog]) dialog[open] .scrim,
|
|
414
|
+
:host([use-native-dialog][closing]) .scrim {
|
|
415
|
+
position: fixed;
|
|
416
|
+
inset: 0;
|
|
417
|
+
background: var(--ix-dialog-scrim, rgba(0, 0, 0, 0.32));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
:host([use-native-dialog]) dialog[open] .scrim {
|
|
421
|
+
overscroll-behavior: contain;
|
|
422
|
+
touch-action: none;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
:host([use-native-dialog]) dialog[open] > .container,
|
|
426
|
+
:host([use-native-dialog][closing]) dialog > .container {
|
|
427
|
+
transform: translate(-50%, -50%);
|
|
428
|
+
width: auto;
|
|
429
|
+
height: auto;
|
|
430
|
+
max-block-size: var(--ix-dialog-max-height, 90dvh);
|
|
431
|
+
border-radius: 0.75rem;
|
|
432
|
+
background: var(--ix-dialog-bg, #fff);
|
|
433
|
+
box-shadow: var(
|
|
434
|
+
--ix-dialog-shadow,
|
|
435
|
+
0 0.625rem 1.875rem rgba(0, 0, 0, 0.25)
|
|
436
|
+
);
|
|
437
|
+
display: grid;
|
|
438
|
+
grid-template-rows: auto 1fr auto;
|
|
439
|
+
overflow: hidden;
|
|
440
|
+
z-index: 9;
|
|
441
|
+
transform-origin: top center;
|
|
442
|
+
will-change: transform, opacity;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
:host([use-native-dialog]) .headline,
|
|
446
|
+
:host([use-native-dialog]) .content,
|
|
447
|
+
:host([use-native-dialog]) .actions {
|
|
448
|
+
padding: var(--ix-dialog-section-padding, 1rem);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
:host([use-native-dialog]) .content {
|
|
452
|
+
overflow: auto;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
:host([use-native-dialog]) .actions {
|
|
456
|
+
display: inline-flex;
|
|
457
|
+
gap: var(--ix-dialog-actions-gap, 0.5rem);
|
|
458
|
+
justify-content: flex-end;
|
|
459
|
+
align-items: center;
|
|
460
|
+
padding-block: var(--ix-dialog-actions-padding-block, 0.75rem);
|
|
461
|
+
border-top: var(
|
|
462
|
+
--ix-dialog-actions-border,
|
|
463
|
+
1px solid rgba(0, 0, 0, 0.08)
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
@keyframes ix-fold-in {
|
|
468
|
+
from {
|
|
469
|
+
transform: translate(-50%, -50%) translateY(-0.5rem) scaleY(0.92);
|
|
470
|
+
opacity: 0;
|
|
471
|
+
}
|
|
472
|
+
to {
|
|
473
|
+
transform: translate(-50%, -50%) translateY(0) scaleY(1);
|
|
474
|
+
opacity: 1;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
@keyframes ix-fold-out {
|
|
478
|
+
from {
|
|
479
|
+
transform: translate(-50%, -50%) translateY(0) scaleY(1);
|
|
480
|
+
opacity: 1;
|
|
481
|
+
}
|
|
482
|
+
to {
|
|
483
|
+
transform: translate(-50%, -50%) translateY(-0.5rem) scaleY(0.98);
|
|
484
|
+
opacity: 0;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
:host([use-native-dialog]:not([closing])) dialog[open] > .container {
|
|
489
|
+
animation: ix-fold-in var(--ix-dialog-in-dur, 1000ms)
|
|
490
|
+
cubic-bezier(0.2, 0.7, 0.3, 1) both;
|
|
491
|
+
}
|
|
492
|
+
:host([use-native-dialog][closing]) dialog > .container {
|
|
493
|
+
animation: ix-fold-out var(--ix-dialog-out-dur, 250ms)
|
|
494
|
+
cubic-bezier(0.2, 0.7, 0.3, 1) both;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
@media (prefers-reduced-motion: reduce) {
|
|
498
|
+
:host([use-native-dialog]) dialog > .container {
|
|
499
|
+
animation: none !important;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
`],D.shadowRootOptions={...t.shadowRootOptions,delegatesFocus:!0},s([h(".dialog")],D.prototype,"component",void 0),s([c({type:Boolean,reflect:!0})],D.prototype,"open",void 0),s([c({type:Boolean,attribute:"prevent-cancel"})],D.prototype,"preventCancel",void 0),s([c({type:Boolean})],D.prototype,"preventCloseOnScrimClick",void 0),s([c({type:Boolean})],D.prototype,"disableNextClickIsFromContent",void 0),s([c({type:Boolean,reflect:!0,attribute:"use-native-dialog"})],D.prototype,"useNativeDialog",void 0),s([c({type:Boolean})],D.prototype,"allowOverflow",void 0),s([c({type:Object})],D.prototype,"contentStyles",void 0),s([p()],D.prototype,"nativeClosing",void 0);class $ extends(P=D){}O=$,$.styles=[Reflect.get(P,"styles",O),e`
|
|
503
|
+
.dialog {
|
|
504
|
+
max-height: 90vh;
|
|
505
|
+
max-width: 90vw;
|
|
506
|
+
}
|
|
507
|
+
`],customElements.define("ix-dialog",$);export{$ as IxDialogStyled};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-dialog following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Digital Realty",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.3.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
26
26
|
"build": "tsc && npm run analyze -- --exclude dist && rollup -c",
|
|
27
27
|
"prepublish": "tsc && npm run analyze -- --exclude dist",
|
|
28
|
-
"lint": "eslint --ext .ts,.html .
|
|
29
|
-
"format": "eslint --ext .ts,.html . --fix
|
|
28
|
+
"lint": "eslint --ext .ts,.html . && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
29
|
+
"format": "eslint --ext .ts,.html . --fix && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
30
30
|
"test": "tsc && wtr --coverage",
|
|
31
31
|
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@digital-realty/ix-select": "^1.
|
|
35
|
-
"@digital-realty/ix-shared-fns": "^1.
|
|
34
|
+
"@digital-realty/ix-select": "^1.3.1",
|
|
35
|
+
"@digital-realty/ix-shared-fns": "^1.1.1",
|
|
36
36
|
"@lit/react": "^1.0.2",
|
|
37
37
|
"@material/web": "2.4.0",
|
|
38
38
|
"@open-wc/lit-helpers": "^0.7.0",
|
|
@@ -42,32 +42,26 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
45
|
-
"@open-wc/eslint-config": "^9.2.1",
|
|
46
45
|
"@open-wc/testing": "^3.1.6",
|
|
47
|
-
"@
|
|
48
|
-
"@typescript-eslint/
|
|
46
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
48
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
49
49
|
"@web/dev-server": "^0.4.6",
|
|
50
50
|
"@web/test-runner": "^0.20.2",
|
|
51
|
-
"concurrently": "^9.1
|
|
52
|
-
"eslint": "^
|
|
51
|
+
"concurrently": "^9.2.1",
|
|
52
|
+
"eslint": "^9.39.4",
|
|
53
53
|
"eslint-config-prettier": "^8.3.0",
|
|
54
54
|
"husky": "^4.3.8",
|
|
55
55
|
"lint-staged": "^10.5.4",
|
|
56
56
|
"prettier": "^2.4.1",
|
|
57
57
|
"rollup": "^4.29.1",
|
|
58
|
-
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
59
58
|
"rollup-plugin-summary": "^2.0.0",
|
|
60
|
-
"rollup-plugin-uglify": "^6.0.4",
|
|
61
59
|
"tslib": "^2.3.1",
|
|
62
60
|
"typescript": "^4.5.2"
|
|
63
61
|
},
|
|
64
62
|
"customElements": "custom-elements.json",
|
|
65
63
|
"eslintConfig": {
|
|
66
64
|
"parser": "@typescript-eslint/parser",
|
|
67
|
-
"extends": [
|
|
68
|
-
"@open-wc",
|
|
69
|
-
"prettier"
|
|
70
|
-
],
|
|
71
65
|
"plugins": [
|
|
72
66
|
"@typescript-eslint"
|
|
73
67
|
],
|
|
@@ -108,5 +102,5 @@
|
|
|
108
102
|
"README.md",
|
|
109
103
|
"LICENSE"
|
|
110
104
|
],
|
|
111
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "da06737d6707fd3d4ef898ba0fa632e7b3ed8019"
|
|
112
106
|
}
|