angular-matecu 4.0.7 → 4.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.
- package/README.md +347 -130
- package/ng-package.json +7 -0
- package/package.json +6 -21
- package/src/lib/components/matecu-alert-box/matecu-alert-box.component.html +11 -0
- package/src/lib/components/matecu-alert-box/matecu-alert-box.component.scss +39 -0
- package/src/lib/components/matecu-alert-box/matecu-alert-box.component.spec.ts +25 -0
- package/src/lib/components/matecu-alert-box/matecu-alert-box.component.ts +60 -0
- package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.html +24 -0
- package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.scss +5 -0
- package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.spec.ts +25 -0
- package/src/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.ts +53 -0
- package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.html +10 -0
- package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.scss +34 -0
- package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.spec.ts +25 -0
- package/src/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.ts +45 -0
- package/src/lib/components/matecu-autocomplete/matecu-autocomplete.html +36 -0
- package/src/lib/components/matecu-autocomplete/matecu-autocomplete.scss +56 -0
- package/src/lib/components/matecu-autocomplete/matecu-autocomplete.spec.ts +23 -0
- package/src/lib/components/matecu-autocomplete/matecu-autocomplete.ts +336 -0
- package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.html +64 -0
- package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.scss +23 -0
- package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.spec.ts +23 -0
- package/src/lib/components/matecu-autocomplete-multiple/matecu-autocomplete-multiple.ts +314 -0
- package/src/lib/components/matecu-file-input/matecu-file-input-customization.md +284 -0
- package/src/lib/components/matecu-file-input/matecu-file-input.example.md +228 -0
- package/src/lib/components/matecu-file-input/matecu-file-input.html +128 -0
- package/src/lib/components/matecu-file-input/matecu-file-input.scss +461 -0
- package/src/lib/components/matecu-file-input/matecu-file-input.spec.ts +340 -0
- package/src/lib/components/matecu-file-input/matecu-file-input.ts +438 -0
- package/src/lib/components/matecu-spinner/matecu-spinner.component.css +15 -0
- package/src/lib/components/matecu-spinner/matecu-spinner.component.html +44 -0
- package/src/lib/components/matecu-spinner/matecu-spinner.component.spec.ts +25 -0
- package/src/lib/components/matecu-spinner/matecu-spinner.component.ts +54 -0
- package/src/lib/components/matecu-spinner/spinner-loader.component.scss +13 -0
- package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.html +1 -0
- package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.scss +19 -0
- package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.spec.ts +25 -0
- package/src/lib/components/matecu-topbar-action/matecu-topbar-action.component.ts +14 -0
- package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.html +1 -0
- package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.scss +14 -0
- package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.spec.ts +25 -0
- package/src/lib/components/matecu-topbar-body/matecu-topbar-body.component.ts +11 -0
- package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.html +3 -0
- package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.scss +19 -0
- package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.spec.ts +25 -0
- package/src/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.ts +31 -0
- package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.html +1 -0
- package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.scss +8 -0
- package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.spec.ts +23 -0
- package/src/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.ts +11 -0
- package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.html +9 -0
- package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.scss +34 -0
- package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.spec.ts +23 -0
- package/src/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.ts +18 -0
- package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.html +7 -0
- package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.scss +49 -0
- package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.spec.ts +25 -0
- package/src/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.ts +112 -0
- package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.html +20 -0
- package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.scss +90 -0
- package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.spec.ts +25 -0
- package/src/lib/components/matecu-topbar-search/matecu-topbar-search.component.ts +92 -0
- package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.html +1 -0
- package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.scss +91 -0
- package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.spec.ts +25 -0
- package/src/lib/components/matecu-topbar-title/matecu-topbar-title.component.ts +14 -0
- package/src/lib/modules/matecu-alert-box/matecu-alert-box.module.ts +16 -0
- package/src/lib/modules/matecu-spinner/matecu-spinner.module.ts +14 -0
- package/src/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.ts +45 -0
- package/src/lib/services/matecu-snack-bar.service.spec.ts +16 -0
- package/src/lib/services/matecu-snack-bar.service.ts +66 -0
- package/src/lib/services/matecu-spinner.service.spec.ts +16 -0
- package/src/lib/services/matecu-spinner.service.ts +39 -0
- package/src/lib/types/matecu-alert-dialog.ts +10 -0
- package/{lib/types/matecu-alert-snackbar.d.ts → src/lib/types/matecu-alert-snackbar.ts} +5 -4
- package/src/lib/types/matecu-altert-box-type.ts +6 -0
- package/src/lib/types/matecu-autocomplete.ts +5 -0
- package/{public-api.d.ts → src/public-api.ts} +14 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/CHANGELOG.md +0 -22
- package/esm2022/angular-matecu.mjs +0 -5
- package/esm2022/lib/components/matecu-alert-box/matecu-alert-box.component.mjs +0 -67
- package/esm2022/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.mjs +0 -54
- package/esm2022/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.mjs +0 -43
- package/esm2022/lib/components/matecu-spinner/matecu-spinner.component.mjs +0 -58
- package/esm2022/lib/components/matecu-topbar-action/matecu-topbar-action.component.mjs +0 -18
- package/esm2022/lib/components/matecu-topbar-body/matecu-topbar-body.component.mjs +0 -17
- package/esm2022/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.mjs +0 -43
- package/esm2022/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.mjs +0 -12
- package/esm2022/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.mjs +0 -29
- package/esm2022/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.mjs +0 -112
- package/esm2022/lib/components/matecu-topbar-search/matecu-topbar-search.component.mjs +0 -93
- package/esm2022/lib/components/matecu-topbar-title/matecu-topbar-title.component.mjs +0 -18
- package/esm2022/lib/modules/matecu-alert-box/matecu-alert-box.module.mjs +0 -24
- package/esm2022/lib/modules/matecu-spinner/matecu-spinner.module.mjs +0 -22
- package/esm2022/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.mjs +0 -83
- package/esm2022/lib/services/matecu-snack-bar.service.mjs +0 -66
- package/esm2022/lib/services/matecu-spinner.service.mjs +0 -44
- package/esm2022/lib/types/matecu-alert-dialog.mjs +0 -2
- package/esm2022/lib/types/matecu-alert-snackbar.mjs +0 -2
- package/esm2022/lib/types/matecu-altert-box-type.mjs +0 -8
- package/esm2022/public-api.mjs +0 -32
- package/fesm2022/angular-matecu.mjs +0 -735
- package/fesm2022/angular-matecu.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/components/matecu-alert-box/matecu-alert-box.component.d.ts +0 -19
- package/lib/components/matecu-alert-dialog/matecu-alert-dialog.component.d.ts +0 -22
- package/lib/components/matecu-alert-snack-bar/matecu-alert-snack-bar.component.d.ts +0 -20
- package/lib/components/matecu-spinner/matecu-spinner.component.d.ts +0 -20
- package/lib/components/matecu-topbar-action/matecu-topbar-action.component.d.ts +0 -9
- package/lib/components/matecu-topbar-body/matecu-topbar-body.component.d.ts +0 -6
- package/lib/components/matecu-topbar-fab/matecu-topbar-fab.component.d.ts +0 -12
- package/lib/components/matecu-topbar-header-column/matecu-topbar-header-column.component.d.ts +0 -5
- package/lib/components/matecu-topbar-header-row/matecu-topbar-header-row.component.d.ts +0 -8
- package/lib/components/matecu-topbar-layout/matecu-topbar-layout.component.d.ts +0 -27
- package/lib/components/matecu-topbar-search/matecu-topbar-search.component.d.ts +0 -27
- package/lib/components/matecu-topbar-title/matecu-topbar-title.component.d.ts +0 -9
- package/lib/modules/matecu-alert-box/matecu-alert-box.module.d.ts +0 -14
- package/lib/modules/matecu-spinner/matecu-spinner.module.d.ts +0 -8
- package/lib/modules/matecu-topbar-layout/matecu-topbar-layout.module.d.ts +0 -19
- package/lib/services/matecu-snack-bar.service.d.ts +0 -17
- package/lib/services/matecu-spinner.service.d.ts +0 -15
- package/lib/types/matecu-alert-dialog.d.ts +0 -9
- package/lib/types/matecu-altert-box-type.d.ts +0 -6
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
Input,
|
|
4
|
+
Output,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
forwardRef,
|
|
7
|
+
OnDestroy,
|
|
8
|
+
signal,
|
|
9
|
+
computed,
|
|
10
|
+
effect,
|
|
11
|
+
inject,
|
|
12
|
+
OnInit,
|
|
13
|
+
Injector,
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
ControlValueAccessor,
|
|
18
|
+
NG_VALUE_ACCESSOR,
|
|
19
|
+
FormControl,
|
|
20
|
+
ReactiveFormsModule,
|
|
21
|
+
} from '@angular/forms';
|
|
22
|
+
|
|
23
|
+
import { MatFormFieldControl } from '@angular/material/form-field';
|
|
24
|
+
import { NgControl } from '@angular/forms';
|
|
25
|
+
import { Subject } from 'rxjs';
|
|
26
|
+
import { CdkDragDrop, DragDropModule, moveItemInArray } from '@angular/cdk/drag-drop';
|
|
27
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
28
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
29
|
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
30
|
+
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
31
|
+
import { CdkFixedSizeVirtualScroll, ScrollingModule } from '@angular/cdk/scrolling';
|
|
32
|
+
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
|
|
33
|
+
|
|
34
|
+
import { ViewChild } from '@angular/core';
|
|
35
|
+
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
|
|
36
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
37
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
38
|
+
import {
|
|
39
|
+
MatecuAutocompleteFilterFn,
|
|
40
|
+
MatecuAutocompleteOption,
|
|
41
|
+
} from '../../types/matecu-autocomplete';
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
selector: 'matecu-autocomplete-multiple',
|
|
45
|
+
standalone: true,
|
|
46
|
+
imports: [
|
|
47
|
+
ReactiveFormsModule,
|
|
48
|
+
MatChipsModule,
|
|
49
|
+
DragDropModule,
|
|
50
|
+
MatIconModule,
|
|
51
|
+
MatProgressSpinnerModule,
|
|
52
|
+
MatAutocompleteModule,
|
|
53
|
+
ScrollingModule,
|
|
54
|
+
MatButtonModule,
|
|
55
|
+
MatTooltipModule,
|
|
56
|
+
],
|
|
57
|
+
templateUrl: './matecu-autocomplete-multiple.html',
|
|
58
|
+
styleUrls: ['./matecu-autocomplete-multiple.scss'],
|
|
59
|
+
providers: [
|
|
60
|
+
{
|
|
61
|
+
provide: NG_VALUE_ACCESSOR,
|
|
62
|
+
useExisting: forwardRef(() => MatecuAutocompleteMultiple),
|
|
63
|
+
multi: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
provide: MatFormFieldControl,
|
|
67
|
+
useExisting: MatecuAutocompleteMultiple,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
})
|
|
71
|
+
export class MatecuAutocompleteMultiple
|
|
72
|
+
implements ControlValueAccessor, MatFormFieldControl<string[]>, OnDestroy, OnInit
|
|
73
|
+
{
|
|
74
|
+
static nextId = 0;
|
|
75
|
+
|
|
76
|
+
// ================= INPUTS =================
|
|
77
|
+
|
|
78
|
+
@Input() placeholder = '';
|
|
79
|
+
@Input() loading = false;
|
|
80
|
+
@Input() searchChangeDebounceTime = 300;
|
|
81
|
+
@Input() enableSelectAll = true;
|
|
82
|
+
@Input() readonly = false;
|
|
83
|
+
@Input() selectAllLabel = 'Select All';
|
|
84
|
+
@Input() clearAllLabel = 'Clear All';
|
|
85
|
+
@Input() showTooltip = true;
|
|
86
|
+
@Input() filterFn: MatecuAutocompleteFilterFn = this.createFilterFn();
|
|
87
|
+
private _options = signal<MatecuAutocompleteOption[]>([]);
|
|
88
|
+
|
|
89
|
+
@Input({ required: true })
|
|
90
|
+
set options(value: MatecuAutocompleteOption[]) {
|
|
91
|
+
this._options.set(value ?? []);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get options() {
|
|
95
|
+
return this._options();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ================= OUTPUT =================
|
|
99
|
+
|
|
100
|
+
@Output() searchChange = new EventEmitter<string>();
|
|
101
|
+
|
|
102
|
+
// ================= INTERNAL CONTROL =================
|
|
103
|
+
|
|
104
|
+
control = new FormControl<string[]>([], { nonNullable: true });
|
|
105
|
+
controlValue$ = toSignal(this.control.valueChanges);
|
|
106
|
+
searchControl = new FormControl<string>('', { nonNullable: true });
|
|
107
|
+
@ViewChild(MatAutocompleteTrigger)
|
|
108
|
+
autocompleteTrigger!: MatAutocompleteTrigger;
|
|
109
|
+
|
|
110
|
+
// ================= SIGNALS =================
|
|
111
|
+
|
|
112
|
+
readonly searchText = signal<string>(''); // 🔥 AHORA SÍ existe correctamente
|
|
113
|
+
|
|
114
|
+
readonly filteredOptions = computed(() => {
|
|
115
|
+
const filter = this.searchText();
|
|
116
|
+
|
|
117
|
+
return this._options().filter(
|
|
118
|
+
(o) => this.filterFn(o[1], filter) && !this.control.value.includes(o[0]),
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
readonly selectedItems = computed(() => {
|
|
123
|
+
const values = this.controlValue$() ?? [];
|
|
124
|
+
return values.map((v) => {
|
|
125
|
+
const found = this._options().find((o) => o[0] === v);
|
|
126
|
+
return {
|
|
127
|
+
value: v,
|
|
128
|
+
label: found ? found[1] : v,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// ================= FORM FIELD CONTROL =================
|
|
134
|
+
|
|
135
|
+
stateChanges = new Subject<void>();
|
|
136
|
+
focused = false;
|
|
137
|
+
controlType = 'autocomplete-multiple';
|
|
138
|
+
id = `autocomplete-multiple-${MatecuAutocompleteMultiple.nextId++}`;
|
|
139
|
+
describedBy = '';
|
|
140
|
+
disabled = false;
|
|
141
|
+
required = false;
|
|
142
|
+
errorState = false;
|
|
143
|
+
private injector: Injector;
|
|
144
|
+
ngControl: NgControl | null = null;
|
|
145
|
+
|
|
146
|
+
get empty() {
|
|
147
|
+
return this.control.value.length === 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
get shouldLabelFloat() {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ================= CONSTRUCTOR =================
|
|
155
|
+
|
|
156
|
+
constructor(injector: Injector) {
|
|
157
|
+
this.injector = injector;
|
|
158
|
+
// Debounce search
|
|
159
|
+
let timeout: any;
|
|
160
|
+
|
|
161
|
+
this.searchControl.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {
|
|
162
|
+
this.searchText.set(value ?? '');
|
|
163
|
+
});
|
|
164
|
+
this.control.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {
|
|
165
|
+
this.onChange(value);
|
|
166
|
+
this.stateChanges.next();
|
|
167
|
+
});
|
|
168
|
+
effect(() => {
|
|
169
|
+
const value = this.searchText();
|
|
170
|
+
|
|
171
|
+
clearTimeout(timeout);
|
|
172
|
+
|
|
173
|
+
timeout = setTimeout(() => {
|
|
174
|
+
this.searchChange.emit(value);
|
|
175
|
+
}, this.searchChangeDebounceTime);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
value: string[] | null = null;
|
|
179
|
+
autofilled?: boolean | undefined;
|
|
180
|
+
userAriaDescribedBy?: string | undefined;
|
|
181
|
+
disableAutomaticLabeling?: boolean | undefined;
|
|
182
|
+
describedByIds?: string[] | undefined;
|
|
183
|
+
|
|
184
|
+
ngOnInit(): void {
|
|
185
|
+
try {
|
|
186
|
+
this.ngControl = this.injector.get(NgControl, null);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
// Ignorar si no se puede obtener NgControl
|
|
189
|
+
this.ngControl = null;
|
|
190
|
+
}
|
|
191
|
+
// Propagar cambios del FormControl interno
|
|
192
|
+
}
|
|
193
|
+
// ================= AUTOCOMPLETE =================
|
|
194
|
+
|
|
195
|
+
selectOption(option: [string, string]) {
|
|
196
|
+
if (this.readonly || this.disabled) return;
|
|
197
|
+
if (!Array.isArray(option)) return;
|
|
198
|
+
if (!this.control.value.includes(option[0])) {
|
|
199
|
+
this.control.setValue([...this.control.value, option[0]]);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// limpiar input correctamente
|
|
203
|
+
this.searchControl.setValue('');
|
|
204
|
+
this.searchText.set('');
|
|
205
|
+
|
|
206
|
+
// cerrar panel
|
|
207
|
+
this.autocompleteTrigger.closePanel();
|
|
208
|
+
}
|
|
209
|
+
displayLabel(option: [string, string]): string {
|
|
210
|
+
return Array.isArray(option) ? option[1] : '';
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// ================= CHIP ACTIONS =================
|
|
214
|
+
|
|
215
|
+
remove(value: string) {
|
|
216
|
+
if (this.readonly || this.disabled) return;
|
|
217
|
+
|
|
218
|
+
this.control.setValue(this.control.value.filter((v) => v !== value));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
selectAll() {
|
|
222
|
+
if (this.readonly || this.disabled) return;
|
|
223
|
+
|
|
224
|
+
const allValues = this._options().map((o) => o[0]);
|
|
225
|
+
|
|
226
|
+
this.control.setValue([...new Set([...this.control.value, ...allValues])]);
|
|
227
|
+
|
|
228
|
+
this.searchControl.setValue('');
|
|
229
|
+
this.searchText.set('');
|
|
230
|
+
|
|
231
|
+
this.autocompleteTrigger.closePanel();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
clearAll(): void {
|
|
235
|
+
if (this.disabled || this.readonly) return;
|
|
236
|
+
|
|
237
|
+
if (this.control.value.length === 0) return;
|
|
238
|
+
|
|
239
|
+
this.control.setValue([]);
|
|
240
|
+
this.searchControl.setValue('');
|
|
241
|
+
this.searchText.set('');
|
|
242
|
+
|
|
243
|
+
this.autocompleteTrigger?.closePanel();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ================= DRAG & DROP =================
|
|
247
|
+
|
|
248
|
+
drop(event: CdkDragDrop<any>) {
|
|
249
|
+
if (this.disabled || this.readonly) return;
|
|
250
|
+
|
|
251
|
+
const current = [...this.control.value];
|
|
252
|
+
moveItemInArray(current, event.previousIndex, event.currentIndex);
|
|
253
|
+
this.control.setValue(current);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ================= KEYBOARD =================
|
|
257
|
+
|
|
258
|
+
onKeyDown(event: KeyboardEvent) {
|
|
259
|
+
if (this.readonly || this.disabled) return;
|
|
260
|
+
|
|
261
|
+
if (event.key === 'Backspace' && !this.searchText() && this.control.value.length > 0) {
|
|
262
|
+
const updated = [...this.control.value];
|
|
263
|
+
updated.pop();
|
|
264
|
+
this.control.setValue(updated);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ================= CVA =================
|
|
269
|
+
|
|
270
|
+
onChange: (value: string[]) => void = () => {};
|
|
271
|
+
onTouched: () => void = () => {};
|
|
272
|
+
|
|
273
|
+
writeValue(value: string[] | null): void {
|
|
274
|
+
this.control.setValue(value ?? [], { emitEvent: false });
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
registerOnChange(fn: any): void {
|
|
278
|
+
this.onChange = fn;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
registerOnTouched(fn: any): void {
|
|
282
|
+
this.onTouched = fn;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
setDisabledState(isDisabled: boolean): void {
|
|
286
|
+
this.disabled = isDisabled;
|
|
287
|
+
|
|
288
|
+
isDisabled
|
|
289
|
+
? this.control.disable({ emitEvent: false })
|
|
290
|
+
: this.control.enable({ emitEvent: false });
|
|
291
|
+
|
|
292
|
+
this.stateChanges.next();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
setDescribedByIds(ids: string[]): void {
|
|
296
|
+
this.describedBy = ids.join(' ');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
onContainerClick() {}
|
|
300
|
+
|
|
301
|
+
ngOnDestroy() {
|
|
302
|
+
this.stateChanges.complete();
|
|
303
|
+
}
|
|
304
|
+
trackByValue = (_: number, item: [string, string]) => item[0];
|
|
305
|
+
openPanel() {
|
|
306
|
+
this.autocompleteTrigger.openPanel();
|
|
307
|
+
setTimeout(() => this.autocompleteTrigger.updatePosition());
|
|
308
|
+
}
|
|
309
|
+
private createFilterFn(): (v1: string, v2: string) => boolean {
|
|
310
|
+
return (v1: string, v2: string): boolean => {
|
|
311
|
+
return v1.toLowerCase().includes(v2.toLowerCase());
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# Matecu File Input - CSS Customization Guide
|
|
2
|
+
|
|
3
|
+
## 🎨 Overview
|
|
4
|
+
|
|
5
|
+
The Matecu File Input component uses CSS custom properties (variables) to make theming and customization easy. All variables use the `--matecu-file-input-*` namespace to prevent conflicts with other components.
|
|
6
|
+
|
|
7
|
+
## 🔧 Available CSS Variables
|
|
8
|
+
|
|
9
|
+
### Color Palette
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
:root {
|
|
13
|
+
/* Base Colors */
|
|
14
|
+
--matecu-file-input-color-primary: #4f46e5;
|
|
15
|
+
--matecu-file-input-color-primary-hover: #4338ca;
|
|
16
|
+
--matecu-file-input-color-success: #10b981;
|
|
17
|
+
--matecu-file-input-color-error: #ef4444;
|
|
18
|
+
--matecu-file-input-color-error-hover: #dc2626;
|
|
19
|
+
--matecu-file-input-color-loading: #8b5cf6;
|
|
20
|
+
--matecu-file-input-color-disabled: #9ca3af;
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Border Colors
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
:root {
|
|
28
|
+
--matecu-file-input-border-default: #e1e5e9;
|
|
29
|
+
--matecu-file-input-border-hover: var(--matecu-file-input-color-primary);
|
|
30
|
+
--matecu-file-input-border-success: var(--matecu-file-input-color-success);
|
|
31
|
+
--matecu-file-input-border-error: var(--matecu-file-input-color-error);
|
|
32
|
+
--matecu-file-input-border-loading: var(--matecu-file-input-color-loading);
|
|
33
|
+
--matecu-file-input-border-separator: #e5e7eb;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Background Colors
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
:root {
|
|
41
|
+
--matecu-file-input-bg-default: #fafbfc;
|
|
42
|
+
--matecu-file-input-bg-hover: #f8faff;
|
|
43
|
+
--matecu-file-input-bg-drag-over: #eef2ff;
|
|
44
|
+
--matecu-file-input-bg-disabled: #f5f5f5;
|
|
45
|
+
--matecu-file-input-bg-success: #f0fdf4;
|
|
46
|
+
--matecu-file-input-bg-error: #fef2f2;
|
|
47
|
+
--matecu-file-input-bg-loading: #faf5ff;
|
|
48
|
+
--matecu-file-input-bg-surface: #ffffff;
|
|
49
|
+
--matecu-file-input-bg-surface-alt: #f3f4f6;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Text Colors
|
|
54
|
+
|
|
55
|
+
```css
|
|
56
|
+
:root {
|
|
57
|
+
--matecu-file-input-text-primary: #111827;
|
|
58
|
+
--matecu-file-input-text-secondary: #374151;
|
|
59
|
+
--matecu-file-input-text-muted: #6b7280;
|
|
60
|
+
--matecu-file-input-text-disabled: #9ca3af;
|
|
61
|
+
--matecu-file-input-text-on-primary: #ffffff;
|
|
62
|
+
--matecu-file-input-text-error: #dc2626;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Button Colors
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
:root {
|
|
70
|
+
--matecu-file-input-button-primary-bg: var(--matecu-file-input-color-primary);
|
|
71
|
+
--matecu-file-input-button-primary-bg-hover: var(--matecu-file-input-color-primary-hover);
|
|
72
|
+
--matecu-file-input-button-primary-text: var(--matecu-file-input-text-on-primary);
|
|
73
|
+
--matecu-file-input-button-danger-bg: var(--matecu-file-input-color-error);
|
|
74
|
+
--matecu-file-input-button-danger-bg-hover: var(--matecu-file-input-color-error-hover);
|
|
75
|
+
--matecu-file-input-button-danger-text: var(--matecu-file-input-text-on-primary);
|
|
76
|
+
--matecu-file-input-button-disabled-bg: var(--matecu-file-input-color-disabled);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Design System
|
|
81
|
+
|
|
82
|
+
```css
|
|
83
|
+
:root {
|
|
84
|
+
/* Shadows */
|
|
85
|
+
--matecu-file-input-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
86
|
+
--matecu-file-input-shadow-md: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
87
|
+
|
|
88
|
+
/* Border Radius */
|
|
89
|
+
--matecu-file-input-border-radius-sm: 4px;
|
|
90
|
+
--matecu-file-input-border-radius-md: 6px;
|
|
91
|
+
--matecu-file-input-border-radius-lg: 8px;
|
|
92
|
+
--matecu-file-input-border-radius-xl: 12px;
|
|
93
|
+
|
|
94
|
+
/* Border Width */
|
|
95
|
+
--matecu-file-input-border-width: 2px;
|
|
96
|
+
|
|
97
|
+
/* Spinner */
|
|
98
|
+
--matecu-file-input-spinner-track: #e5e7eb;
|
|
99
|
+
--matecu-file-input-spinner-fill: var(--matecu-file-input-color-loading);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 🎯 Customization Examples
|
|
104
|
+
|
|
105
|
+
### Dark Theme
|
|
106
|
+
|
|
107
|
+
```css
|
|
108
|
+
.dark-theme {
|
|
109
|
+
--matecu-file-input-color-primary: #818cf8;
|
|
110
|
+
--matecu-file-input-color-primary-hover: #6366f1;
|
|
111
|
+
|
|
112
|
+
--matecu-file-input-bg-default: #1f2937;
|
|
113
|
+
--matecu-file-input-bg-hover: #374151;
|
|
114
|
+
--matecu-file-input-bg-surface: #111827;
|
|
115
|
+
--matecu-file-input-bg-surface-alt: #1f2937;
|
|
116
|
+
|
|
117
|
+
--matecu-file-input-text-primary: #f9fafb;
|
|
118
|
+
--matecu-file-input-text-secondary: #e5e7eb;
|
|
119
|
+
--matecu-file-input-text-muted: #9ca3af;
|
|
120
|
+
|
|
121
|
+
--matecu-file-input-border-default: #374151;
|
|
122
|
+
--matecu-file-input-border-separator: #374151;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Brand Colors (Blue Theme)
|
|
127
|
+
|
|
128
|
+
```css
|
|
129
|
+
.blue-theme {
|
|
130
|
+
--matecu-file-input-color-primary: #3b82f6;
|
|
131
|
+
--matecu-file-input-color-primary-hover: #2563eb;
|
|
132
|
+
--matecu-file-input-color-success: #059669;
|
|
133
|
+
--matecu-file-input-color-error: #dc2626;
|
|
134
|
+
|
|
135
|
+
--matecu-file-input-bg-hover: #dbeafe;
|
|
136
|
+
--matecu-file-input-bg-drag-over: #bfdbfe;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Green Theme
|
|
141
|
+
|
|
142
|
+
```css
|
|
143
|
+
.green-theme {
|
|
144
|
+
--matecu-file-input-color-primary: #059669;
|
|
145
|
+
--matecu-file-input-color-primary-hover: #047857;
|
|
146
|
+
|
|
147
|
+
--matecu-file-input-bg-hover: #d1fae5;
|
|
148
|
+
--matecu-file-input-bg-drag-over: #a7f3d0;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Minimal Theme
|
|
153
|
+
|
|
154
|
+
```css
|
|
155
|
+
.minimal-theme {
|
|
156
|
+
--matecu-file-input-border-radius-sm: 2px;
|
|
157
|
+
--matecu-file-input-border-radius-md: 4px;
|
|
158
|
+
--matecu-file-input-border-radius-lg: 6px;
|
|
159
|
+
--matecu-file-input-border-width: 1px;
|
|
160
|
+
|
|
161
|
+
--matecu-file-input-shadow-sm: none;
|
|
162
|
+
--matecu-file-input-shadow-md: none;
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### High Contrast Theme
|
|
167
|
+
|
|
168
|
+
```css
|
|
169
|
+
.high-contrast-theme {
|
|
170
|
+
--matecu-file-input-color-primary: #0066cc;
|
|
171
|
+
--matecu-file-input-color-error: #d93025;
|
|
172
|
+
--matecu-file-input-color-success: #137333;
|
|
173
|
+
|
|
174
|
+
--matecu-file-input-border-width: 3px;
|
|
175
|
+
--matecu-file-input-text-primary: #000000;
|
|
176
|
+
--matecu-file-input-bg-surface: #ffffff;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 📱 Implementation
|
|
181
|
+
|
|
182
|
+
### Global Customization
|
|
183
|
+
|
|
184
|
+
```css
|
|
185
|
+
/* In your global styles.css */
|
|
186
|
+
:root {
|
|
187
|
+
--matecu-file-input-color-primary: #your-brand-color;
|
|
188
|
+
--matecu-file-input-border-radius-md: 12px;
|
|
189
|
+
/* ... other customizations */
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Component-Specific Customization
|
|
194
|
+
|
|
195
|
+
```css
|
|
196
|
+
/* Target specific component instance */
|
|
197
|
+
.my-custom-file-input {
|
|
198
|
+
--matecu-file-input-color-primary: #ff6b35;
|
|
199
|
+
--matecu-file-input-bg-hover: #ffebe6;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```html
|
|
204
|
+
<!-- HTML -->
|
|
205
|
+
<matecu-file-input class="my-custom-file-input"> </matecu-file-input>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Angular Component Customization
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// In your component
|
|
212
|
+
@Component({
|
|
213
|
+
selector: 'app-upload',
|
|
214
|
+
template: ` <matecu-file-input class="branded-upload" [multiple]="true"> </matecu-file-input> `,
|
|
215
|
+
styles: [
|
|
216
|
+
`
|
|
217
|
+
.branded-upload {
|
|
218
|
+
--matecu-file-input-color-primary: #your-primary-color;
|
|
219
|
+
--matecu-file-input-color-success: #your-success-color;
|
|
220
|
+
--matecu-file-input-border-radius-lg: 16px;
|
|
221
|
+
}
|
|
222
|
+
`,
|
|
223
|
+
],
|
|
224
|
+
})
|
|
225
|
+
export class UploadComponent {}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### SCSS/Sass Variables
|
|
229
|
+
|
|
230
|
+
```scss
|
|
231
|
+
// Define your theme variables
|
|
232
|
+
$primary-color: #6366f1;
|
|
233
|
+
$success-color: #10b981;
|
|
234
|
+
$border-radius: 8px;
|
|
235
|
+
|
|
236
|
+
// Apply to the component
|
|
237
|
+
.my-file-input {
|
|
238
|
+
--matecu-file-input-color-primary: #{$primary-color};
|
|
239
|
+
--matecu-file-input-color-success: #{$success-color};
|
|
240
|
+
--matecu-file-input-border-radius-lg: #{$border-radius};
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## 🔍 Best Practices
|
|
245
|
+
|
|
246
|
+
1. **Always use the full variable name** to avoid conflicts
|
|
247
|
+
2. **Test in different states** (hover, error, success, loading)
|
|
248
|
+
3. **Ensure sufficient contrast** for accessibility
|
|
249
|
+
4. **Consider responsive behavior** when customizing sizes
|
|
250
|
+
5. **Use semantic color names** in your design system
|
|
251
|
+
6. **Document your customizations** for team consistency
|
|
252
|
+
|
|
253
|
+
## 🎨 Design System Integration
|
|
254
|
+
|
|
255
|
+
The component variables are designed to integrate seamlessly with popular design systems:
|
|
256
|
+
|
|
257
|
+
- **Tailwind CSS**: Map to your Tailwind config colors
|
|
258
|
+
- **Material Design**: Use Material color palette
|
|
259
|
+
- **Bootstrap**: Integrate with Bootstrap theme colors
|
|
260
|
+
- **Custom Design System**: Map to your brand colors and spacing
|
|
261
|
+
|
|
262
|
+
## 🚀 Advanced Customization
|
|
263
|
+
|
|
264
|
+
For more complex customizations, you can also override specific component styles while respecting the CSS variable system:
|
|
265
|
+
|
|
266
|
+
```css
|
|
267
|
+
.advanced-file-input {
|
|
268
|
+
/* Use variables for consistency */
|
|
269
|
+
--matecu-file-input-color-primary: #your-color;
|
|
270
|
+
|
|
271
|
+
/* Additional custom styles */
|
|
272
|
+
.file-input-container {
|
|
273
|
+
backdrop-filter: blur(10px);
|
|
274
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.select-button {
|
|
278
|
+
font-size: 18px;
|
|
279
|
+
padding: 16px 32px;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
This approach ensures your customizations work with future component updates while maintaining design consistency.
|