@proximus/lavender-drawer 2.0.0-alpha.8 → 2.0.0-alpha.81
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 +10 -1
- package/dist/index.es.js +78 -39
- package/package.json +2 -2
package/dist/Drawer.d.ts
CHANGED
|
@@ -6,15 +6,20 @@ 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;
|
|
14
15
|
disconnectedCallback(): void;
|
|
15
16
|
show(): void;
|
|
16
17
|
hide(): void;
|
|
17
18
|
toggleFooterVisibility(): void;
|
|
19
|
+
addOpenListener(): void;
|
|
20
|
+
addCloseListener(): void;
|
|
21
|
+
get $opener(): HTMLElement;
|
|
22
|
+
get $closer(): HTMLElement;
|
|
18
23
|
get $closeButton(): Icon;
|
|
19
24
|
get $dialog(): HTMLDialogElement;
|
|
20
25
|
get open(): boolean;
|
|
@@ -24,4 +29,8 @@ export declare class Drawer extends HTMLElement {
|
|
|
24
29
|
set open(value: boolean);
|
|
25
30
|
get closeButtonAriaLabel(): string;
|
|
26
31
|
set closeButtonAriaLabel(value: string);
|
|
32
|
+
get openedby(): string;
|
|
33
|
+
set openedby(value: string);
|
|
34
|
+
get closedby(): string;
|
|
35
|
+
set closedby(value: string);
|
|
27
36
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -3,10 +3,10 @@ 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)}@media only screen and (min-width: 48em){#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 only screen and (min-width: 64.0625em){#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 only screen and (min-width: 90.0625em){#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
|
+
const d = "px.lavender.drawer.hide";
|
|
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">
|
|
@@ -38,27 +38,11 @@ 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
44
|
var t;
|
|
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", () => {
|
|
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
47
|
}), this.toggleFooterVisibility(), (t = this.$slotFooter) == null || t.addEventListener(
|
|
64
48
|
"slotchange",
|
|
@@ -66,31 +50,50 @@ class d extends HTMLElement {
|
|
|
66
50
|
);
|
|
67
51
|
}
|
|
68
52
|
static get observedAttributes() {
|
|
69
|
-
return ["open", "close-button-aria-label"];
|
|
70
|
-
}
|
|
71
|
-
attributeChangedCallback(t, e,
|
|
72
|
-
var a,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
return ["open", "close-button-aria-label", "openedby", "closedby"];
|
|
54
|
+
}
|
|
55
|
+
attributeChangedCallback(t, e, o) {
|
|
56
|
+
var a, i, s;
|
|
57
|
+
switch (t) {
|
|
58
|
+
case "open":
|
|
59
|
+
o !== null ? this.show() : this.hide();
|
|
60
|
+
break;
|
|
61
|
+
case "close-button-aria-label":
|
|
62
|
+
o ? (s = (i = this.$closeButton) == null ? void 0 : i.setAttribute) == null || s.call(
|
|
63
|
+
i,
|
|
64
|
+
"aria-label",
|
|
65
|
+
o || "Close drawer"
|
|
66
|
+
) : (a = this.$closeButton) == null || a.removeAttribute("aria-label");
|
|
67
|
+
break;
|
|
68
|
+
case "openedby":
|
|
69
|
+
if (o !== e) {
|
|
70
|
+
if (e) {
|
|
71
|
+
const r = document.querySelector(`#${e}`);
|
|
72
|
+
r == null || r.removeEventListener("click", () => this.show());
|
|
73
|
+
}
|
|
74
|
+
this.addOpenListener();
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
case "closedby":
|
|
78
|
+
this.addCloseListener();
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
disconnectedCallback() {
|
|
80
|
-
var t;
|
|
83
|
+
var t, e;
|
|
81
84
|
(t = this.$slotFooter) == null || t.removeEventListener(
|
|
82
85
|
"slotchange",
|
|
83
86
|
this.toggleFooterVisibility
|
|
84
|
-
);
|
|
87
|
+
), (e = this.observer) == null || e.disconnect(), this.$opener && this.$opener.removeEventListener("click", () => this.show()), this.$closer && this.$closer.removeEventListener("click", () => this.hide());
|
|
85
88
|
}
|
|
86
89
|
show() {
|
|
87
90
|
var t, e;
|
|
88
|
-
(e = (t = this.$dialog).showPopover) == null || e.call(t);
|
|
91
|
+
(e = (t = this.$dialog).showPopover) == null || e.call(t), document.body.style.overflow = "hidden";
|
|
89
92
|
}
|
|
90
93
|
hide() {
|
|
91
94
|
var t, e;
|
|
92
|
-
(e = (t = this.$dialog).hidePopover) == null || e.call(t), this.dispatchEvent(
|
|
93
|
-
new Event(
|
|
95
|
+
(e = (t = this.$dialog).hidePopover) == null || e.call(t), document.body.style.overflow = "", this.dispatchEvent(
|
|
96
|
+
new Event(d, {
|
|
94
97
|
bubbles: !0,
|
|
95
98
|
composed: !0
|
|
96
99
|
})
|
|
@@ -99,6 +102,30 @@ class d extends HTMLElement {
|
|
|
99
102
|
toggleFooterVisibility() {
|
|
100
103
|
this.$slottedFooter ? this.$footer.style.display = "block" : this.$footer.style.display = "none";
|
|
101
104
|
}
|
|
105
|
+
addOpenListener() {
|
|
106
|
+
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(() => {
|
|
107
|
+
this.$opener && (this.observer.disconnect(), this.observer = null, this.addOpenListener());
|
|
108
|
+
}), this.observer.observe(document.body, {
|
|
109
|
+
childList: !0,
|
|
110
|
+
subtree: !0
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
addCloseListener() {
|
|
114
|
+
var t;
|
|
115
|
+
this.$closer && ((t = this.$closer) == null || t.addEventListener("click", () => {
|
|
116
|
+
this.hide();
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
get $opener() {
|
|
120
|
+
return document.querySelector(
|
|
121
|
+
`#${this.getAttribute("openedby")}`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
get $closer() {
|
|
125
|
+
return document.querySelector(
|
|
126
|
+
`#${this.getAttribute("closedby")}`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
102
129
|
get $closeButton() {
|
|
103
130
|
return this.shadowRoot.querySelector("px-button-icon");
|
|
104
131
|
}
|
|
@@ -128,9 +155,21 @@ class d extends HTMLElement {
|
|
|
128
155
|
set closeButtonAriaLabel(t) {
|
|
129
156
|
this.setAttribute("close-button-aria-label", t);
|
|
130
157
|
}
|
|
158
|
+
get openedby() {
|
|
159
|
+
return this.getAttribute("openedby");
|
|
160
|
+
}
|
|
161
|
+
set openedby(t) {
|
|
162
|
+
this.setAttribute("openedby", t);
|
|
163
|
+
}
|
|
164
|
+
get closedby() {
|
|
165
|
+
return this.getAttribute("closedby");
|
|
166
|
+
}
|
|
167
|
+
set closedby(t) {
|
|
168
|
+
this.setAttribute("closedby", t);
|
|
169
|
+
}
|
|
131
170
|
}
|
|
132
|
-
customElements.get("px-drawer") || customElements.define("px-drawer",
|
|
171
|
+
customElements.get("px-drawer") || customElements.define("px-drawer", h);
|
|
133
172
|
export {
|
|
134
|
-
|
|
135
|
-
|
|
173
|
+
h as Drawer,
|
|
174
|
+
d as HIDE_EVENT
|
|
136
175
|
};
|
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.81",
|
|
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"
|