@fluid-topics/ft-modal 1.3.30 → 1.3.32
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 +6 -3
- package/build/ft-modal.js +36 -10
- package/build/ft-modal.light.js +146 -140
- package/build/ft-modal.min.js +160 -154
- package/build/ft-modal.styles.js +16 -8
- package/package.json +4 -4
package/build/ft-modal.d.ts
CHANGED
|
@@ -9,12 +9,15 @@ 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
|
+
private onKeyUp;
|
|
17
|
+
protected onTriggerClick(e: MouseEvent): void;
|
|
18
|
+
protected elementToFocusOnClose?: HTMLElement;
|
|
19
|
+
private intersectionObserver;
|
|
20
|
+
open(elementToFocusOnClose?: HTMLElement): void;
|
|
18
21
|
close(): void;
|
|
19
22
|
disconnectedCallback(): void;
|
|
20
23
|
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} @keyup=${this.onKeyUp} 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,25 @@ class FtModal extends withI18n(FtdsBase) {
|
|
|
70
83
|
</div>
|
|
71
84
|
`;
|
|
72
85
|
}
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
onKeyUp(e) {
|
|
87
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
88
|
+
this.open(e.target);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onTriggerClick(e) {
|
|
92
|
+
this.open(e.target);
|
|
93
|
+
}
|
|
94
|
+
open(elementToFocusOnClose) {
|
|
95
|
+
this.elementToFocusOnClose = elementToFocusOnClose;
|
|
96
|
+
if (this.dialog) {
|
|
97
|
+
this.dialog.showModal();
|
|
98
|
+
this.intersectionObserver.observe(this.dialog);
|
|
99
|
+
this.dispatchEvent(new FtModalOpenEvent());
|
|
100
|
+
}
|
|
75
101
|
}
|
|
76
102
|
close() {
|
|
77
|
-
|
|
103
|
+
var _a;
|
|
104
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.close();
|
|
78
105
|
this.onClose();
|
|
79
106
|
}
|
|
80
107
|
disconnectedCallback() {
|
|
@@ -82,7 +109,9 @@ class FtModal extends withI18n(FtdsBase) {
|
|
|
82
109
|
this.close();
|
|
83
110
|
}
|
|
84
111
|
onClose() {
|
|
85
|
-
|
|
112
|
+
var _a;
|
|
113
|
+
this.intersectionObserver.disconnect();
|
|
114
|
+
(_a = this.elementToFocusOnClose) === null || _a === void 0 ? void 0 : _a.focus();
|
|
86
115
|
this.dispatchEvent(new FtModalCloseEvent());
|
|
87
116
|
}
|
|
88
117
|
onOverlayClick() {
|
|
@@ -107,9 +136,6 @@ __decorate([
|
|
|
107
136
|
__decorate([
|
|
108
137
|
property()
|
|
109
138
|
], FtModal.prototype, "icon", void 0);
|
|
110
|
-
__decorate([
|
|
111
|
-
query("ft-button")
|
|
112
|
-
], FtModal.prototype, "button", void 0);
|
|
113
139
|
__decorate([
|
|
114
140
|
query("dialog")
|
|
115
141
|
], FtModal.prototype, "dialog", void 0);
|