@proximus/lavender-drawer 2.0.0-alpha.1 → 2.0.0-alpha.100
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 +17 -3
- package/dist/index.es.js +119 -53
- package/package.json +2 -2
package/dist/Drawer.d.ts
CHANGED
|
@@ -6,17 +6,31 @@ 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;
|
|
9
10
|
template: string;
|
|
10
11
|
constructor();
|
|
11
12
|
connectedCallback(): void;
|
|
12
13
|
static get observedAttributes(): string[];
|
|
13
|
-
attributeChangedCallback(
|
|
14
|
+
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
14
16
|
show(): void;
|
|
15
17
|
hide(): void;
|
|
18
|
+
toggleFooterVisibility(): void;
|
|
19
|
+
addOpenListener(): void;
|
|
20
|
+
addCloseListener(): void;
|
|
21
|
+
get $opener(): HTMLElement;
|
|
22
|
+
get $closer(): HTMLElement;
|
|
16
23
|
get $closeButton(): Icon;
|
|
17
24
|
get $dialog(): HTMLDialogElement;
|
|
18
25
|
get open(): boolean;
|
|
26
|
+
get $slotFooter(): HTMLSlotElement;
|
|
27
|
+
get $slottedFooter(): HTMLElement;
|
|
28
|
+
get $footer(): HTMLElement;
|
|
19
29
|
set open(value: boolean);
|
|
20
|
-
get
|
|
21
|
-
set
|
|
30
|
+
get closeButtonAriaLabel(): string;
|
|
31
|
+
set closeButtonAriaLabel(value: string);
|
|
32
|
+
get openedby(): string;
|
|
33
|
+
set openedby(value: string);
|
|
34
|
+
get closedby(): string;
|
|
35
|
+
set closedby(value: string);
|
|
22
36
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -3,25 +3,25 @@ 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
|
-
|
|
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)}@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){#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{width:75%;height:100%;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{max-height:100%;height:100%;margin:0 auto 0 0}:host([showfrom="left"]) dialog{width:75%;height:100%;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}}@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)}}@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
8
|
const d = "px.lavender.drawer.hide";
|
|
9
|
-
class
|
|
9
|
+
class h extends HTMLElement {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(), this.template = `<dialog popover role="dialog" aria-modal="true" >
|
|
12
12
|
<div id="container">
|
|
13
|
-
<px-vstack gap="
|
|
14
|
-
<px-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
<px-vstack gap="heading-to-subtitle" id="header">
|
|
14
|
+
<px-h1 variant="title-2xl">
|
|
15
|
+
<slot name="title"></slot>
|
|
16
|
+
</px-h1>
|
|
17
|
+
<px-h2 variant="subtitle" color="neutral">
|
|
18
|
+
<slot name="subtitle"></slot>
|
|
19
|
+
</px-h2>
|
|
20
|
+
</px-vstack>
|
|
21
|
+
<div id="content">
|
|
22
|
+
<slot></slot>
|
|
23
|
+
</div>
|
|
24
|
+
<px-vstack gap="l" id="footer">
|
|
25
25
|
<px-separator size="m"></px-separator>
|
|
26
26
|
<px-stack
|
|
27
27
|
gap="s"
|
|
@@ -34,57 +34,100 @@ class l extends HTMLElement {
|
|
|
34
34
|
<slot name="footer"></slot>
|
|
35
35
|
</px-stack>
|
|
36
36
|
</px-vstack>
|
|
37
|
-
<px-button-icon variant="secondary" size="small">
|
|
37
|
+
<px-button-icon variant="secondary" size="small" id="close">
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
`#${this.getAttribute("closedby")}`
|
|
47
|
-
);
|
|
48
|
-
t == null || t.addEventListener("click", () => {
|
|
49
|
-
this.hide();
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (this.hasAttribute("openedby")) {
|
|
53
|
-
const t = document.querySelector(
|
|
54
|
-
`px-button#${this.getAttribute("openedby")}`
|
|
55
|
-
);
|
|
56
|
-
t == null || t.addEventListener("click", () => {
|
|
57
|
-
this.show();
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
this.$closeButton.addEventListener("click", () => {
|
|
44
|
+
var t;
|
|
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", () => {
|
|
61
46
|
this.hide();
|
|
62
|
-
})
|
|
47
|
+
}), this.$dialog.addEventListener("toggle", (e) => {
|
|
48
|
+
e.newState === "closed" && this.hide();
|
|
49
|
+
}), this.toggleFooterVisibility(), (t = this.$slotFooter) == null || t.addEventListener(
|
|
50
|
+
"slotchange",
|
|
51
|
+
this.toggleFooterVisibility
|
|
52
|
+
);
|
|
63
53
|
}
|
|
64
54
|
static get observedAttributes() {
|
|
65
|
-
return ["open", "aria-label
|
|
55
|
+
return ["open", "close-button-aria-label", "openedby", "closedby"];
|
|
56
|
+
}
|
|
57
|
+
attributeChangedCallback(t, e, o) {
|
|
58
|
+
var a, i, s;
|
|
59
|
+
switch (t) {
|
|
60
|
+
case "open":
|
|
61
|
+
o !== null ? this.show() : this.hide();
|
|
62
|
+
break;
|
|
63
|
+
case "close-button-aria-label":
|
|
64
|
+
o ? (s = (i = this.$closeButton) == null ? void 0 : i.setAttribute) == null || s.call(
|
|
65
|
+
i,
|
|
66
|
+
"aria-label",
|
|
67
|
+
o || "Close drawer"
|
|
68
|
+
) : (a = this.$closeButton) == null || a.removeAttribute("aria-label");
|
|
69
|
+
break;
|
|
70
|
+
case "openedby":
|
|
71
|
+
if (o !== e) {
|
|
72
|
+
if (e) {
|
|
73
|
+
const r = document.querySelector(`#${e}`);
|
|
74
|
+
r == null || r.removeEventListener("click", () => this.show());
|
|
75
|
+
}
|
|
76
|
+
this.addOpenListener();
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case "closedby":
|
|
80
|
+
this.addCloseListener();
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
66
83
|
}
|
|
67
|
-
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
) : (a = this.$closeButton) == null || a.removeAttribute("aria-label"));
|
|
84
|
+
disconnectedCallback() {
|
|
85
|
+
var t, e;
|
|
86
|
+
(t = this.$slotFooter) == null || t.removeEventListener(
|
|
87
|
+
"slotchange",
|
|
88
|
+
this.toggleFooterVisibility
|
|
89
|
+
), (e = this.observer) == null || e.disconnect(), this.$opener && this.$opener.removeEventListener("click", () => this.show()), this.$closer && this.$closer.removeEventListener("click", () => this.hide());
|
|
74
90
|
}
|
|
75
91
|
show() {
|
|
76
|
-
var t,
|
|
77
|
-
(
|
|
92
|
+
var t, e;
|
|
93
|
+
(e = (t = this.$dialog).showPopover) == null || e.call(t), document.body.style.overflow = "hidden";
|
|
78
94
|
}
|
|
79
95
|
hide() {
|
|
80
|
-
var t,
|
|
81
|
-
(
|
|
96
|
+
var t, e;
|
|
97
|
+
(e = (t = this.$dialog).hidePopover) == null || e.call(t), document.body.style.overflow = "", this.dispatchEvent(
|
|
82
98
|
new Event(d, {
|
|
83
99
|
bubbles: !0,
|
|
84
100
|
composed: !0
|
|
85
101
|
})
|
|
86
102
|
);
|
|
87
103
|
}
|
|
104
|
+
toggleFooterVisibility() {
|
|
105
|
+
this.$slottedFooter ? this.$footer.style.display = "block" : this.$footer.style.display = "none";
|
|
106
|
+
}
|
|
107
|
+
addOpenListener() {
|
|
108
|
+
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(() => {
|
|
109
|
+
this.$opener && (this.observer.disconnect(), this.observer = null, this.addOpenListener());
|
|
110
|
+
}), this.observer.observe(document.body, {
|
|
111
|
+
childList: !0,
|
|
112
|
+
subtree: !0
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
addCloseListener() {
|
|
116
|
+
var t;
|
|
117
|
+
this.$closer && ((t = this.$closer) == null || t.addEventListener("click", () => {
|
|
118
|
+
this.hide();
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
get $opener() {
|
|
122
|
+
return document.querySelector(
|
|
123
|
+
`#${this.getAttribute("openedby")}`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
get $closer() {
|
|
127
|
+
return document.querySelector(
|
|
128
|
+
`#${this.getAttribute("closedby")}`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
88
131
|
get $closeButton() {
|
|
89
132
|
return this.shadowRoot.querySelector("px-button-icon");
|
|
90
133
|
}
|
|
@@ -94,18 +137,41 @@ class l extends HTMLElement {
|
|
|
94
137
|
get open() {
|
|
95
138
|
return this.hasAttribute("open");
|
|
96
139
|
}
|
|
140
|
+
get $slotFooter() {
|
|
141
|
+
return this.shadowRoot.querySelector(
|
|
142
|
+
'slot[name="footer"]'
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
get $slottedFooter() {
|
|
146
|
+
return this.querySelector('[slot="footer"]');
|
|
147
|
+
}
|
|
148
|
+
get $footer() {
|
|
149
|
+
return this.shadowRoot.querySelector("#footer");
|
|
150
|
+
}
|
|
97
151
|
set open(t) {
|
|
98
152
|
t ? this.setAttribute("open", "") : this.removeAttribute("open");
|
|
99
153
|
}
|
|
100
|
-
get
|
|
101
|
-
return this.getAttribute("aria-label
|
|
154
|
+
get closeButtonAriaLabel() {
|
|
155
|
+
return this.getAttribute("close-button-aria-label");
|
|
156
|
+
}
|
|
157
|
+
set closeButtonAriaLabel(t) {
|
|
158
|
+
this.setAttribute("close-button-aria-label", t);
|
|
159
|
+
}
|
|
160
|
+
get openedby() {
|
|
161
|
+
return this.getAttribute("openedby");
|
|
162
|
+
}
|
|
163
|
+
set openedby(t) {
|
|
164
|
+
this.setAttribute("openedby", t);
|
|
165
|
+
}
|
|
166
|
+
get closedby() {
|
|
167
|
+
return this.getAttribute("closedby");
|
|
102
168
|
}
|
|
103
|
-
set
|
|
104
|
-
this.setAttribute("
|
|
169
|
+
set closedby(t) {
|
|
170
|
+
this.setAttribute("closedby", t);
|
|
105
171
|
}
|
|
106
172
|
}
|
|
107
|
-
customElements.get("px-drawer") || customElements.define("px-drawer",
|
|
173
|
+
customElements.get("px-drawer") || customElements.define("px-drawer", h);
|
|
108
174
|
export {
|
|
109
|
-
|
|
175
|
+
h as Drawer,
|
|
110
176
|
d as HIDE_EVENT
|
|
111
177
|
};
|
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.100",
|
|
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"
|