@fluid-topics/ft-modal 1.3.31 → 1.3.33
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/build/ft-modal.d.ts +5 -3
- package/build/ft-modal.js +31 -10
- package/build/ft-modal.light.js +142 -134
- package/build/ft-modal.min.js +143 -135
- package/build/ft-modal.styles.d.ts +2 -1
- package/build/ft-modal.styles.js +21 -10
- package/package.json +4 -4
package/build/ft-modal.d.ts
CHANGED
|
@@ -9,12 +9,14 @@ export declare class FtModal extends FtModal_base implements FtModalProperties {
|
|
|
9
9
|
buttonIcon?: string;
|
|
10
10
|
heading: string;
|
|
11
11
|
icon?: string;
|
|
12
|
-
|
|
13
|
-
private dialog;
|
|
12
|
+
dialog?: HTMLDialogElement;
|
|
14
13
|
size: DesignSystemSize;
|
|
15
14
|
constructor();
|
|
16
15
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
17
|
-
|
|
16
|
+
protected onTriggerClick(e: MouseEvent): void;
|
|
17
|
+
protected elementToFocusOnClose?: HTMLElement;
|
|
18
|
+
private intersectionObserver;
|
|
19
|
+
open(elementToFocusOnClose?: HTMLElement): void;
|
|
18
20
|
close(): void;
|
|
19
21
|
disconnectedCallback(): void;
|
|
20
22
|
private onClose;
|
package/build/ft-modal.js
CHANGED
|
@@ -23,12 +23,22 @@ class FtModalCloseEvent extends Event {
|
|
|
23
23
|
super("close");
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
class FtModalOpenEvent extends Event {
|
|
27
|
+
constructor() {
|
|
28
|
+
super("open");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
26
31
|
class FtModal extends withI18n(FtdsBase) {
|
|
27
32
|
constructor() {
|
|
28
33
|
super();
|
|
29
34
|
this.buttonLabel = "";
|
|
30
35
|
this.heading = "";
|
|
31
36
|
this.size = DesignSystemSize.small;
|
|
37
|
+
this.intersectionObserver = new IntersectionObserver(() => {
|
|
38
|
+
if (this.dialog && !this.dialog.checkVisibility()) {
|
|
39
|
+
this.close();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
32
42
|
this.addI18nContext(ftModalContext, defaultFtModalMessages);
|
|
33
43
|
}
|
|
34
44
|
render() {
|
|
@@ -37,9 +47,11 @@ class FtModal extends withI18n(FtdsBase) {
|
|
|
37
47
|
};
|
|
38
48
|
return html `
|
|
39
49
|
<div class="${classMap(classes)}" part="container">
|
|
40
|
-
<
|
|
41
|
-
${
|
|
42
|
-
|
|
50
|
+
<slot @click=${this.onTriggerClick} name="trigger">
|
|
51
|
+
<ft-button part="button" icon="${ifDefined(this.buttonIcon)}" label="${this.buttonLabel}" ariaHasPopup="dialog">
|
|
52
|
+
${when(this.buttonIcon, () => nothing, () => this.buttonLabel)}
|
|
53
|
+
</ft-button>
|
|
54
|
+
</slot>
|
|
43
55
|
<dialog part="dialog" aria-labelledby="heading" @close=${this.onClose}>
|
|
44
56
|
<div part="overlay" @click=${this.onOverlayClick}></div>
|
|
45
57
|
<div part="inner-container">
|
|
@@ -54,6 +66,7 @@ class FtModal extends withI18n(FtdsBase) {
|
|
|
54
66
|
icon="${FtIcons.CLOSE}"
|
|
55
67
|
tertiary
|
|
56
68
|
label="${modal.messages.closeModal()}"
|
|
69
|
+
tooltipPosition="left"
|
|
57
70
|
@click=${this.close}>
|
|
58
71
|
</ft-button>
|
|
59
72
|
</div>
|
|
@@ -70,11 +83,20 @@ class FtModal extends withI18n(FtdsBase) {
|
|
|
70
83
|
</div>
|
|
71
84
|
`;
|
|
72
85
|
}
|
|
73
|
-
|
|
74
|
-
this.
|
|
86
|
+
onTriggerClick(e) {
|
|
87
|
+
this.open(e.target);
|
|
88
|
+
}
|
|
89
|
+
open(elementToFocusOnClose) {
|
|
90
|
+
this.elementToFocusOnClose = elementToFocusOnClose;
|
|
91
|
+
if (this.dialog) {
|
|
92
|
+
this.dialog.showModal();
|
|
93
|
+
this.intersectionObserver.observe(this.dialog);
|
|
94
|
+
this.dispatchEvent(new FtModalOpenEvent());
|
|
95
|
+
}
|
|
75
96
|
}
|
|
76
97
|
close() {
|
|
77
|
-
|
|
98
|
+
var _a;
|
|
99
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close();
|
|
78
100
|
this.onClose();
|
|
79
101
|
}
|
|
80
102
|
disconnectedCallback() {
|
|
@@ -82,7 +104,9 @@ class FtModal extends withI18n(FtdsBase) {
|
|
|
82
104
|
this.close();
|
|
83
105
|
}
|
|
84
106
|
onClose() {
|
|
85
|
-
|
|
107
|
+
var _a;
|
|
108
|
+
this.intersectionObserver.disconnect();
|
|
109
|
+
(_a = this.elementToFocusOnClose) === null || _a === void 0 ? void 0 : _a.focus();
|
|
86
110
|
this.dispatchEvent(new FtModalCloseEvent());
|
|
87
111
|
}
|
|
88
112
|
onOverlayClick() {
|
|
@@ -107,9 +131,6 @@ __decorate([
|
|
|
107
131
|
__decorate([
|
|
108
132
|
property()
|
|
109
133
|
], FtModal.prototype, "icon", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
query("ft-button")
|
|
112
|
-
], FtModal.prototype, "button", void 0);
|
|
113
134
|
__decorate([
|
|
114
135
|
query("dialog")
|
|
115
136
|
], FtModal.prototype, "dialog", void 0);
|