@telperion/elements 2.0.0 → 3.0.0

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.
@@ -0,0 +1,295 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var lit = require('lit');
5
+ var decorators_js = require('lit/decorators.js');
6
+ var uniqueId = require('@telperion/js-utils/unique-id');
7
+ var position = require('./position.cjs');
8
+
9
+ exports.PopoverElement = class PopoverElement extends lit.LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ /** Mirrored to the native `popover` attribute. */
13
+ this.mode = "auto";
14
+ /** CSS query selector resolved against `document`. */
15
+ this.target = null;
16
+ /** Placement spec — see class docs. */
17
+ this.position = null;
18
+ /** How the resolved target opens the popover. */
19
+ this.trigger = "manual";
20
+ /** Per-instance anchor id (without the leading `--`). */
21
+ this.#anchorId = uniqueId.uniqueId("tp-popover");
22
+ /** Currently resolved anchor element (if any). */
23
+ this.#anchorEl = null;
24
+ /** Whether we set `anchor-name` on the current anchor (so we clean up). */
25
+ this.#anchorNameSet = false;
26
+ /** Bound trigger listener cleanups for the current anchor. */
27
+ this.#triggerCleanups = [];
28
+ }
29
+ static {
30
+ const style = (this.GLOBAL_STYLE = document.createElement("style"));
31
+ // Pre-baked rules. Each instance gets:
32
+ // - data-pi/data-ti/data-pb/data-tb attributes set by JS,
33
+ // - inline `position-anchor: --tp-popover-N`,
34
+ // - inline `anchor-name: --tp-popover-N` on the resolved target.
35
+ //
36
+ // Use `margin` on the popover to add gap between the popover and its
37
+ // anchor target. The default `position-try-fallbacks` flips the popover
38
+ // off-axis when there is no room — the engine swaps `inset-*-start` with
39
+ // `inset-*-end` and the `start`/`end` keywords inside `anchor()` for us,
40
+ // and our translate-vars are symmetric so they remain correct after a
41
+ // flip.
42
+ style.textContent = `
43
+ tp-popover {
44
+ --tp-popover-inline-position: attr(data-ti type(*));
45
+ --tp-popover-block-position: attr(data-tb type(*));
46
+ inset: auto;
47
+ translate: var(--tp-popover-translate-x, 0) var(--tp-popover-translate-y, 0);
48
+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
49
+
50
+ &[data-tb="middle"] {
51
+ --tp-popover-block-position: center;
52
+ }
53
+
54
+ &[data-pi="start"],
55
+ &[data-pi="center"] {
56
+ inset-inline-start: anchor(var(--tp-popover-inline-position));
57
+ }
58
+
59
+ &[data-pi="center"] {
60
+ --tp-popover-translate-x: -50%;
61
+ }
62
+
63
+ &[data-pi="end"] {
64
+ inset-inline-end: anchor(var(--tp-popover-inline-position));
65
+ }
66
+
67
+ &[data-pb="top"],
68
+ &[data-pb="middle"] {
69
+ inset-block-start: anchor(var(--tp-popover-block-position));
70
+ }
71
+
72
+ &[data-pb="middle"] {
73
+ --tp-popover-translate-y: -50%;
74
+ }
75
+
76
+ &[data-pb="bottom"] {
77
+ inset-block-end: anchor(var(--tp-popover-block-position));
78
+ }
79
+ }
80
+ `;
81
+ document.head.appendChild(style);
82
+ }
83
+ /** Per-instance anchor id (without the leading `--`). */
84
+ #anchorId;
85
+ /** Currently resolved anchor element (if any). */
86
+ #anchorEl;
87
+ /** The currently-resolved anchor element. */
88
+ get anchorElement() {
89
+ return this.#anchorEl;
90
+ }
91
+ /** Custom-property name (with leading `--`) bound on the anchor. */
92
+ get anchorName() {
93
+ return `--${this.#anchorId}`;
94
+ }
95
+ /** Whether we set `anchor-name` on the current anchor (so we clean up). */
96
+ #anchorNameSet;
97
+ /** Bound trigger listener cleanups for the current anchor. */
98
+ #triggerCleanups;
99
+ createRenderRoot() {
100
+ return this;
101
+ }
102
+ connectedCallback() {
103
+ super.connectedCallback();
104
+ this.#syncMode();
105
+ this.#syncAnchor();
106
+ this.#syncPosition();
107
+ this.#syncTrigger();
108
+ }
109
+ disconnectedCallback() {
110
+ super.disconnectedCallback();
111
+ this.#clearTrigger();
112
+ this.#releaseAnchor();
113
+ }
114
+ updated(changed) {
115
+ if (changed.has("mode"))
116
+ this.#syncMode();
117
+ if (changed.has("target")) {
118
+ this.#syncAnchor();
119
+ this.#syncTrigger();
120
+ }
121
+ if (changed.has("position"))
122
+ this.#syncPosition();
123
+ if (changed.has("trigger"))
124
+ this.#syncTrigger();
125
+ }
126
+ render() {
127
+ return lit.html ``;
128
+ }
129
+ // -- Mode / popover attr --------------------------------------------------
130
+ #syncMode() {
131
+ const value = this.mode === "manual" ? "manual" : "auto";
132
+ if (this.getAttribute("popover") !== value) {
133
+ this.setAttribute("popover", value);
134
+ }
135
+ }
136
+ // -- Anchor resolution ----------------------------------------------------
137
+ #resolveTarget() {
138
+ const selector = this.target;
139
+ if (selector) {
140
+ try {
141
+ const el = document.querySelector(selector);
142
+ if (el instanceof HTMLElement)
143
+ return el;
144
+ console.warn(`<tp-popover>: target "${selector}" did not resolve to an HTMLElement; using parentElement.`);
145
+ }
146
+ catch {
147
+ console.warn(`<tp-popover>: invalid target selector "${selector}"; using parentElement.`);
148
+ }
149
+ }
150
+ const parent = this.parentElement;
151
+ return parent instanceof HTMLElement ? parent : null;
152
+ }
153
+ #syncAnchor() {
154
+ const next = this.#resolveTarget();
155
+ if (next === this.#anchorEl) {
156
+ // Re-apply in case the target lost its anchor-name in between.
157
+ if (next)
158
+ this.#applyAnchorTo(next);
159
+ return;
160
+ }
161
+ this.#releaseAnchor();
162
+ this.#anchorEl = next;
163
+ if (next)
164
+ this.#applyAnchorTo(next);
165
+ }
166
+ #applyAnchorTo(el) {
167
+ const cssName = `--${this.#anchorId}`;
168
+ const existing = el.style.getPropertyValue("anchor-name").trim();
169
+ if (existing && existing !== cssName) {
170
+ // Don't overwrite a pre-existing anchor-name; just bind to it.
171
+ this.style.setProperty("position-anchor", existing);
172
+ this.#anchorNameSet = false;
173
+ return;
174
+ }
175
+ el.style.setProperty("anchor-name", cssName);
176
+ this.style.setProperty("position-anchor", cssName);
177
+ this.#anchorNameSet = true;
178
+ }
179
+ #releaseAnchor() {
180
+ if (this.#anchorEl && this.#anchorNameSet) {
181
+ const cssName = `--${this.#anchorId}`;
182
+ if (this.#anchorEl.style.getPropertyValue("anchor-name").trim() === cssName) {
183
+ this.#anchorEl.style.removeProperty("anchor-name");
184
+ }
185
+ }
186
+ this.#anchorEl = null;
187
+ this.#anchorNameSet = false;
188
+ this.style.removeProperty("position-anchor");
189
+ }
190
+ // -- Position parsing -----------------------------------------------------
191
+ #syncPosition() {
192
+ let parsed = position.parsePosition(this.position);
193
+ if (this.position && !parsed) {
194
+ console.warn(`<tp-popover>: invalid position "${this.position}"; using default.`);
195
+ }
196
+ parsed ??= position.DEFAULT_POSITION;
197
+ this.dataset["pi"] = parsed.popInline;
198
+ this.dataset["ti"] = parsed.targetInline;
199
+ this.dataset["pb"] = parsed.popBlock;
200
+ this.dataset["tb"] = parsed.targetBlock;
201
+ }
202
+ // -- Trigger handling -----------------------------------------------------
203
+ #clearTrigger() {
204
+ for (const fn of this.#triggerCleanups)
205
+ fn();
206
+ this.#triggerCleanups = [];
207
+ }
208
+ #syncTrigger() {
209
+ this.#clearTrigger();
210
+ const anchor = this.#anchorEl;
211
+ if (!anchor)
212
+ return;
213
+ if (this.trigger === "click") {
214
+ const onClick = () => {
215
+ try {
216
+ this.togglePopover();
217
+ }
218
+ catch {
219
+ /* not connected / unsupported */
220
+ }
221
+ };
222
+ anchor.addEventListener("click", onClick);
223
+ this.#triggerCleanups.push(() => anchor.removeEventListener("click", onClick));
224
+ return;
225
+ }
226
+ if (this.trigger === "hover") {
227
+ let hideTimer = null;
228
+ const cancelHide = () => {
229
+ if (hideTimer !== null) {
230
+ clearTimeout(hideTimer);
231
+ hideTimer = null;
232
+ }
233
+ };
234
+ const show = () => {
235
+ cancelHide();
236
+ try {
237
+ this.showPopover();
238
+ }
239
+ catch {
240
+ /* already open / unsupported */
241
+ }
242
+ };
243
+ const scheduleHide = () => {
244
+ cancelHide();
245
+ hideTimer = setTimeout(() => {
246
+ try {
247
+ this.hidePopover();
248
+ }
249
+ catch {
250
+ /* already closed / unsupported */
251
+ }
252
+ }, 120);
253
+ };
254
+ anchor.addEventListener("pointerenter", show);
255
+ anchor.addEventListener("pointerleave", scheduleHide);
256
+ anchor.addEventListener("focusin", show);
257
+ anchor.addEventListener("focusout", scheduleHide);
258
+ this.addEventListener("pointerenter", cancelHide);
259
+ this.addEventListener("pointerleave", scheduleHide);
260
+ this.addEventListener("focusin", cancelHide);
261
+ this.addEventListener("focusout", scheduleHide);
262
+ this.#triggerCleanups.push(() => {
263
+ cancelHide();
264
+ anchor.removeEventListener("pointerenter", show);
265
+ anchor.removeEventListener("pointerleave", scheduleHide);
266
+ anchor.removeEventListener("focusin", show);
267
+ anchor.removeEventListener("focusout", scheduleHide);
268
+ this.removeEventListener("pointerenter", cancelHide);
269
+ this.removeEventListener("pointerleave", scheduleHide);
270
+ this.removeEventListener("focusin", cancelHide);
271
+ this.removeEventListener("focusout", scheduleHide);
272
+ });
273
+ }
274
+ }
275
+ };
276
+ tslib.__decorate([
277
+ decorators_js.property({ reflect: true }),
278
+ tslib.__metadata("design:type", String)
279
+ ], exports.PopoverElement.prototype, "mode", void 0);
280
+ tslib.__decorate([
281
+ decorators_js.property({ reflect: true }),
282
+ tslib.__metadata("design:type", Object)
283
+ ], exports.PopoverElement.prototype, "target", void 0);
284
+ tslib.__decorate([
285
+ decorators_js.property({ reflect: true }),
286
+ tslib.__metadata("design:type", Object)
287
+ ], exports.PopoverElement.prototype, "position", void 0);
288
+ tslib.__decorate([
289
+ decorators_js.property({ reflect: true }),
290
+ tslib.__metadata("design:type", String)
291
+ ], exports.PopoverElement.prototype, "trigger", void 0);
292
+ exports.PopoverElement = tslib.__decorate([
293
+ decorators_js.customElement("tp-popover")
294
+ ], exports.PopoverElement);
295
+ //# sourceMappingURL=popover-element.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-element.cjs","sources":["../../../../libs/elements/src/popover/popover-element.ts"],"sourcesContent":[null],"names":["PopoverElement","LitElement","uniqueId","html","parsePosition","DEFAULT_POSITION","__decorate","property","customElement"],"mappings":";;;;;;;;AAiF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AAA,UAAA,EAAA,MAAA,CAAA;AAI/BM,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACqB,CAAA,EAAAP,sBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAzEtCA,sBAAc,GAAAM,gBAAA,CAAA;IAD1BE,2BAAa,CAAC,YAAY;AACd,CAAA,EAAAR,sBAAc,CA0R1B;;"}
@@ -0,0 +1,295 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { LitElement, html } from 'lit';
3
+ import { property, customElement } from 'lit/decorators.js';
4
+ import { uniqueId } from '@telperion/js-utils/unique-id';
5
+ import { parsePosition, DEFAULT_POSITION } from './position.js';
6
+
7
+ let PopoverElement = class PopoverElement extends LitElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ /** Mirrored to the native `popover` attribute. */
11
+ this.mode = "auto";
12
+ /** CSS query selector resolved against `document`. */
13
+ this.target = null;
14
+ /** Placement spec — see class docs. */
15
+ this.position = null;
16
+ /** How the resolved target opens the popover. */
17
+ this.trigger = "manual";
18
+ /** Per-instance anchor id (without the leading `--`). */
19
+ this.#anchorId = uniqueId("tp-popover");
20
+ /** Currently resolved anchor element (if any). */
21
+ this.#anchorEl = null;
22
+ /** Whether we set `anchor-name` on the current anchor (so we clean up). */
23
+ this.#anchorNameSet = false;
24
+ /** Bound trigger listener cleanups for the current anchor. */
25
+ this.#triggerCleanups = [];
26
+ }
27
+ static {
28
+ const style = (this.GLOBAL_STYLE = document.createElement("style"));
29
+ // Pre-baked rules. Each instance gets:
30
+ // - data-pi/data-ti/data-pb/data-tb attributes set by JS,
31
+ // - inline `position-anchor: --tp-popover-N`,
32
+ // - inline `anchor-name: --tp-popover-N` on the resolved target.
33
+ //
34
+ // Use `margin` on the popover to add gap between the popover and its
35
+ // anchor target. The default `position-try-fallbacks` flips the popover
36
+ // off-axis when there is no room — the engine swaps `inset-*-start` with
37
+ // `inset-*-end` and the `start`/`end` keywords inside `anchor()` for us,
38
+ // and our translate-vars are symmetric so they remain correct after a
39
+ // flip.
40
+ style.textContent = `
41
+ tp-popover {
42
+ --tp-popover-inline-position: attr(data-ti type(*));
43
+ --tp-popover-block-position: attr(data-tb type(*));
44
+ inset: auto;
45
+ translate: var(--tp-popover-translate-x, 0) var(--tp-popover-translate-y, 0);
46
+ position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
47
+
48
+ &[data-tb="middle"] {
49
+ --tp-popover-block-position: center;
50
+ }
51
+
52
+ &[data-pi="start"],
53
+ &[data-pi="center"] {
54
+ inset-inline-start: anchor(var(--tp-popover-inline-position));
55
+ }
56
+
57
+ &[data-pi="center"] {
58
+ --tp-popover-translate-x: -50%;
59
+ }
60
+
61
+ &[data-pi="end"] {
62
+ inset-inline-end: anchor(var(--tp-popover-inline-position));
63
+ }
64
+
65
+ &[data-pb="top"],
66
+ &[data-pb="middle"] {
67
+ inset-block-start: anchor(var(--tp-popover-block-position));
68
+ }
69
+
70
+ &[data-pb="middle"] {
71
+ --tp-popover-translate-y: -50%;
72
+ }
73
+
74
+ &[data-pb="bottom"] {
75
+ inset-block-end: anchor(var(--tp-popover-block-position));
76
+ }
77
+ }
78
+ `;
79
+ document.head.appendChild(style);
80
+ }
81
+ /** Per-instance anchor id (without the leading `--`). */
82
+ #anchorId;
83
+ /** Currently resolved anchor element (if any). */
84
+ #anchorEl;
85
+ /** The currently-resolved anchor element. */
86
+ get anchorElement() {
87
+ return this.#anchorEl;
88
+ }
89
+ /** Custom-property name (with leading `--`) bound on the anchor. */
90
+ get anchorName() {
91
+ return `--${this.#anchorId}`;
92
+ }
93
+ /** Whether we set `anchor-name` on the current anchor (so we clean up). */
94
+ #anchorNameSet;
95
+ /** Bound trigger listener cleanups for the current anchor. */
96
+ #triggerCleanups;
97
+ createRenderRoot() {
98
+ return this;
99
+ }
100
+ connectedCallback() {
101
+ super.connectedCallback();
102
+ this.#syncMode();
103
+ this.#syncAnchor();
104
+ this.#syncPosition();
105
+ this.#syncTrigger();
106
+ }
107
+ disconnectedCallback() {
108
+ super.disconnectedCallback();
109
+ this.#clearTrigger();
110
+ this.#releaseAnchor();
111
+ }
112
+ updated(changed) {
113
+ if (changed.has("mode"))
114
+ this.#syncMode();
115
+ if (changed.has("target")) {
116
+ this.#syncAnchor();
117
+ this.#syncTrigger();
118
+ }
119
+ if (changed.has("position"))
120
+ this.#syncPosition();
121
+ if (changed.has("trigger"))
122
+ this.#syncTrigger();
123
+ }
124
+ render() {
125
+ return html ``;
126
+ }
127
+ // -- Mode / popover attr --------------------------------------------------
128
+ #syncMode() {
129
+ const value = this.mode === "manual" ? "manual" : "auto";
130
+ if (this.getAttribute("popover") !== value) {
131
+ this.setAttribute("popover", value);
132
+ }
133
+ }
134
+ // -- Anchor resolution ----------------------------------------------------
135
+ #resolveTarget() {
136
+ const selector = this.target;
137
+ if (selector) {
138
+ try {
139
+ const el = document.querySelector(selector);
140
+ if (el instanceof HTMLElement)
141
+ return el;
142
+ console.warn(`<tp-popover>: target "${selector}" did not resolve to an HTMLElement; using parentElement.`);
143
+ }
144
+ catch {
145
+ console.warn(`<tp-popover>: invalid target selector "${selector}"; using parentElement.`);
146
+ }
147
+ }
148
+ const parent = this.parentElement;
149
+ return parent instanceof HTMLElement ? parent : null;
150
+ }
151
+ #syncAnchor() {
152
+ const next = this.#resolveTarget();
153
+ if (next === this.#anchorEl) {
154
+ // Re-apply in case the target lost its anchor-name in between.
155
+ if (next)
156
+ this.#applyAnchorTo(next);
157
+ return;
158
+ }
159
+ this.#releaseAnchor();
160
+ this.#anchorEl = next;
161
+ if (next)
162
+ this.#applyAnchorTo(next);
163
+ }
164
+ #applyAnchorTo(el) {
165
+ const cssName = `--${this.#anchorId}`;
166
+ const existing = el.style.getPropertyValue("anchor-name").trim();
167
+ if (existing && existing !== cssName) {
168
+ // Don't overwrite a pre-existing anchor-name; just bind to it.
169
+ this.style.setProperty("position-anchor", existing);
170
+ this.#anchorNameSet = false;
171
+ return;
172
+ }
173
+ el.style.setProperty("anchor-name", cssName);
174
+ this.style.setProperty("position-anchor", cssName);
175
+ this.#anchorNameSet = true;
176
+ }
177
+ #releaseAnchor() {
178
+ if (this.#anchorEl && this.#anchorNameSet) {
179
+ const cssName = `--${this.#anchorId}`;
180
+ if (this.#anchorEl.style.getPropertyValue("anchor-name").trim() === cssName) {
181
+ this.#anchorEl.style.removeProperty("anchor-name");
182
+ }
183
+ }
184
+ this.#anchorEl = null;
185
+ this.#anchorNameSet = false;
186
+ this.style.removeProperty("position-anchor");
187
+ }
188
+ // -- Position parsing -----------------------------------------------------
189
+ #syncPosition() {
190
+ let parsed = parsePosition(this.position);
191
+ if (this.position && !parsed) {
192
+ console.warn(`<tp-popover>: invalid position "${this.position}"; using default.`);
193
+ }
194
+ parsed ??= DEFAULT_POSITION;
195
+ this.dataset["pi"] = parsed.popInline;
196
+ this.dataset["ti"] = parsed.targetInline;
197
+ this.dataset["pb"] = parsed.popBlock;
198
+ this.dataset["tb"] = parsed.targetBlock;
199
+ }
200
+ // -- Trigger handling -----------------------------------------------------
201
+ #clearTrigger() {
202
+ for (const fn of this.#triggerCleanups)
203
+ fn();
204
+ this.#triggerCleanups = [];
205
+ }
206
+ #syncTrigger() {
207
+ this.#clearTrigger();
208
+ const anchor = this.#anchorEl;
209
+ if (!anchor)
210
+ return;
211
+ if (this.trigger === "click") {
212
+ const onClick = () => {
213
+ try {
214
+ this.togglePopover();
215
+ }
216
+ catch {
217
+ /* not connected / unsupported */
218
+ }
219
+ };
220
+ anchor.addEventListener("click", onClick);
221
+ this.#triggerCleanups.push(() => anchor.removeEventListener("click", onClick));
222
+ return;
223
+ }
224
+ if (this.trigger === "hover") {
225
+ let hideTimer = null;
226
+ const cancelHide = () => {
227
+ if (hideTimer !== null) {
228
+ clearTimeout(hideTimer);
229
+ hideTimer = null;
230
+ }
231
+ };
232
+ const show = () => {
233
+ cancelHide();
234
+ try {
235
+ this.showPopover();
236
+ }
237
+ catch {
238
+ /* already open / unsupported */
239
+ }
240
+ };
241
+ const scheduleHide = () => {
242
+ cancelHide();
243
+ hideTimer = setTimeout(() => {
244
+ try {
245
+ this.hidePopover();
246
+ }
247
+ catch {
248
+ /* already closed / unsupported */
249
+ }
250
+ }, 120);
251
+ };
252
+ anchor.addEventListener("pointerenter", show);
253
+ anchor.addEventListener("pointerleave", scheduleHide);
254
+ anchor.addEventListener("focusin", show);
255
+ anchor.addEventListener("focusout", scheduleHide);
256
+ this.addEventListener("pointerenter", cancelHide);
257
+ this.addEventListener("pointerleave", scheduleHide);
258
+ this.addEventListener("focusin", cancelHide);
259
+ this.addEventListener("focusout", scheduleHide);
260
+ this.#triggerCleanups.push(() => {
261
+ cancelHide();
262
+ anchor.removeEventListener("pointerenter", show);
263
+ anchor.removeEventListener("pointerleave", scheduleHide);
264
+ anchor.removeEventListener("focusin", show);
265
+ anchor.removeEventListener("focusout", scheduleHide);
266
+ this.removeEventListener("pointerenter", cancelHide);
267
+ this.removeEventListener("pointerleave", scheduleHide);
268
+ this.removeEventListener("focusin", cancelHide);
269
+ this.removeEventListener("focusout", scheduleHide);
270
+ });
271
+ }
272
+ }
273
+ };
274
+ __decorate([
275
+ property({ reflect: true }),
276
+ __metadata("design:type", String)
277
+ ], PopoverElement.prototype, "mode", void 0);
278
+ __decorate([
279
+ property({ reflect: true }),
280
+ __metadata("design:type", Object)
281
+ ], PopoverElement.prototype, "target", void 0);
282
+ __decorate([
283
+ property({ reflect: true }),
284
+ __metadata("design:type", Object)
285
+ ], PopoverElement.prototype, "position", void 0);
286
+ __decorate([
287
+ property({ reflect: true }),
288
+ __metadata("design:type", String)
289
+ ], PopoverElement.prototype, "trigger", void 0);
290
+ PopoverElement = __decorate([
291
+ customElement("tp-popover")
292
+ ], PopoverElement);
293
+
294
+ export { PopoverElement };
295
+ //# sourceMappingURL=popover-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-element.js","sources":["../../../../libs/elements/src/popover/popover-element.ts"],"sourcesContent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