@telperion/elements 2.0.1 → 3.0.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/.build-manifest.json +12 -1
- package/README.md +46 -1
- package/fesm/elements.mjs +393 -1
- package/fesm/elements.mjs.map +1 -1
- package/iife/elements.js +15 -15
- package/iife/elements.js.map +1 -1
- package/iife/popover/index.js +35 -0
- package/iife/popover/index.js.map +1 -0
- package/index.cjs +5 -0
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +52 -7
- package/popover/index.cjs +11 -0
- package/popover/index.cjs.map +1 -0
- package/popover/index.d.cts +98 -0
- package/popover/index.d.ts +98 -0
- package/popover/index.js +2 -0
- package/popover/index.js.map +1 -0
- package/popover/popover-element.cjs +301 -0
- package/popover/popover-element.cjs.map +1 -0
- package/popover/popover-element.js +301 -0
- package/popover/popover-element.js.map +1 -0
- package/popover/position.cjs +103 -0
- package/popover/position.cjs.map +1 -0
- package/popover/position.js +100 -0
- package/popover/position.js.map +1 -0
|
@@ -0,0 +1,301 @@
|
|
|
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 = (event) => {
|
|
215
|
+
// If the click bubbled up from inside the popover itself (which
|
|
216
|
+
// happens when the anchor is an ancestor of the popover), ignore
|
|
217
|
+
// it — otherwise the popover would close immediately on every
|
|
218
|
+
// interaction with its own content.
|
|
219
|
+
if (event.composedPath().includes(this))
|
|
220
|
+
return;
|
|
221
|
+
try {
|
|
222
|
+
this.togglePopover();
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
/* not connected / unsupported */
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
anchor.addEventListener("click", onClick);
|
|
229
|
+
this.#triggerCleanups.push(() => anchor.removeEventListener("click", onClick));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (this.trigger === "hover") {
|
|
233
|
+
let hideTimer = null;
|
|
234
|
+
const cancelHide = () => {
|
|
235
|
+
if (hideTimer !== null) {
|
|
236
|
+
clearTimeout(hideTimer);
|
|
237
|
+
hideTimer = null;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
const show = () => {
|
|
241
|
+
cancelHide();
|
|
242
|
+
try {
|
|
243
|
+
this.showPopover();
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
/* already open / unsupported */
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const scheduleHide = () => {
|
|
250
|
+
cancelHide();
|
|
251
|
+
hideTimer = setTimeout(() => {
|
|
252
|
+
try {
|
|
253
|
+
this.hidePopover();
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
/* already closed / unsupported */
|
|
257
|
+
}
|
|
258
|
+
}, 120);
|
|
259
|
+
};
|
|
260
|
+
anchor.addEventListener("pointerenter", show);
|
|
261
|
+
anchor.addEventListener("pointerleave", scheduleHide);
|
|
262
|
+
anchor.addEventListener("focusin", show);
|
|
263
|
+
anchor.addEventListener("focusout", scheduleHide);
|
|
264
|
+
this.addEventListener("pointerenter", cancelHide);
|
|
265
|
+
this.addEventListener("pointerleave", scheduleHide);
|
|
266
|
+
this.addEventListener("focusin", cancelHide);
|
|
267
|
+
this.addEventListener("focusout", scheduleHide);
|
|
268
|
+
this.#triggerCleanups.push(() => {
|
|
269
|
+
cancelHide();
|
|
270
|
+
anchor.removeEventListener("pointerenter", show);
|
|
271
|
+
anchor.removeEventListener("pointerleave", scheduleHide);
|
|
272
|
+
anchor.removeEventListener("focusin", show);
|
|
273
|
+
anchor.removeEventListener("focusout", scheduleHide);
|
|
274
|
+
this.removeEventListener("pointerenter", cancelHide);
|
|
275
|
+
this.removeEventListener("pointerleave", scheduleHide);
|
|
276
|
+
this.removeEventListener("focusin", cancelHide);
|
|
277
|
+
this.removeEventListener("focusout", scheduleHide);
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
tslib.__decorate([
|
|
283
|
+
decorators_js.property({ reflect: true }),
|
|
284
|
+
tslib.__metadata("design:type", String)
|
|
285
|
+
], exports.PopoverElement.prototype, "mode", void 0);
|
|
286
|
+
tslib.__decorate([
|
|
287
|
+
decorators_js.property({ reflect: true }),
|
|
288
|
+
tslib.__metadata("design:type", Object)
|
|
289
|
+
], exports.PopoverElement.prototype, "target", void 0);
|
|
290
|
+
tslib.__decorate([
|
|
291
|
+
decorators_js.property({ reflect: true }),
|
|
292
|
+
tslib.__metadata("design:type", Object)
|
|
293
|
+
], exports.PopoverElement.prototype, "position", void 0);
|
|
294
|
+
tslib.__decorate([
|
|
295
|
+
decorators_js.property({ reflect: true }),
|
|
296
|
+
tslib.__metadata("design:type", String)
|
|
297
|
+
], exports.PopoverElement.prototype, "trigger", void 0);
|
|
298
|
+
exports.PopoverElement = tslib.__decorate([
|
|
299
|
+
decorators_js.customElement("tp-popover")
|
|
300
|
+
], exports.PopoverElement);
|
|
301
|
+
//# 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":";;;;;;;;AAiFaA,sBAAc,GAApB,MAAM,cAAe,SAAQC,cAAU,CAAA;AAAvC,IAAA,WAAA,GAAA;;;QA6DL,IAAA,CAAA,IAAI,GAAsB,MAAM;;QAIhC,IAAA,CAAA,MAAM,GAAkB,IAAI;;QAI5B,IAAA,CAAA,QAAQ,GAAkB,IAAI;;QAI9B,IAAA,CAAA,OAAO,GAAiC,QAAQ;;AAGvC,QAAA,IAAA,CAAA,SAAS,GAAGC,iBAAQ,CAAC,YAAY,CAAC;;QAG3C,IAAA,CAAA,SAAS,GAAuB,IAAI;;QAapC,IAAA,CAAA,cAAc,GAAG,KAAK;;QAGtB,IAAA,CAAA,gBAAgB,GAAsB,EAAE;IAgM1C;AA5RE,IAAA;AACE,QAAA,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;;;;;;;;;;;;QAanE,KAAK,CAAC,WAAW,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCnB;AACD,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;;;AAoBzB,IAAA,SAAS;;AAGlB,IAAA,SAAS;;AAGT,IAAA,IAAI,aAAa,GAAA;QACf,O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S,EAAE,UAAU,CAAC;AAC/C,gBAAA,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,YAAY,CAAC;AACpD,YAAA,CAAC,CAAC;QACJ;IACF;;AAjOAC,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACK,CAAA,EAAAP,sBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAIjCM,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACC,CAAA,EAAAP,sBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAI7BM,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;AACG,CAAA,EAAAP,sBAAA,CAAA,SAAA,EAAA,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,CA+R1B;;"}
|
|
@@ -0,0 +1,301 @@
|
|
|
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 = (event) => {
|
|
213
|
+
// If the click bubbled up from inside the popover itself (which
|
|
214
|
+
// happens when the anchor is an ancestor of the popover), ignore
|
|
215
|
+
// it — otherwise the popover would close immediately on every
|
|
216
|
+
// interaction with its own content.
|
|
217
|
+
if (event.composedPath().includes(this))
|
|
218
|
+
return;
|
|
219
|
+
try {
|
|
220
|
+
this.togglePopover();
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
/* not connected / unsupported */
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
anchor.addEventListener("click", onClick);
|
|
227
|
+
this.#triggerCleanups.push(() => anchor.removeEventListener("click", onClick));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (this.trigger === "hover") {
|
|
231
|
+
let hideTimer = null;
|
|
232
|
+
const cancelHide = () => {
|
|
233
|
+
if (hideTimer !== null) {
|
|
234
|
+
clearTimeout(hideTimer);
|
|
235
|
+
hideTimer = null;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const show = () => {
|
|
239
|
+
cancelHide();
|
|
240
|
+
try {
|
|
241
|
+
this.showPopover();
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
/* already open / unsupported */
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
const scheduleHide = () => {
|
|
248
|
+
cancelHide();
|
|
249
|
+
hideTimer = setTimeout(() => {
|
|
250
|
+
try {
|
|
251
|
+
this.hidePopover();
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
/* already closed / unsupported */
|
|
255
|
+
}
|
|
256
|
+
}, 120);
|
|
257
|
+
};
|
|
258
|
+
anchor.addEventListener("pointerenter", show);
|
|
259
|
+
anchor.addEventListener("pointerleave", scheduleHide);
|
|
260
|
+
anchor.addEventListener("focusin", show);
|
|
261
|
+
anchor.addEventListener("focusout", scheduleHide);
|
|
262
|
+
this.addEventListener("pointerenter", cancelHide);
|
|
263
|
+
this.addEventListener("pointerleave", scheduleHide);
|
|
264
|
+
this.addEventListener("focusin", cancelHide);
|
|
265
|
+
this.addEventListener("focusout", scheduleHide);
|
|
266
|
+
this.#triggerCleanups.push(() => {
|
|
267
|
+
cancelHide();
|
|
268
|
+
anchor.removeEventListener("pointerenter", show);
|
|
269
|
+
anchor.removeEventListener("pointerleave", scheduleHide);
|
|
270
|
+
anchor.removeEventListener("focusin", show);
|
|
271
|
+
anchor.removeEventListener("focusout", scheduleHide);
|
|
272
|
+
this.removeEventListener("pointerenter", cancelHide);
|
|
273
|
+
this.removeEventListener("pointerleave", scheduleHide);
|
|
274
|
+
this.removeEventListener("focusin", cancelHide);
|
|
275
|
+
this.removeEventListener("focusout", scheduleHide);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
__decorate([
|
|
281
|
+
property({ reflect: true }),
|
|
282
|
+
__metadata("design:type", String)
|
|
283
|
+
], PopoverElement.prototype, "mode", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
property({ reflect: true }),
|
|
286
|
+
__metadata("design:type", Object)
|
|
287
|
+
], PopoverElement.prototype, "target", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
property({ reflect: true }),
|
|
290
|
+
__metadata("design:type", Object)
|
|
291
|
+
], PopoverElement.prototype, "position", void 0);
|
|
292
|
+
__decorate([
|
|
293
|
+
property({ reflect: true }),
|
|
294
|
+
__metadata("design:type", String)
|
|
295
|
+
], PopoverElement.prototype, "trigger", void 0);
|
|
296
|
+
PopoverElement = __decorate([
|
|
297
|
+
customElement("tp-popover")
|
|
298
|
+
], PopoverElement);
|
|
299
|
+
|
|
300
|
+
export { PopoverElement };
|
|
301
|
+
//# sourceMappingURL=popover-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover-element.js","sources":["../../../../libs/elements/src/popover/popover-element.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAiFO,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU,CAAA;AAAvC,IAAA,WAAA,GAAA;;;QA6DL,IAAA,CAAA,IAAI,GAAsB,MAAM;;QAIhC,IAAA,CAAA,MAAM,GAAkB,IAAI;;QAI5B,IAAA,CAAA,QAAQ,GAAkB,IAAI;;QAI9B,IAAA,CAAA,OAAO,GAAiC,QAAQ;;AAGvC,QAAA,IAAA,CAAA,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC;;QAG3C,IAAA,CAAA,SAAS,GAAuB,IAAI;;QAapC,IAAA,CAAA,cAAc,GAAG,KAAK;;QAGtB,IAAA,CAAA,gBAAgB,GAAsB,EAAE;IAgM1C;AA5RE,IAAA;AACE,QAAA,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;;;;;;;;;;;;QAanE,KAAK,CAAC,WAAW,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCnB;AACD,QAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;;;AAoBzB,IAAA,SAAS;;AAGlB,IAAA,SAAS;;AAGT,IAAA,IAAI,aAAa,GAAA;QACf,OAAO,I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