@proximus/lavender-dropdown 2.0.0-alpha.2 → 2.0.0-alpha.200
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 +8 -0
- package/dist/anchorPolyfill.d.ts +1 -1
- package/dist/custom-elements.json +279 -0
- package/dist/index.es.js +133 -145
- package/dist/vscode.css-custom-data.json +6 -0
- package/dist/vscode.html-custom-data.json +18 -0
- package/dist/web-types.json +44 -0
- package/package.json +2 -2
package/dist/Dropdown.d.ts
CHANGED
|
@@ -13,7 +13,11 @@ 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
|
+
updatePopoverHeight(newValue?: string): void;
|
|
17
21
|
private initPopover;
|
|
18
22
|
private get popoverId();
|
|
19
23
|
private get anchorName();
|
|
@@ -24,4 +28,8 @@ export declare class Dropdown extends WithExtraAttributes {
|
|
|
24
28
|
set anchorAlignment(value: AnchorAlignment);
|
|
25
29
|
get usePolyfill(): boolean;
|
|
26
30
|
set usePolyfill(value: boolean);
|
|
31
|
+
get manualToggle(): boolean;
|
|
32
|
+
set manualToggle(value: boolean);
|
|
33
|
+
get popoverHeight(): string | null;
|
|
34
|
+
set popoverHeight(value: string | null);
|
|
27
35
|
}
|
package/dist/anchorPolyfill.d.ts
CHANGED
|
@@ -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,279 @@
|
|
|
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": "updatePopoverHeight",
|
|
71
|
+
"parameters": [
|
|
72
|
+
{
|
|
73
|
+
"name": "newValue",
|
|
74
|
+
"optional": true,
|
|
75
|
+
"type": {
|
|
76
|
+
"text": "string"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"kind": "method",
|
|
83
|
+
"name": "initPopover",
|
|
84
|
+
"privacy": "private"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"kind": "field",
|
|
88
|
+
"name": "popoverId",
|
|
89
|
+
"privacy": "private",
|
|
90
|
+
"readonly": true
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"kind": "field",
|
|
94
|
+
"name": "anchorName",
|
|
95
|
+
"privacy": "private",
|
|
96
|
+
"readonly": true
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"kind": "field",
|
|
100
|
+
"name": "$style",
|
|
101
|
+
"privacy": "private",
|
|
102
|
+
"readonly": true
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"kind": "field",
|
|
106
|
+
"name": "$trigger",
|
|
107
|
+
"readonly": true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"kind": "field",
|
|
111
|
+
"name": "$popoverElement",
|
|
112
|
+
"readonly": true
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"kind": "field",
|
|
116
|
+
"name": "anchorAlignment",
|
|
117
|
+
"type": {
|
|
118
|
+
"text": "AnchorAlignment"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"kind": "field",
|
|
123
|
+
"name": "usePolyfill"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"kind": "field",
|
|
127
|
+
"name": "manualToggle"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"kind": "field",
|
|
131
|
+
"name": "popoverHeight"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"kind": "field",
|
|
135
|
+
"name": "innerHTML"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"attributes": [
|
|
139
|
+
{
|
|
140
|
+
"name": "id"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "anchoralignment"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "use-polyfill"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "manual-toggle"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "popover-height"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"superclass": {
|
|
156
|
+
"name": "WithExtraAttributes",
|
|
157
|
+
"package": "@proximus/lavender-common"
|
|
158
|
+
},
|
|
159
|
+
"tagName": "px-dropdown",
|
|
160
|
+
"customElement": true
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"exports": [
|
|
164
|
+
{
|
|
165
|
+
"kind": "js",
|
|
166
|
+
"name": "Dropdown",
|
|
167
|
+
"declaration": {
|
|
168
|
+
"name": "Dropdown",
|
|
169
|
+
"module": "src/Dropdown.ts"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"kind": "custom-element-definition",
|
|
174
|
+
"name": "px-dropdown",
|
|
175
|
+
"declaration": {
|
|
176
|
+
"name": "Dropdown",
|
|
177
|
+
"module": "src/Dropdown.ts"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"kind": "javascript-module",
|
|
184
|
+
"path": "src/anchorPolyfill.ts",
|
|
185
|
+
"declarations": [
|
|
186
|
+
{
|
|
187
|
+
"kind": "function",
|
|
188
|
+
"name": "anchorPolyfill",
|
|
189
|
+
"parameters": [
|
|
190
|
+
{
|
|
191
|
+
"name": "$trigger",
|
|
192
|
+
"type": {
|
|
193
|
+
"text": "HTMLElement"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"name": "$popoverElement",
|
|
198
|
+
"type": {
|
|
199
|
+
"text": "HTMLElement"
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "anchorAlignment",
|
|
204
|
+
"default": "'bottom-left'",
|
|
205
|
+
"type": {
|
|
206
|
+
"text": "AnchorAlignment"
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "computedStyle",
|
|
211
|
+
"type": {
|
|
212
|
+
"text": "CSSStyleDeclaration"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "usePolyfill",
|
|
217
|
+
"default": "false"
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
"exports": [
|
|
223
|
+
{
|
|
224
|
+
"kind": "js",
|
|
225
|
+
"name": "anchorPolyfill",
|
|
226
|
+
"declaration": {
|
|
227
|
+
"name": "anchorPolyfill",
|
|
228
|
+
"module": "src/anchorPolyfill.ts"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"kind": "javascript-module",
|
|
235
|
+
"path": "src/common.ts",
|
|
236
|
+
"declarations": [
|
|
237
|
+
{
|
|
238
|
+
"kind": "variable",
|
|
239
|
+
"name": "anchorAlignmentValues",
|
|
240
|
+
"type": {
|
|
241
|
+
"text": "[\n 'top-left',\n 'top-right',\n 'bottom-left',\n 'bottom-right',\n]"
|
|
242
|
+
},
|
|
243
|
+
"default": "[ 'top-left', 'top-right', 'bottom-left', 'bottom-right', ]"
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"exports": [
|
|
247
|
+
{
|
|
248
|
+
"kind": "js",
|
|
249
|
+
"name": "anchorAlignmentValues",
|
|
250
|
+
"declaration": {
|
|
251
|
+
"name": "anchorAlignmentValues",
|
|
252
|
+
"module": "src/common.ts"
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"kind": "javascript-module",
|
|
259
|
+
"path": "src/dropdown.css",
|
|
260
|
+
"declarations": [],
|
|
261
|
+
"exports": []
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"kind": "javascript-module",
|
|
265
|
+
"path": "src/index.ts",
|
|
266
|
+
"declarations": [],
|
|
267
|
+
"exports": [
|
|
268
|
+
{
|
|
269
|
+
"kind": "js",
|
|
270
|
+
"name": "*",
|
|
271
|
+
"declaration": {
|
|
272
|
+
"name": "*",
|
|
273
|
+
"module": "src/Dropdown.ts"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,61 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"top-left",
|
|
9
|
-
"top-right",
|
|
10
|
-
"bottom-left",
|
|
11
|
-
"bottom-right"
|
|
1
|
+
import { WithExtraAttributes as e, log as t, propertyToAttributeSetter as n } from "@proximus/lavender-common";
|
|
2
|
+
//#region src/dropdown.css?inline
|
|
3
|
+
var r = ":host{position:relative}::slotted([slot=popover]){border-radius:var(--px-radius-main,8px);background:var(--px-color-background-container-light-default,#fff);padding:var(--px-padding-xs-mobile) 0;width:auto;max-height:var(--px-popover-max-height);border:0;margin: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]){top:auto}:host([anchoralignment=top-right]) ::slotted([slot=popover]){top:auto}:host([anchoralignment=bottom-right]) ::slotted([slot=popover]){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]){padding-block:var(--px-padding-s-desktop);width:auto;right:auto}}", i = [
|
|
4
|
+
"top-left",
|
|
5
|
+
"top-right",
|
|
6
|
+
"bottom-left",
|
|
7
|
+
"bottom-right"
|
|
12
8
|
];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 a(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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 o = new CSSStyleSheet();
|
|
22
|
+
o.replaceSync(r);
|
|
23
|
+
var s = "bottom-left", c = 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([
|
|
29
|
+
::slotted([popover]) {
|
|
59
30
|
position-anchor: ${this.anchorName};
|
|
60
31
|
top: anchor(${this.anchorName} bottom);
|
|
61
32
|
left: anchor(${this.anchorName} left);
|
|
@@ -82,96 +53,113 @@ class T extends C {
|
|
|
82
53
|
right: anchor(${this.anchorName} right);
|
|
83
54
|
}
|
|
84
55
|
}`;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
56
|
+
}
|
|
57
|
+
static get observedAttributes() {
|
|
58
|
+
return [
|
|
59
|
+
...super.observedAttributes,
|
|
60
|
+
"id",
|
|
61
|
+
"anchoralignment",
|
|
62
|
+
"use-polyfill",
|
|
63
|
+
"manual-toggle",
|
|
64
|
+
"popover-height"
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
constructor() {
|
|
68
|
+
super(o), this.template = () => `
|
|
69
|
+
<style>${this.css}</style>
|
|
70
|
+
<slot name="trigger"></slot>
|
|
71
|
+
<slot name="popover"></slot>`, this.isAboutToClose = !1, this.triggerPopoverDisplay = () => {
|
|
72
|
+
this.isAboutToClose || (this.$popoverElement.togglePopover({ source: this.$trigger }), this.manualToggle || (this.$trigger.ariaExpanded = "true"));
|
|
73
|
+
}, this.showPopover = () => {
|
|
74
|
+
this.isAboutToClose || this.$popoverElement.showPopover();
|
|
75
|
+
}, this.hidePopover = () => {
|
|
76
|
+
this.$popoverElement.hidePopover();
|
|
77
|
+
}, this.#t = () => {
|
|
78
|
+
this.$popoverElement.matches(":popover-open") && (this.isAboutToClose = !0, this.manualToggle || (this.$trigger.ariaExpanded = "false"));
|
|
79
|
+
}, this.#n = () => {
|
|
80
|
+
this.$popoverElement.matches(":popover-open") || setTimeout(() => {
|
|
81
|
+
this.isAboutToClose = !1;
|
|
82
|
+
});
|
|
83
|
+
}, this.shadowRoot.innerHTML = this.template();
|
|
84
|
+
}
|
|
85
|
+
connectedCallback() {
|
|
86
|
+
this.getAttribute("id") || this.setAttribute("id", `px-dropdown-${Math.random().toString(36).substring(2, 15)}`), this.getAttribute("anchoralignment") || this.setAttribute("anchoralignment", s), a(this.$trigger, this.$popoverElement, this.anchorAlignment, getComputedStyle(this), this.usePolyfill);
|
|
87
|
+
}
|
|
88
|
+
#e() {
|
|
89
|
+
this.isAboutToClose = !1, this.manualToggle || this.$trigger.removeEventListener("click", this.triggerPopoverDisplay), this.$popoverElement.removeEventListener("beforetoggle", this.#t), this.$popoverElement.removeEventListener("toggle", this.#n);
|
|
90
|
+
}
|
|
91
|
+
#t;
|
|
92
|
+
#n;
|
|
93
|
+
#r() {
|
|
94
|
+
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));
|
|
95
|
+
}
|
|
96
|
+
attributeChangedCallback(e, t, n) {
|
|
97
|
+
if (t !== n) switch (e) {
|
|
98
|
+
case "id":
|
|
99
|
+
this.initPopover();
|
|
100
|
+
break;
|
|
101
|
+
case "use-polyfill":
|
|
102
|
+
a(this.$trigger, this.$popoverElement, this.anchorAlignment, getComputedStyle(this), this.usePolyfill);
|
|
103
|
+
break;
|
|
104
|
+
case "manual-toggle":
|
|
105
|
+
n != null && this.$trigger?.removeAttribute("aria-expanded");
|
|
106
|
+
break;
|
|
107
|
+
case "popover-height":
|
|
108
|
+
this.updatePopoverHeight(n);
|
|
109
|
+
break;
|
|
110
|
+
default: super.attributeChangedCallback(e, t, n);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
updatePopoverHeight(e) {
|
|
114
|
+
e ? this.$popoverElement.style.setProperty("--px-popover-max-height", e) : this.$popoverElement.style.removeProperty("--px-popover-max-height");
|
|
115
|
+
}
|
|
116
|
+
initPopover() {
|
|
117
|
+
if (this.$trigger) {
|
|
118
|
+
this.$trigger.setAttribute("popovertarget", this.popoverId);
|
|
119
|
+
let e = this.getAttribute("id");
|
|
120
|
+
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();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
get popoverId() {
|
|
124
|
+
return `${this.getAttribute("id")}-popover`;
|
|
125
|
+
}
|
|
126
|
+
get anchorName() {
|
|
127
|
+
return `--${this.getAttribute("id")}-anchor`;
|
|
128
|
+
}
|
|
129
|
+
get $style() {
|
|
130
|
+
return this.shadowRoot.querySelector("style");
|
|
131
|
+
}
|
|
132
|
+
get $trigger() {
|
|
133
|
+
return this.querySelector("[slot=\"trigger\"]");
|
|
134
|
+
}
|
|
135
|
+
get $popoverElement() {
|
|
136
|
+
return this.querySelector("[slot=\"popover\"]");
|
|
137
|
+
}
|
|
138
|
+
get anchorAlignment() {
|
|
139
|
+
return this.getAttribute("anchoralignment") || s;
|
|
140
|
+
}
|
|
141
|
+
set anchorAlignment(e) {
|
|
142
|
+
i.includes(e) ? this.setAttribute("anchoralignment", e) : (t(`Invalid anchor alignment value: ${e}. Using default ${s}.`), this.setAttribute("anchoralignment", s));
|
|
143
|
+
}
|
|
144
|
+
get usePolyfill() {
|
|
145
|
+
return this.hasAttribute("use-polyfill");
|
|
146
|
+
}
|
|
147
|
+
set usePolyfill(e) {
|
|
148
|
+
e ? this.setAttribute("use-polyfill", "") : this.removeAttribute("use-polyfill");
|
|
149
|
+
}
|
|
150
|
+
get manualToggle() {
|
|
151
|
+
return this.hasAttribute("manual-toggle");
|
|
152
|
+
}
|
|
153
|
+
set manualToggle(e) {
|
|
154
|
+
e ? this.setAttribute("manual-toggle", "") : this.removeAttribute("manual-toggle");
|
|
155
|
+
}
|
|
156
|
+
get popoverHeight() {
|
|
157
|
+
return this.getAttribute("popover-height");
|
|
158
|
+
}
|
|
159
|
+
set popoverHeight(e) {
|
|
160
|
+
n(this, "popover-height", e);
|
|
161
|
+
}
|
|
177
162
|
};
|
|
163
|
+
customElements.get("px-dropdown") || customElements.define("px-dropdown", c);
|
|
164
|
+
//#endregion
|
|
165
|
+
export { c as Dropdown };
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
],
|
|
15
|
+
"references": []
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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.200",
|
|
5
|
+
"description-markup": "markdown",
|
|
6
|
+
"contributions": {
|
|
7
|
+
"html": {
|
|
8
|
+
"elements": [
|
|
9
|
+
{
|
|
10
|
+
"name": "px-dropdown",
|
|
11
|
+
"description": "\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
|
+
],
|
|
20
|
+
"events": [],
|
|
21
|
+
"js": {
|
|
22
|
+
"properties": [
|
|
23
|
+
{ "name": "triggerPopoverDisplay" },
|
|
24
|
+
{ "name": "showPopover" },
|
|
25
|
+
{ "name": "hidePopover" },
|
|
26
|
+
{ "name": "$trigger" },
|
|
27
|
+
{ "name": "$popoverElement" },
|
|
28
|
+
{ "name": "anchorAlignment", "type": "AnchorAlignment" },
|
|
29
|
+
{ "name": "usePolyfill" },
|
|
30
|
+
{ "name": "manualToggle" },
|
|
31
|
+
{ "name": "popoverHeight" },
|
|
32
|
+
{ "name": "innerHTML" }
|
|
33
|
+
],
|
|
34
|
+
"events": []
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"css": {
|
|
40
|
+
"properties": [],
|
|
41
|
+
"pseudo-elements": []
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-dropdown",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.200",
|
|
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"
|