@fylib/adapter-angular 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/base/base-component.d.ts +18 -0
  2. package/dist/base/base-component.js +36 -0
  3. package/dist/base/interaction.utils.d.ts +7 -0
  4. package/dist/base/interaction.utils.js +34 -0
  5. package/dist/base/interaction.utils.test.d.ts +1 -0
  6. package/dist/base/interaction.utils.test.js +25 -0
  7. package/dist/components/accordion.component.d.ts +32 -0
  8. package/dist/components/accordion.component.js +337 -0
  9. package/dist/components/badge.component.d.ts +10 -0
  10. package/dist/components/badge.component.js +112 -0
  11. package/dist/components/button.component.d.ts +33 -0
  12. package/dist/components/button.component.js +272 -0
  13. package/dist/components/card.component.d.ts +29 -0
  14. package/dist/components/card.component.js +236 -0
  15. package/dist/components/chart.component.d.ts +39 -0
  16. package/dist/components/chart.component.js +307 -0
  17. package/dist/components/icon.component.d.ts +18 -0
  18. package/dist/components/icon.component.js +144 -0
  19. package/dist/components/input.component.d.ts +50 -0
  20. package/dist/components/input.component.js +383 -0
  21. package/dist/components/modal.component.d.ts +46 -0
  22. package/dist/components/modal.component.js +404 -0
  23. package/dist/components/nav-link.component.d.ts +11 -0
  24. package/dist/components/nav-link.component.js +121 -0
  25. package/dist/components/notification-menu.component.d.ts +68 -0
  26. package/dist/components/notification-menu.component.js +695 -0
  27. package/dist/components/select.component.d.ts +52 -0
  28. package/dist/components/select.component.js +395 -0
  29. package/dist/components/table.component.d.ts +55 -0
  30. package/dist/components/table.component.js +643 -0
  31. package/dist/components/text.component.d.ts +8 -0
  32. package/dist/components/text.component.js +58 -0
  33. package/dist/components/toast.component.d.ts +27 -0
  34. package/dist/components/toast.component.js +260 -0
  35. package/dist/directives/animation.directive.d.ts +5 -0
  36. package/dist/directives/animation.directive.js +34 -0
  37. package/dist/directives/theme-vars.directive.d.ts +7 -0
  38. package/dist/directives/theme-vars.directive.js +70 -0
  39. package/dist/directives/wallpaper.directive.d.ts +28 -0
  40. package/dist/directives/wallpaper.directive.js +195 -0
  41. package/dist/effects/confetti.plugin.d.ts +1 -0
  42. package/dist/effects/confetti.plugin.js +151 -0
  43. package/dist/effects/extra-effects.plugin.d.ts +3 -0
  44. package/dist/effects/extra-effects.plugin.js +288 -0
  45. package/dist/effects/hearts.plugin.d.ts +1 -0
  46. package/dist/effects/hearts.plugin.js +172 -0
  47. package/dist/effects/register-all.d.ts +1 -0
  48. package/dist/effects/register-all.js +16 -0
  49. package/dist/effects/ui-effects.plugin.d.ts +1 -0
  50. package/dist/effects/ui-effects.plugin.js +134 -0
  51. package/dist/icons/providers/fontawesome.provider.d.ts +3 -0
  52. package/dist/icons/providers/fontawesome.provider.js +25 -0
  53. package/dist/icons/providers/mdi.provider.d.ts +3 -0
  54. package/dist/icons/providers/mdi.provider.js +13 -0
  55. package/dist/icons/providers/phosphor.provider.d.ts +3 -0
  56. package/dist/icons/providers/phosphor.provider.js +17 -0
  57. package/dist/icons/registry.d.ts +22 -0
  58. package/dist/icons/registry.js +12 -0
  59. package/dist/index.d.ts +29 -0
  60. package/dist/index.js +29 -0
  61. package/dist/layouts/layout.component.d.ts +24 -0
  62. package/dist/layouts/layout.component.js +255 -0
  63. package/dist/layouts/slot.component.d.ts +61 -0
  64. package/dist/layouts/slot.component.js +937 -0
  65. package/dist/providers.d.ts +12 -0
  66. package/dist/providers.js +18 -0
  67. package/dist/services/fylib.service.d.ts +31 -0
  68. package/dist/services/fylib.service.js +214 -0
  69. package/dist/services/notification.service.d.ts +27 -0
  70. package/dist/services/notification.service.js +118 -0
  71. package/dist/services/sse.service.d.ts +16 -0
  72. package/dist/services/sse.service.js +109 -0
  73. package/dist/services/webclient.service.d.ts +38 -0
  74. package/dist/services/webclient.service.js +144 -0
  75. package/package.json +43 -0
@@ -0,0 +1,27 @@
1
+ import { EventEmitter, OnInit, OnDestroy } from '@angular/core';
2
+ import { ToastProps } from '@fylib/catalog';
3
+ import { BaseFyComponent } from '../base/base-component';
4
+ export declare class FyToastComponent extends BaseFyComponent<'fy-toast'> implements ToastProps, OnInit, OnDestroy {
5
+ id?: string;
6
+ title?: string;
7
+ message: string;
8
+ type: 'info' | 'success' | 'warning' | 'error';
9
+ duration: number;
10
+ showIcon: boolean;
11
+ closable: boolean;
12
+ position: any;
13
+ activeAnimations: boolean | null;
14
+ activeEffects: boolean | null;
15
+ customStyles: Record<string, string> | null;
16
+ fyClose: EventEmitter<void>;
17
+ private timer?;
18
+ isClosing: import("@angular/core").WritableSignal<boolean>;
19
+ constructor();
20
+ ngOnInit(): void;
21
+ ngOnDestroy(): void;
22
+ close(): void;
23
+ get resolvedIcon(): string;
24
+ get resolvedIconColor(): string;
25
+ get resolvedCloseIcon(): string;
26
+ get animationClassSuffix(): string;
27
+ }
@@ -0,0 +1,260 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Component, Input, Output, EventEmitter, inject, ViewEncapsulation, signal } from '@angular/core';
11
+ import { CommonModule } from '@angular/common';
12
+ import { FyLibService } from '../services/fylib.service';
13
+ import { BaseFyComponent } from '../base/base-component';
14
+ import { FyIconComponent } from './icon.component';
15
+ let FyToastComponent = class FyToastComponent extends BaseFyComponent {
16
+ constructor() {
17
+ super(inject(FyLibService), 'fy-toast');
18
+ this.type = 'info';
19
+ this.duration = 3000;
20
+ this.showIcon = true;
21
+ this.closable = true;
22
+ this.position = 'top-right';
23
+ this.activeAnimations = null;
24
+ this.activeEffects = null;
25
+ this.customStyles = null;
26
+ this.fyClose = new EventEmitter();
27
+ this.isClosing = signal(false);
28
+ }
29
+ ngOnInit() {
30
+ if (this.duration > 0) {
31
+ this.timer = setTimeout(() => this.close(), this.duration);
32
+ }
33
+ this.triggerByEvent('fy-toast.open', undefined, this.activeEffects);
34
+ }
35
+ ngOnDestroy() {
36
+ if (this.timer)
37
+ clearTimeout(this.timer);
38
+ }
39
+ close() {
40
+ if (this.isClosing())
41
+ return;
42
+ this.isClosing.set(true);
43
+ // Aguarda a animação de saída (out) terminar antes de emitir o fechamento
44
+ setTimeout(() => {
45
+ this.fyClose.emit();
46
+ }, 300); // tempo aproximado da animação toast-out
47
+ }
48
+ get resolvedIcon() {
49
+ const themeIcons = this.fylib.getTokens().effects?.toast?.icons;
50
+ const iconFromTheme = themeIcons ? themeIcons[this.type] : undefined;
51
+ if (iconFromTheme) {
52
+ return iconFromTheme;
53
+ }
54
+ switch (this.type) {
55
+ case 'success': return 'check-circle';
56
+ case 'warning': return 'warning';
57
+ case 'error': return 'x-circle';
58
+ default: return 'info';
59
+ }
60
+ }
61
+ get resolvedIconColor() {
62
+ const themeIconColors = this.fylib.getTokens().effects?.toast?.iconColor;
63
+ const colorFromTheme = themeIconColors ? themeIconColors[this.type] : undefined;
64
+ if (colorFromTheme) {
65
+ return String(colorFromTheme);
66
+ }
67
+ const colors = this.fylib.getTokens().colors;
68
+ switch (this.type) {
69
+ case 'success': return String(colors?.success || '#28cd41');
70
+ case 'warning': return String(colors?.warning || '#ffcc00');
71
+ case 'error': return String(colors?.danger || '#ff3b30');
72
+ default: return String(colors?.info || '#007aff');
73
+ }
74
+ }
75
+ get resolvedCloseIcon() {
76
+ const themeCloseIcon = this.fylib.getTokens().effects?.toast?.closeIcon;
77
+ return themeCloseIcon || 'x';
78
+ }
79
+ get animationClassSuffix() {
80
+ if (this.isClosing()) {
81
+ return ' fy-anim-toast-out';
82
+ }
83
+ return ' fy-anim-toast-in';
84
+ }
85
+ };
86
+ __decorate([
87
+ Input(),
88
+ __metadata("design:type", String)
89
+ ], FyToastComponent.prototype, "id", void 0);
90
+ __decorate([
91
+ Input(),
92
+ __metadata("design:type", String)
93
+ ], FyToastComponent.prototype, "title", void 0);
94
+ __decorate([
95
+ Input(),
96
+ __metadata("design:type", String)
97
+ ], FyToastComponent.prototype, "message", void 0);
98
+ __decorate([
99
+ Input(),
100
+ __metadata("design:type", String)
101
+ ], FyToastComponent.prototype, "type", void 0);
102
+ __decorate([
103
+ Input(),
104
+ __metadata("design:type", Number)
105
+ ], FyToastComponent.prototype, "duration", void 0);
106
+ __decorate([
107
+ Input(),
108
+ __metadata("design:type", Boolean)
109
+ ], FyToastComponent.prototype, "showIcon", void 0);
110
+ __decorate([
111
+ Input(),
112
+ __metadata("design:type", Boolean)
113
+ ], FyToastComponent.prototype, "closable", void 0);
114
+ __decorate([
115
+ Input(),
116
+ __metadata("design:type", Object)
117
+ ], FyToastComponent.prototype, "position", void 0);
118
+ __decorate([
119
+ Input(),
120
+ __metadata("design:type", Object)
121
+ ], FyToastComponent.prototype, "activeAnimations", void 0);
122
+ __decorate([
123
+ Input(),
124
+ __metadata("design:type", Object)
125
+ ], FyToastComponent.prototype, "activeEffects", void 0);
126
+ __decorate([
127
+ Input(),
128
+ __metadata("design:type", Object)
129
+ ], FyToastComponent.prototype, "customStyles", void 0);
130
+ __decorate([
131
+ Output(),
132
+ __metadata("design:type", Object)
133
+ ], FyToastComponent.prototype, "fyClose", void 0);
134
+ FyToastComponent = __decorate([
135
+ Component({
136
+ selector: 'fy-toast',
137
+ standalone: true,
138
+ imports: [CommonModule, FyIconComponent],
139
+ template: `
140
+ <div
141
+ class="fy-toast"
142
+ [class]="'fy-toast--' + type"
143
+ [class]="composeAnimClasses(animationClassSuffix)"
144
+ [style]="getHostStyles(customStyles)"
145
+ >
146
+ @if (showIcon) {
147
+ <div class="fy-toast__icon">
148
+ <fy-icon [name]="resolvedIcon" [color]="resolvedIconColor"></fy-icon>
149
+ </div>
150
+ }
151
+
152
+ <div class="fy-toast__content">
153
+ @if (title) { <div class="fy-toast__title">{{ title }}</div> }
154
+ <div class="fy-toast__message">{{ message }}</div>
155
+ </div>
156
+
157
+ @if (closable) {
158
+ <button class="fy-toast__close" (click)="close()">
159
+ <fy-icon [name]="resolvedCloseIcon"></fy-icon>
160
+ </button>
161
+ }
162
+ </div>
163
+ `,
164
+ styles: [`
165
+ .fy-toast {
166
+ display: flex;
167
+ align-items: flex-start;
168
+ gap: var(--fy-effects-toast-gap, var(--fy-spacing-sm, 8px));
169
+ padding: var(--fy-effects-toast-padding, var(--fy-spacing-md, 12px));
170
+ min-width: var(--fy-effects-toast-minWidth, 280px);
171
+ max-width: var(--fy-effects-toast-maxWidth, 420px);
172
+ background: var(--fy-effects-toast-background, #ffffff);
173
+ border: 1px solid var(--fy-effects-toast-borderColor, rgba(0,0,0,0.1));
174
+ border-radius: var(--fy-effects-toast-borderRadius, 8px);
175
+ box-shadow: var(--fy-effects-toast-shadow, 0 4px 12px rgba(0,0,0,0.1));
176
+ color: var(--fy-effects-toast-textColor, inherit);
177
+ pointer-events: auto;
178
+ margin-bottom: 8px;
179
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
180
+ position: relative;
181
+ }
182
+
183
+ /* Animações base */
184
+ .fy-anim-toast-in {
185
+ animation: toast-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
186
+ }
187
+
188
+ .fy-anim-toast-out {
189
+ animation: toast-out 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
190
+ }
191
+
192
+ @keyframes toast-in {
193
+ from { transform: translateX(100%); opacity: 0; }
194
+ to { transform: translateX(0); opacity: 1; }
195
+ }
196
+
197
+ @keyframes toast-out {
198
+ from { transform: scale(1); opacity: 1; }
199
+ to { transform: scale(0.8); opacity: 0; }
200
+ }
201
+
202
+ .fy-toast__icon {
203
+ flex-shrink: 0;
204
+ font-size: var(--fy-effects-toast-iconSize, 20px);
205
+ display: flex;
206
+ align-items: center;
207
+ justify-content: center;
208
+ }
209
+
210
+ .fy-toast--info .fy-toast__icon { color: var(--fy-effects-toast-iconColor-info, var(--fy-colors-info, #007aff)); }
211
+ .fy-toast--success .fy-toast__icon { color: var(--fy-effects-toast-iconColor-success, var(--fy-colors-success, #28cd41)); }
212
+ .fy-toast--warning .fy-toast__icon { color: var(--fy-effects-toast-iconColor-warning, var(--fy-colors-warning, #ffcc00)); }
213
+ .fy-toast--error .fy-toast__icon { color: var(--fy-effects-toast-iconColor-error, var(--fy-colors-danger, #ff3b30)); }
214
+
215
+ .fy-toast__content {
216
+ flex: 1;
217
+ overflow: hidden;
218
+ }
219
+
220
+ .fy-toast__title {
221
+ font-weight: var(--fy-effects-toast-titleFontWeight, var(--fy-typography-fontWeight-bold, 600));
222
+ font-size: var(--fy-effects-toast-titleFontSize, var(--fy-typography-fontSize-md, 14px));
223
+ margin-bottom: 2px;
224
+ }
225
+
226
+ .fy-toast__message {
227
+ font-size: var(--fy-effects-toast-messageFontSize, var(--fy-typography-fontSize-sm, 13px));
228
+ line-height: var(--fy-effects-toast-messageLineHeight, 1.4);
229
+ opacity: 0.9;
230
+ }
231
+
232
+ .fy-toast__close {
233
+ position: absolute;
234
+ top: 4px;
235
+ right: 4px;
236
+ flex-shrink: 0;
237
+ background: var(--fy-effects-toast-closeButtonBackground, transparent);
238
+ border: var(--fy-effects-toast-closeButtonBorder, none);
239
+ border-radius: var(--fy-effects-toast-closeButtonBorderRadius, 0);
240
+ padding: 2px;
241
+ cursor: pointer;
242
+ opacity: var(--fy-effects-toast-closeButtonOpacity, 0.5);
243
+ transition: opacity 0.2s;
244
+ color: currentColor;
245
+ display: flex;
246
+ align-items: center;
247
+ justify-content: center;
248
+ width: var(--fy-effects-toast-closeButtonSize, 18px);
249
+ height: var(--fy-effects-toast-closeButtonSize, 18px);
250
+ }
251
+
252
+ .fy-toast__close:hover {
253
+ opacity: var(--fy-effects-toast-closeButtonHoverOpacity, 1);
254
+ }
255
+ `],
256
+ encapsulation: ViewEncapsulation.None
257
+ }),
258
+ __metadata("design:paramtypes", [])
259
+ ], FyToastComponent);
260
+ export { FyToastComponent };
@@ -0,0 +1,5 @@
1
+ export declare class FyAnimationDirective {
2
+ private el;
3
+ animationName: string;
4
+ play(): void;
5
+ }
@@ -0,0 +1,34 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Directive, inject, ElementRef, Input } from '@angular/core';
11
+ import { animationEngine } from '@fylib/animation';
12
+ let FyAnimationDirective = class FyAnimationDirective {
13
+ constructor() {
14
+ this.el = inject(ElementRef);
15
+ }
16
+ play() {
17
+ if (this.animationName) {
18
+ animationEngine.playAnimation(this.animationName);
19
+ // Aqui poderíamos adicionar lógica para aplicar classes CSS ou Web Animations API
20
+ this.el.nativeElement.classList.add(`fy-anim-${this.animationName}`);
21
+ }
22
+ }
23
+ };
24
+ __decorate([
25
+ Input('fyAnimation'),
26
+ __metadata("design:type", String)
27
+ ], FyAnimationDirective.prototype, "animationName", void 0);
28
+ FyAnimationDirective = __decorate([
29
+ Directive({
30
+ selector: '[fyAnimation]',
31
+ standalone: true
32
+ })
33
+ ], FyAnimationDirective);
34
+ export { FyAnimationDirective };
@@ -0,0 +1,7 @@
1
+ export declare class FyThemeVarsDirective {
2
+ private el;
3
+ private fylib;
4
+ constructor();
5
+ private ensureResetInjected;
6
+ private applyTokensToElement;
7
+ }
@@ -0,0 +1,70 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Directive, ElementRef, inject, effect } from '@angular/core';
11
+ import { FyLibService } from '../services/fylib.service';
12
+ let FyThemeVarsDirective = class FyThemeVarsDirective {
13
+ constructor() {
14
+ this.el = inject(ElementRef);
15
+ this.fylib = inject(FyLibService);
16
+ this.ensureResetInjected();
17
+ effect(() => {
18
+ const tokens = this.fylib.tokens();
19
+ const config = this.fylib.config();
20
+ this.applyTokensToElement(this.el.nativeElement, tokens, !!config.theme?.animationsEnabled);
21
+ });
22
+ }
23
+ ensureResetInjected() {
24
+ const doc = this.el.nativeElement.ownerDocument;
25
+ if (!doc.getElementById('fy-reset-style')) {
26
+ const style = doc.createElement('style');
27
+ style.id = 'fy-reset-style';
28
+ style.textContent = `
29
+ *,*::before,*::after{box-sizing:border-box}
30
+ html,body{height:100%}
31
+ body{margin:0;padding:0;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
32
+ h1,h2,h3,h4,h5,h6,p,figure,blockquote,dl,dd{margin:0}
33
+ ul,ol{margin:0;padding:0;list-style:none}
34
+ img,picture,video,canvas,svg{display:block;max-width:100%}
35
+ input,button,textarea,select{font:inherit;color:inherit}
36
+ a{text-decoration:none;color:inherit}
37
+ table{border-collapse:collapse;border-spacing:0}
38
+ `;
39
+ doc.head.appendChild(style);
40
+ }
41
+ }
42
+ applyTokensToElement(element, tokens, animationsEnabled, prefix = '--fy-') {
43
+ Object.keys(tokens).forEach(key => {
44
+ const value = tokens[key];
45
+ if (value == null) {
46
+ return;
47
+ }
48
+ if (typeof value === 'object') {
49
+ this.applyTokensToElement(element, value, animationsEnabled, `${prefix}${key}-`);
50
+ }
51
+ else {
52
+ element.style.setProperty(`${prefix}${key}`, String(value));
53
+ }
54
+ });
55
+ if (!animationsEnabled) {
56
+ element.classList.add('fy-animations-disabled');
57
+ }
58
+ else {
59
+ element.classList.remove('fy-animations-disabled');
60
+ }
61
+ }
62
+ };
63
+ FyThemeVarsDirective = __decorate([
64
+ Directive({
65
+ selector: '[fyThemeVars]',
66
+ standalone: true
67
+ }),
68
+ __metadata("design:paramtypes", [])
69
+ ], FyThemeVarsDirective);
70
+ export { FyThemeVarsDirective };
@@ -0,0 +1,28 @@
1
+ import { OnInit, OnChanges, SimpleChanges } from '@angular/core';
2
+ import { WallpaperName } from '@fylib/config';
3
+ export declare class FyWallpaperDirective implements OnInit, OnChanges {
4
+ private el;
5
+ private renderer;
6
+ private fylib;
7
+ private platformId;
8
+ private document;
9
+ wallpaperName?: WallpaperName | string | null;
10
+ wallpaperOpacity?: number;
11
+ wallpaperEnabled: boolean;
12
+ private styleElement?;
13
+ constructor();
14
+ ngOnInit(): void;
15
+ ngOnChanges(changes: SimpleChanges): void;
16
+ private applyWallpaper;
17
+ private renderWallpaper;
18
+ private applyHeartsPattern;
19
+ private applyGeometricPattern;
20
+ private applyPineTreesPattern;
21
+ private applyCyberGridPattern;
22
+ private applyDotsPattern;
23
+ private applyGrassPattern;
24
+ private applyAeroWavesPattern;
25
+ private applyMeshGradientPattern;
26
+ private ensureAnimationStyles;
27
+ private clearWallpaper;
28
+ }
@@ -0,0 +1,195 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Directive, ElementRef, Input, inject, Renderer2, effect, PLATFORM_ID } from '@angular/core';
11
+ import { isPlatformBrowser, DOCUMENT } from '@angular/common';
12
+ import { FyLibService } from '../services/fylib.service';
13
+ let FyWallpaperDirective = class FyWallpaperDirective {
14
+ constructor() {
15
+ this.el = inject(ElementRef);
16
+ this.renderer = inject(Renderer2);
17
+ this.fylib = inject(FyLibService);
18
+ this.platformId = inject(PLATFORM_ID);
19
+ this.document = inject(DOCUMENT);
20
+ this.wallpaperEnabled = true;
21
+ // Reage a mudanças na configuração global (ex: habilitar/desabilitar wallpaperEnabled no theme.config.ts)
22
+ effect(() => {
23
+ this.fylib.config();
24
+ this.applyWallpaper();
25
+ });
26
+ }
27
+ ngOnInit() {
28
+ this.applyWallpaper();
29
+ }
30
+ ngOnChanges(changes) {
31
+ if (changes['wallpaperName'] || changes['wallpaperOpacity'] || changes['wallpaperEnabled']) {
32
+ this.applyWallpaper();
33
+ }
34
+ }
35
+ applyWallpaper() {
36
+ // No SSR, evitamos processar wallpaper se não estivermos no browser
37
+ if (!isPlatformBrowser(this.platformId)) {
38
+ return;
39
+ }
40
+ const config = this.fylib.config();
41
+ const globalEnabled = config.theme?.wallpaperEnabled ?? false;
42
+ // Só mostra se habilitado globalmente no AppConfig (theme.config.ts)
43
+ if (!globalEnabled || this.wallpaperEnabled === false) {
44
+ this.clearWallpaper();
45
+ return;
46
+ }
47
+ let wallpaper;
48
+ // Lógica de resolução solicitada:
49
+ // 1. Se informou um nome específico (diferente de "" ou "auto"), usa ele como override com precedência total
50
+ if (this.wallpaperName && this.wallpaperName !== '' && this.wallpaperName !== 'auto') {
51
+ wallpaper = {
52
+ name: this.wallpaperName,
53
+ type: 'pattern',
54
+ opacity: this.wallpaperOpacity
55
+ };
56
+ }
57
+ else {
58
+ // 2. Se a diretiva está presente mas sem valor ("" ou "auto" ou undefined), pega o padrão do tema corrente
59
+ wallpaper = this.fylib.getThemeWallpaper();
60
+ // Se pegou do tema, aplica o override de opacidade da diretiva se existir
61
+ if (wallpaper && this.wallpaperOpacity !== undefined) {
62
+ wallpaper = { ...wallpaper, opacity: this.wallpaperOpacity };
63
+ }
64
+ }
65
+ if (!wallpaper) {
66
+ this.clearWallpaper();
67
+ return;
68
+ }
69
+ this.renderWallpaper(wallpaper);
70
+ }
71
+ renderWallpaper(wp) {
72
+ // Se não houver opacidade definida (nem na prop nem no objeto wallpaper), padrão é 1
73
+ const opacity = wp.opacity ?? 1;
74
+ // Garantir que o elemento tem posição relativa se for usar overlay
75
+ if (wp.overlay) {
76
+ this.renderer.setStyle(this.el.nativeElement, 'position', 'relative');
77
+ }
78
+ switch (wp.name) {
79
+ case 'hearts':
80
+ this.applyHeartsPattern(opacity);
81
+ break;
82
+ case 'geometric':
83
+ this.applyGeometricPattern(opacity);
84
+ break;
85
+ case 'pine-trees':
86
+ this.applyPineTreesPattern(opacity);
87
+ break;
88
+ case 'cyber-grid':
89
+ this.applyCyberGridPattern(opacity);
90
+ break;
91
+ case 'dots':
92
+ this.applyDotsPattern(opacity);
93
+ break;
94
+ case 'grass':
95
+ this.applyGrassPattern(opacity);
96
+ break;
97
+ case 'aero-waves':
98
+ this.applyAeroWavesPattern(opacity);
99
+ break;
100
+ case 'mesh-gradient':
101
+ this.applyMeshGradientPattern(opacity);
102
+ break;
103
+ default:
104
+ this.clearWallpaper();
105
+ }
106
+ }
107
+ applyHeartsPattern(opacity) {
108
+ const nativeEl = this.el.nativeElement;
109
+ this.ensureAnimationStyles();
110
+ // Removido backgroundColor fixo para respeitar o do elemento original
111
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cpath d='M50 30c0-10-10-10-10-10s-10 0-10 10 10 20 20 30c10-10 20-20 20-30s0-10-10-10-10 0-10 10z' fill='%23ff85a2' fill-opacity='${opacity * 0.2}'/%3E%3Cpath d='M10 70c0-5-5-5-5-5s-5 0-5 5 5 10 10 15c5-5 10-10 10-15s0-5-5-5-5 0-5 5z' fill='%23ffb3c6' fill-opacity='${opacity * 0.15}'/%3E%3Cpath d='M80 80c0-7-7-7-7-7s-7 0-7 7 7 14 14 21c7-7 14-14 14-21s0-7-7-7-7 0-7 7z' fill='%23a2d2ff' fill-opacity='${opacity * 0.1}'/%3E%3C/svg%3E")`);
112
+ this.renderer.setStyle(nativeEl, 'backgroundRepeat', 'repeat');
113
+ this.renderer.setStyle(nativeEl, 'animation', 'fy-wallpaper-diagonal 20s linear infinite');
114
+ }
115
+ applyGeometricPattern(opacity) {
116
+ const nativeEl = this.el.nativeElement;
117
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M30 0l30 30-30 30L0 30z' fill='%233b82f6' fill-opacity='${opacity * 0.1}'/%3E%3C/svg%3E")`);
118
+ this.renderer.setStyle(nativeEl, 'backgroundRepeat', 'repeat');
119
+ }
120
+ applyPineTreesPattern(opacity) {
121
+ const nativeEl = this.el.nativeElement;
122
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath d='M40 10l15 30H25l15-30zM40 30l20 40H20l20-40z' fill='%232f5233' fill-opacity='${opacity * 0.15}'/%3E%3C/svg%3E")`);
123
+ this.renderer.setStyle(nativeEl, 'backgroundRepeat', 'repeat');
124
+ this.ensureAnimationStyles();
125
+ this.renderer.setStyle(nativeEl, 'animation', 'fy-wallpaper-diagonal 30s linear infinite');
126
+ }
127
+ applyCyberGridPattern(opacity) {
128
+ const nativeEl = this.el.nativeElement;
129
+ // Reduzida a intensidade da linha (0.15) para não escurecer demais o conteúdo
130
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `linear-gradient(rgba(34, 197, 94, ${opacity * 0.15}) 1px, transparent 1px), linear-gradient(90deg, rgba(34, 197, 94, ${opacity * 0.15}) 1px, transparent 1px)`);
131
+ this.renderer.setStyle(nativeEl, 'backgroundSize', '40px 40px');
132
+ }
133
+ applyDotsPattern(opacity) {
134
+ const nativeEl = this.el.nativeElement;
135
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `radial-gradient(circle, rgba(0,0,0,${opacity * 0.1}) 1px, transparent 1px)`);
136
+ this.renderer.setStyle(nativeEl, 'backgroundSize', '20px 20px');
137
+ }
138
+ applyGrassPattern(opacity) {
139
+ const nativeEl = this.el.nativeElement;
140
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M20 40c0-10 5-15 10-20M20 40c0-10-5-15-10-20' stroke='%2334d399' stroke-width='1' fill='none' stroke-opacity='${opacity * 0.3}'/%3E%3C/svg%3E")`);
141
+ this.renderer.setStyle(nativeEl, 'backgroundRepeat', 'repeat');
142
+ }
143
+ applyAeroWavesPattern(opacity) {
144
+ const nativeEl = this.el.nativeElement;
145
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `linear-gradient(135deg, rgba(255,255,255,${opacity * 0.2}) 0%, transparent 50%, rgba(255,255,255,${opacity * 0.2}) 100%)`);
146
+ this.renderer.setStyle(nativeEl, 'backgroundSize', '200% 200%');
147
+ this.ensureAnimationStyles();
148
+ this.renderer.setStyle(nativeEl, 'animation', 'fy-wallpaper-diagonal 15s ease infinite');
149
+ }
150
+ applyMeshGradientPattern(opacity) {
151
+ const nativeEl = this.el.nativeElement;
152
+ this.renderer.setStyle(nativeEl, 'backgroundImage', `radial-gradient(at 0% 0%, rgba(0, 122, 255, ${opacity * 0.15}) 0px, transparent 50%), radial-gradient(at 100% 100%, rgba(82, 212, 255, ${opacity * 0.15}) 0px, transparent 50%)`);
153
+ }
154
+ ensureAnimationStyles() {
155
+ if (!isPlatformBrowser(this.platformId))
156
+ return;
157
+ if (this.document.getElementById('fy-wallpaper-styles'))
158
+ return;
159
+ const style = this.document.createElement('style');
160
+ style.id = 'fy-wallpaper-styles';
161
+ style.innerHTML = `
162
+ @keyframes fy-wallpaper-diagonal {
163
+ from { background-position: 0 0; }
164
+ to { background-position: 200px 200px; }
165
+ }
166
+ `;
167
+ this.document.head.appendChild(style);
168
+ }
169
+ clearWallpaper() {
170
+ const nativeEl = this.el.nativeElement;
171
+ this.renderer.removeStyle(nativeEl, 'backgroundImage');
172
+ this.renderer.removeStyle(nativeEl, 'backgroundRepeat');
173
+ this.renderer.removeStyle(nativeEl, 'animation');
174
+ }
175
+ };
176
+ __decorate([
177
+ Input('fyWallpaper'),
178
+ __metadata("design:type", Object)
179
+ ], FyWallpaperDirective.prototype, "wallpaperName", void 0);
180
+ __decorate([
181
+ Input(),
182
+ __metadata("design:type", Number)
183
+ ], FyWallpaperDirective.prototype, "wallpaperOpacity", void 0);
184
+ __decorate([
185
+ Input(),
186
+ __metadata("design:type", Boolean)
187
+ ], FyWallpaperDirective.prototype, "wallpaperEnabled", void 0);
188
+ FyWallpaperDirective = __decorate([
189
+ Directive({
190
+ selector: '[fyWallpaper]',
191
+ standalone: true
192
+ }),
193
+ __metadata("design:paramtypes", [])
194
+ ], FyWallpaperDirective);
195
+ export { FyWallpaperDirective };
@@ -0,0 +1 @@
1
+ export declare function registerConfettiPlugin(): void;