@su-labs/tooltip 20.0.0 → 22.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.
- package/README.md +2 -2
- package/fesm2022/su-labs-tooltip.mjs +766 -487
- package/fesm2022/su-labs-tooltip.mjs.map +1 -1
- package/package.json +7 -6
- package/types/su-labs-tooltip.d.ts +195 -0
- package/index.d.ts +0 -115
|
@@ -1,498 +1,777 @@
|
|
|
1
|
-
import { DOCUMENT, NgTemplateOutlet } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { SU_TOOLTIP_LABELS, SuTooltipController,
|
|
5
|
-
|
|
1
|
+
import { DOCUMENT, NgTemplateOutlet } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, TemplateRef, afterRenderEffect, booleanAttribute, computed, effect, inject, input, model, numberAttribute, signal, untracked, viewChild } from "@angular/core";
|
|
4
|
+
import { SU_TOOLTIP_LABELS, SuTooltipController, suTooltipIconClip, suTooltipIconPosition, suTooltipPosition } from "@su-labs/core/tooltip";
|
|
6
5
|
let nextTooltipId = 0;
|
|
7
|
-
const FOCUSABLE =
|
|
6
|
+
const FOCUSABLE = "a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]";
|
|
8
7
|
const DEFAULT_DURATION = 200;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
8
|
+
var SuTooltipComponent = class SuTooltipComponent {
|
|
9
|
+
text = input("", ...ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []);
|
|
10
|
+
trigger = input("content", ...ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []);
|
|
11
|
+
icon = input("", ...ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []);
|
|
12
|
+
placement = input("top", ...ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []);
|
|
13
|
+
openOn = input(...ngDevMode ? [void 0, { debugName: "openOn" }] : /* istanbul ignore next */ []);
|
|
14
|
+
interactive = input(false, {
|
|
15
|
+
...ngDevMode ? { debugName: "interactive" } : /* istanbul ignore next */ {},
|
|
16
|
+
transform: booleanAttribute
|
|
17
|
+
});
|
|
18
|
+
animated = input(true, {
|
|
19
|
+
...ngDevMode ? { debugName: "animated" } : /* istanbul ignore next */ {},
|
|
20
|
+
transform: booleanAttribute
|
|
21
|
+
});
|
|
22
|
+
width = input(...ngDevMode ? [void 0, { debugName: "width" }] : /* istanbul ignore next */ []);
|
|
23
|
+
arrow = input(true, {
|
|
24
|
+
...ngDevMode ? { debugName: "arrow" } : /* istanbul ignore next */ {},
|
|
25
|
+
transform: booleanAttribute
|
|
26
|
+
});
|
|
27
|
+
offset = input(8, {
|
|
28
|
+
...ngDevMode ? { debugName: "offset" } : /* istanbul ignore next */ {},
|
|
29
|
+
transform: numberAttribute
|
|
30
|
+
});
|
|
31
|
+
showDelay = input(300, {
|
|
32
|
+
...ngDevMode ? { debugName: "showDelay" } : /* istanbul ignore next */ {},
|
|
33
|
+
transform: numberAttribute
|
|
34
|
+
});
|
|
35
|
+
hideDelay = input(100, {
|
|
36
|
+
...ngDevMode ? { debugName: "hideDelay" } : /* istanbul ignore next */ {},
|
|
37
|
+
transform: numberAttribute
|
|
38
|
+
});
|
|
39
|
+
disabled = input(false, {
|
|
40
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
41
|
+
transform: booleanAttribute
|
|
42
|
+
});
|
|
43
|
+
label = input(...ngDevMode ? [void 0, { debugName: "label" }] : /* istanbul ignore next */ []);
|
|
44
|
+
labels = input({}, ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
|
|
45
|
+
open = model(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
|
|
46
|
+
panelId = `su-tooltip-${nextTooltipId++}`;
|
|
47
|
+
isIcon = computed(() => this.trigger() === "icon", ...ngDevMode ? [{ debugName: "isIcon" }] : /* istanbul ignore next */ []);
|
|
48
|
+
opensOn = computed(() => this.openOn() ?? (this.isIcon() ? "click" : "hover"), ...ngDevMode ? [{ debugName: "opensOn" }] : /* istanbul ignore next */ []);
|
|
49
|
+
isInteractive = computed(() => this.interactive() || this.opensOn() === "click", ...ngDevMode ? [{ debugName: "isInteractive" }] : /* istanbul ignore next */ []);
|
|
50
|
+
describes = computed(() => !this.isIcon() && this.opensOn() === "hover", ...ngDevMode ? [{ debugName: "describes" }] : /* istanbul ignore next */ []);
|
|
51
|
+
template = computed(() => {
|
|
52
|
+
const text = this.text();
|
|
53
|
+
return text instanceof TemplateRef ? text : null;
|
|
54
|
+
}, ...ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []);
|
|
55
|
+
plainText = computed(() => {
|
|
56
|
+
const text = this.text();
|
|
57
|
+
return typeof text === "string" ? text : "";
|
|
58
|
+
}, ...ngDevMode ? [{ debugName: "plainText" }] : /* istanbul ignore next */ []);
|
|
59
|
+
iconTemplate = computed(() => {
|
|
60
|
+
const icon = this.icon();
|
|
61
|
+
return icon instanceof TemplateRef ? icon : null;
|
|
62
|
+
}, ...ngDevMode ? [{ debugName: "iconTemplate" }] : /* istanbul ignore next */ []);
|
|
63
|
+
iconText = computed(() => {
|
|
64
|
+
const icon = this.icon();
|
|
65
|
+
return typeof icon === "string" ? icon : "";
|
|
66
|
+
}, ...ngDevMode ? [{ debugName: "iconText" }] : /* istanbul ignore next */ []);
|
|
67
|
+
texts = computed(() => ({
|
|
68
|
+
...SU_TOOLTIP_LABELS,
|
|
69
|
+
...this.labels()
|
|
70
|
+
}), ...ngDevMode ? [{ debugName: "texts" }] : /* istanbul ignore next */ []);
|
|
71
|
+
morphed = signal(false, ...ngDevMode ? [{ debugName: "morphed" }] : /* istanbul ignore next */ []);
|
|
72
|
+
host = inject(ElementRef);
|
|
73
|
+
document = inject(DOCUMENT);
|
|
74
|
+
panel = viewChild.required("panel", ...ngDevMode ? [{ debugName: "panel" }] : /* istanbul ignore next */ []);
|
|
75
|
+
content = viewChild.required("content", ...ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []);
|
|
76
|
+
iconButton = viewChild("iconButton", ...ngDevMode ? [{ debugName: "iconButton" }] : /* istanbul ignore next */ []);
|
|
77
|
+
closeButton = viewChild("closeButton", ...ngDevMode ? [{ debugName: "closeButton" }] : /* istanbul ignore next */ []);
|
|
78
|
+
controller = new SuTooltipController();
|
|
79
|
+
animation = null;
|
|
80
|
+
iconClip = null;
|
|
81
|
+
shown = false;
|
|
82
|
+
focusOnOpen = false;
|
|
83
|
+
leftWhileGrowing = false;
|
|
84
|
+
returningFocus = false;
|
|
85
|
+
linkedTrigger = null;
|
|
86
|
+
constructor() {
|
|
87
|
+
const unsubscribe = this.controller.state.subscribe((state) => this.open.set(state.open));
|
|
88
|
+
inject(DestroyRef).onDestroy(() => {
|
|
89
|
+
unsubscribe();
|
|
90
|
+
this.controller.cancel();
|
|
91
|
+
this.animation?.cancel();
|
|
92
|
+
});
|
|
93
|
+
effect(() => {
|
|
94
|
+
const delays = {
|
|
95
|
+
showDelay: this.showDelay(),
|
|
96
|
+
hideDelay: this.hideDelay()
|
|
97
|
+
};
|
|
98
|
+
untracked(() => this.controller.setDelays(delays));
|
|
99
|
+
});
|
|
100
|
+
effect(() => {
|
|
101
|
+
const open = this.open() && !this.disabled();
|
|
102
|
+
untracked(() => {
|
|
103
|
+
this.controller.setOpen(open);
|
|
104
|
+
this.open.set(open);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
effect((onCleanup) => {
|
|
108
|
+
if (!this.open()) return;
|
|
109
|
+
const onKeydown = (event) => this.onDocumentKeydown(event);
|
|
110
|
+
const onPointerDown = (event) => this.onDocumentPointerDown(event);
|
|
111
|
+
const onMove = () => this.place();
|
|
112
|
+
const view = this.document.defaultView;
|
|
113
|
+
this.document.addEventListener("keydown", onKeydown);
|
|
114
|
+
this.document.addEventListener("pointerdown", onPointerDown);
|
|
115
|
+
view?.addEventListener("scroll", onMove, true);
|
|
116
|
+
view?.addEventListener("resize", onMove);
|
|
117
|
+
onCleanup(() => {
|
|
118
|
+
this.document.removeEventListener("keydown", onKeydown);
|
|
119
|
+
this.document.removeEventListener("pointerdown", onPointerDown);
|
|
120
|
+
view?.removeEventListener("scroll", onMove, true);
|
|
121
|
+
view?.removeEventListener("resize", onMove);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
afterRenderEffect(() => {
|
|
125
|
+
const open = this.open();
|
|
126
|
+
untracked(() => open ? this.reveal() : this.conceal());
|
|
127
|
+
});
|
|
128
|
+
afterRenderEffect(() => {
|
|
129
|
+
const trigger = this.isIcon() ? null : this.contentTrigger();
|
|
130
|
+
const describes = this.describes();
|
|
131
|
+
const open = this.open();
|
|
132
|
+
untracked(() => this.linkTrigger(trigger, describes, open));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
show() {
|
|
136
|
+
this.controller.open();
|
|
137
|
+
}
|
|
138
|
+
hide() {
|
|
139
|
+
this.controller.close();
|
|
140
|
+
}
|
|
141
|
+
toggle() {
|
|
142
|
+
this.controller.toggle();
|
|
143
|
+
}
|
|
144
|
+
onPointerEnter(event) {
|
|
145
|
+
if (this.disabled() || event.pointerType === "touch" || this.opensOn() !== "hover") return;
|
|
146
|
+
this.controller.show();
|
|
147
|
+
}
|
|
148
|
+
onPointerLeave(event) {
|
|
149
|
+
if (event.pointerType === "touch" || this.opensOn() !== "hover") return;
|
|
150
|
+
if (this.isGrowing()) {
|
|
151
|
+
this.leftWhileGrowing = true;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.controller.hide();
|
|
155
|
+
}
|
|
156
|
+
onFocusIn(event) {
|
|
157
|
+
if (this.inPanel(event.target)) {
|
|
158
|
+
this.controller.cancel();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!this.disabled() && !this.returningFocus && this.opensOn() === "hover") this.controller.open();
|
|
162
|
+
}
|
|
163
|
+
onFocusOut(event) {
|
|
164
|
+
const next = this.asNode(event.relatedTarget);
|
|
165
|
+
if (!next || this.host.nativeElement.contains(next)) return;
|
|
166
|
+
this.controller.close();
|
|
167
|
+
}
|
|
168
|
+
onClick(event) {
|
|
169
|
+
if (this.disabled() || this.inPanel(event.target)) return;
|
|
170
|
+
if (this.isIcon()) {
|
|
171
|
+
if (!this.iconButton()?.nativeElement.contains(this.asNode(event.target))) return;
|
|
172
|
+
this.focusOnOpen = !this.open();
|
|
173
|
+
this.controller.toggle();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (this.opensOn() === "click") this.controller.toggle();
|
|
177
|
+
}
|
|
178
|
+
onKeydown(event) {
|
|
179
|
+
if (event.key === "Escape" && this.open()) {
|
|
180
|
+
event.stopPropagation();
|
|
181
|
+
this.closeAndRefocus();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!this.isIcon() && this.opensOn() === "click" && event.target === this.host.nativeElement && this.contentTrigger() === this.host.nativeElement && (event.key === "Enter" || event.key === " ")) {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
this.controller.toggle();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
onClose() {
|
|
190
|
+
this.closeAndRefocus();
|
|
191
|
+
}
|
|
192
|
+
onDocumentKeydown(event) {
|
|
193
|
+
if (event.key === "Escape" && !event.defaultPrevented) this.closeAndRefocus();
|
|
194
|
+
}
|
|
195
|
+
onDocumentPointerDown(event) {
|
|
196
|
+
const target = this.asNode(event.target);
|
|
197
|
+
if (!target || !this.host.nativeElement.contains(target)) this.controller.close();
|
|
198
|
+
}
|
|
199
|
+
closeAndRefocus() {
|
|
200
|
+
const hadFocus = this.host.nativeElement.contains(this.document.activeElement);
|
|
201
|
+
this.controller.close();
|
|
202
|
+
if (hadFocus) {
|
|
203
|
+
this.returningFocus = true;
|
|
204
|
+
this.triggerElement()?.focus({ preventScroll: true });
|
|
205
|
+
this.returningFocus = false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
reveal() {
|
|
209
|
+
const panel = this.panel().nativeElement;
|
|
210
|
+
this.animation?.cancel();
|
|
211
|
+
this.leftWhileGrowing = false;
|
|
212
|
+
if (!this.shown) {
|
|
213
|
+
this.shown = true;
|
|
214
|
+
panel.classList.add("su-tooltip-shown");
|
|
215
|
+
if (typeof panel.showPopover === "function" && !panel.matches(":popover-open")) panel.showPopover();
|
|
216
|
+
}
|
|
217
|
+
this.place();
|
|
218
|
+
if (this.focusOnOpen) {
|
|
219
|
+
this.focusOnOpen = false;
|
|
220
|
+
this.closeButton()?.nativeElement.focus({ preventScroll: true });
|
|
221
|
+
}
|
|
222
|
+
requestFrame(this.document, () => this.morphed.set(true));
|
|
223
|
+
if (this.moves(panel)) {
|
|
224
|
+
this.animation = this.isIcon() ? this.growFromIcon(panel) : panel.animate([{
|
|
225
|
+
opacity: 0,
|
|
226
|
+
transform: "scale(0.6)"
|
|
227
|
+
}, {
|
|
228
|
+
opacity: 1,
|
|
229
|
+
transform: "none"
|
|
230
|
+
}], {
|
|
231
|
+
duration: this.duration(panel),
|
|
232
|
+
easing: this.easing(panel)
|
|
233
|
+
});
|
|
234
|
+
if (this.animation) this.animation.onfinish = () => this.hideIfLeftWhileGrowing();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
isGrowing() {
|
|
238
|
+
return this.open() && this.animation?.playState === "running";
|
|
239
|
+
}
|
|
240
|
+
hideIfLeftWhileGrowing() {
|
|
241
|
+
this.animation = null;
|
|
242
|
+
if (this.leftWhileGrowing && !this.host.nativeElement.matches(":hover")) this.controller.hide();
|
|
243
|
+
}
|
|
244
|
+
conceal() {
|
|
245
|
+
this.morphed.set(false);
|
|
246
|
+
if (!this.shown) return;
|
|
247
|
+
const panel = this.panel().nativeElement;
|
|
248
|
+
this.animation?.cancel();
|
|
249
|
+
if (!this.moves(panel)) {
|
|
250
|
+
this.removePanel(panel);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const duration = this.duration(panel) * .75;
|
|
254
|
+
const animation = this.isIcon() && this.iconClip ? panel.animate([{ clipPath: this.iconClip.to }, { clipPath: this.iconClip.from }], {
|
|
255
|
+
duration,
|
|
256
|
+
easing: "ease-in"
|
|
257
|
+
}) : panel.animate([{
|
|
258
|
+
opacity: 1,
|
|
259
|
+
transform: "none"
|
|
260
|
+
}, {
|
|
261
|
+
opacity: 0,
|
|
262
|
+
transform: "scale(0.6)"
|
|
263
|
+
}], {
|
|
264
|
+
duration,
|
|
265
|
+
easing: "ease-in"
|
|
266
|
+
});
|
|
267
|
+
animation.onfinish = () => this.removePanel(panel);
|
|
268
|
+
this.animation = animation;
|
|
269
|
+
}
|
|
270
|
+
removePanel(panel) {
|
|
271
|
+
this.shown = false;
|
|
272
|
+
this.animation = null;
|
|
273
|
+
panel.classList.remove("su-tooltip-shown");
|
|
274
|
+
if (typeof panel.hidePopover === "function" && panel.matches(":popover-open")) panel.hidePopover();
|
|
275
|
+
}
|
|
276
|
+
growFromIcon(panel) {
|
|
277
|
+
if (!this.iconClip) return null;
|
|
278
|
+
const duration = this.duration(panel);
|
|
279
|
+
panel.querySelector(".su-tooltip-body")?.animate([
|
|
280
|
+
{ opacity: 0 },
|
|
281
|
+
{
|
|
282
|
+
opacity: 0,
|
|
283
|
+
offset: .4
|
|
284
|
+
},
|
|
285
|
+
{ opacity: 1 }
|
|
286
|
+
], { duration });
|
|
287
|
+
return panel.animate([{ clipPath: this.iconClip.from }, { clipPath: this.iconClip.to }], {
|
|
288
|
+
duration,
|
|
289
|
+
easing: this.easing(panel)
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
place() {
|
|
293
|
+
if (!this.shown) return;
|
|
294
|
+
const panel = this.panel().nativeElement;
|
|
295
|
+
const view = this.document.defaultView;
|
|
296
|
+
const viewport = {
|
|
297
|
+
width: this.document.documentElement.clientWidth,
|
|
298
|
+
height: view?.innerHeight ?? 0
|
|
299
|
+
};
|
|
300
|
+
const rtl = view?.getComputedStyle(this.host.nativeElement).direction === "rtl";
|
|
301
|
+
const size = {
|
|
302
|
+
width: panel.offsetWidth,
|
|
303
|
+
height: panel.offsetHeight
|
|
304
|
+
};
|
|
305
|
+
const icon = this.iconButton()?.nativeElement;
|
|
306
|
+
if (this.isIcon() && icon) {
|
|
307
|
+
const iconRect = icon.getBoundingClientRect();
|
|
308
|
+
const position = suTooltipIconPosition(iconRect, size, {
|
|
309
|
+
placement: this.placement(),
|
|
310
|
+
viewport,
|
|
311
|
+
rtl
|
|
312
|
+
});
|
|
313
|
+
panel.dataset["inline"] = position.inline;
|
|
314
|
+
panel.dataset["block"] = position.block;
|
|
315
|
+
panel.style.left = `${position.x}px`;
|
|
316
|
+
panel.style.top = `${position.y}px`;
|
|
317
|
+
panel.style.setProperty("--su-tooltip-icon-x", `${position.icon.x}px`);
|
|
318
|
+
panel.style.setProperty("--su-tooltip-icon-y", `${position.icon.y}px`);
|
|
319
|
+
const radius = parseFloat(view?.getComputedStyle(panel).borderTopLeftRadius ?? "") || 0;
|
|
320
|
+
this.iconClip = suTooltipIconClip(position, size, iconRect.width, radius);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const position = suTooltipPosition(this.content().nativeElement.getBoundingClientRect(), size, {
|
|
324
|
+
placement: this.placement(),
|
|
325
|
+
offset: this.offset(),
|
|
326
|
+
viewport,
|
|
327
|
+
rtl
|
|
328
|
+
});
|
|
329
|
+
panel.dataset["side"] = position.side;
|
|
330
|
+
panel.style.left = `${position.x}px`;
|
|
331
|
+
panel.style.top = `${position.y}px`;
|
|
332
|
+
panel.style.transformOrigin = `${position.origin.x}px ${position.origin.y}px`;
|
|
333
|
+
panel.style.setProperty("--su-tooltip-arrow-offset", `${position.arrow}px`);
|
|
334
|
+
}
|
|
335
|
+
moves(panel) {
|
|
336
|
+
const view = this.document.defaultView;
|
|
337
|
+
return this.animated() && typeof panel.animate === "function" && !view?.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
338
|
+
}
|
|
339
|
+
duration(panel) {
|
|
340
|
+
const value = this.document.defaultView?.getComputedStyle(panel).getPropertyValue("--su-tooltip-duration").trim();
|
|
341
|
+
return toMilliseconds(value) ?? DEFAULT_DURATION;
|
|
342
|
+
}
|
|
343
|
+
easing(panel) {
|
|
344
|
+
return this.document.defaultView?.getComputedStyle(panel).getPropertyValue("--su-tooltip-easing").trim() || "cubic-bezier(0.2, 0.9, 0.3, 1.1)";
|
|
345
|
+
}
|
|
346
|
+
triggerElement() {
|
|
347
|
+
return this.isIcon() ? this.iconButton()?.nativeElement ?? null : this.contentTrigger();
|
|
348
|
+
}
|
|
349
|
+
contentTrigger() {
|
|
350
|
+
return this.content().nativeElement.querySelector(FOCUSABLE) ?? this.host.nativeElement;
|
|
351
|
+
}
|
|
352
|
+
linkTrigger(trigger, describes, open) {
|
|
353
|
+
if (this.linkedTrigger && this.linkedTrigger !== trigger) this.unlink(this.linkedTrigger);
|
|
354
|
+
this.linkedTrigger = trigger;
|
|
355
|
+
if (!trigger) return;
|
|
356
|
+
const isHost = trigger === this.host.nativeElement;
|
|
357
|
+
if (describes) {
|
|
358
|
+
setToken(trigger, "aria-describedby", this.panelId, true);
|
|
359
|
+
trigger.removeAttribute("aria-expanded");
|
|
360
|
+
trigger.removeAttribute("aria-controls");
|
|
361
|
+
} else {
|
|
362
|
+
setToken(trigger, "aria-describedby", this.panelId, false);
|
|
363
|
+
trigger.setAttribute("aria-expanded", String(open));
|
|
364
|
+
trigger.setAttribute("aria-controls", this.panelId);
|
|
365
|
+
}
|
|
366
|
+
toggleAttribute(trigger, "role", "button", isHost && !describes);
|
|
367
|
+
toggleAttribute(trigger, "tabindex", "0", isHost);
|
|
368
|
+
}
|
|
369
|
+
unlink(trigger) {
|
|
370
|
+
setToken(trigger, "aria-describedby", this.panelId, false);
|
|
371
|
+
trigger.removeAttribute("aria-expanded");
|
|
372
|
+
trigger.removeAttribute("aria-controls");
|
|
373
|
+
if (trigger === this.host.nativeElement) {
|
|
374
|
+
trigger.removeAttribute("role");
|
|
375
|
+
trigger.removeAttribute("tabindex");
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
inPanel(target) {
|
|
379
|
+
const node = this.asNode(target);
|
|
380
|
+
return !!node && this.panel().nativeElement.contains(node);
|
|
381
|
+
}
|
|
382
|
+
asNode(target) {
|
|
383
|
+
return target instanceof Node ? target : null;
|
|
384
|
+
}
|
|
385
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
386
|
+
minVersion: "12.0.0",
|
|
387
|
+
version: "22.2.4",
|
|
388
|
+
ngImport: i0,
|
|
389
|
+
type: SuTooltipComponent,
|
|
390
|
+
deps: [],
|
|
391
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
392
|
+
});
|
|
393
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
394
|
+
minVersion: "17.0.0",
|
|
395
|
+
version: "22.2.4",
|
|
396
|
+
type: SuTooltipComponent,
|
|
397
|
+
isStandalone: true,
|
|
398
|
+
selector: "su-lib-tooltip",
|
|
399
|
+
inputs: {
|
|
400
|
+
text: {
|
|
401
|
+
classPropertyName: "text",
|
|
402
|
+
publicName: "text",
|
|
403
|
+
isSignal: true,
|
|
404
|
+
isRequired: false,
|
|
405
|
+
transformFunction: null
|
|
406
|
+
},
|
|
407
|
+
trigger: {
|
|
408
|
+
classPropertyName: "trigger",
|
|
409
|
+
publicName: "trigger",
|
|
410
|
+
isSignal: true,
|
|
411
|
+
isRequired: false,
|
|
412
|
+
transformFunction: null
|
|
413
|
+
},
|
|
414
|
+
icon: {
|
|
415
|
+
classPropertyName: "icon",
|
|
416
|
+
publicName: "icon",
|
|
417
|
+
isSignal: true,
|
|
418
|
+
isRequired: false,
|
|
419
|
+
transformFunction: null
|
|
420
|
+
},
|
|
421
|
+
placement: {
|
|
422
|
+
classPropertyName: "placement",
|
|
423
|
+
publicName: "placement",
|
|
424
|
+
isSignal: true,
|
|
425
|
+
isRequired: false,
|
|
426
|
+
transformFunction: null
|
|
427
|
+
},
|
|
428
|
+
openOn: {
|
|
429
|
+
classPropertyName: "openOn",
|
|
430
|
+
publicName: "openOn",
|
|
431
|
+
isSignal: true,
|
|
432
|
+
isRequired: false,
|
|
433
|
+
transformFunction: null
|
|
434
|
+
},
|
|
435
|
+
interactive: {
|
|
436
|
+
classPropertyName: "interactive",
|
|
437
|
+
publicName: "interactive",
|
|
438
|
+
isSignal: true,
|
|
439
|
+
isRequired: false,
|
|
440
|
+
transformFunction: null
|
|
441
|
+
},
|
|
442
|
+
animated: {
|
|
443
|
+
classPropertyName: "animated",
|
|
444
|
+
publicName: "animated",
|
|
445
|
+
isSignal: true,
|
|
446
|
+
isRequired: false,
|
|
447
|
+
transformFunction: null
|
|
448
|
+
},
|
|
449
|
+
width: {
|
|
450
|
+
classPropertyName: "width",
|
|
451
|
+
publicName: "width",
|
|
452
|
+
isSignal: true,
|
|
453
|
+
isRequired: false,
|
|
454
|
+
transformFunction: null
|
|
455
|
+
},
|
|
456
|
+
arrow: {
|
|
457
|
+
classPropertyName: "arrow",
|
|
458
|
+
publicName: "arrow",
|
|
459
|
+
isSignal: true,
|
|
460
|
+
isRequired: false,
|
|
461
|
+
transformFunction: null
|
|
462
|
+
},
|
|
463
|
+
offset: {
|
|
464
|
+
classPropertyName: "offset",
|
|
465
|
+
publicName: "offset",
|
|
466
|
+
isSignal: true,
|
|
467
|
+
isRequired: false,
|
|
468
|
+
transformFunction: null
|
|
469
|
+
},
|
|
470
|
+
showDelay: {
|
|
471
|
+
classPropertyName: "showDelay",
|
|
472
|
+
publicName: "showDelay",
|
|
473
|
+
isSignal: true,
|
|
474
|
+
isRequired: false,
|
|
475
|
+
transformFunction: null
|
|
476
|
+
},
|
|
477
|
+
hideDelay: {
|
|
478
|
+
classPropertyName: "hideDelay",
|
|
479
|
+
publicName: "hideDelay",
|
|
480
|
+
isSignal: true,
|
|
481
|
+
isRequired: false,
|
|
482
|
+
transformFunction: null
|
|
483
|
+
},
|
|
484
|
+
disabled: {
|
|
485
|
+
classPropertyName: "disabled",
|
|
486
|
+
publicName: "disabled",
|
|
487
|
+
isSignal: true,
|
|
488
|
+
isRequired: false,
|
|
489
|
+
transformFunction: null
|
|
490
|
+
},
|
|
491
|
+
label: {
|
|
492
|
+
classPropertyName: "label",
|
|
493
|
+
publicName: "label",
|
|
494
|
+
isSignal: true,
|
|
495
|
+
isRequired: false,
|
|
496
|
+
transformFunction: null
|
|
497
|
+
},
|
|
498
|
+
labels: {
|
|
499
|
+
classPropertyName: "labels",
|
|
500
|
+
publicName: "labels",
|
|
501
|
+
isSignal: true,
|
|
502
|
+
isRequired: false,
|
|
503
|
+
transformFunction: null
|
|
504
|
+
},
|
|
505
|
+
open: {
|
|
506
|
+
classPropertyName: "open",
|
|
507
|
+
publicName: "open",
|
|
508
|
+
isSignal: true,
|
|
509
|
+
isRequired: false,
|
|
510
|
+
transformFunction: null
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
outputs: { open: "openChange" },
|
|
514
|
+
host: {
|
|
515
|
+
listeners: {
|
|
516
|
+
"pointerenter": "onPointerEnter($event)",
|
|
517
|
+
"pointerleave": "onPointerLeave($event)",
|
|
518
|
+
"focusin": "onFocusIn($event)",
|
|
519
|
+
"focusout": "onFocusOut($event)",
|
|
520
|
+
"click": "onClick($event)",
|
|
521
|
+
"keydown": "onKeydown($event)"
|
|
522
|
+
},
|
|
523
|
+
properties: {
|
|
524
|
+
"class.su-tooltip-open": "open()",
|
|
525
|
+
"style.--su-tooltip-width": "width()",
|
|
526
|
+
"style.--su-tooltip-offset.px": "offset()"
|
|
527
|
+
},
|
|
528
|
+
classAttribute: "su-tooltip"
|
|
529
|
+
},
|
|
530
|
+
viewQueries: [
|
|
531
|
+
{
|
|
532
|
+
propertyName: "panel",
|
|
533
|
+
first: true,
|
|
534
|
+
predicate: ["panel"],
|
|
535
|
+
descendants: true,
|
|
536
|
+
isSignal: true
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
propertyName: "content",
|
|
540
|
+
first: true,
|
|
541
|
+
predicate: ["content"],
|
|
542
|
+
descendants: true,
|
|
543
|
+
isSignal: true
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
propertyName: "iconButton",
|
|
547
|
+
first: true,
|
|
548
|
+
predicate: ["iconButton"],
|
|
549
|
+
descendants: true,
|
|
550
|
+
isSignal: true
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
propertyName: "closeButton",
|
|
554
|
+
first: true,
|
|
555
|
+
predicate: ["closeButton"],
|
|
556
|
+
descendants: true,
|
|
557
|
+
isSignal: true
|
|
558
|
+
}
|
|
559
|
+
],
|
|
560
|
+
ngImport: i0,
|
|
561
|
+
template: "<span #content class=\"su-tooltip-content\"><ng-content /></span>\n@if (isIcon()) {\n <button\n #iconButton\n type=\"button\"\n class=\"su-tooltip-icon\"\n [attr.aria-label]=\"label() ?? texts().more\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\">\n <ng-container [ngTemplateOutlet]=\"iconGlyph\" />\n </button>\n}\n<ng-template #iconGlyph>\n @if (iconTemplate(); as glyph) {\n <ng-container [ngTemplateOutlet]=\"glyph\" />\n } @else if (iconText()) {\n <span class=\"su-tooltip-icon-text\" aria-hidden=\"true\">{{ iconText() }}</span>\n } @else {\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"M9 9a3 3 0 1 1 4.5 2.6c-.9.5-1.5 1.2-1.5 2.2V15\" />\n <path d=\"M12 19h.01\" />\n </svg>\n }\n</ng-template>\n<div\n #panel\n popover=\"manual\"\n class=\"su-tooltip-panel\"\n [id]=\"panelId\"\n [attr.role]=\"describes() ? 'tooltip' : null\"\n [class.su-tooltip-panel-icon]=\"isIcon()\"\n [class.su-tooltip-interactive]=\"isInteractive()\">\n @if (isIcon()) {\n <button\n #closeButton\n type=\"button\"\n class=\"su-tooltip-close\"\n [class.su-tooltip-morphed]=\"morphed()\"\n [attr.aria-label]=\"texts().close\"\n (click)=\"onClose()\">\n <span class=\"su-tooltip-glyph su-tooltip-glyph-icon\">\n <ng-container [ngTemplateOutlet]=\"iconGlyph\" />\n </span>\n <span class=\"su-tooltip-glyph su-tooltip-glyph-close\">\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"M6 6l12 12M18 6L6 18\" />\n </svg>\n </span>\n </button>\n } @else if (arrow()) {\n <span class=\"su-tooltip-arrow\" aria-hidden=\"true\"></span>\n }\n <div class=\"su-tooltip-body\">\n @if (template(); as body) {\n <ng-container [ngTemplateOutlet]=\"body\" />\n } @else {\n {{ plainText() }}\n }\n </div>\n</div>\n",
|
|
562
|
+
styles: [":host{display:inline}.su-tooltip-content:not(:empty)+.su-tooltip-icon{margin-inline-start:.25em}.su-tooltip-icon,.su-tooltip-close{block-size:var(--su-tooltip-icon-size, 1.375rem);border:0;border-radius:50%;cursor:pointer;display:inline-grid;inline-size:var(--su-tooltip-icon-size, 1.375rem);padding:0;place-items:center}.su-tooltip-icon:focus-visible,.su-tooltip-close:focus-visible{outline:var(--su-tooltip-focus-ring, 2px solid currentColor);outline-offset:2px}.su-tooltip-icon svg,.su-tooltip-close svg{block-size:62%;fill:none;inline-size:62%;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.5}.su-tooltip-icon{background:var(--su-tooltip-icon-background, var(--su-tooltip-background, #1f2937));color:var(--su-tooltip-icon-color, var(--su-tooltip-text-color, #f9fafb));vertical-align:middle}.su-tooltip-panel{background:var(--su-tooltip-background, #1f2937);border:var(--su-tooltip-border, 0);border-radius:var(--su-tooltip-radius, .375rem);box-shadow:var(--su-tooltip-shadow, 0 6px 20px rgba(0, 0, 0, .18));box-sizing:border-box;color:var(--su-tooltip-text-color, #f9fafb);display:none;font-family:var(--su-tooltip-font-family, inherit);font-size:var(--su-tooltip-font-size, .875rem);font-weight:400;height:max-content;inset:auto;line-height:var(--su-tooltip-line-height, 1.45);margin:0;max-width:min(var(--su-tooltip-max-width, 20rem),100vw - 16px);overflow:visible;padding:var(--su-tooltip-padding, .375rem .625rem);pointer-events:none;position:fixed;text-align:start;white-space:normal;width:var(--su-tooltip-width, max-content);z-index:var(--su-tooltip-z-index, 1000)}.su-tooltip-panel.su-tooltip-shown{display:block}.su-tooltip-panel.su-tooltip-interactive{pointer-events:auto}.su-tooltip-panel.su-tooltip-interactive:before{content:\"\";position:absolute}.su-tooltip-panel[data-side=top]:before{block-size:calc(var(--su-tooltip-offset, 8px) + 2px);inset-inline:0;top:100%}.su-tooltip-panel[data-side=bottom]:before{block-size:calc(var(--su-tooltip-offset, 8px) + 2px);bottom:100%;inset-inline:0}.su-tooltip-panel[data-side=left]:before{inline-size:calc(var(--su-tooltip-offset, 8px) + 2px);inset-block:0;left:100%}.su-tooltip-panel[data-side=right]:before{inline-size:calc(var(--su-tooltip-offset, 8px) + 2px);inset-block:0;right:100%}.su-tooltip-arrow{--su-tooltip-arrow-half: calc(var(--su-tooltip-arrow-size, 8px) / -2);background:inherit;block-size:var(--su-tooltip-arrow-size, 8px);inline-size:var(--su-tooltip-arrow-size, 8px);position:absolute;rotate:45deg}[data-side=top]>.su-tooltip-arrow{bottom:var(--su-tooltip-arrow-half);left:var(--su-tooltip-arrow-offset, 50%);translate:-50% 0}[data-side=bottom]>.su-tooltip-arrow{left:var(--su-tooltip-arrow-offset, 50%);top:var(--su-tooltip-arrow-half);translate:-50% 0}[data-side=left]>.su-tooltip-arrow{right:var(--su-tooltip-arrow-half);top:var(--su-tooltip-arrow-offset, 50%);translate:0 -50%}[data-side=right]>.su-tooltip-arrow{left:var(--su-tooltip-arrow-half);top:var(--su-tooltip-arrow-offset, 50%);translate:0 -50%}.su-tooltip-panel-icon{--su-tooltip-icon-gap: .5rem;background:var(--su-tooltip-icon-background, var(--su-tooltip-background, #1f2937));border-radius:var(--su-tooltip-icon-radius, .875rem);color:var(--su-tooltip-icon-color, var(--su-tooltip-text-color, #f9fafb));max-width:calc(100vw - 16px);min-block-size:calc(var(--su-tooltip-icon-size, 1.375rem) + 12px);overflow:hidden;padding:var(--su-tooltip-icon-padding, .5rem .75rem);width:var(--su-tooltip-width, 16rem)}.su-tooltip-panel-icon:not([data-inline=right]){padding-left:calc(6px + var(--su-tooltip-icon-size, 1.375rem) + var(--su-tooltip-icon-gap))}.su-tooltip-panel-icon[data-inline=right]{padding-right:calc(6px + var(--su-tooltip-icon-size, 1.375rem) + var(--su-tooltip-icon-gap))}.su-tooltip-close{background:transparent;color:inherit;display:grid;left:var(--su-tooltip-icon-x, 6px);position:absolute;top:var(--su-tooltip-icon-y, 6px)}.su-tooltip-icon-text{font-size:calc(var(--su-tooltip-icon-size, 1.375rem) * .6);font-weight:700;line-height:1}.su-tooltip-glyph{block-size:100%;display:grid;grid-area:1/1;inline-size:100%;place-items:center;transition:opacity var(--su-tooltip-duration, .2s) ease,rotate var(--su-tooltip-duration, .2s) var(--su-tooltip-easing, cubic-bezier(.2, .9, .3, 1.1))}.su-tooltip-glyph-close,.su-tooltip-morphed .su-tooltip-glyph-icon{opacity:0;rotate:-90deg}.su-tooltip-morphed .su-tooltip-glyph-close{opacity:1;rotate:0deg}@media(prefers-reduced-motion:reduce){.su-tooltip-glyph{transition:none}}\n"],
|
|
563
|
+
dependencies: [{
|
|
564
|
+
kind: "directive",
|
|
565
|
+
type: NgTemplateOutlet,
|
|
566
|
+
selector: "[ngTemplateOutlet]",
|
|
567
|
+
inputs: [
|
|
568
|
+
"ngTemplateOutletContext",
|
|
569
|
+
"ngTemplateOutlet",
|
|
570
|
+
"ngTemplateOutletInjector"
|
|
571
|
+
]
|
|
572
|
+
}],
|
|
573
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
574
|
+
});
|
|
575
|
+
};
|
|
576
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
577
|
+
minVersion: "12.0.0",
|
|
578
|
+
version: "22.2.4",
|
|
579
|
+
ngImport: i0,
|
|
580
|
+
type: SuTooltipComponent,
|
|
581
|
+
decorators: [{
|
|
582
|
+
type: Component,
|
|
583
|
+
args: [{
|
|
584
|
+
selector: "su-lib-tooltip",
|
|
585
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
586
|
+
imports: [NgTemplateOutlet],
|
|
587
|
+
host: {
|
|
588
|
+
class: "su-tooltip",
|
|
589
|
+
"[class.su-tooltip-open]": "open()",
|
|
590
|
+
"[style.--su-tooltip-width]": "width()",
|
|
591
|
+
"[style.--su-tooltip-offset.px]": "offset()",
|
|
592
|
+
"(pointerenter)": "onPointerEnter($event)",
|
|
593
|
+
"(pointerleave)": "onPointerLeave($event)",
|
|
594
|
+
"(focusin)": "onFocusIn($event)",
|
|
595
|
+
"(focusout)": "onFocusOut($event)",
|
|
596
|
+
"(click)": "onClick($event)",
|
|
597
|
+
"(keydown)": "onKeydown($event)"
|
|
598
|
+
},
|
|
599
|
+
template: "<span #content class=\"su-tooltip-content\"><ng-content /></span>\n@if (isIcon()) {\n <button\n #iconButton\n type=\"button\"\n class=\"su-tooltip-icon\"\n [attr.aria-label]=\"label() ?? texts().more\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\">\n <ng-container [ngTemplateOutlet]=\"iconGlyph\" />\n </button>\n}\n<ng-template #iconGlyph>\n @if (iconTemplate(); as glyph) {\n <ng-container [ngTemplateOutlet]=\"glyph\" />\n } @else if (iconText()) {\n <span class=\"su-tooltip-icon-text\" aria-hidden=\"true\">{{ iconText() }}</span>\n } @else {\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"M9 9a3 3 0 1 1 4.5 2.6c-.9.5-1.5 1.2-1.5 2.2V15\" />\n <path d=\"M12 19h.01\" />\n </svg>\n }\n</ng-template>\n<div\n #panel\n popover=\"manual\"\n class=\"su-tooltip-panel\"\n [id]=\"panelId\"\n [attr.role]=\"describes() ? 'tooltip' : null\"\n [class.su-tooltip-panel-icon]=\"isIcon()\"\n [class.su-tooltip-interactive]=\"isInteractive()\">\n @if (isIcon()) {\n <button\n #closeButton\n type=\"button\"\n class=\"su-tooltip-close\"\n [class.su-tooltip-morphed]=\"morphed()\"\n [attr.aria-label]=\"texts().close\"\n (click)=\"onClose()\">\n <span class=\"su-tooltip-glyph su-tooltip-glyph-icon\">\n <ng-container [ngTemplateOutlet]=\"iconGlyph\" />\n </span>\n <span class=\"su-tooltip-glyph su-tooltip-glyph-close\">\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n <path d=\"M6 6l12 12M18 6L6 18\" />\n </svg>\n </span>\n </button>\n } @else if (arrow()) {\n <span class=\"su-tooltip-arrow\" aria-hidden=\"true\"></span>\n }\n <div class=\"su-tooltip-body\">\n @if (template(); as body) {\n <ng-container [ngTemplateOutlet]=\"body\" />\n } @else {\n {{ plainText() }}\n }\n </div>\n</div>\n",
|
|
600
|
+
styles: [":host{display:inline}.su-tooltip-content:not(:empty)+.su-tooltip-icon{margin-inline-start:.25em}.su-tooltip-icon,.su-tooltip-close{block-size:var(--su-tooltip-icon-size, 1.375rem);border:0;border-radius:50%;cursor:pointer;display:inline-grid;inline-size:var(--su-tooltip-icon-size, 1.375rem);padding:0;place-items:center}.su-tooltip-icon:focus-visible,.su-tooltip-close:focus-visible{outline:var(--su-tooltip-focus-ring, 2px solid currentColor);outline-offset:2px}.su-tooltip-icon svg,.su-tooltip-close svg{block-size:62%;fill:none;inline-size:62%;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.5}.su-tooltip-icon{background:var(--su-tooltip-icon-background, var(--su-tooltip-background, #1f2937));color:var(--su-tooltip-icon-color, var(--su-tooltip-text-color, #f9fafb));vertical-align:middle}.su-tooltip-panel{background:var(--su-tooltip-background, #1f2937);border:var(--su-tooltip-border, 0);border-radius:var(--su-tooltip-radius, .375rem);box-shadow:var(--su-tooltip-shadow, 0 6px 20px rgba(0, 0, 0, .18));box-sizing:border-box;color:var(--su-tooltip-text-color, #f9fafb);display:none;font-family:var(--su-tooltip-font-family, inherit);font-size:var(--su-tooltip-font-size, .875rem);font-weight:400;height:max-content;inset:auto;line-height:var(--su-tooltip-line-height, 1.45);margin:0;max-width:min(var(--su-tooltip-max-width, 20rem),100vw - 16px);overflow:visible;padding:var(--su-tooltip-padding, .375rem .625rem);pointer-events:none;position:fixed;text-align:start;white-space:normal;width:var(--su-tooltip-width, max-content);z-index:var(--su-tooltip-z-index, 1000)}.su-tooltip-panel.su-tooltip-shown{display:block}.su-tooltip-panel.su-tooltip-interactive{pointer-events:auto}.su-tooltip-panel.su-tooltip-interactive:before{content:\"\";position:absolute}.su-tooltip-panel[data-side=top]:before{block-size:calc(var(--su-tooltip-offset, 8px) + 2px);inset-inline:0;top:100%}.su-tooltip-panel[data-side=bottom]:before{block-size:calc(var(--su-tooltip-offset, 8px) + 2px);bottom:100%;inset-inline:0}.su-tooltip-panel[data-side=left]:before{inline-size:calc(var(--su-tooltip-offset, 8px) + 2px);inset-block:0;left:100%}.su-tooltip-panel[data-side=right]:before{inline-size:calc(var(--su-tooltip-offset, 8px) + 2px);inset-block:0;right:100%}.su-tooltip-arrow{--su-tooltip-arrow-half: calc(var(--su-tooltip-arrow-size, 8px) / -2);background:inherit;block-size:var(--su-tooltip-arrow-size, 8px);inline-size:var(--su-tooltip-arrow-size, 8px);position:absolute;rotate:45deg}[data-side=top]>.su-tooltip-arrow{bottom:var(--su-tooltip-arrow-half);left:var(--su-tooltip-arrow-offset, 50%);translate:-50% 0}[data-side=bottom]>.su-tooltip-arrow{left:var(--su-tooltip-arrow-offset, 50%);top:var(--su-tooltip-arrow-half);translate:-50% 0}[data-side=left]>.su-tooltip-arrow{right:var(--su-tooltip-arrow-half);top:var(--su-tooltip-arrow-offset, 50%);translate:0 -50%}[data-side=right]>.su-tooltip-arrow{left:var(--su-tooltip-arrow-half);top:var(--su-tooltip-arrow-offset, 50%);translate:0 -50%}.su-tooltip-panel-icon{--su-tooltip-icon-gap: .5rem;background:var(--su-tooltip-icon-background, var(--su-tooltip-background, #1f2937));border-radius:var(--su-tooltip-icon-radius, .875rem);color:var(--su-tooltip-icon-color, var(--su-tooltip-text-color, #f9fafb));max-width:calc(100vw - 16px);min-block-size:calc(var(--su-tooltip-icon-size, 1.375rem) + 12px);overflow:hidden;padding:var(--su-tooltip-icon-padding, .5rem .75rem);width:var(--su-tooltip-width, 16rem)}.su-tooltip-panel-icon:not([data-inline=right]){padding-left:calc(6px + var(--su-tooltip-icon-size, 1.375rem) + var(--su-tooltip-icon-gap))}.su-tooltip-panel-icon[data-inline=right]{padding-right:calc(6px + var(--su-tooltip-icon-size, 1.375rem) + var(--su-tooltip-icon-gap))}.su-tooltip-close{background:transparent;color:inherit;display:grid;left:var(--su-tooltip-icon-x, 6px);position:absolute;top:var(--su-tooltip-icon-y, 6px)}.su-tooltip-icon-text{font-size:calc(var(--su-tooltip-icon-size, 1.375rem) * .6);font-weight:700;line-height:1}.su-tooltip-glyph{block-size:100%;display:grid;grid-area:1/1;inline-size:100%;place-items:center;transition:opacity var(--su-tooltip-duration, .2s) ease,rotate var(--su-tooltip-duration, .2s) var(--su-tooltip-easing, cubic-bezier(.2, .9, .3, 1.1))}.su-tooltip-glyph-close,.su-tooltip-morphed .su-tooltip-glyph-icon{opacity:0;rotate:-90deg}.su-tooltip-morphed .su-tooltip-glyph-close{opacity:1;rotate:0deg}@media(prefers-reduced-motion:reduce){.su-tooltip-glyph{transition:none}}\n"]
|
|
601
|
+
}]
|
|
602
|
+
}],
|
|
603
|
+
ctorParameters: () => [],
|
|
604
|
+
propDecorators: {
|
|
605
|
+
text: [{
|
|
606
|
+
type: i0.Input,
|
|
607
|
+
args: [{
|
|
608
|
+
isSignal: true,
|
|
609
|
+
alias: "text",
|
|
610
|
+
required: false
|
|
611
|
+
}]
|
|
612
|
+
}],
|
|
613
|
+
trigger: [{
|
|
614
|
+
type: i0.Input,
|
|
615
|
+
args: [{
|
|
616
|
+
isSignal: true,
|
|
617
|
+
alias: "trigger",
|
|
618
|
+
required: false
|
|
619
|
+
}]
|
|
620
|
+
}],
|
|
621
|
+
icon: [{
|
|
622
|
+
type: i0.Input,
|
|
623
|
+
args: [{
|
|
624
|
+
isSignal: true,
|
|
625
|
+
alias: "icon",
|
|
626
|
+
required: false
|
|
627
|
+
}]
|
|
628
|
+
}],
|
|
629
|
+
placement: [{
|
|
630
|
+
type: i0.Input,
|
|
631
|
+
args: [{
|
|
632
|
+
isSignal: true,
|
|
633
|
+
alias: "placement",
|
|
634
|
+
required: false
|
|
635
|
+
}]
|
|
636
|
+
}],
|
|
637
|
+
openOn: [{
|
|
638
|
+
type: i0.Input,
|
|
639
|
+
args: [{
|
|
640
|
+
isSignal: true,
|
|
641
|
+
alias: "openOn",
|
|
642
|
+
required: false
|
|
643
|
+
}]
|
|
644
|
+
}],
|
|
645
|
+
interactive: [{
|
|
646
|
+
type: i0.Input,
|
|
647
|
+
args: [{
|
|
648
|
+
isSignal: true,
|
|
649
|
+
alias: "interactive",
|
|
650
|
+
required: false
|
|
651
|
+
}]
|
|
652
|
+
}],
|
|
653
|
+
animated: [{
|
|
654
|
+
type: i0.Input,
|
|
655
|
+
args: [{
|
|
656
|
+
isSignal: true,
|
|
657
|
+
alias: "animated",
|
|
658
|
+
required: false
|
|
659
|
+
}]
|
|
660
|
+
}],
|
|
661
|
+
width: [{
|
|
662
|
+
type: i0.Input,
|
|
663
|
+
args: [{
|
|
664
|
+
isSignal: true,
|
|
665
|
+
alias: "width",
|
|
666
|
+
required: false
|
|
667
|
+
}]
|
|
668
|
+
}],
|
|
669
|
+
arrow: [{
|
|
670
|
+
type: i0.Input,
|
|
671
|
+
args: [{
|
|
672
|
+
isSignal: true,
|
|
673
|
+
alias: "arrow",
|
|
674
|
+
required: false
|
|
675
|
+
}]
|
|
676
|
+
}],
|
|
677
|
+
offset: [{
|
|
678
|
+
type: i0.Input,
|
|
679
|
+
args: [{
|
|
680
|
+
isSignal: true,
|
|
681
|
+
alias: "offset",
|
|
682
|
+
required: false
|
|
683
|
+
}]
|
|
684
|
+
}],
|
|
685
|
+
showDelay: [{
|
|
686
|
+
type: i0.Input,
|
|
687
|
+
args: [{
|
|
688
|
+
isSignal: true,
|
|
689
|
+
alias: "showDelay",
|
|
690
|
+
required: false
|
|
691
|
+
}]
|
|
692
|
+
}],
|
|
693
|
+
hideDelay: [{
|
|
694
|
+
type: i0.Input,
|
|
695
|
+
args: [{
|
|
696
|
+
isSignal: true,
|
|
697
|
+
alias: "hideDelay",
|
|
698
|
+
required: false
|
|
699
|
+
}]
|
|
700
|
+
}],
|
|
701
|
+
disabled: [{
|
|
702
|
+
type: i0.Input,
|
|
703
|
+
args: [{
|
|
704
|
+
isSignal: true,
|
|
705
|
+
alias: "disabled",
|
|
706
|
+
required: false
|
|
707
|
+
}]
|
|
708
|
+
}],
|
|
709
|
+
label: [{
|
|
710
|
+
type: i0.Input,
|
|
711
|
+
args: [{
|
|
712
|
+
isSignal: true,
|
|
713
|
+
alias: "label",
|
|
714
|
+
required: false
|
|
715
|
+
}]
|
|
716
|
+
}],
|
|
717
|
+
labels: [{
|
|
718
|
+
type: i0.Input,
|
|
719
|
+
args: [{
|
|
720
|
+
isSignal: true,
|
|
721
|
+
alias: "labels",
|
|
722
|
+
required: false
|
|
723
|
+
}]
|
|
724
|
+
}],
|
|
725
|
+
open: [{
|
|
726
|
+
type: i0.Input,
|
|
727
|
+
args: [{
|
|
728
|
+
isSignal: true,
|
|
729
|
+
alias: "open",
|
|
730
|
+
required: false
|
|
731
|
+
}]
|
|
732
|
+
}, {
|
|
733
|
+
type: i0.Output,
|
|
734
|
+
args: ["openChange"]
|
|
735
|
+
}],
|
|
736
|
+
panel: [{
|
|
737
|
+
type: i0.ViewChild,
|
|
738
|
+
args: ["panel", { isSignal: true }]
|
|
739
|
+
}],
|
|
740
|
+
content: [{
|
|
741
|
+
type: i0.ViewChild,
|
|
742
|
+
args: ["content", { isSignal: true }]
|
|
743
|
+
}],
|
|
744
|
+
iconButton: [{
|
|
745
|
+
type: i0.ViewChild,
|
|
746
|
+
args: ["iconButton", { isSignal: true }]
|
|
747
|
+
}],
|
|
748
|
+
closeButton: [{
|
|
749
|
+
type: i0.ViewChild,
|
|
750
|
+
args: ["closeButton", { isSignal: true }]
|
|
751
|
+
}]
|
|
752
|
+
}
|
|
753
|
+
});
|
|
455
754
|
function setToken(element, name, token, present) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (next.length) {
|
|
461
|
-
element.setAttribute(name, next.join(' '));
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
element.removeAttribute(name);
|
|
465
|
-
}
|
|
755
|
+
const tokens = (element.getAttribute(name) ?? "").split(/\s+/).filter((item) => item && item !== token);
|
|
756
|
+
const next = present ? [...tokens, token] : tokens;
|
|
757
|
+
if (next.length) element.setAttribute(name, next.join(" "));
|
|
758
|
+
else element.removeAttribute(name);
|
|
466
759
|
}
|
|
467
760
|
function toggleAttribute(element, name, value, present) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
else {
|
|
472
|
-
element.removeAttribute(name);
|
|
473
|
-
}
|
|
761
|
+
if (present) element.setAttribute(name, value);
|
|
762
|
+
else element.removeAttribute(name);
|
|
474
763
|
}
|
|
475
764
|
function toMilliseconds(value) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
const amount = Number(match[1]);
|
|
481
|
-
return match[2] === 's' ? amount * 1000 : amount;
|
|
765
|
+
const match = value?.match(/^([\d.]+)(ms|s)$/);
|
|
766
|
+
if (!match) return null;
|
|
767
|
+
const amount = Number(match[1]);
|
|
768
|
+
return match[2] === "s" ? amount * 1e3 : amount;
|
|
482
769
|
}
|
|
483
770
|
function requestFrame(document, callback) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
callback();
|
|
490
|
-
}
|
|
771
|
+
const view = document.defaultView;
|
|
772
|
+
if (view?.requestAnimationFrame) view.requestAnimationFrame(callback);
|
|
773
|
+
else callback();
|
|
491
774
|
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Generated bundle index. Do not edit.
|
|
495
|
-
*/
|
|
496
|
-
|
|
497
775
|
export { SuTooltipComponent };
|
|
498
|
-
|
|
776
|
+
|
|
777
|
+
//# sourceMappingURL=su-labs-tooltip.mjs.map
|