@ngx-smz/ui-kit 21.10.0-next.25 → 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.
- package/bin/smz-theme.mjs +134 -0
- package/fesm2022/ngx-smz-ui-kit.mjs +766 -25
- package/fesm2022/ngx-smz-ui-kit.mjs.map +1 -1
- package/package.json +5 -1
- package/tailwind.preset.js +13 -56
- package/themes/default.css +47 -19
- package/tokens/tailwind-tokens.cjs +66 -0
- package/tokens/theme-engine.cjs +534 -0
- package/tokens/theme.schema.json +1293 -0
- package/tokens/tokens.json +1264 -0
- package/types/ngx-smz-ui-kit.d.ts +672 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 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 } 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
5
|
import { NgTemplateOutlet, NgStyle, NgClass, DOCUMENT } from '@angular/common';
|
|
@@ -416,6 +416,27 @@ 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
|
+
/** 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
|
+
|
|
419
440
|
const SMZ_TOOLTIP_DEFAULT_OPTIONS = {
|
|
420
441
|
variant: 'dark',
|
|
421
442
|
arrow: true,
|
|
@@ -434,13 +455,13 @@ const SMZ_TOOLTIP_DEFAULTS = new InjectionToken('SMZ_TOOLTIP_DEFAULTS');
|
|
|
434
455
|
function provideSmzTooltipDefaults(defaults) {
|
|
435
456
|
return makeEnvironmentProviders([{ provide: SMZ_TOOLTIP_DEFAULTS, useValue: defaults }]);
|
|
436
457
|
}
|
|
437
|
-
const globalDefaults$
|
|
458
|
+
const globalDefaults$2 = {};
|
|
438
459
|
/**
|
|
439
460
|
* Padroes globais definidos fora da injecao de dependencias (usado pelo `SmzUiBuilder` do @ngx-smz/core).
|
|
440
461
|
* O token `SMZ_TOOLTIP_DEFAULTS`, quando provido, tem precedencia.
|
|
441
462
|
*/
|
|
442
463
|
function smzSetTooltipDefaults(defaults) {
|
|
443
|
-
Object.assign(globalDefaults$
|
|
464
|
+
Object.assign(globalDefaults$2, defaults ?? {});
|
|
444
465
|
}
|
|
445
466
|
/** Distancia entre o host e a caixa do tooltip, com e sem seta. */
|
|
446
467
|
const GAP_WITH_ARROW = 8;
|
|
@@ -675,7 +696,7 @@ class SmzTooltipDirective {
|
|
|
675
696
|
providedDefaults = inject(SMZ_TOOLTIP_DEFAULTS, { optional: true });
|
|
676
697
|
tooltipId = `smz-tooltip-${nextId$1++}`;
|
|
677
698
|
get defaults() {
|
|
678
|
-
return { ...SMZ_TOOLTIP_DEFAULT_OPTIONS, ...globalDefaults$
|
|
699
|
+
return { ...SMZ_TOOLTIP_DEFAULT_OPTIONS, ...globalDefaults$2, ...(this.providedDefaults ?? {}) };
|
|
679
700
|
}
|
|
680
701
|
overlayRef;
|
|
681
702
|
componentRef;
|
|
@@ -882,6 +903,7 @@ class SmzTooltipDirective {
|
|
|
882
903
|
const scrollStrategy = this.overlay.scrollStrategies.reposition({ scrollThrottle: 20, autoClose: true });
|
|
883
904
|
const overlayRef = this.overlay.create({ positionStrategy, scrollStrategy });
|
|
884
905
|
this.overlayRef = overlayRef;
|
|
906
|
+
smzInheritThemeScope(overlayRef, this.host.nativeElement);
|
|
885
907
|
const zIndex = this.option('tooltipZIndex');
|
|
886
908
|
if (zIndex !== '')
|
|
887
909
|
overlayRef.hostElement.style.zIndex = String(zIndex);
|
|
@@ -2260,6 +2282,8 @@ class SmzDialogService {
|
|
|
2260
2282
|
...pane,
|
|
2261
2283
|
maxWidth: pane.maxWidth ?? '95vw',
|
|
2262
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);
|
|
2263
2287
|
if (resolved.baseZIndex != null) {
|
|
2264
2288
|
overlayRef.hostElement.style.zIndex = String(resolved.baseZIndex + 1);
|
|
2265
2289
|
if (overlayRef.backdropElement)
|
|
@@ -2424,6 +2448,7 @@ class SmzDialogComponent {
|
|
|
2424
2448
|
...(this.maximized() ? { width: '100vw', height: '100vh', maxWidth: '100vw', maxHeight: '100vh' } : { ...this.sizing().pane, maxWidth: this.sizing().pane.maxWidth ?? '95vw' }),
|
|
2425
2449
|
});
|
|
2426
2450
|
SmzZIndex.set('modal', this.overlayRef.hostElement, 1100 + this.baseZIndex());
|
|
2451
|
+
smzInheritThemeScope(this.overlayRef, this.host.nativeElement);
|
|
2427
2452
|
if (this.overlayRef.backdropElement) {
|
|
2428
2453
|
this.overlayRef.backdropElement.style.zIndex = String(SmzZIndex.get(this.overlayRef.hostElement) - 1);
|
|
2429
2454
|
}
|
|
@@ -2634,6 +2659,7 @@ class SmzPopoverComponent {
|
|
|
2634
2659
|
});
|
|
2635
2660
|
if (this.autoZIndex())
|
|
2636
2661
|
SmzZIndex.set('overlay', this.overlayRef.hostElement, 1000);
|
|
2662
|
+
smzInheritThemeScope(this.overlayRef, this.origin ?? this.host.nativeElement);
|
|
2637
2663
|
if (this.dismissable()) {
|
|
2638
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());
|
|
2639
2665
|
}
|
|
@@ -2776,6 +2802,7 @@ class SmzDrawerComponent {
|
|
|
2776
2802
|
scrollStrategy: this.overlay.scrollStrategies.block(),
|
|
2777
2803
|
});
|
|
2778
2804
|
SmzZIndex.set('modal', this.overlayRef.hostElement, 1100);
|
|
2805
|
+
smzInheritThemeScope(this.overlayRef, this.host.nativeElement);
|
|
2779
2806
|
if (this.overlayRef.backdropElement) {
|
|
2780
2807
|
this.overlayRef.backdropElement.style.zIndex = String(SmzZIndex.get(this.overlayRef.hostElement) - 1);
|
|
2781
2808
|
}
|
|
@@ -2903,7 +2930,7 @@ const SMZ_TOAST_DEFAULTS = new InjectionToken('SMZ_TOAST_DEFAULTS');
|
|
|
2903
2930
|
function provideSmzToastDefaults(defaults) {
|
|
2904
2931
|
return makeEnvironmentProviders([{ provide: SMZ_TOAST_DEFAULTS, useValue: defaults }]);
|
|
2905
2932
|
}
|
|
2906
|
-
const globalDefaults = {};
|
|
2933
|
+
const globalDefaults$1 = {};
|
|
2907
2934
|
/**
|
|
2908
2935
|
* Padroes globais definidos fora da injecao de dependencias (usado pelo `SmzUiBuilder` do @ngx-smz/core).
|
|
2909
2936
|
* O token `SMZ_TOAST_DEFAULTS`, quando provido, tem precedencia. Campos `undefined` sao ignorados.
|
|
@@ -2911,12 +2938,12 @@ const globalDefaults = {};
|
|
|
2911
2938
|
function smzSetToastDefaults(defaults) {
|
|
2912
2939
|
for (const [key, value] of Object.entries(defaults ?? {})) {
|
|
2913
2940
|
if (value !== undefined && value !== null)
|
|
2914
|
-
globalDefaults[key] = value;
|
|
2941
|
+
globalDefaults$1[key] = value;
|
|
2915
2942
|
}
|
|
2916
2943
|
}
|
|
2917
2944
|
/** Padroes em vigor: base do kit, depois `smzSetToastDefaults`, depois o token. */
|
|
2918
2945
|
function smzResolveToastDefaults(provided) {
|
|
2919
|
-
return { ...SMZ_TOAST_DEFAULT_OPTIONS, ...globalDefaults, ...(provided ?? {}) };
|
|
2946
|
+
return { ...SMZ_TOAST_DEFAULT_OPTIONS, ...globalDefaults$1, ...(provided ?? {}) };
|
|
2920
2947
|
}
|
|
2921
2948
|
let nextId = 0;
|
|
2922
2949
|
const GROUP_FIELDS = ['key', 'severity', 'summary', 'detail', 'icon', 'sticky', 'styleClass'];
|
|
@@ -3757,6 +3784,7 @@ class SmzMenuListComponent {
|
|
|
3757
3784
|
});
|
|
3758
3785
|
if (this.autoZIndex())
|
|
3759
3786
|
SmzZIndex.set('menu', this.overlayRef.hostElement, 1000 + this.baseZIndex());
|
|
3787
|
+
smzInheritThemeScope(this.overlayRef, origin ?? this.host.nativeElement);
|
|
3760
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());
|
|
3761
3789
|
this.overlayRef.attach(new TemplatePortal(this.list(), this.viewContainer));
|
|
3762
3790
|
this.shown.emit();
|
|
@@ -4103,6 +4131,7 @@ class SmzAnchoredPanel {
|
|
|
4103
4131
|
minWidth: options.matchWidth ? anchor.getBoundingClientRect().width : undefined,
|
|
4104
4132
|
});
|
|
4105
4133
|
SmzZIndex.set('overlay', this.overlayRef.hostElement, 1000);
|
|
4134
|
+
smzInheritThemeScope(this.overlayRef, anchor);
|
|
4106
4135
|
const dismiss = () => {
|
|
4107
4136
|
this.close();
|
|
4108
4137
|
options.onDismiss?.();
|
|
@@ -9311,22 +9340,606 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
|
|
|
9311
9340
|
}]
|
|
9312
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 }] }] } });
|
|
9313
9342
|
|
|
9314
|
-
const
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
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,
|
|
9319
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
|
+
});
|
|
9320
9682
|
/**
|
|
9321
|
-
*
|
|
9322
|
-
*
|
|
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
|
+
}
|
|
9733
|
+
/**
|
|
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.
|
|
9323
9897
|
*/
|
|
9324
9898
|
class SmzThemeService {
|
|
9325
|
-
|
|
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
|
+
}
|
|
9326
9938
|
/** Sobrescreve cores: `{ primary: '#6366f1' }` -> `--smz-color-primary`. Aceita hexadecimal ou canais ("99 102 241"). */
|
|
9327
9939
|
setColors(colors) {
|
|
9328
9940
|
for (const [name, value] of Object.entries(colors)) {
|
|
9329
|
-
|
|
9941
|
+
const parsed = smzParseColor(value);
|
|
9942
|
+
this.setInline(`--smz-color-${name}`, parsed != null ? smzToChannels(parsed) : value);
|
|
9330
9943
|
}
|
|
9331
9944
|
}
|
|
9332
9945
|
/** Define a cor primaria a partir de uma paleta; escolhe os tons por modo claro/escuro. */
|
|
@@ -9340,17 +9953,37 @@ class SmzThemeService {
|
|
|
9340
9953
|
'on-primary': dark ? '#0f172a' : '#ffffff',
|
|
9341
9954
|
});
|
|
9342
9955
|
}
|
|
9343
|
-
/**
|
|
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. */
|
|
9344
9961
|
reset() {
|
|
9345
|
-
const
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
if (prop.startsWith('--smz-'))
|
|
9349
|
-
style.removeProperty(prop);
|
|
9350
|
-
}
|
|
9962
|
+
for (const name of this.inline)
|
|
9963
|
+
this.root.style.removeProperty(name);
|
|
9964
|
+
this.inline.clear();
|
|
9351
9965
|
}
|
|
9352
9966
|
isDark() {
|
|
9353
|
-
return this.root.classList.contains('
|
|
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;
|
|
9354
9987
|
}
|
|
9355
9988
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9356
9989
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SmzThemeService, providedIn: 'root' });
|
|
@@ -9360,6 +9993,114 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
|
|
|
9360
9993
|
args: [{ providedIn: 'root' }]
|
|
9361
9994
|
}] });
|
|
9362
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
|
+
|
|
9363
10104
|
/* eslint-disable max-len -- classes Tailwind nos templates */
|
|
9364
10105
|
/**
|
|
9365
10106
|
* Card. Substitui o `p-card` do PrimeNG.
|
|
@@ -10594,5 +11335,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
|
|
|
10594
11335
|
* Generated bundle index. Do not edit.
|
|
10595
11336
|
*/
|
|
10596
11337
|
|
|
10597
|
-
export { SMZ_DIALOG_CONTENT, SMZ_SOFT_TONE, SMZ_SOLID_TONE, SMZ_TOAST_DEFAULTS, SMZ_TOAST_DEFAULT_OPTIONS, SMZ_TOOLTIP_DEFAULTS, SMZ_TOOLTIP_DEFAULT_OPTIONS, SMZ_TREE_TABLE, SmzAccordionComponent, SmzAccordionContentComponent, SmzAccordionHeaderComponent, SmzAccordionPanelComponent, SmzAnchoredPanel, SmzAutoCompleteComponent, SmzAutoFocusDirective, SmzBadgeComponent, SmzBadgeDirective, SmzBlockUiComponent, SmzButtonComponent, SmzCardComponent, SmzCheckboxComponent, SmzColorPickerComponent, SmzConfirmContentComponent, SmzConfirmationService, SmzConnectedOverlayScrollHandler, SmzDataViewComponent, SmzDatePickerComponent, SmzDialogComponent, SmzDialogConfig, SmzDialogFrameComponent, SmzDialogRef, SmzDialogService, SmzDividerComponent, SmzDomHandler, SmzDrawerComponent, SmzFileUploadComponent, SmzFilterMatchMode, SmzFilterOperator, SmzFilterService, SmzFloatLabelComponent, SmzIconComponent, SmzIconFieldComponent, SmzInputGroupAddonComponent, SmzInputGroupComponent, SmzInputIconComponent, SmzInputMaskComponent, SmzInputNumberComponent, SmzInputTextDirective, SmzListboxComponent, SmzLocaleService, SmzMenuListComponent, SmzMessageComponent, SmzMessageService, SmzMultiSelectComponent, SmzObjectUtils, SmzPaginatorComponent, SmzPanelComponent, SmzPasswordComponent, SmzPickListComponent, SmzPopoverComponent, SmzProgressBarComponent, SmzProgressSpinnerComponent, SmzRadioButtonComponent, SmzRippleDirective, SmzSelectButtonComponent, SmzSelectComponent, SmzSkeletonComponent, SmzSplitterComponent, SmzSplitterPanelComponent, SmzStyleClassDirective, SmzTabComponent, SmzTabListComponent, SmzTabPanelComponent, SmzTabPanelsComponent, SmzTabsComponent, SmzTagComponent, SmzTemplateDirective, SmzTextareaDirective, SmzThemeService, SmzToastContainerComponent, SmzToastEnterDirective, SmzToastLifeDirective, SmzToggleSwitchComponent, SmzToolbarComponent, SmzTooltipComponent, SmzTooltipDirective, SmzTranslationKeys, SmzTreeSelectComponent, SmzTreeTableCheckboxComponent, SmzTreeTableComponent, SmzTreeTableHeaderCheckboxComponent, SmzTreeTableRowDirective, SmzTreeTableSortIconComponent, SmzTreeTableSortableColumnDirective, SmzTreeTableTogglerComponent, SmzUiTimelineComponent, SmzUiTreeComponent, SmzValueAccessor, SmzZIndex, filterOptions, optionDisabled, optionLabel, optionValue, provideSmzToastDefaults, provideSmzTooltipDefaults, sameValue, smzCalendarStart, smzCx, smzFindTemplate, smzFormatDate, smzMergeClasses, smzNormalizeSeverity, smzNormalizeStyleClass, smzParseButtonStyleClass, smzParseDate, smzResolveToastDefaults, smzSameDay, smzSetToastDefaults, smzSetTooltipDefaults, smzStartOfDay, smzStaticHostClass, smzTwoDigits, smzUniqueId, smzVariants };
|
|
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 };
|
|
10598
11339
|
//# sourceMappingURL=ngx-smz-ui-kit.mjs.map
|