@cas-smartdesign/popover 4.1.2 → 4.2.1
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/docs/doc.css +1 -1
- package/dist/docs/doc.mjs +36 -39
- package/dist/popover-with-externals.js +3 -3
- package/dist/popover-with-externals.js.map +4 -4
- package/dist/popover.d.ts +2 -0
- package/dist/popover.mjs +92 -73
- package/dist/popover.mjs.map +1 -1
- package/npm-third-party-licenses.json +51 -46
- package/package.json +3 -3
package/dist/popover.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export default class Popover extends HTMLElement {
|
|
|
61
61
|
private set open(value);
|
|
62
62
|
private handleOpenChange;
|
|
63
63
|
private hideIfExternalTarget;
|
|
64
|
+
private handleTabKeyDown;
|
|
64
65
|
private handleTargetSelectorChange;
|
|
65
66
|
private addTargetEventListener;
|
|
66
67
|
private removeTargetEventListener;
|
|
@@ -73,4 +74,5 @@ export default class Popover extends HTMLElement {
|
|
|
73
74
|
private get content();
|
|
74
75
|
private addTargetClassForOpen;
|
|
75
76
|
private removeTargetClassForOpen;
|
|
77
|
+
private findNextFocusableAfter;
|
|
76
78
|
}
|
package/dist/popover.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createPopper as d } from "@popperjs/core";
|
|
2
|
-
const
|
|
2
|
+
const f = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBox="0 0 24 12">\r
|
|
3
3
|
<path d="M0 0l11.96 12L24 0z" fill="#999" class="arrow-border"/>\r
|
|
4
4
|
<path d="M12 11L1 0h22z" fill="#f2f2f2" class="arrow-background"/>\r
|
|
5
5
|
</svg>\r
|
|
6
|
-
`,
|
|
6
|
+
`, g = navigator.userAgent.indexOf("Trident") !== -1, p = 1, c = "sd-popover-open", l = class l extends HTMLElement {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments), this._open = !1, this._firstUpdated = !1, this.toggle = () => {
|
|
9
9
|
this.open = !this.open;
|
|
@@ -11,58 +11,67 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
11
11
|
this.open = !0;
|
|
12
12
|
}, this.hide = () => {
|
|
13
13
|
this.open = !1;
|
|
14
|
-
}, this.hideIfExternalTarget = (
|
|
15
|
-
const
|
|
16
|
-
(!(
|
|
14
|
+
}, this.hideIfExternalTarget = (e) => {
|
|
15
|
+
const t = e.target;
|
|
16
|
+
(!(t instanceof HTMLElement) || !this._container.contains(t) && !this.targetElement.contains(t)) && this.hide();
|
|
17
|
+
}, this.handleTabKeyDown = (e) => {
|
|
18
|
+
if (e.key !== "Tab")
|
|
19
|
+
return;
|
|
20
|
+
const t = e.shiftKey;
|
|
21
|
+
let r = null;
|
|
22
|
+
const s = e.target, i = this.content;
|
|
23
|
+
if (s instanceof HTMLElement && i && (r = this.findNextFocusableAfter(s, i, !t)), r)
|
|
24
|
+
return;
|
|
25
|
+
e.preventDefault(), this.open = !1, this.findNextFocusableAfter(this.targetElement, null, !t)?.focus();
|
|
17
26
|
};
|
|
18
27
|
}
|
|
19
28
|
get triggerType() {
|
|
20
29
|
return this.getAttribute("trigger-type");
|
|
21
30
|
}
|
|
22
|
-
set triggerType(
|
|
23
|
-
|
|
31
|
+
set triggerType(e) {
|
|
32
|
+
e ? this.setAttribute("trigger-type", e) : this.removeAttribute("trigger-type");
|
|
24
33
|
}
|
|
25
34
|
get placement() {
|
|
26
35
|
return this.getAttribute("placement");
|
|
27
36
|
}
|
|
28
|
-
set placement(
|
|
29
|
-
|
|
37
|
+
set placement(e) {
|
|
38
|
+
e ? this.setAttribute("placement", e) : this.removeAttribute("placement");
|
|
30
39
|
}
|
|
31
40
|
get targetElement() {
|
|
32
41
|
return this._targetElement;
|
|
33
42
|
}
|
|
34
|
-
set targetElement(
|
|
35
|
-
this.removeTargetEventListener(this.targetElement), this._targetElement && this._targetElement.getAttribute("aria-expanded") == "true" && this._targetElement.setAttribute("aria-expanded", "false"), this._targetElement =
|
|
43
|
+
set targetElement(e) {
|
|
44
|
+
this.removeTargetEventListener(this.targetElement), this._targetElement && this._targetElement.getAttribute("aria-expanded") == "true" && this._targetElement.setAttribute("aria-expanded", "false"), this._targetElement = e, e && e.setAttribute("aria-expanded", "false"), this.addTargetEventListener(this.targetElement), this.updatePopper();
|
|
36
45
|
}
|
|
37
46
|
get targetSelector() {
|
|
38
47
|
return this.getAttribute("target-selector");
|
|
39
48
|
}
|
|
40
|
-
set targetSelector(
|
|
41
|
-
|
|
49
|
+
set targetSelector(e) {
|
|
50
|
+
e ? this.setAttribute("target-selector", e) : this.removeAttribute("target-selector");
|
|
42
51
|
}
|
|
43
52
|
get modal() {
|
|
44
53
|
return this.hasAttribute("modal");
|
|
45
54
|
}
|
|
46
|
-
set modal(
|
|
47
|
-
|
|
55
|
+
set modal(e) {
|
|
56
|
+
e ? this.setAttribute("modal", "") : this.removeAttribute("modal");
|
|
48
57
|
}
|
|
49
58
|
get popoverFor() {
|
|
50
59
|
return this.getAttribute("popover-for");
|
|
51
60
|
}
|
|
52
|
-
set popoverFor(
|
|
53
|
-
|
|
61
|
+
set popoverFor(e) {
|
|
62
|
+
e ? this.setAttribute("popover-for", e) : this.removeAttribute("popover-for");
|
|
54
63
|
}
|
|
55
64
|
get flipPriority() {
|
|
56
65
|
return this._flipPriority;
|
|
57
66
|
}
|
|
58
|
-
set flipPriority(
|
|
59
|
-
|
|
67
|
+
set flipPriority(e) {
|
|
68
|
+
e && e.length > 0 ? this._flipPriority = e : this._flipPriority = null, this.reConfigurePopper();
|
|
60
69
|
}
|
|
61
70
|
get offset() {
|
|
62
71
|
return this.getAttribute("offset") ? parseInt(this.getAttribute("offset")) : 0;
|
|
63
72
|
}
|
|
64
|
-
set offset(
|
|
65
|
-
|
|
73
|
+
set offset(e) {
|
|
74
|
+
e ? this.setAttribute("offset", e.toString()) : this.removeAttribute("offset"), this.reConfigurePopper();
|
|
66
75
|
}
|
|
67
76
|
reConfigurePopper() {
|
|
68
77
|
this._popper && this.configurePopper();
|
|
@@ -70,14 +79,14 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
70
79
|
get noArrow() {
|
|
71
80
|
return this.hasAttribute("no-arrow");
|
|
72
81
|
}
|
|
73
|
-
set noArrow(
|
|
74
|
-
|
|
82
|
+
set noArrow(e) {
|
|
83
|
+
e ? this.setAttribute("no-arrow", "") : this.removeAttribute("no-arrow");
|
|
75
84
|
}
|
|
76
85
|
static get observedAttributes() {
|
|
77
86
|
return ["placement", "target-selector", "trigger-type"];
|
|
78
87
|
}
|
|
79
|
-
attributeChangedCallback(
|
|
80
|
-
switch (
|
|
88
|
+
attributeChangedCallback(e, t) {
|
|
89
|
+
switch (e) {
|
|
81
90
|
case "placement": {
|
|
82
91
|
this.updatePopper();
|
|
83
92
|
break;
|
|
@@ -87,7 +96,7 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
87
96
|
break;
|
|
88
97
|
}
|
|
89
98
|
case "target-selector": {
|
|
90
|
-
this.handleTargetSelectorChange(
|
|
99
|
+
this.handleTargetSelectorChange(t);
|
|
91
100
|
break;
|
|
92
101
|
}
|
|
93
102
|
}
|
|
@@ -95,7 +104,7 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
95
104
|
connectedCallback() {
|
|
96
105
|
this._firstUpdated || (this.firstUpdated(), this._firstUpdated = !0), this.targetElement ? this.addTargetEventListener(this.targetElement) : this.targetSelector && requestAnimationFrame(() => {
|
|
97
106
|
this.isConnected && this.handleTargetSelectorChange(null);
|
|
98
|
-
}), this._arrow = document.createElement("div"), this._arrow.classList.add("popover-arrow"), this._arrow.setAttribute("data-popper-arrow", ""), this._arrow.style.display = "flex", this._arrow.innerHTML =
|
|
107
|
+
}), this._arrow = document.createElement("div"), this._arrow.classList.add("popover-arrow"), this._arrow.setAttribute("data-popper-arrow", ""), this._arrow.style.display = "flex", this._arrow.innerHTML = f;
|
|
99
108
|
}
|
|
100
109
|
disconnectedCallback() {
|
|
101
110
|
this.targetElement && (this.removeTargetEventListener(this.targetElement), this.removeTargetClassForOpen(this.targetElement)), this._resizeObserver && (this._resizeObserver.disconnect(), this._resizeObserver = null);
|
|
@@ -106,8 +115,8 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
106
115
|
get open() {
|
|
107
116
|
return this._open;
|
|
108
117
|
}
|
|
109
|
-
set open(
|
|
110
|
-
|
|
118
|
+
set open(e) {
|
|
119
|
+
e !== this._open && (this._open = e, this.handleOpenChange());
|
|
111
120
|
}
|
|
112
121
|
handleOpenChange() {
|
|
113
122
|
this.open ? (this._popper || this.configurePopper(), this._container.innerHTML = "", this.popoverFor && this._container.setAttribute("popover-for", this.popoverFor), this.content && (this._container.prepend(this.content), Object.assign(this.content.style, {
|
|
@@ -115,56 +124,56 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
115
124
|
display: "block",
|
|
116
125
|
zIndex: 1
|
|
117
126
|
}), window.requestAnimationFrame(() => {
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
})), this.ensureArrowIsAdded(), this.ownerDocument.body.appendChild(this._container), this.updatePopper(), this.setAttribute("open", ""), this.modal && (window.addEventListener("click", this.hideIfExternalTarget, { capture: !0 }), window.addEventListener("focus", this.hideIfExternalTarget, { capture: !0 })), this.targetElement && (this.addTargetClassForOpen(this.targetElement), this.targetElement.setAttribute("aria-expanded", "true")), this.dispatchEvent(new CustomEvent("open"))) : (this.ownerDocument.body.removeChild(this._container), this.removeAttribute("open"), window.removeEventListener("click", this.hideIfExternalTarget, { capture: !0 }), window.removeEventListener("focus", this.hideIfExternalTarget, { capture: !0 }), this.targetElement && (this.removeTargetClassForOpen(this.targetElement), this.targetElement.setAttribute("aria-expanded", "false")), this.dispatchEvent(new CustomEvent("close")));
|
|
127
|
+
let e = getComputedStyle(this.content).backgroundColor;
|
|
128
|
+
e == "rgba(0, 0, 0, 0)" && (this.content.style.background = e = "#f2f2f2"), this._arrow.querySelector(".arrow-background").style.fill = e;
|
|
129
|
+
})), this.ensureArrowIsAdded(), this.ownerDocument.body.appendChild(this._container), this.updatePopper(), this.setAttribute("open", ""), this.modal && (window.addEventListener("click", this.hideIfExternalTarget, { capture: !0 }), window.addEventListener("focus", this.hideIfExternalTarget, { capture: !0 })), this.targetElement && (this.addTargetClassForOpen(this.targetElement), this.targetElement.setAttribute("aria-expanded", "true")), this.dispatchEvent(new CustomEvent("open")), this._container.addEventListener("keydown", this.handleTabKeyDown)) : (this.ownerDocument.body.removeChild(this._container), this.removeAttribute("open"), window.removeEventListener("click", this.hideIfExternalTarget, { capture: !0 }), window.removeEventListener("focus", this.hideIfExternalTarget, { capture: !0 }), this.targetElement && (this.removeTargetClassForOpen(this.targetElement), this.targetElement.setAttribute("aria-expanded", "false")), this.dispatchEvent(new CustomEvent("close")), this._container.removeEventListener("keydown", this.handleTabKeyDown));
|
|
121
130
|
}
|
|
122
|
-
handleTargetSelectorChange(
|
|
123
|
-
const
|
|
124
|
-
|
|
131
|
+
handleTargetSelectorChange(e) {
|
|
132
|
+
const t = document.querySelector(e);
|
|
133
|
+
t && (this.removeTargetEventListener(t), this.removeTargetClassForOpen(t)), this.targetSelector && (this.targetElement = document.querySelector(this.targetSelector), this.addTargetEventListener(this.targetElement));
|
|
125
134
|
}
|
|
126
|
-
addTargetEventListener(
|
|
127
|
-
if (
|
|
135
|
+
addTargetEventListener(e) {
|
|
136
|
+
if (e)
|
|
128
137
|
switch (this.triggerType) {
|
|
129
138
|
case "hover": {
|
|
130
|
-
|
|
139
|
+
e.addEventListener("mouseenter", this.show), e.addEventListener("mouseleave", this.hide);
|
|
131
140
|
break;
|
|
132
141
|
}
|
|
133
142
|
case "click": {
|
|
134
|
-
|
|
143
|
+
e.addEventListener("click", this.toggle);
|
|
135
144
|
break;
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
|
-
removeTargetEventListener(
|
|
140
|
-
if (
|
|
148
|
+
removeTargetEventListener(e) {
|
|
149
|
+
if (e)
|
|
141
150
|
switch (this.triggerType) {
|
|
142
151
|
case "hover": {
|
|
143
|
-
|
|
152
|
+
e.removeEventListener("mouseenter", this.show), e.removeEventListener("mouseleave", this.hide);
|
|
144
153
|
break;
|
|
145
154
|
}
|
|
146
155
|
case "click": {
|
|
147
|
-
|
|
156
|
+
e.removeEventListener("click", this.toggle);
|
|
148
157
|
break;
|
|
149
158
|
}
|
|
150
159
|
}
|
|
151
160
|
}
|
|
152
161
|
configurePopper() {
|
|
153
162
|
this.createContentContainer(), this.ensureArrowIsAdded();
|
|
154
|
-
const
|
|
155
|
-
placement:
|
|
163
|
+
const e = this, t = {
|
|
164
|
+
placement: e.placement,
|
|
156
165
|
strategy: "absolute",
|
|
157
166
|
modifiers: [
|
|
158
167
|
{
|
|
159
168
|
name: "computeStyles",
|
|
160
169
|
options: {
|
|
161
|
-
gpuAcceleration: !
|
|
170
|
+
gpuAcceleration: !g
|
|
162
171
|
}
|
|
163
172
|
},
|
|
164
173
|
{
|
|
165
174
|
name: "flip",
|
|
166
175
|
options: {
|
|
167
|
-
fallbackPlacements:
|
|
176
|
+
fallbackPlacements: e._flipPriority
|
|
168
177
|
}
|
|
169
178
|
},
|
|
170
179
|
{
|
|
@@ -172,7 +181,7 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
172
181
|
options: {
|
|
173
182
|
offset: () => [
|
|
174
183
|
0,
|
|
175
|
-
|
|
184
|
+
e.noArrow ? 0 + e.offset : this._arrow.clientHeight + e.offset
|
|
176
185
|
]
|
|
177
186
|
}
|
|
178
187
|
},
|
|
@@ -188,7 +197,7 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
188
197
|
enabled: !0,
|
|
189
198
|
phase: "beforeWrite",
|
|
190
199
|
fn({ state: r }) {
|
|
191
|
-
Object.assign(
|
|
200
|
+
Object.assign(e._arrow.style, {
|
|
192
201
|
top: r.styles.arrow.top || "",
|
|
193
202
|
left: r.styles.arrow.left || "",
|
|
194
203
|
bottom: r.styles.arrow.bottom || "",
|
|
@@ -201,12 +210,12 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
201
210
|
enabled: !0,
|
|
202
211
|
phase: "afterWrite",
|
|
203
212
|
fn({ state: r }) {
|
|
204
|
-
|
|
213
|
+
e.updateArrow(r.placement);
|
|
205
214
|
}
|
|
206
215
|
}
|
|
207
216
|
]
|
|
208
217
|
};
|
|
209
|
-
this._popper = d(this.targetElement, this._container,
|
|
218
|
+
this._popper = d(this.targetElement, this._container, t);
|
|
210
219
|
}
|
|
211
220
|
createContentContainer() {
|
|
212
221
|
this._container = document.createElement("div"), this._container.classList.add("popover-container"), this._container.tabIndex = 0, this._resizeObserver && this._resizeObserver.disconnect(), this._resizeObserver = new ResizeObserver(() => {
|
|
@@ -226,56 +235,66 @@ const g = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="12" viewBo
|
|
|
226
235
|
updatePopper() {
|
|
227
236
|
this._popper && (this._popper.state.elements.reference = this.targetElement, this._popper.state.options.placement = this.placement, this.open && this._popper.update());
|
|
228
237
|
}
|
|
229
|
-
updateArrow(
|
|
238
|
+
updateArrow(e) {
|
|
230
239
|
if (this._arrow) {
|
|
231
|
-
const
|
|
232
|
-
if (this._arrow.setAttribute("variant",
|
|
233
|
-
const r = this._arrow.querySelector("svg"),
|
|
234
|
-
switch (
|
|
240
|
+
const t = this.getArrowVariant(e);
|
|
241
|
+
if (this._arrow.setAttribute("variant", t), this._content) {
|
|
242
|
+
const r = this._arrow.querySelector("svg"), s = this._arrow.clientWidth, i = this._arrow.clientHeight, a = `-${i - p}px`, h = (s - i) / 2, n = `-${i + h - p}px`;
|
|
243
|
+
switch (t) {
|
|
235
244
|
case "bottom": {
|
|
236
|
-
this._arrow.style.top =
|
|
245
|
+
this._arrow.style.top = a, r.style.transform = "rotate(180deg)";
|
|
237
246
|
break;
|
|
238
247
|
}
|
|
239
248
|
case "top": {
|
|
240
|
-
this._arrow.style.bottom =
|
|
249
|
+
this._arrow.style.bottom = a, r.style.transform = "rotate(0deg)";
|
|
241
250
|
break;
|
|
242
251
|
}
|
|
243
252
|
case "left": {
|
|
244
|
-
this._arrow.style.right =
|
|
253
|
+
this._arrow.style.right = n, r.style.transform = "rotate(270deg)";
|
|
245
254
|
break;
|
|
246
255
|
}
|
|
247
256
|
case "right": {
|
|
248
|
-
this._arrow.style.left =
|
|
257
|
+
this._arrow.style.left = n, r.style.transform = "rotate(90deg)";
|
|
249
258
|
break;
|
|
250
259
|
}
|
|
251
260
|
}
|
|
252
261
|
}
|
|
253
262
|
}
|
|
254
263
|
}
|
|
255
|
-
getArrowVariant(
|
|
256
|
-
if (
|
|
264
|
+
getArrowVariant(e) {
|
|
265
|
+
if (e.indexOf("bottom") !== -1)
|
|
257
266
|
return "bottom";
|
|
258
|
-
if (
|
|
267
|
+
if (e.indexOf("top") !== -1)
|
|
259
268
|
return "top";
|
|
260
|
-
if (
|
|
269
|
+
if (e.indexOf("left") !== -1)
|
|
261
270
|
return "left";
|
|
262
|
-
if (
|
|
271
|
+
if (e.indexOf("right") !== -1)
|
|
263
272
|
return "right";
|
|
264
273
|
}
|
|
265
274
|
get content() {
|
|
266
275
|
return this._content || (this._content = this.firstElementChild, this._content.setAttribute("data-popper-content", "")), this._content;
|
|
267
276
|
}
|
|
268
|
-
addTargetClassForOpen(
|
|
269
|
-
|
|
277
|
+
addTargetClassForOpen(e) {
|
|
278
|
+
e && e.classList.add(c);
|
|
270
279
|
}
|
|
271
|
-
removeTargetClassForOpen(
|
|
272
|
-
|
|
280
|
+
removeTargetClassForOpen(e) {
|
|
281
|
+
e && e.classList.remove(c);
|
|
282
|
+
}
|
|
283
|
+
findNextFocusableAfter(e, t, r) {
|
|
284
|
+
if (!e) return null;
|
|
285
|
+
const s = t ?? document.body, i = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
|
|
286
|
+
acceptNode(h) {
|
|
287
|
+
const n = h;
|
|
288
|
+
return n.tabIndex >= 0 && !n.hidden && n.offsetParent !== null ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
return i.currentNode = e, r ? i.nextNode() : i.previousNode();
|
|
273
292
|
}
|
|
274
293
|
};
|
|
275
|
-
|
|
276
|
-
let
|
|
277
|
-
customElements.get(
|
|
294
|
+
l.ID = "sd-popover";
|
|
295
|
+
let o = l;
|
|
296
|
+
customElements.get(o.ID) || customElements.define(o.ID, o);
|
|
278
297
|
export {
|
|
279
|
-
|
|
298
|
+
o as default
|
|
280
299
|
};
|
|
281
300
|
//# sourceMappingURL=popover.mjs.map
|
package/dist/popover.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.mjs","sources":["../arrow.svg?raw","../popover.ts"],"sourcesContent":["export default \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"24\\\" height=\\\"12\\\" viewBox=\\\"0 0 24 12\\\">\\r\\n <path d=\\\"M0 0l11.96 12L24 0z\\\" fill=\\\"#999\\\" class=\\\"arrow-border\\\"/>\\r\\n <path d=\\\"M12 11L1 0h22z\\\" fill=\\\"#f2f2f2\\\" class=\\\"arrow-background\\\"/>\\r\\n</svg>\\r\\n\"","import { createPopper, Instance as Popper, Options, Placement } from \"@popperjs/core\";\nimport { default as arrowSvg } from \"./arrow.svg?raw\";\n\nconst isIE11 = navigator.userAgent.indexOf(\"Trident\") !== -1;\nconst arrowOverlapOffset = 1;\nconst targetClassOpen = \"sd-popover-open\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [Popover.ID]: Popover;\n }\n}\n\nexport type TriggerType = \"click\" | \"hover\" | \"manual\";\nexport type ArrowVariant = \"bottom\" | \"left\" | \"right\" | \"top\";\nexport type IOpenEvent = void;\nexport type ICloseEvent = void;\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n open: CustomEvent<IOpenEvent>;\n close: CustomEvent<ICloseEvent>;\n}\n\nexport default interface Popover {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport default class Popover extends HTMLElement {\n public static readonly ID = \"sd-popover\";\n private _open = false;\n private _popper: Popper;\n private _targetElement: HTMLElement;\n private _container: HTMLElement;\n private _arrow: HTMLElement;\n private _content: HTMLElement;\n private _firstUpdated = false;\n private _flipPriority: Placement[];\n private _resizeObserver: ResizeObserver;\n\n public get triggerType(): TriggerType {\n return this.getAttribute(\"trigger-type\") as TriggerType;\n }\n\n public set triggerType(type: TriggerType) {\n if (type) {\n this.setAttribute(\"trigger-type\", type);\n } else {\n this.removeAttribute(\"trigger-type\");\n }\n }\n\n public get placement(): Placement {\n return this.getAttribute(\"placement\") as Placement;\n }\n\n public set placement(placement: Placement) {\n if (placement) {\n this.setAttribute(\"placement\", placement);\n } else {\n this.removeAttribute(\"placement\");\n }\n }\n\n public get targetElement(): HTMLElement {\n return this._targetElement;\n }\n\n public set targetElement(element: HTMLElement) {\n this.removeTargetEventListener(this.targetElement);\n if (this._targetElement && \"true\" == this._targetElement.getAttribute(\"aria-expanded\")) {\n this._targetElement.setAttribute(\"aria-expanded\", \"false\");\n }\n this._targetElement = element;\n if (element) {\n element.setAttribute(\"aria-expanded\", \"false\");\n }\n this.addTargetEventListener(this.targetElement);\n this.updatePopper();\n }\n\n public get targetSelector(): string {\n return this.getAttribute(\"target-selector\");\n }\n\n public set targetSelector(selector: string) {\n if (selector) {\n this.setAttribute(\"target-selector\", selector);\n } else {\n this.removeAttribute(\"target-selector\");\n }\n }\n\n public get modal(): boolean {\n return this.hasAttribute(\"modal\");\n }\n\n public set modal(modal: boolean) {\n if (modal) {\n this.setAttribute(\"modal\", \"\");\n } else {\n this.removeAttribute(\"modal\");\n }\n }\n\n public get popoverFor(): string {\n return this.getAttribute(\"popover-for\");\n }\n\n public set popoverFor(popoverFor: string) {\n if (popoverFor) {\n this.setAttribute(\"popover-for\", popoverFor);\n } else {\n this.removeAttribute(\"popover-for\");\n }\n }\n\n public get flipPriority(): Placement[] {\n return this._flipPriority;\n }\n\n public set flipPriority(priority: Placement[]) {\n if (priority && priority.length > 0) {\n this._flipPriority = priority;\n } else {\n this._flipPriority = null;\n }\n this.reConfigurePopper();\n }\n\n public get offset(): number {\n return this.getAttribute(\"offset\") ? parseInt(this.getAttribute(\"offset\")) : 0;\n }\n\n public set offset(offset: number) {\n if (offset) {\n this.setAttribute(\"offset\", offset.toString());\n } else {\n this.removeAttribute(\"offset\");\n }\n this.reConfigurePopper();\n }\n\n private reConfigurePopper() {\n if (this._popper) {\n this.configurePopper();\n }\n }\n\n public get noArrow(): boolean {\n return this.hasAttribute(\"no-arrow\");\n }\n\n public set noArrow(noArrow: boolean) {\n if (noArrow) {\n this.setAttribute(\"no-arrow\", \"\");\n } else {\n this.removeAttribute(\"no-arrow\");\n }\n }\n\n static get observedAttributes(): string[] {\n return [\"placement\", \"target-selector\", \"trigger-type\"];\n }\n\n public attributeChangedCallback(name: string, oldValue: string): void {\n switch (name) {\n case \"placement\": {\n this.updatePopper();\n break;\n }\n case \"trigger-type\": {\n this.removeTargetEventListener(this.targetElement);\n this.addTargetEventListener(this.targetElement);\n break;\n }\n case \"target-selector\": {\n this.handleTargetSelectorChange(oldValue);\n break;\n }\n }\n }\n\n public connectedCallback(): void {\n if (!this._firstUpdated) {\n this.firstUpdated();\n this._firstUpdated = true;\n }\n if (this.targetElement) {\n this.addTargetEventListener(this.targetElement);\n } else if (this.targetSelector) {\n // The browser is currently attaching html nodes to the dom tree, the target may not be present in it yet.\n requestAnimationFrame(() => {\n if (this.isConnected) {\n this.handleTargetSelectorChange(null);\n }\n });\n }\n\n this._arrow = document.createElement(\"div\");\n this._arrow.classList.add(\"popover-arrow\");\n this._arrow.setAttribute(\"data-popper-arrow\", \"\");\n this._arrow.style.display = \"flex\";\n this._arrow.innerHTML = arrowSvg;\n }\n\n public disconnectedCallback(): void {\n if (this.targetElement) {\n this.removeTargetEventListener(this.targetElement);\n this.removeTargetClassForOpen(this.targetElement);\n }\n if (this._resizeObserver) {\n this._resizeObserver.disconnect();\n this._resizeObserver = null;\n }\n }\n\n public toggle = (): void => {\n this.open = !this.open;\n };\n\n public show = (): void => {\n this.open = true;\n };\n\n public hide = (): void => {\n this.open = false;\n };\n\n private firstUpdated(): void {\n this.style.display = \"none\";\n this.triggerType = this.triggerType || \"click\";\n this.placement = this.placement || \"auto\";\n }\n\n private get open(): boolean {\n return this._open;\n }\n\n private set open(open: boolean) {\n if (open !== this._open) {\n this._open = open;\n this.handleOpenChange();\n }\n }\n\n private handleOpenChange(): void {\n if (this.open) {\n if (!this._popper) {\n this.configurePopper();\n }\n\n this._container.innerHTML = \"\";\n if (this.popoverFor) {\n this._container.setAttribute(\"popover-for\", this.popoverFor);\n }\n if (this.content) {\n this._container.prepend(this.content);\n Object.assign(this.content.style, {\n position: \"relative\",\n display: \"block\",\n zIndex: 1,\n });\n window.requestAnimationFrame(() => {\n let backgroundColor = getComputedStyle(this.content).backgroundColor;\n if (backgroundColor == \"rgba(0, 0, 0, 0)\") {\n this.content.style.background = backgroundColor = \"#f2f2f2\";\n }\n (this._arrow.querySelector(\".arrow-background\") as HTMLElement).style.fill = backgroundColor;\n });\n }\n this.ensureArrowIsAdded();\n this.ownerDocument.body.appendChild(this._container);\n this.updatePopper();\n this.setAttribute(\"open\", \"\");\n\n if (this.modal) {\n window.addEventListener(\"click\", this.hideIfExternalTarget, { capture: true });\n window.addEventListener(\"focus\", this.hideIfExternalTarget, { capture: true });\n }\n if (this.targetElement) {\n this.addTargetClassForOpen(this.targetElement);\n this.targetElement.setAttribute(\"aria-expanded\", \"true\");\n }\n this.dispatchEvent(new CustomEvent(\"open\"));\n } else {\n this.ownerDocument.body.removeChild(this._container);\n this.removeAttribute(\"open\");\n window.removeEventListener(\"click\", this.hideIfExternalTarget, { capture: true });\n window.removeEventListener(\"focus\", this.hideIfExternalTarget, { capture: true });\n\n if (this.targetElement) {\n this.removeTargetClassForOpen(this.targetElement);\n this.targetElement.setAttribute(\"aria-expanded\", \"false\");\n }\n this.dispatchEvent(new CustomEvent(\"close\"));\n }\n }\n\n private hideIfExternalTarget = (event: Event) => {\n const target = event.target;\n if (\n !(target instanceof HTMLElement) ||\n (!this._container.contains(target) && !this.targetElement.contains(target))\n ) {\n this.hide();\n }\n };\n\n private handleTargetSelectorChange(oldValue: string): void {\n const oldTarget = document.querySelector<HTMLElement>(oldValue);\n if (oldTarget) {\n this.removeTargetEventListener(oldTarget);\n this.removeTargetClassForOpen(oldTarget);\n }\n if (this.targetSelector) {\n this.targetElement = document.querySelector(this.targetSelector);\n this.addTargetEventListener(this.targetElement);\n }\n }\n\n private addTargetEventListener(target: HTMLElement): void {\n if (target) {\n switch (this.triggerType) {\n case \"hover\": {\n target.addEventListener(\"mouseenter\", this.show);\n target.addEventListener(\"mouseleave\", this.hide);\n break;\n }\n case \"click\": {\n target.addEventListener(\"click\", this.toggle);\n break;\n }\n }\n }\n }\n\n private removeTargetEventListener(target: HTMLElement): void {\n if (target) {\n switch (this.triggerType) {\n case \"hover\": {\n target.removeEventListener(\"mouseenter\", this.show);\n target.removeEventListener(\"mouseleave\", this.hide);\n break;\n }\n case \"click\": {\n target.removeEventListener(\"click\", this.toggle);\n break;\n }\n }\n }\n }\n\n private configurePopper(): void {\n this.createContentContainer();\n // In popper.js 2 the arrow needs to be added before calling Popper#createPopper\n this.ensureArrowIsAdded();\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const popover = this;\n const options: Options = {\n placement: popover.placement as Placement,\n strategy: \"absolute\",\n modifiers: [\n {\n name: \"computeStyles\",\n options: {\n gpuAcceleration: !isIE11,\n },\n },\n {\n name: \"flip\",\n options: {\n fallbackPlacements: popover._flipPriority,\n },\n },\n {\n name: \"offset\",\n options: {\n offset: () => {\n return [\n 0,\n popover.noArrow ? 0 + popover.offset : this._arrow.clientHeight + popover.offset,\n ];\n },\n },\n },\n {\n name: \"arrow\",\n options: {\n padding: 6, // Avoid to reach the edges of the popper element with the arrow\n },\n },\n {\n name: \"resetArrowStyles\",\n enabled: true,\n phase: \"beforeWrite\",\n fn({ state }) {\n Object.assign(popover._arrow.style, {\n top: state.styles.arrow.top || \"\",\n left: state.styles.arrow.left || \"\",\n bottom: state.styles.arrow.bottom || \"\",\n right: state.styles.arrow.right || \"\",\n });\n },\n },\n {\n name: \"onUpdate\",\n enabled: true,\n phase: \"afterWrite\",\n fn({ state }) {\n popover.updateArrow(state.placement);\n },\n },\n ],\n };\n this._popper = createPopper(this.targetElement, this._container, options);\n }\n\n private createContentContainer(): void {\n this._container = document.createElement(\"div\");\n this._container.classList.add(\"popover-container\");\n this._container.tabIndex = 0;\n if (this._resizeObserver) {\n this._resizeObserver.disconnect();\n }\n this._resizeObserver = new ResizeObserver(() => {\n if (this._popper) {\n this._popper.update();\n }\n });\n this._resizeObserver.observe(this._container);\n Object.assign(this._container.style, {\n boxShadow: `0 4px 5px 0 rgba(0, 0, 0, 0.14),\n 0 1px 10px 0 rgba(0, 0, 0, 0.12),\n 0 2px 4px -1px rgba(0, 0, 0, 0.4)`,\n border: \"1px solid #999\",\n boxSizing: \"border-box\",\n zIndex: 20000,\n });\n }\n\n private ensureArrowIsAdded() {\n if (!this.noArrow && !this._container.contains(this._arrow)) {\n this._container.appendChild(this._arrow);\n }\n }\n\n public updatePopper(): void {\n if (this._popper) {\n this._popper.state.elements.reference = this.targetElement;\n this._popper.state.options.placement = this.placement;\n\n if (this.open) {\n this._popper.update();\n }\n }\n }\n\n private updateArrow(placement: Placement): void {\n if (this._arrow) {\n const arrowVariant = this.getArrowVariant(placement);\n this._arrow.setAttribute(\"variant\", arrowVariant);\n if (this._content) {\n const svg = this._arrow.querySelector(\"svg\");\n\n const arrowWidth = this._arrow.clientWidth;\n const arrowHeight = this._arrow.clientHeight;\n const verticalOffset = `-${arrowHeight - arrowOverlapOffset}px`;\n\n const horizontalTransformationOffset = (arrowWidth - arrowHeight) / 2;\n // Note that arrowHeight is used on purpose for the horizontalOffset\n // as this is the height of the unrotated wrapper div which defines the gap between the\n // reference element and the popover.\n const horizontalOffset = `-${arrowHeight + horizontalTransformationOffset - arrowOverlapOffset}px`;\n\n switch (arrowVariant) {\n case \"bottom\": {\n this._arrow.style.top = verticalOffset;\n svg.style.transform = \"rotate(180deg)\";\n break;\n }\n case \"top\": {\n this._arrow.style.bottom = verticalOffset;\n svg.style.transform = \"rotate(0deg)\";\n break;\n }\n case \"left\": {\n this._arrow.style.right = horizontalOffset;\n svg.style.transform = \"rotate(270deg)\";\n break;\n }\n case \"right\": {\n this._arrow.style.left = horizontalOffset;\n svg.style.transform = \"rotate(90deg)\";\n break;\n }\n }\n }\n }\n }\n\n private getArrowVariant(placement: Placement): ArrowVariant {\n if (placement.indexOf(\"bottom\") !== -1) {\n return \"bottom\";\n } else if (placement.indexOf(\"top\") !== -1) {\n return \"top\";\n } else if (placement.indexOf(\"left\") !== -1) {\n return \"left\";\n } else if (placement.indexOf(\"right\") !== -1) {\n return \"right\";\n }\n }\n\n private get content(): HTMLElement {\n if (!this._content) {\n this._content = this.firstElementChild as HTMLElement;\n this._content.setAttribute(\"data-popper-content\", \"\");\n }\n return this._content;\n }\n\n private addTargetClassForOpen(target: HTMLElement): void {\n if (target) {\n target.classList.add(targetClassOpen);\n }\n }\n\n private removeTargetClassForOpen(target: HTMLElement): void {\n if (target) {\n target.classList.remove(targetClassOpen);\n }\n }\n}\n\nif (!customElements.get(Popover.ID)) {\n customElements.define(Popover.ID, Popover);\n}\n"],"names":["arrowSvg","isIE11","arrowOverlapOffset","targetClassOpen","_Popover","event","target","type","placement","element","selector","modal","popoverFor","priority","offset","noArrow","name","oldValue","open","backgroundColor","oldTarget","popover","options","state","createPopper","arrowVariant","svg","arrowWidth","arrowHeight","verticalOffset","horizontalTransformationOffset","horizontalOffset","Popover"],"mappings":";AAAA,MAAeA,IAAA;AAAA;AAAA;AAAA;AAAA,GCGTC,IAAS,UAAU,UAAU,QAAQ,SAAS,MAAM,IACpDC,IAAqB,GACrBC,IAAkB,mBA0CHC,IAArB,MAAqBA,UAAgB,YAAY;AAAA,EAAjD,cAAA;AAAA,UAAA,GAAA,SAAA,GAEI,KAAQ,QAAQ,IAMhB,KAAQ,gBAAgB,IAqLxB,KAAO,SAAS,MAAY;AACnB,WAAA,OAAO,CAAC,KAAK;AAAA,IAAA,GAGtB,KAAO,OAAO,MAAY;AACtB,WAAK,OAAO;AAAA,IAAA,GAGhB,KAAO,OAAO,MAAY;AACtB,WAAK,OAAO;AAAA,IAAA,GAyER,KAAA,uBAAuB,CAACC,MAAiB;AAC7C,YAAMC,IAASD,EAAM;AACrB,OACI,EAAEC,aAAkB,gBACnB,CAAC,KAAK,WAAW,SAASA,CAAM,KAAK,CAAC,KAAK,cAAc,SAASA,CAAM,MAEzE,KAAK,KAAK;AAAA,IACd;AAAA,EACJ;AAAA,EA3QA,IAAW,cAA2B;AAC3B,WAAA,KAAK,aAAa,cAAc;AAAA,EAC3C;AAAA,EAEA,IAAW,YAAYC,GAAmB;AACtC,IAAIA,IACK,KAAA,aAAa,gBAAgBA,CAAI,IAEtC,KAAK,gBAAgB,cAAc;AAAA,EAE3C;AAAA,EAEA,IAAW,YAAuB;AACvB,WAAA,KAAK,aAAa,WAAW;AAAA,EACxC;AAAA,EAE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/2000/svg\\\" width=\\\"24\\\" height=\\\"12\\\" viewBox=\\\"0 0 24 12\\\">\\r\\n <path d=\\\"M0 0l11.96 12L24 0z\\\" fill=\\\"#999\\\" class=\\\"arrow-border\\\"/>\\r\\n <path d=\\\"M12 11L1 0h22z\\\" fill=\\\"#f2f2f2\\\" class=\\\"arrow-background\\\"/>\\r\\n</svg>\\r\\n\"","import { createPopper, Instance as Popper, Options, Placement } from \"@popperjs/core\";\nimport { default as arrowSvg } from \"./arrow.svg?raw\";\n\nconst isIE11 = navigator.userAgent.indexOf(\"Trident\") !== -1;\nconst arrowOverlapOffset = 1;\nconst targetClassOpen = \"sd-popover-open\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [Popover.ID]: Popover;\n }\n}\n\nexport type TriggerType = \"click\" | \"hover\" | \"manual\";\nexport type ArrowVariant = \"bottom\" | \"left\" | \"right\" | \"top\";\nexport type IOpenEvent = void;\nexport type ICloseEvent = void;\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n open: CustomEvent<IOpenEvent>;\n close: CustomEvent<ICloseEvent>;\n}\n\nexport default interface Popover {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport default class Popover extends HTMLElement {\n public static readonly ID = \"sd-popover\";\n private _open = false;\n private _popper: Popper;\n private _targetElement: HTMLElement;\n private _container: HTMLElement;\n private _arrow: HTMLElement;\n private _content: HTMLElement;\n private _firstUpdated = false;\n private _flipPriority: Placement[];\n private _resizeObserver: ResizeObserver;\n\n public get triggerType(): TriggerType {\n return this.getAttribute(\"trigger-type\") as TriggerType;\n }\n\n public set triggerType(type: TriggerType) {\n if (type) {\n this.setAttribute(\"trigger-type\", type);\n } else {\n this.removeAttribute(\"trigger-type\");\n }\n }\n\n public get placement(): Placement {\n return this.getAttribute(\"placement\") as Placement;\n }\n\n public set placement(placement: Placement) {\n if (placement) {\n this.setAttribute(\"placement\", placement);\n } else {\n this.removeAttribute(\"placement\");\n }\n }\n\n public get targetElement(): HTMLElement {\n return this._targetElement;\n }\n\n public set targetElement(element: HTMLElement) {\n this.removeTargetEventListener(this.targetElement);\n if (this._targetElement && \"true\" == this._targetElement.getAttribute(\"aria-expanded\")) {\n this._targetElement.setAttribute(\"aria-expanded\", \"false\");\n }\n this._targetElement = element;\n if (element) {\n element.setAttribute(\"aria-expanded\", \"false\");\n }\n this.addTargetEventListener(this.targetElement);\n this.updatePopper();\n }\n\n public get targetSelector(): string {\n return this.getAttribute(\"target-selector\");\n }\n\n public set targetSelector(selector: string) {\n if (selector) {\n this.setAttribute(\"target-selector\", selector);\n } else {\n this.removeAttribute(\"target-selector\");\n }\n }\n\n public get modal(): boolean {\n return this.hasAttribute(\"modal\");\n }\n\n public set modal(modal: boolean) {\n if (modal) {\n this.setAttribute(\"modal\", \"\");\n } else {\n this.removeAttribute(\"modal\");\n }\n }\n\n public get popoverFor(): string {\n return this.getAttribute(\"popover-for\");\n }\n\n public set popoverFor(popoverFor: string) {\n if (popoverFor) {\n this.setAttribute(\"popover-for\", popoverFor);\n } else {\n this.removeAttribute(\"popover-for\");\n }\n }\n\n public get flipPriority(): Placement[] {\n return this._flipPriority;\n }\n\n public set flipPriority(priority: Placement[]) {\n if (priority && priority.length > 0) {\n this._flipPriority = priority;\n } else {\n this._flipPriority = null;\n }\n this.reConfigurePopper();\n }\n\n public get offset(): number {\n return this.getAttribute(\"offset\") ? parseInt(this.getAttribute(\"offset\")) : 0;\n }\n\n public set offset(offset: number) {\n if (offset) {\n this.setAttribute(\"offset\", offset.toString());\n } else {\n this.removeAttribute(\"offset\");\n }\n this.reConfigurePopper();\n }\n\n private reConfigurePopper() {\n if (this._popper) {\n this.configurePopper();\n }\n }\n\n public get noArrow(): boolean {\n return this.hasAttribute(\"no-arrow\");\n }\n\n public set noArrow(noArrow: boolean) {\n if (noArrow) {\n this.setAttribute(\"no-arrow\", \"\");\n } else {\n this.removeAttribute(\"no-arrow\");\n }\n }\n\n static get observedAttributes(): string[] {\n return [\"placement\", \"target-selector\", \"trigger-type\"];\n }\n\n public attributeChangedCallback(name: string, oldValue: string): void {\n switch (name) {\n case \"placement\": {\n this.updatePopper();\n break;\n }\n case \"trigger-type\": {\n this.removeTargetEventListener(this.targetElement);\n this.addTargetEventListener(this.targetElement);\n break;\n }\n case \"target-selector\": {\n this.handleTargetSelectorChange(oldValue);\n break;\n }\n }\n }\n\n public connectedCallback(): void {\n if (!this._firstUpdated) {\n this.firstUpdated();\n this._firstUpdated = true;\n }\n if (this.targetElement) {\n this.addTargetEventListener(this.targetElement);\n } else if (this.targetSelector) {\n // The browser is currently attaching html nodes to the dom tree, the target may not be present in it yet.\n requestAnimationFrame(() => {\n if (this.isConnected) {\n this.handleTargetSelectorChange(null);\n }\n });\n }\n\n this._arrow = document.createElement(\"div\");\n this._arrow.classList.add(\"popover-arrow\");\n this._arrow.setAttribute(\"data-popper-arrow\", \"\");\n this._arrow.style.display = \"flex\";\n this._arrow.innerHTML = arrowSvg;\n }\n\n public disconnectedCallback(): void {\n if (this.targetElement) {\n this.removeTargetEventListener(this.targetElement);\n this.removeTargetClassForOpen(this.targetElement);\n }\n if (this._resizeObserver) {\n this._resizeObserver.disconnect();\n this._resizeObserver = null;\n }\n }\n\n public toggle = (): void => {\n this.open = !this.open;\n };\n\n public show = (): void => {\n this.open = true;\n };\n\n public hide = (): void => {\n this.open = false;\n };\n\n private firstUpdated(): void {\n this.style.display = \"none\";\n this.triggerType = this.triggerType || \"click\";\n this.placement = this.placement || \"auto\";\n }\n\n private get open(): boolean {\n return this._open;\n }\n\n private set open(open: boolean) {\n if (open !== this._open) {\n this._open = open;\n this.handleOpenChange();\n }\n }\n\n private handleOpenChange(): void {\n if (this.open) {\n if (!this._popper) {\n this.configurePopper();\n }\n\n this._container.innerHTML = \"\";\n if (this.popoverFor) {\n this._container.setAttribute(\"popover-for\", this.popoverFor);\n }\n if (this.content) {\n this._container.prepend(this.content);\n Object.assign(this.content.style, {\n position: \"relative\",\n display: \"block\",\n zIndex: 1,\n });\n window.requestAnimationFrame(() => {\n let backgroundColor = getComputedStyle(this.content).backgroundColor;\n if (backgroundColor == \"rgba(0, 0, 0, 0)\") {\n this.content.style.background = backgroundColor = \"#f2f2f2\";\n }\n (this._arrow.querySelector(\".arrow-background\") as HTMLElement).style.fill = backgroundColor;\n });\n }\n this.ensureArrowIsAdded();\n this.ownerDocument.body.appendChild(this._container);\n this.updatePopper();\n this.setAttribute(\"open\", \"\");\n\n if (this.modal) {\n window.addEventListener(\"click\", this.hideIfExternalTarget, { capture: true });\n window.addEventListener(\"focus\", this.hideIfExternalTarget, { capture: true });\n }\n if (this.targetElement) {\n this.addTargetClassForOpen(this.targetElement);\n this.targetElement.setAttribute(\"aria-expanded\", \"true\");\n }\n this.dispatchEvent(new CustomEvent(\"open\"));\n\n this._container.addEventListener(\"keydown\", this.handleTabKeyDown);\n } else {\n this.ownerDocument.body.removeChild(this._container);\n this.removeAttribute(\"open\");\n window.removeEventListener(\"click\", this.hideIfExternalTarget, { capture: true });\n window.removeEventListener(\"focus\", this.hideIfExternalTarget, { capture: true });\n\n if (this.targetElement) {\n this.removeTargetClassForOpen(this.targetElement);\n this.targetElement.setAttribute(\"aria-expanded\", \"false\");\n }\n this.dispatchEvent(new CustomEvent(\"close\"));\n\n this._container.removeEventListener(\"keydown\", this.handleTabKeyDown);\n }\n }\n\n private hideIfExternalTarget = (event: Event) => {\n const target = event.target;\n if (\n !(target instanceof HTMLElement) ||\n (!this._container.contains(target) && !this.targetElement.contains(target))\n ) {\n this.hide();\n }\n };\n\n private handleTabKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\") {\n return;\n }\n\n const shift = event.shiftKey;\n let nextInsidePopover: HTMLElement | null = null;\n\n const target = event.target as Element | null;\n const root = this.content;\n\n if (target instanceof HTMLElement && root) {\n nextInsidePopover = this.findNextFocusableAfter(target, root, !shift);\n }\n\n if (nextInsidePopover) {\n // Let browser handle tabbing inside popover\n return;\n }\n\n // No more focusable elements inside popover → close it\n event.preventDefault();\n this.open = false;\n\n const next = this.findNextFocusableAfter(this.targetElement, null, !shift);\n next?.focus();\n };\n\n private handleTargetSelectorChange(oldValue: string): void {\n const oldTarget = document.querySelector<HTMLElement>(oldValue);\n if (oldTarget) {\n this.removeTargetEventListener(oldTarget);\n this.removeTargetClassForOpen(oldTarget);\n }\n if (this.targetSelector) {\n this.targetElement = document.querySelector(this.targetSelector);\n this.addTargetEventListener(this.targetElement);\n }\n }\n\n private addTargetEventListener(target: HTMLElement): void {\n if (target) {\n switch (this.triggerType) {\n case \"hover\": {\n target.addEventListener(\"mouseenter\", this.show);\n target.addEventListener(\"mouseleave\", this.hide);\n break;\n }\n case \"click\": {\n target.addEventListener(\"click\", this.toggle);\n break;\n }\n }\n }\n }\n\n private removeTargetEventListener(target: HTMLElement): void {\n if (target) {\n switch (this.triggerType) {\n case \"hover\": {\n target.removeEventListener(\"mouseenter\", this.show);\n target.removeEventListener(\"mouseleave\", this.hide);\n break;\n }\n case \"click\": {\n target.removeEventListener(\"click\", this.toggle);\n break;\n }\n }\n }\n }\n\n private configurePopper(): void {\n this.createContentContainer();\n // In popper.js 2 the arrow needs to be added before calling Popper#createPopper\n this.ensureArrowIsAdded();\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const popover = this;\n const options: Options = {\n placement: popover.placement as Placement,\n strategy: \"absolute\",\n modifiers: [\n {\n name: \"computeStyles\",\n options: {\n gpuAcceleration: !isIE11,\n },\n },\n {\n name: \"flip\",\n options: {\n fallbackPlacements: popover._flipPriority,\n },\n },\n {\n name: \"offset\",\n options: {\n offset: () => {\n return [\n 0,\n popover.noArrow ? 0 + popover.offset : this._arrow.clientHeight + popover.offset,\n ];\n },\n },\n },\n {\n name: \"arrow\",\n options: {\n padding: 6, // Avoid to reach the edges of the popper element with the arrow\n },\n },\n {\n name: \"resetArrowStyles\",\n enabled: true,\n phase: \"beforeWrite\",\n fn({ state }) {\n Object.assign(popover._arrow.style, {\n top: state.styles.arrow.top || \"\",\n left: state.styles.arrow.left || \"\",\n bottom: state.styles.arrow.bottom || \"\",\n right: state.styles.arrow.right || \"\",\n });\n },\n },\n {\n name: \"onUpdate\",\n enabled: true,\n phase: \"afterWrite\",\n fn({ state }) {\n popover.updateArrow(state.placement);\n },\n },\n ],\n };\n this._popper = createPopper(this.targetElement, this._container, options);\n }\n\n private createContentContainer(): void {\n this._container = document.createElement(\"div\");\n this._container.classList.add(\"popover-container\");\n this._container.tabIndex = 0;\n if (this._resizeObserver) {\n this._resizeObserver.disconnect();\n }\n this._resizeObserver = new ResizeObserver(() => {\n if (this._popper) {\n this._popper.update();\n }\n });\n this._resizeObserver.observe(this._container);\n Object.assign(this._container.style, {\n boxShadow: `0 4px 5px 0 rgba(0, 0, 0, 0.14),\n 0 1px 10px 0 rgba(0, 0, 0, 0.12),\n 0 2px 4px -1px rgba(0, 0, 0, 0.4)`,\n border: \"1px solid #999\",\n boxSizing: \"border-box\",\n zIndex: 20000,\n });\n }\n\n private ensureArrowIsAdded() {\n if (!this.noArrow && !this._container.contains(this._arrow)) {\n this._container.appendChild(this._arrow);\n }\n }\n\n public updatePopper(): void {\n if (this._popper) {\n this._popper.state.elements.reference = this.targetElement;\n this._popper.state.options.placement = this.placement;\n\n if (this.open) {\n this._popper.update();\n }\n }\n }\n\n private updateArrow(placement: Placement): void {\n if (this._arrow) {\n const arrowVariant = this.getArrowVariant(placement);\n this._arrow.setAttribute(\"variant\", arrowVariant);\n if (this._content) {\n const svg = this._arrow.querySelector(\"svg\");\n\n const arrowWidth = this._arrow.clientWidth;\n const arrowHeight = this._arrow.clientHeight;\n const verticalOffset = `-${arrowHeight - arrowOverlapOffset}px`;\n\n const horizontalTransformationOffset = (arrowWidth - arrowHeight) / 2;\n // Note that arrowHeight is used on purpose for the horizontalOffset\n // as this is the height of the unrotated wrapper div which defines the gap between the\n // reference element and the popover.\n const horizontalOffset = `-${arrowHeight + horizontalTransformationOffset - arrowOverlapOffset}px`;\n\n switch (arrowVariant) {\n case \"bottom\": {\n this._arrow.style.top = verticalOffset;\n svg.style.transform = \"rotate(180deg)\";\n break;\n }\n case \"top\": {\n this._arrow.style.bottom = verticalOffset;\n svg.style.transform = \"rotate(0deg)\";\n break;\n }\n case \"left\": {\n this._arrow.style.right = horizontalOffset;\n svg.style.transform = \"rotate(270deg)\";\n break;\n }\n case \"right\": {\n this._arrow.style.left = horizontalOffset;\n svg.style.transform = \"rotate(90deg)\";\n break;\n }\n }\n }\n }\n }\n\n private getArrowVariant(placement: Placement): ArrowVariant {\n if (placement.indexOf(\"bottom\") !== -1) {\n return \"bottom\";\n } else if (placement.indexOf(\"top\") !== -1) {\n return \"top\";\n } else if (placement.indexOf(\"left\") !== -1) {\n return \"left\";\n } else if (placement.indexOf(\"right\") !== -1) {\n return \"right\";\n }\n }\n\n private get content(): HTMLElement {\n if (!this._content) {\n this._content = this.firstElementChild as HTMLElement;\n this._content.setAttribute(\"data-popper-content\", \"\");\n }\n return this._content;\n }\n\n private addTargetClassForOpen(target: HTMLElement): void {\n if (target) {\n target.classList.add(targetClassOpen);\n }\n }\n\n private removeTargetClassForOpen(target: HTMLElement): void {\n if (target) {\n target.classList.remove(targetClassOpen);\n }\n }\n\n private findNextFocusableAfter(\n trigger: HTMLElement | null,\n root: HTMLElement | null,\n forward: boolean,\n ): HTMLElement | null {\n if (!trigger) return null;\n\n const effectiveRoot = root ?? document.body;\n\n const walker = document.createTreeWalker(effectiveRoot, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node) {\n const el = node as HTMLElement;\n\n return el.tabIndex >= 0 && !el.hidden && el.offsetParent !== null\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP;\n },\n });\n\n walker.currentNode = trigger;\n\n const nextNode = forward ? walker.nextNode() : walker.previousNode();\n\n return nextNode as HTMLElement | null;\n }\n}\n\nif (!customElements.get(Popover.ID)) {\n customElements.define(Popover.ID, Popover);\n}\n"],"names":["arrowSvg","isIE11","arrowOverlapOffset","targetClassOpen","_Popover","event","target","shift","nextInsidePopover","root","type","placement","element","selector","modal","popoverFor","priority","offset","noArrow","name","oldValue","open","backgroundColor","oldTarget","popover","options","state","createPopper","arrowVariant","svg","arrowWidth","arrowHeight","verticalOffset","horizontalTransformationOffset","horizontalOffset","trigger","forward","effectiveRoot","walker","node","el","Popover"],"mappings":";AAAA,MAAAA,IAAe;AAAA;AAAA;AAAA;AAAA,GCGTC,IAAS,UAAU,UAAU,QAAQ,SAAS,MAAM,IACpDC,IAAqB,GACrBC,IAAkB,mBA0CHC,IAArB,MAAqBA,UAAgB,YAAY;AAAA,EAAjD,cAAA;AAAA,UAAA,GAAA,SAAA,GAEI,KAAQ,QAAQ,IAMhB,KAAQ,gBAAgB,IAqLxB,KAAO,SAAS,MAAY;AACxB,WAAK,OAAO,CAAC,KAAK;AAAA,IACtB,GAEA,KAAO,OAAO,MAAY;AACtB,WAAK,OAAO;AAAA,IAChB,GAEA,KAAO,OAAO,MAAY;AACtB,WAAK,OAAO;AAAA,IAChB,GA4EA,KAAQ,uBAAuB,CAACC,MAAiB;AAC7C,YAAMC,IAASD,EAAM;AACrB,OACI,EAAEC,aAAkB,gBACnB,CAAC,KAAK,WAAW,SAASA,CAAM,KAAK,CAAC,KAAK,cAAc,SAASA,CAAM,MAEzE,KAAK,KAAA;AAAA,IAEb,GAEA,KAAQ,mBAAmB,CAACD,MAAyB;AACjD,UAAIA,EAAM,QAAQ;AACd;AAGJ,Y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