@proximus/lavender-drawer 2.0.0-alpha.19 → 2.0.0-alpha.190
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 +25 -5
- package/dist/index.es.js +149 -130
- package/package.json +2 -2
package/dist/Drawer.d.ts
CHANGED
|
@@ -6,22 +6,42 @@ 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 | null;
|
|
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;
|
|
21
|
-
get $slotFooter(): HTMLSlotElement;
|
|
22
|
-
get $slottedFooter(): HTMLElement;
|
|
27
|
+
get $slotFooter(): HTMLSlotElement | null;
|
|
28
|
+
get $slottedFooter(): HTMLElement | null;
|
|
23
29
|
get $footer(): HTMLElement;
|
|
24
30
|
set open(value: boolean);
|
|
25
|
-
get closeButtonAriaLabel(): string;
|
|
26
|
-
set closeButtonAriaLabel(value: string);
|
|
31
|
+
get closeButtonAriaLabel(): string | null;
|
|
32
|
+
set closeButtonAriaLabel(value: string | null);
|
|
33
|
+
get openedby(): string | null;
|
|
34
|
+
set openedby(value: string | null);
|
|
35
|
+
get closedby(): string | null;
|
|
36
|
+
set closedby(value: string | null);
|
|
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,134 +3,153 @@ import "@proximus/lavender-layout";
|
|
|
3
3
|
import "@proximus/lavender-button-icon";
|
|
4
4
|
import "@proximus/lavender-icon";
|
|
5
5
|
import "@proximus/lavender-heading";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<div id
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
6
|
+
import { booleanPropertyToAttributeSetter as e, propertyToAttributeSetter as t } from "@proximus/lavender-common";
|
|
7
|
+
//#region src/drawer.css?inline
|
|
8
|
+
var n = ":host *{box-sizing:border-box}::backdrop{-webkit-backdrop-filter:saturate(180%)blur(15px);backdrop-filter:saturate(180%)blur(15px);background:#0000004d}dialog{box-shadow:none;border-radius:var(--px-radius-main) var(--px-radius-main) 0 0;background-color:var(--px-color-background-surface-light);border:0;width:100%;margin:auto 0 0;padding:0;animation:.3s dialog-fade-in-bottom}#container{column-gap:var(--px-spacing-l-mobile);padding:var(--px-padding-l-mobile);grid-template:\"header close\"\"content content\"1fr\"footer footer\"/1fr auto;max-height:90dvh;display:grid}#header{margin-bottom:var(--px-spacing-l-mobile);grid-area:header}#close{grid-area:close}#content{grid-area:content;overflow:hidden auto}#footer{margin-top:var(--px-spacing-l-mobile);grid-area:footer}:host([fullscreen]) #container{height:90dvh}@media screen and (width<=47.938rem){:host([fullscreen--mobile]) #container{height:90dvh}}@media screen and (width>=48rem) and (width<=64rem){:host([fullscreen--tablet]) #container{height:90dvh}}@media screen and (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 (width>=64.0625rem) and (width<=90rem){:host([fullscreen--laptop]:not([showfrom=left]):not([showfrom=right])) #container{height:90dvh}}@media screen and (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)}:is(:host([showfrom=right]),:host([showfrom=left])) dialog{width:75%;height:100%}:is(:host([showfrom=right]),:host([showfrom=left])) #container{height:100%;max-height:100%}:host([showfrom=right]) dialog{border-radius:var(--px-radius-main) 0 0 var(--px-radius-main);margin:0 0 0 auto;animation:.3s dialog-fade-in-right}:host([showfrom=right]) #container{margin:0 auto 0 0}:host([showfrom=left]) dialog{border-radius:0 var(--px-radius-main) var(--px-radius-main) 0;margin:0 auto 0 0;animation:.3s dialog-fade-in-left}:host([showfrom=left]) #container{margin:0 0 0 auto}:is(:host([showfrom=right][fullscreen]),:host([showfrom=left][fullscreen])) #container{height:100%}}@media screen and (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}}", r = new CSSStyleSheet();
|
|
9
|
+
r.replaceSync(n);
|
|
10
|
+
var i = "px.lavender.drawer.hide", a = class extends HTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(), this.observer = null, this.previousFocusedElement = null, this.template = "<dialog popover role=\"dialog\" aria-modal=\"true\" >\n <div id=\"container\">\n <px-vstack gap=\"heading-to-subtitle\" id=\"header\">\n <px-h1 variant=\"title-2xl\">\n <slot name=\"title\"></slot>\n </px-h1>\n <px-h2 variant=\"subtitle\" color=\"neutral\">\n <slot name=\"subtitle\"></slot>\n </px-h2>\n </px-vstack>\n <div id=\"content\">\n <slot></slot>\n </div>\n <px-vstack gap=\"l\" id=\"footer\">\n <px-separator size=\"m\"></px-separator>\n <px-stack\n gap=\"s\"\n justify-content=\"flex-end\"\n align-items=\"center\"\n align-items--mobile=\"stretch\"\n direction=\"row\"\n direction--mobile=\"column-reverse\"\n >\n <slot name=\"footer\"></slot>\n </px-stack>\n </px-vstack>\n <px-button-icon variant=\"secondary\" size=\"small\" id=\"close\">\n <px-icon name=\"cross\" from=\"lavender\"></px-icon>\n </px-button-icon>\n </div>\n </dialog>", this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = this.template, this.shadowRoot.adoptedStyleSheets = [r];
|
|
13
|
+
}
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
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", () => {
|
|
16
|
+
this.hide();
|
|
17
|
+
}), this.$dialog.addEventListener("toggle", (e) => {
|
|
18
|
+
e.newState === "closed" && this.hide();
|
|
19
|
+
}), this.toggleFooterVisibility(), this.$slotFooter?.addEventListener("slotchange", this.toggleFooterVisibility);
|
|
20
|
+
}
|
|
21
|
+
static get observedAttributes() {
|
|
22
|
+
return [
|
|
23
|
+
"open",
|
|
24
|
+
"close-button-aria-label",
|
|
25
|
+
"openedby",
|
|
26
|
+
"closedby",
|
|
27
|
+
"fullscreen",
|
|
28
|
+
"fullscreen--mobile",
|
|
29
|
+
"fullscreen--tablet",
|
|
30
|
+
"fullscreen--laptop",
|
|
31
|
+
"fullscreen--desktop"
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
attributeChangedCallback(e, t, n) {
|
|
35
|
+
switch (e) {
|
|
36
|
+
case "open":
|
|
37
|
+
n === null ? this.hide() : this.show();
|
|
38
|
+
break;
|
|
39
|
+
case "close-button-aria-label":
|
|
40
|
+
n ? this.$closeButton?.setAttribute?.("aria-label", n || "Close drawer") : this.$closeButton?.removeAttribute("aria-label");
|
|
41
|
+
break;
|
|
42
|
+
case "openedby":
|
|
43
|
+
n !== t && (t && document.querySelector(`#${t}`)?.removeEventListener("click", () => this.show()), this.addOpenListener());
|
|
44
|
+
break;
|
|
45
|
+
case "closedby": this.addCloseListener();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
disconnectedCallback() {
|
|
49
|
+
this.$slotFooter?.removeEventListener("slotchange", this.toggleFooterVisibility), this.observer?.disconnect(), this.$opener && this.$opener.removeEventListener("click", () => this.show()), this.$closer && this.$closer.removeEventListener("click", () => this.hide());
|
|
50
|
+
}
|
|
51
|
+
show() {
|
|
52
|
+
let e = document.activeElement;
|
|
53
|
+
this.previousFocusedElement = e?.shadowRoot?.activeElement ?? e, this.$dialog.showPopover?.(), document.body.style.overflow = "hidden";
|
|
54
|
+
}
|
|
55
|
+
hide() {
|
|
56
|
+
this.$dialog.hidePopover?.(), document.body.style.overflow = "", this.previousFocusedElement?.focus(), this.previousFocusedElement = null, this.dispatchEvent(new Event(i, {
|
|
57
|
+
bubbles: !0,
|
|
58
|
+
composed: !0
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
toggleFooterVisibility() {
|
|
62
|
+
this.$slottedFooter ? this.$footer.style.display = "block" : this.$footer.style.display = "none";
|
|
63
|
+
}
|
|
64
|
+
addOpenListener() {
|
|
65
|
+
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(() => {
|
|
66
|
+
this.$opener && (this.observer.disconnect(), this.observer = null, this.addOpenListener());
|
|
67
|
+
}), this.observer.observe(document.body, {
|
|
68
|
+
childList: !0,
|
|
69
|
+
subtree: !0
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
addCloseListener() {
|
|
73
|
+
this.$closer && this.$closer?.addEventListener("click", () => {
|
|
74
|
+
this.hide();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
get $opener() {
|
|
78
|
+
return document.querySelector(`#${this.getAttribute("openedby")}`);
|
|
79
|
+
}
|
|
80
|
+
get $closer() {
|
|
81
|
+
return document.querySelector(`#${this.getAttribute("closedby")}`);
|
|
82
|
+
}
|
|
83
|
+
get $closeButton() {
|
|
84
|
+
return this.shadowRoot.querySelector("px-button-icon");
|
|
85
|
+
}
|
|
86
|
+
get $dialog() {
|
|
87
|
+
return this.shadowRoot.querySelector("dialog");
|
|
88
|
+
}
|
|
89
|
+
get open() {
|
|
90
|
+
return this.hasAttribute("open");
|
|
91
|
+
}
|
|
92
|
+
get $slotFooter() {
|
|
93
|
+
return this.shadowRoot.querySelector("slot[name=\"footer\"]");
|
|
94
|
+
}
|
|
95
|
+
get $slottedFooter() {
|
|
96
|
+
return this.querySelector("[slot=\"footer\"]");
|
|
97
|
+
}
|
|
98
|
+
get $footer() {
|
|
99
|
+
return this.shadowRoot.querySelector("#footer");
|
|
100
|
+
}
|
|
101
|
+
set open(t) {
|
|
102
|
+
e(this, "open", t);
|
|
103
|
+
}
|
|
104
|
+
get closeButtonAriaLabel() {
|
|
105
|
+
return this.getAttribute("close-button-aria-label");
|
|
106
|
+
}
|
|
107
|
+
set closeButtonAriaLabel(e) {
|
|
108
|
+
t(this, "close-button-aria-label", e);
|
|
109
|
+
}
|
|
110
|
+
get openedby() {
|
|
111
|
+
return this.getAttribute("openedby");
|
|
112
|
+
}
|
|
113
|
+
set openedby(e) {
|
|
114
|
+
t(this, "openedby", e);
|
|
115
|
+
}
|
|
116
|
+
get closedby() {
|
|
117
|
+
return this.getAttribute("closedby");
|
|
118
|
+
}
|
|
119
|
+
set closedby(e) {
|
|
120
|
+
t(this, "closedby", e);
|
|
121
|
+
}
|
|
122
|
+
get fullscreen() {
|
|
123
|
+
return this.hasAttribute("fullscreen");
|
|
124
|
+
}
|
|
125
|
+
set fullscreen(t) {
|
|
126
|
+
e(this, "fullscreen", t);
|
|
127
|
+
}
|
|
128
|
+
get fullscreenMobile() {
|
|
129
|
+
return this.hasAttribute("fullscreen--mobile");
|
|
130
|
+
}
|
|
131
|
+
set fullscreenMobile(t) {
|
|
132
|
+
e(this, "fullscreen--mobile", t);
|
|
133
|
+
}
|
|
134
|
+
get fullscreenTablet() {
|
|
135
|
+
return this.hasAttribute("fullscreen--tablet");
|
|
136
|
+
}
|
|
137
|
+
set fullscreenTablet(t) {
|
|
138
|
+
e(this, "fullscreen--tablet", t);
|
|
139
|
+
}
|
|
140
|
+
get fullscreenLaptop() {
|
|
141
|
+
return this.hasAttribute("fullscreen--laptop");
|
|
142
|
+
}
|
|
143
|
+
set fullscreenLaptop(t) {
|
|
144
|
+
e(this, "fullscreen--laptop", t);
|
|
145
|
+
}
|
|
146
|
+
get fullscreenDesktop() {
|
|
147
|
+
return this.hasAttribute("fullscreen--desktop");
|
|
148
|
+
}
|
|
149
|
+
set fullscreenDesktop(t) {
|
|
150
|
+
e(this, "fullscreen--desktop", t);
|
|
151
|
+
}
|
|
136
152
|
};
|
|
153
|
+
customElements.get("px-drawer") || customElements.define("px-drawer", a);
|
|
154
|
+
//#endregion
|
|
155
|
+
export { a as Drawer, i as HIDE_EVENT };
|
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.190",
|
|
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"
|