@proximus/lavender-dropdown 1.4.9-beta.2 → 1.4.9

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.
@@ -13,9 +13,6 @@ export declare class Dropdown extends WithExtraAttributes {
13
13
  constructor();
14
14
  connectedCallback(): void;
15
15
  private isAboutToClose;
16
- triggerPopoverDisplay: () => void;
17
- showPopover: () => void;
18
- hidePopover: () => void;
19
16
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
20
17
  private initPopover;
21
18
  private get popoverId();
@@ -27,6 +24,4 @@ export declare class Dropdown extends WithExtraAttributes {
27
24
  set anchorAlignment(value: AnchorAlignment);
28
25
  get usePolyfill(): boolean;
29
26
  set usePolyfill(value: boolean);
30
- get manualToggle(): boolean;
31
- set manualToggle(value: boolean);
32
27
  }
package/dist/index.es.js CHANGED
@@ -1,48 +1,45 @@
1
- var $ = (o) => {
1
+ var x = (o) => {
2
2
  throw TypeError(o);
3
3
  };
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
- import { WithExtraAttributes as T, log as k } from "@proximus/lavender-common";
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 = [
4
+ var b = (o, t, e) => t.has(o) || x("Cannot " + e);
5
+ var s = (o, t, e) => (b(o, t, "read from private field"), e ? e.call(o) : t.get(o)), c = (o, t, e) => t.has(o) ? x("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e), u = (o, t, e, i) => (b(o, t, "write to private field"), i ? i.call(o, e) : t.set(o, e), e), f = (o, t, e) => (b(o, t, "access private method"), e);
6
+ import { WithExtraAttributes as C, log as P } from "@proximus/lavender-common";
7
+ const S = ':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: 767px){::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: 768px){::slotted([slot="popover"]){padding-block:var(--px-padding-s-desktop);right:auto;width:auto}}', T = [
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", s, r = !1) {
14
- "anchorName" in document.documentElement.style && r === !1 || e.addEventListener("toggle", () => {
15
- var f, v;
16
- if (!o || !e)
13
+ function y(o, t, e = "bottom-left", i, d = !1) {
14
+ "anchorName" in document.documentElement.style && d === !1 || t.addEventListener("toggle", () => {
15
+ var v, $;
16
+ if (!o || !t)
17
17
  return;
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", "")
18
+ const r = o.getBoundingClientRect(), N = ((v = window.visualViewport) == null ? void 0 : v.height) ?? window.innerHeight, n = (($ = window.visualViewport) == null ? void 0 : $.width) ?? window.innerWidth, g = i.getPropertyValue("--px-padding-s-mobile") || "16px", k = parseInt(
19
+ (i.getPropertyValue("--px-icon-size-xs-desktop") || "24").replace("px", "")
20
20
  );
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`);
21
+ ["top-left", "top-right"].includes(e) ? (t.style.bottom = `calc( ${g} + ${N - r.top - window.scrollY}px)`, t.style.top = "auto", e === "top-left" ? t.style.left = n < 768 ? `${g}px` : `${r.left}px` : t.style.right = n < 768 ? `${g}px` : `${n - r.right}px`) : (t.style.top = `${r.bottom + window.scrollY}px`, e === "bottom-left" ? t.style.left = n < 768 ? `${g}px` : `${r.left}px` : t.style.right = n < 768 ? `${g}px` : `${n - r.right - k}px`);
22
22
  });
23
23
  }
24
- const y = new CSSStyleSheet();
25
- y.replaceSync(C);
26
- const c = "bottom-left";
27
- var h, A, n, a, w;
28
- class S extends T {
24
+ const w = new CSSStyleSheet();
25
+ w.replaceSync(S);
26
+ const m = "bottom-left";
27
+ var p, A, l, a, h, E;
28
+ class L extends C {
29
29
  constructor() {
30
- super(y);
31
- d(this, h);
32
- d(this, n);
33
- d(this, a);
30
+ super(w);
31
+ c(this, p);
32
+ c(this, l);
33
+ c(this, a);
34
+ c(this, h);
34
35
  this.template = () => `
35
36
  <style>${this.css}</style>
36
37
  <slot name="trigger"></slot>
37
- <slot name="popover"></slot>`, this.isAboutToClose = !1, this.triggerPopoverDisplay = () => {
38
- this.isAboutToClose || (this.$popoverElement.togglePopover({ source: this.$trigger }), this.manualToggle || (this.$trigger.ariaExpanded = "true"));
39
- }, this.showPopover = () => {
40
- this.isAboutToClose || this.$popoverElement.showPopover();
41
- }, this.hidePopover = () => {
42
- this.$popoverElement.hidePopover();
43
- }, m(this, n, () => {
44
- this.$popoverElement.matches(":popover-open") && (this.isAboutToClose = !0, this.manualToggle || (this.$trigger.ariaExpanded = "false"));
45
- }), m(this, a, () => {
38
+ <slot name="popover"></slot>`, this.isAboutToClose = !1, u(this, l, () => {
39
+ this.isAboutToClose || (this.$popoverElement.togglePopover({ source: this.$trigger }), this.$trigger.ariaExpanded = "true");
40
+ }), u(this, a, () => {
41
+ this.$popoverElement.matches(":popover-open") && (this.isAboutToClose = !0, this.$trigger.ariaExpanded = "false");
42
+ }), u(this, h, () => {
46
43
  this.$popoverElement.matches(":popover-open") || setTimeout(() => {
47
44
  this.isAboutToClose = !1;
48
45
  });
@@ -91,15 +88,14 @@ class S extends T {
91
88
  ...super.observedAttributes,
92
89
  "id",
93
90
  "anchoralignment",
94
- "use-polyfill",
95
- "manual-toggle"
91
+ "use-polyfill"
96
92
  ];
97
93
  }
98
94
  connectedCallback() {
99
95
  this.getAttribute("id") || this.setAttribute(
100
96
  "id",
101
97
  `px-dropdown-${Math.random().toString(36).substring(2, 15)}`
102
- ), this.getAttribute("anchoralignment") || this.setAttribute("anchoralignment", c), x(
98
+ ), this.getAttribute("anchoralignment") || this.setAttribute("anchoralignment", m), y(
103
99
  this.$trigger,
104
100
  this.$popoverElement,
105
101
  this.anchorAlignment,
@@ -107,15 +103,14 @@ class S extends T {
107
103
  this.usePolyfill
108
104
  );
109
105
  }
110
- attributeChangedCallback(t, s, r) {
111
- var i;
112
- if (s !== r)
113
- switch (t) {
106
+ attributeChangedCallback(e, i, d) {
107
+ if (i !== d)
108
+ switch (e) {
114
109
  case "id":
115
110
  this.initPopover();
116
111
  break;
117
112
  case "use-polyfill":
118
- x(
113
+ y(
119
114
  this.$trigger,
120
115
  this.$popoverElement,
121
116
  this.anchorAlignment,
@@ -123,16 +118,13 @@ class S extends T {
123
118
  this.usePolyfill
124
119
  );
125
120
  break;
126
- case "manual-toggle":
127
- r != null && ((i = this.$trigger) == null || i.removeAttribute("aria-expanded"));
128
- break;
129
121
  default:
130
- super.attributeChangedCallback(t, s, r);
122
+ super.attributeChangedCallback(e, i, d);
131
123
  break;
132
124
  }
133
125
  }
134
126
  initPopover() {
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));
127
+ this.$trigger && (this.$trigger.setAttribute("popovertarget", this.popoverId), this.$trigger.setAttribute("aria-controls", this.popoverId), this.$trigger.setAttribute("aria-expanded", "false"), this.$popoverElement.setAttribute("id", this.popoverId), this.$popoverElement.setAttribute("popover", ""), this.$style.innerHTML = this.css, f(this, p, A).call(this), f(this, p, E).call(this));
136
128
  }
137
129
  get popoverId() {
138
130
  return `${this.getAttribute("id")}-popover`;
@@ -150,42 +142,36 @@ class S extends T {
150
142
  return this.querySelector('[slot="popover"]');
151
143
  }
152
144
  get anchorAlignment() {
153
- return this.getAttribute("anchoralignment") || c;
145
+ return this.getAttribute("anchoralignment") || m;
154
146
  }
155
- set anchorAlignment(t) {
156
- N.includes(t) ? this.setAttribute("anchoralignment", t) : (k(
157
- `Invalid anchor alignment value: ${t}. Using default ${c}.`
158
- ), this.setAttribute("anchoralignment", c));
147
+ set anchorAlignment(e) {
148
+ T.includes(e) ? this.setAttribute("anchoralignment", e) : (P(
149
+ `Invalid anchor alignment value: ${e}. Using default ${m}.`
150
+ ), this.setAttribute("anchoralignment", m));
159
151
  }
160
152
  get usePolyfill() {
161
153
  return this.hasAttribute("use-polyfill");
162
154
  }
163
- set usePolyfill(t) {
164
- t ? this.setAttribute("use-polyfill", "") : this.removeAttribute("use-polyfill");
165
- }
166
- get manualToggle() {
167
- return this.hasAttribute("manual-toggle");
168
- }
169
- set manualToggle(t) {
170
- t ? this.setAttribute("manual-toggle", "") : this.removeAttribute("manual-toggle");
155
+ set usePolyfill(e) {
156
+ e ? this.setAttribute("use-polyfill", "") : this.removeAttribute("use-polyfill");
171
157
  }
172
158
  }
173
- h = new WeakSet(), A = function() {
174
- this.isAboutToClose = !1, this.manualToggle || this.$trigger.removeEventListener("click", this.triggerPopoverDisplay), this.$popoverElement.removeEventListener(
159
+ p = new WeakSet(), A = function() {
160
+ this.isAboutToClose = !1, this.$trigger.removeEventListener("click", s(this, l)), this.$popoverElement.removeEventListener(
175
161
  "beforetoggle",
176
- g(this, n)
177
- ), this.$popoverElement.removeEventListener("toggle", g(this, a));
178
- }, n = new WeakMap(), a = new WeakMap(), /**
162
+ s(this, a)
163
+ ), this.$popoverElement.removeEventListener("toggle", s(this, h));
164
+ }, l = new WeakMap(), a = new WeakMap(), h = new WeakMap(), /**
179
165
  * Handles the manual display of the popover when the trigger is clicked.
180
166
  * This is necessary for cases where the trigger is not a button or input element.
181
167
  * This method adds event listeners to the trigger element to toggle the popover.
182
168
  * It also manages the state of whether the popover is about to close or not to avoid
183
169
  * race conditions when the popover is toggled and the trigger click event is fired.
184
170
  */
185
- w = function() {
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)));
171
+ E = function() {
172
+ this.$trigger && !["button", "input"].includes(this.$trigger.localName) && (this.$trigger.addEventListener("click", s(this, l)), this.$popoverElement.addEventListener("beforetoggle", s(this, a)), this.$popoverElement.addEventListener("toggle", s(this, h)));
187
173
  };
188
- customElements.get("px-dropdown") || customElements.define("px-dropdown", S);
174
+ customElements.get("px-dropdown") || customElements.define("px-dropdown", L);
189
175
  export {
190
- S as Dropdown
176
+ L as Dropdown
191
177
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-dropdown",
3
- "version": "1.4.9-beta.2",
3
+ "version": "1.4.9",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",