@fluid-topics/ftds-modal 2.2.37 → 2.2.38
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/ftds-modal.d.ts +7 -4
- package/build/ftds-modal.js +49 -17
- package/build/ftds-modal.light.js +144 -141
- package/build/ftds-modal.min.js +113 -110
- package/package.json +8 -8
package/build/ftds-modal.d.ts
CHANGED
|
@@ -11,15 +11,18 @@ export declare class FtdsModal extends FtdsModal_base implements FtdsModalProper
|
|
|
11
11
|
icon?: FtdsIcons;
|
|
12
12
|
iconVariant?: FtdsIconVariants;
|
|
13
13
|
dialogOpen?: boolean;
|
|
14
|
-
private dialog;
|
|
15
14
|
size: DesignSystemSize;
|
|
16
15
|
constructor();
|
|
17
16
|
protected render(): import("lit").TemplateResult<1>;
|
|
17
|
+
private dialog?;
|
|
18
|
+
private invoker?;
|
|
18
19
|
protected contentAvailableCallback(props: PropertyValues): void;
|
|
19
|
-
open(): void;
|
|
20
|
+
open(invoker?: HTMLElement): void;
|
|
21
|
+
private onOpen;
|
|
20
22
|
close(): void;
|
|
21
|
-
disconnectedCallback(): void;
|
|
22
|
-
private onOverlayClick;
|
|
23
23
|
private onClose;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
disconnectedCallback(): void;
|
|
26
|
+
private onEscapePressed;
|
|
24
27
|
}
|
|
25
28
|
export {};
|
package/build/ftds-modal.js
CHANGED
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { html, nothing, } from "lit";
|
|
8
8
|
import { property, query, } from "lit/decorators.js";
|
|
9
|
-
import { DesignSystemFamily, FtdsBase, } from "@fluid-topics/ft-wc-utils";
|
|
9
|
+
import { DesignSystemFamily, focusTrap, FtdsBase, } from "@fluid-topics/ft-wc-utils";
|
|
10
10
|
import { classMap } from "lit/directives/class-map.js";
|
|
11
11
|
import { designSystemStyle } from "./ftds-modal.styles";
|
|
12
12
|
import { FtdsButton } from "@fluid-topics/ftds-button";
|
|
@@ -15,6 +15,11 @@ import { FtdsIcon, FtdsIcons, } from "@fluid-topics/ftds-icon";
|
|
|
15
15
|
import { FtdsTypography, FtdsTypographyVariants, } from "@fluid-topics/ftds-typography";
|
|
16
16
|
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
17
17
|
import { defaultModalMessages, modal, } from "./FtDsModalMessages";
|
|
18
|
+
class FtdsModalOpenEvent extends Event {
|
|
19
|
+
constructor() {
|
|
20
|
+
super("open");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
18
23
|
class FtdsModalCloseEvent extends Event {
|
|
19
24
|
constructor() {
|
|
20
25
|
super("close");
|
|
@@ -35,14 +40,17 @@ export class FtdsModal extends withI18n(FtdsBase) {
|
|
|
35
40
|
return html `
|
|
36
41
|
<div class="${classMap(classes)}" part="container">
|
|
37
42
|
<dialog part="dialog"
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
popover="manual"
|
|
44
|
+
aria-labelledby="heading"
|
|
45
|
+
aria-modal="true"
|
|
46
|
+
${focusTrap()}>
|
|
47
|
+
<div part="overlay" @click=${this.close}></div>
|
|
40
48
|
<div part="inner-container">
|
|
41
49
|
<div part="header">
|
|
42
50
|
${this.icon ? html `
|
|
43
51
|
<ftds-icon part="icon" icon="${this.icon}" variant="${this.iconVariant}"></ftds-icon>
|
|
44
52
|
` : nothing}
|
|
45
|
-
<ftds-typography part="heading" variant="${FtdsTypographyVariants.body1semibold}">
|
|
53
|
+
<ftds-typography id="heading" part="heading" variant="${FtdsTypographyVariants.body1semibold}">
|
|
46
54
|
${this.heading}
|
|
47
55
|
</ftds-typography>
|
|
48
56
|
<ftds-button part="closing-button"
|
|
@@ -68,32 +76,56 @@ export class FtdsModal extends withI18n(FtdsBase) {
|
|
|
68
76
|
`;
|
|
69
77
|
}
|
|
70
78
|
contentAvailableCallback(props) {
|
|
79
|
+
var _a;
|
|
71
80
|
super.contentAvailableCallback(props);
|
|
72
|
-
|
|
81
|
+
const isDialogOpen = (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.matches(":popover-open");
|
|
82
|
+
if (props.has("dialogOpen") && this.dialogOpen != isDialogOpen) {
|
|
73
83
|
if (this.dialogOpen) {
|
|
74
|
-
this.
|
|
84
|
+
this.open();
|
|
75
85
|
}
|
|
76
86
|
else {
|
|
77
|
-
this.
|
|
87
|
+
this.close();
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
|
-
open() {
|
|
91
|
+
open(invoker) {
|
|
92
|
+
var _a;
|
|
93
|
+
this.invoker = invoker;
|
|
94
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.showPopover({ source: this.invoker });
|
|
95
|
+
this.onOpen();
|
|
96
|
+
}
|
|
97
|
+
onOpen() {
|
|
82
98
|
this.dialogOpen = true;
|
|
99
|
+
this.dispatchEvent(new FtdsModalOpenEvent());
|
|
83
100
|
}
|
|
84
101
|
close() {
|
|
102
|
+
var _a;
|
|
103
|
+
(_a = this.dialog) === null || _a === void 0 ? void 0 : _a.hidePopover();
|
|
104
|
+
this.onClose();
|
|
105
|
+
}
|
|
106
|
+
onClose() {
|
|
107
|
+
var _a;
|
|
108
|
+
if ((_a = this.invoker) === null || _a === void 0 ? void 0 : _a.isConnected) {
|
|
109
|
+
this.invoker.focus();
|
|
110
|
+
}
|
|
111
|
+
this.invoker = undefined;
|
|
85
112
|
this.dialogOpen = false;
|
|
113
|
+
this.dispatchEvent(new FtdsModalCloseEvent());
|
|
114
|
+
}
|
|
115
|
+
connectedCallback() {
|
|
116
|
+
super.connectedCallback();
|
|
117
|
+
this.addEventListener("keydown", this.onEscapePressed);
|
|
86
118
|
}
|
|
87
119
|
disconnectedCallback() {
|
|
88
120
|
super.disconnectedCallback();
|
|
121
|
+
this.removeEventListener("keydown", this.onEscapePressed);
|
|
89
122
|
this.close();
|
|
90
123
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.close();
|
|
124
|
+
onEscapePressed(e) {
|
|
125
|
+
if (e.key === "Escape") {
|
|
126
|
+
this.close();
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
}
|
|
97
129
|
}
|
|
98
130
|
}
|
|
99
131
|
FtdsModal.elementDefinitions = {
|
|
@@ -114,9 +146,9 @@ __decorate([
|
|
|
114
146
|
__decorate([
|
|
115
147
|
property({ type: Boolean, reflect: true })
|
|
116
148
|
], FtdsModal.prototype, "dialogOpen", void 0);
|
|
117
|
-
__decorate([
|
|
118
|
-
query("dialog")
|
|
119
|
-
], FtdsModal.prototype, "dialog", void 0);
|
|
120
149
|
__decorate([
|
|
121
150
|
property()
|
|
122
151
|
], FtdsModal.prototype, "size", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
query("dialog")
|
|
154
|
+
], FtdsModal.prototype, "dialog", void 0);
|