@proximus/lavender-dropdown 1.4.10-beta.4 → 1.4.10
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/Dropdown.d.ts +0 -3
- package/dist/index.es.js +26 -42
- package/package.json +1 -1
package/dist/Dropdown.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export declare class Dropdown extends WithExtraAttributes {
|
|
|
17
17
|
showPopover: () => void;
|
|
18
18
|
hidePopover: () => void;
|
|
19
19
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
20
|
-
updatePopoverHeight(newValue?: string): void;
|
|
21
20
|
private initPopover;
|
|
22
21
|
private get popoverId();
|
|
23
22
|
private get anchorName();
|
|
@@ -30,6 +29,4 @@ export declare class Dropdown extends WithExtraAttributes {
|
|
|
30
29
|
set usePolyfill(value: boolean);
|
|
31
30
|
get manualToggle(): boolean;
|
|
32
31
|
set manualToggle(value: boolean);
|
|
33
|
-
get popoverHeight(): string;
|
|
34
|
-
set popoverHeight(value: string);
|
|
35
32
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
var $ = (o) => {
|
|
2
2
|
throw TypeError(o);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var g = (o, e, t) => (
|
|
4
|
+
var u = (o, e, t) => e.has(o) || $("Cannot " + t);
|
|
5
|
+
var g = (o, e, t) => (u(o, e, "read from private field"), t ? t.call(o) : e.get(o)), d = (o, e, t) => e.has(o) ? $("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), m = (o, e, t, s) => (u(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), b = (o, e, t) => (u(o, e, "access private method"), t);
|
|
6
6
|
import { WithExtraAttributes as T, log as k } from "@proximus/lavender-common";
|
|
7
|
-
const
|
|
7
|
+
const C = ':host{position:relative}::slotted([slot="popover"]){position:absolute;border-radius:var(--px-radius-main, 8px);background:var(--px-color-background-container-light-default, #fff);box-shadow:0 20px 25px -5px #25252514;margin:0;padding:var(--px-padding-xs-mobile) 0;border:0;right:0;width:auto}:host([grow]) ::slotted([slot="trigger"]):after{right:0;padding-right:var(--px-padding-xs-mobile)}:host([anchoralignment="top-left"]) ::slotted([slot="popover"]){top:auto}:host([anchoralignment="top-right"]) ::slotted([slot="popover"]){top:auto}:host([anchoralignment="bottom-right"]) ::slotted([slot="popover"]){left:auto}@media screen and (max-width: 47.938rem){::slotted([slot="trigger"]){display:block;width:100%}:host([anchoralignment="top-left"]) ::slotted([slot="popover"]){left:var(--px-padding-s-mobile)}:host([anchoralignment="top-right"]) ::slotted([slot="popover"]){left:var(--px-padding-s-mobile)}}@media screen and (min-width: 48rem){::slotted([slot="popover"]){padding-block:var(--px-padding-s-desktop);right:auto;width:auto}}', N = [
|
|
8
8
|
"top-left",
|
|
9
9
|
"top-right",
|
|
10
10
|
"bottom-left",
|
|
11
11
|
"bottom-right"
|
|
12
12
|
];
|
|
13
|
-
function x(o, e, t = "bottom-left",
|
|
14
|
-
"anchorName" in document.documentElement.style &&
|
|
15
|
-
var
|
|
13
|
+
function x(o, e, t = "bottom-left", s, r = !1) {
|
|
14
|
+
"anchorName" in document.documentElement.style && r === !1 || e.addEventListener("toggle", () => {
|
|
15
|
+
var f, v;
|
|
16
16
|
if (!o || !e)
|
|
17
17
|
return;
|
|
18
|
-
const i = o.getBoundingClientRect(),
|
|
19
|
-
(
|
|
18
|
+
const i = o.getBoundingClientRect(), E = ((f = window.visualViewport) == null ? void 0 : f.height) ?? window.innerHeight, l = ((v = window.visualViewport) == null ? void 0 : v.width) ?? window.innerWidth, p = s.getPropertyValue("--px-padding-s-mobile") || "16px", P = parseInt(
|
|
19
|
+
(s.getPropertyValue("--px-icon-size-xs-desktop") || "24").replace("px", "")
|
|
20
20
|
);
|
|
21
|
-
["top-left", "top-right"].includes(t) ? (e.style.bottom = `calc( ${p} + ${
|
|
21
|
+
["top-left", "top-right"].includes(t) ? (e.style.bottom = `calc( ${p} + ${E - i.top - window.scrollY}px)`, e.style.top = "auto", t === "top-left" ? e.style.left = l < 768 ? `${p}px` : `${i.left}px` : e.style.right = l < 768 ? `${p}px` : `${l - i.right}px`) : (e.style.top = `${i.bottom + window.scrollY}px`, t === "bottom-left" ? e.style.left = l < 768 ? `${p}px` : `${i.left}px` : e.style.right = l < 768 ? `${p}px` : `${l - i.right - P}px`);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
const y = new CSSStyleSheet();
|
|
25
|
-
y.replaceSync(
|
|
25
|
+
y.replaceSync(C);
|
|
26
26
|
const c = "bottom-left";
|
|
27
|
-
var
|
|
27
|
+
var h, A, n, a, w;
|
|
28
28
|
class S extends T {
|
|
29
29
|
constructor() {
|
|
30
30
|
super(y);
|
|
31
|
-
d(this, n);
|
|
32
31
|
d(this, h);
|
|
32
|
+
d(this, n);
|
|
33
33
|
d(this, a);
|
|
34
34
|
this.template = () => `
|
|
35
35
|
<style>${this.css}</style>
|
|
@@ -40,9 +40,9 @@ class S extends T {
|
|
|
40
40
|
this.isAboutToClose || this.$popoverElement.showPopover();
|
|
41
41
|
}, this.hidePopover = () => {
|
|
42
42
|
this.$popoverElement.hidePopover();
|
|
43
|
-
},
|
|
43
|
+
}, m(this, n, () => {
|
|
44
44
|
this.$popoverElement.matches(":popover-open") && (this.isAboutToClose = !0, this.manualToggle || (this.$trigger.ariaExpanded = "false"));
|
|
45
|
-
}),
|
|
45
|
+
}), m(this, a, () => {
|
|
46
46
|
this.$popoverElement.matches(":popover-open") || setTimeout(() => {
|
|
47
47
|
this.isAboutToClose = !1;
|
|
48
48
|
});
|
|
@@ -58,7 +58,7 @@ class S extends T {
|
|
|
58
58
|
anchor-name: ${this.anchorName};
|
|
59
59
|
}
|
|
60
60
|
:host([anchoralignment="bottom-left"]) {
|
|
61
|
-
::slotted([popover]) {
|
|
61
|
+
::slotted([slot="popover"]) {
|
|
62
62
|
position-anchor: ${this.anchorName};
|
|
63
63
|
top: anchor(${this.anchorName} bottom);
|
|
64
64
|
left: anchor(${this.anchorName} left);
|
|
@@ -92,8 +92,7 @@ class S extends T {
|
|
|
92
92
|
"id",
|
|
93
93
|
"anchoralignment",
|
|
94
94
|
"use-polyfill",
|
|
95
|
-
"manual-toggle"
|
|
96
|
-
"popover-height"
|
|
95
|
+
"manual-toggle"
|
|
97
96
|
];
|
|
98
97
|
}
|
|
99
98
|
connectedCallback() {
|
|
@@ -108,9 +107,9 @@ class S extends T {
|
|
|
108
107
|
this.usePolyfill
|
|
109
108
|
);
|
|
110
109
|
}
|
|
111
|
-
attributeChangedCallback(t,
|
|
110
|
+
attributeChangedCallback(t, s, r) {
|
|
112
111
|
var i;
|
|
113
|
-
if (
|
|
112
|
+
if (s !== r)
|
|
114
113
|
switch (t) {
|
|
115
114
|
case "id":
|
|
116
115
|
this.initPopover();
|
|
@@ -125,24 +124,15 @@ class S extends T {
|
|
|
125
124
|
);
|
|
126
125
|
break;
|
|
127
126
|
case "manual-toggle":
|
|
128
|
-
|
|
129
|
-
break;
|
|
130
|
-
case "popover-height":
|
|
131
|
-
this.updatePopoverHeight(s);
|
|
127
|
+
r != null && ((i = this.$trigger) == null || i.removeAttribute("aria-expanded"));
|
|
132
128
|
break;
|
|
133
129
|
default:
|
|
134
|
-
super.attributeChangedCallback(t,
|
|
130
|
+
super.attributeChangedCallback(t, s, r);
|
|
135
131
|
break;
|
|
136
132
|
}
|
|
137
133
|
}
|
|
138
|
-
updatePopoverHeight(t) {
|
|
139
|
-
t ? this.$popoverElement.style.setProperty(
|
|
140
|
-
"--px-popover-max-height",
|
|
141
|
-
t
|
|
142
|
-
) : this.$popoverElement.style.removeProperty("--px-popover-max-height");
|
|
143
|
-
}
|
|
144
134
|
initPopover() {
|
|
145
|
-
this.$trigger && (this.$trigger.setAttribute("popovertarget", this.popoverId), this.$trigger.setAttribute("aria-controls", this.getAttribute("id")), this.hasAttribute("manual-toggle") || this.$trigger.setAttribute("aria-expanded", "false"), this.$popoverElement.setAttribute("id", this.popoverId), this.$popoverElement.setAttribute("popover", ""), this.$style.innerHTML = this.css,
|
|
135
|
+
this.$trigger && (this.$trigger.setAttribute("popovertarget", this.popoverId), this.$trigger.setAttribute("aria-controls", this.getAttribute("id")), this.hasAttribute("manual-toggle") || this.$trigger.setAttribute("aria-expanded", "false"), this.$popoverElement.setAttribute("id", this.popoverId), this.$popoverElement.setAttribute("popover", ""), this.$style.innerHTML = this.css, b(this, h, A).call(this), b(this, h, w).call(this));
|
|
146
136
|
}
|
|
147
137
|
get popoverId() {
|
|
148
138
|
return `${this.getAttribute("id")}-popover`;
|
|
@@ -163,7 +153,7 @@ class S extends T {
|
|
|
163
153
|
return this.getAttribute("anchoralignment") || c;
|
|
164
154
|
}
|
|
165
155
|
set anchorAlignment(t) {
|
|
166
|
-
|
|
156
|
+
N.includes(t) ? this.setAttribute("anchoralignment", t) : (k(
|
|
167
157
|
`Invalid anchor alignment value: ${t}. Using default ${c}.`
|
|
168
158
|
), this.setAttribute("anchoralignment", c));
|
|
169
159
|
}
|
|
@@ -179,19 +169,13 @@ class S extends T {
|
|
|
179
169
|
set manualToggle(t) {
|
|
180
170
|
t ? this.setAttribute("manual-toggle", "") : this.removeAttribute("manual-toggle");
|
|
181
171
|
}
|
|
182
|
-
get popoverHeight() {
|
|
183
|
-
return this.getAttribute("popover-height");
|
|
184
|
-
}
|
|
185
|
-
set popoverHeight(t) {
|
|
186
|
-
t ? this.setAttribute("popover-height", t) : this.removeAttribute("popover-height");
|
|
187
|
-
}
|
|
188
172
|
}
|
|
189
|
-
|
|
173
|
+
h = new WeakSet(), A = function() {
|
|
190
174
|
this.isAboutToClose = !1, this.manualToggle || this.$trigger.removeEventListener("click", this.triggerPopoverDisplay), this.$popoverElement.removeEventListener(
|
|
191
175
|
"beforetoggle",
|
|
192
|
-
g(this,
|
|
176
|
+
g(this, n)
|
|
193
177
|
), this.$popoverElement.removeEventListener("toggle", g(this, a));
|
|
194
|
-
},
|
|
178
|
+
}, n = new WeakMap(), a = new WeakMap(), /**
|
|
195
179
|
* Handles the manual display of the popover when the trigger is clicked.
|
|
196
180
|
* This is necessary for cases where the trigger is not a button or input element.
|
|
197
181
|
* This method adds event listeners to the trigger element to toggle the popover.
|
|
@@ -199,7 +183,7 @@ n = new WeakSet(), A = function() {
|
|
|
199
183
|
* race conditions when the popover is toggled and the trigger click event is fired.
|
|
200
184
|
*/
|
|
201
185
|
w = function() {
|
|
202
|
-
this.$trigger &&
|
|
186
|
+
this.$trigger && (this.manualToggle || this.$trigger.addEventListener("click", this.triggerPopoverDisplay), this.$popoverElement.addEventListener("beforetoggle", g(this, n)), this.$popoverElement.addEventListener("toggle", g(this, a)));
|
|
203
187
|
};
|
|
204
188
|
customElements.get("px-dropdown") || customElements.define("px-dropdown", S);
|
|
205
189
|
export {
|