@salas-ds/cli 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/index.js +296 -94
  2. package/package.json +4 -5
  3. package/templates/angular/accordion/accordion-content.component.ts +9 -0
  4. package/templates/angular/accordion/accordion-item.component.ts +138 -0
  5. package/templates/angular/accordion/accordion-trigger.component.ts +9 -0
  6. package/templates/angular/accordion/accordion.component.ts +120 -0
  7. package/templates/angular/accordion/accordion.module.ts +21 -0
  8. package/templates/angular/autocomplete/autocomplete.component.ts +707 -0
  9. package/templates/angular/autocomplete/autocomplete.module.ts +8 -0
  10. package/templates/angular/avatar/avatar-badge.component.ts +18 -0
  11. package/templates/angular/avatar/avatar-fallback.component.ts +39 -0
  12. package/templates/angular/avatar/avatar-group-count.component.ts +46 -0
  13. package/templates/angular/avatar/avatar-group.component.ts +33 -0
  14. package/templates/angular/avatar/avatar-image.component.ts +57 -0
  15. package/templates/angular/avatar/avatar.component.ts +73 -0
  16. package/templates/angular/avatar/avatar.module.ts +27 -0
  17. package/templates/angular/badge/badge.component.ts +84 -0
  18. package/templates/angular/badge/badge.module.ts +9 -0
  19. package/templates/angular/button/button.component.ts +24 -4
  20. package/templates/angular/card/card.component.ts +100 -0
  21. package/templates/angular/card/card.module.ts +8 -0
  22. package/templates/angular/checkbox/checkbox.component.ts +172 -0
  23. package/templates/angular/checkbox/checkbox.module.ts +8 -0
  24. package/templates/angular/datepicker/datepicker.component.ts +660 -0
  25. package/templates/angular/datepicker/datepicker.module.ts +8 -0
  26. package/templates/angular/dialog/dialog-content.component.ts +9 -0
  27. package/templates/angular/dialog/dialog-description.component.ts +17 -0
  28. package/templates/angular/dialog/dialog-footer.component.ts +17 -0
  29. package/templates/angular/dialog/dialog-header.component.ts +14 -0
  30. package/templates/angular/dialog/dialog-title.component.ts +18 -0
  31. package/templates/angular/dialog/dialog-trigger.component.ts +9 -0
  32. package/templates/angular/dialog/dialog.component.ts +212 -0
  33. package/templates/angular/dialog/dialog.module.ts +31 -0
  34. package/templates/angular/input/input.component.ts +229 -0
  35. package/templates/angular/input/input.module.ts +8 -0
  36. package/templates/angular/scroll-area/scroll-area.component.ts +72 -0
  37. package/templates/angular/scroll-area/scroll-area.module.ts +9 -0
  38. package/templates/angular/scroll-area/scroll-bar.component.ts +15 -0
  39. package/templates/angular/select/select.component.ts +292 -0
  40. package/templates/angular/select/select.module.ts +8 -0
  41. package/templates/angular/separator/separator.component.ts +63 -0
  42. package/templates/angular/separator/separator.module.ts +9 -0
  43. package/templates/angular/sheet/sheet-content.component.ts +13 -0
  44. package/templates/angular/sheet/sheet-description.component.ts +29 -0
  45. package/templates/angular/sheet/sheet-footer.component.ts +27 -0
  46. package/templates/angular/sheet/sheet-header.component.ts +26 -0
  47. package/templates/angular/sheet/sheet-title.component.ts +31 -0
  48. package/templates/angular/sheet/sheet-trigger.component.ts +11 -0
  49. package/templates/angular/sheet/sheet.component.ts +251 -0
  50. package/templates/angular/sheet/sheet.module.ts +30 -0
  51. package/templates/angular/sidebar/sidebar-content.component.ts +25 -0
  52. package/templates/angular/sidebar/sidebar-footer.component.ts +20 -0
  53. package/templates/angular/sidebar/sidebar-group-content.component.ts +16 -0
  54. package/templates/angular/sidebar/sidebar-group-label.component.ts +20 -0
  55. package/templates/angular/sidebar/sidebar-group.component.ts +14 -0
  56. package/templates/angular/sidebar/sidebar-header.component.ts +25 -0
  57. package/templates/angular/sidebar/sidebar-inset.component.ts +85 -0
  58. package/templates/angular/sidebar/sidebar-menu-button.component.ts +75 -0
  59. package/templates/angular/sidebar/sidebar-menu-item.component.ts +14 -0
  60. package/templates/angular/sidebar/sidebar-menu.component.ts +19 -0
  61. package/templates/angular/sidebar/sidebar-provider.component.ts +77 -0
  62. package/templates/angular/sidebar/sidebar-trigger.component.ts +58 -0
  63. package/templates/angular/sidebar/sidebar.component.ts +228 -0
  64. package/templates/angular/sidebar/sidebar.module.ts +48 -0
  65. package/templates/angular/sidebar/sidebar.service.ts +93 -0
  66. package/templates/angular/skeleton/skeleton.component.ts +44 -0
  67. package/templates/angular/skeleton/skeleton.module.ts +8 -0
  68. package/templates/angular/spinner/spinner.component.ts +75 -0
  69. package/templates/angular/spinner/spinner.module.ts +8 -0
  70. package/templates/angular/table/table-body.component.ts +23 -0
  71. package/templates/angular/table/table-caption.component.ts +29 -0
  72. package/templates/angular/table/table-cell.component.ts +49 -0
  73. package/templates/angular/table/table-footer.component.ts +32 -0
  74. package/templates/angular/table/table-head.component.ts +48 -0
  75. package/templates/angular/table/table-header.component.ts +28 -0
  76. package/templates/angular/table/table-row.component.ts +36 -0
  77. package/templates/angular/table/table.component.ts +35 -0
  78. package/templates/angular/table/table.module.ts +33 -0
  79. package/templates/angular/tabs/tabs-content.component.ts +71 -0
  80. package/templates/angular/tabs/tabs-list.component.ts +70 -0
  81. package/templates/angular/tabs/tabs-trigger.component.ts +149 -0
  82. package/templates/angular/tabs/tabs.component.ts +155 -0
  83. package/templates/angular/tabs/tabs.module.ts +21 -0
  84. package/templates/angular/textarea/textarea.component.ts +268 -0
  85. package/templates/angular/textarea/textarea.module.ts +8 -0
  86. package/templates/angular/toast/toast.module.ts +8 -0
  87. package/templates/angular/toast/toast.service.ts +104 -0
  88. package/templates/angular/toast/toaster.component.ts +329 -0
  89. package/templates/angular/tooltip/tooltip-content.component.ts +43 -0
  90. package/templates/angular/tooltip/tooltip-trigger.component.ts +13 -0
  91. package/templates/angular/tooltip/tooltip.component.ts +243 -0
  92. package/templates/angular/tooltip/tooltip.module.ts +10 -0
@@ -0,0 +1,268 @@
1
+ import { Component, Input, forwardRef, ViewChild, ElementRef, AfterViewInit, ViewEncapsulation } from '@angular/core';
2
+ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3
+ import { cn } from '../utils';
4
+ import { LucideAngularModule } from 'lucide-angular';
5
+ import { CommonModule } from '@angular/common';
6
+
7
+ /**
8
+ * Textarea component types
9
+ */
10
+
11
+ export type TextareaSize = 'sm' | 'md' | 'lg';
12
+ export type TextareaVariant = 'default' | 'error' | 'success';
13
+
14
+ export interface TextareaProps {
15
+ size?: TextareaSize;
16
+ variant?: TextareaVariant;
17
+ disabled?: boolean;
18
+ readonly?: boolean;
19
+ required?: boolean;
20
+ placeholder?: string;
21
+ value?: string;
22
+ name?: string;
23
+ id?: string;
24
+ rows?: number;
25
+ cols?: number;
26
+ maxlength?: number;
27
+ minlength?: number;
28
+ }
29
+
30
+
31
+ @Component({
32
+ selector: 'salas-textarea',
33
+ standalone: true,
34
+ imports: [CommonModule, LucideAngularModule],
35
+ encapsulation: ViewEncapsulation.None,
36
+ template: `
37
+ <div [class]="wrapperClasses">
38
+ <textarea
39
+ [id]="id"
40
+ [name]="name"
41
+ [placeholder]="placeholder"
42
+ [disabled]="disabled"
43
+ [readonly]="readonly"
44
+ [required]="required"
45
+ [rows]="rows"
46
+ [attr.cols]="cols ?? null"
47
+ [attr.maxlength]="maxlength ?? null"
48
+ [attr.minlength]="minlength ?? null"
49
+ [class]="textareaClasses"
50
+ (input)="onInput($event)"
51
+ (blur)="onBlur()"
52
+ (focus)="onFocus()"
53
+ [attr.aria-invalid]="variant === 'error'"
54
+ [attr.aria-describedby]="id ? id + '-hint' : null"
55
+ #textareaRef
56
+ ></textarea>
57
+ @if (variant === 'error') {
58
+ <lucide-icon name="x" [size]="iconSize" class="salas-textarea-icon salas-textarea-icon--error" />
59
+ }
60
+ @if (variant === 'success') {
61
+ <lucide-icon name="check" [size]="iconSize" class="salas-textarea-icon salas-textarea-icon--success" />
62
+ }
63
+ </div>
64
+ `,
65
+ styles: [`
66
+ .salas-textarea-wrapper {
67
+ position: relative;
68
+ display: inline-block;
69
+ width: 100%;
70
+ }
71
+
72
+ .salas-textarea {
73
+ width: 100%;
74
+ border-radius: 0.375rem;
75
+ border: 1px solid var(--salas-gray-300);
76
+ background-color: white;
77
+ padding: 0.5rem 0.75rem;
78
+ font-size: 0.875rem;
79
+ line-height: 1.5;
80
+ transition: all 0.2s;
81
+ outline: none;
82
+ resize: vertical;
83
+ font-family: inherit;
84
+ min-height: 5rem;
85
+ }
86
+
87
+ .salas-textarea::placeholder {
88
+ color: var(--salas-gray-400);
89
+ }
90
+
91
+ .salas-textarea:focus {
92
+ border-color: var(--salas-primary-500);
93
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
94
+ }
95
+
96
+ .salas-textarea:disabled {
97
+ background-color: var(--salas-gray-50);
98
+ cursor: not-allowed;
99
+ opacity: 0.6;
100
+ resize: none;
101
+ }
102
+
103
+ .salas-textarea:read-only {
104
+ background-color: var(--salas-gray-50);
105
+ cursor: default;
106
+ resize: none;
107
+ }
108
+
109
+ /* Variants */
110
+ .salas-textarea--error {
111
+ border-color: var(--salas-destructive-500);
112
+ }
113
+
114
+ .salas-textarea--error:focus {
115
+ border-color: var(--salas-destructive-500);
116
+ box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
117
+ }
118
+
119
+ .salas-textarea--success {
120
+ border-color: var(--salas-success-500);
121
+ }
122
+
123
+ .salas-textarea--success:focus {
124
+ border-color: var(--salas-success-500);
125
+ box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
126
+ }
127
+
128
+ /* Sizes */
129
+ .salas-textarea--sm {
130
+ padding: 0.375rem 0.625rem;
131
+ font-size: 0.8125rem;
132
+ min-height: 4rem;
133
+ }
134
+
135
+ .salas-textarea--md {
136
+ padding: 0.5rem 0.75rem;
137
+ min-height: 5rem;
138
+ }
139
+
140
+ .salas-textarea--lg {
141
+ padding: 0.625rem 1rem;
142
+ font-size: 1rem;
143
+ min-height: 6rem;
144
+ }
145
+
146
+ .salas-textarea-icon {
147
+ position: absolute;
148
+ right: 0.75rem;
149
+ top: 0.75rem;
150
+ pointer-events: none;
151
+ }
152
+
153
+ .salas-textarea-icon--error {
154
+ color: var(--salas-destructive-500);
155
+ }
156
+
157
+ .salas-textarea-icon--success {
158
+ color: var(--salas-success-500);
159
+ }
160
+
161
+ /* Dark theme */
162
+ [data-theme='dark'] .salas-textarea {
163
+ background-color: var(--salas-gray-900);
164
+ border-color: var(--salas-gray-700);
165
+ color: var(--salas-text, #fafafa);
166
+ }
167
+
168
+ [data-theme='dark'] .salas-textarea::placeholder {
169
+ color: var(--salas-gray-500);
170
+ }
171
+
172
+ [data-theme='dark'] .salas-textarea:focus {
173
+ border-color: var(--salas-primary-500);
174
+ }
175
+
176
+ [data-theme='dark'] .salas-textarea:disabled {
177
+ background-color: var(--salas-gray-800);
178
+ opacity: 0.6;
179
+ }
180
+
181
+ [data-theme='dark'] .salas-textarea:read-only {
182
+ background-color: var(--salas-gray-800);
183
+ }
184
+
185
+ [data-theme='dark'] .salas-textarea--error {
186
+ border-color: var(--salas-destructive-500);
187
+ }
188
+
189
+ [data-theme='dark'] .salas-textarea--success {
190
+ border-color: var(--salas-success-500);
191
+ }
192
+ `],
193
+ providers: [
194
+ {
195
+ provide: NG_VALUE_ACCESSOR,
196
+ useExisting: forwardRef(() => SalasTextareaComponent),
197
+ multi: true,
198
+ },
199
+ ],
200
+ })
201
+ export class SalasTextareaComponent implements ControlValueAccessor, TextareaProps, AfterViewInit {
202
+ @ViewChild('textareaRef', { static: false }) textareaRef?: ElementRef<HTMLTextAreaElement>;
203
+
204
+ @Input() size: TextareaSize = 'md';
205
+ @Input() variant: TextareaVariant = 'default';
206
+ @Input() disabled = false;
207
+ @Input() readonly = false;
208
+ @Input() required = false;
209
+ @Input() placeholder = '';
210
+ @Input() name = '';
211
+ @Input() id = '';
212
+ @Input() rows = 4;
213
+ @Input() cols?: number;
214
+ @Input() maxlength?: number;
215
+ @Input() minlength?: number;
216
+
217
+ private onChange: (value: string) => void = () => {};
218
+ private onTouched: () => void = () => {};
219
+
220
+ get wrapperClasses(): string {
221
+ return cn('salas-textarea-wrapper');
222
+ }
223
+
224
+ get textareaClasses(): string {
225
+ return cn(
226
+ 'salas-textarea',
227
+ `salas-textarea--${this.size}`,
228
+ this.variant !== 'default' && `salas-textarea--${this.variant}`
229
+ );
230
+ }
231
+
232
+ get iconSize(): number {
233
+ return this.size === 'sm' ? 16 : this.size === 'lg' ? 20 : 18;
234
+ }
235
+
236
+ ngAfterViewInit(): void {}
237
+
238
+ onInput(event: Event): void {
239
+ const target = event.target as HTMLTextAreaElement;
240
+ this.onChange(target.value);
241
+ }
242
+
243
+ onBlur(): void {
244
+ this.onTouched();
245
+ }
246
+
247
+ onFocus(): void {}
248
+
249
+ // ControlValueAccessor
250
+ writeValue(value: string | null | undefined): void {
251
+ const newValue = value ?? '';
252
+ if (this.textareaRef?.nativeElement) {
253
+ this.textareaRef.nativeElement.value = newValue;
254
+ }
255
+ }
256
+
257
+ registerOnChange(fn: (value: string) => void): void {
258
+ this.onChange = fn;
259
+ }
260
+
261
+ registerOnTouched(fn: () => void): void {
262
+ this.onTouched = fn;
263
+ }
264
+
265
+ setDisabledState(isDisabled: boolean): void {
266
+ this.disabled = isDisabled;
267
+ }
268
+ }
@@ -0,0 +1,8 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { SalasTextareaComponent } from './textarea.component';
3
+
4
+ @NgModule({
5
+ imports: [SalasTextareaComponent],
6
+ exports: [SalasTextareaComponent],
7
+ })
8
+ export class SalasTextareaModule {}
@@ -0,0 +1,8 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { SalasToasterComponent } from './toaster.component';
3
+
4
+ @NgModule({
5
+ imports: [SalasToasterComponent],
6
+ exports: [SalasToasterComponent],
7
+ })
8
+ export class SalasToastModule {}
@@ -0,0 +1,104 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ export type ToastType = 'default' | 'success' | 'info' | 'warning' | 'error';
4
+
5
+ export type ToastPosition =
6
+ | 'top-left'
7
+ | 'top-center'
8
+ | 'top-right'
9
+ | 'bottom-left'
10
+ | 'bottom-center'
11
+ | 'bottom-right';
12
+
13
+ export interface ToastData {
14
+ id: string;
15
+ type: ToastType;
16
+ title: string;
17
+ description?: string;
18
+ duration?: number;
19
+ dismissible?: boolean;
20
+ action?: {
21
+ label: string;
22
+ onClick: () => void;
23
+ };
24
+ }
25
+
26
+ export interface ToasterProps {
27
+ position?: ToastPosition;
28
+ duration?: number;
29
+ richColors?: boolean;
30
+ }
31
+
32
+
33
+ let toastIdCounter = 0;
34
+
35
+ @Injectable({ providedIn: 'root' })
36
+ export class SalasToastService {
37
+ toasts: ToastData[] = [];
38
+ position: ToastPosition = 'bottom-right';
39
+ defaultDuration = 4000;
40
+
41
+ private listeners: Array<() => void> = [];
42
+
43
+ onChange(fn: () => void): () => void {
44
+ this.listeners.push(fn);
45
+ return () => {
46
+ this.listeners = this.listeners.filter((l) => l !== fn);
47
+ };
48
+ }
49
+
50
+ private notify(): void {
51
+ this.listeners.forEach((fn) => fn());
52
+ }
53
+
54
+ private addToast(type: ToastType, title: string, options?: Partial<Omit<ToastData, 'id' | 'type' | 'title'>>): string {
55
+ const id = `toast-${++toastIdCounter}`;
56
+ const toast: ToastData = {
57
+ id,
58
+ type,
59
+ title,
60
+ description: options?.description,
61
+ duration: options?.duration ?? this.defaultDuration,
62
+ dismissible: options?.dismissible ?? true,
63
+ action: options?.action,
64
+ };
65
+ this.toasts = [...this.toasts, toast];
66
+ this.notify();
67
+
68
+ if (toast.duration && toast.duration > 0) {
69
+ setTimeout(() => this.dismiss(id), toast.duration);
70
+ }
71
+
72
+ return id;
73
+ }
74
+
75
+ toast(title: string, options?: Partial<Omit<ToastData, 'id' | 'type' | 'title'>>): string {
76
+ return this.addToast('default', title, options);
77
+ }
78
+
79
+ success(title: string, options?: Partial<Omit<ToastData, 'id' | 'type' | 'title'>>): string {
80
+ return this.addToast('success', title, options);
81
+ }
82
+
83
+ info(title: string, options?: Partial<Omit<ToastData, 'id' | 'type' | 'title'>>): string {
84
+ return this.addToast('info', title, options);
85
+ }
86
+
87
+ warning(title: string, options?: Partial<Omit<ToastData, 'id' | 'type' | 'title'>>): string {
88
+ return this.addToast('warning', title, options);
89
+ }
90
+
91
+ error(title: string, options?: Partial<Omit<ToastData, 'id' | 'type' | 'title'>>): string {
92
+ return this.addToast('error', title, options);
93
+ }
94
+
95
+ dismiss(id: string): void {
96
+ this.toasts = this.toasts.filter((t) => t.id !== id);
97
+ this.notify();
98
+ }
99
+
100
+ dismissAll(): void {
101
+ this.toasts = [];
102
+ this.notify();
103
+ }
104
+ }