@proximus/lavender-modal 2.0.0-alpha.46 → 2.0.0-alpha.47
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/Modal.d.ts +14 -0
- package/dist/index.es.js +57 -21
- package/package.json +1 -1
package/dist/Modal.d.ts
CHANGED
|
@@ -6,13 +6,21 @@ import '@proximus/lavender-heading';
|
|
|
6
6
|
import '@proximus/lavender-paragraph';
|
|
7
7
|
import { type ButtonIcon } from '@proximus/lavender-button-icon';
|
|
8
8
|
import { type Icon } from '@proximus/lavender-icon';
|
|
9
|
+
export declare const statusValues: string[];
|
|
9
10
|
export declare class Modal extends HTMLElement {
|
|
11
|
+
private onOpenClick;
|
|
12
|
+
private onCloseClick;
|
|
13
|
+
private commandButtonCleanups;
|
|
14
|
+
private openerElement;
|
|
15
|
+
private closerElement;
|
|
10
16
|
template: string;
|
|
11
17
|
constructor();
|
|
12
18
|
connectedCallback(): void;
|
|
13
19
|
static get observedAttributes(): string[];
|
|
14
20
|
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
|
15
21
|
disconnectedCallback(): void;
|
|
22
|
+
addEventListenersToCommandButtons(): void;
|
|
23
|
+
private removeCommandButtonListeners;
|
|
16
24
|
handleOpenChange(): void;
|
|
17
25
|
handleStatusChange(oldStatus: string, newStatus: string): void;
|
|
18
26
|
getIcon(status: string): "checkmark_fill" | "exclamation_mark_fill" | "minus_fill" | "information_fill";
|
|
@@ -20,6 +28,9 @@ export declare class Modal extends HTMLElement {
|
|
|
20
28
|
close(): void;
|
|
21
29
|
updateMediaSrc(src: string): void;
|
|
22
30
|
addOpenListener(): void;
|
|
31
|
+
private removeOpenListener;
|
|
32
|
+
addCloseListener(value: string): void;
|
|
33
|
+
private removeCloseListener;
|
|
23
34
|
toggleDescriptionVisibility(): void;
|
|
24
35
|
toggleCloseButtonSafeArea(): void;
|
|
25
36
|
get $slottedCloseButton(): HTMLSlotElement;
|
|
@@ -27,11 +38,14 @@ export declare class Modal extends HTMLElement {
|
|
|
27
38
|
get $slottedDescription(): HTMLSlotElement;
|
|
28
39
|
get $slotDescription(): HTMLSlotElement;
|
|
29
40
|
get $descriptionContainer(): HTMLParagraphElement;
|
|
41
|
+
get $titleContainer(): HTMLHeadingElement;
|
|
30
42
|
get $opener(): HTMLButtonElement;
|
|
31
43
|
get status(): string;
|
|
32
44
|
set status(value: string);
|
|
33
45
|
get openedby(): string;
|
|
34
46
|
set openedby(value: string);
|
|
47
|
+
get closedby(): string;
|
|
48
|
+
set closedby(value: string);
|
|
35
49
|
get $closeButton(): ButtonIcon;
|
|
36
50
|
get $statusIcon(): Icon;
|
|
37
51
|
get $mediaContainer(): HTMLDivElement;
|
package/dist/index.es.js
CHANGED
|
@@ -6,10 +6,10 @@ import "@proximus/lavender-heading";
|
|
|
6
6
|
import "@proximus/lavender-paragraph";
|
|
7
7
|
const a = '*{box-sizing:border-box}#container{display:flex;flex-wrap:nowrap;font-family:var(--px-font-family);font-size:var(--px-font-size-base);color:var(--px-color-text-neutral-default);width:inherit;border-radius:var(--px-radius-main);background-color:var(--px-color-background-surface-default);overflow:hidden}#container.info{border-left:5px var(--px-color-icon-brand-default) solid}#container.success{border-left:5px var(--px-color-icon-purpose-success-default) solid}#container.warning{border-left:5px var(--px-color-icon-purpose-warning-default) solid}#container.error{border-left:5px var(--px-color-icon-purpose-error-default) solid}#container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-mobile)))}#content-container{padding:var(--px-padding-m-mobile);flex-grow:1}#media-container{display:none}::slotted(px-button-icon[slot="close-button"]){position:absolute;top:var(--px-padding-m-mobile);right:var(--px-padding-m-mobile)}dialog{background:transparent;border-radius:0;box-shadow:none;padding:0;border:0;box-sizing:border-box;transform:scale(.95);animation:modalIn .3s ease-out forwards}::backdrop{background:#0000004d;-webkit-backdrop-filter:saturate(180%) blur(15px);backdrop-filter:saturate(180%) blur(15px)}#content{max-height:12.5em;overflow:auto}@media only screen and (min-width: 48em){#container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-tablet)))}::slotted(px-button-icon[slot="close-button"]){position:absolute;top:var(--px-padding-m-tablet);right:var(--px-padding-m-tablet)}#content{max-height:25em}}@media only screen and (min-width: 64.0625em){#container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-laptop)))}::slotted(px-button-icon[slot="close-button"]){top:var(--px-padding-m-laptop);right:var(--px-padding-m-laptop)}:host([media-src]) #container.has-close-button #icon-container{max-width:100%}:host([media-src]) #media-container{display:block;background-size:cover;background-position:center center;background-repeat:no-repeat;flex-basis:25em;flex-shrink:0}}@media screen and (min-width: 1118px){#container{width:1080px}}@media only screen and (min-width: 90.0625em){:host(:not([media-src])) #container.has-close-button #icon-container{max-width:calc(100% - (var(--px-size-m) + var(--px-spacing-s-desktop)))}::slotted(px-button-icon[slot="close-button"]){position:absolute;top:var(--px-padding-m-desktop);right:var(--px-padding-m-desktop)}}@keyframes modalIn{0%{transform:scale(.95);opacity:0}to{transform:scale(1);opacity:1}}', r = new CSSStyleSheet();
|
|
8
8
|
r.replaceSync(a);
|
|
9
|
-
const
|
|
10
|
-
class
|
|
9
|
+
const l = "px.lavender.modal.close", c = ["", "info", "success", "error", "warning"];
|
|
10
|
+
class d extends HTMLElement {
|
|
11
11
|
constructor() {
|
|
12
|
-
super(), this.template = `<dialog>
|
|
12
|
+
super(), this.onOpenClick = () => this.show(), this.onCloseClick = () => this.close(), this.commandButtonCleanups = [], this.openerElement = null, this.closerElement = null, this.template = `<dialog>
|
|
13
13
|
<div id="container">
|
|
14
14
|
<div id="content-container">
|
|
15
15
|
<px-vstack gap="default" >
|
|
@@ -24,6 +24,7 @@ class l extends HTMLElement {
|
|
|
24
24
|
</px-vstack>
|
|
25
25
|
</px-hstack>
|
|
26
26
|
<div id="content">
|
|
27
|
+
<slot name="content"></slot>
|
|
27
28
|
<slot></slot>
|
|
28
29
|
</div>
|
|
29
30
|
<px-separator size="m"></px-separator>
|
|
@@ -47,15 +48,7 @@ class l extends HTMLElement {
|
|
|
47
48
|
}
|
|
48
49
|
connectedCallback() {
|
|
49
50
|
var t, e;
|
|
50
|
-
|
|
51
|
-
const o = document.querySelector(
|
|
52
|
-
`#${this.getAttribute("closedby")}`
|
|
53
|
-
);
|
|
54
|
-
o == null || o.addEventListener("click", () => {
|
|
55
|
-
this.close();
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
this.hasAttribute("openedby") && this.addOpenListener(), this.hasAttribute("media-src") && this.updateMediaSrc(this.getAttribute("media-src")), this.toggleDescriptionVisibility(), (t = this.$slotDescription) == null || t.addEventListener(
|
|
51
|
+
this.addEventListenersToCommandButtons(), this.toggleDescriptionVisibility = this.toggleDescriptionVisibility.bind(this), this.toggleCloseButtonSafeArea = this.toggleCloseButtonSafeArea.bind(this), this.hasAttribute("open") && this.show(), this.hasAttribute("closedby") && this.addCloseListener(this.getAttribute("closedby")), this.hasAttribute("openedby") && this.addOpenListener(), this.hasAttribute("media-src") && this.updateMediaSrc(this.getAttribute("media-src")), this.toggleDescriptionVisibility(), (t = this.$slotDescription) == null || t.addEventListener(
|
|
59
52
|
"slotchange",
|
|
60
53
|
this.toggleDescriptionVisibility
|
|
61
54
|
), this.toggleCloseButtonSafeArea(), (e = this.$slotCloseButton) == null || e.addEventListener(
|
|
@@ -64,7 +57,7 @@ class l extends HTMLElement {
|
|
|
64
57
|
);
|
|
65
58
|
}
|
|
66
59
|
static get observedAttributes() {
|
|
67
|
-
return ["open", "status", "media-src", "openedby"];
|
|
60
|
+
return ["open", "status", "media-src", "openedby", "closedby", "id"];
|
|
68
61
|
}
|
|
69
62
|
attributeChangedCallback(t, e, o) {
|
|
70
63
|
switch (t) {
|
|
@@ -80,21 +73,42 @@ class l extends HTMLElement {
|
|
|
80
73
|
case "openedby":
|
|
81
74
|
this.addOpenListener();
|
|
82
75
|
break;
|
|
76
|
+
case "closedby":
|
|
77
|
+
this.addCloseListener(o);
|
|
78
|
+
break;
|
|
79
|
+
case "id":
|
|
80
|
+
this.addEventListenersToCommandButtons();
|
|
81
|
+
break;
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
disconnectedCallback() {
|
|
86
|
-
var t;
|
|
85
|
+
var t, e;
|
|
87
86
|
(t = this.$slotDescription) == null || t.removeEventListener(
|
|
88
87
|
"slotchange",
|
|
89
88
|
this.toggleDescriptionVisibility
|
|
90
|
-
)
|
|
89
|
+
), (e = this.$slotCloseButton) == null || e.removeEventListener(
|
|
90
|
+
"slotchange",
|
|
91
|
+
this.toggleCloseButtonSafeArea
|
|
92
|
+
), this.removeCommandButtonListeners(), this.removeOpenListener(), this.removeCloseListener();
|
|
93
|
+
}
|
|
94
|
+
addEventListenersToCommandButtons() {
|
|
95
|
+
this.removeCommandButtonListeners(), this.id && document.querySelectorAll(`[commandfor="${this.id}"]`).forEach((t) => {
|
|
96
|
+
t.getAttribute("command") === "show-modal" ? (t.addEventListener("click", this.onOpenClick), this.commandButtonCleanups.push(
|
|
97
|
+
() => t.removeEventListener("click", this.onOpenClick)
|
|
98
|
+
)) : t.getAttribute("command") === "close" && (t.addEventListener("click", this.onCloseClick), this.commandButtonCleanups.push(
|
|
99
|
+
() => t.removeEventListener("click", this.onCloseClick)
|
|
100
|
+
));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
removeCommandButtonListeners() {
|
|
104
|
+
this.commandButtonCleanups.forEach((t) => t()), this.commandButtonCleanups = [];
|
|
91
105
|
}
|
|
92
106
|
handleOpenChange() {
|
|
93
107
|
this.hasAttribute("open") ? this.show() : this.close();
|
|
94
108
|
}
|
|
95
109
|
handleStatusChange(t, e) {
|
|
96
110
|
var o, s, n;
|
|
97
|
-
if (e === "info" ? this.$container.classList.add("info") : this.$container.classList.remove("info"), e === "success" ? this.$container.classList.add("success") : this.$container.classList.remove("success"), e === "error" ? this.$container.classList.add("error") : this.$container.classList.remove("error"), e === "warning" ? this.$container.classList.add("warning") : this.$container.classList.remove("warning"), e === null && this.$statusIcon)
|
|
111
|
+
if (c.includes(e) ? this.$titleContainer.setAttribute("color", "neutral") : this.$titleContainer.hasAttribute("color") && this.$titleContainer.removeAttribute("color"), e === "info" ? this.$container.classList.add("info") : this.$container.classList.remove("info"), e === "success" ? this.$container.classList.add("success") : this.$container.classList.remove("success"), e === "error" ? this.$container.classList.add("error") : this.$container.classList.remove("error"), e === "warning" ? this.$container.classList.add("warning") : this.$container.classList.remove("warning"), e === null && this.$statusIcon)
|
|
98
112
|
(o = this.$statusIcon) == null || o.remove();
|
|
99
113
|
else if (t === null && e && !this.$statusIcon) {
|
|
100
114
|
const i = document.createElement("px-icon");
|
|
@@ -110,7 +124,7 @@ class l extends HTMLElement {
|
|
|
110
124
|
}
|
|
111
125
|
close() {
|
|
112
126
|
this.$dialog.close(), document.body.style.overflow = "", this.dispatchEvent(
|
|
113
|
-
new CustomEvent(
|
|
127
|
+
new CustomEvent(l, {
|
|
114
128
|
bubbles: !0,
|
|
115
129
|
composed: !0
|
|
116
130
|
})
|
|
@@ -120,8 +134,20 @@ class l extends HTMLElement {
|
|
|
120
134
|
this.$mediaContainer.style.backgroundImage = `url(${t})`;
|
|
121
135
|
}
|
|
122
136
|
addOpenListener() {
|
|
123
|
-
var t
|
|
124
|
-
|
|
137
|
+
var t;
|
|
138
|
+
this.removeOpenListener(), this.openerElement = this.$opener, (t = this.openerElement) == null || t.addEventListener("click", this.onOpenClick);
|
|
139
|
+
}
|
|
140
|
+
removeOpenListener() {
|
|
141
|
+
var t;
|
|
142
|
+
(t = this.openerElement) == null || t.removeEventListener("click", this.onOpenClick), this.openerElement = null;
|
|
143
|
+
}
|
|
144
|
+
addCloseListener(t) {
|
|
145
|
+
var e, o;
|
|
146
|
+
t === "none" && ((e = this.$dialog) == null || e.setAttribute("closedby", "none")), this.removeCloseListener(), t && t !== "none" && (this.closerElement = document.querySelector(`#${t}`), (o = this.closerElement) == null || o.addEventListener("click", this.onCloseClick));
|
|
147
|
+
}
|
|
148
|
+
removeCloseListener() {
|
|
149
|
+
var t;
|
|
150
|
+
(t = this.closerElement) == null || t.removeEventListener("click", this.onCloseClick), this.closerElement = null;
|
|
125
151
|
}
|
|
126
152
|
toggleDescriptionVisibility() {
|
|
127
153
|
this.$slottedDescription ? this.$descriptionContainer.style.display = "block" : this.$descriptionContainer.style.display = "none";
|
|
@@ -151,6 +177,9 @@ class l extends HTMLElement {
|
|
|
151
177
|
'px-p[font-weight="title"]'
|
|
152
178
|
);
|
|
153
179
|
}
|
|
180
|
+
get $titleContainer() {
|
|
181
|
+
return this.shadowRoot.querySelector("px-h1");
|
|
182
|
+
}
|
|
154
183
|
get $opener() {
|
|
155
184
|
return document.querySelector(
|
|
156
185
|
`px-button#${this.getAttribute("openedby")}`
|
|
@@ -168,6 +197,12 @@ class l extends HTMLElement {
|
|
|
168
197
|
set openedby(t) {
|
|
169
198
|
this.setAttribute("openedby", t);
|
|
170
199
|
}
|
|
200
|
+
get closedby() {
|
|
201
|
+
return this.getAttribute("closedby");
|
|
202
|
+
}
|
|
203
|
+
set closedby(t) {
|
|
204
|
+
this.setAttribute("closedby", t);
|
|
205
|
+
}
|
|
171
206
|
get $closeButton() {
|
|
172
207
|
return this.shadowRoot.querySelector("px-button-icon");
|
|
173
208
|
}
|
|
@@ -198,7 +233,8 @@ class l extends HTMLElement {
|
|
|
198
233
|
return this.$dialog.open;
|
|
199
234
|
}
|
|
200
235
|
}
|
|
201
|
-
customElements.get("px-modal") || customElements.define("px-modal",
|
|
236
|
+
customElements.get("px-modal") || customElements.define("px-modal", d);
|
|
202
237
|
export {
|
|
203
|
-
|
|
238
|
+
d as Modal,
|
|
239
|
+
c as statusValues
|
|
204
240
|
};
|