@proximus/lavender-drawer 2.0.0-alpha.12 → 2.0.0-alpha.121
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/Drawer.d.ts +21 -1
- package/dist/index.es.js +131 -49
- package/package.json +2 -2
package/dist/Drawer.d.ts
CHANGED
|
@@ -6,15 +6,21 @@ import '@proximus/lavender-heading';
|
|
|
6
6
|
import { type Icon } from '@proximus/lavender-icon';
|
|
7
7
|
export declare const HIDE_EVENT = "px.lavender.drawer.hide";
|
|
8
8
|
export declare class Drawer extends HTMLElement {
|
|
9
|
+
observer: MutationObserver;
|
|
10
|
+
private previousFocusedElement;
|
|
9
11
|
template: string;
|
|
10
12
|
constructor();
|
|
11
13
|
connectedCallback(): void;
|
|
12
14
|
static get observedAttributes(): string[];
|
|
13
|
-
attributeChangedCallback(
|
|
15
|
+
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
|
14
16
|
disconnectedCallback(): void;
|
|
15
17
|
show(): void;
|
|
16
18
|
hide(): void;
|
|
17
19
|
toggleFooterVisibility(): void;
|
|
20
|
+
addOpenListener(): void;
|
|
21
|
+
addCloseListener(): void;
|
|
22
|
+
get $opener(): HTMLElement;
|
|
23
|
+
get $closer(): HTMLElement;
|
|
18
24
|
get $closeButton(): Icon;
|
|
19
25
|
get $dialog(): HTMLDialogElement;
|
|
20
26
|
get open(): boolean;
|
|
@@ -24,4 +30,18 @@ export declare class Drawer extends HTMLElement {
|
|
|
24
30
|
set open(value: boolean);
|
|
25
31
|
get closeButtonAriaLabel(): string;
|
|
26
32
|
set closeButtonAriaLabel(value: string);
|
|
33
|
+
get openedby(): string;
|
|
34
|
+
set openedby(value: string);
|
|
35
|
+
get closedby(): string;
|
|
36
|
+
set closedby(value: string);
|
|
37
|
+
get fullscreen(): boolean;
|
|
38
|
+
set fullscreen(value: boolean);
|
|
39
|
+
get fullscreenMobile(): boolean;
|
|
40
|
+
set fullscreenMobile(value: boolean);
|
|
41
|
+
get fullscreenTablet(): boolean;
|
|
42
|
+
set fullscreenTablet(value: boolean);
|
|
43
|
+
get fullscreenLaptop(): boolean;
|
|
44
|
+
set fullscreenLaptop(value: boolean);
|
|
45
|
+
get fullscreenDesktop(): boolean;
|
|
46
|
+
set fullscreenDesktop(value: boolean);
|
|
27
47
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -3,12 +3,12 @@ import "@proximus/lavender-layout";
|
|
|
3
3
|
import "@proximus/lavender-button-icon";
|
|
4
4
|
import "@proximus/lavender-icon";
|
|
5
5
|
import "@proximus/lavender-heading";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
class
|
|
6
|
+
const l = ':host *{box-sizing:border-box}::backdrop{background:#0000004d;-webkit-backdrop-filter:saturate(180%) blur(15px);backdrop-filter:saturate(180%) blur(15px)}dialog{box-shadow:none;padding:0;margin:auto 0 0;border:0;width:100%;animation:dialog-fade-in-bottom .3s;border-radius:var(--px-radius-main) var(--px-radius-main) 0 0;background-color:var(--px-color-background-surface-light)}#container{display:grid;grid-template:"header close" auto "content content" 1fr "footer footer" auto / 1fr auto;column-gap:var(--px-spacing-l-mobile);padding:var(--px-padding-l-mobile);max-height:90dvh}#header{grid-area:header;margin-bottom:var(--px-spacing-l-mobile)}#close{grid-area:close}#content{grid-area:content;overflow:hidden;overflow-y:auto}#footer{grid-area:footer;margin-top:var(--px-spacing-l-mobile)}:host([fullscreen]) #container{height:90dvh}@media screen and (max-width: 47.938rem){:host([fullscreen--mobile]) #container{height:90dvh}}@media screen and (min-width: 48rem) and (max-width: 64rem){:host([fullscreen--tablet]) #container{height:90dvh}}@media screen and (min-width: 48rem){#container{column-gap:var(--px-spacing-l-tablet);padding:var(--px-padding-l-tablet)}#header{margin-bottom:var(--px-spacing-l-tablet)}#footer{margin-top:var(--px-spacing-l-tablet)}}@media screen and (min-width: 64.0625rem) and (max-width: 90rem){:host([fullscreen--laptop]:not([showfrom="left"]):not([showfrom="right"])) #container{height:90dvh}}@media screen and (min-width: 64.0625rem){#container{column-gap:var(--px-spacing-l-laptop);padding:var(--px-padding-l-laptop);max-width:var(--px-content-wrapper-max-width-laptop);margin:0 auto}#header{margin-bottom:var(--px-spacing-l-laptop)}#footer{margin-top:var(--px-spacing-l-laptop)}:host([showfrom="right"]) dialog,:host([showfrom="left"]) dialog{width:75%;height:100%}:host([showfrom="right"]) #container,:host([showfrom="left"]) #container{max-height:100%;height:100%}:host([showfrom="right"]) dialog{margin:0 0 0 auto;animation:dialog-fade-in-right .3s;border-radius:var(--px-radius-main) 0 0 var(--px-radius-main)}:host([showfrom="right"]) #container{margin:0 auto 0 0}:host([showfrom="left"]) dialog{margin:0 auto 0 0;animation:dialog-fade-in-left .3s;border-radius:0 var(--px-radius-main) var(--px-radius-main) 0}:host([showfrom="left"]) #container{margin:0 0 0 auto}:host([showfrom="right"][fullscreen]) #container,:host([showfrom="left"][fullscreen]) #container{height:100%}}@media screen and (min-width: 90.0625rem){#container{column-gap:var(--px-spacing-l-desktop);padding:var(--px-padding-l-desktop)}#header{margin-bottom:var(--px-spacing-l-desktop)}#footer{margin-top:var(--px-spacing-l-desktop)}:host([fullscreen--desktop]:not([showfrom="left"]):not([showfrom="right"])) #container{height:90dvh}}@keyframes dialog-fade-in-right{0%{margin-right:-1080px}to{margin-right:0}}@keyframes dialog-fade-in-left{0%{margin-left:-1080px}to{margin-left:0}}@keyframes dialog-fade-in-bottom{0%{margin-bottom:-200px}to{margin-bottom:0}}', n = new CSSStyleSheet();
|
|
7
|
+
n.replaceSync(l);
|
|
8
|
+
const d = "px.lavender.drawer.hide";
|
|
9
|
+
class h extends HTMLElement {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(), this.template = `<dialog popover role="dialog" aria-modal="true" >
|
|
11
|
+
super(), this.previousFocusedElement = null, this.template = `<dialog popover role="dialog" aria-modal="true" >
|
|
12
12
|
<div id="container">
|
|
13
13
|
<px-vstack gap="heading-to-subtitle" id="header">
|
|
14
14
|
<px-h1 variant="title-2xl">
|
|
@@ -38,59 +38,75 @@ class d extends HTMLElement {
|
|
|
38
38
|
<px-icon name="cross" from="lavender"></px-icon>
|
|
39
39
|
</px-button-icon>
|
|
40
40
|
</div>
|
|
41
|
-
</dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [
|
|
41
|
+
</dialog>`, this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [n];
|
|
42
42
|
}
|
|
43
43
|
connectedCallback() {
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
const e = document.querySelector(
|
|
47
|
-
`#${this.getAttribute("closedby")}`
|
|
48
|
-
);
|
|
49
|
-
e == null || e.addEventListener("click", () => {
|
|
50
|
-
this.hide();
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (this.hasAttribute("openedby")) {
|
|
54
|
-
const e = document.querySelector(
|
|
55
|
-
`px-button#${this.getAttribute("openedby")}`
|
|
56
|
-
);
|
|
57
|
-
e == null || e.addEventListener("click", () => {
|
|
58
|
-
this.show();
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
this.$closeButton.addEventListener("click", () => {
|
|
44
|
+
var e;
|
|
45
|
+
this.toggleFooterVisibility = this.toggleFooterVisibility.bind(this), this.$opener && this.addOpenListener(), this.$closer && this.addCloseListener(), this.hasAttribute("showfrom") || this.setAttribute("showfrom", "bottom"), this.$closeButton.addEventListener("click", () => {
|
|
62
46
|
this.hide();
|
|
63
|
-
}), this.
|
|
47
|
+
}), this.$dialog.addEventListener("toggle", (t) => {
|
|
48
|
+
t.newState === "closed" && this.hide();
|
|
49
|
+
}), this.toggleFooterVisibility(), (e = this.$slotFooter) == null || e.addEventListener(
|
|
64
50
|
"slotchange",
|
|
65
51
|
this.toggleFooterVisibility
|
|
66
52
|
);
|
|
67
53
|
}
|
|
68
54
|
static get observedAttributes() {
|
|
69
|
-
return [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
return [
|
|
56
|
+
"open",
|
|
57
|
+
"close-button-aria-label",
|
|
58
|
+
"openedby",
|
|
59
|
+
"closedby",
|
|
60
|
+
"fullscreen",
|
|
61
|
+
"fullscreen--mobile",
|
|
62
|
+
"fullscreen--tablet",
|
|
63
|
+
"fullscreen--laptop",
|
|
64
|
+
"fullscreen--desktop"
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
attributeChangedCallback(e, t, o) {
|
|
68
|
+
var i, r, a;
|
|
69
|
+
switch (e) {
|
|
70
|
+
case "open":
|
|
71
|
+
o !== null ? this.show() : this.hide();
|
|
72
|
+
break;
|
|
73
|
+
case "close-button-aria-label":
|
|
74
|
+
o ? (a = (r = this.$closeButton) == null ? void 0 : r.setAttribute) == null || a.call(
|
|
75
|
+
r,
|
|
76
|
+
"aria-label",
|
|
77
|
+
o || "Close drawer"
|
|
78
|
+
) : (i = this.$closeButton) == null || i.removeAttribute("aria-label");
|
|
79
|
+
break;
|
|
80
|
+
case "openedby":
|
|
81
|
+
if (o !== t) {
|
|
82
|
+
if (t) {
|
|
83
|
+
const s = document.querySelector(`#${t}`);
|
|
84
|
+
s == null || s.removeEventListener("click", () => this.show());
|
|
85
|
+
}
|
|
86
|
+
this.addOpenListener();
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case "closedby":
|
|
90
|
+
this.addCloseListener();
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
78
93
|
}
|
|
79
94
|
disconnectedCallback() {
|
|
80
|
-
var t;
|
|
81
|
-
(
|
|
95
|
+
var e, t;
|
|
96
|
+
(e = this.$slotFooter) == null || e.removeEventListener(
|
|
82
97
|
"slotchange",
|
|
83
98
|
this.toggleFooterVisibility
|
|
84
|
-
);
|
|
99
|
+
), (t = this.observer) == null || t.disconnect(), this.$opener && this.$opener.removeEventListener("click", () => this.show()), this.$closer && this.$closer.removeEventListener("click", () => this.hide());
|
|
85
100
|
}
|
|
86
101
|
show() {
|
|
87
|
-
var t,
|
|
88
|
-
|
|
102
|
+
var t, o, i;
|
|
103
|
+
const e = document.activeElement;
|
|
104
|
+
this.previousFocusedElement = ((t = e == null ? void 0 : e.shadowRoot) == null ? void 0 : t.activeElement) ?? e, (i = (o = this.$dialog).showPopover) == null || i.call(o), document.body.style.overflow = "hidden";
|
|
89
105
|
}
|
|
90
106
|
hide() {
|
|
91
|
-
var t,
|
|
92
|
-
(
|
|
93
|
-
new Event(
|
|
107
|
+
var e, t, o;
|
|
108
|
+
(t = (e = this.$dialog).hidePopover) == null || t.call(e), document.body.style.overflow = "", (o = this.previousFocusedElement) == null || o.focus(), this.previousFocusedElement = null, this.dispatchEvent(
|
|
109
|
+
new Event(d, {
|
|
94
110
|
bubbles: !0,
|
|
95
111
|
composed: !0
|
|
96
112
|
})
|
|
@@ -99,6 +115,30 @@ class d extends HTMLElement {
|
|
|
99
115
|
toggleFooterVisibility() {
|
|
100
116
|
this.$slottedFooter ? this.$footer.style.display = "block" : this.$footer.style.display = "none";
|
|
101
117
|
}
|
|
118
|
+
addOpenListener() {
|
|
119
|
+
this.$opener ? this.$opener.getAttribute("data-has-opener") !== "true" && (this.$opener.setAttribute("data-has-opener", "true"), this.$opener.addEventListener("click", () => this.show())) : (this.observer = new MutationObserver(() => {
|
|
120
|
+
this.$opener && (this.observer.disconnect(), this.observer = null, this.addOpenListener());
|
|
121
|
+
}), this.observer.observe(document.body, {
|
|
122
|
+
childList: !0,
|
|
123
|
+
subtree: !0
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
addCloseListener() {
|
|
127
|
+
var e;
|
|
128
|
+
this.$closer && ((e = this.$closer) == null || e.addEventListener("click", () => {
|
|
129
|
+
this.hide();
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
get $opener() {
|
|
133
|
+
return document.querySelector(
|
|
134
|
+
`#${this.getAttribute("openedby")}`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
get $closer() {
|
|
138
|
+
return document.querySelector(
|
|
139
|
+
`#${this.getAttribute("closedby")}`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
102
142
|
get $closeButton() {
|
|
103
143
|
return this.shadowRoot.querySelector("px-button-icon");
|
|
104
144
|
}
|
|
@@ -119,18 +159,60 @@ class d extends HTMLElement {
|
|
|
119
159
|
get $footer() {
|
|
120
160
|
return this.shadowRoot.querySelector("#footer");
|
|
121
161
|
}
|
|
122
|
-
set open(
|
|
123
|
-
|
|
162
|
+
set open(e) {
|
|
163
|
+
e ? this.setAttribute("open", "") : this.removeAttribute("open");
|
|
124
164
|
}
|
|
125
165
|
get closeButtonAriaLabel() {
|
|
126
166
|
return this.getAttribute("close-button-aria-label");
|
|
127
167
|
}
|
|
128
|
-
set closeButtonAriaLabel(
|
|
129
|
-
this.setAttribute("close-button-aria-label",
|
|
168
|
+
set closeButtonAriaLabel(e) {
|
|
169
|
+
this.setAttribute("close-button-aria-label", e);
|
|
170
|
+
}
|
|
171
|
+
get openedby() {
|
|
172
|
+
return this.getAttribute("openedby");
|
|
173
|
+
}
|
|
174
|
+
set openedby(e) {
|
|
175
|
+
this.setAttribute("openedby", e);
|
|
176
|
+
}
|
|
177
|
+
get closedby() {
|
|
178
|
+
return this.getAttribute("closedby");
|
|
179
|
+
}
|
|
180
|
+
set closedby(e) {
|
|
181
|
+
this.setAttribute("closedby", e);
|
|
182
|
+
}
|
|
183
|
+
get fullscreen() {
|
|
184
|
+
return this.hasAttribute("fullscreen");
|
|
185
|
+
}
|
|
186
|
+
set fullscreen(e) {
|
|
187
|
+
e ? this.setAttribute("fullscreen", "") : this.removeAttribute("fullscreen");
|
|
188
|
+
}
|
|
189
|
+
get fullscreenMobile() {
|
|
190
|
+
return this.hasAttribute("fullscreen--mobile");
|
|
191
|
+
}
|
|
192
|
+
set fullscreenMobile(e) {
|
|
193
|
+
e ? this.setAttribute("fullscreen--mobile", "") : this.removeAttribute("fullscreen--mobile");
|
|
194
|
+
}
|
|
195
|
+
get fullscreenTablet() {
|
|
196
|
+
return this.hasAttribute("fullscreen--tablet");
|
|
197
|
+
}
|
|
198
|
+
set fullscreenTablet(e) {
|
|
199
|
+
e ? this.setAttribute("fullscreen--tablet", "") : this.removeAttribute("fullscreen--tablet");
|
|
200
|
+
}
|
|
201
|
+
get fullscreenLaptop() {
|
|
202
|
+
return this.hasAttribute("fullscreen--laptop");
|
|
203
|
+
}
|
|
204
|
+
set fullscreenLaptop(e) {
|
|
205
|
+
e ? this.setAttribute("fullscreen--laptop", "") : this.removeAttribute("fullscreen--laptop");
|
|
206
|
+
}
|
|
207
|
+
get fullscreenDesktop() {
|
|
208
|
+
return this.hasAttribute("fullscreen--desktop");
|
|
209
|
+
}
|
|
210
|
+
set fullscreenDesktop(e) {
|
|
211
|
+
e ? this.setAttribute("fullscreen--desktop", "") : this.removeAttribute("fullscreen--desktop");
|
|
130
212
|
}
|
|
131
213
|
}
|
|
132
|
-
customElements.get("px-drawer") || customElements.define("px-drawer",
|
|
214
|
+
customElements.get("px-drawer") || customElements.define("px-drawer", h);
|
|
133
215
|
export {
|
|
134
|
-
|
|
135
|
-
|
|
216
|
+
h as Drawer,
|
|
217
|
+
d as HIDE_EVENT
|
|
136
218
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-drawer",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.121",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"clean": "rm -rf dist",
|
|
14
14
|
"build": "npm run clean && NODE_ENV=development vite build && tsc && npm run transform-package-json && npm run wc-manifest",
|
|
15
15
|
"test": "vitest run --coverage",
|
|
16
|
-
"wc-manifest": "cem analyze --globs \"src/*\" --config
|
|
16
|
+
"wc-manifest": "cem analyze --globs \"src/*\" --config ../../custom-elements-manifest.config.js --outdir dist"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|