@digital-realty/ix-dialog 1.0.26 → 1.0.28

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.
@@ -1,6 +1,6 @@
1
1
  import { LitElement } from 'lit';
2
2
  import './md-dialog.js';
3
- import { Dialog } from '@material/web/dialog/internal/dialog.js';
3
+ import { Dialog } from './internal/dialog.js';
4
4
  export declare class IxDialog extends LitElement {
5
5
  /** @nocollapse */
6
6
  static shadowRootOptions: {
@@ -1 +1 @@
1
- {"version":3,"file":"IxDialog.js","sourceRoot":"","sources":["../src/IxDialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,MAAM,OAAO,QAAS,SAAQ,UAAU;IAAxC;;QAc8C,SAAI,GAAG,KAAK,CAAC;IAwC3D,CAAC;IAtCC,MAAM;QACJ,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO;QACL,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;gBAEC,IAAI,CAAC,IAAI;;gBAET,IAAI,CAAC,MAAM;kBACT,IAAI,CAAC,QAAQ;iBACd,IAAI,CAAC,OAAO;kBACX,IAAI,CAAC,QAAQ;kBACb,IAAI,CAAC,QAAQ;;;;;;;KAO1B,CAAC;IACJ,CAAC;;AApDD;IACE,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,GAAA,CAAA;AAED,kBAAkB;AACF,0BAAiB,GAAG;IAClC,GAAG,UAAU,CAAC,iBAAiB;IAC/B,cAAc,EAAE,IAAI;CACrB,CAAC;AAGF;IADC,KAAK,CAAC,SAAS,CAAC;2CACW;AAEgB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAAc","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport './md-dialog.js';\nimport { Dialog } from '@material/web/dialog/internal/dialog.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\n\nexport class IxDialog extends LitElement {\n static {\n requestUpdateOnAriaChange(IxDialog);\n }\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n @query('.dialog')\n readonly component!: Dialog;\n\n @property({ type: Boolean, reflect: true }) open = false;\n\n onOpen() {\n this.dispatchEvent(new Event('open'));\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 }\n\n onCancel() {\n this.dispatchEvent(new Event('cancel'));\n }\n\n render() {\n return html`\n <md-dialog\n ?open=${this.open}\n class=\"dialog\"\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>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AAiB;IAC/B,cAAc,EAAE,IAAI;CACrB,CAAC;AAGF;IADC,KAAK,CAAC,SAAS,CAAC;2CACW;AAEgB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAAc","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport './md-dialog.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\nimport { Dialog } from './internal/dialog.js';\n\nexport class IxDialog extends LitElement {\n static {\n requestUpdateOnAriaChange(IxDialog);\n }\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n @query('.dialog')\n readonly component!: Dialog;\n\n @property({ type: Boolean, reflect: true }) open = false;\n\n onOpen() {\n this.dispatchEvent(new Event('open'));\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 }\n\n onCancel() {\n this.dispatchEvent(new Event('cancel'));\n }\n\n render() {\n return html`\n <md-dialog\n ?open=${this.open}\n class=\"dialog\"\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 }\n}\n"]}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import '@material/web/divider/divider.js';
7
+ import { LitElement } from 'lit';
8
+ import { DialogAnimation } from '@material/web/dialog/internal/animations.js';
9
+ /**
10
+ * A dialog component.
11
+ *
12
+ * @fires open {Event} Dispatched when the dialog is opening before any animations.
13
+ * @fires opened {Event} Dispatched when the dialog has opened after any animations.
14
+ * @fires close {Event} Dispatched when the dialog is closing before any animations.
15
+ * @fires closed {Event} Dispatched when the dialog has closed after any animations.
16
+ * @fires cancel {Event} Dispatched when the dialog has been canceled by clicking
17
+ * on the scrim or pressing Escape.
18
+ */
19
+ export declare class Dialog extends LitElement {
20
+ /**
21
+ * Opens the dialog when set to `true` and closes it when set to `false`.
22
+ */
23
+ get open(): boolean;
24
+ set open(open: boolean);
25
+ /**
26
+ * Gets or sets the dialog's return value, usually to indicate which button
27
+ * a user pressed to close it.
28
+ *
29
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue
30
+ */
31
+ returnValue: string;
32
+ /**
33
+ * The type of dialog for accessibility. Set this to `alert` to announce a
34
+ * dialog as an alert dialog.
35
+ */
36
+ type?: 'alert';
37
+ /**
38
+ * Gets the opening animation for a dialog. Set to a new function to customize
39
+ * the animation.
40
+ */
41
+ getOpenAnimation: () => DialogAnimation;
42
+ /**
43
+ * Gets the closing animation for a dialog. Set to a new function to customize
44
+ * the animation.
45
+ */
46
+ getCloseAnimation: () => DialogAnimation;
47
+ private isOpen;
48
+ private isOpening;
49
+ private isConnectedPromiseResolve;
50
+ private isConnectedPromise;
51
+ private readonly dialog;
52
+ private readonly scrim;
53
+ private readonly container;
54
+ private readonly headline;
55
+ private readonly content;
56
+ private readonly actions;
57
+ private isAtScrollTop;
58
+ private isAtScrollBottom;
59
+ private readonly scroller;
60
+ private readonly topAnchor;
61
+ private readonly bottomAnchor;
62
+ private nextClickIsFromContent;
63
+ private intersectionObserver?;
64
+ private hasHeadline;
65
+ private hasActions;
66
+ private hasIcon;
67
+ private escapePressedWithoutCancel;
68
+ constructor();
69
+ /**
70
+ * Opens the dialog and fires a cancelable `open` event. After a dialog's
71
+ * animation, an `opened` event is fired.
72
+ *
73
+ * Add an `autocomplete` attribute to a child of the dialog that should
74
+ * receive focus after opening.
75
+ *
76
+ * @return A Promise that resolves after the animation is finished and the
77
+ * `opened` event was fired.
78
+ */
79
+ show(): Promise<void>;
80
+ /**
81
+ * Closes the dialog and fires a cancelable `close` event. After a dialog's
82
+ * animation, a `closed` event is fired.
83
+ *
84
+ * @param returnValue A return value usually indicating which button was used
85
+ * to close a dialog. If a dialog is canceled by clicking the scrim or
86
+ * pressing Escape, it will not change the return value after closing.
87
+ * @return A Promise that resolves after the animation is finished and the
88
+ * `closed` event was fired.
89
+ */
90
+ close(returnValue?: string): Promise<void>;
91
+ connectedCallback(): void;
92
+ disconnectedCallback(): void;
93
+ protected render(): import("lit").TemplateResult<1>;
94
+ protected firstUpdated(): void;
95
+ private handleDialogClick;
96
+ private handleContentClick;
97
+ private handleSubmit;
98
+ private handleCancel;
99
+ private handleClose;
100
+ private handleKeydown;
101
+ private animateDialog;
102
+ private handleHeadlineChange;
103
+ private handleActionsChange;
104
+ private handleIconChange;
105
+ private handleAnchorIntersection;
106
+ private getIsConnectedPromise;
107
+ }
@@ -0,0 +1,431 @@
1
+ /* eslint-disable no-shadow */
2
+ /* eslint-disable class-methods-use-this */
3
+ /**
4
+ * @license
5
+ * Copyright 2023 Google LLC
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ import { __decorate } from "tslib";
9
+ import '@material/web/divider/divider.js';
10
+ import { html, isServer, LitElement, nothing } from 'lit';
11
+ import { property, query, state } from 'lit/decorators.js';
12
+ import { classMap } from 'lit/directives/class-map.js';
13
+ import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
14
+ import { redispatchEvent } from '@material/web/internal/events/redispatch-event.js';
15
+ import { DIALOG_DEFAULT_CLOSE_ANIMATION, DIALOG_DEFAULT_OPEN_ANIMATION, } from '@material/web/dialog/internal/animations.js';
16
+ /**
17
+ * A dialog component.
18
+ *
19
+ * @fires open {Event} Dispatched when the dialog is opening before any animations.
20
+ * @fires opened {Event} Dispatched when the dialog has opened after any animations.
21
+ * @fires close {Event} Dispatched when the dialog is closing before any animations.
22
+ * @fires closed {Event} Dispatched when the dialog has closed after any animations.
23
+ * @fires cancel {Event} Dispatched when the dialog has been canceled by clicking
24
+ * on the scrim or pressing Escape.
25
+ */
26
+ export class Dialog extends LitElement {
27
+ /**
28
+ * Opens the dialog when set to `true` and closes it when set to `false`.
29
+ */
30
+ get open() {
31
+ return this.isOpen;
32
+ }
33
+ set open(open) {
34
+ if (open === this.isOpen) {
35
+ return;
36
+ }
37
+ this.isOpen = open;
38
+ if (open) {
39
+ this.setAttribute('open', '');
40
+ this.show();
41
+ }
42
+ else {
43
+ this.removeAttribute('open');
44
+ this.close();
45
+ }
46
+ }
47
+ constructor() {
48
+ super();
49
+ /**
50
+ * Gets or sets the dialog's return value, usually to indicate which button
51
+ * a user pressed to close it.
52
+ *
53
+ * https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue
54
+ */
55
+ this.returnValue = '';
56
+ /**
57
+ * Gets the opening animation for a dialog. Set to a new function to customize
58
+ * the animation.
59
+ */
60
+ this.getOpenAnimation = () => DIALOG_DEFAULT_OPEN_ANIMATION;
61
+ /**
62
+ * Gets the closing animation for a dialog. Set to a new function to customize
63
+ * the animation.
64
+ */
65
+ this.getCloseAnimation = () => DIALOG_DEFAULT_CLOSE_ANIMATION;
66
+ this.isOpen = false;
67
+ this.isOpening = false;
68
+ this.isConnectedPromise = this.getIsConnectedPromise();
69
+ this.isAtScrollTop = false;
70
+ this.isAtScrollBottom = false;
71
+ this.nextClickIsFromContent = false;
72
+ // Dialogs should not be SSR'd while open, so we can just use runtime checks.
73
+ this.hasHeadline = false;
74
+ this.hasActions = false;
75
+ this.hasIcon = false;
76
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=1512224
77
+ // Chrome v120 has a bug where escape keys do not trigger cancels. If we get
78
+ // a dialog "close" event that is triggered without a "cancel" after an escape
79
+ // keydown, then we need to manually trigger our closing logic.
80
+ //
81
+ // This bug occurs when pressing escape to close a dialog without first
82
+ // interacting with the dialog's content.
83
+ //
84
+ // Cleanup tracking:
85
+ // https://github.com/material-components/material-web/issues/5330
86
+ // This can be removed when full CloseWatcher support added and the above bug
87
+ // in Chromium is fixed to fire 'cancel' with one escape press and close with
88
+ // multiple.
89
+ this.escapePressedWithoutCancel = false;
90
+ if (!isServer) {
91
+ this.addEventListener('submit', this.handleSubmit);
92
+ // We do not use `delegatesFocus: true` due to a Chromium bug with
93
+ // selecting text.
94
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=950357
95
+ //
96
+ // Material requires using focus trapping within the dialog (see
97
+ // b/314840853 for the bug to add it). This would normally mean we don't
98
+ // care about delegating focus since the `<dialog>` never receives it.
99
+ // However, we still need to handle situations when a user has not
100
+ // provided an focusable child in the content. When that happens, the
101
+ // `<dialog>` itself is focused.
102
+ //
103
+ // Listen to focus/blur instead of focusin/focusout since those can bubble
104
+ // from content.
105
+ this.addEventListener('focus', () => {
106
+ var _a;
107
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.focus();
108
+ });
109
+ this.addEventListener('blur', () => {
110
+ var _a;
111
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.blur();
112
+ });
113
+ }
114
+ }
115
+ /**
116
+ * Opens the dialog and fires a cancelable `open` event. After a dialog's
117
+ * animation, an `opened` event is fired.
118
+ *
119
+ * Add an `autocomplete` attribute to a child of the dialog that should
120
+ * receive focus after opening.
121
+ *
122
+ * @return A Promise that resolves after the animation is finished and the
123
+ * `opened` event was fired.
124
+ */
125
+ async show() {
126
+ var _a;
127
+ this.isOpening = true;
128
+ // Dialogs can be opened before being attached to the DOM, so we need to
129
+ // wait until we're connected before calling `showModal()`.
130
+ await this.isConnectedPromise;
131
+ await this.updateComplete;
132
+ const dialog = this.dialog;
133
+ // Check if already opened or if `dialog.close()` was called while awaiting.
134
+ if (dialog.open || !this.isOpening) {
135
+ this.isOpening = false;
136
+ return;
137
+ }
138
+ const preventOpen = !this.dispatchEvent(new Event('open', { cancelable: true }));
139
+ if (preventOpen) {
140
+ this.open = false;
141
+ return;
142
+ }
143
+ // All Material dialogs are modal.
144
+ dialog.showModal();
145
+ this.open = true;
146
+ // Reset scroll position if re-opening a dialog with the same content.
147
+ if (this.scroller) {
148
+ this.scroller.scrollTop = 0;
149
+ }
150
+ // Native modal dialogs ignore autofocus and instead force focus to the
151
+ // first focusable child. Override this behavior if there is a child with
152
+ // an autofocus attribute.
153
+ (_a = this.querySelector('[autofocus]')) === null || _a === void 0 ? void 0 : _a.focus();
154
+ await this.animateDialog(this.getOpenAnimation());
155
+ this.dispatchEvent(new Event('opened'));
156
+ this.isOpening = false;
157
+ }
158
+ /**
159
+ * Closes the dialog and fires a cancelable `close` event. After a dialog's
160
+ * animation, a `closed` event is fired.
161
+ *
162
+ * @param returnValue A return value usually indicating which button was used
163
+ * to close a dialog. If a dialog is canceled by clicking the scrim or
164
+ * pressing Escape, it will not change the return value after closing.
165
+ * @return A Promise that resolves after the animation is finished and the
166
+ * `closed` event was fired.
167
+ */
168
+ async close(returnValue = this.returnValue) {
169
+ this.isOpening = false;
170
+ if (!this.isConnected) {
171
+ // Disconnected dialogs do not fire close events or animate.
172
+ this.open = false;
173
+ return;
174
+ }
175
+ await this.updateComplete;
176
+ const dialog = this.dialog;
177
+ // Check if already closed or if `dialog.show()` was called while awaiting.
178
+ if (!dialog.open || this.isOpening) {
179
+ this.open = false;
180
+ return;
181
+ }
182
+ const prevReturnValue = this.returnValue;
183
+ this.returnValue = returnValue;
184
+ const preventClose = !this.dispatchEvent(new Event('close', { cancelable: true }));
185
+ if (preventClose) {
186
+ this.returnValue = prevReturnValue;
187
+ return;
188
+ }
189
+ await this.animateDialog(this.getCloseAnimation());
190
+ dialog.close(returnValue);
191
+ this.open = false;
192
+ this.dispatchEvent(new Event('closed'));
193
+ }
194
+ connectedCallback() {
195
+ super.connectedCallback();
196
+ this.isConnectedPromiseResolve();
197
+ }
198
+ disconnectedCallback() {
199
+ super.disconnectedCallback();
200
+ this.isConnectedPromise = this.getIsConnectedPromise();
201
+ }
202
+ render() {
203
+ const scrollable = this.open && !(this.isAtScrollTop && this.isAtScrollBottom);
204
+ const classes = {
205
+ 'has-headline': this.hasHeadline,
206
+ 'has-actions': this.hasActions,
207
+ 'has-icon': this.hasIcon,
208
+ scrollable: scrollable,
209
+ 'show-top-divider': scrollable && !this.isAtScrollTop,
210
+ 'show-bottom-divider': scrollable && !this.isAtScrollBottom,
211
+ };
212
+ const { ariaLabel } = this;
213
+ return html `
214
+ <div class="scrim"></div>
215
+ <dialog
216
+ class=${classMap(classes)}
217
+ aria-label=${ariaLabel || nothing}
218
+ aria-labelledby=${this.hasHeadline ? 'headline' : nothing}
219
+ role=${this.type === 'alert' ? 'alertdialog' : nothing}
220
+ @cancel=${this.handleCancel}
221
+ @click=${this.handleDialogClick}
222
+ @close=${this.handleClose}
223
+ @keydown=${this.handleKeydown}
224
+ .returnValue=${this.returnValue || nothing}
225
+ >
226
+ <div class="container" @mousedown=${this.handleContentClick}>
227
+ <div class="headline">
228
+ <div class="icon" aria-hidden="true">
229
+ <slot name="icon" @slotchange=${this.handleIconChange}></slot>
230
+ </div>
231
+ <h2 id="headline" aria-hidden=${!this.hasHeadline || nothing}>
232
+ <slot
233
+ name="headline"
234
+ @slotchange=${this.handleHeadlineChange}
235
+ ></slot>
236
+ </h2>
237
+ <md-divider></md-divider>
238
+ </div>
239
+ <div class="scroller">
240
+ <div class="content">
241
+ <div class="top anchor"></div>
242
+ <slot name="content"></slot>
243
+ <div class="bottom anchor"></div>
244
+ </div>
245
+ </div>
246
+ <div class="actions">
247
+ <md-divider></md-divider>
248
+ <slot name="actions" @slotchange=${this.handleActionsChange}></slot>
249
+ </div>
250
+ </div>
251
+ </dialog>
252
+ `;
253
+ }
254
+ firstUpdated() {
255
+ this.intersectionObserver = new IntersectionObserver(entries => {
256
+ for (const entry of entries) {
257
+ this.handleAnchorIntersection(entry);
258
+ }
259
+ }, { root: this.scroller });
260
+ this.intersectionObserver.observe(this.topAnchor);
261
+ this.intersectionObserver.observe(this.bottomAnchor);
262
+ }
263
+ handleDialogClick() {
264
+ if (this.nextClickIsFromContent) {
265
+ // Avoid doing a layout calculation below if we know the click came from
266
+ // content.
267
+ this.nextClickIsFromContent = false;
268
+ return;
269
+ }
270
+ // Click originated on the backdrop. Native `<dialog>`s will not cancel,
271
+ // but Material dialogs do.
272
+ const preventDefault = !this.dispatchEvent(new Event('cancel', { cancelable: true }));
273
+ if (preventDefault) {
274
+ return;
275
+ }
276
+ this.close();
277
+ }
278
+ handleContentClick() {
279
+ this.nextClickIsFromContent = true;
280
+ }
281
+ handleSubmit(event) {
282
+ var _a;
283
+ const form = event.target;
284
+ const { submitter } = event;
285
+ if (form.method !== 'dialog' || !submitter) {
286
+ return;
287
+ }
288
+ // Close reason is the submitter's value attribute, or the dialog's
289
+ // `returnValue` if there is no attribute.
290
+ this.close((_a = submitter.getAttribute('value')) !== null && _a !== void 0 ? _a : this.returnValue);
291
+ }
292
+ handleCancel(event) {
293
+ if (event.target !== this.dialog) {
294
+ // Ignore any cancel events dispatched by content.
295
+ return;
296
+ }
297
+ this.escapePressedWithoutCancel = false;
298
+ const preventDefault = !redispatchEvent(this, event);
299
+ // We always prevent default on the original dialog event since we'll
300
+ // animate closing it before it actually closes.
301
+ event.preventDefault();
302
+ if (preventDefault) {
303
+ return;
304
+ }
305
+ this.close();
306
+ }
307
+ handleClose() {
308
+ var _a;
309
+ if (!this.escapePressedWithoutCancel) {
310
+ return;
311
+ }
312
+ this.escapePressedWithoutCancel = false;
313
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new Event('cancel', { cancelable: true }));
314
+ }
315
+ handleKeydown(event) {
316
+ if (event.key !== 'Escape') {
317
+ return;
318
+ }
319
+ // An escape key was pressed. If a "close" event fires next without a
320
+ // "cancel" event first, then we know we're in the Chrome v120 bug.
321
+ this.escapePressedWithoutCancel = true;
322
+ // Wait a full task for the cancel/close event listeners to fire, then
323
+ // reset the flag.
324
+ setTimeout(() => {
325
+ this.escapePressedWithoutCancel = false;
326
+ });
327
+ }
328
+ async animateDialog(animation) {
329
+ const { dialog, scrim, container, headline, content, actions } = this;
330
+ if (!dialog || !scrim || !container || !headline || !content || !actions) {
331
+ return;
332
+ }
333
+ const { container: containerAnimate, dialog: dialogAnimate, scrim: scrimAnimate, headline: headlineAnimate, content: contentAnimate, actions: actionsAnimate, } = animation;
334
+ const elementAndAnimation = [
335
+ [dialog, dialogAnimate !== null && dialogAnimate !== void 0 ? dialogAnimate : []],
336
+ [scrim, scrimAnimate !== null && scrimAnimate !== void 0 ? scrimAnimate : []],
337
+ [container, containerAnimate !== null && containerAnimate !== void 0 ? containerAnimate : []],
338
+ [headline, headlineAnimate !== null && headlineAnimate !== void 0 ? headlineAnimate : []],
339
+ [content, contentAnimate !== null && contentAnimate !== void 0 ? contentAnimate : []],
340
+ [actions, actionsAnimate !== null && actionsAnimate !== void 0 ? actionsAnimate : []],
341
+ ];
342
+ const animations = [];
343
+ for (const [element, animation] of elementAndAnimation) {
344
+ for (const animateArgs of animation) {
345
+ animations.push(element.animate(...animateArgs));
346
+ }
347
+ }
348
+ await Promise.all(animations.map(animation => animation.finished));
349
+ }
350
+ handleHeadlineChange(event) {
351
+ const slot = event.target;
352
+ this.hasHeadline = slot.assignedElements().length > 0;
353
+ }
354
+ handleActionsChange(event) {
355
+ const slot = event.target;
356
+ this.hasActions = slot.assignedElements().length > 0;
357
+ }
358
+ handleIconChange(event) {
359
+ const slot = event.target;
360
+ this.hasIcon = slot.assignedElements().length > 0;
361
+ }
362
+ handleAnchorIntersection(entry) {
363
+ const { target, isIntersecting } = entry;
364
+ if (target === this.topAnchor) {
365
+ this.isAtScrollTop = isIntersecting;
366
+ }
367
+ if (target === this.bottomAnchor) {
368
+ this.isAtScrollBottom = isIntersecting;
369
+ }
370
+ }
371
+ getIsConnectedPromise() {
372
+ return new Promise(resolve => {
373
+ this.isConnectedPromiseResolve = resolve;
374
+ });
375
+ }
376
+ }
377
+ (() => {
378
+ requestUpdateOnAriaChange(Dialog);
379
+ })();
380
+ __decorate([
381
+ property({ type: Boolean })
382
+ ], Dialog.prototype, "open", null);
383
+ __decorate([
384
+ property({ attribute: false })
385
+ ], Dialog.prototype, "returnValue", void 0);
386
+ __decorate([
387
+ property()
388
+ ], Dialog.prototype, "type", void 0);
389
+ __decorate([
390
+ query('dialog')
391
+ ], Dialog.prototype, "dialog", void 0);
392
+ __decorate([
393
+ query('.scrim')
394
+ ], Dialog.prototype, "scrim", void 0);
395
+ __decorate([
396
+ query('.container')
397
+ ], Dialog.prototype, "container", void 0);
398
+ __decorate([
399
+ query('.headline')
400
+ ], Dialog.prototype, "headline", void 0);
401
+ __decorate([
402
+ query('.content')
403
+ ], Dialog.prototype, "content", void 0);
404
+ __decorate([
405
+ query('.actions')
406
+ ], Dialog.prototype, "actions", void 0);
407
+ __decorate([
408
+ state()
409
+ ], Dialog.prototype, "isAtScrollTop", void 0);
410
+ __decorate([
411
+ state()
412
+ ], Dialog.prototype, "isAtScrollBottom", void 0);
413
+ __decorate([
414
+ query('.scroller')
415
+ ], Dialog.prototype, "scroller", void 0);
416
+ __decorate([
417
+ query('.top.anchor')
418
+ ], Dialog.prototype, "topAnchor", void 0);
419
+ __decorate([
420
+ query('.bottom.anchor')
421
+ ], Dialog.prototype, "bottomAnchor", void 0);
422
+ __decorate([
423
+ state()
424
+ ], Dialog.prototype, "hasHeadline", void 0);
425
+ __decorate([
426
+ state()
427
+ ], Dialog.prototype, "hasActions", void 0);
428
+ __decorate([
429
+ state()
430
+ ], Dialog.prototype, "hasIcon", void 0);
431
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +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,QA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AAgB,GAAG,cAAc,CAAC;SACxC;IACH,CAAC;IAEO,qBAAqB;QAC3B,OAAO,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;YACjC,IAAI,CAAC,yBAAyB,GAAG,OAAO,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjcC;IACE,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,GAAA,CAAA;AAMD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kCAG3B;AAuB+B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAkB;AAMrC;IAAX,QAAQ,EAAE;oCAAgB;AAuBV;IAAhB,KAAK,CAAC,QAAQ,CAAC;sCAAoD;AAEnD;IAAhB,KAAK,CAAC,QAAQ,CAAC;qCAAmD;AAE9C;IAApB,KAAK,CAAC,YAAY,CAAC;yCAAuD;AAEvD;IAAnB,KAAK,CAAC,WAAW,CAAC;wCAAsD;AAEtD;IAAlB,KAAK,CAAC,UAAU,CAAC;uCAAqD;AAEpD;IAAlB,KAAK,CAAC,UAAU,CAAC;uCAAqD;AAE9D;IAAR,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;AAOnE;IAAR,KAAK,EAAE;2CAA6B;AAE5B;IAAR,KAAK,EAAE;0CAA4B;AAE3B;IAAR,KAAK,EAAE;uCAAyB","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 { requestUpdateOnAriaChange } 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/**\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 */\nexport class Dialog extends LitElement {\n static {\n requestUpdateOnAriaChange(Dialog);\n }\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 * 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 * 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 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 // 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 constructor() {\n super();\n if (!isServer) {\n this.addEventListener('submit', this.handleSubmit);\n\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 // Material requires using focus trapping within the dialog (see\n // b/314840853 for the bug to add it). This would normally mean we don't\n // care about delegating focus since the `<dialog>` never receives it.\n // However, we still need to handle situations when a user has not\n // provided an focusable child in the content. When that happens, the\n // `<dialog>` itself is focused.\n //\n // Listen to focus/blur instead of focusin/focusout since those can bubble\n // from content.\n this.addEventListener('focus', () => {\n this.dialog?.focus();\n });\n this.addEventListener('blur', () => {\n this.dialog?.blur();\n });\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 `autocomplete` 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 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 };\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 <div class=\"container\" @mousedown=${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 </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.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 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 animations.push(element.animate(...animateArgs));\n }\n }\n\n await Promise.all(animations.map(animation => animation.finished));\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"]}
@@ -1 +1 @@
1
- import{css,LitElement,html}from"lit";import{__decorate}from"tslib";import{query,property}from"lit/decorators.js";import{Dialog}from"@material/web/dialog/internal/dialog.js";import{requestUpdateOnAriaChange}from"@material/web/internal/aria/delegate.js";const 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-height:140px;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:flex}::backdrop{background:0 0}.scrim{background:var(--ix-scrim-color,#000);display:none;inset:0;opacity:var(--ix-scrim-opacity,50%);pointer-events:none;position:fixed;z-index:1}:host([open]) .scrim{display:flex}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}.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:hidden;z-index:1}.scrollable .scroller{overflow-y:scroll}.content{color:var(--md-dialog-supporting-text-color,var(--md-sys-color-on-surface-variant,#49454f));font-family:var(--md-dialog-supporting-text-font,var(--md-sys-typescale-body-medium-font,var(--md-ref-typeface-plain,Roboto)));font-size:var(--md-dialog-supporting-text-size,var(--md-sys-typescale-body-medium-size,.875rem));line-height:var(--md-dialog-supporting-text-line-height,var(--md-sys-typescale-body-medium-line-height,1.25rem));font-weight:var(--md-dialog-supporting-text-weight,var(--md-sys-typescale-body-medium-weight,var(--md-ref-typeface-weight-regular,400)));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);class IxDialog extends LitElement{constructor(){super(...arguments),this.open=!1}onOpen(){this.dispatchEvent(new Event("open"))}onOpened(){this.dispatchEvent(new Event("opened"))}onClose(){this.dispatchEvent(new Event("close"))}onClosed(){this.dispatchEvent(new Event("closed"))}onCancel(){this.dispatchEvent(new Event("cancel"))}render(){return html`<md-dialog ?open="${this.open}" class="dialog" @open="${this.onOpen}" @opened="${this.onOpened}" @close="${this.onClose}" @closed="${this.onClosed}" @cancel="${this.onCancel}"><slot slot="headline" name="headline"></slot><slot slot="content" name="content"></slot><slot slot="actions" name="actions"></slot>></md-dialog>`}}requestUpdateOnAriaChange(IxDialog),IxDialog.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0},__decorate([query(".dialog")],IxDialog.prototype,"component",void 0),__decorate([property({type:Boolean,reflect:!0})],IxDialog.prototype,"open",void 0);class IxDialogStyled extends IxDialog{}IxDialogStyled.styles=css`:host,:host :root,:root{font-size:var(--ix-dialog-font-size,.875rem);line-height:var(--ix-dialog-line-height,1.25rem)}.dialog{max-height:90vh;max-width:90vw;background:red;font-size:var(--ix-dialog-font-size,.875rem);line-height:var(--ix-dialog-line-height,1.25rem)}`,window.customElements.define("ix-dialog",IxDialogStyled);export{IxDialogStyled};
1
+ import{LitElement,isServer,html,nothing,css}from"lit";import{__decorate}from"tslib";import{property,query,state}from"lit/decorators.js";import"@material/web/divider/divider.js";import{classMap}from"lit/directives/class-map.js";import{requestUpdateOnAriaChange}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";class Dialog extends LitElement{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.returnValue="",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,isServer||(this.addEventListener("submit",this.handleSubmit),this.addEventListener("focus",()=>{var e;null!=(e=this.dialog)&&e.focus()}),this.addEventListener("blur",()=>{var e;null!=(e=this.dialog)&&e.blur()}))}async show(){this.isOpening=!0,await this.isConnectedPromise,await this.updateComplete;var e=this.dialog;e.open||!this.isOpening?this.isOpening=!1:!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,i;this.isOpening=!1,!this.isConnected||(await this.updateComplete,!(t=this.dialog).open)||this.isOpening?this.open=!1:(i=this.returnValue,this.returnValue=e,!this.dispatchEvent(new Event("close",{cancelable:!0}))?this.returnValue=i:(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},t=this.ariaLabel;return html`<div class="scrim"></div><dialog class="${classMap(e)}" aria-label="${t||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}"><div class="container" @mousedown="${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></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.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){var{dialog:i,scrim:o,container:a,headline:n,content:s,actions:l}=this;if(i&&o&&a&&n&&s&&l){var{container:r,dialog:d,scrim:h,headline:c,content:p,actions:m}=e,g=[];for(let[e,t]of[[i,null!=d?d:[]],[o,null!=h?h:[]],[a,null!=r?r:[]],[n,null!=c?c:[]],[s,null!=p?p:[]],[l,null!=m?m:[]]])for(var v of t)g.push(e.animate(...v));await Promise.all(g.map(e=>e.finished))}}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})}}requestUpdateOnAriaChange(Dialog),__decorate([property({type:Boolean})],Dialog.prototype,"open",null),__decorate([property({attribute:!1})],Dialog.prototype,"returnValue",void 0),__decorate([property()],Dialog.prototype,"type",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([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-height:140px;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:flex}::backdrop{background:0 0}.scrim{background:var(--ix-scrim-color,#000);display:none;inset:0;opacity:var(--ix-scrim-opacity,50%);pointer-events:none;position:fixed;z-index:1}:host([open]) .scrim{display:flex}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}.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:hidden;z-index:1}.scrollable .scroller{overflow-y:scroll}.content{color:var(--md-dialog-supporting-text-color,var(--md-sys-color-on-surface-variant,#49454f));font-family:var(--md-dialog-supporting-text-font,var(--md-sys-typescale-body-medium-font,var(--md-ref-typeface-plain,Roboto)));font-size:var(--md-dialog-supporting-text-size,var(--md-sys-typescale-body-medium-size,.875rem));line-height:var(--md-dialog-supporting-text-line-height,var(--md-sys-typescale-body-medium-line-height,1.25rem));font-weight:var(--md-dialog-supporting-text-weight,var(--md-sys-typescale-body-medium-weight,var(--md-ref-typeface-weight-regular,400)));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);class IxDialog extends LitElement{constructor(){super(...arguments),this.open=!1}onOpen(){this.dispatchEvent(new Event("open"))}onOpened(){this.dispatchEvent(new Event("opened"))}onClose(){this.dispatchEvent(new Event("close"))}onClosed(){this.dispatchEvent(new Event("closed"))}onCancel(){this.dispatchEvent(new Event("cancel"))}render(){return html`<md-dialog ?open="${this.open}" class="dialog" @open="${this.onOpen}" @opened="${this.onOpened}" @close="${this.onClose}" @closed="${this.onClosed}" @cancel="${this.onCancel}"><slot slot="headline" name="headline"></slot><slot slot="content" name="content"></slot><slot slot="actions" name="actions"></slot>></md-dialog>`}}requestUpdateOnAriaChange(IxDialog),IxDialog.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0},__decorate([query(".dialog")],IxDialog.prototype,"component",void 0),__decorate([property({type:Boolean,reflect:!0})],IxDialog.prototype,"open",void 0);class IxDialogStyled extends IxDialog{}IxDialogStyled.styles=css`:host,:host :root,:root{font-size:var(--ix-dialog-font-size,.875rem);line-height:var(--ix-dialog-line-height,1.25rem)}.dialog{max-height:90vh;max-width:90vw;background:red;font-size:var(--ix-dialog-font-size,.875rem);line-height:var(--ix-dialog-line-height,1.25rem)}`,window.customElements.define("ix-dialog",IxDialogStyled);export{IxDialogStyled};
@@ -1,5 +1,5 @@
1
1
  import { CSSResultOrNative } from 'lit';
2
- import { Dialog } from '@material/web/dialog/internal/dialog.js';
2
+ import { Dialog } from './internal/dialog.js';
3
3
  export declare const styles: import("lit").CSSResult;
4
4
  export declare class MdDialog extends Dialog {
5
5
  static styles: CSSResultOrNative[];
package/dist/md-dialog.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { css } from 'lit';
2
- import { Dialog } from '@material/web/dialog/internal/dialog.js';
2
+ import { Dialog } from './internal/dialog.js';
3
3
  export const styles = css `
4
4
  :host {
5
5
  border-start-start-radius: var(
@@ -1 +1 @@
1
- {"version":3,"file":"md-dialog.js","sourceRoot":"","sources":["../src/md-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,GAAG,EAAE,MAAM,KAAK,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AAEjE,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkRxB,CAAC;AAEF,MAAM,OAAO,QAAS,SAAQ,MAAM;;AAClB,eAAM,GAAwB,CAAC,MAAM,CAAC,CAAC;AAGzD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { CSSResultOrNative, css } from 'lit';\n\nimport { Dialog } from '@material/web/dialog/internal/dialog.js';\n\nexport const styles = css`\n :host {\n border-start-start-radius: var(\n --md-dialog-container-shape-start-start,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n border-start-end-radius: var(\n --md-dialog-container-shape-start-end,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n border-end-end-radius: var(\n --md-dialog-container-shape-end-end,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n border-end-start-radius: var(\n --md-dialog-container-shape-end-start,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n display: contents;\n margin: auto;\n max-height: min(560px, 100% - 48px);\n max-width: min(560px, 100% - 48px);\n min-height: 140px;\n min-width: 280px;\n position: fixed;\n height: fit-content;\n width: fit-content;\n }\n\n dialog {\n background: rgba(0, 0, 0, 0);\n border: none;\n border-radius: inherit;\n box-shadow: 0px 12px 16px 0px rgba(0, 0, 0, 0.58);\n flex-direction: column;\n height: inherit;\n margin: inherit;\n max-height: inherit;\n max-width: inherit;\n min-height: inherit;\n min-width: inherit;\n outline: none;\n overflow: visible;\n padding: 0;\n width: inherit;\n }\n\n dialog[open] {\n display: flex;\n }\n\n ::backdrop {\n background: none;\n }\n\n .scrim {\n background: var(--ix-scrim-color, #000);\n display: none;\n inset: 0;\n opacity: var(--ix-scrim-opacity, 50%);\n pointer-events: none;\n position: fixed;\n z-index: 1;\n }\n\n :host([open]) .scrim {\n display: flex;\n }\n\n h2 {\n all: unset;\n align-self: stretch;\n }\n\n .headline {\n align-items: center;\n color: var(\n --md-dialog-headline-color,\n var(--md-sys-color-on-surface, #1d1b20)\n );\n display: flex;\n flex-direction: column;\n font-family: var(\n --md-dialog-headline-font,\n var(\n --md-sys-typescale-headline-small-font,\n var(--md-ref-typeface-brand, Roboto)\n )\n );\n font-size: var(\n --md-dialog-headline-size,\n var(--md-sys-typescale-headline-small-size, 1.5rem)\n );\n line-height: var(\n --md-dialog-headline-line-height,\n var(--md-sys-typescale-headline-small-line-height, 2rem)\n );\n font-weight: var(\n --md-dialog-headline-weight,\n var(\n --md-sys-typescale-headline-small-weight,\n var(--md-ref-typeface-weight-regular, 400)\n )\n );\n position: relative;\n }\n\n slot[name='headline']::slotted(*) {\n align-items: center;\n align-self: stretch;\n box-sizing: border-box;\n display: flex;\n gap: 8px;\n padding: 24px 24px 0;\n }\n\n .icon {\n display: flex;\n }\n\n slot[name='icon']::slotted(*) {\n color: var(--md-dialog-icon-color, var(--md-sys-color-secondary, #625b71));\n fill: currentColor;\n font-size: var(--md-dialog-icon-size, 24px);\n margin-top: 24px;\n height: var(--md-dialog-icon-size, 24px);\n width: var(--md-dialog-icon-size, 24px);\n }\n\n .has-icon slot[name='headline']::slotted(*) {\n justify-content: center;\n padding-top: 16px;\n }\n\n .scrollable slot[name='headline']::slotted(*) {\n padding-bottom: 16px;\n }\n\n .scrollable.has-headline slot[name='content']::slotted(*) {\n padding-top: 8px;\n }\n\n .container {\n border-radius: inherit;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n overflow: hidden;\n position: relative;\n transform-origin: top;\n }\n\n .container::before {\n background: var(\n --md-dialog-container-color,\n var(--md-sys-color-surface-container-high, #ece6f0)\n );\n border-radius: inherit;\n content: '';\n inset: 0;\n position: absolute;\n }\n\n .scroller {\n display: flex;\n flex: 1;\n flex-direction: column;\n overflow: hidden;\n z-index: 1;\n }\n\n .scrollable .scroller {\n overflow-y: scroll;\n }\n\n .content {\n color: var(\n --md-dialog-supporting-text-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n );\n font-family: var(\n --md-dialog-supporting-text-font,\n var(\n --md-sys-typescale-body-medium-font,\n var(--md-ref-typeface-plain, Roboto)\n )\n );\n font-size: var(\n --md-dialog-supporting-text-size,\n var(--md-sys-typescale-body-medium-size, 0.875rem)\n );\n line-height: var(\n --md-dialog-supporting-text-line-height,\n var(--md-sys-typescale-body-medium-line-height, 1.25rem)\n );\n font-weight: var(\n --md-dialog-supporting-text-weight,\n var(\n --md-sys-typescale-body-medium-weight,\n var(--md-ref-typeface-weight-regular, 400)\n )\n );\n height: min-content;\n position: relative;\n }\n\n slot[name='content']::slotted(*) {\n box-sizing: border-box;\n padding: 24px;\n }\n\n .anchor {\n position: absolute;\n }\n\n .top.anchor {\n top: 0;\n }\n\n .bottom.anchor {\n bottom: 0;\n }\n\n .actions {\n position: relative;\n }\n\n slot[name='actions']::slotted(*) {\n box-sizing: border-box;\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n padding: 16px 24px 24px;\n }\n\n .has-actions slot[name='content']::slotted(*) {\n padding-bottom: 8px;\n }\n\n md-divider {\n display: none;\n position: absolute;\n }\n\n .has-headline.show-top-divider .headline md-divider,\n .has-actions.show-bottom-divider .actions md-divider {\n display: flex;\n }\n\n .headline md-divider {\n bottom: 0;\n }\n\n .actions md-divider {\n top: 0;\n }\n\n @media (forced-colors: active) {\n dialog {\n outline: 2px solid WindowText;\n }\n }\n`;\n\nexport class MdDialog extends Dialog {\n static override styles: CSSResultOrNative[] = [styles];\n}\n\nwindow.customElements.define('md-dialog', MdDialog);\n"]}
1
+ {"version":3,"file":"md-dialog.js","sourceRoot":"","sources":["../src/md-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,GAAG,EAAE,MAAM,KAAK,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkRxB,CAAC;AAEF,MAAM,OAAO,QAAS,SAAQ,MAAM;;AAClB,eAAM,GAAwB,CAAC,MAAM,CAAC,CAAC;AAGzD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { CSSResultOrNative, css } from 'lit';\n\nimport { Dialog } from './internal/dialog.js';\n\nexport const styles = css`\n :host {\n border-start-start-radius: var(\n --md-dialog-container-shape-start-start,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n border-start-end-radius: var(\n --md-dialog-container-shape-start-end,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n border-end-end-radius: var(\n --md-dialog-container-shape-end-end,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n border-end-start-radius: var(\n --md-dialog-container-shape-end-start,\n var(\n --md-dialog-container-shape,\n var(--md-sys-shape-corner-extra-large, 28px)\n )\n );\n display: contents;\n margin: auto;\n max-height: min(560px, 100% - 48px);\n max-width: min(560px, 100% - 48px);\n min-height: 140px;\n min-width: 280px;\n position: fixed;\n height: fit-content;\n width: fit-content;\n }\n\n dialog {\n background: rgba(0, 0, 0, 0);\n border: none;\n border-radius: inherit;\n box-shadow: 0px 12px 16px 0px rgba(0, 0, 0, 0.58);\n flex-direction: column;\n height: inherit;\n margin: inherit;\n max-height: inherit;\n max-width: inherit;\n min-height: inherit;\n min-width: inherit;\n outline: none;\n overflow: visible;\n padding: 0;\n width: inherit;\n }\n\n dialog[open] {\n display: flex;\n }\n\n ::backdrop {\n background: none;\n }\n\n .scrim {\n background: var(--ix-scrim-color, #000);\n display: none;\n inset: 0;\n opacity: var(--ix-scrim-opacity, 50%);\n pointer-events: none;\n position: fixed;\n z-index: 1;\n }\n\n :host([open]) .scrim {\n display: flex;\n }\n\n h2 {\n all: unset;\n align-self: stretch;\n }\n\n .headline {\n align-items: center;\n color: var(\n --md-dialog-headline-color,\n var(--md-sys-color-on-surface, #1d1b20)\n );\n display: flex;\n flex-direction: column;\n font-family: var(\n --md-dialog-headline-font,\n var(\n --md-sys-typescale-headline-small-font,\n var(--md-ref-typeface-brand, Roboto)\n )\n );\n font-size: var(\n --md-dialog-headline-size,\n var(--md-sys-typescale-headline-small-size, 1.5rem)\n );\n line-height: var(\n --md-dialog-headline-line-height,\n var(--md-sys-typescale-headline-small-line-height, 2rem)\n );\n font-weight: var(\n --md-dialog-headline-weight,\n var(\n --md-sys-typescale-headline-small-weight,\n var(--md-ref-typeface-weight-regular, 400)\n )\n );\n position: relative;\n }\n\n slot[name='headline']::slotted(*) {\n align-items: center;\n align-self: stretch;\n box-sizing: border-box;\n display: flex;\n gap: 8px;\n padding: 24px 24px 0;\n }\n\n .icon {\n display: flex;\n }\n\n slot[name='icon']::slotted(*) {\n color: var(--md-dialog-icon-color, var(--md-sys-color-secondary, #625b71));\n fill: currentColor;\n font-size: var(--md-dialog-icon-size, 24px);\n margin-top: 24px;\n height: var(--md-dialog-icon-size, 24px);\n width: var(--md-dialog-icon-size, 24px);\n }\n\n .has-icon slot[name='headline']::slotted(*) {\n justify-content: center;\n padding-top: 16px;\n }\n\n .scrollable slot[name='headline']::slotted(*) {\n padding-bottom: 16px;\n }\n\n .scrollable.has-headline slot[name='content']::slotted(*) {\n padding-top: 8px;\n }\n\n .container {\n border-radius: inherit;\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n overflow: hidden;\n position: relative;\n transform-origin: top;\n }\n\n .container::before {\n background: var(\n --md-dialog-container-color,\n var(--md-sys-color-surface-container-high, #ece6f0)\n );\n border-radius: inherit;\n content: '';\n inset: 0;\n position: absolute;\n }\n\n .scroller {\n display: flex;\n flex: 1;\n flex-direction: column;\n overflow: hidden;\n z-index: 1;\n }\n\n .scrollable .scroller {\n overflow-y: scroll;\n }\n\n .content {\n color: var(\n --md-dialog-supporting-text-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n );\n font-family: var(\n --md-dialog-supporting-text-font,\n var(\n --md-sys-typescale-body-medium-font,\n var(--md-ref-typeface-plain, Roboto)\n )\n );\n font-size: var(\n --md-dialog-supporting-text-size,\n var(--md-sys-typescale-body-medium-size, 0.875rem)\n );\n line-height: var(\n --md-dialog-supporting-text-line-height,\n var(--md-sys-typescale-body-medium-line-height, 1.25rem)\n );\n font-weight: var(\n --md-dialog-supporting-text-weight,\n var(\n --md-sys-typescale-body-medium-weight,\n var(--md-ref-typeface-weight-regular, 400)\n )\n );\n height: min-content;\n position: relative;\n }\n\n slot[name='content']::slotted(*) {\n box-sizing: border-box;\n padding: 24px;\n }\n\n .anchor {\n position: absolute;\n }\n\n .top.anchor {\n top: 0;\n }\n\n .bottom.anchor {\n bottom: 0;\n }\n\n .actions {\n position: relative;\n }\n\n slot[name='actions']::slotted(*) {\n box-sizing: border-box;\n display: flex;\n gap: 8px;\n justify-content: flex-end;\n padding: 16px 24px 24px;\n }\n\n .has-actions slot[name='content']::slotted(*) {\n padding-bottom: 8px;\n }\n\n md-divider {\n display: none;\n position: absolute;\n }\n\n .has-headline.show-top-divider .headline md-divider,\n .has-actions.show-bottom-divider .actions md-divider {\n display: flex;\n }\n\n .headline md-divider {\n bottom: 0;\n }\n\n .actions md-divider {\n top: 0;\n }\n\n @media (forced-colors: active) {\n dialog {\n outline: 2px solid WindowText;\n }\n }\n`;\n\nexport class MdDialog extends Dialog {\n static override styles: CSSResultOrNative[] = [styles];\n}\n\nwindow.customElements.define('md-dialog', MdDialog);\n"]}
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.0.26",
6
+ "version": "1.0.28",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.js",
@@ -30,7 +30,8 @@
30
30
  "@lit/react": "^1.0.2",
31
31
  "@material/web": "1.2.0",
32
32
  "lit": "^2.7.6",
33
- "react": "^18.2.0"
33
+ "react": "^18.2.0",
34
+ "tslib": "^2.3.1"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@custom-elements-manifest/analyzer": "^0.4.17",
@@ -99,5 +100,5 @@
99
100
  "README.md",
100
101
  "LICENSE"
101
102
  ],
102
- "gitHead": "7c374b2f2035622c10293676a3122eb4ead4fa82"
103
+ "gitHead": "dc83d7ba595b824274ec44de0918b5b826fcd3ed"
103
104
  }