@digital-realty/ix-dialog 1.0.28 → 1.0.30-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IxDialog.d.ts +21 -21
- package/dist/IxDialog.js +43 -43
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/dialog.d.ts +107 -107
- package/dist/internal/dialog.js +391 -391
- package/dist/ix-dialog.d.ts +4 -4
- package/dist/ix-dialog.js +6 -6
- package/dist/md-dialog.d.ts +6 -6
- package/dist/md-dialog.js +7 -7
- package/dist/react/IxDialog.d.ts +2 -2
- package/dist/react/IxDialog.js +9 -9
- package/package.json +2 -2
package/dist/IxDialog.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import './md-dialog.js';
|
|
3
|
-
import { Dialog } from './internal/dialog.js';
|
|
4
|
-
export declare class IxDialog extends LitElement {
|
|
5
|
-
/** @nocollapse */
|
|
6
|
-
static shadowRootOptions: {
|
|
7
|
-
delegatesFocus: boolean;
|
|
8
|
-
mode: ShadowRootMode;
|
|
9
|
-
slotAssignment?: SlotAssignmentMode | undefined;
|
|
10
|
-
customElements?: CustomElementRegistry | undefined;
|
|
11
|
-
registry?: CustomElementRegistry | undefined;
|
|
12
|
-
};
|
|
13
|
-
readonly component: Dialog;
|
|
14
|
-
open: boolean;
|
|
15
|
-
onOpen(): void;
|
|
16
|
-
onOpened(): void;
|
|
17
|
-
onClose(): void;
|
|
18
|
-
onClosed(): void;
|
|
19
|
-
onCancel(): void;
|
|
20
|
-
render(): import("lit").TemplateResult<1>;
|
|
21
|
-
}
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import './md-dialog.js';
|
|
3
|
+
import { Dialog } from './internal/dialog.js';
|
|
4
|
+
export declare class IxDialog extends LitElement {
|
|
5
|
+
/** @nocollapse */
|
|
6
|
+
static shadowRootOptions: {
|
|
7
|
+
delegatesFocus: boolean;
|
|
8
|
+
mode: ShadowRootMode;
|
|
9
|
+
slotAssignment?: SlotAssignmentMode | undefined;
|
|
10
|
+
customElements?: CustomElementRegistry | undefined;
|
|
11
|
+
registry?: CustomElementRegistry | undefined;
|
|
12
|
+
};
|
|
13
|
+
readonly component: Dialog;
|
|
14
|
+
open: boolean;
|
|
15
|
+
onOpen(): void;
|
|
16
|
+
onOpened(): void;
|
|
17
|
+
onClose(): void;
|
|
18
|
+
onClosed(): void;
|
|
19
|
+
onCancel(): void;
|
|
20
|
+
render(): import("lit").TemplateResult<1>;
|
|
21
|
+
}
|
package/dist/IxDialog.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { html, LitElement } from 'lit';
|
|
3
|
-
import { property, query } from 'lit/decorators.js';
|
|
4
|
-
import './md-dialog.js';
|
|
5
|
-
import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
|
|
6
|
-
export class IxDialog extends LitElement {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.open = false;
|
|
10
|
-
}
|
|
11
|
-
onOpen() {
|
|
12
|
-
this.dispatchEvent(new Event('open'));
|
|
13
|
-
}
|
|
14
|
-
onOpened() {
|
|
15
|
-
this.dispatchEvent(new Event('opened'));
|
|
16
|
-
}
|
|
17
|
-
onClose() {
|
|
18
|
-
this.dispatchEvent(new Event('close'));
|
|
19
|
-
}
|
|
20
|
-
onClosed() {
|
|
21
|
-
this.dispatchEvent(new Event('closed'));
|
|
22
|
-
}
|
|
23
|
-
onCancel() {
|
|
24
|
-
this.dispatchEvent(new Event('cancel'));
|
|
25
|
-
}
|
|
26
|
-
render() {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, LitElement } from 'lit';
|
|
3
|
+
import { property, query } from 'lit/decorators.js';
|
|
4
|
+
import './md-dialog.js';
|
|
5
|
+
import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
|
|
6
|
+
export class IxDialog extends LitElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.open = false;
|
|
10
|
+
}
|
|
11
|
+
onOpen() {
|
|
12
|
+
this.dispatchEvent(new Event('open'));
|
|
13
|
+
}
|
|
14
|
+
onOpened() {
|
|
15
|
+
this.dispatchEvent(new Event('opened'));
|
|
16
|
+
}
|
|
17
|
+
onClose() {
|
|
18
|
+
this.dispatchEvent(new Event('close'));
|
|
19
|
+
}
|
|
20
|
+
onClosed() {
|
|
21
|
+
this.dispatchEvent(new Event('closed'));
|
|
22
|
+
}
|
|
23
|
+
onCancel() {
|
|
24
|
+
this.dispatchEvent(new Event('cancel'));
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
27
|
return html `
|
|
28
28
|
<md-dialog
|
|
29
29
|
?open=${this.open}
|
|
@@ -39,21 +39,21 @@ export class IxDialog extends LitElement {
|
|
|
39
39
|
<slot slot="actions" name="actions"></slot>
|
|
40
40
|
></md-dialog
|
|
41
41
|
>
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
(() => {
|
|
46
|
-
requestUpdateOnAriaChange(IxDialog);
|
|
47
|
-
})();
|
|
48
|
-
/** @nocollapse */
|
|
49
|
-
IxDialog.shadowRootOptions = {
|
|
50
|
-
...LitElement.shadowRootOptions,
|
|
51
|
-
delegatesFocus: true,
|
|
52
|
-
};
|
|
53
|
-
__decorate([
|
|
54
|
-
query('.dialog')
|
|
55
|
-
], IxDialog.prototype, "component", void 0);
|
|
56
|
-
__decorate([
|
|
57
|
-
property({ type: Boolean, reflect: true })
|
|
58
|
-
], IxDialog.prototype, "open", void 0);
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
(() => {
|
|
46
|
+
requestUpdateOnAriaChange(IxDialog);
|
|
47
|
+
})();
|
|
48
|
+
/** @nocollapse */
|
|
49
|
+
IxDialog.shadowRootOptions = {
|
|
50
|
+
...LitElement.shadowRootOptions,
|
|
51
|
+
delegatesFocus: true,
|
|
52
|
+
};
|
|
53
|
+
__decorate([
|
|
54
|
+
query('.dialog')
|
|
55
|
+
], IxDialog.prototype, "component", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
property({ type: Boolean, reflect: true })
|
|
58
|
+
], IxDialog.prototype, "open", void 0);
|
|
59
59
|
//# sourceMappingURL=IxDialog.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { IxDialog } from './IxDialog.js';
|
|
1
|
+
export { IxDialog } from './IxDialog.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { IxDialog } from './IxDialog.js';
|
|
1
|
+
export { IxDialog } from './IxDialog.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,107 +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
|
-
}
|
|
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
|
+
}
|
package/dist/internal/dialog.js
CHANGED
|
@@ -1,215 +1,215 @@
|
|
|
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;
|
|
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
213
|
return html `
|
|
214
214
|
<div class="scrim"></div>
|
|
215
215
|
<dialog
|
|
@@ -249,183 +249,183 @@ export class Dialog extends LitElement {
|
|
|
249
249
|
</div>
|
|
250
250
|
</div>
|
|
251
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);
|
|
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
431
|
//# sourceMappingURL=dialog.js.map
|
package/dist/ix-dialog.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IxDialog } from './IxDialog.js';
|
|
2
|
-
export declare class IxDialogStyled extends IxDialog {
|
|
3
|
-
static styles: import("lit").CSSResult;
|
|
4
|
-
}
|
|
1
|
+
import { IxDialog } from './IxDialog.js';
|
|
2
|
+
export declare class IxDialogStyled extends IxDialog {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
}
|
package/dist/ix-dialog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { css } from 'lit';
|
|
2
|
-
import { IxDialog } from './IxDialog.js';
|
|
3
|
-
export class IxDialogStyled extends IxDialog {
|
|
4
|
-
}
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { IxDialog } from './IxDialog.js';
|
|
3
|
+
export class IxDialogStyled extends IxDialog {
|
|
4
|
+
}
|
|
5
5
|
IxDialogStyled.styles = css `
|
|
6
6
|
:root,
|
|
7
7
|
:host :root,
|
|
@@ -17,6 +17,6 @@ IxDialogStyled.styles = css `
|
|
|
17
17
|
font-size: var(--ix-dialog-font-size, 0.875rem);
|
|
18
18
|
line-height: var(--ix-dialog-line-height, 1.25rem);
|
|
19
19
|
}
|
|
20
|
-
`;
|
|
21
|
-
window.customElements.define('ix-dialog', IxDialogStyled);
|
|
20
|
+
`;
|
|
21
|
+
window.customElements.define('ix-dialog', IxDialogStyled);
|
|
22
22
|
//# sourceMappingURL=ix-dialog.js.map
|
package/dist/md-dialog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CSSResultOrNative } from 'lit';
|
|
2
|
-
import { Dialog } from './internal/dialog.js';
|
|
3
|
-
export declare const styles: import("lit").CSSResult;
|
|
4
|
-
export declare class MdDialog extends Dialog {
|
|
5
|
-
static styles: CSSResultOrNative[];
|
|
6
|
-
}
|
|
1
|
+
import { CSSResultOrNative } from 'lit';
|
|
2
|
+
import { Dialog } from './internal/dialog.js';
|
|
3
|
+
export declare const styles: import("lit").CSSResult;
|
|
4
|
+
export declare class MdDialog extends Dialog {
|
|
5
|
+
static styles: CSSResultOrNative[];
|
|
6
|
+
}
|
package/dist/md-dialog.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { css } from 'lit';
|
|
2
|
-
import { Dialog } from './internal/dialog.js';
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
import { Dialog } from './internal/dialog.js';
|
|
3
3
|
export const styles = css `
|
|
4
4
|
:host {
|
|
5
5
|
border-start-start-radius: var(
|
|
@@ -274,9 +274,9 @@ export const styles = css `
|
|
|
274
274
|
outline: 2px solid WindowText;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
`;
|
|
278
|
-
export class MdDialog extends Dialog {
|
|
279
|
-
}
|
|
280
|
-
MdDialog.styles = [styles];
|
|
281
|
-
window.customElements.define('md-dialog', MdDialog);
|
|
277
|
+
`;
|
|
278
|
+
export class MdDialog extends Dialog {
|
|
279
|
+
}
|
|
280
|
+
MdDialog.styles = [styles];
|
|
281
|
+
window.customElements.define('md-dialog', MdDialog);
|
|
282
282
|
//# sourceMappingURL=md-dialog.js.map
|
package/dist/react/IxDialog.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IxDialog as LitComp } from '../IxDialog.js';
|
|
2
|
-
export declare const IxDialog: import("@lit/react").ReactWebComponent<LitComp, {}>;
|
|
1
|
+
import { IxDialog as LitComp } from '../IxDialog.js';
|
|
2
|
+
export declare const IxDialog: import("@lit/react").ReactWebComponent<LitComp, {}>;
|
package/dist/react/IxDialog.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createComponent } from '@lit/react';
|
|
3
|
-
import { IxDialog as LitComp } from '../IxDialog.js';
|
|
4
|
-
customElements.define('ix-dialog', LitComp);
|
|
5
|
-
export const IxDialog = createComponent({
|
|
6
|
-
tagName: 'ix-dialog',
|
|
7
|
-
elementClass: LitComp,
|
|
8
|
-
react: React,
|
|
9
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import { IxDialog as LitComp } from '../IxDialog.js';
|
|
4
|
+
customElements.define('ix-dialog', LitComp);
|
|
5
|
+
export const IxDialog = createComponent({
|
|
6
|
+
tagName: 'ix-dialog',
|
|
7
|
+
elementClass: LitComp,
|
|
8
|
+
react: React,
|
|
9
|
+
});
|
|
10
10
|
//# sourceMappingURL=IxDialog.js.map
|
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.
|
|
6
|
+
"version": "1.0.30-alpha.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"README.md",
|
|
101
101
|
"LICENSE"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "020de6dab25bbe6058e9a71b2c56681822403481"
|
|
104
104
|
}
|