@ngx-smz/ui-kit 21.10.0-next.22 → 21.10.0-next.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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, InjectionToken, viewChild, ViewContainerRef, Injectable, model, contentChildren, contentChild } from '@angular/core';
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, isDevMode, provideAppInitializer } 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,275 @@ 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 OFFSET = 8;
419
+ /** Atributo que marca um contêiner com tema próprio (diretiva `[smzTheme]`) e os overlays abertos a partir dele. */
420
+ const SMZ_THEME_SCOPE_ATTRIBUTE = 'data-smz-theme-scope';
421
+ /** Atributos de tema que um overlay herda do escopo de onde foi aberto. */
422
+ const INHERITED = [SMZ_THEME_SCOPE_ATTRIBUTE, 'data-smz-mode', 'data-smz-density'];
423
+ /**
424
+ * Faz o painel de um overlay herdar o tema do escopo de onde ele foi aberto.
425
+ *
426
+ * O contêiner de overlays do CDK é filho do `<body>`, fora do contêiner com `[smzTheme]`, então as variáveis do
427
+ * escopo não chegam ao painel pela árvore. Todo overlay do kit chama esta função logo depois de criado.
428
+ */
429
+ function smzInheritThemeScope(overlayRef, origin) {
430
+ const scope = origin?.closest(`[${SMZ_THEME_SCOPE_ATTRIBUTE}]`);
431
+ if (scope == null)
432
+ return;
433
+ for (const name of INHERITED) {
434
+ const value = scope.getAttribute(name);
435
+ if (value != null)
436
+ overlayRef.overlayElement.setAttribute(name, value);
437
+ }
438
+ }
439
+
440
+ const SMZ_TOOLTIP_DEFAULT_OPTIONS = {
441
+ variant: 'dark',
442
+ arrow: true,
443
+ showDelay: 300,
444
+ hideDelay: 0,
445
+ warmupWindow: 500,
446
+ tooltipEvent: 'both',
447
+ position: 'top',
448
+ };
449
+ const SMZ_TOOLTIP_DEFAULTS = new InjectionToken('SMZ_TOOLTIP_DEFAULTS');
450
+ /**
451
+ * Padroes globais do `smzTooltip` (variante, seta, atrasos, janela de aquecimento).
452
+ *
453
+ * providers: [provideSmzTooltipDefaults({ variant: 'light', showDelay: 200 })]
454
+ */
455
+ function provideSmzTooltipDefaults(defaults) {
456
+ return makeEnvironmentProviders([{ provide: SMZ_TOOLTIP_DEFAULTS, useValue: defaults }]);
457
+ }
458
+ const globalDefaults$2 = {};
459
+ /**
460
+ * Padroes globais definidos fora da injecao de dependencias (usado pelo `SmzUiBuilder` do @ngx-smz/core).
461
+ * O token `SMZ_TOOLTIP_DEFAULTS`, quando provido, tem precedencia.
462
+ */
463
+ function smzSetTooltipDefaults(defaults) {
464
+ Object.assign(globalDefaults$2, defaults ?? {});
465
+ }
466
+ /** Distancia entre o host e a caixa do tooltip, com e sem seta. */
467
+ const GAP_WITH_ARROW = 8;
468
+ const GAP_PLAIN = 6;
469
+ /** Distancia minima da seta ate o canto da caixa. */
470
+ const ARROW_INSET = 12;
471
+ const LONG_PRESS = 450;
472
+ /** Depois de um toque o navegador emite `mouseenter` sintetico; ignorado durante essa janela. */
473
+ const TOUCH_MOUSE_GUARD = 800;
474
+ const pair = (originX, originY, overlayX, overlayY) => ({ originX, originY, overlayX, overlayY });
475
+ const TOP = pair('center', 'top', 'center', 'bottom');
476
+ const BOTTOM = pair('center', 'bottom', 'center', 'top');
477
+ const LEFT = pair('start', 'center', 'end', 'center');
478
+ const RIGHT = pair('end', 'center', 'start', 'center');
479
+ const TOP_START = pair('start', 'top', 'start', 'bottom');
480
+ const TOP_END = pair('end', 'top', 'end', 'bottom');
481
+ const BOTTOM_START = pair('start', 'bottom', 'start', 'top');
482
+ const BOTTOM_END = pair('end', 'bottom', 'end', 'top');
483
+ /** Posicao pedida primeiro, depois o lado oposto e as alternativas mais proximas. */
420
484
  const POSITIONS$3 = {
421
- top: [
422
- { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom', offsetY: -OFFSET },
423
- { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top', offsetY: OFFSET },
424
- ],
425
- bottom: [
426
- { originX: 'center', originY: 'bottom', overlayX: 'center', overlayY: 'top', offsetY: OFFSET },
427
- { originX: 'center', originY: 'top', overlayX: 'center', overlayY: 'bottom', offsetY: -OFFSET },
428
- ],
429
- left: [
430
- { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center', offsetX: -OFFSET },
431
- { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center', offsetX: OFFSET },
432
- ],
433
- right: [
434
- { originX: 'end', originY: 'center', overlayX: 'start', overlayY: 'center', offsetX: OFFSET },
435
- { originX: 'start', originY: 'center', overlayX: 'end', overlayY: 'center', offsetX: -OFFSET },
436
- ],
485
+ top: [TOP, BOTTOM, TOP_START, TOP_END],
486
+ bottom: [BOTTOM, TOP, BOTTOM_START, BOTTOM_END],
487
+ left: [LEFT, RIGHT, TOP, BOTTOM],
488
+ right: [RIGHT, LEFT, TOP, BOTTOM],
489
+ 'top-start': [TOP_START, BOTTOM_START, TOP_END, BOTTOM_END],
490
+ 'top-end': [TOP_END, BOTTOM_END, TOP_START, BOTTOM_START],
491
+ 'bottom-start': [BOTTOM_START, TOP_START, BOTTOM_END, TOP_END],
492
+ 'bottom-end': [BOTTOM_END, TOP_END, BOTTOM_START, TOP_START],
493
+ };
494
+ function sideOf(position) {
495
+ if (position.originY === 'top' && position.overlayY === 'bottom')
496
+ return 'top';
497
+ if (position.originY === 'bottom' && position.overlayY === 'top')
498
+ return 'bottom';
499
+ return position.overlayX === 'end' ? 'left' : 'right';
500
+ }
501
+ /** Cores por variante/severidade. Strings literais para o Tailwind encontrar no scan. */
502
+ const VARIANT_TONE = {
503
+ dark: 'border-transparent bg-ui-fg text-ui-surface-1',
504
+ light: 'border-ui-line-strong bg-ui-surface-2 text-ui-fg',
505
+ };
506
+ const VARIANT_MUTED = {
507
+ dark: 'text-ui-surface-1/75',
508
+ light: 'text-ui-fg-muted',
509
+ };
510
+ const VARIANT_KEY = {
511
+ dark: 'bg-ui-surface-1/15',
512
+ light: 'bg-ui-surface-3',
513
+ };
514
+ /** `success` usa o tom `-hover` (mais escuro): branco sobre o tom base fica abaixo de 4.5:1. */
515
+ const SEVERITY_TONE$2 = {
516
+ primary: 'border-transparent bg-ui-primary text-ui-on-primary',
517
+ secondary: 'border-ui-line-strong bg-ui-surface-3 text-ui-fg',
518
+ success: 'border-transparent bg-ui-success-hover text-ui-on-success',
519
+ warning: 'border-transparent bg-ui-warning text-ui-on-warning',
520
+ danger: 'border-transparent bg-ui-danger text-ui-on-danger',
521
+ };
522
+ /** Lado do host: a area transparente que liga o host ao tooltip, para o mouse atravessar sem fechar. */
523
+ const BRIDGE_PROPERTY = {
524
+ top: 'padding-bottom',
525
+ bottom: 'padding-top',
526
+ left: 'padding-right',
527
+ right: 'padding-left',
437
528
  };
529
+ let nextId$1 = 0;
438
530
  class SmzTooltipComponent {
439
- text = input.required(...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
531
+ text = input('', ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
532
+ template = input(null, ...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
440
533
  escape = input(true, ...(ngDevMode ? [{ debugName: "escape" }] : /* istanbul ignore next */ []));
441
- classes = 'max-w-xs rounded-control bg-ui-fg px-2 py-1 font-ui text-ui-xs text-ui-surface-1 shadow-overlay';
534
+ title = input('', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
535
+ shortcut = input('', ...(ngDevMode ? [{ debugName: "shortcut" }] : /* istanbul ignore next */ []));
536
+ variant = input('dark', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
537
+ severity = input(null, ...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
538
+ arrow = input(true, ...(ngDevMode ? [{ debugName: "arrow" }] : /* istanbul ignore next */ []));
539
+ styleClass = input('', ...(ngDevMode ? [{ debugName: "styleClass" }] : /* istanbul ignore next */ []));
540
+ tooltipId = input('', ...(ngDevMode ? [{ debugName: "tooltipId" }] : /* istanbul ignore next */ []));
541
+ /** Lado real em relacao ao host (definido depois que o CDK posiciona). Vazio = ainda nao posicionado. */
542
+ side = input('', ...(ngDevMode ? [{ debugName: "side" }] : /* istanbul ignore next */ []));
543
+ /** Posicao da seta ao longo da borda (px a partir do canto), para ela apontar para o centro do host. */
544
+ arrowOffset = input(null, ...(ngDevMode ? [{ debugName: "arrowOffset" }] : /* istanbul ignore next */ []));
545
+ /** Sem animacao (aquecimento entre tooltips vizinhos). */
546
+ instant = input(false, ...(ngDevMode ? [{ debugName: "instant" }] : /* istanbul ignore next */ []));
547
+ gap = input(GAP_WITH_ARROW, ...(ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []));
548
+ tone = computed(() => (this.severity() ? smzNormalizeSeverity(this.severity()) : null), ...(ngDevMode ? [{ debugName: "tone" }] : /* istanbul ignore next */ []));
549
+ keys = computed(() => (this.shortcut() ?? '').split('+').map((key) => key.trim()).filter((key) => key.length > 0), ...(ngDevMode ? [{ debugName: "keys" }] : /* istanbul ignore next */ []));
550
+ classes = computed(() => {
551
+ const tone = this.tone();
552
+ const rich = !!this.title() || !!this.template();
553
+ return [
554
+ 'w-max max-w-[min(280px,calc(100vw-16px))] rounded-control border font-ui text-ui-sm leading-snug shadow-overlay',
555
+ rich ? 'px-3 py-2' : 'px-2.5 py-1.5',
556
+ tone ? SEVERITY_TONE$2[tone] : VARIANT_TONE[this.variant()],
557
+ this.styleClass() ?? '',
558
+ ].join(' ');
559
+ }, ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
560
+ /** Com titulo, o texto vira descricao em tom mais suave (so nas variantes; nas severidades herda a cor). */
561
+ textClasses = computed(() => (this.title() && !this.tone() ? VARIANT_MUTED[this.variant()] : ''), ...(ngDevMode ? [{ debugName: "textClasses" }] : /* istanbul ignore next */ []));
562
+ keyClasses = computed(() => (this.tone() ? 'bg-black/15' : VARIANT_KEY[this.variant()]), ...(ngDevMode ? [{ debugName: "keyClasses" }] : /* istanbul ignore next */ []));
563
+ bridgeStyle = computed(() => {
564
+ const side = this.side();
565
+ return side ? `${BRIDGE_PROPERTY[side]}: ${this.gap()}px` : '';
566
+ }, ...(ngDevMode ? [{ debugName: "bridgeStyle" }] : /* istanbul ignore next */ []));
442
567
  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
- @if (escape()) {
445
- <div role="tooltip" [class]="classes">{{ text() }}</div>
446
- }
447
- @else {
448
- <div role="tooltip" [class]="classes" [innerHTML]="text()"></div>
449
- }
450
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
568
+ 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: `
569
+ <div
570
+ role="tooltip"
571
+ class="smz-tooltip"
572
+ [id]="tooltipId()"
573
+ [class]="classes()"
574
+ [style.--smz-tooltip-arrow]="arrowOffset()"
575
+ [attr.data-side]="side()"
576
+ [attr.data-variant]="variant()"
577
+ [attr.data-severity]="tone()"
578
+ [attr.data-state]="side() ? 'open' : 'pending'"
579
+ [attr.data-instant]="instant()"
580
+ >
581
+ @if (template(); as tpl) {
582
+ <ng-container [ngTemplateOutlet]="tpl" />
583
+ }
584
+ @else {
585
+ @if (title()) {
586
+ <div class="font-semibold" data-part="title">{{ title() }}</div>
587
+ }
588
+ @if (text() || keys().length > 0) {
589
+ <div class="flex items-center gap-2.5">
590
+ @if (escape()) {
591
+ <span data-part="text" [class]="textClasses()">{{ text() }}</span>
592
+ }
593
+ @else {
594
+ <span data-part="text" [class]="textClasses()" [innerHTML]="text()"></span>
595
+ }
596
+ @if (keys().length > 0) {
597
+ <span class="ml-auto inline-flex flex-none gap-[3px]" data-part="shortcut">
598
+ @for (key of keys(); track $index) {
599
+ <kbd class="rounded px-[5px] font-ui-mono text-[11px] leading-[18px]" [class]="keyClasses()">{{ key }}</kbd>
600
+ }
601
+ </span>
602
+ }
603
+ </div>
604
+ }
605
+ }
606
+ @if (arrow()) {
607
+ <span class="smz-tooltip-arrow" aria-hidden="true"></span>
608
+ }
609
+ </div>
610
+ `, 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
611
  }
452
612
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzTooltipComponent, decorators: [{
453
613
  type: Component,
454
- args: [{
455
- selector: 'ui-tooltip',
456
- changeDetection: ChangeDetectionStrategy.OnPush,
457
- template: `
458
- @if (escape()) {
459
- <div role="tooltip" [class]="classes">{{ text() }}</div>
460
- }
461
- @else {
462
- <div role="tooltip" [class]="classes" [innerHTML]="text()"></div>
463
- }
464
- `,
465
- }]
466
- }], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: true }] }], escape: [{ type: i0.Input, args: [{ isSignal: true, alias: "escape", required: false }] }] } });
614
+ args: [{ selector: 'ui-tooltip', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], host: { class: 'block', '[style]': 'bridgeStyle()' }, template: `
615
+ <div
616
+ role="tooltip"
617
+ class="smz-tooltip"
618
+ [id]="tooltipId()"
619
+ [class]="classes()"
620
+ [style.--smz-tooltip-arrow]="arrowOffset()"
621
+ [attr.data-side]="side()"
622
+ [attr.data-variant]="variant()"
623
+ [attr.data-severity]="tone()"
624
+ [attr.data-state]="side() ? 'open' : 'pending'"
625
+ [attr.data-instant]="instant()"
626
+ >
627
+ @if (template(); as tpl) {
628
+ <ng-container [ngTemplateOutlet]="tpl" />
629
+ }
630
+ @else {
631
+ @if (title()) {
632
+ <div class="font-semibold" data-part="title">{{ title() }}</div>
633
+ }
634
+ @if (text() || keys().length > 0) {
635
+ <div class="flex items-center gap-2.5">
636
+ @if (escape()) {
637
+ <span data-part="text" [class]="textClasses()">{{ text() }}</span>
638
+ }
639
+ @else {
640
+ <span data-part="text" [class]="textClasses()" [innerHTML]="text()"></span>
641
+ }
642
+ @if (keys().length > 0) {
643
+ <span class="ml-auto inline-flex flex-none gap-[3px]" data-part="shortcut">
644
+ @for (key of keys(); track $index) {
645
+ <kbd class="rounded px-[5px] font-ui-mono text-[11px] leading-[18px]" [class]="keyClasses()">{{ key }}</kbd>
646
+ }
647
+ </span>
648
+ }
649
+ </div>
650
+ }
651
+ }
652
+ @if (arrow()) {
653
+ <span class="smz-tooltip-arrow" aria-hidden="true"></span>
654
+ }
655
+ </div>
656
+ `, 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"] }]
657
+ }], 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 }] }] } });
658
+ /** Estado compartilhado entre todos os tooltips: um aberto por vez e aquecimento entre vizinhos. */
659
+ const shared = { active: null, lastClosedAt: 0 };
467
660
  /**
468
661
  * Tooltip do ui-kit. Substitui o `pTooltip` do PrimeNG.
469
662
  * Requer o CSS do CDK Overlay no app (`@angular/cdk/overlay-prebuilt.css`).
470
663
  *
471
- * <button smzButton smzTooltip="Salvar" tooltipPosition="bottom">...</button>
664
+ * <button smzButton smzTooltip="Salvar" tooltipShortcut="Ctrl+S" tooltipPosition="bottom">...</button>
665
+ * <span class="truncate" [smzTooltip]="nome" tooltipOnOverflow>{{ nome }}</span>
666
+ * <i [smzTooltip]="ajuda" tooltipVariant="light"></i> <ng-template #ajuda>conteudo livre</ng-template>
667
+ *
668
+ * Abre no hover e no foco por teclado (`:focus-visible`), e por toque longo em telas de toque.
669
+ * Elemento desabilitado nao emite eventos de mouse: envolva-o em um `<span tabindex="0" smzTooltip="...">`
670
+ * e ponha `pointer-events-none` no elemento desabilitado, para o hover chegar ao wrapper.
472
671
  */
473
672
  class SmzTooltipDirective {
474
673
  text = input('', { ...(ngDevMode ? { debugName: "text" } : /* istanbul ignore next */ {}), alias: 'smzTooltip' });
475
- tooltipPosition = input('top', ...(ngDevMode ? [{ debugName: "tooltipPosition" }] : /* istanbul ignore next */ []));
476
- showDelay = input(300, ...(ngDevMode ? [{ debugName: "showDelay" }] : /* istanbul ignore next */ []));
477
- hideDelay = input(0, ...(ngDevMode ? [{ debugName: "hideDelay" }] : /* istanbul ignore next */ []));
478
- tooltipEvent = input('hover', ...(ngDevMode ? [{ debugName: "tooltipEvent" }] : /* istanbul ignore next */ []));
674
+ tooltipPosition = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipPosition" }] : /* istanbul ignore next */ []));
675
+ showDelay = input(undefined, ...(ngDevMode ? [{ debugName: "showDelay" }] : /* istanbul ignore next */ []));
676
+ hideDelay = input(undefined, ...(ngDevMode ? [{ debugName: "hideDelay" }] : /* istanbul ignore next */ []));
677
+ tooltipEvent = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipEvent" }] : /* istanbul ignore next */ []));
479
678
  escape = input(true, { ...(ngDevMode ? { debugName: "escape" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
480
679
  tooltipStyleClass = input('', ...(ngDevMode ? [{ debugName: "tooltipStyleClass" }] : /* istanbul ignore next */ []));
481
680
  tooltipZIndex = input('', ...(ngDevMode ? [{ debugName: "tooltipZIndex" }] : /* istanbul ignore next */ []));
482
681
  tooltipDisabled = input(false, { ...(ngDevMode ? { debugName: "tooltipDisabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
682
+ tooltipTitle = input('', ...(ngDevMode ? [{ debugName: "tooltipTitle" }] : /* istanbul ignore next */ []));
683
+ tooltipShortcut = input('', ...(ngDevMode ? [{ debugName: "tooltipShortcut" }] : /* istanbul ignore next */ []));
684
+ tooltipVariant = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipVariant" }] : /* istanbul ignore next */ []));
685
+ tooltipSeverity = input(null, ...(ngDevMode ? [{ debugName: "tooltipSeverity" }] : /* istanbul ignore next */ []));
686
+ tooltipArrow = input(undefined, { ...(ngDevMode ? { debugName: "tooltipArrow" } : /* istanbul ignore next */ {}), transform: (value) => (value === undefined || value === null ? undefined : booleanAttribute(value)) });
687
+ tooltipOnOverflow = input(false, { ...(ngDevMode ? { debugName: "tooltipOnOverflow" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
483
688
  /** Opcoes agrupadas (compatibilidade com `tooltipOptions` do PrimeNG). Sobrescrevem os inputs individuais. */
484
689
  tooltipOptions = input(undefined, ...(ngDevMode ? [{ debugName: "tooltipOptions" }] : /* istanbul ignore next */ []));
485
690
  /** Aceito por compatibilidade; o overlay do CDK ja e anexado ao body. */
@@ -487,98 +692,302 @@ class SmzTooltipDirective {
487
692
  overrides = signal({}, ...(ngDevMode ? [{ debugName: "overrides" }] : /* istanbul ignore next */ []));
488
693
  overlay = inject(Overlay);
489
694
  host = inject(ElementRef);
695
+ viewContainer = inject(ViewContainerRef);
696
+ providedDefaults = inject(SMZ_TOOLTIP_DEFAULTS, { optional: true });
697
+ tooltipId = `smz-tooltip-${nextId$1++}`;
698
+ get defaults() {
699
+ return { ...SMZ_TOOLTIP_DEFAULT_OPTIONS, ...globalDefaults$2, ...(this.providedDefaults ?? {}) };
700
+ }
490
701
  overlayRef;
702
+ componentRef;
703
+ subscriptions;
491
704
  showTimer;
492
705
  hideTimer;
706
+ touchTimer;
707
+ lastTouchAt = 0;
708
+ openedByTouch = false;
709
+ onDocumentKeydown = (event) => {
710
+ if (event.key === 'Escape')
711
+ this.hide();
712
+ };
713
+ onDocumentTouch = (event) => {
714
+ const target = event.target;
715
+ if (target && (this.host.nativeElement.contains(target) || this.overlayRef?.overlayElement.contains(target)))
716
+ return;
717
+ this.hide();
718
+ };
719
+ onPanelEnter = () => clearTimeout(this.hideTimer);
720
+ onPanelLeave = (event) => {
721
+ if (this.host.nativeElement.contains(event.relatedTarget))
722
+ return;
723
+ if (this.openedByTouch || this.hasKeyboardFocus())
724
+ return;
725
+ this.scheduleHide();
726
+ };
493
727
  /** Ajuste programatico de opcoes (usado por diretivas que envolvem o tooltip). */
494
728
  configure(options) {
495
729
  this.overrides.update((current) => ({ ...current, ...options }));
496
730
  }
497
- onEnter(source) {
731
+ onEnter(source, event) {
498
732
  if (!this.accepts(source))
499
733
  return;
500
- this.show();
734
+ if (source === 'hover') {
735
+ // `mouseenter` sintetico depois de um toque: no toque quem abre e o toque longo.
736
+ if (Date.now() - this.lastTouchAt < TOUCH_MOUSE_GUARD)
737
+ return;
738
+ this.show();
739
+ return;
740
+ }
741
+ // No modo padrao (`both`) o foco so abre para quem navega por teclado; clique de mouse nao abre.
742
+ // No modo `focus` explicito qualquer foco abre (ex.: `appTooltipTouchSupport`).
743
+ if (this.option('tooltipEvent') === 'both' && !this.isFocusVisible(event?.target))
744
+ return;
745
+ this.show(true);
501
746
  }
502
- onLeave(source) {
747
+ onLeave(source, event) {
503
748
  if (!this.accepts(source))
504
749
  return;
505
750
  clearTimeout(this.showTimer);
506
- clearTimeout(this.hideTimer);
507
- const delay = this.option('hideDelay');
508
- if (delay > 0)
509
- this.hideTimer = setTimeout(() => this.hide(), delay);
510
- else
511
- this.hide();
751
+ if (source === 'hover') {
752
+ // Mouse indo do host para o proprio tooltip (conteudo "hoverable", WCAG 1.4.13): continua aberto.
753
+ const related = event?.relatedTarget;
754
+ if (related && this.overlayRef?.overlayElement.contains(related))
755
+ return;
756
+ if (this.openedByTouch || this.hasKeyboardFocus())
757
+ return;
758
+ }
759
+ else {
760
+ const related = event?.relatedTarget;
761
+ if (related && this.overlayRef?.overlayElement.contains(related))
762
+ return;
763
+ }
764
+ this.scheduleHide();
512
765
  }
513
- show() {
514
- const text = this.text();
515
- if (this.option('tooltipDisabled') || !text)
766
+ onTouchStart() {
767
+ this.lastTouchAt = Date.now();
768
+ if (this.option('tooltipEvent') === 'focus')
769
+ return;
770
+ clearTimeout(this.touchTimer);
771
+ this.touchTimer = setTimeout(() => {
772
+ this.openedByTouch = true;
773
+ this.show(true);
774
+ }, LONG_PRESS);
775
+ }
776
+ onTouchEnd() {
777
+ this.lastTouchAt = Date.now();
778
+ clearTimeout(this.touchTimer);
779
+ }
780
+ /** Abre o tooltip. `immediate` ignora o `showDelay` (foco por teclado, toque longo). */
781
+ show(immediate = false) {
782
+ if (!this.canShow())
516
783
  return;
517
784
  clearTimeout(this.hideTimer);
518
785
  if (this.overlayRef)
519
786
  return;
520
787
  clearTimeout(this.showTimer);
521
- this.showTimer = setTimeout(() => this.open(text), this.option('showDelay'));
788
+ const warm = this.isWarm();
789
+ const delay = immediate || warm ? 0 : this.option('showDelay');
790
+ if (delay > 0)
791
+ this.showTimer = setTimeout(() => this.open(false), delay);
792
+ else
793
+ this.open(warm);
522
794
  }
523
795
  hide() {
524
796
  clearTimeout(this.showTimer);
525
797
  clearTimeout(this.hideTimer);
526
- this.overlayRef?.dispose();
798
+ clearTimeout(this.touchTimer);
799
+ if (!this.overlayRef)
800
+ return;
801
+ const overlayRef = this.overlayRef;
527
802
  this.overlayRef = undefined;
803
+ this.componentRef = undefined;
804
+ this.openedByTouch = false;
805
+ this.subscriptions?.unsubscribe();
806
+ this.subscriptions = undefined;
807
+ document.removeEventListener('keydown', this.onDocumentKeydown, true);
808
+ document.removeEventListener('touchstart', this.onDocumentTouch, true);
809
+ overlayRef.overlayElement.removeEventListener('mouseenter', this.onPanelEnter);
810
+ overlayRef.overlayElement.removeEventListener('mouseleave', this.onPanelLeave);
811
+ overlayRef.dispose();
812
+ this.setDescribedBy(false);
813
+ if (shared.active === this) {
814
+ shared.active = null;
815
+ shared.lastClosedAt = Date.now();
816
+ }
528
817
  }
529
818
  ngOnDestroy() {
530
819
  this.hide();
531
820
  }
821
+ scheduleHide() {
822
+ clearTimeout(this.hideTimer);
823
+ const delay = this.option('hideDelay');
824
+ if (delay > 0)
825
+ this.hideTimer = setTimeout(() => this.hide(), delay);
826
+ else
827
+ this.hide();
828
+ }
532
829
  accepts(source) {
533
830
  const event = this.option('tooltipEvent');
534
831
  return event === 'both' || event === source;
535
832
  }
833
+ canShow() {
834
+ if (this.option('tooltipDisabled'))
835
+ return false;
836
+ if (!this.text() && !this.option('tooltipTitle') && !this.option('tooltipShortcut'))
837
+ return false;
838
+ return !this.option('tooltipOnOverflow') || this.isOverflowing();
839
+ }
840
+ isOverflowing() {
841
+ const element = this.host.nativeElement;
842
+ return element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
843
+ }
844
+ isFocusVisible(target) {
845
+ const element = target ?? this.host.nativeElement;
846
+ try {
847
+ return element.matches(':focus-visible');
848
+ }
849
+ catch {
850
+ return true;
851
+ }
852
+ }
853
+ hasKeyboardFocus() {
854
+ if (!this.accepts('focus'))
855
+ return false;
856
+ const active = document.activeElement;
857
+ if (!active || !this.host.nativeElement.contains(active))
858
+ return false;
859
+ return this.option('tooltipEvent') === 'focus' || this.isFocusVisible(active);
860
+ }
861
+ /** Outro tooltip aberto, ou fechado ha pouco: este abre na hora e sem animacao. */
862
+ isWarm() {
863
+ const window = this.defaults.warmupWindow;
864
+ if (window <= 0)
865
+ return false;
866
+ return (shared.active !== null && shared.active !== this) || Date.now() - shared.lastClosedAt < window;
867
+ }
536
868
  option(key) {
537
869
  const fromInputs = {
538
- tooltipPosition: this.tooltipPosition(),
539
- showDelay: this.showDelay(),
540
- hideDelay: this.hideDelay(),
541
- tooltipEvent: this.tooltipEvent(),
870
+ tooltipPosition: this.tooltipPosition() ?? this.defaults.position,
871
+ showDelay: this.showDelay() ?? this.defaults.showDelay,
872
+ hideDelay: this.hideDelay() ?? this.defaults.hideDelay,
873
+ tooltipEvent: this.tooltipEvent() ?? this.defaults.tooltipEvent,
542
874
  escape: this.escape(),
543
875
  tooltipStyleClass: this.tooltipStyleClass(),
544
876
  tooltipZIndex: this.tooltipZIndex(),
545
877
  tooltipDisabled: this.tooltipDisabled(),
878
+ tooltipTitle: this.tooltipTitle() ?? '',
879
+ tooltipShortcut: this.tooltipShortcut() ?? '',
880
+ tooltipVariant: this.tooltipVariant() ?? this.defaults.variant,
881
+ tooltipSeverity: this.tooltipSeverity() ?? null,
882
+ tooltipArrow: this.tooltipArrow() ?? this.defaults.arrow,
883
+ tooltipOnOverflow: this.tooltipOnOverflow(),
546
884
  };
547
885
  const merged = { ...fromInputs, ...(this.tooltipOptions() ?? {}), ...this.overrides() };
548
886
  return merged[key];
549
887
  }
550
- open(text) {
551
- this.overlayRef = this.overlay.create({
552
- positionStrategy: this.overlay
553
- .position()
554
- .flexibleConnectedTo(this.host)
555
- .withPositions(POSITIONS$3[this.option('tooltipPosition')])
556
- .withPush(true),
557
- scrollStrategy: this.overlay.scrollStrategies.close(),
558
- });
888
+ open(instant) {
889
+ if (this.overlayRef || !this.canShow())
890
+ return;
891
+ // Um tooltip por vez: o anterior fecha na hora.
892
+ if (shared.active && shared.active !== this)
893
+ shared.active.hide();
894
+ shared.active = this;
895
+ const arrow = this.option('tooltipArrow');
896
+ const positionStrategy = this.overlay
897
+ .position()
898
+ .flexibleConnectedTo(this.host)
899
+ .withPositions(POSITIONS$3[this.option('tooltipPosition')] ?? POSITIONS$3.top)
900
+ .withPush(true);
901
+ // Acompanha o host durante a rolagem e fecha so quando sai da vista. Fechar em qualquer rolagem derrubava o tooltip
902
+ // aberto por foco quando o proprio foco rolava a pagina (Tab ate um elemento fora da tela).
903
+ const scrollStrategy = this.overlay.scrollStrategies.reposition({ scrollThrottle: 20, autoClose: true });
904
+ const overlayRef = this.overlay.create({ positionStrategy, scrollStrategy });
905
+ this.overlayRef = overlayRef;
906
+ smzInheritThemeScope(overlayRef, this.host.nativeElement);
559
907
  const zIndex = this.option('tooltipZIndex');
560
908
  if (zIndex !== '')
561
- this.overlayRef.hostElement.style.zIndex = String(zIndex);
562
- const ref = this.overlayRef.attach(new ComponentPortal(SmzTooltipComponent));
563
- ref.setInput('text', text);
909
+ overlayRef.hostElement.style.zIndex = String(zIndex);
910
+ const content = this.text();
911
+ const ref = overlayRef.attach(new ComponentPortal(SmzTooltipComponent, this.viewContainer));
912
+ this.componentRef = ref;
913
+ ref.setInput('tooltipId', this.tooltipId);
914
+ ref.setInput('text', typeof content === 'string' ? content : '');
915
+ ref.setInput('template', content instanceof TemplateRef ? content : null);
564
916
  ref.setInput('escape', this.option('escape'));
917
+ ref.setInput('title', this.option('tooltipTitle'));
918
+ ref.setInput('shortcut', this.option('tooltipShortcut'));
919
+ ref.setInput('variant', this.option('tooltipVariant'));
920
+ ref.setInput('severity', this.option('tooltipSeverity'));
921
+ ref.setInput('arrow', arrow);
922
+ ref.setInput('styleClass', this.option('tooltipStyleClass'));
923
+ ref.setInput('instant', instant);
924
+ ref.setInput('gap', arrow ? GAP_WITH_ARROW : GAP_PLAIN);
925
+ ref.changeDetectorRef.detectChanges();
926
+ this.subscriptions = new Subscription();
927
+ this.subscriptions.add(this.watchPosition(positionStrategy, ref));
928
+ // Fechado pelo CDK (host rolou para fora da vista): limpa o estado para poder abrir de novo.
929
+ this.subscriptions.add(overlayRef.detachments().subscribe(() => this.hide()));
930
+ overlayRef.overlayElement.addEventListener('mouseenter', this.onPanelEnter);
931
+ overlayRef.overlayElement.addEventListener('mouseleave', this.onPanelLeave);
932
+ document.addEventListener('keydown', this.onDocumentKeydown, true);
933
+ if (this.openedByTouch)
934
+ document.addEventListener('touchstart', this.onDocumentTouch, true);
935
+ this.setDescribedBy(true);
936
+ }
937
+ /** Lado real e posicao da seta, recalculados sempre que o CDK reposiciona (inversao por falta de espaco). */
938
+ watchPosition(strategy, ref) {
939
+ return strategy.positionChanges.subscribe((change) => {
940
+ const side = sideOf(change.connectionPair);
941
+ const sideChanged = ref.instance.side() !== side;
942
+ ref.setInput('side', side);
943
+ ref.changeDetectorRef.detectChanges();
944
+ // A ponte (padding do lado do host) muda o tamanho do painel: reposiciona uma vez com o tamanho final.
945
+ if (sideChanged)
946
+ this.overlayRef?.updatePosition();
947
+ const box = ref.location.nativeElement.querySelector('[role="tooltip"]');
948
+ if (!box)
949
+ return;
950
+ const hostRect = this.host.nativeElement.getBoundingClientRect();
951
+ const boxRect = box.getBoundingClientRect();
952
+ const horizontal = side === 'top' || side === 'bottom';
953
+ const length = horizontal ? boxRect.width : boxRect.height;
954
+ const center = horizontal ? hostRect.left + hostRect.width / 2 - boxRect.left : hostRect.top + hostRect.height / 2 - boxRect.top;
955
+ const inset = Math.min(ARROW_INSET, length / 2);
956
+ ref.setInput('arrowOffset', `${Math.round(Math.max(inset, Math.min(length - inset, center)))}px`);
957
+ ref.changeDetectorRef.detectChanges();
958
+ });
959
+ }
960
+ /** Associa o tooltip ao host para leitores de tela enquanto estiver aberto. */
961
+ setDescribedBy(open) {
962
+ const element = this.host.nativeElement;
963
+ const current = (element.getAttribute('aria-describedby') ?? '').split(/\s+/).filter((id) => id && id !== this.tooltipId);
964
+ if (open)
965
+ current.push(this.tooltipId);
966
+ if (current.length > 0)
967
+ element.setAttribute('aria-describedby', current.join(' '));
968
+ else
969
+ element.removeAttribute('aria-describedby');
565
970
  }
566
971
  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 });
972
+ 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
973
  }
569
974
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzTooltipDirective, decorators: [{
570
975
  type: Directive,
571
976
  args: [{
572
977
  selector: '[smzTooltip]',
573
978
  host: {
574
- '(mouseenter)': 'onEnter(\'hover\')',
575
- '(mouseleave)': 'onLeave(\'hover\')',
576
- '(focusin)': 'onEnter(\'focus\')',
577
- '(focusout)': 'onLeave(\'focus\')',
979
+ '(mouseenter)': 'onEnter(\'hover\', $event)',
980
+ '(mouseleave)': 'onLeave(\'hover\', $event)',
981
+ '(focusin)': 'onEnter(\'focus\', $event)',
982
+ '(focusout)': 'onLeave(\'focus\', $event)',
578
983
  '(keydown.escape)': 'hide()',
984
+ '(touchstart)': 'onTouchStart()',
985
+ '(touchend)': 'onTouchEnd()',
986
+ '(touchmove)': 'onTouchEnd()',
987
+ '(touchcancel)': 'onTouchEnd()',
579
988
  },
580
989
  }]
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 }] }] } });
990
+ }], 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
991
 
583
992
  /**
584
993
  * Efeito ripple. Substitui o `pRipple` do PrimeNG.
@@ -1873,6 +2282,8 @@ class SmzDialogService {
1873
2282
  ...pane,
1874
2283
  maxWidth: pane.maxWidth ?? '95vw',
1875
2284
  });
2285
+ // Sem elemento de origem: o diálogo herda o tema de onde está o foco (o gatilho que o abriu).
2286
+ smzInheritThemeScope(overlayRef, overlayRef.overlayElement.ownerDocument.activeElement);
1876
2287
  if (resolved.baseZIndex != null) {
1877
2288
  overlayRef.hostElement.style.zIndex = String(resolved.baseZIndex + 1);
1878
2289
  if (overlayRef.backdropElement)
@@ -2037,6 +2448,7 @@ class SmzDialogComponent {
2037
2448
  ...(this.maximized() ? { width: '100vw', height: '100vh', maxWidth: '100vw', maxHeight: '100vh' } : { ...this.sizing().pane, maxWidth: this.sizing().pane.maxWidth ?? '95vw' }),
2038
2449
  });
2039
2450
  SmzZIndex.set('modal', this.overlayRef.hostElement, 1100 + this.baseZIndex());
2451
+ smzInheritThemeScope(this.overlayRef, this.host.nativeElement);
2040
2452
  if (this.overlayRef.backdropElement) {
2041
2453
  this.overlayRef.backdropElement.style.zIndex = String(SmzZIndex.get(this.overlayRef.hostElement) - 1);
2042
2454
  }
@@ -2247,6 +2659,7 @@ class SmzPopoverComponent {
2247
2659
  });
2248
2660
  if (this.autoZIndex())
2249
2661
  SmzZIndex.set('overlay', this.overlayRef.hostElement, 1000);
2662
+ smzInheritThemeScope(this.overlayRef, this.origin ?? this.host.nativeElement);
2250
2663
  if (this.dismissable()) {
2251
2664
  merge(this.overlayRef.outsidePointerEvents().pipe(filter((outside) => !this.origin?.contains(outside.target))), this.overlayRef.keydownEvents().pipe(filter((key) => key.key === 'Escape'))).subscribe(() => this.hide());
2252
2665
  }
@@ -2389,6 +2802,7 @@ class SmzDrawerComponent {
2389
2802
  scrollStrategy: this.overlay.scrollStrategies.block(),
2390
2803
  });
2391
2804
  SmzZIndex.set('modal', this.overlayRef.hostElement, 1100);
2805
+ smzInheritThemeScope(this.overlayRef, this.host.nativeElement);
2392
2806
  if (this.overlayRef.backdropElement) {
2393
2807
  this.overlayRef.backdropElement.style.zIndex = String(SmzZIndex.get(this.overlayRef.hostElement) - 1);
2394
2808
  }
@@ -2499,18 +2913,95 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
2499
2913
  }]
2500
2914
  }], 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
2915
 
2916
+ const SMZ_TOAST_DEFAULT_OPTIONS = {
2917
+ showProgress: true,
2918
+ pauseOnHover: true,
2919
+ maxVisible: 5,
2920
+ life: 3000,
2921
+ lifeBySeverity: { warn: 6000, error: 6000 },
2922
+ groupDuplicates: true,
2923
+ };
2924
+ const SMZ_TOAST_DEFAULTS = new InjectionToken('SMZ_TOAST_DEFAULTS');
2925
+ /**
2926
+ * Padroes globais do `ui-toast`.
2927
+ *
2928
+ * providers: [provideSmzToastDefaults({ maxVisible: 3, lifeBySeverity: { error: 10000 } })]
2929
+ */
2930
+ function provideSmzToastDefaults(defaults) {
2931
+ return makeEnvironmentProviders([{ provide: SMZ_TOAST_DEFAULTS, useValue: defaults }]);
2932
+ }
2933
+ const globalDefaults$1 = {};
2934
+ /**
2935
+ * Padroes globais definidos fora da injecao de dependencias (usado pelo `SmzUiBuilder` do @ngx-smz/core).
2936
+ * O token `SMZ_TOAST_DEFAULTS`, quando provido, tem precedencia. Campos `undefined` sao ignorados.
2937
+ */
2938
+ function smzSetToastDefaults(defaults) {
2939
+ for (const [key, value] of Object.entries(defaults ?? {})) {
2940
+ if (value !== undefined && value !== null)
2941
+ globalDefaults$1[key] = value;
2942
+ }
2943
+ }
2944
+ /** Padroes em vigor: base do kit, depois `smzSetToastDefaults`, depois o token. */
2945
+ function smzResolveToastDefaults(provided) {
2946
+ return { ...SMZ_TOAST_DEFAULT_OPTIONS, ...globalDefaults$1, ...(provided ?? {}) };
2947
+ }
2502
2948
  let nextId = 0;
2949
+ const GROUP_FIELDS = ['key', 'severity', 'summary', 'detail', 'icon', 'sticky', 'styleClass'];
2950
+ function sameContent(a, b) {
2951
+ return GROUP_FIELDS.every((field) => (a[field] ?? null) === (b[field] ?? null)) && (a.action?.label ?? null) === (b.action?.label ?? null);
2952
+ }
2503
2953
  /** Barramento de mensagens do toast. Substitui o `MessageService` do PrimeNG. */
2504
2954
  class SmzMessageService {
2505
2955
  state = signal([], ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2956
+ providedDefaults = inject(SMZ_TOAST_DEFAULTS, { optional: true });
2506
2957
  /** Mensagens atualmente na fila (todas as chaves). */
2507
2958
  messages = this.state.asReadonly();
2508
2959
  add(message) {
2509
2960
  this.addAll([message]);
2510
2961
  }
2511
2962
  addAll(messages) {
2512
- const prepared = messages.map((message) => ({ ...message, id: message.id ?? `smz-toast-${++nextId}` }));
2513
- this.state.update((current) => [...current, ...prepared]);
2963
+ const groupDuplicates = smzResolveToastDefaults(this.providedDefaults).groupDuplicates;
2964
+ this.state.update((current) => {
2965
+ const next = [...current];
2966
+ for (const message of messages) {
2967
+ const canGroup = groupDuplicates && message.group !== false && !message.loading && (message.id === undefined || message.id === null);
2968
+ const index = canGroup ? next.findIndex((entry) => entry.group !== false && !entry.loading && sameContent(entry, message)) : -1;
2969
+ if (index >= 0) {
2970
+ const existing = next[index];
2971
+ next[index] = { ...existing, count: (existing.count ?? 1) + 1, revision: (existing.revision ?? 0) + 1 };
2972
+ }
2973
+ else {
2974
+ next.push({ ...message, id: message.id ?? `smz-toast-${++nextId}` });
2975
+ }
2976
+ }
2977
+ return next;
2978
+ });
2979
+ }
2980
+ /** Atualiza no lugar a mensagem com esse `id` e reinicia o tempo de vida dela. */
2981
+ update(id, changes) {
2982
+ this.state.update((current) => current.map((entry) => (entry.id === id ? { ...entry, ...changes, id, revision: (entry.revision ?? 0) + 1 } : entry)));
2983
+ }
2984
+ /**
2985
+ * Toast de carregamento que depois vira o resultado, no mesmo lugar.
2986
+ *
2987
+ * const toast = messages.loading({ summary: 'Gerando Excel...' });
2988
+ * exportar().subscribe({ next: () => toast.success('Excel gerado com sucesso.'), error: () => toast.error('Falha ao gerar o Excel.') });
2989
+ */
2990
+ loading(message) {
2991
+ const base = typeof message === 'string' ? { summary: message } : message;
2992
+ const id = base.id ?? `smz-toast-${++nextId}`;
2993
+ this.state.update((current) => [...current, { severity: 'secondary', closable: false, ...base, id, loading: true }]);
2994
+ const settle = (severity, result) => {
2995
+ const changes = typeof result === 'string' ? { detail: result } : (result ?? {});
2996
+ this.update(id, { closable: true, ...changes, severity: changes.severity ?? severity, loading: false });
2997
+ };
2998
+ return {
2999
+ id,
3000
+ update: (changes) => this.update(id, changes),
3001
+ success: (result) => settle('success', result),
3002
+ error: (result) => settle('error', result),
3003
+ close: () => this.remove({ id }),
3004
+ };
2514
3005
  }
2515
3006
  remove(message) {
2516
3007
  this.state.update((current) => current.filter((entry) => entry !== message && entry.id !== message.id));
@@ -2536,6 +3027,16 @@ const POSITION_CLASSES = {
2536
3027
  'bottom-right': 'bottom-4 right-4 items-end',
2537
3028
  center: 'top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 items-center',
2538
3029
  };
3030
+ /** De onde o toast entra: do lado da tela em que o container esta. */
3031
+ const ENTER_OFFSET = {
3032
+ 'top-left': { x: -28, y: 0 },
3033
+ 'top-center': { x: 0, y: -18 },
3034
+ 'top-right': { x: 28, y: 0 },
3035
+ 'bottom-left': { x: -28, y: 0 },
3036
+ 'bottom-center': { x: 0, y: 18 },
3037
+ 'bottom-right': { x: 28, y: 0 },
3038
+ center: { x: 0, y: 0 },
3039
+ };
2539
3040
  const SEVERITY_TONE = {
2540
3041
  success: 'success',
2541
3042
  info: 'primary',
@@ -2545,42 +3046,213 @@ const SEVERITY_TONE = {
2545
3046
  contrast: 'secondary',
2546
3047
  };
2547
3048
  /**
2548
- * Fundo opaco (surface-2) com tinta da severidade por cima (gradiente de uma cor so) e faixa lateral na cor da severidade.
2549
- * O texto e o icone usam `text-ui-fg` (contraste AA em qualquer tema); a severidade fica na tinta, na borda e na faixa.
2550
- * Strings literais para o Tailwind encontrar no scan.
3049
+ * O texto usa `text-ui-fg` / `text-ui-fg-muted` sobre fundo opaco (contraste AA em qualquer tema); a severidade fica
3050
+ * no icone, na barra e na tinta. Strings literais para o Tailwind encontrar no scan.
2551
3051
  */
2552
3052
  const TOAST_TONE = {
2553
- primary: 'border-ui-primary/50 border-l-ui-primary bg-[linear-gradient(rgb(var(--smz-color-primary)/0.12),rgb(var(--smz-color-primary)/0.12))]',
2554
- secondary: 'border-ui-line-strong border-l-ui-fg-muted bg-[linear-gradient(rgb(var(--smz-color-fg-muted)/0.1),rgb(var(--smz-color-fg-muted)/0.1))]',
2555
- success: 'border-ui-success/50 border-l-ui-success bg-[linear-gradient(rgb(var(--smz-color-success)/0.12),rgb(var(--smz-color-success)/0.12))]',
2556
- warning: 'border-ui-warning/60 border-l-ui-warning bg-[linear-gradient(rgb(var(--smz-color-warning)/0.14),rgb(var(--smz-color-warning)/0.14))]',
2557
- danger: 'border-ui-danger/50 border-l-ui-danger bg-[linear-gradient(rgb(var(--smz-color-danger)/0.12),rgb(var(--smz-color-danger)/0.12))]',
3053
+ primary: {
3054
+ card: 'border-ui-primary/40 bg-[linear-gradient(rgb(var(--smz-color-primary)/0.07),rgb(var(--smz-color-primary)/0.07))]',
3055
+ solid: 'bg-ui-primary text-ui-on-primary',
3056
+ track: 'bg-ui-primary/20',
3057
+ fill: 'bg-ui-primary',
3058
+ action: 'border-ui-primary/50 hover:bg-ui-primary/15',
3059
+ },
3060
+ secondary: {
3061
+ card: 'border-ui-line-strong bg-[linear-gradient(rgb(var(--smz-color-fg-muted)/0.07),rgb(var(--smz-color-fg-muted)/0.07))]',
3062
+ solid: 'bg-ui-fg-muted text-ui-surface-1',
3063
+ track: 'bg-ui-fg-muted/20',
3064
+ fill: 'bg-ui-fg-muted',
3065
+ action: 'border-ui-line-strong hover:bg-ui-fg-muted/15',
3066
+ },
3067
+ success: {
3068
+ card: 'border-ui-success/40 bg-[linear-gradient(rgb(var(--smz-color-success)/0.07),rgb(var(--smz-color-success)/0.07))]',
3069
+ solid: 'bg-ui-success text-ui-on-success',
3070
+ track: 'bg-ui-success/20',
3071
+ fill: 'bg-ui-success',
3072
+ action: 'border-ui-success/50 hover:bg-ui-success/15',
3073
+ },
3074
+ warning: {
3075
+ card: 'border-ui-warning/50 bg-[linear-gradient(rgb(var(--smz-color-warning)/0.09),rgb(var(--smz-color-warning)/0.09))]',
3076
+ solid: 'bg-ui-warning text-ui-on-warning',
3077
+ track: 'bg-ui-warning/25',
3078
+ fill: 'bg-ui-warning',
3079
+ action: 'border-ui-warning/60 hover:bg-ui-warning/15',
3080
+ },
3081
+ danger: {
3082
+ card: 'border-ui-danger/40 bg-[linear-gradient(rgb(var(--smz-color-danger)/0.07),rgb(var(--smz-color-danger)/0.07))]',
3083
+ solid: 'bg-ui-danger text-ui-on-danger',
3084
+ track: 'bg-ui-danger/20',
3085
+ fill: 'bg-ui-danger',
3086
+ action: 'border-ui-danger/50 hover:bg-ui-danger/15',
3087
+ },
2558
3088
  };
2559
- const DEFAULT_LIFE = 3000;
3089
+ const SWIPE_DISMISS = 80;
3090
+ /** Inputs opcionais: ausente (`undefined`) significa "usa o padrao global". */
3091
+ const optionalNumber = (value) => (value === undefined || value === null || value === '' ? undefined : numberAttribute(value));
3092
+ const optionalBoolean = (value) => (value === undefined || value === null ? undefined : booleanAttribute(value));
3093
+ function prefersReducedMotion() {
3094
+ return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
3095
+ }
3096
+ /**
3097
+ * Relogio do toast: a barra que encolhe E o fechamento sao a mesma animacao (Web Animations API), entao nunca
3098
+ * dessincronizam. Pausar e pausar a animacao; `expired` dispara quando ela termina.
3099
+ * Nao usa animacao CSS de proposito: resets globais de `prefers-reduced-motion` (`animation-duration: 0.01ms !important`)
3100
+ * fechariam o toast na hora. Sem `Element.animate` (SSR, testes) cai para `setTimeout`.
3101
+ */
3102
+ class SmzToastLifeDirective {
3103
+ /** Tempo de vida em ms. */
3104
+ duration = input.required({ ...(ngDevMode ? { debugName: "duration" } : /* istanbul ignore next */ {}), alias: 'smzToastLife' });
3105
+ paused = input(false, ...(ngDevMode ? [{ debugName: "paused" }] : /* istanbul ignore next */ []));
3106
+ /** Mudou: reinicia do zero (mensagem atualizada ou repetida). */
3107
+ revision = input(0, ...(ngDevMode ? [{ debugName: "revision" }] : /* istanbul ignore next */ []));
3108
+ expired = output();
3109
+ element = inject(ElementRef).nativeElement;
3110
+ animation;
3111
+ timer;
3112
+ remaining = 0;
3113
+ startedAt = 0;
3114
+ constructor() {
3115
+ effect(() => {
3116
+ this.revision();
3117
+ const duration = this.duration();
3118
+ untracked(() => this.start(duration));
3119
+ });
3120
+ effect(() => {
3121
+ const paused = this.paused();
3122
+ untracked(() => (paused ? this.pause() : this.resume()));
3123
+ });
3124
+ inject(DestroyRef).onDestroy(() => this.stop());
3125
+ }
3126
+ start(duration) {
3127
+ this.stop();
3128
+ const life = Math.max(0, duration);
3129
+ if (typeof this.element.animate === 'function') {
3130
+ this.animation = this.element.animate([{ transform: 'scaleX(1)' }, { transform: 'scaleX(0)' }], { duration: life, easing: 'linear', fill: 'forwards' });
3131
+ this.animation.onfinish = () => this.expired.emit();
3132
+ if (this.paused())
3133
+ this.animation.pause();
3134
+ return;
3135
+ }
3136
+ this.remaining = life;
3137
+ if (!this.paused())
3138
+ this.arm();
3139
+ }
3140
+ pause() {
3141
+ if (this.animation) {
3142
+ if (this.animation.playState === 'running')
3143
+ this.animation.pause();
3144
+ return;
3145
+ }
3146
+ if (this.timer === undefined)
3147
+ return;
3148
+ clearTimeout(this.timer);
3149
+ this.timer = undefined;
3150
+ this.remaining = Math.max(0, this.remaining - (Date.now() - this.startedAt));
3151
+ }
3152
+ resume() {
3153
+ if (this.animation) {
3154
+ if (this.animation.playState === 'paused')
3155
+ this.animation.play();
3156
+ return;
3157
+ }
3158
+ if (this.timer === undefined && this.remaining > 0)
3159
+ this.arm();
3160
+ }
3161
+ arm() {
3162
+ this.startedAt = Date.now();
3163
+ this.timer = setTimeout(() => {
3164
+ this.timer = undefined;
3165
+ this.remaining = 0;
3166
+ this.expired.emit();
3167
+ }, this.remaining);
3168
+ }
3169
+ stop() {
3170
+ if (this.animation) {
3171
+ this.animation.onfinish = null;
3172
+ this.animation.cancel();
3173
+ this.animation = undefined;
3174
+ }
3175
+ clearTimeout(this.timer);
3176
+ this.timer = undefined;
3177
+ }
3178
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastLifeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
3179
+ 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 });
3180
+ }
3181
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastLifeDirective, decorators: [{
3182
+ type: Directive,
3183
+ args: [{ selector: '[smzToastLife]' }]
3184
+ }], 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"] }] } });
3185
+ /** Animacao de entrada do toast (uma vez, quando o elemento nasce): desliza do lado do container com fade. */
3186
+ class SmzToastEnterDirective {
3187
+ offset = input({ x: 0, y: 0 }, { ...(ngDevMode ? { debugName: "offset" } : /* istanbul ignore next */ {}), alias: 'smzToastEnter' });
3188
+ constructor() {
3189
+ const element = inject(ElementRef).nativeElement;
3190
+ let played = false;
3191
+ effect(() => {
3192
+ const { x, y } = this.offset();
3193
+ if (played || typeof element.animate !== 'function')
3194
+ return;
3195
+ played = true;
3196
+ if (prefersReducedMotion()) {
3197
+ element.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 200, easing: 'ease-out' });
3198
+ return;
3199
+ }
3200
+ 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)' });
3201
+ });
3202
+ }
3203
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastEnterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
3204
+ 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 });
3205
+ }
3206
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastEnterDirective, decorators: [{
3207
+ type: Directive,
3208
+ args: [{ selector: '[smzToastEnter]' }]
3209
+ }], ctorParameters: () => [], propDecorators: { offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzToastEnter", required: false }] }] } });
2560
3210
  /**
2561
3211
  * Container de toasts: exibe as mensagens do `SmzMessageService`. Substitui o `p-toast` do PrimeNG.
2562
3212
  *
2563
3213
  * <ui-toast position="bottom-right" />
3214
+ *
3215
+ * Cada toast tem icone da severidade, barra de progresso do tempo de vida (pausa com mouse/foco sobre a pilha e com a
3216
+ * aba em segundo plano), animacao de entrada/saida e, opcionalmente, um botao de acao.
2564
3217
  */
2565
3218
  class SmzToastContainerComponent {
2566
3219
  position = input('top-right', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
2567
3220
  key = input(undefined, ...(ngDevMode ? [{ debugName: "key" }] : /* istanbul ignore next */ []));
2568
- life = input(DEFAULT_LIFE, ...(ngDevMode ? [{ debugName: "life" }] : /* istanbul ignore next */ []));
3221
+ /** Tempo de vida (ms) das mensagens sem `life`. Sem o input valem os padroes globais (3s; aviso e erro 6s). */
3222
+ life = input(undefined, { ...(ngDevMode ? { debugName: "life" } : /* istanbul ignore next */ {}), transform: optionalNumber });
3223
+ /** Tempo de vida (ms) por severidade; tem precedencia sobre `life`. */
3224
+ lifeBySeverity = input(undefined, ...(ngDevMode ? [{ debugName: "lifeBySeverity" }] : /* istanbul ignore next */ []));
3225
+ showProgress = input(undefined, { ...(ngDevMode ? { debugName: "showProgress" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
3226
+ pauseOnHover = input(undefined, { ...(ngDevMode ? { debugName: "pauseOnHover" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
3227
+ /** Maximo de toasts visiveis; os excedentes entram quando abrir espaco (padrao 5). */
3228
+ maxVisible = input(undefined, { ...(ngDevMode ? { debugName: "maxVisible" } : /* istanbul ignore next */ {}), transform: optionalNumber });
2569
3229
  style = input(null, ...(ngDevMode ? [{ debugName: "style" }] : /* istanbul ignore next */ []));
2570
3230
  styleClass = input('', ...(ngDevMode ? [{ debugName: "styleClass" }] : /* istanbul ignore next */ []));
2571
3231
  service = inject(SmzMessageService);
2572
- timers = new Map();
3232
+ providedDefaults = inject(SMZ_TOAST_DEFAULTS, { optional: true });
3233
+ leaving = new Set();
3234
+ drag;
3235
+ hovered = signal(false, ...(ngDevMode ? [{ debugName: "hovered" }] : /* istanbul ignore next */ []));
3236
+ focused = signal(false, ...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
3237
+ hidden = signal(typeof document !== 'undefined' && document.visibilityState === 'hidden', ...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
2573
3238
  positionClasses = computed(() => POSITION_CLASSES[this.position()] ?? POSITION_CLASSES['top-right'], ...(ngDevMode ? [{ debugName: "positionClasses" }] : /* istanbul ignore next */ []));
3239
+ enterOffset = computed(() => ENTER_OFFSET[this.position()] ?? ENTER_OFFSET['top-right'], ...(ngDevMode ? [{ debugName: "enterOffset" }] : /* istanbul ignore next */ []));
2574
3240
  visibleMessages = computed(() => {
2575
3241
  const key = this.key();
2576
3242
  return this.service.messages().filter((message) => (key ? message.key === key : !message.key));
2577
3243
  }, ...(ngDevMode ? [{ debugName: "visibleMessages" }] : /* istanbul ignore next */ []));
3244
+ /** As primeiras `maxVisible`; o relogio das demais so comeca quando elas entram na tela. */
3245
+ shownMessages = computed(() => {
3246
+ const max = this.maxVisible() ?? this.defaults.maxVisible;
3247
+ const messages = this.visibleMessages();
3248
+ return max > 0 ? messages.slice(0, max) : messages;
3249
+ }, ...(ngDevMode ? [{ debugName: "shownMessages" }] : /* istanbul ignore next */ []));
2578
3250
  layer = viewChild('layer', ...(ngDevMode ? [{ debugName: "layer" }] : /* istanbul ignore next */ []));
3251
+ stack = viewChild('stack', ...(ngDevMode ? [{ debugName: "stack" }] : /* istanbul ignore next */ []));
3252
+ get defaults() {
3253
+ return smzResolveToastDefaults(this.providedDefaults);
3254
+ }
2579
3255
  constructor() {
2580
- effect(() => {
2581
- for (const message of this.visibleMessages())
2582
- this.schedule(message);
2583
- });
2584
3256
  // Abre a camada quando ha mensagens (reabrindo a cada mudanca para ficar acima de overlays abertos depois) e fecha quando nao ha.
2585
3257
  effect(() => {
2586
3258
  const count = this.visibleMessages().length;
@@ -2597,150 +3269,436 @@ class SmzToastContainerComponent {
2597
3269
  /* sem suporte: segue com z-index */
2598
3270
  }
2599
3271
  });
2600
- inject(DestroyRef).onDestroy(() => this.timers.forEach((timer) => clearTimeout(timer.handle)));
3272
+ if (typeof document !== 'undefined') {
3273
+ // Aba em segundo plano: o tempo nao corre, para o usuario nao perder mensagens que venceriam sem ele ver.
3274
+ const onVisibility = () => this.hidden.set(document.visibilityState === 'hidden');
3275
+ document.addEventListener('visibilitychange', onVisibility);
3276
+ inject(DestroyRef).onDestroy(() => document.removeEventListener('visibilitychange', onVisibility));
3277
+ }
3278
+ }
3279
+ tone(message) {
3280
+ return TOAST_TONE[this.severityOf(message)] ?? TOAST_TONE.primary;
3281
+ }
3282
+ countClasses(message) {
3283
+ return `inline-block shrink-0 rounded-full px-[7px] font-ui-mono text-[11px] font-medium leading-[18px] ${this.tone(message).solid}`;
3284
+ }
3285
+ iconOf(message) {
3286
+ return this.severityOf(message);
3287
+ }
3288
+ /** Aviso e erro interrompem o leitor de tela (`alert`); o resto e anunciado quando ele estiver livre (`status`). */
3289
+ isAssertive(message) {
3290
+ return !message.loading && (message.severity === 'warn' || message.severity === 'error');
3291
+ }
3292
+ hasLife(message) {
3293
+ return !message.sticky && !message.loading;
3294
+ }
3295
+ showsProgress(message) {
3296
+ return message.showProgress ?? this.showProgress() ?? this.defaults.showProgress;
3297
+ }
3298
+ lifeOf(message) {
3299
+ if (typeof message.life === 'number')
3300
+ return message.life;
3301
+ const severity = message.severity ?? 'info';
3302
+ const fromInput = this.lifeBySeverity()?.[severity] ?? this.life();
3303
+ if (typeof fromInput === 'number')
3304
+ return fromInput;
3305
+ return this.defaults.lifeBySeverity[severity] ?? this.defaults.life;
2601
3306
  }
2602
- toneClasses(message) {
2603
- const tone = SEVERITY_TONE[message.severity ?? 'info'] ?? 'primary';
2604
- return TOAST_TONE[tone] ?? TOAST_TONE.primary;
3307
+ /** Mouse ou foco em qualquer toast seguram a pilha inteira: os de baixo nao somem nem pulam embaixo do cursor. */
3308
+ isPaused(message) {
3309
+ if (this.hidden())
3310
+ return true;
3311
+ const pausable = message.pauseOnHover ?? this.pauseOnHover() ?? this.defaults.pauseOnHover;
3312
+ return pausable && (this.hovered() || this.focused());
3313
+ }
3314
+ onFocusOut(event) {
3315
+ const next = event.relatedTarget;
3316
+ this.focused.set(!!next && !!this.stack()?.nativeElement.contains(next));
3317
+ }
3318
+ runAction(message) {
3319
+ const action = message.action;
3320
+ if (!action)
3321
+ return;
3322
+ action.callback();
3323
+ if (action.closeOnClick !== false)
3324
+ this.close(message);
2605
3325
  }
3326
+ /** Fecha com animacao de saida (fade + leve escala, depois a altura colapsa) e so entao remove a mensagem. */
2606
3327
  close(message) {
2607
- this.clearTimer(message);
2608
- this.service.remove(message);
3328
+ if (this.leaving.has(message.id))
3329
+ return;
3330
+ const slot = this.slotOf(message);
3331
+ const card = slot?.firstElementChild;
3332
+ if (!slot || !card || typeof card.animate !== 'function') {
3333
+ this.remove(message);
3334
+ return;
3335
+ }
3336
+ this.leaving.add(message.id);
3337
+ card.style.pointerEvents = 'none';
3338
+ const reduced = prefersReducedMotion();
3339
+ 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' });
3340
+ fade.onfinish = () => {
3341
+ if (reduced) {
3342
+ this.remove(message);
3343
+ return;
3344
+ }
3345
+ const height = slot.getBoundingClientRect().height;
3346
+ slot.style.overflow = 'hidden';
3347
+ const collapse = slot.animate([{ height: `${height}px`, paddingBottom: getComputedStyle(slot).paddingBottom }, { height: '0px', paddingBottom: '0px' }], { duration: 160, easing: 'ease-out', fill: 'forwards' });
3348
+ collapse.onfinish = () => this.remove(message);
3349
+ collapse.oncancel = () => this.remove(message);
3350
+ };
3351
+ fade.oncancel = () => this.remove(message);
2609
3352
  }
2610
- pause(message) {
2611
- const timer = this.timers.get(message.id);
2612
- if (!timer)
3353
+ onPointerDown(event, message) {
3354
+ // Arrastar para dispensar so em toque/caneta; com mouse existe o botao de fechar.
3355
+ if (event.pointerType === 'mouse' || event.target?.closest('button, a'))
2613
3356
  return;
2614
- clearTimeout(timer.handle);
2615
- timer.remaining -= Date.now() - timer.start;
3357
+ this.drag = { id: message.id, pointerId: event.pointerId, startX: event.clientX, dx: 0, element: event.currentTarget };
2616
3358
  }
2617
- resume(message) {
2618
- const timer = this.timers.get(message.id);
2619
- if (!timer || message.sticky)
3359
+ onPointerMove(event) {
3360
+ const drag = this.drag;
3361
+ if (!drag || drag.pointerId !== event.pointerId)
2620
3362
  return;
2621
- this.arm(message, Math.max(timer.remaining, 500));
3363
+ drag.dx = event.clientX - drag.startX;
3364
+ drag.element.style.transform = `translateX(${drag.dx}px)`;
3365
+ drag.element.style.opacity = String(Math.max(0.3, 1 - Math.abs(drag.dx) / 240));
2622
3366
  }
2623
- schedule(message) {
2624
- if (message.sticky || this.timers.has(message.id))
3367
+ onPointerUp(event, message) {
3368
+ const drag = this.drag;
3369
+ if (!drag || drag.pointerId !== event.pointerId)
3370
+ return;
3371
+ this.drag = undefined;
3372
+ if (event.type === 'pointerup' && Math.abs(drag.dx) >= SWIPE_DISMISS) {
3373
+ this.remove(message);
2625
3374
  return;
2626
- this.arm(message, message.life ?? this.life());
3375
+ }
3376
+ drag.element.style.transform = '';
3377
+ drag.element.style.opacity = '';
2627
3378
  }
2628
- arm(message, duration) {
2629
- const handle = setTimeout(() => this.close(message), duration);
2630
- this.timers.set(message.id, { handle, start: Date.now(), remaining: duration });
3379
+ remove(message) {
3380
+ this.leaving.delete(message.id);
3381
+ this.service.remove(message);
3382
+ // O elemento sob o mouse/foco sumiu sem `mouseleave`/`focusout`: confere o estado real para a pilha nao ficar presa em pausa.
3383
+ setTimeout(() => {
3384
+ const stack = this.stack()?.nativeElement;
3385
+ if (!stack)
3386
+ return;
3387
+ if (this.focused() && !stack.contains(document.activeElement))
3388
+ this.focused.set(false);
3389
+ if (this.hovered() && !stack.matches(':hover'))
3390
+ this.hovered.set(false);
3391
+ }, 50);
3392
+ }
3393
+ slotOf(message) {
3394
+ const slots = this.stack()?.nativeElement.querySelectorAll('[data-part="slot"]');
3395
+ return Array.from(slots ?? []).find((slot) => slot.getAttribute('data-toast-id') === String(message.id)) ?? null;
2631
3396
  }
2632
- clearTimer(message) {
2633
- const timer = this.timers.get(message.id);
2634
- if (timer)
2635
- clearTimeout(timer.handle);
2636
- this.timers.delete(message.id);
3397
+ severityOf(message) {
3398
+ return SEVERITY_TONE[message.severity ?? 'info'] ?? 'primary';
2637
3399
  }
2638
3400
  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: `
3401
+ 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
3402
  <!-- Camada na top layer (Popover API): overlays do CDK (drawer/dialog) ficam la e z-index nao os supera. -->
2641
3403
  <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
3404
  <div
2643
- class="pointer-events-none fixed z-[2000] flex w-80 max-w-[95vw] flex-col gap-2"
3405
+ #stack
3406
+ class="pointer-events-none fixed z-[2000] flex w-96 max-w-[95vw] flex-col"
2644
3407
  [class]="positionClasses()"
2645
3408
  [ngClass]="styleClass()"
2646
3409
  [ngStyle]="style()"
3410
+ [attr.data-paused]="hovered() || focused() || hidden()"
3411
+ (mouseenter)="hovered.set(true)"
3412
+ (mouseleave)="hovered.set(false)"
3413
+ (focusin)="focused.set(true)"
3414
+ (focusout)="onFocusOut($event)"
2647
3415
  >
2648
- @for (message of visibleMessages(); track message.id) {
2649
- <div
2650
- role="alert"
2651
- aria-live="assertive"
2652
- class="pointer-events-auto flex items-start gap-3 rounded-overlay border border-l-4 bg-ui-surface-2 px-4 py-3 font-ui text-ui-fg shadow-overlay"
2653
- [class]="toneClasses(message)"
2654
- [ngClass]="message.styleClass"
2655
- (mouseenter)="pause(message)"
2656
- (mouseleave)="resume(message)"
2657
- >
2658
- @if (message.icon) {
2659
- <i [class]="message.icon" aria-hidden="true"></i>
2660
- }
2661
- <div class="min-w-0 flex-1" [ngClass]="message.contentStyleClass">
2662
- @if (message.summary) {
2663
- <div class="text-ui-md font-medium">{{ message.summary }}</div>
3416
+ @for (message of shownMessages(); track message.id) {
3417
+ <!-- O espaco entre toasts e padding do slot (nao gap): o mouse atravessa a pilha sem "sair" dela. -->
3418
+ <div class="pointer-events-auto w-full pb-2" data-part="slot" [attr.data-toast-id]="message.id">
3419
+ <div
3420
+ 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)]"
3421
+ [class]="tone(message).card"
3422
+ [ngClass]="message.styleClass"
3423
+ [style.padding-bottom.px]="hasLife(message) ? 15 : null"
3424
+ [attr.role]="isAssertive(message) ? 'alert' : 'status'"
3425
+ [attr.aria-live]="isAssertive(message) ? 'assertive' : 'polite'"
3426
+ aria-atomic="true"
3427
+ [attr.data-severity]="message.severity ?? 'info'"
3428
+ [attr.data-loading]="message.loading ? 'true' : null"
3429
+ [smzToastEnter]="enterOffset()"
3430
+ (keydown.escape)="close(message)"
3431
+ (pointerdown)="onPointerDown($event, message)"
3432
+ (pointermove)="onPointerMove($event)"
3433
+ (pointerup)="onPointerUp($event, message)"
3434
+ (pointercancel)="onPointerUp($event, message)"
3435
+ >
3436
+ @if (message.loading) {
3437
+ <span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center text-ui-fg-muted" data-part="icon">
3438
+ <svg viewBox="0 0 24 24" class="h-[22px] w-[22px] animate-spin" fill="none" aria-hidden="true">
3439
+ <circle cx="12" cy="12" r="9" stroke="currentColor" stroke-opacity="0.25" stroke-width="3" />
3440
+ <path d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" stroke-width="3" stroke-linecap="round" />
3441
+ </svg>
3442
+ </span>
2664
3443
  }
2665
- @if (message.detail) {
2666
- <div class="text-ui-sm">{{ message.detail }}</div>
3444
+ @else {
3445
+ <span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-full" data-part="icon" [class]="tone(message).solid">
3446
+ @if (message.icon) {
3447
+ <i class="text-[14px] leading-none" [class]="message.icon" aria-hidden="true"></i>
3448
+ }
3449
+ @else {
3450
+ <svg viewBox="0 0 16 16" class="h-4 w-4" fill="none" aria-hidden="true">
3451
+ @switch (iconOf(message)) {
3452
+ @case ('success') {
3453
+ <path d="M3.5 8.5l3 3 6-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
3454
+ }
3455
+ @case ('warning') {
3456
+ <path d="M8 3.8v5" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
3457
+ <circle cx="8" cy="11.8" r="1.15" fill="currentColor" />
3458
+ }
3459
+ @case ('danger') {
3460
+ <path d="M4.5 4.5l7 7M11.5 4.5l-7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
3461
+ }
3462
+ @default {
3463
+ <path d="M8 7.2v4.3" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
3464
+ <circle cx="8" cy="4.3" r="1.15" fill="currentColor" />
3465
+ }
3466
+ }
3467
+ </svg>
3468
+ }
3469
+ </span>
3470
+ }
3471
+
3472
+ <div class="flex min-w-0 flex-1 flex-col gap-px self-center" [ngClass]="message.contentStyleClass">
3473
+ @if (message.summary) {
3474
+ <div class="flex items-center gap-2 text-ui-md font-semibold" data-part="summary">
3475
+ <span class="min-w-0 [overflow-wrap:anywhere]">{{ message.summary }}</span>
3476
+ @if ((message.count ?? 1) > 1) {
3477
+ <span data-part="count" [class]="countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
3478
+ }
3479
+ </div>
3480
+ }
3481
+ @if (message.detail) {
3482
+ <div class="text-ui-sm [overflow-wrap:anywhere]" data-part="detail" [class]="message.summary ? 'text-ui-fg-muted' : 'text-ui-fg'">
3483
+ {{ message.detail }}
3484
+ @if (!message.summary && (message.count ?? 1) > 1) {
3485
+ <span data-part="count" [class]="'ml-1 ' + countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
3486
+ }
3487
+ </div>
3488
+ }
3489
+ @if (message.action; as action) {
3490
+ <button
3491
+ type="button"
3492
+ 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
3493
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
3494
+ data-part="action"
3495
+ [class]="tone(message).action"
3496
+ (click)="runAction(message)"
3497
+ >{{ action.label }}</button>
3498
+ }
3499
+ </div>
3500
+
3501
+ @if (message.closable !== false) {
3502
+ <button
3503
+ type="button"
3504
+ 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
3505
+ hover:bg-ui-fg/10 hover:text-ui-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
3506
+ aria-label="Fechar"
3507
+ (click)="close(message)"
3508
+ >
3509
+ @if (message.closeIcon) {
3510
+ <i [class]="message.closeIcon" aria-hidden="true"></i>
3511
+ }
3512
+ @else {
3513
+ <svg viewBox="0 0 16 16" class="h-3.5 w-3.5" fill="none" aria-hidden="true">
3514
+ <path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
3515
+ </svg>
3516
+ }
3517
+ </button>
3518
+ }
3519
+
3520
+ @if (hasLife(message)) {
3521
+ <!-- Sempre presente quando ha tempo de vida: com showProgress=false fica invisivel, mas continua sendo o relogio. -->
3522
+ <div
3523
+ class="absolute inset-x-0 bottom-0 transition-[height] duration-ui"
3524
+ aria-hidden="true"
3525
+ data-part="progress"
3526
+ [class]="tone(message).track"
3527
+ [class.opacity-0]="!showsProgress(message)"
3528
+ [style.height.px]="isPaused(message) ? 5 : 3"
3529
+ >
3530
+ <div
3531
+ class="h-full origin-left"
3532
+ data-part="progress-bar"
3533
+ [class]="tone(message).fill"
3534
+ [smzToastLife]="lifeOf(message)"
3535
+ [paused]="isPaused(message)"
3536
+ [revision]="message.revision ?? 0"
3537
+ (expired)="close(message)"
3538
+ ></div>
3539
+ </div>
2667
3540
  }
2668
3541
  </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
3542
  </div>
2683
3543
  }
2684
3544
  </div>
2685
3545
  </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 });
3546
+ `, 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
3547
  }
2688
3548
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzToastContainerComponent, decorators: [{
2689
3549
  type: Component,
2690
3550
  args: [{
2691
3551
  selector: 'ui-toast',
2692
3552
  changeDetection: ChangeDetectionStrategy.OnPush,
2693
- imports: [NgClass, NgStyle],
3553
+ imports: [NgClass, NgStyle, SmzToastLifeDirective, SmzToastEnterDirective],
2694
3554
  template: `
2695
3555
  <!-- Camada na top layer (Popover API): overlays do CDK (drawer/dialog) ficam la e z-index nao os supera. -->
2696
3556
  <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
3557
  <div
2698
- class="pointer-events-none fixed z-[2000] flex w-80 max-w-[95vw] flex-col gap-2"
3558
+ #stack
3559
+ class="pointer-events-none fixed z-[2000] flex w-96 max-w-[95vw] flex-col"
2699
3560
  [class]="positionClasses()"
2700
3561
  [ngClass]="styleClass()"
2701
3562
  [ngStyle]="style()"
3563
+ [attr.data-paused]="hovered() || focused() || hidden()"
3564
+ (mouseenter)="hovered.set(true)"
3565
+ (mouseleave)="hovered.set(false)"
3566
+ (focusin)="focused.set(true)"
3567
+ (focusout)="onFocusOut($event)"
2702
3568
  >
2703
- @for (message of visibleMessages(); track message.id) {
2704
- <div
2705
- role="alert"
2706
- aria-live="assertive"
2707
- class="pointer-events-auto flex items-start gap-3 rounded-overlay border border-l-4 bg-ui-surface-2 px-4 py-3 font-ui text-ui-fg shadow-overlay"
2708
- [class]="toneClasses(message)"
2709
- [ngClass]="message.styleClass"
2710
- (mouseenter)="pause(message)"
2711
- (mouseleave)="resume(message)"
2712
- >
2713
- @if (message.icon) {
2714
- <i [class]="message.icon" aria-hidden="true"></i>
2715
- }
2716
- <div class="min-w-0 flex-1" [ngClass]="message.contentStyleClass">
2717
- @if (message.summary) {
2718
- <div class="text-ui-md font-medium">{{ message.summary }}</div>
3569
+ @for (message of shownMessages(); track message.id) {
3570
+ <!-- O espaco entre toasts e padding do slot (nao gap): o mouse atravessa a pilha sem "sair" dela. -->
3571
+ <div class="pointer-events-auto w-full pb-2" data-part="slot" [attr.data-toast-id]="message.id">
3572
+ <div
3573
+ 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)]"
3574
+ [class]="tone(message).card"
3575
+ [ngClass]="message.styleClass"
3576
+ [style.padding-bottom.px]="hasLife(message) ? 15 : null"
3577
+ [attr.role]="isAssertive(message) ? 'alert' : 'status'"
3578
+ [attr.aria-live]="isAssertive(message) ? 'assertive' : 'polite'"
3579
+ aria-atomic="true"
3580
+ [attr.data-severity]="message.severity ?? 'info'"
3581
+ [attr.data-loading]="message.loading ? 'true' : null"
3582
+ [smzToastEnter]="enterOffset()"
3583
+ (keydown.escape)="close(message)"
3584
+ (pointerdown)="onPointerDown($event, message)"
3585
+ (pointermove)="onPointerMove($event)"
3586
+ (pointerup)="onPointerUp($event, message)"
3587
+ (pointercancel)="onPointerUp($event, message)"
3588
+ >
3589
+ @if (message.loading) {
3590
+ <span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center text-ui-fg-muted" data-part="icon">
3591
+ <svg viewBox="0 0 24 24" class="h-[22px] w-[22px] animate-spin" fill="none" aria-hidden="true">
3592
+ <circle cx="12" cy="12" r="9" stroke="currentColor" stroke-opacity="0.25" stroke-width="3" />
3593
+ <path d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" stroke-width="3" stroke-linecap="round" />
3594
+ </svg>
3595
+ </span>
2719
3596
  }
2720
- @if (message.detail) {
2721
- <div class="text-ui-sm">{{ message.detail }}</div>
3597
+ @else {
3598
+ <span class="inline-flex h-[30px] w-[30px] shrink-0 items-center justify-center rounded-full" data-part="icon" [class]="tone(message).solid">
3599
+ @if (message.icon) {
3600
+ <i class="text-[14px] leading-none" [class]="message.icon" aria-hidden="true"></i>
3601
+ }
3602
+ @else {
3603
+ <svg viewBox="0 0 16 16" class="h-4 w-4" fill="none" aria-hidden="true">
3604
+ @switch (iconOf(message)) {
3605
+ @case ('success') {
3606
+ <path d="M3.5 8.5l3 3 6-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
3607
+ }
3608
+ @case ('warning') {
3609
+ <path d="M8 3.8v5" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
3610
+ <circle cx="8" cy="11.8" r="1.15" fill="currentColor" />
3611
+ }
3612
+ @case ('danger') {
3613
+ <path d="M4.5 4.5l7 7M11.5 4.5l-7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
3614
+ }
3615
+ @default {
3616
+ <path d="M8 7.2v4.3" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
3617
+ <circle cx="8" cy="4.3" r="1.15" fill="currentColor" />
3618
+ }
3619
+ }
3620
+ </svg>
3621
+ }
3622
+ </span>
3623
+ }
3624
+
3625
+ <div class="flex min-w-0 flex-1 flex-col gap-px self-center" [ngClass]="message.contentStyleClass">
3626
+ @if (message.summary) {
3627
+ <div class="flex items-center gap-2 text-ui-md font-semibold" data-part="summary">
3628
+ <span class="min-w-0 [overflow-wrap:anywhere]">{{ message.summary }}</span>
3629
+ @if ((message.count ?? 1) > 1) {
3630
+ <span data-part="count" [class]="countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
3631
+ }
3632
+ </div>
3633
+ }
3634
+ @if (message.detail) {
3635
+ <div class="text-ui-sm [overflow-wrap:anywhere]" data-part="detail" [class]="message.summary ? 'text-ui-fg-muted' : 'text-ui-fg'">
3636
+ {{ message.detail }}
3637
+ @if (!message.summary && (message.count ?? 1) > 1) {
3638
+ <span data-part="count" [class]="'ml-1 ' + countClasses(message)" [attr.aria-label]="message.count + ' vezes'">×{{ message.count }}</span>
3639
+ }
3640
+ </div>
3641
+ }
3642
+ @if (message.action; as action) {
3643
+ <button
3644
+ type="button"
3645
+ 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
3646
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
3647
+ data-part="action"
3648
+ [class]="tone(message).action"
3649
+ (click)="runAction(message)"
3650
+ >{{ action.label }}</button>
3651
+ }
3652
+ </div>
3653
+
3654
+ @if (message.closable !== false) {
3655
+ <button
3656
+ type="button"
3657
+ 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
3658
+ hover:bg-ui-fg/10 hover:text-ui-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ui-focus"
3659
+ aria-label="Fechar"
3660
+ (click)="close(message)"
3661
+ >
3662
+ @if (message.closeIcon) {
3663
+ <i [class]="message.closeIcon" aria-hidden="true"></i>
3664
+ }
3665
+ @else {
3666
+ <svg viewBox="0 0 16 16" class="h-3.5 w-3.5" fill="none" aria-hidden="true">
3667
+ <path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" />
3668
+ </svg>
3669
+ }
3670
+ </button>
3671
+ }
3672
+
3673
+ @if (hasLife(message)) {
3674
+ <!-- Sempre presente quando ha tempo de vida: com showProgress=false fica invisivel, mas continua sendo o relogio. -->
3675
+ <div
3676
+ class="absolute inset-x-0 bottom-0 transition-[height] duration-ui"
3677
+ aria-hidden="true"
3678
+ data-part="progress"
3679
+ [class]="tone(message).track"
3680
+ [class.opacity-0]="!showsProgress(message)"
3681
+ [style.height.px]="isPaused(message) ? 5 : 3"
3682
+ >
3683
+ <div
3684
+ class="h-full origin-left"
3685
+ data-part="progress-bar"
3686
+ [class]="tone(message).fill"
3687
+ [smzToastLife]="lifeOf(message)"
3688
+ [paused]="isPaused(message)"
3689
+ [revision]="message.revision ?? 0"
3690
+ (expired)="close(message)"
3691
+ ></div>
3692
+ </div>
2722
3693
  }
2723
3694
  </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
3695
  </div>
2738
3696
  }
2739
3697
  </div>
2740
3698
  </div>
2741
3699
  `,
2742
3700
  }]
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 }] }] } });
3701
+ }], 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
3702
 
2745
3703
  /* eslint-disable max-len -- classes Tailwind nos templates */
2746
3704
  const POSITIONS$1 = [
@@ -2826,6 +3784,7 @@ class SmzMenuListComponent {
2826
3784
  });
2827
3785
  if (this.autoZIndex())
2828
3786
  SmzZIndex.set('menu', this.overlayRef.hostElement, 1000 + this.baseZIndex());
3787
+ smzInheritThemeScope(this.overlayRef, origin ?? this.host.nativeElement);
2829
3788
  merge(this.overlayRef.outsidePointerEvents().pipe(filter((outside) => !this.origin?.contains(outside.target))), this.overlayRef.keydownEvents().pipe(filter((key) => key.key === 'Escape'))).subscribe(() => this.hide());
2830
3789
  this.overlayRef.attach(new TemplatePortal(this.list(), this.viewContainer));
2831
3790
  this.shown.emit();
@@ -2927,7 +3886,7 @@ class SmzMenuListComponent {
2927
3886
  @if (!popup()) {
2928
3887
  <ng-container [ngTemplateOutlet]="list" />
2929
3888
  }
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 });
3889
+ `, 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
3890
  }
2932
3891
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzMenuListComponent, decorators: [{
2933
3892
  type: Component,
@@ -3172,6 +4131,7 @@ class SmzAnchoredPanel {
3172
4131
  minWidth: options.matchWidth ? anchor.getBoundingClientRect().width : undefined,
3173
4132
  });
3174
4133
  SmzZIndex.set('overlay', this.overlayRef.hostElement, 1000);
4134
+ smzInheritThemeScope(this.overlayRef, anchor);
3175
4135
  const dismiss = () => {
3176
4136
  this.close();
3177
4137
  options.onDismiss?.();
@@ -8380,22 +9340,606 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
8380
9340
  }]
8381
9341
  }], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], selectionMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionMode", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], filterPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterPlaceholder", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], showClear: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClear", required: false }] }], scrollHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollHeight", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }], containerStyleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "containerStyleClass", required: false }] }], appendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "appendTo", required: false }] }], display: [{ type: i0.Input, args: [{ isSignal: true, alias: "display", required: false }] }], filterInputAutoFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterInputAutoFocus", required: false }] }], templates: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => SmzTemplateDirective), { isSignal: true }] }], trigger: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }], panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }] } });
8382
9342
 
8383
- const hexToChannels = (hex) => {
8384
- const value = hex.replace('#', '');
8385
- const full = value.length === 3 ? value.split('').map((c) => c + c).join('') : value;
8386
- const n = parseInt(full, 16);
8387
- return `${Math.floor(n / 65536) % 256} ${Math.floor(n / 256) % 256} ${n % 256}`;
9343
+ const NAMED = { white: '#ffffff', black: '#000000' };
9344
+ const clamp = (value, max) => Math.min(max, Math.max(0, value));
9345
+ const channel = (raw) => (raw.endsWith('%') ? (parseFloat(raw) / 100) * 255 : parseFloat(raw));
9346
+ const alpha = (raw) => {
9347
+ if (raw == null || raw === '')
9348
+ return 1;
9349
+ return clamp(raw.endsWith('%') ? parseFloat(raw) / 100 : parseFloat(raw), 1);
9350
+ };
9351
+ /**
9352
+ * Lê uma cor literal sRGB: hexadecimal (3, 4, 6 ou 8 dígitos), `rgb()`/`rgba()` (vírgula ou espaço) e canais soltos
9353
+ * (`37 99 235`). Devolve `null` para o que só o navegador resolve (`var()`, `color-mix()`, `oklch()`, nomes).
9354
+ */
9355
+ function smzParseColor(input) {
9356
+ const value = (NAMED[input.trim().toLowerCase()] ?? input).trim();
9357
+ const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(value);
9358
+ if (hex) {
9359
+ const digits = hex[1].length <= 4 ? hex[1].split('').map((digit) => digit + digit).join('') : hex[1];
9360
+ const number = parseInt(digits.slice(0, 6), 16);
9361
+ return {
9362
+ r: Math.floor(number / 65536) % 256,
9363
+ g: Math.floor(number / 256) % 256,
9364
+ b: number % 256,
9365
+ a: digits.length === 8 ? parseInt(digits.slice(6), 16) / 255 : 1,
9366
+ };
9367
+ }
9368
+ const fn = /^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i.exec(value);
9369
+ const bare = fn ?? /^([\d.]+)\s+([\d.]+)\s+([\d.]+)$/.exec(value);
9370
+ if (bare) {
9371
+ return {
9372
+ r: clamp(Math.round(channel(bare[1])), 255),
9373
+ g: clamp(Math.round(channel(bare[2])), 255),
9374
+ b: clamp(Math.round(channel(bare[3])), 255),
9375
+ a: alpha(bare[4]),
9376
+ };
9377
+ }
9378
+ return null;
9379
+ }
9380
+ /** Canais RGB separados por espaço (`37 99 235`), o formato das variáveis legadas `--smz-color-*`. */
9381
+ function smzToChannels(color) {
9382
+ return `${color.r} ${color.g} ${color.b}`;
9383
+ }
9384
+ const linear = (value) => {
9385
+ const unit = value / 255;
9386
+ return unit <= 0.04045 ? unit / 12.92 : ((unit + 0.055) / 1.055) ** 2.4;
9387
+ };
9388
+ /** Luminância relativa (WCAG 2.x). */
9389
+ function smzLuminance(color) {
9390
+ return 0.2126 * linear(color.r) + 0.7152 * linear(color.g) + 0.0722 * linear(color.b);
9391
+ }
9392
+ /** Compõe uma cor com alfa sobre um fundo opaco. */
9393
+ function smzComposite(foreground, background) {
9394
+ const mix = (front, back) => Math.round(front * foreground.a + back * (1 - foreground.a));
9395
+ return { r: mix(foreground.r, background.r), g: mix(foreground.g, background.g), b: mix(foreground.b, background.b), a: 1 };
9396
+ }
9397
+ /** Razão de contraste WCAG entre texto e fundo (de 1 a 21). O texto com alfa é composto sobre o fundo. */
9398
+ function smzContrastRatio(foreground, background) {
9399
+ const front = smzLuminance(foreground.a < 1 ? smzComposite(foreground, background) : foreground);
9400
+ const back = smzLuminance(background);
9401
+ const [lighter, darker] = front >= back ? [front, back] : [back, front];
9402
+ return (lighter + 0.05) / (darker + 0.05);
9403
+ }
9404
+ /** Mínimo WCAG AA para texto normal. */
9405
+ const SMZ_CONTRAST_AA = 4.5;
9406
+
9407
+ /**
9408
+ * Camada de componente: cada parte e estado de cada componente, um arquivo por componente neste diretório.
9409
+ * O padrão de todo token daqui é uma referência a um token semântico.
9410
+ */
9411
+ const SMZ_COMPONENT_TOKENS = {};
9412
+
9413
+ /**
9414
+ * Modelo do catálogo de tokens do Design System SMZ.
9415
+ *
9416
+ * Este diretório é dado puro, sem dependência de Angular nem de DOM: é lido pelo motor de tema em runtime e,
9417
+ * em Node, pelo gerador (`scripts/build-design-tokens.mjs`) que produz o CSS padrão, as entradas do preset
9418
+ * Tailwind, o catálogo JSON, o JSON Schema e os tipos do arquivo de tema.
9419
+ */
9420
+ function smzIsTokenDefinition(node) {
9421
+ return typeof node.$type === 'string' && '$value' in node;
9422
+ }
9423
+ /** Atalho para declarar um token: `token('color', '{blue.600}', 'Cor primária')`. */
9424
+ function token($type, $value, $description, extras = {}) {
9425
+ return { $type, $value, $description, ...extras };
9426
+ }
9427
+
9428
+ const SHADES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
9429
+ const palette = (name, hex) => Object.fromEntries(SHADES.map((shade, index) => [String(shade), token('color', `#${hex[index]}`, `${name} ${shade}`)]));
9430
+ /**
9431
+ * Camada primitiva: paletas e escalas brutas, sem papel. Não variam por modo e não viram variável CSS;
9432
+ * existem para os semânticos (e os temas dos apps) referenciarem: `'{blue.600}'`.
9433
+ */
9434
+ const SMZ_PRIMITIVE_TOKENS = {
9435
+ white: token('color', '#ffffff', 'Branco'),
9436
+ black: token('color', '#000000', 'Preto'),
9437
+ slate: palette('Slate', ['f8fafc', 'f1f5f9', 'e2e8f0', 'cbd5e1', '94a3b8', '64748b', '475569', '334155', '1e293b', '0f172a', '020617']),
9438
+ gray: palette('Gray', ['f9fafb', 'f3f4f6', 'e5e7eb', 'd1d5db', '9ca3af', '6b7280', '4b5563', '374151', '1f2937', '111827', '030712']),
9439
+ blue: palette('Blue', ['eff6ff', 'dbeafe', 'bfdbfe', '93c5fd', '60a5fa', '3b82f6', '2563eb', '1d4ed8', '1e40af', '1e3a8a', '172554']),
9440
+ red: palette('Red', ['fef2f2', 'fee2e2', 'fecaca', 'fca5a5', 'f87171', 'ef4444', 'dc2626', 'b91c1c', '991b1b', '7f1d1d', '450a0a']),
9441
+ green: palette('Green', ['f0fdf4', 'dcfce7', 'bbf7d0', '86efac', '4ade80', '22c55e', '16a34a', '15803d', '166534', '14532d', '052e16']),
9442
+ amber: palette('Amber', ['fffbeb', 'fef3c7', 'fde68a', 'fcd34d', 'fbbf24', 'f59e0b', 'd97706', 'b45309', '92400e', '78350f', '451a03']),
9443
+ };
9444
+
9445
+ /**
9446
+ * Cor semântica. `name` é o sufixo histórico (`primary-hover`): dele saem a variável de cor (`--smz-primary-hover`),
9447
+ * a variável legada em canais (`--smz-color-primary-hover`) e o utilitário Tailwind (`bg-ui-primary-hover`).
9448
+ */
9449
+ const color = (name, value, description, contrast) => token('color', value, description, {
9450
+ $cssVar: `--smz-${name}`,
9451
+ $legacyChannels: `--smz-color-${name}`,
9452
+ $utilities: [{ key: 'colors', name: `ui-${name}` }],
9453
+ ...(contrast ? { $contrast: contrast } : {}),
9454
+ });
9455
+ const severity = (name, label, base, hover, active, contrast) => ({
9456
+ default: color(name, base, `Cor ${label}: fundo de botão sólido, texto e borda de destaque.`),
9457
+ hover: color(`${name}-hover`, hover, `Cor ${label} sob o ponteiro.`),
9458
+ active: color(`${name}-active`, active, `Cor ${label} pressionada.`),
9459
+ contrast: color(`on-${name}`, contrast, `Texto e ícone sobre a cor ${label}.`, `color.${name}.default`),
9460
+ });
9461
+ const same = (value) => ({ light: value, dark: value });
9462
+ const utility = (key, name) => ({ key, name });
9463
+ /**
9464
+ * Camada semântica: papéis. São os `--smz-*` anteriores ao contrato, com os mesmos nomes e valores.
9465
+ *
9466
+ * Cores: o token é a cor completa (`--smz-primary`, qualquer valor CSS). A variável antiga em canais
9467
+ * (`--smz-color-primary: 37 99 235`) continua existindo como alias e como entrada de temas antigos.
9468
+ */
9469
+ const SMZ_SEMANTIC_TOKENS = {
9470
+ color: {
9471
+ primary: severity('primary', 'primária', { light: '{blue.600}', dark: '{blue.400}' }, { light: '{blue.700}', dark: '{blue.300}' }, { light: '{blue.800}', dark: '{blue.200}' }, { light: '{white}', dark: '{slate.900}' }),
9472
+ danger: severity('danger', 'de perigo', same('{red.600}'), same('{red.700}'), same('{red.800}'), same('{white}')),
9473
+ success: severity('success', 'de sucesso', same('{green.600}'), same('{green.700}'), same('{green.800}'), same('{white}')),
9474
+ warning: severity('warning', 'de alerta', same('{amber.500}'), same('{amber.600}'), same('{amber.700}'), same('{gray.800}')),
9475
+ surface: {
9476
+ 0: color('surface-0', { light: '{slate.50}', dark: '{slate.950}' }, 'Fundo da página.'),
9477
+ 1: color('surface-1', { light: '{white}', dark: '{slate.900}' }, 'Fundo de cartões e de campos de formulário.'),
9478
+ 2: color('surface-2', { light: '{white}', dark: '{slate.800}' }, 'Fundo de overlays: painéis, menus, diálogos.'),
9479
+ 3: color('surface-3', { light: '{slate.100}', dark: '{slate.700}' }, 'Fundo de item sob o ponteiro e de áreas rebaixadas.'),
9480
+ },
9481
+ fg: {
9482
+ default: color('fg', { light: '{slate.900}', dark: '{slate.100}' }, 'Texto principal.', 'color.surface.1'),
9483
+ muted: color('fg-muted', { light: '{slate.600}', dark: '{slate.300}' }, 'Texto secundário.', 'color.surface.1'),
9484
+ subtle: color('fg-subtle', same('{slate.400}'), 'Texto de apoio e placeholder.'),
9485
+ },
9486
+ line: {
9487
+ default: color('line', { light: '{slate.200}', dark: '{slate.700}' }, 'Borda e divisor.'),
9488
+ strong: color('line-strong', { light: '{slate.300}', dark: '{slate.600}' }, 'Borda de campo de formulário.'),
9489
+ },
9490
+ focus: color('focus', { light: '{blue.600}', dark: '{blue.400}' }, 'Anel de foco.'),
9491
+ },
9492
+ font: {
9493
+ sans: token('fontFamily', 'system-ui, -apple-system, \'Segoe UI\', Roboto, sans-serif', 'Família de fonte da interface.', {
9494
+ $cssVar: '--smz-font-sans', $utilities: [utility('fontFamily', 'ui')],
9495
+ }),
9496
+ mono: token('fontFamily', 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace', 'Família de fonte monoespaçada.', {
9497
+ $cssVar: '--smz-font-mono', $utilities: [utility('fontFamily', 'ui-mono')],
9498
+ }),
9499
+ },
9500
+ text: {
9501
+ xs: token('dimension', '0.75rem', 'Tamanho de fonte extra pequeno.', { $cssVar: '--smz-text-xs' }),
9502
+ sm: token('dimension', '0.8125rem', 'Tamanho de fonte pequeno.', { $cssVar: '--smz-text-sm' }),
9503
+ md: token('dimension', '0.875rem', 'Tamanho de fonte padrão.', { $cssVar: '--smz-text-md' }),
9504
+ lg: token('dimension', '1rem', 'Tamanho de fonte grande.', { $cssVar: '--smz-text-lg' }),
9505
+ xl: token('dimension', '1.125rem', 'Tamanho de fonte extra grande.', { $cssVar: '--smz-text-xl' }),
9506
+ leading: token('number', '1.5', 'Altura de linha.', { $cssVar: '--smz-leading' }),
9507
+ },
9508
+ control: {
9509
+ height: {
9510
+ sm: token('dimension', '2rem', 'Altura de controle pequeno (botão, campo).', {
9511
+ $cssVar: '--smz-control-h-sm', $density: { compact: '1.75rem', comfortable: '2.5rem' },
9512
+ $utilities: [utility('height', 'control-sm'), utility('minHeight', 'control-sm')],
9513
+ }),
9514
+ md: token('dimension', '2.5rem', 'Altura de controle padrão.', {
9515
+ $cssVar: '--smz-control-h', $density: { compact: '2rem', comfortable: '3rem' },
9516
+ $utilities: [utility('height', 'control'), utility('minHeight', 'control')],
9517
+ }),
9518
+ lg: token('dimension', '3rem', 'Altura de controle grande.', {
9519
+ $cssVar: '--smz-control-h-lg', $density: { compact: '2.5rem', comfortable: '3.5rem' },
9520
+ $utilities: [utility('height', 'control-lg'), utility('minHeight', 'control-lg')],
9521
+ }),
9522
+ },
9523
+ paddingX: {
9524
+ sm: token('dimension', '0.75rem', 'Padding horizontal de controle pequeno.', {
9525
+ $cssVar: '--smz-control-px-sm', $utilities: [utility('padding', 'control-x-sm')],
9526
+ }),
9527
+ md: token('dimension', '1rem', 'Padding horizontal de controle padrão.', {
9528
+ $cssVar: '--smz-control-px', $density: { compact: '0.75rem', comfortable: '1.25rem' },
9529
+ $utilities: [utility('padding', 'control-x')],
9530
+ }),
9531
+ lg: token('dimension', '1.5rem', 'Padding horizontal de controle grande.', {
9532
+ $cssVar: '--smz-control-px-lg', $utilities: [utility('padding', 'control-x-lg')],
9533
+ }),
9534
+ },
9535
+ },
9536
+ input: {
9537
+ paddingX: {
9538
+ sm: token('dimension', '{control.paddingX.sm}', 'Padding horizontal de campo de formulário pequeno.', {
9539
+ $cssVar: '--smz-input-px-sm', $utilities: [utility('padding', 'input-x-sm')],
9540
+ }),
9541
+ md: token('dimension', '{control.paddingX.md}', 'Padding horizontal de campo de formulário.', {
9542
+ $cssVar: '--smz-input-px', $utilities: [utility('padding', 'input-x')],
9543
+ }),
9544
+ },
9545
+ },
9546
+ radius: {
9547
+ control: token('dimension', '0.5rem', 'Raio de controles: botão, campo, item de lista.', {
9548
+ $cssVar: '--smz-radius-control', $utilities: [utility('borderRadius', 'control'), utility('borderRadius', 'border')],
9549
+ }),
9550
+ card: token('dimension', '0.75rem', 'Raio de cartões e painéis.', {
9551
+ $cssVar: '--smz-radius-card', $utilities: [utility('borderRadius', 'card')],
9552
+ }),
9553
+ overlay: token('dimension', '0.75rem', 'Raio de overlays: painel de select, menu, diálogo.', {
9554
+ $cssVar: '--smz-radius-overlay', $utilities: [utility('borderRadius', 'overlay')],
9555
+ }),
9556
+ },
9557
+ shadow: {
9558
+ card: token('shadow', '0 1px 2px rgb(0 0 0 / 0.06), 0 1px 3px rgb(0 0 0 / 0.1)', 'Sombra de cartão.', {
9559
+ $cssVar: '--smz-shadow-card', $utilities: [utility('boxShadow', 'card')],
9560
+ }),
9561
+ overlay: token('shadow', '0 8px 24px rgb(0 0 0 / 0.12), 0 2px 6px rgb(0 0 0 / 0.08)', 'Sombra de overlay.', {
9562
+ $cssVar: '--smz-shadow-overlay', $utilities: [utility('boxShadow', 'overlay')],
9563
+ }),
9564
+ },
9565
+ duration: {
9566
+ default: token('duration', '150ms', 'Duração das transições de estado.', {
9567
+ $cssVar: '--smz-duration', $utilities: [utility('transitionDuration', 'ui')],
9568
+ }),
9569
+ },
9570
+ };
9571
+
9572
+ /** Catálogo de tokens do Design System SMZ: fonte única do tema, do preset Tailwind, da documentação e do editor. */
9573
+ const SMZ_TOKEN_CATALOG = {
9574
+ primitive: SMZ_PRIMITIVE_TOKENS,
9575
+ semantic: SMZ_SEMANTIC_TOKENS,
9576
+ components: SMZ_COMPONENT_TOKENS,
8388
9577
  };
9578
+ const LAYERS = [
9579
+ ['primitive', 'primitive'],
9580
+ ['semantic', 'semantic'],
9581
+ ['components', 'component'],
9582
+ ];
9583
+ /** `select.option.selected.background` -> `--smz-select-option-selected-background` (o segmento `default` some). */
9584
+ function smzTokenCssVar(path) {
9585
+ const kebab = path
9586
+ .split('.')
9587
+ .filter((segment) => segment !== 'default')
9588
+ .map((segment) => segment.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())
9589
+ .join('-');
9590
+ return `--smz-${kebab}`;
9591
+ }
9592
+ function flatten(group, layer, prefix, out) {
9593
+ for (const [key, node] of Object.entries(group)) {
9594
+ const path = prefix === '' ? key : `${prefix}.${key}`;
9595
+ if (smzIsTokenDefinition(node)) {
9596
+ const definition = node;
9597
+ out.push({ ...definition, path, layer, cssVar: definition.$cssVar ?? smzTokenCssVar(path) });
9598
+ }
9599
+ else {
9600
+ flatten(node, layer, path, out);
9601
+ }
9602
+ }
9603
+ }
9604
+ function build() {
9605
+ const out = [];
9606
+ for (const [key, layer] of LAYERS)
9607
+ flatten(SMZ_TOKEN_CATALOG[key], layer, '', out);
9608
+ return out;
9609
+ }
9610
+ /** Todos os tokens, achatados, na ordem primitivo, semântico, componente. */
9611
+ const SMZ_TOKENS = build();
9612
+ const BY_PATH = new Map(SMZ_TOKENS.map((item) => [item.path, item]));
9613
+ function smzFindToken(path) {
9614
+ return BY_PATH.get(path);
9615
+ }
9616
+
9617
+ const SMZ_THEME_MODES = ['light', 'dark'];
9618
+
9619
+ const REFERENCE$1 = /\{([^{}]+)\}/g;
9620
+ /** Caminhos referenciados por um valor: `'color-mix(in srgb, {color.primary.default} 10%, transparent)'`. */
9621
+ function smzTokenReferences(value) {
9622
+ return Array.from(value.matchAll(REFERENCE$1), (match) => match[1]);
9623
+ }
9624
+ const MODE_KEYS = new Set(SMZ_THEME_MODES);
9625
+ function collect(tree, layer, prefix, modes, into, problems) {
9626
+ for (const [key, node] of Object.entries(tree ?? {})) {
9627
+ if (prefix === '' && MODE_KEYS.has(key)) {
9628
+ collect(node, layer, '', [key], into, problems);
9629
+ continue;
9630
+ }
9631
+ const path = prefix === '' ? key : `${prefix}.${key}`;
9632
+ if (node != null && typeof node === 'object') {
9633
+ collect(node, layer, path, modes, into, problems);
9634
+ continue;
9635
+ }
9636
+ if (node == null)
9637
+ continue;
9638
+ const target = smzFindToken(path);
9639
+ if (target == null || target.layer !== layer) {
9640
+ problems.push(`token desconhecido na camada ${layer}: "${path}"`);
9641
+ continue;
9642
+ }
9643
+ const value = String(node);
9644
+ const entry = (into[path] ??= {});
9645
+ for (const mode of modes)
9646
+ entry[mode] = value;
9647
+ }
9648
+ }
9649
+ function checkReferences(overrides, problems) {
9650
+ const layerOrder = { primitive: 0, semantic: 1, component: 2 };
9651
+ for (const [path, override] of Object.entries(overrides)) {
9652
+ const owner = smzFindToken(path);
9653
+ if (owner == null)
9654
+ continue;
9655
+ for (const value of Object.values(override)) {
9656
+ for (const reference of smzTokenReferences(value ?? '')) {
9657
+ const target = smzFindToken(reference);
9658
+ if (target == null)
9659
+ problems.push(`"${path}" referencia um token que não existe: "{${reference}}"`);
9660
+ else if (layerOrder[target.layer] > layerOrder[owner.layer])
9661
+ problems.push(`"${path}" (${owner.layer}) não pode referenciar "{${reference}}" (${target.layer})`);
9662
+ else if (reference === path)
9663
+ problems.push(`"${path}" referencia a si mesmo`);
9664
+ }
9665
+ }
9666
+ }
9667
+ }
9668
+ function mergeDefaults(base, extra) {
9669
+ const out = { ...base };
9670
+ for (const [component, values] of Object.entries(extra ?? {}))
9671
+ out[component] = { ...(out[component] ?? {}), ...values };
9672
+ return out;
9673
+ }
9674
+ /** Tema sem nenhuma sobrescrita: o próprio catálogo, que é o preset padrão. */
9675
+ const SMZ_DEFAULT_THEME = Object.freeze({
9676
+ name: 'default',
9677
+ overrides: Object.freeze({}),
9678
+ base: Object.freeze({ rootFontSize: 16, scale: 1 }),
9679
+ density: 'normal',
9680
+ defaults: Object.freeze({}),
9681
+ });
9682
+ /**
9683
+ * Declara o tema de um app. Valida os caminhos e as referências contra o catálogo e devolve o tema achatado.
9684
+ *
9685
+ * ```ts
9686
+ * export const appTheme = defineSmzTheme({
9687
+ * semantic: { radius: { control: '0.25rem' }, dark: { color: { surface: { 0: '#17212f' } } } },
9688
+ * });
9689
+ * ```
9690
+ *
9691
+ * @throws se algum caminho ou referência não existir no catálogo.
9692
+ */
9693
+ function defineSmzTheme(definition) {
9694
+ const parent = definition.extends ?? SMZ_DEFAULT_THEME;
9695
+ const own = {};
9696
+ const problems = [];
9697
+ collect(definition.primitive, 'primitive', '', SMZ_THEME_MODES, own, problems);
9698
+ collect(definition.semantic, 'semantic', '', SMZ_THEME_MODES, own, problems);
9699
+ collect(definition.components, 'component', '', SMZ_THEME_MODES, own, problems);
9700
+ checkReferences(own, problems);
9701
+ if (problems.length > 0)
9702
+ throw new Error(`defineSmzTheme(${definition.name ?? 'tema'}): ${problems.join('; ')}`);
9703
+ const overrides = {};
9704
+ for (const [path, override] of Object.entries(parent.overrides))
9705
+ overrides[path] = { ...override };
9706
+ for (const [path, override] of Object.entries(own))
9707
+ overrides[path] = { ...(overrides[path] ?? {}), ...override };
9708
+ return Object.freeze({
9709
+ name: definition.name ?? parent.name,
9710
+ overrides: Object.freeze(overrides),
9711
+ base: Object.freeze({ ...parent.base, ...(definition.base ?? {}) }),
9712
+ density: definition.density ?? parent.density,
9713
+ defaults: Object.freeze(mergeDefaults(parent.defaults, definition.defaults)),
9714
+ });
9715
+ }
9716
+ /** Quantidade de tokens do catálogo, por camada (diagnóstico e documentação). */
9717
+ function smzCatalogSummary() {
9718
+ const summary = { primitive: 0, semantic: 0, component: 0 };
9719
+ for (const item of SMZ_TOKENS)
9720
+ summary[item.layer] += 1;
9721
+ return summary;
9722
+ }
9723
+
9724
+ const REFERENCE = /\{([^{}]+)\}/g;
9725
+ const MAX_DEPTH = 16;
9726
+ /** Valor bruto de um token em um tema e modo: a sobrescrita do tema, ou o padrão do catálogo. */
9727
+ function smzRawTokenValue(theme, item, mode) {
9728
+ const override = theme.overrides[item.path]?.[mode];
9729
+ if (override != null)
9730
+ return override;
9731
+ return typeof item.$value === 'string' ? item.$value : item.$value[mode];
9732
+ }
8389
9733
  /**
8390
- * Altera tokens do tema em tempo de execucao (cores sao canais RGB em `--smz-color-*`).
8391
- * O tema base vem do CSS (themes/*.css); este servico apenas sobrescreve variaveis no `<html>`.
9734
+ * Valor literal de um token, com todas as referências resolvidas estaticamente (inclusive as de semânticos).
9735
+ * Serve para o que precisa do valor final fora do navegador: canais legados e contraste.
9736
+ */
9737
+ function smzLiteralTokenValue(theme, path, mode, depth = 0) {
9738
+ const item = smzFindToken(path);
9739
+ if (item == null || depth > MAX_DEPTH)
9740
+ return '';
9741
+ return smzRawTokenValue(theme, item, mode).replace(REFERENCE, (_, reference) => smzLiteralTokenValue(theme, reference, mode, depth + 1));
9742
+ }
9743
+ /**
9744
+ * Valor CSS de um token: referência a primitivo vira o literal (primitivos não são variáveis CSS);
9745
+ * referência a semântico ou a componente vira `var(--…)`, para a cascata continuar valendo em runtime e em escopos.
9746
+ */
9747
+ function compile(theme, item, mode) {
9748
+ return smzRawTokenValue(theme, item, mode).replace(REFERENCE, (_, reference) => {
9749
+ const target = smzFindToken(reference);
9750
+ if (target == null)
9751
+ return '';
9752
+ return target.layer === 'primitive' ? smzLiteralTokenValue(theme, reference, mode) : `var(${target.cssVar})`;
9753
+ });
9754
+ }
9755
+ const REM = /(-?\d*\.?\d+)rem\b/g;
9756
+ function scaleDimension(value, factor) {
9757
+ if (factor === 1)
9758
+ return value;
9759
+ return value.replace(REM, (_, amount) => `${Number((parseFloat(amount) * factor).toFixed(5))}rem`);
9760
+ }
9761
+ /** Fator aplicado às dimensões em `rem`: raiz diferente de 16px e escala do tema. */
9762
+ function smzDimensionFactor(theme) {
9763
+ return (16 / theme.base.rootFontSize) * theme.base.scale;
9764
+ }
9765
+ /** O que cada variável CSS deve valer em cada modo para um tema. */
9766
+ function desired(theme) {
9767
+ const out = { light: {}, dark: {}, warnings: [] };
9768
+ const factor = smzDimensionFactor(theme);
9769
+ for (const item of SMZ_TOKENS) {
9770
+ if (item.layer === 'primitive')
9771
+ continue;
9772
+ for (const mode of SMZ_THEME_MODES) {
9773
+ const compiled = item.$type === 'dimension' ? scaleDimension(compile(theme, item, mode), factor) : compile(theme, item, mode);
9774
+ if (item.$legacyChannels == null) {
9775
+ out[mode][item.cssVar] = compiled;
9776
+ continue;
9777
+ }
9778
+ const literal = smzParseColor(smzLiteralTokenValue(theme, item.path, mode));
9779
+ if (literal != null)
9780
+ out[mode][item.$legacyChannels] = smzToChannels(literal);
9781
+ else if (theme.overrides[item.path]?.[mode] != null) {
9782
+ out.warnings.push(`${item.path} (${mode}): "${compiled}" não é uma cor literal, então o alias em canais ${item.$legacyChannels} mantém o valor anterior.`);
9783
+ }
9784
+ // Cor opaca e literal: o token segue a variável em canais, que temas antigos também definem.
9785
+ out[mode][item.cssVar] = literal != null && literal.a === 1 ? `rgb(var(${item.$legacyChannels}))` : compiled;
9786
+ }
9787
+ }
9788
+ return out;
9789
+ }
9790
+ function fullBlocks(theme) {
9791
+ const want = desired(theme);
9792
+ const dark = {};
9793
+ for (const [name, value] of Object.entries(want.dark))
9794
+ if (want.light[name] !== value)
9795
+ dark[name] = value;
9796
+ const density = {};
9797
+ const factor = smzDimensionFactor(theme);
9798
+ for (const item of SMZ_TOKENS) {
9799
+ for (const [level, value] of Object.entries(item.$density ?? {})) {
9800
+ (density[level] ??= {})[item.cssVar] = scaleDimension(value, factor);
9801
+ }
9802
+ }
9803
+ return { light: want.light, dark, density, warnings: want.warnings };
9804
+ }
9805
+ let defaultBlocks = null;
9806
+ /**
9807
+ * Blocos de CSS de um tema.
9808
+ *
9809
+ * Com `full`, todas as variáveis (é como o CSS do preset padrão é gerado). Sem `full`, só o que difere do preset
9810
+ * padrão, considerando a cascata: o bloco escuro do preset tem especificidade maior que o bloco base do tema,
9811
+ * então um valor que o tema define para os dois modos precisa ser repetido no bloco escuro.
9812
+ */
9813
+ function smzThemeCssBlocks(theme, options = {}) {
9814
+ if (options.full)
9815
+ return fullBlocks(theme);
9816
+ const base = (defaultBlocks ??= fullBlocks(SMZ_DEFAULT_THEME));
9817
+ const want = desired(theme);
9818
+ const light = {};
9819
+ const dark = {};
9820
+ for (const [name, value] of Object.entries(want.light))
9821
+ if (base.light[name] !== value)
9822
+ light[name] = value;
9823
+ for (const [name, value] of Object.entries(want.dark)) {
9824
+ const fallback = base.dark[name] ?? light[name] ?? base.light[name];
9825
+ if (fallback !== value)
9826
+ dark[name] = value;
9827
+ }
9828
+ const density = {};
9829
+ if (smzDimensionFactor(theme) !== 1)
9830
+ Object.assign(density, fullBlocks(theme).density);
9831
+ return { light, dark, density, warnings: want.warnings };
9832
+ }
9833
+ const VAR_REFERENCE = /var\((--[\w-]+)/g;
9834
+ /**
9835
+ * Em um escopo, uma variável declarada em `:root` com `var(--outra)` já chega resolvida ao contêiner: sobrescrever
9836
+ * `--outra` no escopo não a recalcula. Por isso o CSS de escopo redeclara também toda variável que depende,
9837
+ * direta ou indiretamente, de uma variável que o tema sobrescreve.
9838
+ */
9839
+ function withDependents(emitted, all) {
9840
+ const out = { ...emitted };
9841
+ for (let changed = true; changed;) {
9842
+ changed = false;
9843
+ for (const [name, value] of Object.entries(all)) {
9844
+ if (name in out)
9845
+ continue;
9846
+ if (Array.from(value.matchAll(VAR_REFERENCE)).some((match) => match[1] in out)) {
9847
+ out[name] = value;
9848
+ changed = true;
9849
+ }
9850
+ }
9851
+ }
9852
+ return out;
9853
+ }
9854
+ const block = (selector, declarations) => {
9855
+ const lines = Object.entries(declarations).map(([name, value]) => ` ${name}: ${value};`);
9856
+ return lines.length === 0 ? '' : `${selector} {\n${lines.join('\n')}\n}\n`;
9857
+ };
9858
+ /** Seletores do modo escuro: o atributo canônico e as classes aceitas por compatibilidade. */
9859
+ const SMZ_DARK_ROOT_SELECTORS = [':root[data-smz-mode=\'dark\']', ':root.app-dark', ':root.dark'];
9860
+ /** CSS (variáveis `--smz-*`) de um tema. */
9861
+ function smzThemeToCss(theme, options = {}) {
9862
+ const blocks = smzThemeCssBlocks(theme, { full: options.full });
9863
+ const scope = options.scope;
9864
+ if (scope != null && !options.full) {
9865
+ const all = desired(theme);
9866
+ blocks.light = withDependents(blocks.light, all.light);
9867
+ blocks.dark = withDependents({ ...blocks.dark }, all.dark);
9868
+ // No modo escuro do escopo, o que o bloco base do escopo redeclarou precisa voltar ao valor escuro.
9869
+ for (const name of Object.keys(blocks.light))
9870
+ if (!(name in blocks.dark) && all.dark[name] !== blocks.light[name])
9871
+ blocks.dark[name] = all.dark[name];
9872
+ }
9873
+ const base = scope ?? ':root';
9874
+ const dark = scope == null
9875
+ ? SMZ_DARK_ROOT_SELECTORS.join(',\n')
9876
+ : [...SMZ_DARK_ROOT_SELECTORS.map((root) => `${root} ${scope}`), `${scope}[data-smz-mode='dark']`].join(',\n');
9877
+ const density = (level) => (scope == null ? `:root[data-smz-density='${level}']` : `${scope}[data-smz-density='${level}'], :root[data-smz-density='${level}'] ${scope}`);
9878
+ return [
9879
+ block(base, blocks.light),
9880
+ block(dark, blocks.dark),
9881
+ ...Object.entries(blocks.density).map(([level, declarations]) => block(density(level), declarations ?? {})),
9882
+ ].filter(Boolean).join('\n');
9883
+ }
9884
+
9885
+ /** Id da folha de estilo que o serviço mantém no `<head>` com as variáveis do tema do app. */
9886
+ const SMZ_THEME_STYLE_ID = 'smz-theme';
9887
+ const MODE_ATTRIBUTE = 'data-smz-mode';
9888
+ const DENSITY_ATTRIBUTE = 'data-smz-density';
9889
+ /** Classe que as folhas de estilo anteriores ao contrato usam para o modo escuro. */
9890
+ const LEGACY_DARK_CLASS = 'app-dark';
9891
+ /**
9892
+ * Tema em runtime: aplica o arquivo de tema (`setTheme`), troca modo, densidade e escala, e mantém os atalhos
9893
+ * anteriores ao contrato (`setColors`, `setPrimaryPalette`).
9894
+ *
9895
+ * O tema do app vira uma folha de estilo no `<head>` (só as variáveis que diferem do preset padrão). Os atalhos
9896
+ * escrevem variáveis no `style` do `<html>`, que têm precedência sobre a folha.
8392
9897
  */
8393
9898
  class SmzThemeService {
8394
- root = inject(DOCUMENT).documentElement;
9899
+ document = inject(DOCUMENT);
9900
+ root = this.document.documentElement;
9901
+ current = signal(SMZ_DEFAULT_THEME, ...(ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []));
9902
+ currentMode = signal(this.isDark() ? 'dark' : 'light', ...(ngDevMode ? [{ debugName: "currentMode" }] : /* istanbul ignore next */ []));
9903
+ /** Variáveis que este serviço escreveu no `<html>`; `reset()` remove só estas. */
9904
+ inline = new Set();
9905
+ /** Tema aplicado. */
9906
+ theme = this.current.asReadonly();
9907
+ /** Modo aplicado por `setMode` (ou o encontrado no `<html>` ao iniciar). */
9908
+ mode = this.currentMode.asReadonly();
9909
+ /** Aplica um tema: substitui a folha de estilo do tema e a densidade. Aceita o tema pronto ou a definição. */
9910
+ setTheme(theme) {
9911
+ const resolved = 'overrides' in theme ? theme : defineSmzTheme(theme);
9912
+ this.current.set(resolved);
9913
+ this.styleElement().textContent = smzThemeToCss(resolved);
9914
+ this.applyDensity(resolved.density);
9915
+ if (isDevMode()) {
9916
+ // eslint-disable-next-line no-console
9917
+ for (const warning of smzThemeCssBlocks(resolved).warnings)
9918
+ console.warn(`[smz-theme] ${warning}`);
9919
+ }
9920
+ }
9921
+ /** Aplica uma alteração sobre o tema atual (o que o editor de tema faz a cada mudança). */
9922
+ patch(definition) {
9923
+ this.setTheme(defineSmzTheme({ ...definition, extends: this.current() }));
9924
+ }
9925
+ /** Modo claro ou escuro. Marca `data-smz-mode` e, por compatibilidade, a classe `app-dark` no `<html>`. */
9926
+ setMode(mode) {
9927
+ this.root.setAttribute(MODE_ATTRIBUTE, mode);
9928
+ this.root.classList.toggle(LEGACY_DARK_CLASS, mode === 'dark');
9929
+ this.currentMode.set(mode);
9930
+ }
9931
+ setDensity(density) {
9932
+ this.patch({ density });
9933
+ }
9934
+ /** Fator de escala das dimensões do tema (1 = sem escala). */
9935
+ setScale(scale) {
9936
+ this.patch({ base: { scale } });
9937
+ }
8395
9938
  /** Sobrescreve cores: `{ primary: '#6366f1' }` -> `--smz-color-primary`. Aceita hexadecimal ou canais ("99 102 241"). */
8396
9939
  setColors(colors) {
8397
9940
  for (const [name, value] of Object.entries(colors)) {
8398
- this.root.style.setProperty(`--smz-color-${name}`, value.startsWith('#') ? hexToChannels(value) : value);
9941
+ const parsed = smzParseColor(value);
9942
+ this.setInline(`--smz-color-${name}`, parsed != null ? smzToChannels(parsed) : value);
8399
9943
  }
8400
9944
  }
8401
9945
  /** Define a cor primaria a partir de uma paleta; escolhe os tons por modo claro/escuro. */
@@ -8409,17 +9953,37 @@ class SmzThemeService {
8409
9953
  'on-primary': dark ? '#0f172a' : '#ffffff',
8410
9954
  });
8411
9955
  }
8412
- /** Remove todas as sobrescritas feitas por este servico (volta ao tema do CSS). */
9956
+ /** Escreve uma variável CSS do tema direto no `<html>` (tem precedência sobre o tema aplicado). */
9957
+ setVariable(name, value) {
9958
+ this.setInline(name, value);
9959
+ }
9960
+ /** Remove as sobrescritas feitas por `setColors`, `setPrimaryPalette` e `setVariable`. O tema aplicado por `setTheme` fica. */
8413
9961
  reset() {
8414
- const style = this.root.style;
8415
- for (let i = style.length - 1; i >= 0; i--) {
8416
- const prop = style.item(i);
8417
- if (prop.startsWith('--smz-'))
8418
- style.removeProperty(prop);
8419
- }
9962
+ for (const name of this.inline)
9963
+ this.root.style.removeProperty(name);
9964
+ this.inline.clear();
8420
9965
  }
8421
9966
  isDark() {
8422
- return this.root.classList.contains('app-dark') || this.root.getAttribute('data-smz-mode') === 'dark';
9967
+ return this.root.classList.contains(LEGACY_DARK_CLASS) || this.root.classList.contains('dark') || this.root.getAttribute(MODE_ATTRIBUTE) === 'dark';
9968
+ }
9969
+ setInline(name, value) {
9970
+ this.root.style.setProperty(name, value);
9971
+ this.inline.add(name);
9972
+ }
9973
+ applyDensity(density) {
9974
+ if (density === 'normal')
9975
+ this.root.removeAttribute(DENSITY_ATTRIBUTE);
9976
+ else
9977
+ this.root.setAttribute(DENSITY_ATTRIBUTE, density);
9978
+ }
9979
+ styleElement() {
9980
+ const existing = this.document.getElementById(SMZ_THEME_STYLE_ID);
9981
+ if (existing instanceof HTMLStyleElement)
9982
+ return existing;
9983
+ const created = this.document.createElement('style');
9984
+ created.id = SMZ_THEME_STYLE_ID;
9985
+ this.document.head.appendChild(created);
9986
+ return created;
8423
9987
  }
8424
9988
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
8425
9989
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzThemeService, providedIn: 'root' });
@@ -8429,6 +9993,114 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
8429
9993
  args: [{ providedIn: 'root' }]
8430
9994
  }] });
8431
9995
 
9996
+ let nextScopeId = 0;
9997
+ /**
9998
+ * Aplica um tema, ou uma sobrescrita parcial, a um contêiner e a tudo dentro dele, inclusive aos overlays
9999
+ * (select, menu, diálogo, tooltip) abertos a partir dele.
10000
+ *
10001
+ * ```html
10002
+ * <section [smzTheme]="{ semantic: { radius: { control: '0' } } }" smzThemeMode="dark">…</section>
10003
+ * ```
10004
+ */
10005
+ class SmzThemeDirective {
10006
+ /** Tema pronto (`defineSmzTheme`) ou definição parcial, aplicada sobre o preset padrão. */
10007
+ smzTheme = input.required(...(ngDevMode ? [{ debugName: "smzTheme" }] : /* istanbul ignore next */ []));
10008
+ /** Força o modo dentro do escopo, independentemente do modo do app. */
10009
+ smzThemeMode = input(undefined, ...(ngDevMode ? [{ debugName: "smzThemeMode" }] : /* istanbul ignore next */ []));
10010
+ smzThemeDensity = input(undefined, ...(ngDevMode ? [{ debugName: "smzThemeDensity" }] : /* istanbul ignore next */ []));
10011
+ scopeId = `smz-scope-${(nextScopeId += 1)}`;
10012
+ document = inject(DOCUMENT);
10013
+ host = inject(ElementRef);
10014
+ style = null;
10015
+ resolved = null;
10016
+ constructor() {
10017
+ effect(() => {
10018
+ const value = this.smzTheme();
10019
+ this.resolved = value == null ? null : 'overrides' in value ? value : defineSmzTheme(value);
10020
+ const css = this.resolved == null ? '' : smzThemeToCss(this.resolved, { scope: `[${SMZ_THEME_SCOPE_ATTRIBUTE}="${this.scopeId}"]` });
10021
+ this.styleElement().textContent = css;
10022
+ });
10023
+ }
10024
+ ngOnDestroy() {
10025
+ this.style?.remove();
10026
+ }
10027
+ density() {
10028
+ const density = this.smzThemeDensity() ?? this.resolved?.density ?? 'normal';
10029
+ return density === 'normal' ? null : density;
10030
+ }
10031
+ styleElement() {
10032
+ if (this.style == null) {
10033
+ this.style = this.document.createElement('style');
10034
+ this.style.setAttribute('data-smz-theme-scope-style', this.scopeId);
10035
+ this.document.head.appendChild(this.style);
10036
+ }
10037
+ return this.style;
10038
+ }
10039
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzThemeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
10040
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.5", type: SmzThemeDirective, isStandalone: true, selector: "[smzTheme]", inputs: { smzTheme: { classPropertyName: "smzTheme", publicName: "smzTheme", isSignal: true, isRequired: true, transformFunction: null }, smzThemeMode: { classPropertyName: "smzThemeMode", publicName: "smzThemeMode", isSignal: true, isRequired: false, transformFunction: null }, smzThemeDensity: { classPropertyName: "smzThemeDensity", publicName: "smzThemeDensity", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-smz-theme-scope": "scopeId", "attr.data-smz-mode": "smzThemeMode() ?? null", "attr.data-smz-density": "density()" } }, ngImport: i0 });
10041
+ }
10042
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzThemeDirective, decorators: [{
10043
+ type: Directive,
10044
+ args: [{
10045
+ selector: '[smzTheme]',
10046
+ host: {
10047
+ '[attr.data-smz-theme-scope]': 'scopeId',
10048
+ '[attr.data-smz-mode]': 'smzThemeMode() ?? null',
10049
+ '[attr.data-smz-density]': 'density()',
10050
+ },
10051
+ }]
10052
+ }], ctorParameters: () => [], propDecorators: { smzTheme: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzTheme", required: true }] }], smzThemeMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzThemeMode", required: false }] }], smzThemeDensity: [{ type: i0.Input, args: [{ isSignal: true, alias: "smzThemeDensity", required: false }] }] } });
10053
+
10054
+ /**
10055
+ * Props padrão por componente vindas do tema (`defaults` do arquivo de tema), fornecidas por `provideSmzTheme`.
10056
+ * Um app também pode fornecer o token direto para um trecho da árvore.
10057
+ */
10058
+ const SMZ_COMPONENT_DEFAULTS = new InjectionToken('SMZ_COMPONENT_DEFAULTS');
10059
+ const globalDefaults = {};
10060
+ /**
10061
+ * Define props padrão de componentes fora da injeção de dependência (usado pelos builders do `@ngx-smz/core`,
10062
+ * que configuram a lib antes de existir injetor). O que vier de `SMZ_COMPONENT_DEFAULTS` tem precedência.
10063
+ */
10064
+ function smzSetComponentDefaults(defaults) {
10065
+ for (const [component, values] of Object.entries(defaults ?? {})) {
10066
+ globalDefaults[component] = { ...(globalDefaults[component] ?? {}), ...values };
10067
+ }
10068
+ }
10069
+ /**
10070
+ * Props padrão de um componente, na ordem de precedência: constantes do componente, `smzSetComponentDefaults`,
10071
+ * `SMZ_COMPONENT_DEFAULTS`. Chamar em contexto de injeção (inicializador de campo ou construtor).
10072
+ *
10073
+ * O input explícito do componente continua vencendo: o padrão só vale quando o input não foi informado.
10074
+ */
10075
+ function smzComponentDefaults(component, builtIn) {
10076
+ const provided = inject(SMZ_COMPONENT_DEFAULTS, { optional: true });
10077
+ return { ...builtIn, ...globalDefaults[component], ...provided?.[component] };
10078
+ }
10079
+
10080
+ /** Tema do app, como fornecido por `provideSmzTheme`. */
10081
+ const SMZ_THEME = new InjectionToken('SMZ_THEME');
10082
+ /**
10083
+ * Aplica o arquivo de tema do app na inicialização e disponibiliza as props padrão de componente do tema.
10084
+ *
10085
+ * ```ts
10086
+ * bootstrapApplication(App, { providers: [provideSmzTheme(appTheme)] });
10087
+ * ```
10088
+ *
10089
+ * O CSS do tema entra em runtime, depois do primeiro paint. Para evitar a troca visível em apps com tema muito
10090
+ * diferente do padrão, gere o CSS em build (`smz-theme build`) e inclua-o nos estilos do app.
10091
+ */
10092
+ function provideSmzTheme(theme) {
10093
+ const resolved = 'overrides' in theme ? theme : defineSmzTheme(theme);
10094
+ return makeEnvironmentProviders([
10095
+ { provide: SMZ_THEME, useValue: resolved },
10096
+ { provide: SMZ_COMPONENT_DEFAULTS, useValue: resolved.defaults },
10097
+ provideAppInitializer(() => inject(SmzThemeService).setTheme(resolved)),
10098
+ ]);
10099
+ }
10100
+
10101
+ // ARQUIVO GERADO: não edite. Fonte: src/lib/theme/catalog (rode `npm run build:design-tokens`).
10102
+ /* eslint-disable max-len, @typescript-eslint/no-empty-object-type */
10103
+
8432
10104
  /* eslint-disable max-len -- classes Tailwind nos templates */
8433
10105
  /**
8434
10106
  * Card. Substitui o `p-card` do PrimeNG.
@@ -9663,5 +11335,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
9663
11335
  * Generated bundle index. Do not edit.
9664
11336
  */
9665
11337
 
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 };
11338
+ export { SMZ_COMPONENT_DEFAULTS, SMZ_CONTRAST_AA, SMZ_DARK_ROOT_SELECTORS, SMZ_DEFAULT_THEME, SMZ_DIALOG_CONTENT, SMZ_SOFT_TONE, SMZ_SOLID_TONE, SMZ_THEME, SMZ_THEME_MODES, SMZ_THEME_SCOPE_ATTRIBUTE, SMZ_THEME_STYLE_ID, SMZ_TOAST_DEFAULTS, SMZ_TOAST_DEFAULT_OPTIONS, SMZ_TOKENS, SMZ_TOKEN_CATALOG, 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, SmzThemeDirective, SmzThemeService, SmzToastContainerComponent, SmzToastEnterDirective, SmzToastLifeDirective, SmzToggleSwitchComponent, SmzToolbarComponent, SmzTooltipComponent, SmzTooltipDirective, SmzTranslationKeys, SmzTreeSelectComponent, SmzTreeTableCheckboxComponent, SmzTreeTableComponent, SmzTreeTableHeaderCheckboxComponent, SmzTreeTableRowDirective, SmzTreeTableSortIconComponent, SmzTreeTableSortableColumnDirective, SmzTreeTableTogglerComponent, SmzUiTimelineComponent, SmzUiTreeComponent, SmzValueAccessor, SmzZIndex, defineSmzTheme, filterOptions, optionDisabled, optionLabel, optionValue, provideSmzTheme, provideSmzToastDefaults, provideSmzTooltipDefaults, sameValue, smzCalendarStart, smzCatalogSummary, smzComponentDefaults, smzComposite, smzContrastRatio, smzCx, smzDimensionFactor, smzFindTemplate, smzFindToken, smzFormatDate, smzInheritThemeScope, smzIsTokenDefinition, smzLiteralTokenValue, smzLuminance, smzMergeClasses, smzNormalizeSeverity, smzNormalizeStyleClass, smzParseButtonStyleClass, smzParseColor, smzParseDate, smzRawTokenValue, smzResolveToastDefaults, smzSameDay, smzSetComponentDefaults, smzSetToastDefaults, smzSetTooltipDefaults, smzStartOfDay, smzStaticHostClass, smzThemeCssBlocks, smzThemeToCss, smzToChannels, smzTokenCssVar, smzTokenReferences, smzTwoDigits, smzUniqueId, smzVariants, token };
9667
11339
  //# sourceMappingURL=ngx-smz-ui-kit.mjs.map