@su-labs/tooltip 21.0.0 → 22.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.
@@ -1,498 +1,777 @@
1
- import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { input, booleanAttribute, numberAttribute, model, computed, TemplateRef, signal, inject, ElementRef, viewChild, DestroyRef, effect, untracked, afterRenderEffect, ChangeDetectionStrategy, Component } from '@angular/core';
4
- import { SU_TOOLTIP_LABELS, SuTooltipController, suTooltipIconPosition, suTooltipIconClip, suTooltipPosition } from '@su-labs/core/tooltip';
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 = 'a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';
6
+ const FOCUSABLE = "a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]";
8
7
  const DEFAULT_DURATION = 200;
9
- /**
10
- * A tooltip over `SuTooltipController` from `@su-labs/core/tooltip`. Its content is the trigger, `text` is what the
11
- * tooltip shows. It opens on hover and focus or on click (`openOn`), beside the trigger with an arrow, and grows out
12
- * of it. With `trigger="icon"` a "?" button follows the content and the tooltip grows out of that icon, which turns
13
- * into its close button.
14
- */
15
- class SuTooltipComponent {
16
- /** What the tooltip shows: a text, or an `<ng-template>` for links, formatting or any other markup */
17
- text = input('', ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
18
- /** The trigger: the content between the tags, or a "?" icon after it that grows into the tooltip @default 'content' */
19
- trigger = input('content', ...(ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []));
20
- /** The icon instead of the "?": a short text such as `i` or `!`, or an `<ng-template>` with your own SVG */
21
- icon = input('', ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
22
- /** The side the tooltip opens on, lined up with the trigger's start or end with `-start` and `-end` @default 'top' */
23
- placement = input('top', ...(ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []));
24
- /** What opens it: `hover` (and keyboard focus) or `click` @default 'hover', 'click' for the icon */
25
- openOn = input(...(ngDevMode ? [undefined, { debugName: "openOn" }] : /* istanbul ignore next */ []));
26
- /**
27
- * The pointer can move onto the tooltip, e.g. to click a link in it; otherwise the pointer goes through it and
28
- * it closes as soon as the pointer leaves the trigger. Always on with `click` @default false
29
- */
30
- interactive = input(false, { ...(ngDevMode ? { debugName: "interactive" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
31
- /** Grows out of the trigger when it opens and back into it when it closes; off when the user prefers less motion @default true */
32
- animated = input(true, { ...(ngDevMode ? { debugName: "animated" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
33
- /** The tooltip's width, any CSS length; without it, it fits its text up to `--su-tooltip-max-width` (`16rem` for the icon) */
34
- width = input(...(ngDevMode ? [undefined, { debugName: "width" }] : /* istanbul ignore next */ []));
35
- /** The arrow pointing at the trigger, beside content triggers @default true */
36
- arrow = input(true, { ...(ngDevMode ? { debugName: "arrow" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
37
- /** Pixels between the trigger and the tooltip @default 8 */
38
- offset = input(8, { ...(ngDevMode ? { debugName: "offset" } : /* istanbul ignore next */ {}), transform: numberAttribute });
39
- /** Milliseconds the pointer rests on the trigger before it opens @default 300 */
40
- showDelay = input(300, { ...(ngDevMode ? { debugName: "showDelay" } : /* istanbul ignore next */ {}), transform: numberAttribute });
41
- /** Milliseconds before it closes once the pointer leaves @default 100 */
42
- hideDelay = input(100, { ...(ngDevMode ? { debugName: "hideDelay" } : /* istanbul ignore next */ {}), transform: numberAttribute });
43
- /** Doesn't open, and closes if open @default false */
44
- disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
45
- /** The icon's name for screen readers @default labels.more */
46
- label = input(...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
47
- /** Texts to replace, e.g. in the page's language */
48
- labels = input({}, ...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
49
- /** Whether the tooltip is open; setting it opens or closes it at once */
50
- open = model(false, ...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
51
- panelId = `su-tooltip-${nextTooltipId++}`;
52
- isIcon = computed(() => this.trigger() === 'icon', ...(ngDevMode ? [{ debugName: "isIcon" }] : /* istanbul ignore next */ []));
53
- opensOn = computed(() => this.openOn() ?? (this.isIcon() ? 'click' : 'hover'), ...(ngDevMode ? [{ debugName: "opensOn" }] : /* istanbul ignore next */ []));
54
- isInteractive = computed(() => this.interactive() || this.opensOn() === 'click', ...(ngDevMode ? [{ debugName: "isInteractive" }] : /* istanbul ignore next */ []));
55
- /** A hover tooltip describes its trigger; the others are shown and hidden by a button */
56
- describes = computed(() => !this.isIcon() && this.opensOn() === 'hover', ...(ngDevMode ? [{ debugName: "describes" }] : /* istanbul ignore next */ []));
57
- template = computed(() => {
58
- const text = this.text();
59
- return text instanceof TemplateRef ? text : null;
60
- }, ...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
61
- plainText = computed(() => {
62
- const text = this.text();
63
- return typeof text === 'string' ? text : '';
64
- }, ...(ngDevMode ? [{ debugName: "plainText" }] : /* istanbul ignore next */ []));
65
- iconTemplate = computed(() => {
66
- const icon = this.icon();
67
- return icon instanceof TemplateRef ? icon : null;
68
- }, ...(ngDevMode ? [{ debugName: "iconTemplate" }] : /* istanbul ignore next */ []));
69
- iconText = computed(() => {
70
- const icon = this.icon();
71
- return typeof icon === 'string' ? icon : '';
72
- }, ...(ngDevMode ? [{ debugName: "iconText" }] : /* istanbul ignore next */ []));
73
- texts = computed(() => ({
74
- ...SU_TOOLTIP_LABELS,
75
- ...this.labels(),
76
- }), ...(ngDevMode ? [{ debugName: "texts" }] : /* istanbul ignore next */ []));
77
- /** The close button shows the "×" once the icon has opened, so the "?" turns into it */
78
- morphed = signal(false, ...(ngDevMode ? [{ debugName: "morphed" }] : /* istanbul ignore next */ []));
79
- host = inject(ElementRef);
80
- document = inject(DOCUMENT);
81
- panel = viewChild.required('panel');
82
- content = viewChild.required('content');
83
- iconButton = viewChild('iconButton', ...(ngDevMode ? [{ debugName: "iconButton" }] : /* istanbul ignore next */ []));
84
- closeButton = viewChild('closeButton', ...(ngDevMode ? [{ debugName: "closeButton" }] : /* istanbul ignore next */ []));
85
- controller = new SuTooltipController();
86
- animation = null;
87
- iconClip = null;
88
- shown = false;
89
- /** The close button takes focus once the icon tooltip opens, after the user opened it with the icon */
90
- focusOnOpen = false;
91
- leftWhileGrowing = false;
92
- /** Focus coming back to the trigger after the tooltip closed doesn't open it again */
93
- returningFocus = false;
94
- linkedTrigger = null;
95
- constructor() {
96
- const unsubscribe = this.controller.state.subscribe(state => this.open.set(state.open));
97
- const destroyRef = inject(DestroyRef);
98
- destroyRef.onDestroy(() => {
99
- unsubscribe();
100
- this.controller.cancel();
101
- this.animation?.cancel();
102
- });
103
- effect(() => {
104
- const delays = {
105
- showDelay: this.showDelay(),
106
- hideDelay: this.hideDelay(),
107
- };
108
- untracked(() => this.controller.setDelays(delays));
109
- });
110
- effect(() => {
111
- const open = this.open() && !this.disabled();
112
- untracked(() => {
113
- this.controller.setOpen(open);
114
- this.open.set(open);
115
- });
116
- });
117
- effect(onCleanup => {
118
- if (!this.open()) {
119
- return;
120
- }
121
- const onKeydown = (event) => this.onDocumentKeydown(event);
122
- const onPointerDown = (event) => this.onDocumentPointerDown(event);
123
- const onMove = () => this.place();
124
- const view = this.document.defaultView;
125
- this.document.addEventListener('keydown', onKeydown);
126
- this.document.addEventListener('pointerdown', onPointerDown);
127
- view?.addEventListener('scroll', onMove, true);
128
- view?.addEventListener('resize', onMove);
129
- onCleanup(() => {
130
- this.document.removeEventListener('keydown', onKeydown);
131
- this.document.removeEventListener('pointerdown', onPointerDown);
132
- view?.removeEventListener('scroll', onMove, true);
133
- view?.removeEventListener('resize', onMove);
134
- });
135
- });
136
- afterRenderEffect(() => {
137
- const open = this.open();
138
- untracked(() => (open ? this.reveal() : this.conceal()));
139
- });
140
- afterRenderEffect(() => {
141
- const trigger = this.isIcon() ? null : this.contentTrigger();
142
- const describes = this.describes();
143
- const open = this.open();
144
- untracked(() => this.linkTrigger(trigger, describes, open));
145
- });
146
- }
147
- /** Opens the tooltip now */
148
- show() {
149
- this.controller.open();
150
- }
151
- /** Closes the tooltip now */
152
- hide() {
153
- this.controller.close();
154
- }
155
- /** Opens or closes the tooltip now */
156
- toggle() {
157
- this.controller.toggle();
158
- }
159
- onPointerEnter(event) {
160
- if (this.disabled() ||
161
- event.pointerType === 'touch' ||
162
- this.opensOn() !== 'hover') {
163
- return;
164
- }
165
- this.controller.show();
166
- }
167
- onPointerLeave(event) {
168
- if (event.pointerType === 'touch' || this.opensOn() !== 'hover') {
169
- return;
170
- }
171
- if (this.isGrowing()) {
172
- this.leftWhileGrowing = true;
173
- return;
174
- }
175
- this.controller.hide();
176
- }
177
- onFocusIn(event) {
178
- if (this.inPanel(event.target)) {
179
- this.controller.cancel();
180
- return;
181
- }
182
- if (!this.disabled() &&
183
- !this.returningFocus &&
184
- this.opensOn() === 'hover') {
185
- this.controller.open();
186
- }
187
- }
188
- onFocusOut(event) {
189
- const next = this.asNode(event.relatedTarget);
190
- if (!next || this.host.nativeElement.contains(next)) {
191
- return;
192
- }
193
- this.controller.close();
194
- }
195
- onClick(event) {
196
- if (this.disabled() || this.inPanel(event.target)) {
197
- return;
198
- }
199
- if (this.isIcon()) {
200
- if (!this.iconButton()?.nativeElement.contains(this.asNode(event.target))) {
201
- return;
202
- }
203
- this.focusOnOpen = !this.open();
204
- this.controller.toggle();
205
- return;
206
- }
207
- if (this.opensOn() === 'click') {
208
- this.controller.toggle();
209
- }
210
- }
211
- onKeydown(event) {
212
- if (event.key === 'Escape' && this.open()) {
213
- event.stopPropagation();
214
- this.closeAndRefocus();
215
- return;
216
- }
217
- const isHostButton = !this.isIcon() &&
218
- this.opensOn() === 'click' &&
219
- event.target === this.host.nativeElement &&
220
- this.contentTrigger() === this.host.nativeElement;
221
- if (isHostButton && (event.key === 'Enter' || event.key === ' ')) {
222
- event.preventDefault();
223
- this.controller.toggle();
224
- }
225
- }
226
- onClose() {
227
- this.closeAndRefocus();
228
- }
229
- onDocumentKeydown(event) {
230
- if (event.key === 'Escape' && !event.defaultPrevented) {
231
- this.closeAndRefocus();
232
- }
233
- }
234
- onDocumentPointerDown(event) {
235
- const target = this.asNode(event.target);
236
- if (!target || !this.host.nativeElement.contains(target)) {
237
- this.controller.close();
238
- }
239
- }
240
- closeAndRefocus() {
241
- const hadFocus = this.host.nativeElement.contains(this.document.activeElement);
242
- this.controller.close();
243
- if (hadFocus) {
244
- this.returningFocus = true;
245
- this.triggerElement()?.focus({ preventScroll: true });
246
- this.returningFocus = false;
247
- }
248
- }
249
- reveal() {
250
- const panel = this.panel().nativeElement;
251
- this.animation?.cancel();
252
- this.leftWhileGrowing = false;
253
- if (!this.shown) {
254
- this.shown = true;
255
- panel.classList.add('su-tooltip-shown');
256
- if (typeof panel.showPopover === 'function' && !panel.matches(':popover-open')) {
257
- panel.showPopover();
258
- }
259
- }
260
- this.place();
261
- if (this.focusOnOpen) {
262
- this.focusOnOpen = false;
263
- this.closeButton()?.nativeElement.focus({ preventScroll: true });
264
- }
265
- requestFrame(this.document, () => this.morphed.set(true));
266
- if (this.moves(panel)) {
267
- this.animation = this.isIcon()
268
- ? this.growFromIcon(panel)
269
- : panel.animate([
270
- { opacity: 0, transform: 'scale(0.6)' },
271
- { opacity: 1, transform: 'none' },
272
- ], { duration: this.duration(panel), easing: this.easing(panel) });
273
- if (this.animation) {
274
- this.animation.onfinish = () => this.hideIfLeftWhileGrowing();
275
- }
276
- }
277
- }
278
- /** While it grows, only its visible part counts as under the pointer, so a pointer on the rest seems to leave it */
279
- isGrowing() {
280
- return this.open() && this.animation?.playState === 'running';
281
- }
282
- hideIfLeftWhileGrowing() {
283
- this.animation = null;
284
- if (this.leftWhileGrowing && !this.host.nativeElement.matches(':hover')) {
285
- this.controller.hide();
286
- }
287
- }
288
- conceal() {
289
- this.morphed.set(false);
290
- if (!this.shown) {
291
- return;
292
- }
293
- const panel = this.panel().nativeElement;
294
- this.animation?.cancel();
295
- if (!this.moves(panel)) {
296
- this.removePanel(panel);
297
- return;
298
- }
299
- const duration = this.duration(panel) * 0.75;
300
- const animation = this.isIcon() && this.iconClip
301
- ? panel.animate([{ clipPath: this.iconClip.to }, { clipPath: this.iconClip.from }], { duration, easing: 'ease-in' })
302
- : panel.animate([
303
- { opacity: 1, transform: 'none' },
304
- { opacity: 0, transform: 'scale(0.6)' },
305
- ], { duration, easing: 'ease-in' });
306
- animation.onfinish = () => this.removePanel(panel);
307
- this.animation = animation;
308
- }
309
- removePanel(panel) {
310
- this.shown = false;
311
- this.animation = null;
312
- panel.classList.remove('su-tooltip-shown');
313
- if (typeof panel.hidePopover === 'function' && panel.matches(':popover-open')) {
314
- panel.hidePopover();
315
- }
316
- }
317
- growFromIcon(panel) {
318
- if (!this.iconClip) {
319
- return null;
320
- }
321
- const duration = this.duration(panel);
322
- panel
323
- .querySelector('.su-tooltip-body')
324
- ?.animate([{ opacity: 0 }, { opacity: 0, offset: 0.4 }, { opacity: 1 }], {
325
- duration,
326
- });
327
- return panel.animate([{ clipPath: this.iconClip.from }, { clipPath: this.iconClip.to }], { duration, easing: this.easing(panel) });
328
- }
329
- place() {
330
- if (!this.shown) {
331
- return;
332
- }
333
- const panel = this.panel().nativeElement;
334
- const view = this.document.defaultView;
335
- const viewport = {
336
- width: this.document.documentElement.clientWidth,
337
- height: view?.innerHeight ?? 0,
338
- };
339
- const rtl = view?.getComputedStyle(this.host.nativeElement).direction === 'rtl';
340
- const size = {
341
- width: panel.offsetWidth,
342
- height: panel.offsetHeight,
343
- };
344
- const icon = this.iconButton()?.nativeElement;
345
- if (this.isIcon() && icon) {
346
- const iconRect = icon.getBoundingClientRect();
347
- const position = suTooltipIconPosition(iconRect, size, {
348
- placement: this.placement(),
349
- viewport,
350
- rtl,
351
- });
352
- panel.dataset['inline'] = position.inline;
353
- panel.dataset['block'] = position.block;
354
- panel.style.left = `${position.x}px`;
355
- panel.style.top = `${position.y}px`;
356
- panel.style.setProperty('--su-tooltip-icon-x', `${position.icon.x}px`);
357
- panel.style.setProperty('--su-tooltip-icon-y', `${position.icon.y}px`);
358
- const radius = parseFloat(view?.getComputedStyle(panel).borderTopLeftRadius ?? '') || 0;
359
- this.iconClip = suTooltipIconClip(position, size, iconRect.width, radius);
360
- return;
361
- }
362
- const position = suTooltipPosition(this.content().nativeElement.getBoundingClientRect(), size, { placement: this.placement(), offset: this.offset(), viewport, rtl });
363
- panel.dataset['side'] = position.side;
364
- panel.style.left = `${position.x}px`;
365
- panel.style.top = `${position.y}px`;
366
- panel.style.transformOrigin = `${position.origin.x}px ${position.origin.y}px`;
367
- panel.style.setProperty('--su-tooltip-arrow-offset', `${position.arrow}px`);
368
- }
369
- moves(panel) {
370
- const view = this.document.defaultView;
371
- return (this.animated() &&
372
- typeof panel.animate === 'function' &&
373
- !view?.matchMedia?.('(prefers-reduced-motion: reduce)').matches);
374
- }
375
- duration(panel) {
376
- const value = this.document.defaultView
377
- ?.getComputedStyle(panel)
378
- .getPropertyValue('--su-tooltip-duration')
379
- .trim();
380
- return toMilliseconds(value) ?? DEFAULT_DURATION;
381
- }
382
- easing(panel) {
383
- const value = this.document.defaultView
384
- ?.getComputedStyle(panel)
385
- .getPropertyValue('--su-tooltip-easing')
386
- .trim();
387
- return value || 'cubic-bezier(0.2, 0.9, 0.3, 1.1)';
388
- }
389
- /** The element that takes focus for the tooltip: the icon, the content's first focusable element, or the host */
390
- triggerElement() {
391
- return this.isIcon()
392
- ? (this.iconButton()?.nativeElement ?? null)
393
- : this.contentTrigger();
394
- }
395
- contentTrigger() {
396
- return (this.content().nativeElement.querySelector(FOCUSABLE) ??
397
- this.host.nativeElement);
398
- }
399
- linkTrigger(trigger, describes, open) {
400
- if (this.linkedTrigger && this.linkedTrigger !== trigger) {
401
- this.unlink(this.linkedTrigger);
402
- }
403
- this.linkedTrigger = trigger;
404
- if (!trigger) {
405
- return;
406
- }
407
- const isHost = trigger === this.host.nativeElement;
408
- if (describes) {
409
- setToken(trigger, 'aria-describedby', this.panelId, true);
410
- trigger.removeAttribute('aria-expanded');
411
- trigger.removeAttribute('aria-controls');
412
- }
413
- else {
414
- setToken(trigger, 'aria-describedby', this.panelId, false);
415
- trigger.setAttribute('aria-expanded', String(open));
416
- trigger.setAttribute('aria-controls', this.panelId);
417
- }
418
- toggleAttribute(trigger, 'role', 'button', isHost && !describes);
419
- toggleAttribute(trigger, 'tabindex', '0', isHost);
420
- }
421
- unlink(trigger) {
422
- setToken(trigger, 'aria-describedby', this.panelId, false);
423
- trigger.removeAttribute('aria-expanded');
424
- trigger.removeAttribute('aria-controls');
425
- if (trigger === this.host.nativeElement) {
426
- trigger.removeAttribute('role');
427
- trigger.removeAttribute('tabindex');
428
- }
429
- }
430
- inPanel(target) {
431
- const node = this.asNode(target);
432
- return !!node && this.panel().nativeElement.contains(node);
433
- }
434
- asNode(target) {
435
- return target instanceof Node ? target : null;
436
- }
437
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: SuTooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
438
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.26", type: SuTooltipComponent, isStandalone: true, selector: "su-lib-tooltip", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, trigger: { classPropertyName: "trigger", publicName: "trigger", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "placement", isSignal: true, isRequired: false, transformFunction: null }, openOn: { classPropertyName: "openOn", publicName: "openOn", isSignal: true, isRequired: false, transformFunction: null }, interactive: { classPropertyName: "interactive", publicName: "interactive", isSignal: true, isRequired: false, transformFunction: null }, animated: { classPropertyName: "animated", publicName: "animated", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, arrow: { classPropertyName: "arrow", publicName: "arrow", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "showDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "hideDelay", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { open: "openChange" }, host: { listeners: { "pointerenter": "onPointerEnter($event)", "pointerleave": "onPointerLeave($event)", "focusin": "onFocusIn($event)", "focusout": "onFocusOut($event)", "click": "onClick($event)", "keydown": "onKeydown($event)" }, properties: { "class.su-tooltip-open": "open()", "style.--su-tooltip-width": "width()", "style.--su-tooltip-offset.px": "offset()" }, classAttribute: "su-tooltip" }, viewQueries: [{ propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }, { propertyName: "content", first: true, predicate: ["content"], descendants: true, isSignal: true }, { propertyName: "iconButton", first: true, predicate: ["iconButton"], descendants: true, isSignal: true }, { propertyName: "closeButton", first: true, predicate: ["closeButton"], descendants: true, isSignal: true }], ngImport: i0, 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", 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"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
439
- }
440
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.26", ngImport: i0, type: SuTooltipComponent, decorators: [{
441
- type: Component,
442
- args: [{ selector: 'su-lib-tooltip', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], host: {
443
- class: 'su-tooltip',
444
- '[class.su-tooltip-open]': 'open()',
445
- '[style.--su-tooltip-width]': 'width()',
446
- '[style.--su-tooltip-offset.px]': 'offset()',
447
- '(pointerenter)': 'onPointerEnter($event)',
448
- '(pointerleave)': 'onPointerLeave($event)',
449
- '(focusin)': 'onFocusIn($event)',
450
- '(focusout)': 'onFocusOut($event)',
451
- '(click)': 'onClick($event)',
452
- '(keydown)': 'onKeydown($event)',
453
- }, 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", 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"] }]
454
- }], ctorParameters: () => [], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], trigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "trigger", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], openOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "openOn", required: false }] }], interactive: [{ type: i0.Input, args: [{ isSignal: true, alias: "interactive", required: false }] }], animated: [{ type: i0.Input, args: [{ isSignal: true, alias: "animated", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], arrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "arrow", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], showDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDelay", required: false }] }], hideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideDelay", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labels: [{ type: i0.Input, args: [{ isSignal: true, alias: "labels", required: false }] }], open: [{ type: i0.Input, args: [{ isSignal: true, alias: "open", required: false }] }, { type: i0.Output, args: ["openChange"] }], panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], content: [{ type: i0.ViewChild, args: ['content', { isSignal: true }] }], iconButton: [{ type: i0.ViewChild, args: ['iconButton', { isSignal: true }] }], closeButton: [{ type: i0.ViewChild, args: ['closeButton', { isSignal: true }] }] } });
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
- const tokens = (element.getAttribute(name) ?? '')
457
- .split(/\s+/)
458
- .filter(item => item && item !== token);
459
- const next = present ? [...tokens, token] : tokens;
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
- if (present) {
469
- element.setAttribute(name, value);
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
- const match = value?.match(/^([\d.]+)(ms|s)$/);
477
- if (!match) {
478
- return null;
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
- const view = document.defaultView;
485
- if (view?.requestAnimationFrame) {
486
- view.requestAnimationFrame(callback);
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
- //# sourceMappingURL=su-labs-tooltip.mjs.map
776
+
777
+ //# sourceMappingURL=su-labs-tooltip.mjs.map