@proximus/lavender-dropdown 2.0.0-alpha.21 → 2.0.0-alpha.210

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,7 +13,12 @@ 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;
16
19
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
20
+ updatePopoverMaxHeight(newValue?: string): void;
21
+ updatePopoverMaxWidth(newValue?: string): void;
17
22
  private initPopover;
18
23
  private get popoverId();
19
24
  private get anchorName();
@@ -24,4 +29,14 @@ export declare class Dropdown extends WithExtraAttributes {
24
29
  set anchorAlignment(value: AnchorAlignment);
25
30
  get usePolyfill(): boolean;
26
31
  set usePolyfill(value: boolean);
32
+ get manualToggle(): boolean;
33
+ set manualToggle(value: boolean);
34
+ get popoverHeight(): string | null;
35
+ set popoverHeight(value: string | null);
36
+ get popoverMaxHeight(): string | null;
37
+ set popoverMaxHeight(value: string | null);
38
+ get popoverMaxWidth(): string | null;
39
+ set popoverMaxWidth(value: string | null);
40
+ get inverted(): boolean;
41
+ set inverted(value: boolean);
27
42
  }
@@ -1,2 +1,2 @@
1
1
  import { AnchorAlignment } from './common';
2
- export declare function anchorPolyfill($trigger: HTMLElement, $popoverElement: HTMLElement, anchorAlignment: AnchorAlignment, computedStyle: CSSStyleDeclaration, usePolyfill?: boolean): void;
2
+ export declare function anchorPolyfill($trigger: HTMLElement, $popoverElement: HTMLElement, anchorAlignment: AnchorAlignment | undefined, computedStyle: CSSStyleDeclaration, usePolyfill?: boolean): void;
@@ -0,0 +1,309 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/Dropdown.ts",
8
+ "declarations": [
9
+ {
10
+ "kind": "class",
11
+ "description": "",
12
+ "name": "Dropdown",
13
+ "members": [
14
+ {
15
+ "kind": "field",
16
+ "name": "template",
17
+ "privacy": "private"
18
+ },
19
+ {
20
+ "kind": "field",
21
+ "name": "css",
22
+ "privacy": "private",
23
+ "description": "Instance level styling for the dropdown component.\nThis is used to set the anchor name and position of the popover.",
24
+ "readonly": true
25
+ },
26
+ {
27
+ "kind": "field",
28
+ "name": "isAboutToClose",
29
+ "type": {
30
+ "text": "boolean"
31
+ },
32
+ "privacy": "private",
33
+ "default": "false"
34
+ },
35
+ {
36
+ "kind": "method",
37
+ "name": "#resetManualPopoverDisplay",
38
+ "privacy": "private"
39
+ },
40
+ {
41
+ "kind": "field",
42
+ "name": "triggerPopoverDisplay"
43
+ },
44
+ {
45
+ "kind": "field",
46
+ "name": "showPopover"
47
+ },
48
+ {
49
+ "kind": "field",
50
+ "name": "hidePopover"
51
+ },
52
+ {
53
+ "kind": "field",
54
+ "name": "#beforeToggle",
55
+ "privacy": "private"
56
+ },
57
+ {
58
+ "kind": "field",
59
+ "name": "#onToggle",
60
+ "privacy": "private"
61
+ },
62
+ {
63
+ "kind": "method",
64
+ "name": "#handleManualPopoverDisplay",
65
+ "privacy": "private",
66
+ "description": "Handles the manual display of the popover when the trigger is clicked.\nThis is necessary for cases where the trigger is not a button or input element.\nThis method adds event listeners to the trigger element to toggle the popover.\nIt also manages the state of whether the popover is about to close or not to avoid\nrace conditions when the popover is toggled and the trigger click event is fired."
67
+ },
68
+ {
69
+ "kind": "method",
70
+ "name": "updatePopoverMaxHeight",
71
+ "parameters": [
72
+ {
73
+ "name": "newValue",
74
+ "optional": true,
75
+ "type": {
76
+ "text": "string"
77
+ }
78
+ }
79
+ ]
80
+ },
81
+ {
82
+ "kind": "method",
83
+ "name": "updatePopoverMaxWidth",
84
+ "parameters": [
85
+ {
86
+ "name": "newValue",
87
+ "optional": true,
88
+ "type": {
89
+ "text": "string"
90
+ }
91
+ }
92
+ ]
93
+ },
94
+ {
95
+ "kind": "method",
96
+ "name": "initPopover",
97
+ "privacy": "private"
98
+ },
99
+ {
100
+ "kind": "field",
101
+ "name": "popoverId",
102
+ "privacy": "private",
103
+ "readonly": true
104
+ },
105
+ {
106
+ "kind": "field",
107
+ "name": "anchorName",
108
+ "privacy": "private",
109
+ "readonly": true
110
+ },
111
+ {
112
+ "kind": "field",
113
+ "name": "$style",
114
+ "privacy": "private",
115
+ "readonly": true
116
+ },
117
+ {
118
+ "kind": "field",
119
+ "name": "$trigger",
120
+ "readonly": true
121
+ },
122
+ {
123
+ "kind": "field",
124
+ "name": "$popoverElement",
125
+ "readonly": true
126
+ },
127
+ {
128
+ "kind": "field",
129
+ "name": "anchorAlignment",
130
+ "type": {
131
+ "text": "AnchorAlignment"
132
+ }
133
+ },
134
+ {
135
+ "kind": "field",
136
+ "name": "usePolyfill"
137
+ },
138
+ {
139
+ "kind": "field",
140
+ "name": "manualToggle"
141
+ },
142
+ {
143
+ "kind": "field",
144
+ "name": "popoverHeight"
145
+ },
146
+ {
147
+ "kind": "field",
148
+ "name": "popoverMaxHeight"
149
+ },
150
+ {
151
+ "kind": "field",
152
+ "name": "popoverMaxWidth"
153
+ },
154
+ {
155
+ "kind": "field",
156
+ "name": "inverted"
157
+ }
158
+ ],
159
+ "attributes": [
160
+ {
161
+ "name": "id"
162
+ },
163
+ {
164
+ "name": "anchoralignment"
165
+ },
166
+ {
167
+ "name": "use-polyfill"
168
+ },
169
+ {
170
+ "name": "manual-toggle"
171
+ },
172
+ {
173
+ "name": "popover-height"
174
+ },
175
+ {
176
+ "name": "popover-max-height"
177
+ },
178
+ {
179
+ "name": "popover-max-width"
180
+ },
181
+ {
182
+ "name": "inverted"
183
+ }
184
+ ],
185
+ "superclass": {
186
+ "name": "WithExtraAttributes",
187
+ "package": "@proximus/lavender-common"
188
+ },
189
+ "tagName": "px-dropdown",
190
+ "customElement": true
191
+ }
192
+ ],
193
+ "exports": [
194
+ {
195
+ "kind": "js",
196
+ "name": "Dropdown",
197
+ "declaration": {
198
+ "name": "Dropdown",
199
+ "module": "src/Dropdown.ts"
200
+ }
201
+ },
202
+ {
203
+ "kind": "custom-element-definition",
204
+ "name": "px-dropdown",
205
+ "declaration": {
206
+ "name": "Dropdown",
207
+ "module": "src/Dropdown.ts"
208
+ }
209
+ }
210
+ ]
211
+ },
212
+ {
213
+ "kind": "javascript-module",
214
+ "path": "src/anchorPolyfill.ts",
215
+ "declarations": [
216
+ {
217
+ "kind": "function",
218
+ "name": "anchorPolyfill",
219
+ "parameters": [
220
+ {
221
+ "name": "$trigger",
222
+ "type": {
223
+ "text": "HTMLElement"
224
+ }
225
+ },
226
+ {
227
+ "name": "$popoverElement",
228
+ "type": {
229
+ "text": "HTMLElement"
230
+ }
231
+ },
232
+ {
233
+ "name": "anchorAlignment",
234
+ "default": "'bottom-left'",
235
+ "type": {
236
+ "text": "AnchorAlignment"
237
+ }
238
+ },
239
+ {
240
+ "name": "computedStyle",
241
+ "type": {
242
+ "text": "CSSStyleDeclaration"
243
+ }
244
+ },
245
+ {
246
+ "name": "usePolyfill",
247
+ "default": "false"
248
+ }
249
+ ]
250
+ }
251
+ ],
252
+ "exports": [
253
+ {
254
+ "kind": "js",
255
+ "name": "anchorPolyfill",
256
+ "declaration": {
257
+ "name": "anchorPolyfill",
258
+ "module": "src/anchorPolyfill.ts"
259
+ }
260
+ }
261
+ ]
262
+ },
263
+ {
264
+ "kind": "javascript-module",
265
+ "path": "src/common.ts",
266
+ "declarations": [
267
+ {
268
+ "kind": "variable",
269
+ "name": "anchorAlignmentValues",
270
+ "type": {
271
+ "text": "[\n 'top-left',\n 'top-right',\n 'bottom-left',\n 'bottom-right',\n]"
272
+ },
273
+ "default": "[ 'top-left', 'top-right', 'bottom-left', 'bottom-right', ]"
274
+ }
275
+ ],
276
+ "exports": [
277
+ {
278
+ "kind": "js",
279
+ "name": "anchorAlignmentValues",
280
+ "declaration": {
281
+ "name": "anchorAlignmentValues",
282
+ "module": "src/common.ts"
283
+ }
284
+ }
285
+ ]
286
+ },
287
+ {
288
+ "kind": "javascript-module",
289
+ "path": "src/dropdown.css",
290
+ "declarations": [],
291
+ "exports": []
292
+ },
293
+ {
294
+ "kind": "javascript-module",
295
+ "path": "src/index.ts",
296
+ "declarations": [],
297
+ "exports": [
298
+ {
299
+ "kind": "js",
300
+ "name": "*",
301
+ "declaration": {
302
+ "name": "*",
303
+ "module": "src/Dropdown.ts"
304
+ }
305
+ }
306
+ ]
307
+ }
308
+ ]
309
+ }
package/dist/index.es.js CHANGED
@@ -1,61 +1,32 @@
1
- var x = (o) => {
2
- throw TypeError(o);
3
- };
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
- "top-left",
9
- "top-right",
10
- "bottom-left",
11
- "bottom-right"
1
+ import { WithExtraAttributes as e, booleanPropertyToAttributeSetter as t, log as n, propertyToAttributeSetter as r, renderTemplate as i } from "@proximus/lavender-common";
2
+ //#region src/dropdown.css?inline
3
+ var a = ":host{position:relative}::slotted([slot=popover]){border-radius:var(--px-radius-main,8px);background:var(--px-color-background-surface-light,#fff);margin:var(--px-spacing-xs-mobile) 0 0 0;width:auto;max-height:var(--px-popover-max-height);max-width:var(--px-popover-max-width);border:0;padding:0;position:fixed;right:0;box-shadow:0 20px 25px -5px #25252514}:host([grow]) ::slotted([slot=trigger]):after{padding-right:var(--px-padding-xs-mobile);right:0}:host([anchoralignment=top-left]) ::slotted([slot=popover]){margin:0 0 var(--px-spacing-xs-mobile) 0;top:auto}:host([anchoralignment=top-right]) ::slotted([slot=popover]){margin:0 0 var(--px-spacing-xs-mobile) 0;top:auto;left:auto}:host([anchoralignment=bottom-right]) ::slotted([slot=popover]){margin:var(--px-spacing-xs-mobile) 0 0 0;left:auto}@media screen and (width<=47.938rem){::slotted([slot=trigger]){width:100%;display:block}: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 (width>=48rem){::slotted([slot=popover]){margin:var(--px-spacing-xs-tablet) 0 0 0;width:auto;padding:0;right:auto}:host([anchoralignment=top-left]) ::slotted([slot=popover]){margin:0 0 var(--px-spacing-xs-tablet) 0}:host([anchoralignment=top-right]) ::slotted([slot=popover]){margin:0 0 var(--px-spacing-xs-tablet) 0}:host([anchoralignment=bottom-right]) ::slotted([slot=popover]){margin:var(--px-spacing-xs-tablet) 0 0 0}}@media screen and (width>=64.0625rem){::slotted([slot=popover]){margin:var(--px-spacing-xs-desktop) 0 0 0;width:auto;padding:0;right:auto}}@media screen and (width>=90.0625rem){::slotted([slot=popover]){width:auto;padding:0;right:auto}:host([anchoralignment=bottom-right]) ::slotted([slot=popover]){margin:var(--px-spacing-xs-desktop) 0 0 0}:host([anchoralignment=top-left]) ::slotted([slot=popover]){margin:0 0 var(--px-spacing-xs-desktop) 0}:host([anchoralignment=top-right]) ::slotted([slot=popover]){margin:0 0 var(--px-spacing-xs-desktop) 0}}:host([inverted]) ::slotted([slot=popover]){background:var(--px-color-background-surface-dark,#333)}", o = [
4
+ "top-left",
5
+ "top-right",
6
+ "bottom-left",
7
+ "bottom-right"
12
8
  ];
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
- return;
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
- );
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
- });
9
+ //#endregion
10
+ //#region src/anchorPolyfill.ts
11
+ function s(e, t, n = "bottom-left", r, i = !1) {
12
+ "anchorName" in document.documentElement.style && i === !1 || t.addEventListener("toggle", () => {
13
+ if (!e || !t) return;
14
+ let i = e.getBoundingClientRect(), a = window.visualViewport?.height ?? window.innerHeight, o = window.visualViewport?.width ?? window.innerWidth, s = r.getPropertyValue("--px-padding-s-mobile") || "16px", c = parseInt((r.getPropertyValue("--px-icon-size-xs-desktop") || "24").replace("px", ""));
15
+ ["top-left", "top-right"].includes(n) ? (t.style.bottom = `calc( ${s} + ${a - i.top - window.scrollY}px)`, t.style.top = "auto", n === "top-left" ? t.style.left = o < 768 ? `${s}px` : `${i.left}px` : t.style.right = o < 768 ? `${s}px` : `${o - i.right}px`) : (t.style.top = `${i.bottom + window.scrollY}px`, n === "bottom-left" ? t.style.left = o < 768 ? `${s}px` : `${i.left}px` : t.style.right = o < 768 ? `${s}px` : `${o - i.right - c}px`);
16
+ });
23
17
  }
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
- constructor() {
30
- super(w);
31
- c(this, p);
32
- c(this, l);
33
- c(this, a);
34
- c(this, h);
35
- this.template = () => `
36
- <style>${this.css}</style>
37
- <slot name="trigger"></slot>
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, () => {
43
- this.$popoverElement.matches(":popover-open") || setTimeout(() => {
44
- this.isAboutToClose = !1;
45
- });
46
- }), this.shadowRoot.innerHTML = this.template();
47
- }
48
- /**
49
- * Instance level styling for the dropdown component.
50
- * This is used to set the anchor name and position of the popover.
51
- * @private
52
- */
53
- get css() {
54
- return `::slotted([slot='trigger']) {
18
+ /* v8 ignore end */
19
+ //#endregion
20
+ //#region src/Dropdown.ts
21
+ var c = new CSSStyleSheet();
22
+ c.replaceSync(a);
23
+ var l = "bottom-left", u = class extends e {
24
+ get css() {
25
+ return `::slotted([slot='trigger']) {
55
26
  anchor-name: ${this.anchorName};
56
27
  }
57
28
  :host([anchoralignment="bottom-left"]) {
58
- ::slotted([slot="popover"]) {
29
+ ::slotted([popover]) {
59
30
  position-anchor: ${this.anchorName};
60
31
  top: anchor(${this.anchorName} bottom);
61
32
  left: anchor(${this.anchorName} left);
@@ -65,113 +36,158 @@ class L extends C {
65
36
  ::slotted([slot="popover"]) {
66
37
  position-anchor: ${this.anchorName};
67
38
  top: anchor(${this.anchorName} bottom);
68
- right: calc(anchor(${this.anchorName} right) - var(--px-size-icon-xs));
39
+ right: anchor(${this.anchorName} right);
69
40
  }
70
41
  }
71
42
  :host([anchoralignment="top-left"]) {
72
43
  ::slotted([slot="popover"]) {
73
44
  position-anchor: ${this.anchorName};
74
- bottom: calc( var(--px-padding-s-mobile) + anchor(${this.anchorName} top));
45
+ bottom: anchor(${this.anchorName} top);
75
46
  left: anchor(${this.anchorName} left);
76
47
  }
77
48
  }
78
49
  :host([anchoralignment="top-right"]) {
79
50
  ::slotted([slot="popover"]) {
80
51
  position-anchor: ${this.anchorName};
81
- bottom: calc( var(--px-padding-s-mobile) + anchor(${this.anchorName} top));
52
+ bottom: anchor(${this.anchorName} top);
82
53
  right: anchor(${this.anchorName} right);
83
54
  }
84
55
  }`;
85
- }
86
- static get observedAttributes() {
87
- return [
88
- ...super.observedAttributes,
89
- "id",
90
- "anchoralignment",
91
- "use-polyfill"
92
- ];
93
- }
94
- connectedCallback() {
95
- this.getAttribute("id") || this.setAttribute(
96
- "id",
97
- `px-dropdown-${Math.random().toString(36).substring(2, 15)}`
98
- ), this.getAttribute("anchoralignment") || this.setAttribute("anchoralignment", m), y(
99
- this.$trigger,
100
- this.$popoverElement,
101
- this.anchorAlignment,
102
- getComputedStyle(this),
103
- this.usePolyfill
104
- );
105
- }
106
- attributeChangedCallback(e, i, d) {
107
- if (i !== d)
108
- switch (e) {
109
- case "id":
110
- this.initPopover();
111
- break;
112
- case "use-polyfill":
113
- y(
114
- this.$trigger,
115
- this.$popoverElement,
116
- this.anchorAlignment,
117
- getComputedStyle(this),
118
- this.usePolyfill
119
- );
120
- break;
121
- default:
122
- super.attributeChangedCallback(e, i, d);
123
- break;
124
- }
125
- }
126
- initPopover() {
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));
128
- }
129
- get popoverId() {
130
- return `${this.getAttribute("id")}-popover`;
131
- }
132
- get anchorName() {
133
- return `--${this.getAttribute("id")}-anchor`;
134
- }
135
- get $style() {
136
- return this.shadowRoot.querySelector("style");
137
- }
138
- get $trigger() {
139
- return this.querySelector('[slot="trigger"]');
140
- }
141
- get $popoverElement() {
142
- return this.querySelector('[slot="popover"]');
143
- }
144
- get anchorAlignment() {
145
- return this.getAttribute("anchoralignment") || m;
146
- }
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));
151
- }
152
- get usePolyfill() {
153
- return this.hasAttribute("use-polyfill");
154
- }
155
- set usePolyfill(e) {
156
- e ? this.setAttribute("use-polyfill", "") : this.removeAttribute("use-polyfill");
157
- }
158
- }
159
- p = new WeakSet(), A = function() {
160
- this.isAboutToClose = !1, this.$trigger.removeEventListener("click", s(this, l)), this.$popoverElement.removeEventListener(
161
- "beforetoggle",
162
- s(this, a)
163
- ), this.$popoverElement.removeEventListener("toggle", s(this, h));
164
- }, l = new WeakMap(), a = new WeakMap(), h = new WeakMap(), /**
165
- * Handles the manual display of the popover when the trigger is clicked.
166
- * This is necessary for cases where the trigger is not a button or input element.
167
- * This method adds event listeners to the trigger element to toggle the popover.
168
- * It also manages the state of whether the popover is about to close or not to avoid
169
- * race conditions when the popover is toggled and the trigger click event is fired.
170
- */
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)));
173
- };
174
- customElements.get("px-dropdown") || customElements.define("px-dropdown", L);
175
- export {
176
- L as Dropdown
56
+ }
57
+ static get observedAttributes() {
58
+ return [
59
+ ...super.observedAttributes,
60
+ "id",
61
+ "anchoralignment",
62
+ "use-polyfill",
63
+ "manual-toggle",
64
+ "popover-height",
65
+ "popover-max-height",
66
+ "popover-max-width",
67
+ "inverted"
68
+ ];
69
+ }
70
+ constructor() {
71
+ super(c), this.template = () => `
72
+ <style>${this.css}</style>
73
+ <slot name="trigger"></slot>
74
+ <slot name="popover"></slot>`, this.isAboutToClose = !1, this.triggerPopoverDisplay = () => {
75
+ this.isAboutToClose || (this.$popoverElement.togglePopover({ source: this.$trigger }), this.manualToggle || (this.$trigger.ariaExpanded = "true"));
76
+ }, this.showPopover = () => {
77
+ this.isAboutToClose || this.$popoverElement.showPopover();
78
+ }, this.hidePopover = () => {
79
+ this.$popoverElement.hidePopover();
80
+ }, this.#t = () => {
81
+ this.$popoverElement.matches(":popover-open") && (this.isAboutToClose = !0, this.manualToggle || (this.$trigger.ariaExpanded = "false"));
82
+ }, this.#n = () => {
83
+ this.$popoverElement.matches(":popover-open") || setTimeout(() => {
84
+ this.isAboutToClose = !1;
85
+ });
86
+ }, i(this.shadowRoot, this.template());
87
+ }
88
+ connectedCallback() {
89
+ this.getAttribute("id") || this.setAttribute("id", `px-dropdown-${Math.random().toString(36).substring(2, 15)}`), this.getAttribute("anchoralignment") || this.setAttribute("anchoralignment", l), s(this.$trigger, this.$popoverElement, this.anchorAlignment, getComputedStyle(this), this.usePolyfill);
90
+ }
91
+ #e() {
92
+ this.isAboutToClose = !1, this.manualToggle || this.$trigger.removeEventListener("click", this.triggerPopoverDisplay), this.$popoverElement.removeEventListener("beforetoggle", this.#t), this.$popoverElement.removeEventListener("toggle", this.#n);
93
+ }
94
+ #t;
95
+ #n;
96
+ #r() {
97
+ this.$trigger && !["button", "input"].includes(this.$trigger.localName) && (this.manualToggle || this.$trigger.addEventListener("click", this.triggerPopoverDisplay), this.$popoverElement.addEventListener("beforetoggle", this.#t), this.$popoverElement.addEventListener("toggle", this.#n));
98
+ }
99
+ attributeChangedCallback(e, t, n) {
100
+ if (t !== n) switch (e) {
101
+ case "id":
102
+ this.initPopover();
103
+ break;
104
+ case "use-polyfill":
105
+ s(this.$trigger, this.$popoverElement, this.anchorAlignment, getComputedStyle(this), this.usePolyfill);
106
+ break;
107
+ case "manual-toggle":
108
+ n != null && this.$trigger?.removeAttribute("aria-expanded");
109
+ break;
110
+ case "popover-height":
111
+ case "popover-max-height":
112
+ this.updatePopoverMaxHeight(n);
113
+ break;
114
+ case "popover-max-width":
115
+ this.updatePopoverMaxWidth(n);
116
+ break;
117
+ default: super.attributeChangedCallback(e, t, n);
118
+ }
119
+ }
120
+ updatePopoverMaxHeight(e) {
121
+ e ? this.$popoverElement.style.setProperty("--px-popover-max-height", e) : this.$popoverElement.style.removeProperty("--px-popover-max-height");
122
+ }
123
+ updatePopoverMaxWidth(e) {
124
+ e ? this.$popoverElement.style.setProperty("--px-popover-max-width", e) : this.$popoverElement.style.removeProperty("--px-popover-max-width");
125
+ }
126
+ initPopover() {
127
+ if (this.$trigger) {
128
+ this.$trigger.setAttribute("popovertarget", this.popoverId);
129
+ let e = this.getAttribute("id");
130
+ e && this.$trigger.setAttribute("aria-controls", e), 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, this.#e(), this.#r();
131
+ }
132
+ }
133
+ get popoverId() {
134
+ return `${this.getAttribute("id")}-popover`;
135
+ }
136
+ get anchorName() {
137
+ return `--${this.getAttribute("id")}-anchor`;
138
+ }
139
+ get $style() {
140
+ return this.shadowRoot.querySelector("style");
141
+ }
142
+ get $trigger() {
143
+ return this.querySelector("[slot=\"trigger\"]");
144
+ }
145
+ get $popoverElement() {
146
+ return this.querySelector("[slot=\"popover\"]");
147
+ }
148
+ get anchorAlignment() {
149
+ return this.getAttribute("anchoralignment") || l;
150
+ }
151
+ set anchorAlignment(e) {
152
+ o.includes(e) ? this.setAttribute("anchoralignment", e) : (n(`Invalid anchor alignment value: ${e}. Using default ${l}.`), this.setAttribute("anchoralignment", l));
153
+ }
154
+ get usePolyfill() {
155
+ return this.hasAttribute("use-polyfill");
156
+ }
157
+ set usePolyfill(e) {
158
+ e ? this.setAttribute("use-polyfill", "") : this.removeAttribute("use-polyfill");
159
+ }
160
+ get manualToggle() {
161
+ return this.hasAttribute("manual-toggle");
162
+ }
163
+ set manualToggle(e) {
164
+ e ? this.setAttribute("manual-toggle", "") : this.removeAttribute("manual-toggle");
165
+ }
166
+ get popoverHeight() {
167
+ return this.getAttribute("popover-height");
168
+ }
169
+ set popoverHeight(e) {
170
+ r(this, "popover-height", e);
171
+ }
172
+ get popoverMaxHeight() {
173
+ return this.getAttribute("popover-max-height");
174
+ }
175
+ set popoverMaxHeight(e) {
176
+ r(this, "popover-max-height", e);
177
+ }
178
+ get popoverMaxWidth() {
179
+ return this.getAttribute("popover-max-width");
180
+ }
181
+ set popoverMaxWidth(e) {
182
+ r(this, "popover-max-width", e);
183
+ }
184
+ get inverted() {
185
+ return this.hasAttribute("inverted");
186
+ }
187
+ set inverted(e) {
188
+ t(this, "inverted", e);
189
+ }
177
190
  };
191
+ customElements.get("px-dropdown") || customElements.define("px-dropdown", u);
192
+ //#endregion
193
+ export { u as Dropdown };
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-css-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "properties": [],
5
+ "pseudoElements": []
6
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-html-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "tags": [
5
+ {
6
+ "name": "px-dropdown",
7
+ "description": "\n---\n",
8
+ "attributes": [
9
+ { "name": "id", "values": [] },
10
+ { "name": "anchoralignment", "values": [] },
11
+ { "name": "use-polyfill", "values": [] },
12
+ { "name": "manual-toggle", "values": [] },
13
+ { "name": "popover-height", "values": [] },
14
+ { "name": "popover-max-height", "values": [] },
15
+ { "name": "popover-max-width", "values": [] },
16
+ { "name": "inverted", "values": [] }
17
+ ],
18
+ "references": []
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
+ "name": "@proximus/lavender-dropdown",
4
+ "version": "2.0.0-alpha.210",
5
+ "description-markup": "markdown",
6
+ "contributions": {
7
+ "html": {
8
+ "elements": [
9
+ {
10
+ "name": "px-dropdown",
11
+ "description": "\n\n---\n",
12
+ "doc-url": "",
13
+ "attributes": [
14
+ { "name": "id", "value": { "type": "string" } },
15
+ { "name": "anchoralignment", "value": { "type": "string" } },
16
+ { "name": "use-polyfill", "value": { "type": "string" } },
17
+ { "name": "manual-toggle", "value": { "type": "string" } },
18
+ { "name": "popover-height", "value": { "type": "string" } },
19
+ { "name": "popover-max-height", "value": { "type": "string" } },
20
+ { "name": "popover-max-width", "value": { "type": "string" } },
21
+ { "name": "inverted", "value": { "type": "string" } }
22
+ ],
23
+ "events": [],
24
+ "js": {
25
+ "properties": [
26
+ { "name": "triggerPopoverDisplay" },
27
+ { "name": "showPopover" },
28
+ { "name": "hidePopover" },
29
+ { "name": "$trigger" },
30
+ { "name": "$popoverElement" },
31
+ { "name": "anchorAlignment", "type": "AnchorAlignment" },
32
+ { "name": "usePolyfill" },
33
+ { "name": "manualToggle" },
34
+ { "name": "popoverHeight" },
35
+ { "name": "popoverMaxHeight" },
36
+ { "name": "popoverMaxWidth" },
37
+ { "name": "inverted" }
38
+ ],
39
+ "events": []
40
+ }
41
+ }
42
+ ]
43
+ },
44
+ "css": {
45
+ "properties": [],
46
+ "pseudo-elements": []
47
+ }
48
+ }
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-dropdown",
3
- "version": "2.0.0-alpha.21",
3
+ "version": "2.0.0-alpha.210",
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 ../custom-elements-manifest.config.js --outdir dist"
16
+ "wc-manifest": "cem analyze --globs \"src/*\" --config ../../custom-elements-manifest.config.js --outdir dist"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public"