@ngx-smz/ui-kit 21.10.0-next.22 → 21.10.0-next.25
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/fesm2022/ngx-smz-ui-kit.mjs +1128 -197
- package/fesm2022/ngx-smz-ui-kit.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngx-smz-ui-kit.d.ts +271 -22
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, input, booleanAttribute, computed, Directive, inject, TemplateRef, HostAttributeToken, ChangeDetectionStrategy, Component, ElementRef, afterEveryRender, output, forwardRef, Injector, DestroyRef, afterNextRender, Renderer2, effect,
|
|
2
|
+
import { signal, input, booleanAttribute, computed, Directive, inject, TemplateRef, HostAttributeToken, ChangeDetectionStrategy, Component, InjectionToken, makeEnvironmentProviders, ElementRef, ViewContainerRef, afterEveryRender, output, forwardRef, Injector, DestroyRef, afterNextRender, Renderer2, effect, viewChild, Injectable, model, contentChildren, numberAttribute, untracked, contentChild } from '@angular/core';
|
|
3
3
|
import { Overlay } from '@angular/cdk/overlay';
|
|
4
4
|
import { ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
|
|
5
|
+
import { NgTemplateOutlet, NgStyle, NgClass, DOCUMENT } from '@angular/common';
|
|
6
|
+
import { Subscription, Subject, filter, merge } from 'rxjs';
|
|
5
7
|
import * as i1 from '@angular/forms';
|
|
6
8
|
import { NG_VALUE_ACCESSOR, NgControl, FormsModule } from '@angular/forms';
|
|
7
9
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
8
|
-
import { Subject, filter, merge } from 'rxjs';
|
|
9
|
-
import { NgStyle, NgTemplateOutlet, NgClass, DOCUMENT } from '@angular/common';
|
|
10
10
|
import { RouterLink } from '@angular/router';
|
|
11
11
|
import { CdkDropListGroup, CdkDropList, CdkDrag } from '@angular/cdk/drag-drop';
|
|
12
12
|
|
|
@@ -416,70 +416,254 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
|
|
|
416
416
|
}]
|
|
417
417
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], iconPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconPosition", required: false }] }], severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], outlined: [{ type: i0.Input, args: [{ isSignal: true, alias: "outlined", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }] } });
|
|
418
418
|
|
|
419
|
-
const
|
|
419
|
+
const SMZ_TOOLTIP_DEFAULT_OPTIONS = {
|
|
420
|
+
variant: 'dark',
|
|
421
|
+
arrow: true,
|
|
422
|
+
showDelay: 300,
|
|
423
|
+
hideDelay: 0,
|
|
424
|
+
warmupWindow: 500,
|
|
425
|
+
tooltipEvent: 'both',
|
|
426
|
+
position: 'top',
|
|
427
|
+
};
|
|
428
|
+
const SMZ_TOOLTIP_DEFAULTS = new InjectionToken('SMZ_TOOLTIP_DEFAULTS');
|
|
429
|
+
/**
|
|
430
|
+
* Padroes globais do `smzTooltip` (variante, seta, atrasos, janela de aquecimento).
|
|
431
|
+
*
|
|
432
|
+
* providers: [provideSmzTooltipDefaults({ variant: 'light', showDelay: 200 })]
|
|
433
|
+
*/
|
|
434
|
+
function provideSmzTooltipDefaults(defaults) {
|
|
435
|
+
return makeEnvironmentProviders([{ provide: SMZ_TOOLTIP_DEFAULTS, useValue: defaults }]);
|
|
436
|
+
}
|
|
437
|
+
const globalDefaults$1 = {};
|
|
438
|
+
/**
|
|
439
|
+
* Padroes globais definidos fora da injecao de dependencias (usado pelo `SmzUiBuilder` do @ngx-smz/core).
|
|
440
|
+
* O token `SMZ_TOOLTIP_DEFAULTS`, quando provido, tem precedencia.
|
|
441
|
+
*/
|
|
442
|
+
function smzSetTooltipDefaults(defaults) {
|
|
443
|
+
Object.assign(globalDefaults$1, defaults ?? {});
|
|
444
|
+
}
|
|
445
|
+
/** Distancia entre o host e a caixa do tooltip, com e sem seta. */
|
|
446
|
+
const GAP_WITH_ARROW = 8;
|
|
447
|
+
const GAP_PLAIN = 6;
|
|
448
|
+
/** Distancia minima da seta ate o canto da caixa. */
|
|
449
|
+
const ARROW_INSET = 12;
|
|
450
|
+
const LONG_PRESS = 450;
|
|
451
|
+
/** Depois de um toque o navegador emite `mouseenter` sintetico; ignorado durante essa janela. */
|
|
452
|
+
const TOUCH_MOUSE_GUARD = 800;
|
|
453
|
+
const pair = (originX, originY, overlayX, overlayY) => ({ originX, originY, overlayX, overlayY });
|
|
454
|
+
const TOP = pair('center', 'top', 'center', 'bottom');
|
|
455
|
+
const BOTTOM = pair('center', 'bottom', 'center', 'top');
|
|
456
|
+
const LEFT = pair('start', 'center', 'end', 'center');
|
|
457
|
+
const RIGHT = pair('end', 'center', 'start', 'center');
|
|
458
|
+
const TOP_START = pair('start', 'top', 'start', 'bottom');
|
|
459
|
+
const TOP_END = pair('end', 'top', 'end', 'bottom');
|
|
460
|
+
const BOTTOM_START = pair('start', 'bottom', 'start', 'top');
|
|
461
|
+
const BOTTOM_END = pair('end', 'bottom', 'end', 'top');
|
|
462
|
+
/** Posicao pedida primeiro, depois o lado oposto e as alternativas mais proximas. */
|
|
420
463
|
const POSITIONS$3 = {
|
|
421
|
-
top: [
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
],
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
],
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
464
|
+
top: [TOP, BOTTOM, TOP_START, TOP_END],
|
|
465
|
+
bottom: [BOTTOM, TOP, BOTTOM_START, BOTTOM_END],
|
|
466
|
+
left: [LEFT, RIGHT, TOP, BOTTOM],
|
|
467
|
+
right: [RIGHT, LEFT, TOP, BOTTOM],
|
|
468
|
+
'top-start': [TOP_START, BOTTOM_START, TOP_END, BOTTOM_END],
|
|
469
|
+
'top-end': [TOP_END, BOTTOM_END, TOP_START, BOTTOM_START],
|
|
470
|
+
'bottom-start': [BOTTOM_START, TOP_START, BOTTOM_END, TOP_END],
|
|
471
|
+
'bottom-end': [BOTTOM_END, TOP_END, BOTTOM_START, TOP_START],
|
|
472
|
+
};
|
|
473
|
+
function sideOf(position) {
|
|
474
|
+
if (position.originY === 'top' && position.overlayY === 'bottom')
|
|
475
|
+
return 'top';
|
|
476
|
+
if (position.originY === 'bottom' && position.overlayY === 'top')
|
|
477
|
+
return 'bottom';
|
|
478
|
+
return position.overlayX === 'end' ? 'left' : 'right';
|
|
479
|
+
}
|
|
480
|
+
/** Cores por variante/severidade. Strings literais para o Tailwind encontrar no scan. */
|
|
481
|
+
const VARIANT_TONE = {
|
|
482
|
+
dark: 'border-transparent bg-ui-fg text-ui-surface-1',
|
|
483
|
+
light: 'border-ui-line-strong bg-ui-surface-2 text-ui-fg',
|
|
484
|
+
};
|
|
485
|
+
const VARIANT_MUTED = {
|
|
486
|
+
dark: 'text-ui-surface-1/75',
|
|
487
|
+
light: 'text-ui-fg-muted',
|
|
488
|
+
};
|
|
489
|
+
const VARIANT_KEY = {
|
|
490
|
+
dark: 'bg-ui-surface-1/15',
|
|
491
|
+
light: 'bg-ui-surface-3',
|
|
437
492
|
};
|
|
493
|
+
/** `success` usa o tom `-hover` (mais escuro): branco sobre o tom base fica abaixo de 4.5:1. */
|
|
494
|
+
const SEVERITY_TONE$2 = {
|
|
495
|
+
primary: 'border-transparent bg-ui-primary text-ui-on-primary',
|
|
496
|
+
secondary: 'border-ui-line-strong bg-ui-surface-3 text-ui-fg',
|
|
497
|
+
success: 'border-transparent bg-ui-success-hover text-ui-on-success',
|
|
498
|
+
warning: 'border-transparent bg-ui-warning text-ui-on-warning',
|
|
499
|
+
danger: 'border-transparent bg-ui-danger text-ui-on-danger',
|
|
500
|
+
};
|
|
501
|
+
/** Lado do host: a area transparente que liga o host ao tooltip, para o mouse atravessar sem fechar. */
|
|
502
|
+
const BRIDGE_PROPERTY = {
|
|
503
|
+
top: 'padding-bottom',
|
|
504
|
+
bottom: 'padding-top',
|
|
505
|
+
left: 'padding-right',
|
|
506
|
+
right: 'padding-left',
|
|
507
|
+
};
|
|
508
|
+
let nextId$1 = 0;
|
|
438
509
|
class SmzTooltipComponent {
|
|
439
|
-
text = input
|
|
510
|
+
text = input('', ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
|
|
511
|
+
template = input(null, ...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
|
|
440
512
|
escape = input(true, ...(ngDevMode ? [{ debugName: "escape" }] : /* istanbul ignore next */ []));
|
|
441
|
-
|
|
513
|
+
title = input('', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
514
|
+
shortcut = input('', ...(ngDevMode ? [{ debugName: "shortcut" }] : /* istanbul ignore next */ []));
|
|
515
|
+
variant = input('dark', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
516
|
+
severity = input(null, ...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
|
|
517
|
+
arrow = input(true, ...(ngDevMode ? [{ debugName: "arrow" }] : /* istanbul ignore next */ []));
|
|
518
|
+
styleClass = input('', ...(ngDevMode ? [{ debugName: "styleClass" }] : /* istanbul ignore next */ []));
|
|
519
|
+
tooltipId = input('', ...(ngDevMode ? [{ debugName: "tooltipId" }] : /* istanbul ignore next */ []));
|
|
520
|
+
/** Lado real em relacao ao host (definido depois que o CDK posiciona). Vazio = ainda nao posicionado. */
|
|
521
|
+
side = input('', ...(ngDevMode ? [{ debugName: "side" }] : /* istanbul ignore next */ []));
|
|
522
|
+
/** Posicao da seta ao longo da borda (px a partir do canto), para ela apontar para o centro do host. */
|
|
523
|
+
arrowOffset = input(null, ...(ngDevMode ? [{ debugName: "arrowOffset" }] : /* istanbul ignore next */ []));
|
|
524
|
+
/** Sem animacao (aquecimento entre tooltips vizinhos). */
|
|
525
|
+
instant = input(false, ...(ngDevMode ? [{ debugName: "instant" }] : /* istanbul ignore next */ []));
|
|
526
|
+
gap = input(GAP_WITH_ARROW, ...(ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []));
|
|
527
|
+
tone = computed(() => (this.severity() ? smzNormalizeSeverity(this.severity()) : null), ...(ngDevMode ? [{ debugName: "tone" }] : /* istanbul ignore next */ []));
|
|
528
|
+
keys = computed(() => (this.shortcut() ?? '').split('+').map((key) => key.trim()).filter((key) => key.length > 0), ...(ngDevMode ? [{ debugName: "keys" }] : /* istanbul ignore next */ []));
|
|
529
|
+
classes = computed(() => {
|
|
530
|
+
const tone = this.tone();
|
|
531
|
+
const rich = !!this.title() || !!this.template();
|
|
532
|
+
return [
|
|
533
|
+
'w-max max-w-[min(280px,calc(100vw-16px))] rounded-control border font-ui text-ui-sm leading-snug shadow-overlay',
|
|
534
|
+
rich ? 'px-3 py-2' : 'px-2.5 py-1.5',
|
|
535
|
+
tone ? SEVERITY_TONE$2[tone] : VARIANT_TONE[this.variant()],
|
|
536
|
+
this.styleClass() ?? '',
|
|
537
|
+
].join(' ');
|
|
538
|
+
}, ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
539
|
+
/** Com titulo, o texto vira descricao em tom mais suave (so nas variantes; nas severidades herda a cor). */
|
|
540
|
+
textClasses = computed(() => (this.title() && !this.tone() ? VARIANT_MUTED[this.variant()] : ''), ...(ngDevMode ? [{ debugName: "textClasses" }] : /* istanbul ignore next */ []));
|
|
541
|
+
keyClasses = computed(() => (this.tone() ? 'bg-black/15' : VARIANT_KEY[this.variant()]), ...(ngDevMode ? [{ debugName: "keyClasses" }] : /* istanbul ignore next */ []));
|
|
542
|
+
bridgeStyle = computed(() => {
|
|
543
|
+
const side = this.side();
|
|
544
|
+
return side ? `${BRIDGE_PROPERTY[side]}: ${this.gap()}px` : '';
|
|
545
|
+
}, ...(ngDevMode ? [{ debugName: "bridgeStyle" }] : /* istanbul ignore next */ []));
|
|
442
546
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzTooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
443
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SmzTooltipComponent, isStandalone: true, selector: "ui-tooltip", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: true, transformFunction: null }, escape: { classPropertyName: "escape", publicName: "escape", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
547
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SmzTooltipComponent, isStandalone: true, selector: "ui-tooltip", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null }, escape: { classPropertyName: "escape", publicName: "escape", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: false, transformFunction: null }, arrow: { classPropertyName: "arrow", publicName: "arrow", isSignal: true, isRequired: false, transformFunction: null }, styleClass: { classPropertyName: "styleClass", publicName: "styleClass", isSignal: true, isRequired: false, transformFunction: null }, tooltipId: { classPropertyName: "tooltipId", publicName: "tooltipId", isSignal: true, isRequired: false, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, arrowOffset: { classPropertyName: "arrowOffset", publicName: "arrowOffset", isSignal: true, isRequired: false, transformFunction: null }, instant: { classPropertyName: "instant", publicName: "instant", isSignal: true, isRequired: false, transformFunction: null }, gap: { classPropertyName: "gap", publicName: "gap", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style": "bridgeStyle()" }, classAttribute: "block" }, ngImport: i0, template: `
|
|
548
|
+
<div
|
|
549
|
+
role="tooltip"
|
|
550
|
+
class="smz-tooltip"
|
|
551
|
+
[id]="tooltipId()"
|
|
552
|
+
[class]="classes()"
|
|
553
|
+
[style.--smz-tooltip-arrow]="arrowOffset()"
|
|
554
|
+
[attr.data-side]="side()"
|
|
555
|
+
[attr.data-variant]="variant()"
|
|
556
|
+
[attr.data-severity]="tone()"
|
|
557
|
+
[attr.data-state]="side() ? 'open' : 'pending'"
|
|
558
|
+
[attr.data-instant]="instant()"
|
|
559
|
+
>
|
|
560
|
+
@if (template(); as tpl) {
|
|
561
|
+
<ng-container [ngTemplateOutlet]="tpl" />
|
|
562
|
+
}
|
|
563
|
+
@else {
|
|
564
|
+
@if (title()) {
|
|
565
|
+
<div class="font-semibold" data-part="title">{{ title() }}</div>
|
|
566
|
+
}
|
|
567
|
+
@if (text() || keys().length > 0) {
|
|
568
|
+
<div class="flex items-center gap-2.5">
|
|
569
|
+
@if (escape()) {
|
|
570
|
+
<span data-part="text" [class]="textClasses()">{{ text() }}</span>
|
|
571
|
+
}
|
|
572
|
+
@else {
|
|
573
|
+
<span data-part="text" [class]="textClasses()" [innerHTML]="text()"></span>
|
|
574
|
+
}
|
|
575
|
+
@if (keys().length > 0) {
|
|
576
|
+
<span class="ml-auto inline-flex flex-none gap-[3px]" data-part="shortcut">
|
|
577
|
+
@for (key of keys(); track $index) {
|
|
578
|
+
<kbd class="rounded px-[5px] font-ui-mono text-[11px] leading-[18px]" [class]="keyClasses()">{{ key }}</kbd>
|
|
579
|
+
}
|
|
580
|
+
</span>
|
|
581
|
+
}
|
|
582
|
+
</div>
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
@if (arrow()) {
|
|
586
|
+
<span class="smz-tooltip-arrow" aria-hidden="true"></span>
|
|
587
|
+
}
|
|
588
|
+
</div>
|
|
589
|
+
`, isInline: true, styles: [".smz-tooltip{position:relative}.smz-tooltip[data-state=pending]{opacity:0}.smz-tooltip[data-state=open]{animation:smz-tooltip-in .12s ease-out}.smz-tooltip[data-side=top]{--smz-tooltip-y: 4px}.smz-tooltip[data-side=bottom]{--smz-tooltip-y: -4px}.smz-tooltip[data-side=left]{--smz-tooltip-x: 4px}.smz-tooltip[data-side=right]{--smz-tooltip-x: -4px}.smz-tooltip[data-instant=true]{animation:none}.smz-tooltip-arrow{position:absolute;width:10px;height:10px;background:inherit;border:1px solid transparent;transform:rotate(45deg)}.smz-tooltip[data-side=top]>.smz-tooltip-arrow{bottom:-6px;left:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-right-color:inherit;border-bottom-color:inherit}.smz-tooltip[data-side=bottom]>.smz-tooltip-arrow{top:-6px;left:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-left-color:inherit;border-top-color:inherit}.smz-tooltip[data-side=left]>.smz-tooltip-arrow{right:-6px;top:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-right-color:inherit;border-top-color:inherit}.smz-tooltip[data-side=right]>.smz-tooltip-arrow{left:-6px;top:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-left-color:inherit;border-bottom-color:inherit}@keyframes smz-tooltip-in{0%{opacity:0;transform:translate(var(--smz-tooltip-x, 0),var(--smz-tooltip-y, 0))}}@media(prefers-reduced-motion:reduce){.smz-tooltip[data-state=open]{animation:none}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
451
590
|
}
|
|
452
591
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzTooltipComponent, decorators: [{
|
|
453
592
|
type: Component,
|
|
454
|
-
args: [{
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
593
|
+
args: [{ selector: 'ui-tooltip', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], host: { class: 'block', '[style]': 'bridgeStyle()' }, template: `
|
|
594
|
+
<div
|
|
595
|
+
role="tooltip"
|
|
596
|
+
class="smz-tooltip"
|
|
597
|
+
[id]="tooltipId()"
|
|
598
|
+
[class]="classes()"
|
|
599
|
+
[style.--smz-tooltip-arrow]="arrowOffset()"
|
|
600
|
+
[attr.data-side]="side()"
|
|
601
|
+
[attr.data-variant]="variant()"
|
|
602
|
+
[attr.data-severity]="tone()"
|
|
603
|
+
[attr.data-state]="side() ? 'open' : 'pending'"
|
|
604
|
+
[attr.data-instant]="instant()"
|
|
605
|
+
>
|
|
606
|
+
@if (template(); as tpl) {
|
|
607
|
+
<ng-container [ngTemplateOutlet]="tpl" />
|
|
608
|
+
}
|
|
609
|
+
@else {
|
|
610
|
+
@if (title()) {
|
|
611
|
+
<div class="font-semibold" data-part="title">{{ title() }}</div>
|
|
612
|
+
}
|
|
613
|
+
@if (text() || keys().length > 0) {
|
|
614
|
+
<div class="flex items-center gap-2.5">
|
|
615
|
+
@if (escape()) {
|
|
616
|
+
<span data-part="text" [class]="textClasses()">{{ text() }}</span>
|
|
617
|
+
}
|
|
618
|
+
@else {
|
|
619
|
+
<span data-part="text" [class]="textClasses()" [innerHTML]="text()"></span>
|
|
620
|
+
}
|
|
621
|
+
@if (keys().length > 0) {
|
|
622
|
+
<span class="ml-auto inline-flex flex-none gap-[3px]" data-part="shortcut">
|
|
623
|
+
@for (key of keys(); track $index) {
|
|
624
|
+
<kbd class="rounded px-[5px] font-ui-mono text-[11px] leading-[18px]" [class]="keyClasses()">{{ key }}</kbd>
|
|
625
|
+
}
|
|
626
|
+
</span>
|
|
627
|
+
}
|
|
628
|
+
</div>
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
@if (arrow()) {
|
|
632
|
+
<span class="smz-tooltip-arrow" aria-hidden="true"></span>
|
|
633
|
+
}
|
|
634
|
+
</div>
|
|
635
|
+
`, styles: [".smz-tooltip{position:relative}.smz-tooltip[data-state=pending]{opacity:0}.smz-tooltip[data-state=open]{animation:smz-tooltip-in .12s ease-out}.smz-tooltip[data-side=top]{--smz-tooltip-y: 4px}.smz-tooltip[data-side=bottom]{--smz-tooltip-y: -4px}.smz-tooltip[data-side=left]{--smz-tooltip-x: 4px}.smz-tooltip[data-side=right]{--smz-tooltip-x: -4px}.smz-tooltip[data-instant=true]{animation:none}.smz-tooltip-arrow{position:absolute;width:10px;height:10px;background:inherit;border:1px solid transparent;transform:rotate(45deg)}.smz-tooltip[data-side=top]>.smz-tooltip-arrow{bottom:-6px;left:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-right-color:inherit;border-bottom-color:inherit}.smz-tooltip[data-side=bottom]>.smz-tooltip-arrow{top:-6px;left:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-left-color:inherit;border-top-color:inherit}.smz-tooltip[data-side=left]>.smz-tooltip-arrow{right:-6px;top:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-right-color:inherit;border-top-color:inherit}.smz-tooltip[data-side=right]>.smz-tooltip-arrow{left:-6px;top:calc(var(--smz-tooltip-arrow, 50%) - 5px);border-left-color:inherit;border-bottom-color:inherit}@keyframes smz-tooltip-in{0%{opacity:0;transform:translate(var(--smz-tooltip-x, 0),var(--smz-tooltip-y, 0))}}@media(prefers-reduced-motion:reduce){.smz-tooltip[data-state=open]{animation:none}}\n"] }]
|
|
636
|
+
}], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }], escape: [{ type: i0.Input, args: [{ isSignal: true, alias: "escape", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], shortcut: [{ type: i0.Input, args: [{ isSignal: true, alias: "shortcut", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: false }] }], arrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "arrow", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }], tooltipId: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipId", required: false }] }], side: [{ type: i0.Input, args: [{ isSignal: true, alias: "side", required: false }] }], arrowOffset: [{ type: i0.Input, args: [{ isSignal: true, alias: "arrowOffset", required: false }] }], instant: [{ type: i0.Input, args: [{ isSignal: true, alias: "instant", required: false }] }], gap: [{ type: i0.Input, args: [{ isSignal: true, alias: "gap", required: false }] }] } });
|
|
637
|
+
/** Estado compartilhado entre todos os tooltips: um aberto por vez e aquecimento entre vizinhos. */
|
|
638
|
+
const shared = { active: null, lastClosedAt: 0 };
|
|
467
639
|
/**
|
|
468
640
|
* Tooltip do ui-kit. Substitui o `pTooltip` do PrimeNG.
|
|
469
641
|
* Requer o CSS do CDK Overlay no app (`@angular/cdk/overlay-prebuilt.css`).
|
|
470
642
|
*
|
|
471
|
-
* <button smzButton smzTooltip="Salvar" tooltipPosition="bottom">...</button>
|
|
643
|
+
* <button smzButton smzTooltip="Salvar" tooltipShortcut="Ctrl+S" tooltipPosition="bottom">...</button>
|
|
644
|
+
* <span class="truncate" [smzTooltip]="nome" tooltipOnOverflow>{{ nome }}</span>
|
|
645
|
+
* <i [smzTooltip]="ajuda" tooltipVariant="light"></i> <ng-template #ajuda>conteudo livre</ng-template>
|
|
646
|
+
*
|
|
647
|
+
* Abre no hover e no foco por teclado (`:focus-visible`), e por toque longo em telas de toque.
|
|
648
|
+
* Elemento desabilitado nao emite eventos de mouse: envolva-o em um `<span tabindex="0" smzTooltip="...">`
|
|
649
|
+
* e ponha `pointer-events-none` no elemento desabilitado, para o hover chegar ao wrapper.
|
|
472
650
|
*/
|
|
473
651
|
class SmzTooltipDirective {
|
|
474
652
|
text = input('', { ...(ngDevMode ? { debugName: "text" } : /* istanbul ignore next */ {}), alias: 'smzTooltip' });
|
|
475
|
-
tooltipPosition = input(
|
|
476
|
-
showDelay = input(
|
|
477
|
-
hideDelay = input(
|
|
478
|
-
tooltipEvent = input(
|
|
653
|
+
tooltipPosition = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipPosition" }] : /* istanbul ignore next */ []));
|
|
654
|
+
showDelay = input(undefined, ...(ngDevMode ? [{ debugName: "showDelay" }] : /* istanbul ignore next */ []));
|
|
655
|
+
hideDelay = input(undefined, ...(ngDevMode ? [{ debugName: "hideDelay" }] : /* istanbul ignore next */ []));
|
|
656
|
+
tooltipEvent = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipEvent" }] : /* istanbul ignore next */ []));
|
|
479
657
|
escape = input(true, { ...(ngDevMode ? { debugName: "escape" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
480
658
|
tooltipStyleClass = input('', ...(ngDevMode ? [{ debugName: "tooltipStyleClass" }] : /* istanbul ignore next */ []));
|
|
481
659
|
tooltipZIndex = input('', ...(ngDevMode ? [{ debugName: "tooltipZIndex" }] : /* istanbul ignore next */ []));
|
|
482
660
|
tooltipDisabled = input(false, { ...(ngDevMode ? { debugName: "tooltipDisabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
661
|
+
tooltipTitle = input('', ...(ngDevMode ? [{ debugName: "tooltipTitle" }] : /* istanbul ignore next */ []));
|
|
662
|
+
tooltipShortcut = input('', ...(ngDevMode ? [{ debugName: "tooltipShortcut" }] : /* istanbul ignore next */ []));
|
|
663
|
+
tooltipVariant = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipVariant" }] : /* istanbul ignore next */ []));
|
|
664
|
+
tooltipSeverity = input(null, ...(ngDevMode ? [{ debugName: "tooltipSeverity" }] : /* istanbul ignore next */ []));
|
|
665
|
+
tooltipArrow = input(undefined, { ...(ngDevMode ? { debugName: "tooltipArrow" } : /* istanbul ignore next */ {}), transform: (value) => (value === undefined || value === null ? undefined : booleanAttribute(value)) });
|
|
666
|
+
tooltipOnOverflow = input(false, { ...(ngDevMode ? { debugName: "tooltipOnOverflow" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
483
667
|
/** Opcoes agrupadas (compatibilidade com `tooltipOptions` do PrimeNG). Sobrescrevem os inputs individuais. */
|
|
484
668
|
tooltipOptions = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipOptions" }] : /* istanbul ignore next */ []));
|
|
485
669
|
/** Aceito por compatibilidade; o overlay do CDK ja e anexado ao body. */
|
|
@@ -487,98 +671,301 @@ class SmzTooltipDirective {
|
|
|
487
671
|
overrides = signal({}, ...(ngDevMode ? [{ debugName: "overrides" }] : /* istanbul ignore next */ []));
|
|
488
672
|
overlay = inject(Overlay);
|
|
489
673
|
host = inject(ElementRef);
|
|
674
|
+
viewContainer = inject(ViewContainerRef);
|
|
675
|
+
providedDefaults = inject(SMZ_TOOLTIP_DEFAULTS, { optional: true });
|
|
676
|
+
tooltipId = `smz-tooltip-${nextId$1++}`;
|
|
677
|
+
get defaults() {
|
|
678
|
+
return { ...SMZ_TOOLTIP_DEFAULT_OPTIONS, ...globalDefaults$1, ...(this.providedDefaults ?? {}) };
|
|
679
|
+
}
|
|
490
680
|
overlayRef;
|
|
681
|
+
componentRef;
|
|
682
|
+
subscriptions;
|
|
491
683
|
showTimer;
|
|
492
684
|
hideTimer;
|
|
685
|
+
touchTimer;
|
|
686
|
+
lastTouchAt = 0;
|
|
687
|
+
openedByTouch = false;
|
|
688
|
+
onDocumentKeydown = (event) => {
|
|
689
|
+
if (event.key === 'Escape')
|
|
690
|
+
this.hide();
|
|
691
|
+
};
|
|
692
|
+
onDocumentTouch = (event) => {
|
|
693
|
+
const target = event.target;
|
|
694
|
+
if (target && (this.host.nativeElement.contains(target) || this.overlayRef?.overlayElement.contains(target)))
|
|
695
|
+
return;
|
|
696
|
+
this.hide();
|
|
697
|
+
};
|
|
698
|
+
onPanelEnter = () => clearTimeout(this.hideTimer);
|
|
699
|
+
onPanelLeave = (event) => {
|
|
700
|
+
if (this.host.nativeElement.contains(event.relatedTarget))
|
|
701
|
+
return;
|
|
702
|
+
if (this.openedByTouch || this.hasKeyboardFocus())
|
|
703
|
+
return;
|
|
704
|
+
this.scheduleHide();
|
|
705
|
+
};
|
|
493
706
|
/** Ajuste programatico de opcoes (usado por diretivas que envolvem o tooltip). */
|
|
494
707
|
configure(options) {
|
|
495
708
|
this.overrides.update((current) => ({ ...current, ...options }));
|
|
496
709
|
}
|
|
497
|
-
onEnter(source) {
|
|
710
|
+
onEnter(source, event) {
|
|
498
711
|
if (!this.accepts(source))
|
|
499
712
|
return;
|
|
500
|
-
|
|
713
|
+
if (source === 'hover') {
|
|
714
|
+
// `mouseenter` sintetico depois de um toque: no toque quem abre e o toque longo.
|
|
715
|
+
if (Date.now() - this.lastTouchAt < TOUCH_MOUSE_GUARD)
|
|
716
|
+
return;
|
|
717
|
+
this.show();
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
// No modo padrao (`both`) o foco so abre para quem navega por teclado; clique de mouse nao abre.
|
|
721
|
+
// No modo `focus` explicito qualquer foco abre (ex.: `appTooltipTouchSupport`).
|
|
722
|
+
if (this.option('tooltipEvent') === 'both' && !this.isFocusVisible(event?.target))
|
|
723
|
+
return;
|
|
724
|
+
this.show(true);
|
|
501
725
|
}
|
|
502
|
-
onLeave(source) {
|
|
726
|
+
onLeave(source, event) {
|
|
503
727
|
if (!this.accepts(source))
|
|
504
728
|
return;
|
|
505
729
|
clearTimeout(this.showTimer);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
this.
|
|
730
|
+
if (source === 'hover') {
|
|
731
|
+
// Mouse indo do host para o proprio tooltip (conteudo "hoverable", WCAG 1.4.13): continua aberto.
|
|
732
|
+
const related = event?.relatedTarget;
|
|
733
|
+
if (related && this.overlayRef?.overlayElement.contains(related))
|
|
734
|
+
return;
|
|
735
|
+
if (this.openedByTouch || this.hasKeyboardFocus())
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
const related = event?.relatedTarget;
|
|
740
|
+
if (related && this.overlayRef?.overlayElement.contains(related))
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
this.scheduleHide();
|
|
512
744
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
if (this.option('
|
|
745
|
+
onTouchStart() {
|
|
746
|
+
this.lastTouchAt = Date.now();
|
|
747
|
+
if (this.option('tooltipEvent') === 'focus')
|
|
748
|
+
return;
|
|
749
|
+
clearTimeout(this.touchTimer);
|
|
750
|
+
this.touchTimer = setTimeout(() => {
|
|
751
|
+
this.openedByTouch = true;
|
|
752
|
+
this.show(true);
|
|
753
|
+
}, LONG_PRESS);
|
|
754
|
+
}
|
|
755
|
+
onTouchEnd() {
|
|
756
|
+
this.lastTouchAt = Date.now();
|
|
757
|
+
clearTimeout(this.touchTimer);
|
|
758
|
+
}
|
|
759
|
+
/** Abre o tooltip. `immediate` ignora o `showDelay` (foco por teclado, toque longo). */
|
|
760
|
+
show(immediate = false) {
|
|
761
|
+
if (!this.canShow())
|
|
516
762
|
return;
|
|
517
763
|
clearTimeout(this.hideTimer);
|
|
518
764
|
if (this.overlayRef)
|
|
519
765
|
return;
|
|
520
766
|
clearTimeout(this.showTimer);
|
|
521
|
-
|
|
767
|
+
const warm = this.isWarm();
|
|
768
|
+
const delay = immediate || warm ? 0 : this.option('showDelay');
|
|
769
|
+
if (delay > 0)
|
|
770
|
+
this.showTimer = setTimeout(() => this.open(false), delay);
|
|
771
|
+
else
|
|
772
|
+
this.open(warm);
|
|
522
773
|
}
|
|
523
774
|
hide() {
|
|
524
775
|
clearTimeout(this.showTimer);
|
|
525
776
|
clearTimeout(this.hideTimer);
|
|
526
|
-
this.
|
|
777
|
+
clearTimeout(this.touchTimer);
|
|
778
|
+
if (!this.overlayRef)
|
|
779
|
+
return;
|
|
780
|
+
const overlayRef = this.overlayRef;
|
|
527
781
|
this.overlayRef = undefined;
|
|
782
|
+
this.componentRef = undefined;
|
|
783
|
+
this.openedByTouch = false;
|
|
784
|
+
this.subscriptions?.unsubscribe();
|
|
785
|
+
this.subscriptions = undefined;
|
|
786
|
+
document.removeEventListener('keydown', this.onDocumentKeydown, true);
|
|
787
|
+
document.removeEventListener('touchstart', this.onDocumentTouch, true);
|
|
788
|
+
overlayRef.overlayElement.removeEventListener('mouseenter', this.onPanelEnter);
|
|
789
|
+
overlayRef.overlayElement.removeEventListener('mouseleave', this.onPanelLeave);
|
|
790
|
+
overlayRef.dispose();
|
|
791
|
+
this.setDescribedBy(false);
|
|
792
|
+
if (shared.active === this) {
|
|
793
|
+
shared.active = null;
|
|
794
|
+
shared.lastClosedAt = Date.now();
|
|
795
|
+
}
|
|
528
796
|
}
|
|
529
797
|
ngOnDestroy() {
|
|
530
798
|
this.hide();
|
|
531
799
|
}
|
|
800
|
+
scheduleHide() {
|
|
801
|
+
clearTimeout(this.hideTimer);
|
|
802
|
+
const delay = this.option('hideDelay');
|
|
803
|
+
if (delay > 0)
|
|
804
|
+
this.hideTimer = setTimeout(() => this.hide(), delay);
|
|
805
|
+
else
|
|
806
|
+
this.hide();
|
|
807
|
+
}
|
|
532
808
|
accepts(source) {
|
|
533
809
|
const event = this.option('tooltipEvent');
|
|
534
810
|
return event === 'both' || event === source;
|
|
535
811
|
}
|
|
812
|
+
canShow() {
|
|
813
|
+
if (this.option('tooltipDisabled'))
|
|
814
|
+
return false;
|
|
815
|
+
if (!this.text() && !this.option('tooltipTitle') && !this.option('tooltipShortcut'))
|
|
816
|
+
return false;
|
|
817
|
+
return !this.option('tooltipOnOverflow') || this.isOverflowing();
|
|
818
|
+
}
|
|
819
|
+
isOverflowing() {
|
|
820
|
+
const element = this.host.nativeElement;
|
|
821
|
+
return element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
|
|
822
|
+
}
|
|
823
|
+
isFocusVisible(target) {
|
|
824
|
+
const element = target ?? this.host.nativeElement;
|
|
825
|
+
try {
|
|
826
|
+
return element.matches(':focus-visible');
|
|
827
|
+
}
|
|
828
|
+
catch {
|
|
829
|
+
return true;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
hasKeyboardFocus() {
|
|
833
|
+
if (!this.accepts('focus'))
|
|
834
|
+
return false;
|
|
835
|
+
const active = document.activeElement;
|
|
836
|
+
if (!active || !this.host.nativeElement.contains(active))
|
|
837
|
+
return false;
|
|
838
|
+
return this.option('tooltipEvent') === 'focus' || this.isFocusVisible(active);
|
|
839
|
+
}
|
|
840
|
+
/** Outro tooltip aberto, ou fechado ha pouco: este abre na hora e sem animacao. */
|
|
841
|
+
isWarm() {
|
|
842
|
+
const window = this.defaults.warmupWindow;
|
|
843
|
+
if (window <= 0)
|
|
844
|
+
return false;
|
|
845
|
+
return (shared.active !== null && shared.active !== this) || Date.now() - shared.lastClosedAt < window;
|
|
846
|
+
}
|
|
536
847
|
option(key) {
|
|
537
848
|
const fromInputs = {
|
|
538
|
-
tooltipPosition: this.tooltipPosition(),
|
|
539
|
-
showDelay: this.showDelay(),
|
|
540
|
-
hideDelay: this.hideDelay(),
|
|
541
|
-
tooltipEvent: this.tooltipEvent(),
|
|
849
|
+
tooltipPosition: this.tooltipPosition() ?? this.defaults.position,
|
|
850
|
+
showDelay: this.showDelay() ?? this.defaults.showDelay,
|
|
851
|
+
hideDelay: this.hideDelay() ?? this.defaults.hideDelay,
|
|
852
|
+
tooltipEvent: this.tooltipEvent() ?? this.defaults.tooltipEvent,
|
|
542
853
|
escape: this.escape(),
|
|
543
854
|
tooltipStyleClass: this.tooltipStyleClass(),
|
|
544
855
|
tooltipZIndex: this.tooltipZIndex(),
|
|
545
856
|
tooltipDisabled: this.tooltipDisabled(),
|
|
857
|
+
tooltipTitle: this.tooltipTitle() ?? '',
|
|
858
|
+
tooltipShortcut: this.tooltipShortcut() ?? '',
|
|
859
|
+
tooltipVariant: this.tooltipVariant() ?? this.defaults.variant,
|
|
860
|
+
tooltipSeverity: this.tooltipSeverity() ?? null,
|
|
861
|
+
tooltipArrow: this.tooltipArrow() ?? this.defaults.arrow,
|
|
862
|
+
tooltipOnOverflow: this.tooltipOnOverflow(),
|
|
546
863
|
};
|
|
547
864
|
const merged = { ...fromInputs, ...(this.tooltipOptions() ?? {}), ...this.overrides() };
|
|
548
865
|
return merged[key];
|
|
549
866
|
}
|
|
550
|
-
open(
|
|
551
|
-
this.overlayRef
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
867
|
+
open(instant) {
|
|
868
|
+
if (this.overlayRef || !this.canShow())
|
|
869
|
+
return;
|
|
870
|
+
// Um tooltip por vez: o anterior fecha na hora.
|
|
871
|
+
if (shared.active && shared.active !== this)
|
|
872
|
+
shared.active.hide();
|
|
873
|
+
shared.active = this;
|
|
874
|
+
const arrow = this.option('tooltipArrow');
|
|
875
|
+
const positionStrategy = this.overlay
|
|
876
|
+
.position()
|
|
877
|
+
.flexibleConnectedTo(this.host)
|
|
878
|
+
.withPositions(POSITIONS$3[this.option('tooltipPosition')] ?? POSITIONS$3.top)
|
|
879
|
+
.withPush(true);
|
|
880
|
+
// Acompanha o host durante a rolagem e fecha so quando sai da vista. Fechar em qualquer rolagem derrubava o tooltip
|
|
881
|
+
// aberto por foco quando o proprio foco rolava a pagina (Tab ate um elemento fora da tela).
|
|
882
|
+
const scrollStrategy = this.overlay.scrollStrategies.reposition({ scrollThrottle: 20, autoClose: true });
|
|
883
|
+
const overlayRef = this.overlay.create({ positionStrategy, scrollStrategy });
|
|
884
|
+
this.overlayRef = overlayRef;
|
|
559
885
|
const zIndex = this.option('tooltipZIndex');
|
|
560
886
|
if (zIndex !== '')
|
|
561
|
-
|
|
562
|
-
const
|
|
563
|
-
ref.
|
|
887
|
+
overlayRef.hostElement.style.zIndex = String(zIndex);
|
|
888
|
+
const content = this.text();
|
|
889
|
+
const ref = overlayRef.attach(new ComponentPortal(SmzTooltipComponent, this.viewContainer));
|
|
890
|
+
this.componentRef = ref;
|
|
891
|
+
ref.setInput('tooltipId', this.tooltipId);
|
|
892
|
+
ref.setInput('text', typeof content === 'string' ? content : '');
|
|
893
|
+
ref.setInput('template', content instanceof TemplateRef ? content : null);
|
|
564
894
|
ref.setInput('escape', this.option('escape'));
|
|
895
|
+
ref.setInput('title', this.option('tooltipTitle'));
|
|
896
|
+
ref.setInput('shortcut', this.option('tooltipShortcut'));
|
|
897
|
+
ref.setInput('variant', this.option('tooltipVariant'));
|
|
898
|
+
ref.setInput('severity', this.option('tooltipSeverity'));
|
|
899
|
+
ref.setInput('arrow', arrow);
|
|
900
|
+
ref.setInput('styleClass', this.option('tooltipStyleClass'));
|
|
901
|
+
ref.setInput('instant', instant);
|
|
902
|
+
ref.setInput('gap', arrow ? GAP_WITH_ARROW : GAP_PLAIN);
|
|
903
|
+
ref.changeDetectorRef.detectChanges();
|
|
904
|
+
this.subscriptions = new Subscription();
|
|
905
|
+
this.subscriptions.add(this.watchPosition(positionStrategy, ref));
|
|
906
|
+
// Fechado pelo CDK (host rolou para fora da vista): limpa o estado para poder abrir de novo.
|
|
907
|
+
this.subscriptions.add(overlayRef.detachments().subscribe(() => this.hide()));
|
|
908
|
+
overlayRef.overlayElement.addEventListener('mouseenter', this.onPanelEnter);
|
|
909
|
+
overlayRef.overlayElement.addEventListener('mouseleave', this.onPanelLeave);
|
|
910
|
+
document.addEventListener('keydown', this.onDocumentKeydown, true);
|
|
911
|
+
if (this.openedByTouch)
|
|
912
|
+
document.addEventListener('touchstart', this.onDocumentTouch, true);
|
|
913
|
+
this.setDescribedBy(true);
|
|
914
|
+
}
|
|
915
|
+
/** Lado real e posicao da seta, recalculados sempre que o CDK reposiciona (inversao por falta de espaco). */
|
|
916
|
+
watchPosition(strategy, ref) {
|
|
917
|
+
return strategy.positionChanges.subscribe((change) => {
|
|
918
|
+
const side = sideOf(change.connectionPair);
|
|
919
|
+
const sideChanged = ref.instance.side() !== side;
|
|
920
|
+
ref.setInput('side', side);
|
|
921
|
+
ref.changeDetectorRef.detectChanges();
|
|
922
|
+
// A ponte (padding do lado do host) muda o tamanho do painel: reposiciona uma vez com o tamanho final.
|
|
923
|
+
if (sideChanged)
|
|
924
|
+
this.overlayRef?.updatePosition();
|
|
925
|
+
const box = ref.location.nativeElement.querySelector('[role="tooltip"]');
|
|
926
|
+
if (!box)
|
|
927
|
+
return;
|
|
928
|
+
const hostRect = this.host.nativeElement.getBoundingClientRect();
|
|
929
|
+
const boxRect = box.getBoundingClientRect();
|
|
930
|
+
const horizontal = side === 'top' || side === 'bottom';
|
|
931
|
+
const length = horizontal ? boxRect.width : boxRect.height;
|
|
932
|
+
const center = horizontal ? hostRect.left + hostRect.width / 2 - boxRect.left : hostRect.top + hostRect.height / 2 - boxRect.top;
|
|
933
|
+
const inset = Math.min(ARROW_INSET, length / 2);
|
|
934
|
+
ref.setInput('arrowOffset', `${Math.round(Math.max(inset, Math.min(length - inset, center)))}px`);
|
|
935
|
+
ref.changeDetectorRef.detectChanges();
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
/** Associa o tooltip ao host para leitores de tela enquanto estiver aberto. */
|
|
939
|
+
setDescribedBy(open) {
|
|
940
|
+
const element = this.host.nativeElement;
|
|
941
|
+
const current = (element.getAttribute('aria-describedby') ?? '').split(/\s+/).filter((id) => id && id !== this.tooltipId);
|
|
942
|
+
if (open)
|
|
943
|
+
current.push(this.tooltipId);
|
|
944
|
+
if (current.length > 0)
|
|
945
|
+
element.setAttribute('aria-describedby', current.join(' '));
|
|
946
|
+
else
|
|
947
|
+
element.removeAttribute('aria-describedby');
|
|
565
948
|
}
|
|
566
949
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
567
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SmzTooltipDirective, isStandalone: true, selector: "[smzTooltip]", inputs: { text: { classPropertyName: "text", publicName: "smzTooltip", isSignal: true, isRequired: false, transformFunction: null }, tooltipPosition: { classPropertyName: "tooltipPosition", publicName: "tooltipPosition", 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 }, tooltipEvent: { classPropertyName: "tooltipEvent", publicName: "tooltipEvent", isSignal: true, isRequired: false, transformFunction: null }, escape: { classPropertyName: "escape", publicName: "escape", isSignal: true, isRequired: false, transformFunction: null }, tooltipStyleClass: { classPropertyName: "tooltipStyleClass", publicName: "tooltipStyleClass", isSignal: true, isRequired: false, transformFunction: null }, tooltipZIndex: { classPropertyName: "tooltipZIndex", publicName: "tooltipZIndex", isSignal: true, isRequired: false, transformFunction: null }, tooltipDisabled: { classPropertyName: "tooltipDisabled", publicName: "tooltipDisabled", isSignal: true, isRequired: false, transformFunction: null }, tooltipOptions: { classPropertyName: "tooltipOptions", publicName: "tooltipOptions", isSignal: true, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "onEnter('hover')", "mouseleave": "onLeave('hover')", "focusin": "onEnter('focus')", "focusout": "onLeave('focus')", "keydown.escape": "hide()" } }, ngImport: i0 });
|
|
950
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SmzTooltipDirective, isStandalone: true, selector: "[smzTooltip]", inputs: { text: { classPropertyName: "text", publicName: "smzTooltip", isSignal: true, isRequired: false, transformFunction: null }, tooltipPosition: { classPropertyName: "tooltipPosition", publicName: "tooltipPosition", 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 }, tooltipEvent: { classPropertyName: "tooltipEvent", publicName: "tooltipEvent", isSignal: true, isRequired: false, transformFunction: null }, escape: { classPropertyName: "escape", publicName: "escape", isSignal: true, isRequired: false, transformFunction: null }, tooltipStyleClass: { classPropertyName: "tooltipStyleClass", publicName: "tooltipStyleClass", isSignal: true, isRequired: false, transformFunction: null }, tooltipZIndex: { classPropertyName: "tooltipZIndex", publicName: "tooltipZIndex", isSignal: true, isRequired: false, transformFunction: null }, tooltipDisabled: { classPropertyName: "tooltipDisabled", publicName: "tooltipDisabled", isSignal: true, isRequired: false, transformFunction: null }, tooltipTitle: { classPropertyName: "tooltipTitle", publicName: "tooltipTitle", isSignal: true, isRequired: false, transformFunction: null }, tooltipShortcut: { classPropertyName: "tooltipShortcut", publicName: "tooltipShortcut", isSignal: true, isRequired: false, transformFunction: null }, tooltipVariant: { classPropertyName: "tooltipVariant", publicName: "tooltipVariant", isSignal: true, isRequired: false, transformFunction: null }, tooltipSeverity: { classPropertyName: "tooltipSeverity", publicName: "tooltipSeverity", isSignal: true, isRequired: false, transformFunction: null }, tooltipArrow: { classPropertyName: "tooltipArrow", publicName: "tooltipArrow", isSignal: true, isRequired: false, transformFunction: null }, tooltipOnOverflow: { classPropertyName: "tooltipOnOverflow", publicName: "tooltipOnOverflow", isSignal: true, isRequired: false, transformFunction: null }, tooltipOptions: { classPropertyName: "tooltipOptions", publicName: "tooltipOptions", isSignal: true, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "onEnter('hover', $event)", "mouseleave": "onLeave('hover', $event)", "focusin": "onEnter('focus', $event)", "focusout": "onLeave('focus', $event)", "keydown.escape": "hide()", "touchstart": "onTouchStart()", "touchend": "onTouchEnd()", "touchmove": "onTouchEnd()", "touchcancel": "onTouchEnd()" } }, ngImport: i0 });
|
|
568
951
|
}
|
|
569
952
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzTooltipDirective, decorators: [{
|
|
570
953
|
type: Directive,
|
|
571
954
|
args: [{
|
|
572
955
|
selector: '[smzTooltip]',
|
|
573
956
|
host: {
|
|
574
|
-
'(mouseenter)': 'onEnter(\'hover\')',
|
|
575
|
-
'(mouseleave)': 'onLeave(\'hover\')',
|
|
576
|
-
'(focusin)': 'onEnter(\'focus\')',
|
|
577
|
-
'(focusout)': 'onLeave(\'focus\')',
|
|
957
|
+
'(mouseenter)': 'onEnter(\'hover\', $event)',
|
|
958
|
+
'(mouseleave)': 'onLeave(\'hover\', $event)',
|
|
959
|
+
'(focusin)': 'onEnter(\'focus\', $event)',
|
|
960
|
+
'(focusout)': 'onLeave(\'focus\', $event)',
|
|
578
961
|
'(keydown.escape)': 'hide()',
|
|
962
|
+
'(touchstart)': 'onTouchStart()',
|
|
963
|
+
'(touchend)': 'onTouchEnd()',
|
|
964
|
+
'(touchmove)': 'onTouchEnd()',
|
|
965
|
+
'(touchcancel)': 'onTouchEnd()',
|
|
579
966
|
},
|
|
580
967
|
}]
|
|
581
|
-
}], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzTooltip", required: false }] }], tooltipPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipPosition", required: false }] }], showDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDelay", required: false }] }], hideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideDelay", required: false }] }], tooltipEvent: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipEvent", required: false }] }], escape: [{ type: i0.Input, args: [{ isSignal: true, alias: "escape", required: false }] }], tooltipStyleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipStyleClass", required: false }] }], tooltipZIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipZIndex", required: false }] }], tooltipDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipDisabled", required: false }] }], tooltipOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipOptions", required: false }] }], appendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "appendTo", required: false }] }] } });
|
|
968
|
+
}], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzTooltip", required: false }] }], tooltipPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipPosition", required: false }] }], showDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "showDelay", required: false }] }], hideDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideDelay", required: false }] }], tooltipEvent: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipEvent", required: false }] }], escape: [{ type: i0.Input, args: [{ isSignal: true, alias: "escape", required: false }] }], tooltipStyleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipStyleClass", required: false }] }], tooltipZIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipZIndex", required: false }] }], tooltipDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipDisabled", required: false }] }], tooltipTitle: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipTitle", required: false }] }], tooltipShortcut: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipShortcut", required: false }] }], tooltipVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipVariant", required: false }] }], tooltipSeverity: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipSeverity", required: false }] }], tooltipArrow: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipArrow", required: false }] }], tooltipOnOverflow: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipOnOverflow", required: false }] }], tooltipOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipOptions", required: false }] }], appendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "appendTo", required: false }] }] } });
|
|
582
969
|
|
|
583
970
|
/**
|
|
584
971
|
* Efeito ripple. Substitui o `pRipple` do PrimeNG.
|
|
@@ -2499,18 +2886,95 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
|
|
|
2499
2886
|
}]
|
|
2500
2887
|
}], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], fullScreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "fullScreen", required: false }] }], header: [{ type: i0.Input, args: [{ isSignal: true, alias: "header", required: false }] }], modal: [{ type: i0.Input, args: [{ isSignal: true, alias: "modal", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], showCloseIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCloseIcon", required: false }] }], style: [{ type: i0.Input, args: [{ isSignal: true, alias: "style", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }], blockScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "blockScroll", required: false }] }], ariaCloseLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaCloseLabel", required: false }] }], appendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "appendTo", required: false }] }], shown: [{ type: i0.Output, args: ["shown"] }], hidden: [{ type: i0.Output, args: ["hidden"] }], panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], templates: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => SmzTemplateDirective), { isSignal: true }] }] } });
|
|
2501
2888
|
|
|
2889
|
+
const SMZ_TOAST_DEFAULT_OPTIONS = {
|
|
2890
|
+
showProgress: true,
|
|
2891
|
+
pauseOnHover: true,
|
|
2892
|
+
maxVisible: 5,
|
|
2893
|
+
life: 3000,
|
|
2894
|
+
lifeBySeverity: { warn: 6000, error: 6000 },
|
|
2895
|
+
groupDuplicates: true,
|
|
2896
|
+
};
|
|
2897
|
+
const SMZ_TOAST_DEFAULTS = new InjectionToken('SMZ_TOAST_DEFAULTS');
|
|
2898
|
+
/**
|
|
2899
|
+
* Padroes globais do `ui-toast`.
|
|
2900
|
+
*
|
|
2901
|
+
* providers: [provideSmzToastDefaults({ maxVisible: 3, lifeBySeverity: { error: 10000 } })]
|
|
2902
|
+
*/
|
|
2903
|
+
function provideSmzToastDefaults(defaults) {
|
|
2904
|
+
return makeEnvironmentProviders([{ provide: SMZ_TOAST_DEFAULTS, useValue: defaults }]);
|
|
2905
|
+
}
|
|
2906
|
+
const globalDefaults = {};
|
|
2907
|
+
/**
|
|
2908
|
+
* Padroes globais definidos fora da injecao de dependencias (usado pelo `SmzUiBuilder` do @ngx-smz/core).
|
|
2909
|
+
* O token `SMZ_TOAST_DEFAULTS`, quando provido, tem precedencia. Campos `undefined` sao ignorados.
|
|
2910
|
+
*/
|
|
2911
|
+
function smzSetToastDefaults(defaults) {
|
|
2912
|
+
for (const [key, value] of Object.entries(defaults ?? {})) {
|
|
2913
|
+
if (value !== undefined && value !== null)
|
|
2914
|
+
globalDefaults[key] = value;
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
/** Padroes em vigor: base do kit, depois `smzSetToastDefaults`, depois o token. */
|
|
2918
|
+
function smzResolveToastDefaults(provided) {
|
|
2919
|
+
return { ...SMZ_TOAST_DEFAULT_OPTIONS, ...globalDefaults, ...(provided ?? {}) };
|
|
2920
|
+
}
|
|
2502
2921
|
let nextId = 0;
|
|
2922
|
+
const GROUP_FIELDS = ['key', 'severity', 'summary', 'detail', 'icon', 'sticky', 'styleClass'];
|
|
2923
|
+
function sameContent(a, b) {
|
|
2924
|
+
return GROUP_FIELDS.every((field) => (a[field] ?? null) === (b[field] ?? null)) && (a.action?.label ?? null) === (b.action?.label ?? null);
|
|
2925
|
+
}
|
|
2503
2926
|
/** Barramento de mensagens do toast. Substitui o `MessageService` do PrimeNG. */
|
|
2504
2927
|
class SmzMessageService {
|
|
2505
2928
|
state = signal([], ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
2929
|
+
providedDefaults = inject(SMZ_TOAST_DEFAULTS, { optional: true });
|
|
2506
2930
|
/** Mensagens atualmente na fila (todas as chaves). */
|
|
2507
2931
|
messages = this.state.asReadonly();
|
|
2508
2932
|
add(message) {
|
|
2509
2933
|
this.addAll([message]);
|
|
2510
2934
|
}
|
|
2511
2935
|
addAll(messages) {
|
|
2512
|
-
const
|
|
2513
|
-
this.state.update((current) =>
|
|
2936
|
+
const groupDuplicates = smzResolveToastDefaults(this.providedDefaults).groupDuplicates;
|
|
2937
|
+
this.state.update((current) => {
|
|
2938
|
+
const next = [...current];
|
|
2939
|
+
for (const message of messages) {
|
|
2940
|
+
const canGroup = groupDuplicates && message.group !== false && !message.loading && (message.id === undefined || message.id === null);
|
|
2941
|
+
const index = canGroup ? next.findIndex((entry) => entry.group !== false && !entry.loading && sameContent(entry, message)) : -1;
|
|
2942
|
+
if (index >= 0) {
|
|
2943
|
+
const existing = next[index];
|
|
2944
|
+
next[index] = { ...existing, count: (existing.count ?? 1) + 1, revision: (existing.revision ?? 0) + 1 };
|
|
2945
|
+
}
|
|
2946
|
+
else {
|
|
2947
|
+
next.push({ ...message, id: message.id ?? `smz-toast-${++nextId}` });
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
return next;
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
/** Atualiza no lugar a mensagem com esse `id` e reinicia o tempo de vida dela. */
|
|
2954
|
+
update(id, changes) {
|
|
2955
|
+
this.state.update((current) => current.map((entry) => (entry.id === id ? { ...entry, ...changes, id, revision: (entry.revision ?? 0) + 1 } : entry)));
|
|
2956
|
+
}
|
|
2957
|
+
/**
|
|
2958
|
+
* Toast de carregamento que depois vira o resultado, no mesmo lugar.
|
|
2959
|
+
*
|
|
2960
|
+
* const toast = messages.loading({ summary: 'Gerando Excel...' });
|
|
2961
|
+
* exportar().subscribe({ next: () => toast.success('Excel gerado com sucesso.'), error: () => toast.error('Falha ao gerar o Excel.') });
|
|
2962
|
+
*/
|
|
2963
|
+
loading(message) {
|
|
2964
|
+
const base = typeof message === 'string' ? { summary: message } : message;
|
|
2965
|
+
const id = base.id ?? `smz-toast-${++nextId}`;
|
|
2966
|
+
this.state.update((current) => [...current, { severity: 'secondary', closable: false, ...base, id, loading: true }]);
|
|
2967
|
+
const settle = (severity, result) => {
|
|
2968
|
+
const changes = typeof result === 'string' ? { detail: result } : (result ?? {});
|
|
2969
|
+
this.update(id, { closable: true, ...changes, severity: changes.severity ?? severity, loading: false });
|
|
2970
|
+
};
|
|
2971
|
+
return {
|
|
2972
|
+
id,
|
|
2973
|
+
update: (changes) => this.update(id, changes),
|
|
2974
|
+
success: (result) => settle('success', result),
|
|
2975
|
+
error: (result) => settle('error', result),
|
|
2976
|
+
close: () => this.remove({ id }),
|
|
2977
|
+
};
|
|
2514
2978
|
}
|
|
2515
2979
|
remove(message) {
|
|
2516
2980
|
this.state.update((current) => current.filter((entry) => entry !== message && entry.id !== message.id));
|
|
@@ -2536,6 +3000,16 @@ const POSITION_CLASSES = {
|
|
|
2536
3000
|
'bottom-right': 'bottom-4 right-4 items-end',
|
|
2537
3001
|
center: 'top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 items-center',
|
|
2538
3002
|
};
|
|
3003
|
+
/** De onde o toast entra: do lado da tela em que o container esta. */
|
|
3004
|
+
const ENTER_OFFSET = {
|
|
3005
|
+
'top-left': { x: -28, y: 0 },
|
|
3006
|
+
'top-center': { x: 0, y: -18 },
|
|
3007
|
+
'top-right': { x: 28, y: 0 },
|
|
3008
|
+
'bottom-left': { x: -28, y: 0 },
|
|
3009
|
+
'bottom-center': { x: 0, y: 18 },
|
|
3010
|
+
'bottom-right': { x: 28, y: 0 },
|
|
3011
|
+
center: { x: 0, y: 0 },
|
|
3012
|
+
};
|
|
2539
3013
|
const SEVERITY_TONE = {
|
|
2540
3014
|
success: 'success',
|
|
2541
3015
|
info: 'primary',
|
|
@@ -2545,42 +3019,213 @@ const SEVERITY_TONE = {
|
|
|
2545
3019
|
contrast: 'secondary',
|
|
2546
3020
|
};
|
|
2547
3021
|
/**
|
|
2548
|
-
*
|
|
2549
|
-
*
|
|
2550
|
-
* Strings literais para o Tailwind encontrar no scan.
|
|
3022
|
+
* O texto usa `text-ui-fg` / `text-ui-fg-muted` sobre fundo opaco (contraste AA em qualquer tema); a severidade fica
|
|
3023
|
+
* no icone, na barra e na tinta. Strings literais para o Tailwind encontrar no scan.
|
|
2551
3024
|
*/
|
|
2552
3025
|
const TOAST_TONE = {
|
|
2553
|
-
primary:
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
3026
|
+
primary: {
|
|
3027
|
+
card: 'border-ui-primary/40 bg-[linear-gradient(rgb(var(--smz-color-primary)/0.07),rgb(var(--smz-color-primary)/0.07))]',
|
|
3028
|
+
solid: 'bg-ui-primary text-ui-on-primary',
|
|
3029
|
+
track: 'bg-ui-primary/20',
|
|
3030
|
+
fill: 'bg-ui-primary',
|
|
3031
|
+
action: 'border-ui-primary/50 hover:bg-ui-primary/15',
|
|
3032
|
+
},
|
|
3033
|
+
secondary: {
|
|
3034
|
+
card: 'border-ui-line-strong bg-[linear-gradient(rgb(var(--smz-color-fg-muted)/0.07),rgb(var(--smz-color-fg-muted)/0.07))]',
|
|
3035
|
+
solid: 'bg-ui-fg-muted text-ui-surface-1',
|
|
3036
|
+
track: 'bg-ui-fg-muted/20',
|
|
3037
|
+
fill: 'bg-ui-fg-muted',
|
|
3038
|
+
action: 'border-ui-line-strong hover:bg-ui-fg-muted/15',
|
|
3039
|
+
},
|
|
3040
|
+
success: {
|
|
3041
|
+
card: 'border-ui-success/40 bg-[linear-gradient(rgb(var(--smz-color-success)/0.07),rgb(var(--smz-color-success)/0.07))]',
|
|
3042
|
+
solid: 'bg-ui-success text-ui-on-success',
|
|
3043
|
+
track: 'bg-ui-success/20',
|
|
3044
|
+
fill: 'bg-ui-success',
|
|
3045
|
+
action: 'border-ui-success/50 hover:bg-ui-success/15',
|
|
3046
|
+
},
|
|
3047
|
+
warning: {
|
|
3048
|
+
card: 'border-ui-warning/50 bg-[linear-gradient(rgb(var(--smz-color-warning)/0.09),rgb(var(--smz-color-warning)/0.09))]',
|
|
3049
|
+
solid: 'bg-ui-warning text-ui-on-warning',
|
|
3050
|
+
track: 'bg-ui-warning/25',
|
|
3051
|
+
fill: 'bg-ui-warning',
|
|
3052
|
+
action: 'border-ui-warning/60 hover:bg-ui-warning/15',
|
|
3053
|
+
},
|
|
3054
|
+
danger: {
|
|
3055
|
+
card: 'border-ui-danger/40 bg-[linear-gradient(rgb(var(--smz-color-danger)/0.07),rgb(var(--smz-color-danger)/0.07))]',
|
|
3056
|
+
solid: 'bg-ui-danger text-ui-on-danger',
|
|
3057
|
+
track: 'bg-ui-danger/20',
|
|
3058
|
+
fill: 'bg-ui-danger',
|
|
3059
|
+
action: 'border-ui-danger/50 hover:bg-ui-danger/15',
|
|
3060
|
+
},
|
|
2558
3061
|
};
|
|
2559
|
-
const
|
|
3062
|
+
const SWIPE_DISMISS = 80;
|
|
3063
|
+
/** Inputs opcionais: ausente (`undefined`) significa "usa o padrao global". */
|
|
3064
|
+
const optionalNumber = (value) => (value === undefined || value === null || value === '' ? undefined : numberAttribute(value));
|
|
3065
|
+
const optionalBoolean = (value) => (value === undefined || value === null ? undefined : booleanAttribute(value));
|
|
3066
|
+
function prefersReducedMotion() {
|
|
3067
|
+
return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
3068
|
+
}
|
|
3069
|
+
/**
|
|
3070
|
+
* Relogio do toast: a barra que encolhe E o fechamento sao a mesma animacao (Web Animations API), entao nunca
|
|
3071
|
+
* dessincronizam. Pausar e pausar a animacao; `expired` dispara quando ela termina.
|
|
3072
|
+
* Nao usa animacao CSS de proposito: resets globais de `prefers-reduced-motion` (`animation-duration: 0.01ms !important`)
|
|
3073
|
+
* fechariam o toast na hora. Sem `Element.animate` (SSR, testes) cai para `setTimeout`.
|
|
3074
|
+
*/
|
|
3075
|
+
class SmzToastLifeDirective {
|
|
3076
|
+
/** Tempo de vida em ms. */
|
|
3077
|
+
duration = input.required({ ...(ngDevMode ? { debugName: "duration" } : /* istanbul ignore next */ {}), alias: 'smzToastLife' });
|
|
3078
|
+
paused = input(false, ...(ngDevMode ? [{ debugName: "paused" }] : /* istanbul ignore next */ []));
|
|
3079
|
+
/** Mudou: reinicia do zero (mensagem atualizada ou repetida). */
|
|
3080
|
+
revision = input(0, ...(ngDevMode ? [{ debugName: "revision" }] : /* istanbul ignore next */ []));
|
|
3081
|
+
expired = output();
|
|
3082
|
+
element = inject(ElementRef).nativeElement;
|
|
3083
|
+
animation;
|
|
3084
|
+
timer;
|
|
3085
|
+
remaining = 0;
|
|
3086
|
+
startedAt = 0;
|
|
3087
|
+
constructor() {
|
|
3088
|
+
effect(() => {
|
|
3089
|
+
this.revision();
|
|
3090
|
+
const duration = this.duration();
|
|
3091
|
+
untracked(() => this.start(duration));
|
|
3092
|
+
});
|
|
3093
|
+
effect(() => {
|
|
3094
|
+
const paused = this.paused();
|
|
3095
|
+
untracked(() => (paused ? this.pause() : this.resume()));
|
|
3096
|
+
});
|
|
3097
|
+
inject(DestroyRef).onDestroy(() => this.stop());
|
|
3098
|
+
}
|
|
3099
|
+
start(duration) {
|
|
3100
|
+
this.stop();
|
|
3101
|
+
const life = Math.max(0, duration);
|
|
3102
|
+
if (typeof this.element.animate === 'function') {
|
|
3103
|
+
this.animation = this.element.animate([{ transform: 'scaleX(1)' }, { transform: 'scaleX(0)' }], { duration: life, easing: 'linear', fill: 'forwards' });
|
|
3104
|
+
this.animation.onfinish = () => this.expired.emit();
|
|
3105
|
+
if (this.paused())
|
|
3106
|
+
this.animation.pause();
|
|
3107
|
+
return;
|
|
3108
|
+
}
|
|
3109
|
+
this.remaining = life;
|
|
3110
|
+
if (!this.paused())
|
|
3111
|
+
this.arm();
|
|
3112
|
+
}
|
|
3113
|
+
pause() {
|
|
3114
|
+
if (this.animation) {
|
|
3115
|
+
if (this.animation.playState === 'running')
|
|
3116
|
+
this.animation.pause();
|
|
3117
|
+
return;
|
|
3118
|
+
}
|
|
3119
|
+
if (this.timer === undefined)
|
|
3120
|
+
return;
|
|
3121
|
+
clearTimeout(this.timer);
|
|
3122
|
+
this.timer = undefined;
|
|
3123
|
+
this.remaining = Math.max(0, this.remaining - (Date.now() - this.startedAt));
|
|
3124
|
+
}
|
|
3125
|
+
resume() {
|
|
3126
|
+
if (this.animation) {
|
|
3127
|
+
if (this.animation.playState === 'paused')
|
|
3128
|
+
this.animation.play();
|
|
3129
|
+
return;
|
|
3130
|
+
}
|
|
3131
|
+
if (this.timer === undefined && this.remaining > 0)
|
|
3132
|
+
this.arm();
|
|
3133
|
+
}
|
|
3134
|
+
arm() {
|
|
3135
|
+
this.startedAt = Date.now();
|
|
3136
|
+
this.timer = setTimeout(() => {
|
|
3137
|
+
this.timer = undefined;
|
|
3138
|
+
this.remaining = 0;
|
|
3139
|
+
this.expired.emit();
|
|
3140
|
+
}, this.remaining);
|
|
3141
|
+
}
|
|
3142
|
+
stop() {
|
|
3143
|
+
if (this.animation) {
|
|
3144
|
+
this.animation.onfinish = null;
|
|
3145
|
+
this.animation.cancel();
|
|
3146
|
+
this.animation = undefined;
|
|
3147
|
+
}
|
|
3148
|
+
clearTimeout(this.timer);
|
|
3149
|
+
this.timer = undefined;
|
|
3150
|
+
}
|
|
3151
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastLifeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3152
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SmzToastLifeDirective, isStandalone: true, selector: "[smzToastLife]", inputs: { duration: { classPropertyName: "duration", publicName: "smzToastLife", isSignal: true, isRequired: true, transformFunction: null }, paused: { classPropertyName: "paused", publicName: "paused", isSignal: true, isRequired: false, transformFunction: null }, revision: { classPropertyName: "revision", publicName: "revision", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expired: "expired" }, ngImport: i0 });
|
|
3153
|
+
}
|
|
3154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastLifeDirective, decorators: [{
|
|
3155
|
+
type: Directive,
|
|
3156
|
+
args: [{ selector: '[smzToastLife]' }]
|
|
3157
|
+
}], ctorParameters: () => [], propDecorators: { duration: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzToastLife", required: true }] }], paused: [{ type: i0.Input, args: [{ isSignal: true, alias: "paused", required: false }] }], revision: [{ type: i0.Input, args: [{ isSignal: true, alias: "revision", required: false }] }], expired: [{ type: i0.Output, args: ["expired"] }] } });
|
|
3158
|
+
/** Animacao de entrada do toast (uma vez, quando o elemento nasce): desliza do lado do container com fade. */
|
|
3159
|
+
class SmzToastEnterDirective {
|
|
3160
|
+
offset = input({ x: 0, y: 0 }, { ...(ngDevMode ? { debugName: "offset" } : /* istanbul ignore next */ {}), alias: 'smzToastEnter' });
|
|
3161
|
+
constructor() {
|
|
3162
|
+
const element = inject(ElementRef).nativeElement;
|
|
3163
|
+
let played = false;
|
|
3164
|
+
effect(() => {
|
|
3165
|
+
const { x, y } = this.offset();
|
|
3166
|
+
if (played || typeof element.animate !== 'function')
|
|
3167
|
+
return;
|
|
3168
|
+
played = true;
|
|
3169
|
+
if (prefersReducedMotion()) {
|
|
3170
|
+
element.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 200, easing: 'ease-out' });
|
|
3171
|
+
return;
|
|
3172
|
+
}
|
|
3173
|
+
element.animate([{ opacity: 0, transform: `translate(${x}px, ${y}px)` }, { opacity: 1, transform: 'none' }], { duration: 220, easing: 'cubic-bezier(0.2, 0.8, 0.2, 1)' });
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3176
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastEnterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3177
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SmzToastEnterDirective, isStandalone: true, selector: "[smzToastEnter]", inputs: { offset: { classPropertyName: "offset", publicName: "smzToastEnter", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
3178
|
+
}
|
|
3179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastEnterDirective, decorators: [{
|
|
3180
|
+
type: Directive,
|
|
3181
|
+
args: [{ selector: '[smzToastEnter]' }]
|
|
3182
|
+
}], ctorParameters: () => [], propDecorators: { offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzToastEnter", required: false }] }] } });
|
|
2560
3183
|
/**
|
|
2561
3184
|
* Container de toasts: exibe as mensagens do `SmzMessageService`. Substitui o `p-toast` do PrimeNG.
|
|
2562
3185
|
*
|
|
2563
3186
|
* <ui-toast position="bottom-right" />
|
|
3187
|
+
*
|
|
3188
|
+
* Cada toast tem icone da severidade, barra de progresso do tempo de vida (pausa com mouse/foco sobre a pilha e com a
|
|
3189
|
+
* aba em segundo plano), animacao de entrada/saida e, opcionalmente, um botao de acao.
|
|
2564
3190
|
*/
|
|
2565
3191
|
class SmzToastContainerComponent {
|
|
2566
3192
|
position = input('top-right', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
2567
3193
|
key = input(undefined, ...(ngDevMode ? [{ debugName: "key" }] : /* istanbul ignore next */ []));
|
|
2568
|
-
|
|
3194
|
+
/** Tempo de vida (ms) das mensagens sem `life`. Sem o input valem os padroes globais (3s; aviso e erro 6s). */
|
|
3195
|
+
life = input(undefined, { ...(ngDevMode ? { debugName: "life" } : /* istanbul ignore next */ {}), transform: optionalNumber });
|
|
3196
|
+
/** Tempo de vida (ms) por severidade; tem precedencia sobre `life`. */
|
|
3197
|
+
lifeBySeverity = input(undefined, ...(ngDevMode ? [{ debugName: "lifeBySeverity" }] : /* istanbul ignore next */ []));
|
|
3198
|
+
showProgress = input(undefined, { ...(ngDevMode ? { debugName: "showProgress" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
|
|
3199
|
+
pauseOnHover = input(undefined, { ...(ngDevMode ? { debugName: "pauseOnHover" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
|
|
3200
|
+
/** Maximo de toasts visiveis; os excedentes entram quando abrir espaco (padrao 5). */
|
|
3201
|
+
maxVisible = input(undefined, { ...(ngDevMode ? { debugName: "maxVisible" } : /* istanbul ignore next */ {}), transform: optionalNumber });
|
|
2569
3202
|
style = input(null, ...(ngDevMode ? [{ debugName: "style" }] : /* istanbul ignore next */ []));
|
|
2570
3203
|
styleClass = input('', ...(ngDevMode ? [{ debugName: "styleClass" }] : /* istanbul ignore next */ []));
|
|
2571
3204
|
service = inject(SmzMessageService);
|
|
2572
|
-
|
|
3205
|
+
providedDefaults = inject(SMZ_TOAST_DEFAULTS, { optional: true });
|
|
3206
|
+
leaving = new Set();
|
|
3207
|
+
drag;
|
|
3208
|
+
hovered = signal(false, ...(ngDevMode ? [{ debugName: "hovered" }] : /* istanbul ignore next */ []));
|
|
3209
|
+
focused = signal(false, ...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
|
|
3210
|
+
hidden = signal(typeof document !== 'undefined' && document.visibilityState === 'hidden', ...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
|
|
2573
3211
|
positionClasses = computed(() => POSITION_CLASSES[this.position()] ?? POSITION_CLASSES['top-right'], ...(ngDevMode ? [{ debugName: "positionClasses" }] : /* istanbul ignore next */ []));
|
|
3212
|
+
enterOffset = computed(() => ENTER_OFFSET[this.position()] ?? ENTER_OFFSET['top-right'], ...(ngDevMode ? [{ debugName: "enterOffset" }] : /* istanbul ignore next */ []));
|
|
2574
3213
|
visibleMessages = computed(() => {
|
|
2575
3214
|
const key = this.key();
|
|
2576
3215
|
return this.service.messages().filter((message) => (key ? message.key === key : !message.key));
|
|
2577
3216
|
}, ...(ngDevMode ? [{ debugName: "visibleMessages" }] : /* istanbul ignore next */ []));
|
|
3217
|
+
/** As primeiras `maxVisible`; o relogio das demais so comeca quando elas entram na tela. */
|
|
3218
|
+
shownMessages = computed(() => {
|
|
3219
|
+
const max = this.maxVisible() ?? this.defaults.maxVisible;
|
|
3220
|
+
const messages = this.visibleMessages();
|
|
3221
|
+
return max > 0 ? messages.slice(0, max) : messages;
|
|
3222
|
+
}, ...(ngDevMode ? [{ debugName: "shownMessages" }] : /* istanbul ignore next */ []));
|
|
2578
3223
|
layer = viewChild('layer', ...(ngDevMode ? [{ debugName: "layer" }] : /* istanbul ignore next */ []));
|
|
3224
|
+
stack = viewChild('stack', ...(ngDevMode ? [{ debugName: "stack" }] : /* istanbul ignore next */ []));
|
|
3225
|
+
get defaults() {
|
|
3226
|
+
return smzResolveToastDefaults(this.providedDefaults);
|
|
3227
|
+
}
|
|
2579
3228
|
constructor() {
|
|
2580
|
-
effect(() => {
|
|
2581
|
-
for (const message of this.visibleMessages())
|
|
2582
|
-
this.schedule(message);
|
|
2583
|
-
});
|
|
2584
3229
|
// Abre a camada quando ha mensagens (reabrindo a cada mudanca para ficar acima de overlays abertos depois) e fecha quando nao ha.
|
|
2585
3230
|
effect(() => {
|
|
2586
3231
|
const count = this.visibleMessages().length;
|
|
@@ -2597,150 +3242,436 @@ class SmzToastContainerComponent {
|
|
|
2597
3242
|
/* sem suporte: segue com z-index */
|
|
2598
3243
|
}
|
|
2599
3244
|
});
|
|
2600
|
-
|
|
3245
|
+
if (typeof document !== 'undefined') {
|
|
3246
|
+
// Aba em segundo plano: o tempo nao corre, para o usuario nao perder mensagens que venceriam sem ele ver.
|
|
3247
|
+
const onVisibility = () => this.hidden.set(document.visibilityState === 'hidden');
|
|
3248
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
3249
|
+
inject(DestroyRef).onDestroy(() => document.removeEventListener('visibilitychange', onVisibility));
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
tone(message) {
|
|
3253
|
+
return TOAST_TONE[this.severityOf(message)] ?? TOAST_TONE.primary;
|
|
3254
|
+
}
|
|
3255
|
+
countClasses(message) {
|
|
3256
|
+
return `inline-block shrink-0 rounded-full px-[7px] font-ui-mono text-[11px] font-medium leading-[18px] ${this.tone(message).solid}`;
|
|
3257
|
+
}
|
|
3258
|
+
iconOf(message) {
|
|
3259
|
+
return this.severityOf(message);
|
|
3260
|
+
}
|
|
3261
|
+
/** Aviso e erro interrompem o leitor de tela (`alert`); o resto e anunciado quando ele estiver livre (`status`). */
|
|
3262
|
+
isAssertive(message) {
|
|
3263
|
+
return !message.loading && (message.severity === 'warn' || message.severity === 'error');
|
|
3264
|
+
}
|
|
3265
|
+
hasLife(message) {
|
|
3266
|
+
return !message.sticky && !message.loading;
|
|
3267
|
+
}
|
|
3268
|
+
showsProgress(message) {
|
|
3269
|
+
return message.showProgress ?? this.showProgress() ?? this.defaults.showProgress;
|
|
2601
3270
|
}
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
3271
|
+
lifeOf(message) {
|
|
3272
|
+
if (typeof message.life === 'number')
|
|
3273
|
+
return message.life;
|
|
3274
|
+
const severity = message.severity ?? 'info';
|
|
3275
|
+
const fromInput = this.lifeBySeverity()?.[severity] ?? this.life();
|
|
3276
|
+
if (typeof fromInput === 'number')
|
|
3277
|
+
return fromInput;
|
|
3278
|
+
return this.defaults.lifeBySeverity[severity] ?? this.defaults.life;
|
|
2605
3279
|
}
|
|
3280
|
+
/** Mouse ou foco em qualquer toast seguram a pilha inteira: os de baixo nao somem nem pulam embaixo do cursor. */
|
|
3281
|
+
isPaused(message) {
|
|
3282
|
+
if (this.hidden())
|
|
3283
|
+
return true;
|
|
3284
|
+
const pausable = message.pauseOnHover ?? this.pauseOnHover() ?? this.defaults.pauseOnHover;
|
|
3285
|
+
return pausable && (this.hovered() || this.focused());
|
|
3286
|
+
}
|
|
3287
|
+
onFocusOut(event) {
|
|
3288
|
+
const next = event.relatedTarget;
|
|
3289
|
+
this.focused.set(!!next && !!this.stack()?.nativeElement.contains(next));
|
|
3290
|
+
}
|
|
3291
|
+
runAction(message) {
|
|
3292
|
+
const action = message.action;
|
|
3293
|
+
if (!action)
|
|
3294
|
+
return;
|
|
3295
|
+
action.callback();
|
|
3296
|
+
if (action.closeOnClick !== false)
|
|
3297
|
+
this.close(message);
|
|
3298
|
+
}
|
|
3299
|
+
/** Fecha com animacao de saida (fade + leve escala, depois a altura colapsa) e so entao remove a mensagem. */
|
|
2606
3300
|
close(message) {
|
|
2607
|
-
this.
|
|
2608
|
-
|
|
3301
|
+
if (this.leaving.has(message.id))
|
|
3302
|
+
return;
|
|
3303
|
+
const slot = this.slotOf(message);
|
|
3304
|
+
const card = slot?.firstElementChild;
|
|
3305
|
+
if (!slot || !card || typeof card.animate !== 'function') {
|
|
3306
|
+
this.remove(message);
|
|
3307
|
+
return;
|
|
3308
|
+
}
|
|
3309
|
+
this.leaving.add(message.id);
|
|
3310
|
+
card.style.pointerEvents = 'none';
|
|
3311
|
+
const reduced = prefersReducedMotion();
|
|
3312
|
+
const fade = card.animate(reduced ? [{ opacity: 1 }, { opacity: 0 }] : [{ opacity: 1, transform: 'scale(1)' }, { opacity: 0, transform: 'scale(0.96)' }], { duration: 160, easing: 'ease-in', fill: 'forwards' });
|
|
3313
|
+
fade.onfinish = () => {
|
|
3314
|
+
if (reduced) {
|
|
3315
|
+
this.remove(message);
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
const height = slot.getBoundingClientRect().height;
|
|
3319
|
+
slot.style.overflow = 'hidden';
|
|
3320
|
+
const collapse = slot.animate([{ height: `${height}px`, paddingBottom: getComputedStyle(slot).paddingBottom }, { height: '0px', paddingBottom: '0px' }], { duration: 160, easing: 'ease-out', fill: 'forwards' });
|
|
3321
|
+
collapse.onfinish = () => this.remove(message);
|
|
3322
|
+
collapse.oncancel = () => this.remove(message);
|
|
3323
|
+
};
|
|
3324
|
+
fade.oncancel = () => this.remove(message);
|
|
2609
3325
|
}
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
if (
|
|
3326
|
+
onPointerDown(event, message) {
|
|
3327
|
+
// Arrastar para dispensar so em toque/caneta; com mouse existe o botao de fechar.
|
|
3328
|
+
if (event.pointerType === 'mouse' || event.target?.closest('button, a'))
|
|
2613
3329
|
return;
|
|
2614
|
-
|
|
2615
|
-
timer.remaining -= Date.now() - timer.start;
|
|
3330
|
+
this.drag = { id: message.id, pointerId: event.pointerId, startX: event.clientX, dx: 0, element: event.currentTarget };
|
|
2616
3331
|
}
|
|
2617
|
-
|
|
2618
|
-
const
|
|
2619
|
-
if (!
|
|
3332
|
+
onPointerMove(event) {
|
|
3333
|
+
const drag = this.drag;
|
|
3334
|
+
if (!drag || drag.pointerId !== event.pointerId)
|
|
2620
3335
|
return;
|
|
2621
|
-
|
|
3336
|
+
drag.dx = event.clientX - drag.startX;
|
|
3337
|
+
drag.element.style.transform = `translateX(${drag.dx}px)`;
|
|
3338
|
+
drag.element.style.opacity = String(Math.max(0.3, 1 - Math.abs(drag.dx) / 240));
|
|
2622
3339
|
}
|
|
2623
|
-
|
|
2624
|
-
|
|
3340
|
+
onPointerUp(event, message) {
|
|
3341
|
+
const drag = this.drag;
|
|
3342
|
+
if (!drag || drag.pointerId !== event.pointerId)
|
|
3343
|
+
return;
|
|
3344
|
+
this.drag = undefined;
|
|
3345
|
+
if (event.type === 'pointerup' && Math.abs(drag.dx) >= SWIPE_DISMISS) {
|
|
3346
|
+
this.remove(message);
|
|
2625
3347
|
return;
|
|
2626
|
-
|
|
3348
|
+
}
|
|
3349
|
+
drag.element.style.transform = '';
|
|
3350
|
+
drag.element.style.opacity = '';
|
|
3351
|
+
}
|
|
3352
|
+
remove(message) {
|
|
3353
|
+
this.leaving.delete(message.id);
|
|
3354
|
+
this.service.remove(message);
|
|
3355
|
+
// O elemento sob o mouse/foco sumiu sem `mouseleave`/`focusout`: confere o estado real para a pilha nao ficar presa em pausa.
|
|
3356
|
+
setTimeout(() => {
|
|
3357
|
+
const stack = this.stack()?.nativeElement;
|
|
3358
|
+
if (!stack)
|
|
3359
|
+
return;
|
|
3360
|
+
if (this.focused() && !stack.contains(document.activeElement))
|
|
3361
|
+
this.focused.set(false);
|
|
3362
|
+
if (this.hovered() && !stack.matches(':hover'))
|
|
3363
|
+
this.hovered.set(false);
|
|
3364
|
+
}, 50);
|
|
2627
3365
|
}
|
|
2628
|
-
|
|
2629
|
-
const
|
|
2630
|
-
|
|
3366
|
+
slotOf(message) {
|
|
3367
|
+
const slots = this.stack()?.nativeElement.querySelectorAll('[data-part="slot"]');
|
|
3368
|
+
return Array.from(slots ?? []).find((slot) => slot.getAttribute('data-toast-id') === String(message.id)) ?? null;
|
|
2631
3369
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
if (timer)
|
|
2635
|
-
clearTimeout(timer.handle);
|
|
2636
|
-
this.timers.delete(message.id);
|
|
3370
|
+
severityOf(message) {
|
|
3371
|
+
return SEVERITY_TONE[message.severity ?? 'info'] ?? 'primary';
|
|
2637
3372
|
}
|
|
2638
3373
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2639
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SmzToastContainerComponent, isStandalone: true, selector: "ui-toast", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null }, life: { classPropertyName: "life", publicName: "life", isSignal: true, isRequired: false, transformFunction: null }, style: { classPropertyName: "style", publicName: "style", isSignal: true, isRequired: false, transformFunction: null }, styleClass: { classPropertyName: "styleClass", publicName: "styleClass", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "layer", first: true, predicate: ["layer"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
3374
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.5", type: SmzToastContainerComponent, isStandalone: true, selector: "ui-toast", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null }, life: { classPropertyName: "life", publicName: "life", isSignal: true, isRequired: false, transformFunction: null }, lifeBySeverity: { classPropertyName: "lifeBySeverity", publicName: "lifeBySeverity", isSignal: true, isRequired: false, transformFunction: null }, showProgress: { classPropertyName: "showProgress", publicName: "showProgress", isSignal: true, isRequired: false, transformFunction: null }, pauseOnHover: { classPropertyName: "pauseOnHover", publicName: "pauseOnHover", isSignal: true, isRequired: false, transformFunction: null }, maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null }, style: { classPropertyName: "style", publicName: "style", isSignal: true, isRequired: false, transformFunction: null }, styleClass: { classPropertyName: "styleClass", publicName: "styleClass", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "layer", first: true, predicate: ["layer"], descendants: true, isSignal: true }, { propertyName: "stack", first: true, predicate: ["stack"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
2640
3375
|
<!-- Camada na top layer (Popover API): overlays do CDK (drawer/dialog) ficam la e z-index nao os supera. -->
|
|
2641
3376
|
<div #layer popover="manual" class="pointer-events-none fixed inset-0 m-0 h-full w-full overflow-visible border-0 bg-transparent p-0">
|
|
2642
3377
|
<div
|
|
2643
|
-
|
|
3378
|
+
#stack
|
|
3379
|
+
class="pointer-events-none fixed z-[2000] flex w-96 max-w-[95vw] flex-col"
|
|
2644
3380
|
[class]="positionClasses()"
|
|
2645
3381
|
[ngClass]="styleClass()"
|
|
2646
3382
|
[ngStyle]="style()"
|
|
3383
|
+
[attr.data-paused]="hovered() || focused() || hidden()"
|
|
3384
|
+
(mouseenter)="hovered.set(true)"
|
|
3385
|
+
(mouseleave)="hovered.set(false)"
|
|
3386
|
+
(focusin)="focused.set(true)"
|
|
3387
|
+
(focusout)="onFocusOut($event)"
|
|
2647
3388
|
>
|
|
2648
|
-
@for (message of
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
3389
|
+
@for (message of shownMessages(); track message.id) {
|
|
3390
|
+
<!-- O espaco entre toasts e padding do slot (nao gap): o mouse atravessa a pilha sem "sair" dela. -->
|
|
3391
|
+
<div class="pointer-events-auto w-full pb-2" data-part="slot" [attr.data-toast-id]="message.id">
|
|
3392
|
+
<div
|
|
3393
|
+
class="relative flex touch-pan-y items-start gap-3 overflow-hidden rounded-overlay border bg-ui-surface-2 py-3 pl-3.5 pr-3 font-ui text-ui-fg shadow-[0_12px_32px_-8px_rgb(0_0_0/0.28),0_2px_8px_rgb(0_0_0/0.08)]"
|
|
3394
|
+
[class]="tone(message).card"
|
|
3395
|
+
[ngClass]="message.styleClass"
|
|
3396
|
+
[style.padding-bottom.px]="hasLife(message) ? 15 : null"
|
|
3397
|
+
[attr.role]="isAssertive(message) ? 'alert' : 'status'"
|
|
3398
|
+
[attr.aria-live]="isAssertive(message) ? 'assertive' : 'polite'"
|
|
3399
|
+
aria-atomic="true"
|
|
3400
|
+
[attr.data-severity]="message.severity ?? 'info'"
|
|
3401
|
+
[attr.data-loading]="message.loading ? 'true' : null"
|
|
3402
|
+
[smzToastEnter]="enterOffset()"
|
|
3403
|
+
(keydown.escape)="close(message)"
|
|
3404
|
+
(pointerdown)="onPointerDown($event, message)"
|
|
3405
|
+
(pointermove)="onPointerMove($event)"
|
|
3406
|
+
(pointerup)="onPointerUp($event, message)"
|
|
3407
|
+
(pointercancel)="onPointerUp($event, message)"
|
|
3408
|
+
>
|
|
3409
|
+
@if (message.loading) {
|
|
3410
|
+
<span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center text-ui-fg-muted" data-part="icon">
|
|
3411
|
+
<svg viewBox="0 0 24 24" class="h-[22px] w-[22px] animate-spin" fill="none" aria-hidden="true">
|
|
3412
|
+
<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-opacity="0.25" stroke-width="3" />
|
|
3413
|
+
<path d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" stroke-width="3" stroke-linecap="round" />
|
|
3414
|
+
</svg>
|
|
3415
|
+
</span>
|
|
3416
|
+
}
|
|
3417
|
+
@else {
|
|
3418
|
+
<span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-full" data-part="icon" [class]="tone(message).solid">
|
|
3419
|
+
@if (message.icon) {
|
|
3420
|
+
<i class="text-[14px] leading-none" [class]="message.icon" aria-hidden="true"></i>
|
|
3421
|
+
}
|
|
3422
|
+
@else {
|
|
3423
|
+
<svg viewBox="0 0 16 16" class="h-4 w-4" fill="none" aria-hidden="true">
|
|
3424
|
+
@switch (iconOf(message)) {
|
|
3425
|
+
@case ('success') {
|
|
3426
|
+
<path d="M3.5 8.5l3 3 6-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
|
3427
|
+
}
|
|
3428
|
+
@case ('warning') {
|
|
3429
|
+
<path d="M8 3.8v5" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
|
3430
|
+
<circle cx="8" cy="11.8" r="1.15" fill="currentColor" />
|
|
3431
|
+
}
|
|
3432
|
+
@case ('danger') {
|
|
3433
|
+
<path d="M4.5 4.5l7 7M11.5 4.5l-7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
|
3434
|
+
}
|
|
3435
|
+
@default {
|
|
3436
|
+
<path d="M8 7.2v4.3" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
|
3437
|
+
<circle cx="8" cy="4.3" r="1.15" fill="currentColor" />
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
</svg>
|
|
3441
|
+
}
|
|
3442
|
+
</span>
|
|
2664
3443
|
}
|
|
2665
|
-
|
|
2666
|
-
|
|
3444
|
+
|
|
3445
|
+
<div class="flex min-w-0 flex-1 flex-col gap-px self-center" [ngClass]="message.contentStyleClass">
|
|
3446
|
+
@if (message.summary) {
|
|
3447
|
+
<div class="flex items-center gap-2 text-ui-md font-semibold" data-part="summary">
|
|
3448
|
+
<span class="min-w-0 [overflow-wrap:anywhere]">{{ message.summary }}</span>
|
|
3449
|
+
@if ((message.count ?? 1) > 1) {
|
|
3450
|
+
<span data-part="count" [class]="countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
|
|
3451
|
+
}
|
|
3452
|
+
</div>
|
|
3453
|
+
}
|
|
3454
|
+
@if (message.detail) {
|
|
3455
|
+
<div class="text-ui-sm [overflow-wrap:anywhere]" data-part="detail" [class]="message.summary ? 'text-ui-fg-muted' : 'text-ui-fg'">
|
|
3456
|
+
{{ message.detail }}
|
|
3457
|
+
@if (!message.summary && (message.count ?? 1) > 1) {
|
|
3458
|
+
<span data-part="count" [class]="'ml-1 ' + countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
|
|
3459
|
+
}
|
|
3460
|
+
</div>
|
|
3461
|
+
}
|
|
3462
|
+
@if (message.action; as action) {
|
|
3463
|
+
<button
|
|
3464
|
+
type="button"
|
|
3465
|
+
class="mt-2 cursor-pointer self-start rounded-control border bg-transparent px-2.5 py-0.5 text-ui-sm font-semibold text-ui-fg transition-colors duration-ui
|
|
3466
|
+
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
|
|
3467
|
+
data-part="action"
|
|
3468
|
+
[class]="tone(message).action"
|
|
3469
|
+
(click)="runAction(message)"
|
|
3470
|
+
>{{ action.label }}</button>
|
|
3471
|
+
}
|
|
3472
|
+
</div>
|
|
3473
|
+
|
|
3474
|
+
@if (message.closable !== false) {
|
|
3475
|
+
<button
|
|
3476
|
+
type="button"
|
|
3477
|
+
class="inline-flex h-[26px] w-[26px] shrink-0 cursor-pointer items-center justify-center rounded-full text-ui-fg-muted transition-colors duration-ui
|
|
3478
|
+
hover:bg-ui-fg/10 hover:text-ui-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
|
|
3479
|
+
aria-label="Fechar"
|
|
3480
|
+
(click)="close(message)"
|
|
3481
|
+
>
|
|
3482
|
+
@if (message.closeIcon) {
|
|
3483
|
+
<i [class]="message.closeIcon" aria-hidden="true"></i>
|
|
3484
|
+
}
|
|
3485
|
+
@else {
|
|
3486
|
+
<svg viewBox="0 0 16 16" class="h-3.5 w-3.5" fill="none" aria-hidden="true">
|
|
3487
|
+
<path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
|
|
3488
|
+
</svg>
|
|
3489
|
+
}
|
|
3490
|
+
</button>
|
|
3491
|
+
}
|
|
3492
|
+
|
|
3493
|
+
@if (hasLife(message)) {
|
|
3494
|
+
<!-- Sempre presente quando ha tempo de vida: com showProgress=false fica invisivel, mas continua sendo o relogio. -->
|
|
3495
|
+
<div
|
|
3496
|
+
class="absolute inset-x-0 bottom-0 transition-[height] duration-ui"
|
|
3497
|
+
aria-hidden="true"
|
|
3498
|
+
data-part="progress"
|
|
3499
|
+
[class]="tone(message).track"
|
|
3500
|
+
[class.opacity-0]="!showsProgress(message)"
|
|
3501
|
+
[style.height.px]="isPaused(message) ? 5 : 3"
|
|
3502
|
+
>
|
|
3503
|
+
<div
|
|
3504
|
+
class="h-full origin-left"
|
|
3505
|
+
data-part="progress-bar"
|
|
3506
|
+
[class]="tone(message).fill"
|
|
3507
|
+
[smzToastLife]="lifeOf(message)"
|
|
3508
|
+
[paused]="isPaused(message)"
|
|
3509
|
+
[revision]="message.revision ?? 0"
|
|
3510
|
+
(expired)="close(message)"
|
|
3511
|
+
></div>
|
|
3512
|
+
</div>
|
|
2667
3513
|
}
|
|
2668
3514
|
</div>
|
|
2669
|
-
@if (message.closable !== false) {
|
|
2670
|
-
<button
|
|
2671
|
-
type="button"
|
|
2672
|
-
class="inline-flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-full text-ui-fg-muted transition-colors duration-ui
|
|
2673
|
-
hover:bg-ui-fg/10 hover:text-ui-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
|
|
2674
|
-
aria-label="Fechar"
|
|
2675
|
-
(click)="close(message)"
|
|
2676
|
-
>
|
|
2677
|
-
<svg viewBox="0 0 16 16" class="h-3.5 w-3.5" fill="none" aria-hidden="true">
|
|
2678
|
-
<path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
|
|
2679
|
-
</svg>
|
|
2680
|
-
</button>
|
|
2681
|
-
}
|
|
2682
3515
|
</div>
|
|
2683
3516
|
}
|
|
2684
3517
|
</div>
|
|
2685
3518
|
</div>
|
|
2686
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3519
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: SmzToastLifeDirective, selector: "[smzToastLife]", inputs: ["smzToastLife", "paused", "revision"], outputs: ["expired"] }, { kind: "directive", type: SmzToastEnterDirective, selector: "[smzToastEnter]", inputs: ["smzToastEnter"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2687
3520
|
}
|
|
2688
3521
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastContainerComponent, decorators: [{
|
|
2689
3522
|
type: Component,
|
|
2690
3523
|
args: [{
|
|
2691
3524
|
selector: 'ui-toast',
|
|
2692
3525
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2693
|
-
imports: [NgClass, NgStyle],
|
|
3526
|
+
imports: [NgClass, NgStyle, SmzToastLifeDirective, SmzToastEnterDirective],
|
|
2694
3527
|
template: `
|
|
2695
3528
|
<!-- Camada na top layer (Popover API): overlays do CDK (drawer/dialog) ficam la e z-index nao os supera. -->
|
|
2696
3529
|
<div #layer popover="manual" class="pointer-events-none fixed inset-0 m-0 h-full w-full overflow-visible border-0 bg-transparent p-0">
|
|
2697
3530
|
<div
|
|
2698
|
-
|
|
3531
|
+
#stack
|
|
3532
|
+
class="pointer-events-none fixed z-[2000] flex w-96 max-w-[95vw] flex-col"
|
|
2699
3533
|
[class]="positionClasses()"
|
|
2700
3534
|
[ngClass]="styleClass()"
|
|
2701
3535
|
[ngStyle]="style()"
|
|
3536
|
+
[attr.data-paused]="hovered() || focused() || hidden()"
|
|
3537
|
+
(mouseenter)="hovered.set(true)"
|
|
3538
|
+
(mouseleave)="hovered.set(false)"
|
|
3539
|
+
(focusin)="focused.set(true)"
|
|
3540
|
+
(focusout)="onFocusOut($event)"
|
|
2702
3541
|
>
|
|
2703
|
-
@for (message of
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
3542
|
+
@for (message of shownMessages(); track message.id) {
|
|
3543
|
+
<!-- O espaco entre toasts e padding do slot (nao gap): o mouse atravessa a pilha sem "sair" dela. -->
|
|
3544
|
+
<div class="pointer-events-auto w-full pb-2" data-part="slot" [attr.data-toast-id]="message.id">
|
|
3545
|
+
<div
|
|
3546
|
+
class="relative flex touch-pan-y items-start gap-3 overflow-hidden rounded-overlay border bg-ui-surface-2 py-3 pl-3.5 pr-3 font-ui text-ui-fg shadow-[0_12px_32px_-8px_rgb(0_0_0/0.28),0_2px_8px_rgb(0_0_0/0.08)]"
|
|
3547
|
+
[class]="tone(message).card"
|
|
3548
|
+
[ngClass]="message.styleClass"
|
|
3549
|
+
[style.padding-bottom.px]="hasLife(message) ? 15 : null"
|
|
3550
|
+
[attr.role]="isAssertive(message) ? 'alert' : 'status'"
|
|
3551
|
+
[attr.aria-live]="isAssertive(message) ? 'assertive' : 'polite'"
|
|
3552
|
+
aria-atomic="true"
|
|
3553
|
+
[attr.data-severity]="message.severity ?? 'info'"
|
|
3554
|
+
[attr.data-loading]="message.loading ? 'true' : null"
|
|
3555
|
+
[smzToastEnter]="enterOffset()"
|
|
3556
|
+
(keydown.escape)="close(message)"
|
|
3557
|
+
(pointerdown)="onPointerDown($event, message)"
|
|
3558
|
+
(pointermove)="onPointerMove($event)"
|
|
3559
|
+
(pointerup)="onPointerUp($event, message)"
|
|
3560
|
+
(pointercancel)="onPointerUp($event, message)"
|
|
3561
|
+
>
|
|
3562
|
+
@if (message.loading) {
|
|
3563
|
+
<span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center text-ui-fg-muted" data-part="icon">
|
|
3564
|
+
<svg viewBox="0 0 24 24" class="h-[22px] w-[22px] animate-spin" fill="none" aria-hidden="true">
|
|
3565
|
+
<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-opacity="0.25" stroke-width="3" />
|
|
3566
|
+
<path d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" stroke-width="3" stroke-linecap="round" />
|
|
3567
|
+
</svg>
|
|
3568
|
+
</span>
|
|
2719
3569
|
}
|
|
2720
|
-
@
|
|
2721
|
-
<
|
|
3570
|
+
@else {
|
|
3571
|
+
<span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-full" data-part="icon" [class]="tone(message).solid">
|
|
3572
|
+
@if (message.icon) {
|
|
3573
|
+
<i class="text-[14px] leading-none" [class]="message.icon" aria-hidden="true"></i>
|
|
3574
|
+
}
|
|
3575
|
+
@else {
|
|
3576
|
+
<svg viewBox="0 0 16 16" class="h-4 w-4" fill="none" aria-hidden="true">
|
|
3577
|
+
@switch (iconOf(message)) {
|
|
3578
|
+
@case ('success') {
|
|
3579
|
+
<path d="M3.5 8.5l3 3 6-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
|
3580
|
+
}
|
|
3581
|
+
@case ('warning') {
|
|
3582
|
+
<path d="M8 3.8v5" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
|
3583
|
+
<circle cx="8" cy="11.8" r="1.15" fill="currentColor" />
|
|
3584
|
+
}
|
|
3585
|
+
@case ('danger') {
|
|
3586
|
+
<path d="M4.5 4.5l7 7M11.5 4.5l-7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
|
3587
|
+
}
|
|
3588
|
+
@default {
|
|
3589
|
+
<path d="M8 7.2v4.3" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
|
3590
|
+
<circle cx="8" cy="4.3" r="1.15" fill="currentColor" />
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
</svg>
|
|
3594
|
+
}
|
|
3595
|
+
</span>
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
<div class="flex min-w-0 flex-1 flex-col gap-px self-center" [ngClass]="message.contentStyleClass">
|
|
3599
|
+
@if (message.summary) {
|
|
3600
|
+
<div class="flex items-center gap-2 text-ui-md font-semibold" data-part="summary">
|
|
3601
|
+
<span class="min-w-0 [overflow-wrap:anywhere]">{{ message.summary }}</span>
|
|
3602
|
+
@if ((message.count ?? 1) > 1) {
|
|
3603
|
+
<span data-part="count" [class]="countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
|
|
3604
|
+
}
|
|
3605
|
+
</div>
|
|
3606
|
+
}
|
|
3607
|
+
@if (message.detail) {
|
|
3608
|
+
<div class="text-ui-sm [overflow-wrap:anywhere]" data-part="detail" [class]="message.summary ? 'text-ui-fg-muted' : 'text-ui-fg'">
|
|
3609
|
+
{{ message.detail }}
|
|
3610
|
+
@if (!message.summary && (message.count ?? 1) > 1) {
|
|
3611
|
+
<span data-part="count" [class]="'ml-1 ' + countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
|
|
3612
|
+
}
|
|
3613
|
+
</div>
|
|
3614
|
+
}
|
|
3615
|
+
@if (message.action; as action) {
|
|
3616
|
+
<button
|
|
3617
|
+
type="button"
|
|
3618
|
+
class="mt-2 cursor-pointer self-start rounded-control border bg-transparent px-2.5 py-0.5 text-ui-sm font-semibold text-ui-fg transition-colors duration-ui
|
|
3619
|
+
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
|
|
3620
|
+
data-part="action"
|
|
3621
|
+
[class]="tone(message).action"
|
|
3622
|
+
(click)="runAction(message)"
|
|
3623
|
+
>{{ action.label }}</button>
|
|
3624
|
+
}
|
|
3625
|
+
</div>
|
|
3626
|
+
|
|
3627
|
+
@if (message.closable !== false) {
|
|
3628
|
+
<button
|
|
3629
|
+
type="button"
|
|
3630
|
+
class="inline-flex h-[26px] w-[26px] shrink-0 cursor-pointer items-center justify-center rounded-full text-ui-fg-muted transition-colors duration-ui
|
|
3631
|
+
hover:bg-ui-fg/10 hover:text-ui-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
|
|
3632
|
+
aria-label="Fechar"
|
|
3633
|
+
(click)="close(message)"
|
|
3634
|
+
>
|
|
3635
|
+
@if (message.closeIcon) {
|
|
3636
|
+
<i [class]="message.closeIcon" aria-hidden="true"></i>
|
|
3637
|
+
}
|
|
3638
|
+
@else {
|
|
3639
|
+
<svg viewBox="0 0 16 16" class="h-3.5 w-3.5" fill="none" aria-hidden="true">
|
|
3640
|
+
<path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
|
|
3641
|
+
</svg>
|
|
3642
|
+
}
|
|
3643
|
+
</button>
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
@if (hasLife(message)) {
|
|
3647
|
+
<!-- Sempre presente quando ha tempo de vida: com showProgress=false fica invisivel, mas continua sendo o relogio. -->
|
|
3648
|
+
<div
|
|
3649
|
+
class="absolute inset-x-0 bottom-0 transition-[height] duration-ui"
|
|
3650
|
+
aria-hidden="true"
|
|
3651
|
+
data-part="progress"
|
|
3652
|
+
[class]="tone(message).track"
|
|
3653
|
+
[class.opacity-0]="!showsProgress(message)"
|
|
3654
|
+
[style.height.px]="isPaused(message) ? 5 : 3"
|
|
3655
|
+
>
|
|
3656
|
+
<div
|
|
3657
|
+
class="h-full origin-left"
|
|
3658
|
+
data-part="progress-bar"
|
|
3659
|
+
[class]="tone(message).fill"
|
|
3660
|
+
[smzToastLife]="lifeOf(message)"
|
|
3661
|
+
[paused]="isPaused(message)"
|
|
3662
|
+
[revision]="message.revision ?? 0"
|
|
3663
|
+
(expired)="close(message)"
|
|
3664
|
+
></div>
|
|
3665
|
+
</div>
|
|
2722
3666
|
}
|
|
2723
3667
|
</div>
|
|
2724
|
-
@if (message.closable !== false) {
|
|
2725
|
-
<button
|
|
2726
|
-
type="button"
|
|
2727
|
-
class="inline-flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-full text-ui-fg-muted transition-colors duration-ui
|
|
2728
|
-
hover:bg-ui-fg/10 hover:text-ui-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
|
|
2729
|
-
aria-label="Fechar"
|
|
2730
|
-
(click)="close(message)"
|
|
2731
|
-
>
|
|
2732
|
-
<svg viewBox="0 0 16 16" class="h-3.5 w-3.5" fill="none" aria-hidden="true">
|
|
2733
|
-
<path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
|
|
2734
|
-
</svg>
|
|
2735
|
-
</button>
|
|
2736
|
-
}
|
|
2737
3668
|
</div>
|
|
2738
3669
|
}
|
|
2739
3670
|
</div>
|
|
2740
3671
|
</div>
|
|
2741
3672
|
`,
|
|
2742
3673
|
}]
|
|
2743
|
-
}], ctorParameters: () => [], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], life: [{ type: i0.Input, args: [{ isSignal: true, alias: "life", required: false }] }], style: [{ type: i0.Input, args: [{ isSignal: true, alias: "style", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }], layer: [{ type: i0.ViewChild, args: ['layer', { isSignal: true }] }] } });
|
|
3674
|
+
}], ctorParameters: () => [], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], life: [{ type: i0.Input, args: [{ isSignal: true, alias: "life", required: false }] }], lifeBySeverity: [{ type: i0.Input, args: [{ isSignal: true, alias: "lifeBySeverity", required: false }] }], showProgress: [{ type: i0.Input, args: [{ isSignal: true, alias: "showProgress", required: false }] }], pauseOnHover: [{ type: i0.Input, args: [{ isSignal: true, alias: "pauseOnHover", required: false }] }], maxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxVisible", required: false }] }], style: [{ type: i0.Input, args: [{ isSignal: true, alias: "style", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }], layer: [{ type: i0.ViewChild, args: ['layer', { isSignal: true }] }], stack: [{ type: i0.ViewChild, args: ['stack', { isSignal: true }] }] } });
|
|
2744
3675
|
|
|
2745
3676
|
/* eslint-disable max-len -- classes Tailwind nos templates */
|
|
2746
3677
|
const POSITIONS$1 = [
|
|
@@ -2927,7 +3858,7 @@ class SmzMenuListComponent {
|
|
|
2927
3858
|
@if (!popup()) {
|
|
2928
3859
|
<ng-container [ngTemplateOutlet]="list" />
|
|
2929
3860
|
}
|
|
2930
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: SmzTooltipDirective, selector: "[smzTooltip]", inputs: ["smzTooltip", "tooltipPosition", "showDelay", "hideDelay", "tooltipEvent", "escape", "tooltipStyleClass", "tooltipZIndex", "tooltipDisabled", "tooltipOptions", "appendTo"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3861
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: SmzTooltipDirective, selector: "[smzTooltip]", inputs: ["smzTooltip", "tooltipPosition", "showDelay", "hideDelay", "tooltipEvent", "escape", "tooltipStyleClass", "tooltipZIndex", "tooltipDisabled", "tooltipTitle", "tooltipShortcut", "tooltipVariant", "tooltipSeverity", "tooltipArrow", "tooltipOnOverflow", "tooltipOptions", "appendTo"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2931
3862
|
}
|
|
2932
3863
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzMenuListComponent, decorators: [{
|
|
2933
3864
|
type: Component,
|
|
@@ -9663,5 +10594,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
|
|
|
9663
10594
|
* Generated bundle index. Do not edit.
|
|
9664
10595
|
*/
|
|
9665
10596
|
|
|
9666
|
-
export { SMZ_DIALOG_CONTENT, SMZ_SOFT_TONE, SMZ_SOLID_TONE, SMZ_TREE_TABLE, SmzAccordionComponent, SmzAccordionContentComponent, SmzAccordionHeaderComponent, SmzAccordionPanelComponent, SmzAnchoredPanel, SmzAutoCompleteComponent, SmzAutoFocusDirective, SmzBadgeComponent, SmzBadgeDirective, SmzBlockUiComponent, SmzButtonComponent, SmzCardComponent, SmzCheckboxComponent, SmzColorPickerComponent, SmzConfirmContentComponent, SmzConfirmationService, SmzConnectedOverlayScrollHandler, SmzDataViewComponent, SmzDatePickerComponent, SmzDialogComponent, SmzDialogConfig, SmzDialogFrameComponent, SmzDialogRef, SmzDialogService, SmzDividerComponent, SmzDomHandler, SmzDrawerComponent, SmzFileUploadComponent, SmzFilterMatchMode, SmzFilterOperator, SmzFilterService, SmzFloatLabelComponent, SmzIconComponent, SmzIconFieldComponent, SmzInputGroupAddonComponent, SmzInputGroupComponent, SmzInputIconComponent, SmzInputMaskComponent, SmzInputNumberComponent, SmzInputTextDirective, SmzListboxComponent, SmzLocaleService, SmzMenuListComponent, SmzMessageComponent, SmzMessageService, SmzMultiSelectComponent, SmzObjectUtils, SmzPaginatorComponent, SmzPanelComponent, SmzPasswordComponent, SmzPickListComponent, SmzPopoverComponent, SmzProgressBarComponent, SmzProgressSpinnerComponent, SmzRadioButtonComponent, SmzRippleDirective, SmzSelectButtonComponent, SmzSelectComponent, SmzSkeletonComponent, SmzSplitterComponent, SmzSplitterPanelComponent, SmzStyleClassDirective, SmzTabComponent, SmzTabListComponent, SmzTabPanelComponent, SmzTabPanelsComponent, SmzTabsComponent, SmzTagComponent, SmzTemplateDirective, SmzTextareaDirective, SmzThemeService, SmzToastContainerComponent, SmzToggleSwitchComponent, SmzToolbarComponent, SmzTooltipComponent, SmzTooltipDirective, SmzTranslationKeys, SmzTreeSelectComponent, SmzTreeTableCheckboxComponent, SmzTreeTableComponent, SmzTreeTableHeaderCheckboxComponent, SmzTreeTableRowDirective, SmzTreeTableSortIconComponent, SmzTreeTableSortableColumnDirective, SmzTreeTableTogglerComponent, SmzUiTimelineComponent, SmzUiTreeComponent, SmzValueAccessor, SmzZIndex, filterOptions, optionDisabled, optionLabel, optionValue, sameValue, smzCalendarStart, smzCx, smzFindTemplate, smzFormatDate, smzMergeClasses, smzNormalizeSeverity, smzNormalizeStyleClass, smzParseButtonStyleClass, smzParseDate, smzSameDay, smzStartOfDay, smzStaticHostClass, smzTwoDigits, smzUniqueId, smzVariants };
|
|
10597
|
+
export { SMZ_DIALOG_CONTENT, SMZ_SOFT_TONE, SMZ_SOLID_TONE, SMZ_TOAST_DEFAULTS, SMZ_TOAST_DEFAULT_OPTIONS, SMZ_TOOLTIP_DEFAULTS, SMZ_TOOLTIP_DEFAULT_OPTIONS, SMZ_TREE_TABLE, SmzAccordionComponent, SmzAccordionContentComponent, SmzAccordionHeaderComponent, SmzAccordionPanelComponent, SmzAnchoredPanel, SmzAutoCompleteComponent, SmzAutoFocusDirective, SmzBadgeComponent, SmzBadgeDirective, SmzBlockUiComponent, SmzButtonComponent, SmzCardComponent, SmzCheckboxComponent, SmzColorPickerComponent, SmzConfirmContentComponent, SmzConfirmationService, SmzConnectedOverlayScrollHandler, SmzDataViewComponent, SmzDatePickerComponent, SmzDialogComponent, SmzDialogConfig, SmzDialogFrameComponent, SmzDialogRef, SmzDialogService, SmzDividerComponent, SmzDomHandler, SmzDrawerComponent, SmzFileUploadComponent, SmzFilterMatchMode, SmzFilterOperator, SmzFilterService, SmzFloatLabelComponent, SmzIconComponent, SmzIconFieldComponent, SmzInputGroupAddonComponent, SmzInputGroupComponent, SmzInputIconComponent, SmzInputMaskComponent, SmzInputNumberComponent, SmzInputTextDirective, SmzListboxComponent, SmzLocaleService, SmzMenuListComponent, SmzMessageComponent, SmzMessageService, SmzMultiSelectComponent, SmzObjectUtils, SmzPaginatorComponent, SmzPanelComponent, SmzPasswordComponent, SmzPickListComponent, SmzPopoverComponent, SmzProgressBarComponent, SmzProgressSpinnerComponent, SmzRadioButtonComponent, SmzRippleDirective, SmzSelectButtonComponent, SmzSelectComponent, SmzSkeletonComponent, SmzSplitterComponent, SmzSplitterPanelComponent, SmzStyleClassDirective, SmzTabComponent, SmzTabListComponent, SmzTabPanelComponent, SmzTabPanelsComponent, SmzTabsComponent, SmzTagComponent, SmzTemplateDirective, SmzTextareaDirective, SmzThemeService, SmzToastContainerComponent, SmzToastEnterDirective, SmzToastLifeDirective, SmzToggleSwitchComponent, SmzToolbarComponent, SmzTooltipComponent, SmzTooltipDirective, SmzTranslationKeys, SmzTreeSelectComponent, SmzTreeTableCheckboxComponent, SmzTreeTableComponent, SmzTreeTableHeaderCheckboxComponent, SmzTreeTableRowDirective, SmzTreeTableSortIconComponent, SmzTreeTableSortableColumnDirective, SmzTreeTableTogglerComponent, SmzUiTimelineComponent, SmzUiTreeComponent, SmzValueAccessor, SmzZIndex, filterOptions, optionDisabled, optionLabel, optionValue, provideSmzToastDefaults, provideSmzTooltipDefaults, sameValue, smzCalendarStart, smzCx, smzFindTemplate, smzFormatDate, smzMergeClasses, smzNormalizeSeverity, smzNormalizeStyleClass, smzParseButtonStyleClass, smzParseDate, smzResolveToastDefaults, smzSameDay, smzSetToastDefaults, smzSetTooltipDefaults, smzStartOfDay, smzStaticHostClass, smzTwoDigits, smzUniqueId, smzVariants };
|
|
9667
10598
|
//# sourceMappingURL=ngx-smz-ui-kit.mjs.map
|