shirkasoft-ui-components 1.14.0 → 2.0.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 (92) hide show
  1. package/README.md +4 -8
  2. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs +189 -100
  3. package/fesm2022/shirkasoft-ui-components-breadcrumb.mjs.map +1 -1
  4. package/fesm2022/shirkasoft-ui-components-button.mjs +363 -69
  5. package/fesm2022/shirkasoft-ui-components-button.mjs.map +1 -1
  6. package/fesm2022/shirkasoft-ui-components-chart.mjs +206 -142
  7. package/fesm2022/shirkasoft-ui-components-chart.mjs.map +1 -1
  8. package/fesm2022/shirkasoft-ui-components-config.mjs +905 -843
  9. package/fesm2022/shirkasoft-ui-components-config.mjs.map +1 -1
  10. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs +307 -142
  11. package/fesm2022/shirkasoft-ui-components-confirm-dialog.mjs.map +1 -1
  12. package/fesm2022/shirkasoft-ui-components-date-picker.mjs +1624 -1440
  13. package/fesm2022/shirkasoft-ui-components-date-picker.mjs.map +1 -1
  14. package/fesm2022/shirkasoft-ui-components-fieldset.mjs +347 -92
  15. package/fesm2022/shirkasoft-ui-components-fieldset.mjs.map +1 -1
  16. package/fesm2022/shirkasoft-ui-components-file-upload.mjs +484 -300
  17. package/fesm2022/shirkasoft-ui-components-file-upload.mjs.map +1 -1
  18. package/fesm2022/shirkasoft-ui-components-icons.mjs +1028 -533
  19. package/fesm2022/shirkasoft-ui-components-icons.mjs.map +1 -1
  20. package/fesm2022/shirkasoft-ui-components-knob.mjs +389 -201
  21. package/fesm2022/shirkasoft-ui-components-knob.mjs.map +1 -1
  22. package/fesm2022/shirkasoft-ui-components-loading.mjs +505 -128
  23. package/fesm2022/shirkasoft-ui-components-loading.mjs.map +1 -1
  24. package/fesm2022/shirkasoft-ui-components-modal.mjs +311 -314
  25. package/fesm2022/shirkasoft-ui-components-modal.mjs.map +1 -1
  26. package/fesm2022/shirkasoft-ui-components-notification.mjs +188 -142
  27. package/fesm2022/shirkasoft-ui-components-notification.mjs.map +1 -1
  28. package/fesm2022/shirkasoft-ui-components-price-input.mjs +517 -327
  29. package/fesm2022/shirkasoft-ui-components-price-input.mjs.map +1 -1
  30. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs +669 -289
  31. package/fesm2022/shirkasoft-ui-components-rail-sidebar.mjs.map +1 -1
  32. package/fesm2022/shirkasoft-ui-components-select.mjs +1014 -819
  33. package/fesm2022/shirkasoft-ui-components-select.mjs.map +1 -1
  34. package/fesm2022/shirkasoft-ui-components-sidebar.mjs +508 -184
  35. package/fesm2022/shirkasoft-ui-components-sidebar.mjs.map +1 -1
  36. package/fesm2022/shirkasoft-ui-components-skeleton.mjs +197 -57
  37. package/fesm2022/shirkasoft-ui-components-skeleton.mjs.map +1 -1
  38. package/fesm2022/shirkasoft-ui-components-table.mjs +1916 -1698
  39. package/fesm2022/shirkasoft-ui-components-table.mjs.map +1 -1
  40. package/fesm2022/shirkasoft-ui-components-tabs.mjs +419 -175
  41. package/fesm2022/shirkasoft-ui-components-tabs.mjs.map +1 -1
  42. package/fesm2022/shirkasoft-ui-components-tag.mjs +175 -49
  43. package/fesm2022/shirkasoft-ui-components-tag.mjs.map +1 -1
  44. package/fesm2022/shirkasoft-ui-components-text-field.mjs +687 -402
  45. package/fesm2022/shirkasoft-ui-components-text-field.mjs.map +1 -1
  46. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs +310 -124
  47. package/fesm2022/shirkasoft-ui-components-theme-picker.mjs.map +1 -1
  48. package/fesm2022/shirkasoft-ui-components-theme.mjs +141 -174
  49. package/fesm2022/shirkasoft-ui-components-theme.mjs.map +1 -1
  50. package/fesm2022/shirkasoft-ui-components-timeline.mjs +791 -203
  51. package/fesm2022/shirkasoft-ui-components-timeline.mjs.map +1 -1
  52. package/fesm2022/shirkasoft-ui-components-toggle.mjs +179 -109
  53. package/fesm2022/shirkasoft-ui-components-toggle.mjs.map +1 -1
  54. package/fesm2022/shirkasoft-ui-components-tooltip.mjs +244 -180
  55. package/fesm2022/shirkasoft-ui-components-tooltip.mjs.map +1 -1
  56. package/fesm2022/shirkasoft-ui-components-utils.mjs +95 -134
  57. package/fesm2022/shirkasoft-ui-components-utils.mjs.map +1 -1
  58. package/fesm2022/shirkasoft-ui-components-wizard.mjs +673 -165
  59. package/fesm2022/shirkasoft-ui-components-wizard.mjs.map +1 -1
  60. package/fesm2022/shirkasoft-ui-components.mjs +0 -9
  61. package/package.json +5 -5
  62. package/types/shirkasoft-ui-components-breadcrumb.d.ts +59 -44
  63. package/types/shirkasoft-ui-components-button.d.ts +142 -49
  64. package/types/shirkasoft-ui-components-chart.d.ts +59 -44
  65. package/types/shirkasoft-ui-components-config.d.ts +193 -204
  66. package/types/shirkasoft-ui-components-confirm-dialog.d.ts +107 -66
  67. package/types/shirkasoft-ui-components-date-picker.d.ts +527 -398
  68. package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
  69. package/types/shirkasoft-ui-components-file-upload.d.ts +176 -112
  70. package/types/shirkasoft-ui-components-icons.d.ts +1302 -1294
  71. package/types/shirkasoft-ui-components-knob.d.ts +144 -78
  72. package/types/shirkasoft-ui-components-loading.d.ts +155 -64
  73. package/types/shirkasoft-ui-components-modal.d.ts +134 -136
  74. package/types/shirkasoft-ui-components-notification.d.ts +63 -59
  75. package/types/shirkasoft-ui-components-price-input.d.ts +198 -113
  76. package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
  77. package/types/shirkasoft-ui-components-select.d.ts +301 -196
  78. package/types/shirkasoft-ui-components-sidebar.d.ts +198 -93
  79. package/types/shirkasoft-ui-components-skeleton.d.ts +68 -27
  80. package/types/shirkasoft-ui-components-table.d.ts +849 -660
  81. package/types/shirkasoft-ui-components-tabs.d.ts +102 -61
  82. package/types/shirkasoft-ui-components-tag.d.ts +54 -23
  83. package/types/shirkasoft-ui-components-text-field.d.ts +231 -127
  84. package/types/shirkasoft-ui-components-theme-picker.d.ts +92 -58
  85. package/types/shirkasoft-ui-components-theme.d.ts +56 -64
  86. package/types/shirkasoft-ui-components-timeline.d.ts +325 -150
  87. package/types/shirkasoft-ui-components-toggle.d.ts +73 -49
  88. package/types/shirkasoft-ui-components-tooltip.d.ts +64 -43
  89. package/types/shirkasoft-ui-components-utils.d.ts +15 -16
  90. package/types/shirkasoft-ui-components-wizard.d.ts +236 -87
  91. package/types/shirkasoft-ui-components.d.ts +1 -2
  92. package/fesm2022/shirkasoft-ui-components.mjs.map +0 -1
@@ -1,820 +1,1015 @@
1
- import { CommonModule } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { input, output, viewChild, model, signal, computed, inject, DestroyRef, effect, forwardRef, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
4
- import { ReactiveFormsModule, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
5
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
- import * as i1 from '@jsverse/transloco';
7
- import { TranslocoService, TranslocoModule } from '@jsverse/transloco';
8
- import { LucideChevronDown, ShkIconDirective } from 'shirkasoft-ui-components/icons';
9
- import { getIcon, PortalDirective } from 'shirkasoft-ui-components/utils';
10
-
11
- /**
12
- * Shirkasoft UI Components.
13
- * Authors: Roberto Valladares Martin (Ansem13), Julio César García García (Sanjuli14).
14
- * Belongs to Shirkasoft.
15
- */
16
- /**
17
- * Custom select that works as a ControlValueAccessor: single/multiple
18
- * selection, searchable, keyboard navigation, pagination, custom entries and
19
- * reactive-form integration.
20
- */
21
- class SelectComponent {
22
- /** Internal alias kept for the existing implementation. */
23
- get _value() {
24
- return this.value;
25
- }
26
- /** Computes the fixed position of the dropdown so it's not clipped by overflow. */
27
- /** Max height of the dropdown panel (matches `max-h-[240px]` in the template). */
28
- static { this.DROPDOWN_MAX_HEIGHT = 240; }
29
- /** Approximate height of one option row (`py-2` + `text-sm`), used before the panel is rendered. */
30
- static { this.OPTION_HEIGHT = 40; }
31
- /**
32
- * Height the panel will take: the rendered height when the panel already
33
- * exists, otherwise an estimate from the number of rows. Before this the
34
- * position always assumed 240px, so a 3-option select near the bottom of the
35
- * viewport opened upward even though it fitted below.
36
- */
37
- dropdownHeight() {
38
- const max = SelectComponent.DROPDOWN_MAX_HEIGHT;
39
- const panel = this.dropdownContainer()?.nativeElement;
40
- if (panel && panel.offsetHeight > 0)
41
- return Math.min(panel.offsetHeight, max);
42
- const rows = this.regularOptions().length + (this.showCustomOption() ? 1 : 0);
43
- // Empty / loading states still render one row.
44
- return Math.min(Math.max(rows, 1) * SelectComponent.OPTION_HEIGHT + 2, max);
45
- }
46
- /** Computes the fixed position of the dropdown so it's not clipped by overflow. */
47
- computeDropdownPosition() {
48
- const trigger = this.selectTrigger()?.nativeElement;
49
- if (!trigger)
50
- return;
51
- const rect = trigger.getBoundingClientRect();
52
- const height = this.dropdownHeight();
53
- const opensUpward = this.dropdownUpward();
54
- const inModal = !!trigger.closest('shk-modal');
55
- let top;
56
- if (opensUpward) {
57
- top = rect.top - height - 4;
58
- if (top < 8)
59
- top = 8;
60
- }
61
- else {
62
- top = rect.bottom + 4;
63
- // Flip only when the real panel does not fit below and does fit above.
64
- if (!inModal && top + height > window.innerHeight - 8 && rect.top - height - 4 >= 8) {
65
- top = rect.top - height - 4;
66
- }
67
- }
68
- this.dropdownPosition.set({ top, left: rect.left, width: rect.width });
69
- }
70
- constructor(elementRef) {
71
- this.elementRef = elementRef;
72
- /** Resolves icon names to SVG data, falling back to a chevron. */
73
- this.getIcon = (name) => getIcon(name, LucideChevronDown);
74
- /** Available options. */
75
- this.options = input([], ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
76
- /** Enables multi-select mode. */
77
- this.multiple = input(false, ...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
78
- /** Restricts multi-selection to the given value combinations. */
79
- this.validCombinations = input(undefined, ...(ngDevMode ? [{ debugName: "validCombinations" }] : /* istanbul ignore next */ []));
80
- /** Placeholder shown when there is no selection. */
81
- this.placeholder = input('Seleccionar...', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
82
- /** Label used to bind the control inside a `formGroup`. */
83
- this.label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
84
- /** Shows a loading state while options are being fetched. */
85
- this.isLoading = input(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
86
- /** Marks that all options have been loaded (used with pagination + search). */
87
- this.isAllDataLoaded = input(false, ...(ngDevMode ? [{ debugName: "isAllDataLoaded" }] : /* istanbul ignore next */ []));
88
- /** Allows creating new entries from the typed search term. */
89
- this.allowCustomEntries = input(false, ...(ngDevMode ? [{ debugName: "allowCustomEntries" }] : /* istanbul ignore next */ []));
90
- /** Parent form group to resolve the control from `label`. */
91
- this.formGroup = input(undefined, ...(ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []));
92
- /** Enables the search input inside the dropdown. */
93
- this.isSearchable = input(false, ...(ngDevMode ? [{ debugName: "isSearchable" }] : /* istanbul ignore next */ []));
94
- /** Number of options loaded per page when pagination is enabled. */
95
- this.itemsPerPage = input(10, ...(ngDevMode ? [{ debugName: "itemsPerPage" }] : /* istanbul ignore next */ []));
96
- /** FormControl bound externally (used instead of `formGroup`/`label`). */
97
- this.control = input(undefined, ...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
98
- /** Paginates the option list instead of rendering it all at once. */
99
- this.usePagination = input(false, ...(ngDevMode ? [{ debugName: "usePagination" }] : /* istanbul ignore next */ []));
100
- /** Disables the whole select. */
101
- this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
102
- /** Custom per-validation-error messages shown under the select. */
103
- this.errorMessages = input({
104
- required: 'Este campo es requerido',
105
- }, ...(ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []));
106
- /** Keeps the search term when options reload. */
107
- this.preserveSearchOnLoad = input(false, ...(ngDevMode ? [{ debugName: "preserveSearchOnLoad" }] : /* istanbul ignore next */ []));
108
- /** Translation key of the "no records" empty message. */
109
- this.emptyMessageKey = input('common.no_records', ...(ngDevMode ? [{ debugName: "emptyMessageKey" }] : /* istanbul ignore next */ []));
110
- /** Opens the dropdown above the trigger instead of below. */
111
- this.dropdownUpward = input(false, ...(ngDevMode ? [{ debugName: "dropdownUpward" }] : /* istanbul ignore next */ []));
112
- /** Shows the "no selection" option in single-select mode. */
113
- this.showEmptyOption = input(true, ...(ngDevMode ? [{ debugName: "showEmptyOption" }] : /* istanbul ignore next */ []));
114
- /** Emits when the selection changes (new value or array in multiple mode). */
115
- this.selectionChange = output();
116
- /** Emitted on blur/close so Signal Forms can mark the field as touched. */
117
- this.touch = output();
118
- /** Emits the debounced search term while typing. */
119
- this.search = output();
120
- /** Reference to the filter input inside the dropdown (when searchable). */
121
- this.filterInput = viewChild('filterInput', ...(ngDevMode ? [{ debugName: "filterInput" }] : /* istanbul ignore next */ []));
122
- /** Reference to the select container element. */
123
- this.selectContainer = viewChild('selectContainer', ...(ngDevMode ? [{ debugName: "selectContainer" }] : /* istanbul ignore next */ []));
124
- /** Reference to the trigger button. */
125
- this.selectTrigger = viewChild('selectTrigger', ...(ngDevMode ? [{ debugName: "selectTrigger" }] : /* istanbul ignore next */ []));
126
- /** Reference to the dropdown list container. */
127
- this.dropdownContainer = viewChild('dropdownContainer', ...(ngDevMode ? [{ debugName: "dropdownContainer" }] : /* istanbul ignore next */ []));
128
- /** Selection value. Two-way bindable and used by Signal Forms `[formField]`. */
129
- this.value = model(null, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
130
- /** Whether the dropdown is open. */
131
- this.isOpen = signal(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
132
- /** Index of the currently focused option for keyboard navigation. */
133
- this.focusedIndex = signal(-1, ...(ngDevMode ? [{ debugName: "focusedIndex" }] : /* istanbul ignore next */ []));
134
- /** Current search term (searchable mode). */
135
- this.searchTerm = signal('', ...(ngDevMode ? [{ debugName: "searchTerm" }] : /* istanbul ignore next */ []));
136
- /** Current page of the paginated dropdown. */
137
- this.currentPage = signal(1, ...(ngDevMode ? [{ debugName: "currentPage" }] : /* istanbul ignore next */ []));
138
- /** Tracks whether the user typed in the search input. */
139
- this.searchTermChanged = signal(false, ...(ngDevMode ? [{ debugName: "searchTermChanged" }] : /* istanbul ignore next */ []));
140
- /** Internal disabled state from the reactive form (setDisabledState). */
141
- this._isDisabled = signal(false, ...(ngDevMode ? [{ debugName: "_isDisabled" }] : /* istanbul ignore next */ []));
142
- /** Debounce timer handle for the search output. */
143
- this.debounceTimer = null;
144
- /** Error-state counter used to recompute error helpers reactively. */
145
- this.errorTracker = signal(0, ...(ngDevMode ? [{ debugName: "errorTracker" }] : /* istanbul ignore next */ []));
146
- /** Whether an error has been shown at some point (for "fixed" messaging). */
147
- this.hadError = signal(false, ...(ngDevMode ? [{ debugName: "hadError" }] : /* istanbul ignore next */ []));
148
- /** Whether control status/value subscriptions have been attached. */
149
- this.subscribed = signal(false, ...(ngDevMode ? [{ debugName: "subscribed" }] : /* istanbul ignore next */ []));
150
- this.valueSubscribed = signal(false, ...(ngDevMode ? [{ debugName: "valueSubscribed" }] : /* istanbul ignore next */ []));
151
- /** True when the select is disabled via input or by the reactive form. */
152
- this.isDisabled = computed(() => this.disabled() || this._isDisabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
153
- /** Resolves the form control from `control` or from `formGroup`+`label`. */
154
- this.actualControl = computed(() => {
155
- const ctrl = this.control();
156
- if (ctrl)
157
- return ctrl;
158
- const fg = this.formGroup();
159
- const lbl = this.label();
160
- if (fg && lbl) {
161
- return fg.get(lbl);
162
- }
163
- return undefined;
164
- }, ...(ngDevMode ? [{ debugName: "actualControl" }] : /* istanbul ignore next */ []));
165
- /** Whether the bound control should display its error (invalid + touched/dirty). */
166
- this.shouldShowError = computed(() => {
167
- this.errorTracker();
168
- const ctrl = this.actualControl();
169
- return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);
170
- }, ...(ngDevMode ? [{ debugName: "shouldShowError" }] : /* istanbul ignore next */ []));
171
- /** Whether an error was shown before and the control is now valid + touched. */
172
- this.wasFixedError = computed(() => {
173
- this.errorTracker();
174
- const ctrl = this.actualControl();
175
- return this.hadError() && ctrl?.valid && ctrl?.touched;
176
- }, ...(ngDevMode ? [{ debugName: "wasFixedError" }] : /* istanbul ignore next */ []));
177
- /** Text shown in the trigger: the selected label(s) or the placeholder. */
178
- this.displayValue = computed(() => {
179
- const val = this._value();
180
- const opts = this.options();
181
- const isMultiple = this.multiple();
182
- const ph = this.placeholder();
183
- if (!val || (Array.isArray(val) && val.length === 0)) {
184
- return ph;
185
- }
186
- if (isMultiple) {
187
- const values = Array.isArray(val) ? val : [];
188
- const selectedLabels = opts
189
- .filter((option) => values.includes(option.value))
190
- .map((option) => option.label);
191
- if (selectedLabels.length === 0) {
192
- return values.toString();
193
- }
194
- return selectedLabels.join(', ');
195
- }
196
- const selectedOption = opts.find((opt) => opt.value === val);
197
- return selectedOption ? selectedOption.label : val;
198
- }, ...(ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []));
199
- /** List of validation error messages for the bound control. */
200
- this.getErrorMessages = computed(() => {
201
- this.errorTracker();
202
- const ctrl = this.actualControl();
203
- if (!ctrl?.errors)
204
- return [];
205
- const customErrors = this.errorMessages();
206
- const t = this.transloco;
207
- return Object.keys(ctrl.errors).map((errorKey) => {
208
- if (customErrors[errorKey])
209
- return customErrors[errorKey];
210
- switch (errorKey) {
211
- case 'required':
212
- return t.translate('validation.required');
213
- case 'email':
214
- return t.translate('validation.email');
215
- case 'minlength':
216
- return t.translate('validation.minlength', {
217
- min: ctrl.errors['minlength'].requiredLength,
218
- });
219
- case 'maxlength':
220
- return t.translate('validation.maxlength', {
221
- max: ctrl.errors['maxlength'].requiredLength,
222
- });
223
- case 'pattern':
224
- return t.translate('validation.pattern');
225
- default:
226
- return t.translate('validation.invalid');
227
- }
228
- });
229
- }, ...(ngDevMode ? [{ debugName: "getErrorMessages" }] : /* istanbul ignore next */ []));
230
- /** Options filtered by the search term (matches first, then contains). */
231
- this.filteredOptions = computed(() => {
232
- const opts = this.options();
233
- const term = this.searchTerm();
234
- if (!term)
235
- return opts;
236
- const normalizedSearchTerm = this.normalizeText(term);
237
- const matched = opts.filter((option) => this.normalizeText(option.label).includes(normalizedSearchTerm));
238
- return matched.sort((a, b) => {
239
- const aLbl = this.normalizeText(a.label);
240
- const bLbl = this.normalizeText(b.label);
241
- const aStarts = aLbl.startsWith(normalizedSearchTerm);
242
- const bStarts = bLbl.startsWith(normalizedSearchTerm);
243
- if (aStarts && !bStarts)
244
- return -1;
245
- if (!aStarts && bStarts)
246
- return 1;
247
- return 0;
248
- });
249
- }, ...(ngDevMode ? [{ debugName: "filteredOptions" }] : /* istanbul ignore next */ []));
250
- /** Options for the current page, with a synthetic custom entry when allowed. */
251
- this.paginatedOptions = computed(() => {
252
- let filtered = this.filteredOptions();
253
- const term = this.searchTerm();
254
- const allowCustom = this.allowCustomEntries();
255
- if (allowCustom && term && !filtered.some((o) => o.value === term)) {
256
- filtered = [
257
- {
258
- label: `${term} (nuevo)`,
259
- value: term,
260
- custom: true,
261
- },
262
- ...filtered,
263
- ];
264
- }
265
- if (!this.usePagination()) {
266
- return filtered;
267
- }
268
- const page = this.currentPage();
269
- const perPage = this.itemsPerPage();
270
- const startIndex = (page - 1) * perPage;
271
- const endIndex = startIndex + perPage;
272
- return filtered.slice(startIndex, endIndex);
273
- }, ...(ngDevMode ? [{ debugName: "paginatedOptions" }] : /* istanbul ignore next */ []));
274
- /** Non-custom options, including the empty option in single-select mode. */
275
- this.regularOptions = computed(() => {
276
- const opts = this.paginatedOptions().filter((option) => !option.custom);
277
- if (!this.multiple() && this.showEmptyOption()) {
278
- return [{ label: '- Sin selección -', value: null }, ...opts];
279
- }
280
- return opts;
281
- }, ...(ngDevMode ? [{ debugName: "regularOptions" }] : /* istanbul ignore next */ []));
282
- /** Total pages of the filtered option list (1 when pagination is off). */
283
- this.totalPages = computed(() => {
284
- if (!this.usePagination()) {
285
- return 1;
286
- }
287
- const filtered = this.filteredOptions();
288
- const perPage = this.itemsPerPage();
289
- return Math.ceil(filtered.length / perPage);
290
- }, ...(ngDevMode ? [{ debugName: "totalPages" }] : /* istanbul ignore next */ []));
291
- /** Whether there is at least one selected value. */
292
- this.hasSelectedValues = computed(() => {
293
- const val = this._value();
294
- if (this.multiple()) {
295
- return val && val.length > 0;
296
- }
297
- return !!val;
298
- }, ...(ngDevMode ? [{ debugName: "hasSelectedValues" }] : /* istanbul ignore next */ []));
299
- /** Whether the custom optional entry should be offered for the current term. */
300
- this.showCustomOption = computed(() => {
301
- const term = this.searchTerm();
302
- const opts = this.options();
303
- return (this.allowCustomEntries() &&
304
- term !== '' &&
305
- !opts.some((o) => o.value === term));
306
- }, ...(ngDevMode ? [{ debugName: "showCustomOption" }] : /* istanbul ignore next */ []));
307
- /** Fixed position of the dropdown relative to the viewport. */
308
- this.dropdownPosition = signal({ top: 0, left: 0, width: 0 }, ...(ngDevMode ? [{ debugName: "dropdownPosition" }] : /* istanbul ignore next */ []));
309
- this.transloco = inject(TranslocoService);
310
- /** ControlValueAccessor onChange callback. */
311
- this.onChange = (_) => { };
312
- /** ControlValueAccessor onTouched callback. */
313
- this.onTouched = () => { };
314
- this.destroyRef = inject(DestroyRef);
315
- /** Closes the dropdown when the page/container scrolls, ignoring scrolls that start inside the component (its own options list). */
316
- this.scrollCloseHandler = (event) => {
317
- const target = event.target;
318
- if (target && this.isInsideComponent(target))
319
- return;
320
- if (this.isOpen()) {
321
- this.isOpen.set(false);
322
- this.searchTerm.set('');
323
- this.focusedIndex.set(-1);
324
- }
325
- };
326
- const doc = this.elementRef.nativeElement.ownerDocument;
327
- doc.addEventListener('scroll', this.scrollCloseHandler, true);
328
- this.destroyRef.onDestroy(() => doc.removeEventListener('scroll', this.scrollCloseHandler, true));
329
- // Debounced search emission whenever the term changes (searchable mode).
330
- effect(() => {
331
- const term = this.searchTerm();
332
- if (term !== '' && this.isSearchable()) {
333
- if (this.debounceTimer) {
334
- clearTimeout(this.debounceTimer);
335
- }
336
- this.debounceTimer = setTimeout(() => {
337
- this.search.emit(term);
338
- }, 300);
339
- }
340
- });
341
- // Normalizes the value to arrays in multiple mode when empty.
342
- effect(() => {
343
- const isMultiple = this.multiple();
344
- if (this._value() === null || this._value() === undefined) {
345
- this._value.set(isMultiple ? [] : null);
346
- }
347
- });
348
- // Resets to the first page when options reload, clearing the search
349
- // term unless it must be preserved.
350
- effect(() => {
351
- this.options();
352
- this.currentPage.set(1);
353
- if (!this.preserveSearchOnLoad() || !this.searchTermChanged()) {
354
- this.searchTerm.set('');
355
- }
356
- });
357
- // Subscribes to the bound control status/value changes to track errors.
358
- effect(() => {
359
- const ctrl = this.actualControl();
360
- if (!ctrl) {
361
- this.subscribed.set(false);
362
- return;
363
- }
364
- if (this.subscribed())
365
- return;
366
- if (ctrl.invalid && ctrl.touched) {
367
- this.hadError.set(true);
368
- }
369
- ctrl.statusChanges
370
- .pipe(takeUntilDestroyed(this.destroyRef))
371
- .subscribe(() => {
372
- this.errorTracker.update((v) => v + 1);
373
- if (ctrl.invalid && ctrl.touched) {
374
- this.hadError.set(true);
375
- }
376
- });
377
- ctrl.valueChanges
378
- .pipe(takeUntilDestroyed(this.destroyRef))
379
- .subscribe(() => {
380
- this.errorTracker.update((v) => v + 1);
381
- });
382
- this.subscribed.set(true);
383
- });
384
- // Forces error recomputation when the active translation changes.
385
- this.transloco.langChanges$
386
- .pipe(takeUntilDestroyed(this.destroyRef))
387
- .subscribe(() => {
388
- this.errorTracker.update((v) => v + 1);
389
- });
390
- // One-way sync from the reactive control to the internal value signal.
391
- effect(() => {
392
- const ctrl = this.actualControl();
393
- if (!ctrl)
394
- return;
395
- if (!this.valueSubscribed()) {
396
- this.writeValue(ctrl.value);
397
- ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => {
398
- this.writeValue(value);
399
- });
400
- this.valueSubscribed.set(true);
401
- }
402
- });
403
- }
404
- /** Sets the disabled state coming from the reactive form infrastructure. */
405
- setDisabledState(isDisabled) {
406
- this._isDisabled.set(isDisabled);
407
- }
408
- /** Marks the control as touched and updates validity and error state. */
409
- markAsTouchedAndUpdate() {
410
- this.touch.emit();
411
- const ctrl = this.actualControl();
412
- if (ctrl) {
413
- ctrl.markAsTouched();
414
- ctrl.updateValueAndValidity({ emitEvent: false });
415
- }
416
- this.onTouched();
417
- this.errorTracker.update((v) => v + 1);
418
- if (ctrl?.invalid) {
419
- this.hadError.set(true);
420
- }
421
- }
422
- /** Strips accents and lowercases text for accent-insensitive matching. */
423
- normalizeText(text) {
424
- return text
425
- .normalize('NFD')
426
- .replace(/[\u0300-\u036f]/g, '')
427
- .toLowerCase();
428
- }
429
- /** Keyboard handler for the trigger element (open/close/navigate/select). */
430
- onKeydown(event) {
431
- if (this.isDisabled())
432
- return;
433
- switch (event.key) {
434
- case 'Enter':
435
- case ' ':
436
- event.preventDefault();
437
- if (this.isOpen()) {
438
- if (this.focusedIndex() >= 0) {
439
- const options = this.regularOptions();
440
- const selectedOption = options[this.focusedIndex()];
441
- if (selectedOption && !this.isOptionDisabled(selectedOption)) {
442
- this.selectOption(selectedOption);
443
- }
444
- }
445
- }
446
- else {
447
- this.toggleDropdown();
448
- }
449
- break;
450
- case 'Escape':
451
- if (this.isOpen()) {
452
- this.isOpen.set(false);
453
- this.searchTerm.set('');
454
- this.focusedIndex.set(-1);
455
- this.selectTrigger()?.nativeElement.focus();
456
- }
457
- break;
458
- case 'ArrowDown':
459
- event.preventDefault();
460
- if (!this.isOpen()) {
461
- this.toggleDropdown();
462
- }
463
- else {
464
- this.moveFocus(1);
465
- }
466
- break;
467
- case 'ArrowUp':
468
- event.preventDefault();
469
- if (this.isOpen()) {
470
- this.moveFocus(-1);
471
- }
472
- break;
473
- case 'Tab':
474
- if (this.isOpen()) {
475
- this.isOpen.set(false);
476
- this.searchTerm.set('');
477
- this.focusedIndex.set(-1);
478
- }
479
- break;
480
- }
481
- }
482
- /** Keyboard handler for the search input inside a searchable dropdown. */
483
- handleKeyDown(event) {
484
- switch (event.key) {
485
- case 'Enter':
486
- event.preventDefault();
487
- event.stopPropagation();
488
- if (this.focusedIndex() >= 0) {
489
- const options = this.regularOptions();
490
- const option = options[this.focusedIndex()];
491
- if (option && !this.isOptionDisabled(option)) {
492
- this.selectOption(option);
493
- }
494
- }
495
- else {
496
- const filtered = this.filteredOptions();
497
- if (filtered.length > 0) {
498
- this.selectOption(filtered[0]);
499
- }
500
- }
501
- break;
502
- case 'ArrowDown':
503
- event.preventDefault();
504
- event.stopPropagation();
505
- this.moveFocus(1);
506
- break;
507
- case 'ArrowUp':
508
- event.preventDefault();
509
- event.stopPropagation();
510
- this.moveFocus(-1);
511
- break;
512
- case 'Escape':
513
- event.stopPropagation();
514
- event.preventDefault();
515
- this.isOpen.set(false);
516
- this.searchTerm.set('');
517
- this.focusedIndex.set(-1);
518
- this.selectTrigger()?.nativeElement.focus();
519
- break;
520
- }
521
- }
522
- /** Moves the focused option index by `direction`, skipping disabled ones. */
523
- moveFocus(direction) {
524
- const options = this.regularOptions();
525
- if (!options.length)
526
- return;
527
- let newIndex = this.focusedIndex();
528
- do {
529
- newIndex = newIndex + direction;
530
- if (newIndex < 0)
531
- newIndex = options.length - 1;
532
- if (newIndex >= options.length)
533
- newIndex = 0;
534
- } while (this.isOptionDisabled(options[newIndex]) && options.length > 1);
535
- this.focusedIndex.set(newIndex);
536
- setTimeout(() => {
537
- const container = this.dropdownContainer()?.nativeElement;
538
- const activeItem = container?.querySelector('.select-option-active');
539
- if (activeItem && container) {
540
- const itemTop = activeItem.offsetTop;
541
- const itemBottom = itemTop + activeItem.offsetHeight;
542
- const containerScrollTop = container.scrollTop;
543
- const containerHeight = container.clientHeight;
544
- if (itemTop < containerScrollTop) {
545
- container.scrollTop = itemTop;
546
- }
547
- else if (itemBottom > containerScrollTop + containerHeight) {
548
- container.scrollTop = itemBottom - containerHeight;
549
- }
550
- }
551
- });
552
- }
553
- /** Index of the currently selected option, or -1. */
554
- getSelectedIndex() {
555
- const currentVal = this._value();
556
- const options = this.regularOptions();
557
- if (currentVal === null || currentVal === undefined)
558
- return -1;
559
- const index = options.findIndex((opt) => opt.value === currentVal);
560
- return index >= 0 ? index : -1;
561
- }
562
- /** Whether an option is disabled based on the valid combinations rule. */
563
- isOptionDisabled(option) {
564
- if (option.value === null)
565
- return false;
566
- const validCombos = this.validCombinations();
567
- if (!validCombos || !this.multiple()) {
568
- return false;
569
- }
570
- const currentSelection = Array.isArray(this._value()) ? this._value() : [];
571
- if (currentSelection.length === 0) {
572
- return false;
573
- }
574
- if (currentSelection.includes(option.value)) {
575
- return false;
576
- }
577
- const hypotheticalSelection = [...currentSelection, option.value];
578
- return !validCombos.some((combination) => {
579
- const allSelected = hypotheticalSelection.every((selected) => combination.includes(selected));
580
- const withinLimit = hypotheticalSelection.length <= combination.length;
581
- return allSelected && withinLimit;
582
- });
583
- }
584
- /** Whether an option is currently selected. */
585
- isSelected(option) {
586
- const val = this._value();
587
- if (this.multiple()) {
588
- return Array.isArray(val) && val.includes(option.value);
589
- }
590
- return val === option.value;
591
- }
592
- /** Goes to the next options page when possible. */
593
- nextPage() {
594
- const total = this.totalPages();
595
- const current = this.currentPage();
596
- if (current < total) {
597
- this.currentPage.set(current + 1);
598
- }
599
- }
600
- /** Goes to the previous options page when possible. */
601
- previousPage() {
602
- const current = this.currentPage();
603
- if (current > 1) {
604
- this.currentPage.set(current - 1);
605
- }
606
- }
607
- /** Whether a node belongs to the component or to its (portaled) dropdown panel. */
608
- isInsideComponent(target) {
609
- if (!target)
610
- return false;
611
- if (this.elementRef.nativeElement.contains(target))
612
- return true;
613
- const panel = this.dropdownContainer()?.nativeElement;
614
- return !!panel && panel.contains(target);
615
- }
616
- /** Closes the dropdown when a click happens outside the component. */
617
- onClickOutside(event) {
618
- const clickedInside = this.isInsideComponent(event.target);
619
- if (!clickedInside && this.isOpen()) {
620
- this.markAsTouchedAndUpdate();
621
- this.isOpen.set(false);
622
- this.searchTerm.set('');
623
- this.focusedIndex.set(-1);
624
- }
625
- }
626
- /** Selects a typed free-text value as a new custom entry. */
627
- onCustomOptionClick() {
628
- const term = this.searchTerm();
629
- const customOption = {
630
- label: term,
631
- value: term,
632
- };
633
- this._value.set(customOption.value);
634
- this.onChange(customOption.value);
635
- this.selectionChange.emit(customOption.value);
636
- this.isOpen.set(false);
637
- this.searchTerm.set('');
638
- const ctrl = this.actualControl();
639
- if (ctrl) {
640
- ctrl.setValue(customOption.value);
641
- }
642
- this.markAsTouchedAndUpdate();
643
- }
644
- /** Handles typing in the search input (updates term and emits search). */
645
- onInputChange(event) {
646
- const previousSearch = this.searchTerm();
647
- const target = event.target;
648
- this.searchTerm.set(target.value);
649
- this.searchTermChanged.set(true);
650
- if (previousSearch !== this.searchTerm()) {
651
- this.search.emit(this.searchTerm());
652
- if (this.allowCustomEntries() && this.searchTerm()) {
653
- this._value.set(this.searchTerm());
654
- this.onChange(this.searchTerm());
655
- this.selectionChange.emit(this.searchTerm());
656
- }
657
- }
658
- this.currentPage.set(1);
659
- }
660
- /** Selects or toggles the clicked option (custom entries included). */
661
- onOptionClick(option) {
662
- if (this.isDisabled())
663
- return;
664
- if (this.allowCustomEntries() && option.value === this.searchTerm()) {
665
- const customOption = {
666
- label: this.searchTerm(),
667
- value: this.searchTerm(),
668
- };
669
- this._value.set(customOption.value);
670
- this.onChange(customOption.value);
671
- this.selectionChange.emit(customOption.value);
672
- this.isOpen.set(false);
673
- this.searchTerm.set('');
674
- const ctrl = this.actualControl();
675
- if (ctrl) {
676
- ctrl.setValue(customOption.value);
677
- }
678
- this.markAsTouchedAndUpdate();
679
- return;
680
- }
681
- if (this.multiple()) {
682
- this.toggleOption(option);
683
- }
684
- else {
685
- this.selectOption(option);
686
- }
687
- }
688
- /** Selects a single option and updates the control/outputs. */
689
- selectOption(option) {
690
- if (this.multiple()) {
691
- this.toggleOption(option);
692
- return;
693
- }
694
- this._value.set(option.value);
695
- this.onChange(option.value);
696
- this.onTouched();
697
- this.selectionChange.emit(option.value);
698
- this.isOpen.set(false);
699
- const ctrl = this.actualControl();
700
- if (ctrl) {
701
- ctrl.setValue(option.value);
702
- }
703
- this.markAsTouchedAndUpdate();
704
- this.focusedIndex.set(-1);
705
- this.selectTrigger()?.nativeElement.focus();
706
- }
707
- /** Toggles an option in multiple mode, honoring the valid combinations. */
708
- toggleOption(option) {
709
- if (this.isOptionDisabled(option))
710
- return;
711
- if (!this.multiple())
712
- return;
713
- let currentValue = this._value();
714
- if (!Array.isArray(currentValue)) {
715
- currentValue = [];
716
- }
717
- const index = currentValue.indexOf(option.value);
718
- let newValue;
719
- if (index === -1) {
720
- newValue = [...currentValue, option.value];
721
- }
722
- else {
723
- newValue = currentValue.filter((v) => v !== option.value);
724
- }
725
- this._value.set(newValue);
726
- this.onChange(newValue);
727
- this.onTouched();
728
- this.selectionChange.emit(newValue);
729
- this.markAsTouchedAndUpdate();
730
- }
731
- /** Opens/closes the dropdown and manages focus/selection state. */
732
- toggleDropdown() {
733
- if (this.isDisabled())
734
- return;
735
- const wasOpen = this.isOpen();
736
- this.isOpen.update((v) => !v);
737
- if (!wasOpen && this.isOpen()) {
738
- const selectedIdx = this.getSelectedIndex();
739
- this.focusedIndex.set(selectedIdx);
740
- }
741
- else if (wasOpen && !this.isOpen()) {
742
- this.searchTerm.set('');
743
- this.focusedIndex.set(-1);
744
- this.selectTrigger()?.nativeElement.focus();
745
- }
746
- if (this.isOpen() && this.isSearchable()) {
747
- setTimeout(() => {
748
- this.filterInput()?.nativeElement?.focus();
749
- });
750
- }
751
- if (this.isOpen()) {
752
- this.computeDropdownPosition();
753
- // Second pass with the rendered panel height (the first one is an estimate).
754
- requestAnimationFrame(() => {
755
- if (this.isOpen())
756
- this.computeDropdownPosition();
757
- });
758
- }
759
- this.onTouched();
760
- }
761
- /** trackBy for rendered options so Angular reuses DOM nodes by value. */
762
- trackByFn(index, option) {
763
- return option.value;
764
- }
765
- /** Writes an external value into the internal signal (ControlValueAccessor). */
766
- writeValue(value) {
767
- if (value === null ||
768
- value === undefined ||
769
- value === '' ||
770
- (Array.isArray(value) && value.length === 0)) {
771
- this._value.set(this.multiple() ? [] : null);
772
- }
773
- else {
774
- this._value.set(value);
775
- }
776
- }
777
- /** Stores the onChange callback (ControlValueAccessor). */
778
- registerOnChange(fn) {
779
- this.onChange = fn;
780
- }
781
- /** Stores the onTouched callback (ControlValueAccessor). */
782
- registerOnTouched(fn) {
783
- this.onTouched = fn;
784
- }
785
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: SelectComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
786
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.27", type: SelectComponent, isStandalone: true, selector: "shk-select", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, validCombinations: { classPropertyName: "validCombinations", publicName: "validCombinations", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, isLoading: { classPropertyName: "isLoading", publicName: "isLoading", isSignal: true, isRequired: false, transformFunction: null }, isAllDataLoaded: { classPropertyName: "isAllDataLoaded", publicName: "isAllDataLoaded", isSignal: true, isRequired: false, transformFunction: null }, allowCustomEntries: { classPropertyName: "allowCustomEntries", publicName: "allowCustomEntries", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null }, isSearchable: { classPropertyName: "isSearchable", publicName: "isSearchable", isSignal: true, isRequired: false, transformFunction: null }, itemsPerPage: { classPropertyName: "itemsPerPage", publicName: "itemsPerPage", isSignal: true, isRequired: false, transformFunction: null }, control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: false, transformFunction: null }, usePagination: { classPropertyName: "usePagination", publicName: "usePagination", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, errorMessages: { classPropertyName: "errorMessages", publicName: "errorMessages", isSignal: true, isRequired: false, transformFunction: null }, preserveSearchOnLoad: { classPropertyName: "preserveSearchOnLoad", publicName: "preserveSearchOnLoad", isSignal: true, isRequired: false, transformFunction: null }, emptyMessageKey: { classPropertyName: "emptyMessageKey", publicName: "emptyMessageKey", isSignal: true, isRequired: false, transformFunction: null }, dropdownUpward: { classPropertyName: "dropdownUpward", publicName: "dropdownUpward", isSignal: true, isRequired: false, transformFunction: null }, showEmptyOption: { classPropertyName: "showEmptyOption", publicName: "showEmptyOption", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectionChange: "selectionChange", touch: "touch", search: "search", value: "valueChange" }, host: { listeners: { "document:mousedown": "onClickOutside($event)" } }, providers: [
787
- {
788
- provide: NG_VALUE_ACCESSOR,
789
- useExisting: forwardRef(() => SelectComponent),
790
- multi: true,
791
- },
792
- ], viewQueries: [{ propertyName: "filterInput", first: true, predicate: ["filterInput"], descendants: true, isSignal: true }, { propertyName: "selectContainer", first: true, predicate: ["selectContainer"], descendants: true, isSignal: true }, { propertyName: "selectTrigger", first: true, predicate: ["selectTrigger"], descendants: true, isSignal: true }, { propertyName: "dropdownContainer", first: true, predicate: ["dropdownContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"shk-control flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class.shk-control-disabled]=\"isDisabled()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n shkPortal\n (keydown)=\"onKeydown($event)\"\n class=\"shk-select-panel fixed _shk-bg-surface-50 border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700\"\n [class.shk-select-option-disabled]=\"isOptionDisabled(option)\"\n [class.shk-select-option-selected]=\"!multiple() && option.value !== null && isSelected(option)\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n <span class=\"shk-select-option-label flex-1 min-w-0\">{{ option.label }}</span>\n @if (option.value !== null && isSelected(option)) {\n <svg [shkIcon]=\"getIcon('check')\" class=\"shk-select-check w-4 h-4 shrink-0\"></svg>\n }\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando m\u00E1s resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>", styles: [".shk-select-panel{padding:.25rem;border-radius:.625rem;box-shadow:0 10px 24px -6px #0000001f,0 4px 8px -4px #0000000f;animation:shk-select-in .12s ease-out}@keyframes shk-select-in{0%{opacity:0;transform:translateY(-4px) scale(.98)}}@keyframes shk-spin{to{transform:rotate(360deg)}}.shk-select-option{border-radius:.375rem;transition:background-color .1s ease}.shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-select-option:hover:not(.shk-select-option-disabled),.dark .shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-200)}.shk-select-option-label{overflow-wrap:anywhere}.spinner{width:1rem;height:1rem;animation:shk-spin .9s linear infinite;transform-origin:center}.spinner .path{stroke:var(--shk-surface-400);stroke-linecap:round;stroke-dasharray:90,150;stroke-dashoffset:0}.shk-select-option-disabled{cursor:not-allowed}.shk-select-option-selected{color:var(--shk-primary-700);font-weight:500}:host-context(.dark) .shk-select-option-selected,.dark .shk-select-option-selected{color:var(--shk-primary-400)}.shk-select-check{color:var(--shk-primary-600)}:host-context(.dark) .shk-select-check,.dark .shk-select-check{color:var(--shk-primary-400)}.select-option-active{background-color:var(--shk-primary-50);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--shk-primary-500) 35%,transparent);color:var(--shk-primary-700)}:host-context(.dark) .select-option-active,.dark .select-option-active{background-color:color-mix(in srgb,var(--shk-primary-900) 40%,transparent);color:var(--shk-primary-300)}\n"], dependencies: [{ kind: "directive", type: PortalDirective, selector: "[shkPortal]" }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: TranslocoModule }, { kind: "directive", type: ShkIconDirective, selector: "svg[shkIcon]", inputs: ["shkIcon", "size", "strokeWidth", "color"] }, { kind: "pipe", type: i1.TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
793
- }
794
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: SelectComponent, decorators: [{
795
- type: Component,
796
- args: [{ selector: 'shk-select', imports: [
797
- PortalDirective,
798
- CommonModule,
799
- ReactiveFormsModule,
800
- FormsModule,
801
- TranslocoModule,
802
- ShkIconDirective,
803
- ], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
804
- {
805
- provide: NG_VALUE_ACCESSOR,
806
- useExisting: forwardRef(() => SelectComponent),
807
- multi: true,
808
- },
809
- ], template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"shk-control flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class.shk-control-disabled]=\"isDisabled()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n shkPortal\n (keydown)=\"onKeydown($event)\"\n class=\"shk-select-panel fixed _shk-bg-surface-50 border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700\"\n [class.shk-select-option-disabled]=\"isOptionDisabled(option)\"\n [class.shk-select-option-selected]=\"!multiple() && option.value !== null && isSelected(option)\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n <span class=\"shk-select-option-label flex-1 min-w-0\">{{ option.label }}</span>\n @if (option.value !== null && isSelected(option)) {\n <svg [shkIcon]=\"getIcon('check')\" class=\"shk-select-check w-4 h-4 shrink-0\"></svg>\n }\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando m\u00E1s resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>", styles: [".shk-select-panel{padding:.25rem;border-radius:.625rem;box-shadow:0 10px 24px -6px #0000001f,0 4px 8px -4px #0000000f;animation:shk-select-in .12s ease-out}@keyframes shk-select-in{0%{opacity:0;transform:translateY(-4px) scale(.98)}}@keyframes shk-spin{to{transform:rotate(360deg)}}.shk-select-option{border-radius:.375rem;transition:background-color .1s ease}.shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-select-option:hover:not(.shk-select-option-disabled),.dark .shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-200)}.shk-select-option-label{overflow-wrap:anywhere}.spinner{width:1rem;height:1rem;animation:shk-spin .9s linear infinite;transform-origin:center}.spinner .path{stroke:var(--shk-surface-400);stroke-linecap:round;stroke-dasharray:90,150;stroke-dashoffset:0}.shk-select-option-disabled{cursor:not-allowed}.shk-select-option-selected{color:var(--shk-primary-700);font-weight:500}:host-context(.dark) .shk-select-option-selected,.dark .shk-select-option-selected{color:var(--shk-primary-400)}.shk-select-check{color:var(--shk-primary-600)}:host-context(.dark) .shk-select-check,.dark .shk-select-check{color:var(--shk-primary-400)}.select-option-active{background-color:var(--shk-primary-50);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--shk-primary-500) 35%,transparent);color:var(--shk-primary-700)}:host-context(.dark) .select-option-active,.dark .select-option-active{background-color:color-mix(in srgb,var(--shk-primary-900) 40%,transparent);color:var(--shk-primary-300)}\n"] }]
810
- }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], validCombinations: [{ type: i0.Input, args: [{ isSignal: true, alias: "validCombinations", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], isLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "isLoading", required: false }] }], isAllDataLoaded: [{ type: i0.Input, args: [{ isSignal: true, alias: "isAllDataLoaded", required: false }] }], allowCustomEntries: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowCustomEntries", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }], isSearchable: [{ type: i0.Input, args: [{ isSignal: true, alias: "isSearchable", required: false }] }], itemsPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemsPerPage", required: false }] }], control: [{ type: i0.Input, args: [{ isSignal: true, alias: "control", required: false }] }], usePagination: [{ type: i0.Input, args: [{ isSignal: true, alias: "usePagination", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], errorMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessages", required: false }] }], preserveSearchOnLoad: [{ type: i0.Input, args: [{ isSignal: true, alias: "preserveSearchOnLoad", required: false }] }], emptyMessageKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessageKey", required: false }] }], dropdownUpward: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropdownUpward", required: false }] }], showEmptyOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "showEmptyOption", required: false }] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], touch: [{ type: i0.Output, args: ["touch"] }], search: [{ type: i0.Output, args: ["search"] }], filterInput: [{ type: i0.ViewChild, args: ['filterInput', { isSignal: true }] }], selectContainer: [{ type: i0.ViewChild, args: ['selectContainer', { isSignal: true }] }], selectTrigger: [{ type: i0.ViewChild, args: ['selectTrigger', { isSignal: true }] }], dropdownContainer: [{ type: i0.ViewChild, args: ['dropdownContainer', { isSignal: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], onClickOutside: [{
811
- type: HostListener,
812
- args: ['document:mousedown', ['$event']]
813
- }] } });
814
-
815
- /**
816
- * Generated bundle index. Do not edit.
817
- */
818
-
1
+ import { CommonModule } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, HostListener, computed, effect, forwardRef, inject, input, model, output, signal, viewChild } from "@angular/core";
4
+ import { FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";
5
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
6
+ import * as i1 from "@jsverse/transloco";
7
+ import { TranslocoModule, TranslocoService } from "@jsverse/transloco";
8
+ import { LucideChevronDown, ShkIconDirective } from "shirkasoft-ui-components/icons";
9
+ import { PortalDirective, getIcon } from "shirkasoft-ui-components/utils";
10
+ var SelectComponent = class SelectComponent {
11
+ get _value() {
12
+ return this.value;
13
+ }
14
+ static {
15
+ this.DROPDOWN_MAX_HEIGHT = 240;
16
+ }
17
+ static {
18
+ this.OPTION_HEIGHT = 40;
19
+ }
20
+ dropdownHeight() {
21
+ const max = SelectComponent.DROPDOWN_MAX_HEIGHT;
22
+ const panel = this.dropdownContainer()?.nativeElement;
23
+ if (panel && panel.offsetHeight > 0) return Math.min(panel.offsetHeight, max);
24
+ const rows = this.regularOptions().length + (this.showCustomOption() ? 1 : 0);
25
+ return Math.min(Math.max(rows, 1) * SelectComponent.OPTION_HEIGHT + 2, max);
26
+ }
27
+ computeDropdownPosition() {
28
+ const trigger = this.selectTrigger()?.nativeElement;
29
+ if (!trigger) return;
30
+ const rect = trigger.getBoundingClientRect();
31
+ const height = this.dropdownHeight();
32
+ const opensUpward = this.dropdownUpward();
33
+ const inModal = !!trigger.closest("shk-modal");
34
+ let top;
35
+ if (opensUpward) {
36
+ top = rect.top - height - 4;
37
+ if (top < 8) top = 8;
38
+ } else {
39
+ top = rect.bottom + 4;
40
+ if (!inModal && top + height > window.innerHeight - 8 && rect.top - height - 4 >= 8) top = rect.top - height - 4;
41
+ }
42
+ this.dropdownPosition.set({
43
+ top,
44
+ left: rect.left,
45
+ width: rect.width
46
+ });
47
+ }
48
+ constructor(elementRef) {
49
+ this.elementRef = elementRef;
50
+ this.getIcon = (name) => getIcon(name, LucideChevronDown);
51
+ this.options = input([], ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
52
+ this.multiple = input(false, ...ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []);
53
+ this.validCombinations = input(void 0, ...ngDevMode ? [{ debugName: "validCombinations" }] : /* istanbul ignore next */ []);
54
+ this.placeholder = input("Seleccionar...", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
55
+ this.label = input(void 0, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
56
+ this.isLoading = input(false, ...ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []);
57
+ this.isAllDataLoaded = input(false, ...ngDevMode ? [{ debugName: "isAllDataLoaded" }] : /* istanbul ignore next */ []);
58
+ this.allowCustomEntries = input(false, ...ngDevMode ? [{ debugName: "allowCustomEntries" }] : /* istanbul ignore next */ []);
59
+ this.formGroup = input(void 0, ...ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []);
60
+ this.isSearchable = input(false, ...ngDevMode ? [{ debugName: "isSearchable" }] : /* istanbul ignore next */ []);
61
+ this.itemsPerPage = input(10, ...ngDevMode ? [{ debugName: "itemsPerPage" }] : /* istanbul ignore next */ []);
62
+ this.control = input(void 0, ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
63
+ this.usePagination = input(false, ...ngDevMode ? [{ debugName: "usePagination" }] : /* istanbul ignore next */ []);
64
+ this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
65
+ this.errorMessages = input({ required: "Este campo es requerido" }, ...ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []);
66
+ this.preserveSearchOnLoad = input(false, ...ngDevMode ? [{ debugName: "preserveSearchOnLoad" }] : /* istanbul ignore next */ []);
67
+ this.emptyMessageKey = input("common.no_records", ...ngDevMode ? [{ debugName: "emptyMessageKey" }] : /* istanbul ignore next */ []);
68
+ this.dropdownUpward = input(false, ...ngDevMode ? [{ debugName: "dropdownUpward" }] : /* istanbul ignore next */ []);
69
+ this.showEmptyOption = input(true, ...ngDevMode ? [{ debugName: "showEmptyOption" }] : /* istanbul ignore next */ []);
70
+ this.selectionChange = output();
71
+ this.touch = output();
72
+ this.search = output();
73
+ this.filterInput = viewChild("filterInput", ...ngDevMode ? [{ debugName: "filterInput" }] : /* istanbul ignore next */ []);
74
+ this.selectContainer = viewChild("selectContainer", ...ngDevMode ? [{ debugName: "selectContainer" }] : /* istanbul ignore next */ []);
75
+ this.selectTrigger = viewChild("selectTrigger", ...ngDevMode ? [{ debugName: "selectTrigger" }] : /* istanbul ignore next */ []);
76
+ this.dropdownContainer = viewChild("dropdownContainer", ...ngDevMode ? [{ debugName: "dropdownContainer" }] : /* istanbul ignore next */ []);
77
+ this.value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
78
+ this.isOpen = signal(false, ...ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []);
79
+ this.focusedIndex = signal(-1, ...ngDevMode ? [{ debugName: "focusedIndex" }] : /* istanbul ignore next */ []);
80
+ this.searchTerm = signal("", ...ngDevMode ? [{ debugName: "searchTerm" }] : /* istanbul ignore next */ []);
81
+ this.currentPage = signal(1, ...ngDevMode ? [{ debugName: "currentPage" }] : /* istanbul ignore next */ []);
82
+ this.searchTermChanged = signal(false, ...ngDevMode ? [{ debugName: "searchTermChanged" }] : /* istanbul ignore next */ []);
83
+ this._isDisabled = signal(false, ...ngDevMode ? [{ debugName: "_isDisabled" }] : /* istanbul ignore next */ []);
84
+ this.debounceTimer = null;
85
+ this.errorTracker = signal(0, ...ngDevMode ? [{ debugName: "errorTracker" }] : /* istanbul ignore next */ []);
86
+ this.hadError = signal(false, ...ngDevMode ? [{ debugName: "hadError" }] : /* istanbul ignore next */ []);
87
+ this.subscribed = signal(false, ...ngDevMode ? [{ debugName: "subscribed" }] : /* istanbul ignore next */ []);
88
+ this.valueSubscribed = signal(false, ...ngDevMode ? [{ debugName: "valueSubscribed" }] : /* istanbul ignore next */ []);
89
+ this.isDisabled = computed(() => this.disabled() || this._isDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
90
+ this.actualControl = computed(() => {
91
+ const ctrl = this.control();
92
+ if (ctrl) return ctrl;
93
+ const fg = this.formGroup();
94
+ const lbl = this.label();
95
+ if (fg && lbl) return fg.get(lbl);
96
+ }, ...ngDevMode ? [{ debugName: "actualControl" }] : /* istanbul ignore next */ []);
97
+ this.shouldShowError = computed(() => {
98
+ this.errorTracker();
99
+ const ctrl = this.actualControl();
100
+ return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);
101
+ }, ...ngDevMode ? [{ debugName: "shouldShowError" }] : /* istanbul ignore next */ []);
102
+ this.wasFixedError = computed(() => {
103
+ this.errorTracker();
104
+ const ctrl = this.actualControl();
105
+ return this.hadError() && ctrl?.valid && ctrl?.touched;
106
+ }, ...ngDevMode ? [{ debugName: "wasFixedError" }] : /* istanbul ignore next */ []);
107
+ this.displayValue = computed(() => {
108
+ const val = this._value();
109
+ const opts = this.options();
110
+ const isMultiple = this.multiple();
111
+ const ph = this.placeholder();
112
+ if (!val || Array.isArray(val) && val.length === 0) return ph;
113
+ if (isMultiple) {
114
+ const values = Array.isArray(val) ? val : [];
115
+ const selectedLabels = opts.filter((option) => values.includes(option.value)).map((option) => option.label);
116
+ if (selectedLabels.length === 0) return values.toString();
117
+ return selectedLabels.join(", ");
118
+ }
119
+ const selectedOption = opts.find((opt) => opt.value === val);
120
+ return selectedOption ? selectedOption.label : val;
121
+ }, ...ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []);
122
+ this.getErrorMessages = computed(() => {
123
+ this.errorTracker();
124
+ const ctrl = this.actualControl();
125
+ if (!ctrl?.errors) return [];
126
+ const customErrors = this.errorMessages();
127
+ const t = this.transloco;
128
+ return Object.keys(ctrl.errors).map((errorKey) => {
129
+ if (customErrors[errorKey]) return customErrors[errorKey];
130
+ switch (errorKey) {
131
+ case "required": return t.translate("validation.required");
132
+ case "email": return t.translate("validation.email");
133
+ case "minlength": return t.translate("validation.minlength", { min: ctrl.errors["minlength"].requiredLength });
134
+ case "maxlength": return t.translate("validation.maxlength", { max: ctrl.errors["maxlength"].requiredLength });
135
+ case "pattern": return t.translate("validation.pattern");
136
+ default: return t.translate("validation.invalid");
137
+ }
138
+ });
139
+ }, ...ngDevMode ? [{ debugName: "getErrorMessages" }] : /* istanbul ignore next */ []);
140
+ this.filteredOptions = computed(() => {
141
+ const opts = this.options();
142
+ const term = this.searchTerm();
143
+ if (!term) return opts;
144
+ const normalizedSearchTerm = this.normalizeText(term);
145
+ return opts.filter((option) => this.normalizeText(option.label).includes(normalizedSearchTerm)).sort((a, b) => {
146
+ const aLbl = this.normalizeText(a.label);
147
+ const bLbl = this.normalizeText(b.label);
148
+ const aStarts = aLbl.startsWith(normalizedSearchTerm);
149
+ const bStarts = bLbl.startsWith(normalizedSearchTerm);
150
+ if (aStarts && !bStarts) return -1;
151
+ if (!aStarts && bStarts) return 1;
152
+ return 0;
153
+ });
154
+ }, ...ngDevMode ? [{ debugName: "filteredOptions" }] : /* istanbul ignore next */ []);
155
+ this.paginatedOptions = computed(() => {
156
+ let filtered = this.filteredOptions();
157
+ const term = this.searchTerm();
158
+ if (this.allowCustomEntries() && term && !filtered.some((o) => o.value === term)) filtered = [{
159
+ label: `${term} (nuevo)`,
160
+ value: term,
161
+ custom: true
162
+ }, ...filtered];
163
+ if (!this.usePagination()) return filtered;
164
+ const page = this.currentPage();
165
+ const perPage = this.itemsPerPage();
166
+ const startIndex = (page - 1) * perPage;
167
+ const endIndex = startIndex + perPage;
168
+ return filtered.slice(startIndex, endIndex);
169
+ }, ...ngDevMode ? [{ debugName: "paginatedOptions" }] : /* istanbul ignore next */ []);
170
+ this.regularOptions = computed(() => {
171
+ const opts = this.paginatedOptions().filter((option) => !option.custom);
172
+ if (!this.multiple() && this.showEmptyOption()) return [{
173
+ label: "- Sin selección -",
174
+ value: null
175
+ }, ...opts];
176
+ return opts;
177
+ }, ...ngDevMode ? [{ debugName: "regularOptions" }] : /* istanbul ignore next */ []);
178
+ this.totalPages = computed(() => {
179
+ if (!this.usePagination()) return 1;
180
+ const filtered = this.filteredOptions();
181
+ const perPage = this.itemsPerPage();
182
+ return Math.ceil(filtered.length / perPage);
183
+ }, ...ngDevMode ? [{ debugName: "totalPages" }] : /* istanbul ignore next */ []);
184
+ this.hasSelectedValues = computed(() => {
185
+ const val = this._value();
186
+ if (this.multiple()) return val && val.length > 0;
187
+ return !!val;
188
+ }, ...ngDevMode ? [{ debugName: "hasSelectedValues" }] : /* istanbul ignore next */ []);
189
+ this.showCustomOption = computed(() => {
190
+ const term = this.searchTerm();
191
+ const opts = this.options();
192
+ return this.allowCustomEntries() && term !== "" && !opts.some((o) => o.value === term);
193
+ }, ...ngDevMode ? [{ debugName: "showCustomOption" }] : /* istanbul ignore next */ []);
194
+ this.dropdownPosition = signal({
195
+ top: 0,
196
+ left: 0,
197
+ width: 0
198
+ }, ...ngDevMode ? [{ debugName: "dropdownPosition" }] : /* istanbul ignore next */ []);
199
+ this.transloco = inject(TranslocoService);
200
+ this.onChange = (_) => {};
201
+ this.onTouched = () => {};
202
+ this.destroyRef = inject(DestroyRef);
203
+ this.scrollCloseHandler = (event) => {
204
+ const target = event.target;
205
+ if (target && this.isInsideComponent(target)) return;
206
+ if (this.isOpen()) {
207
+ this.isOpen.set(false);
208
+ this.searchTerm.set("");
209
+ this.focusedIndex.set(-1);
210
+ }
211
+ };
212
+ const doc = this.elementRef.nativeElement.ownerDocument;
213
+ doc.addEventListener("scroll", this.scrollCloseHandler, true);
214
+ this.destroyRef.onDestroy(() => doc.removeEventListener("scroll", this.scrollCloseHandler, true));
215
+ effect(() => {
216
+ const term = this.searchTerm();
217
+ if (term !== "" && this.isSearchable()) {
218
+ if (this.debounceTimer) clearTimeout(this.debounceTimer);
219
+ this.debounceTimer = setTimeout(() => {
220
+ this.search.emit(term);
221
+ }, 300);
222
+ }
223
+ });
224
+ effect(() => {
225
+ const isMultiple = this.multiple();
226
+ if (this._value() === null || this._value() === void 0) this._value.set(isMultiple ? [] : null);
227
+ });
228
+ effect(() => {
229
+ this.options();
230
+ this.currentPage.set(1);
231
+ if (!this.preserveSearchOnLoad() || !this.searchTermChanged()) this.searchTerm.set("");
232
+ });
233
+ effect(() => {
234
+ const ctrl = this.actualControl();
235
+ if (!ctrl) {
236
+ this.subscribed.set(false);
237
+ return;
238
+ }
239
+ if (this.subscribed()) return;
240
+ if (ctrl.invalid && ctrl.touched) this.hadError.set(true);
241
+ ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
242
+ this.errorTracker.update((v) => v + 1);
243
+ if (ctrl.invalid && ctrl.touched) this.hadError.set(true);
244
+ });
245
+ ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
246
+ this.errorTracker.update((v) => v + 1);
247
+ });
248
+ this.subscribed.set(true);
249
+ });
250
+ this.transloco.langChanges$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
251
+ this.errorTracker.update((v) => v + 1);
252
+ });
253
+ effect(() => {
254
+ const ctrl = this.actualControl();
255
+ if (!ctrl) return;
256
+ if (!this.valueSubscribed()) {
257
+ this.writeValue(ctrl.value);
258
+ ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => {
259
+ this.writeValue(value);
260
+ });
261
+ this.valueSubscribed.set(true);
262
+ }
263
+ });
264
+ }
265
+ setDisabledState(isDisabled) {
266
+ this._isDisabled.set(isDisabled);
267
+ }
268
+ markAsTouchedAndUpdate() {
269
+ this.touch.emit();
270
+ const ctrl = this.actualControl();
271
+ if (ctrl) {
272
+ ctrl.markAsTouched();
273
+ ctrl.updateValueAndValidity({ emitEvent: false });
274
+ }
275
+ this.onTouched();
276
+ this.errorTracker.update((v) => v + 1);
277
+ if (ctrl?.invalid) this.hadError.set(true);
278
+ }
279
+ normalizeText(text) {
280
+ return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
281
+ }
282
+ onKeydown(event) {
283
+ if (this.isDisabled()) return;
284
+ switch (event.key) {
285
+ case "Enter":
286
+ case " ":
287
+ event.preventDefault();
288
+ if (this.isOpen()) {
289
+ if (this.focusedIndex() >= 0) {
290
+ const selectedOption = this.regularOptions()[this.focusedIndex()];
291
+ if (selectedOption && !this.isOptionDisabled(selectedOption)) this.selectOption(selectedOption);
292
+ }
293
+ } else this.toggleDropdown();
294
+ break;
295
+ case "Escape":
296
+ if (this.isOpen()) {
297
+ this.isOpen.set(false);
298
+ this.searchTerm.set("");
299
+ this.focusedIndex.set(-1);
300
+ this.selectTrigger()?.nativeElement.focus();
301
+ }
302
+ break;
303
+ case "ArrowDown":
304
+ event.preventDefault();
305
+ if (!this.isOpen()) this.toggleDropdown();
306
+ else this.moveFocus(1);
307
+ break;
308
+ case "ArrowUp":
309
+ event.preventDefault();
310
+ if (this.isOpen()) this.moveFocus(-1);
311
+ break;
312
+ case "Tab": if (this.isOpen()) {
313
+ this.isOpen.set(false);
314
+ this.searchTerm.set("");
315
+ this.focusedIndex.set(-1);
316
+ }
317
+ }
318
+ }
319
+ handleKeyDown(event) {
320
+ switch (event.key) {
321
+ case "Enter":
322
+ event.preventDefault();
323
+ event.stopPropagation();
324
+ if (this.focusedIndex() >= 0) {
325
+ const option = this.regularOptions()[this.focusedIndex()];
326
+ if (option && !this.isOptionDisabled(option)) this.selectOption(option);
327
+ } else {
328
+ const filtered = this.filteredOptions();
329
+ if (filtered.length > 0) this.selectOption(filtered[0]);
330
+ }
331
+ break;
332
+ case "ArrowDown":
333
+ event.preventDefault();
334
+ event.stopPropagation();
335
+ this.moveFocus(1);
336
+ break;
337
+ case "ArrowUp":
338
+ event.preventDefault();
339
+ event.stopPropagation();
340
+ this.moveFocus(-1);
341
+ break;
342
+ case "Escape":
343
+ event.stopPropagation();
344
+ event.preventDefault();
345
+ this.isOpen.set(false);
346
+ this.searchTerm.set("");
347
+ this.focusedIndex.set(-1);
348
+ this.selectTrigger()?.nativeElement.focus();
349
+ }
350
+ }
351
+ moveFocus(direction) {
352
+ const options = this.regularOptions();
353
+ if (!options.length) return;
354
+ let newIndex = this.focusedIndex();
355
+ do {
356
+ newIndex = newIndex + direction;
357
+ if (newIndex < 0) newIndex = options.length - 1;
358
+ if (newIndex >= options.length) newIndex = 0;
359
+ } while (this.isOptionDisabled(options[newIndex]) && options.length > 1);
360
+ this.focusedIndex.set(newIndex);
361
+ setTimeout(() => {
362
+ const container = this.dropdownContainer()?.nativeElement;
363
+ const activeItem = container?.querySelector(".select-option-active");
364
+ if (activeItem && container) {
365
+ const itemTop = activeItem.offsetTop;
366
+ const itemBottom = itemTop + activeItem.offsetHeight;
367
+ const containerScrollTop = container.scrollTop;
368
+ const containerHeight = container.clientHeight;
369
+ if (itemTop < containerScrollTop) container.scrollTop = itemTop;
370
+ else if (itemBottom > containerScrollTop + containerHeight) container.scrollTop = itemBottom - containerHeight;
371
+ }
372
+ });
373
+ }
374
+ getSelectedIndex() {
375
+ const currentVal = this._value();
376
+ const options = this.regularOptions();
377
+ if (currentVal === null || currentVal === void 0) return -1;
378
+ const index = options.findIndex((opt) => opt.value === currentVal);
379
+ return index >= 0 ? index : -1;
380
+ }
381
+ isOptionDisabled(option) {
382
+ if (option.value === null) return false;
383
+ const validCombos = this.validCombinations();
384
+ if (!validCombos || !this.multiple()) return false;
385
+ const currentSelection = Array.isArray(this._value()) ? this._value() : [];
386
+ if (currentSelection.length === 0) return false;
387
+ if (currentSelection.includes(option.value)) return false;
388
+ const hypotheticalSelection = [...currentSelection, option.value];
389
+ return !validCombos.some((combination) => {
390
+ const allSelected = hypotheticalSelection.every((selected) => combination.includes(selected));
391
+ const withinLimit = hypotheticalSelection.length <= combination.length;
392
+ return allSelected && withinLimit;
393
+ });
394
+ }
395
+ isSelected(option) {
396
+ const val = this._value();
397
+ if (this.multiple()) return Array.isArray(val) && val.includes(option.value);
398
+ return val === option.value;
399
+ }
400
+ nextPage() {
401
+ const total = this.totalPages();
402
+ const current = this.currentPage();
403
+ if (current < total) this.currentPage.set(current + 1);
404
+ }
405
+ previousPage() {
406
+ const current = this.currentPage();
407
+ if (current > 1) this.currentPage.set(current - 1);
408
+ }
409
+ isInsideComponent(target) {
410
+ if (!target) return false;
411
+ if (this.elementRef.nativeElement.contains(target)) return true;
412
+ const panel = this.dropdownContainer()?.nativeElement;
413
+ return !!panel && panel.contains(target);
414
+ }
415
+ onClickOutside(event) {
416
+ if (!this.isInsideComponent(event.target) && this.isOpen()) {
417
+ this.markAsTouchedAndUpdate();
418
+ this.isOpen.set(false);
419
+ this.searchTerm.set("");
420
+ this.focusedIndex.set(-1);
421
+ }
422
+ }
423
+ onCustomOptionClick() {
424
+ const term = this.searchTerm();
425
+ const customOption = {
426
+ label: term,
427
+ value: term
428
+ };
429
+ this._value.set(customOption.value);
430
+ this.onChange(customOption.value);
431
+ this.selectionChange.emit(customOption.value);
432
+ this.isOpen.set(false);
433
+ this.searchTerm.set("");
434
+ const ctrl = this.actualControl();
435
+ if (ctrl) ctrl.setValue(customOption.value);
436
+ this.markAsTouchedAndUpdate();
437
+ }
438
+ onInputChange(event) {
439
+ const previousSearch = this.searchTerm();
440
+ const target = event.target;
441
+ this.searchTerm.set(target.value);
442
+ this.searchTermChanged.set(true);
443
+ if (previousSearch !== this.searchTerm()) {
444
+ this.search.emit(this.searchTerm());
445
+ if (this.allowCustomEntries() && this.searchTerm()) {
446
+ this._value.set(this.searchTerm());
447
+ this.onChange(this.searchTerm());
448
+ this.selectionChange.emit(this.searchTerm());
449
+ }
450
+ }
451
+ this.currentPage.set(1);
452
+ }
453
+ onOptionClick(option) {
454
+ if (this.isDisabled()) return;
455
+ if (this.allowCustomEntries() && option.value === this.searchTerm()) {
456
+ const customOption = {
457
+ label: this.searchTerm(),
458
+ value: this.searchTerm()
459
+ };
460
+ this._value.set(customOption.value);
461
+ this.onChange(customOption.value);
462
+ this.selectionChange.emit(customOption.value);
463
+ this.isOpen.set(false);
464
+ this.searchTerm.set("");
465
+ const ctrl = this.actualControl();
466
+ if (ctrl) ctrl.setValue(customOption.value);
467
+ this.markAsTouchedAndUpdate();
468
+ return;
469
+ }
470
+ if (this.multiple()) this.toggleOption(option);
471
+ else this.selectOption(option);
472
+ }
473
+ selectOption(option) {
474
+ if (this.multiple()) {
475
+ this.toggleOption(option);
476
+ return;
477
+ }
478
+ this._value.set(option.value);
479
+ this.onChange(option.value);
480
+ this.onTouched();
481
+ this.selectionChange.emit(option.value);
482
+ this.isOpen.set(false);
483
+ const ctrl = this.actualControl();
484
+ if (ctrl) ctrl.setValue(option.value);
485
+ this.markAsTouchedAndUpdate();
486
+ this.focusedIndex.set(-1);
487
+ this.selectTrigger()?.nativeElement.focus();
488
+ }
489
+ toggleOption(option) {
490
+ if (this.isOptionDisabled(option)) return;
491
+ if (!this.multiple()) return;
492
+ let currentValue = this._value();
493
+ if (!Array.isArray(currentValue)) currentValue = [];
494
+ const index = currentValue.indexOf(option.value);
495
+ let newValue;
496
+ if (index === -1) newValue = [...currentValue, option.value];
497
+ else newValue = currentValue.filter((v) => v !== option.value);
498
+ this._value.set(newValue);
499
+ this.onChange(newValue);
500
+ this.onTouched();
501
+ this.selectionChange.emit(newValue);
502
+ this.markAsTouchedAndUpdate();
503
+ }
504
+ toggleDropdown() {
505
+ if (this.isDisabled()) return;
506
+ const wasOpen = this.isOpen();
507
+ this.isOpen.update((v) => !v);
508
+ if (!wasOpen && this.isOpen()) {
509
+ const selectedIdx = this.getSelectedIndex();
510
+ this.focusedIndex.set(selectedIdx);
511
+ } else if (wasOpen && !this.isOpen()) {
512
+ this.searchTerm.set("");
513
+ this.focusedIndex.set(-1);
514
+ this.selectTrigger()?.nativeElement.focus();
515
+ }
516
+ if (this.isOpen() && this.isSearchable()) setTimeout(() => {
517
+ this.filterInput()?.nativeElement?.focus();
518
+ });
519
+ if (this.isOpen()) {
520
+ this.computeDropdownPosition();
521
+ requestAnimationFrame(() => {
522
+ if (this.isOpen()) this.computeDropdownPosition();
523
+ });
524
+ }
525
+ this.onTouched();
526
+ }
527
+ trackByFn(index, option) {
528
+ return option.value;
529
+ }
530
+ writeValue(value) {
531
+ if (value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0) this._value.set(this.multiple() ? [] : null);
532
+ else this._value.set(value);
533
+ }
534
+ registerOnChange(fn) {
535
+ this.onChange = fn;
536
+ }
537
+ registerOnTouched(fn) {
538
+ this.onTouched = fn;
539
+ }
540
+ static {
541
+ this.ɵfac = i0.ɵɵngDeclareFactory({
542
+ minVersion: "12.0.0",
543
+ version: "22.3.2",
544
+ ngImport: i0,
545
+ type: SelectComponent,
546
+ deps: [{ token: ElementRef }],
547
+ target: i0.ɵɵFactoryTarget.Component
548
+ });
549
+ }
550
+ static {
551
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
552
+ minVersion: "17.0.0",
553
+ version: "22.3.2",
554
+ type: SelectComponent,
555
+ isStandalone: true,
556
+ selector: "shk-select",
557
+ inputs: {
558
+ options: {
559
+ classPropertyName: "options",
560
+ publicName: "options",
561
+ isSignal: true,
562
+ isRequired: false,
563
+ transformFunction: null
564
+ },
565
+ multiple: {
566
+ classPropertyName: "multiple",
567
+ publicName: "multiple",
568
+ isSignal: true,
569
+ isRequired: false,
570
+ transformFunction: null
571
+ },
572
+ validCombinations: {
573
+ classPropertyName: "validCombinations",
574
+ publicName: "validCombinations",
575
+ isSignal: true,
576
+ isRequired: false,
577
+ transformFunction: null
578
+ },
579
+ placeholder: {
580
+ classPropertyName: "placeholder",
581
+ publicName: "placeholder",
582
+ isSignal: true,
583
+ isRequired: false,
584
+ transformFunction: null
585
+ },
586
+ label: {
587
+ classPropertyName: "label",
588
+ publicName: "label",
589
+ isSignal: true,
590
+ isRequired: false,
591
+ transformFunction: null
592
+ },
593
+ isLoading: {
594
+ classPropertyName: "isLoading",
595
+ publicName: "isLoading",
596
+ isSignal: true,
597
+ isRequired: false,
598
+ transformFunction: null
599
+ },
600
+ isAllDataLoaded: {
601
+ classPropertyName: "isAllDataLoaded",
602
+ publicName: "isAllDataLoaded",
603
+ isSignal: true,
604
+ isRequired: false,
605
+ transformFunction: null
606
+ },
607
+ allowCustomEntries: {
608
+ classPropertyName: "allowCustomEntries",
609
+ publicName: "allowCustomEntries",
610
+ isSignal: true,
611
+ isRequired: false,
612
+ transformFunction: null
613
+ },
614
+ formGroup: {
615
+ classPropertyName: "formGroup",
616
+ publicName: "formGroup",
617
+ isSignal: true,
618
+ isRequired: false,
619
+ transformFunction: null
620
+ },
621
+ isSearchable: {
622
+ classPropertyName: "isSearchable",
623
+ publicName: "isSearchable",
624
+ isSignal: true,
625
+ isRequired: false,
626
+ transformFunction: null
627
+ },
628
+ itemsPerPage: {
629
+ classPropertyName: "itemsPerPage",
630
+ publicName: "itemsPerPage",
631
+ isSignal: true,
632
+ isRequired: false,
633
+ transformFunction: null
634
+ },
635
+ control: {
636
+ classPropertyName: "control",
637
+ publicName: "control",
638
+ isSignal: true,
639
+ isRequired: false,
640
+ transformFunction: null
641
+ },
642
+ usePagination: {
643
+ classPropertyName: "usePagination",
644
+ publicName: "usePagination",
645
+ isSignal: true,
646
+ isRequired: false,
647
+ transformFunction: null
648
+ },
649
+ disabled: {
650
+ classPropertyName: "disabled",
651
+ publicName: "disabled",
652
+ isSignal: true,
653
+ isRequired: false,
654
+ transformFunction: null
655
+ },
656
+ errorMessages: {
657
+ classPropertyName: "errorMessages",
658
+ publicName: "errorMessages",
659
+ isSignal: true,
660
+ isRequired: false,
661
+ transformFunction: null
662
+ },
663
+ preserveSearchOnLoad: {
664
+ classPropertyName: "preserveSearchOnLoad",
665
+ publicName: "preserveSearchOnLoad",
666
+ isSignal: true,
667
+ isRequired: false,
668
+ transformFunction: null
669
+ },
670
+ emptyMessageKey: {
671
+ classPropertyName: "emptyMessageKey",
672
+ publicName: "emptyMessageKey",
673
+ isSignal: true,
674
+ isRequired: false,
675
+ transformFunction: null
676
+ },
677
+ dropdownUpward: {
678
+ classPropertyName: "dropdownUpward",
679
+ publicName: "dropdownUpward",
680
+ isSignal: true,
681
+ isRequired: false,
682
+ transformFunction: null
683
+ },
684
+ showEmptyOption: {
685
+ classPropertyName: "showEmptyOption",
686
+ publicName: "showEmptyOption",
687
+ isSignal: true,
688
+ isRequired: false,
689
+ transformFunction: null
690
+ },
691
+ value: {
692
+ classPropertyName: "value",
693
+ publicName: "value",
694
+ isSignal: true,
695
+ isRequired: false,
696
+ transformFunction: null
697
+ }
698
+ },
699
+ outputs: {
700
+ selectionChange: "selectionChange",
701
+ touch: "touch",
702
+ search: "search",
703
+ value: "valueChange"
704
+ },
705
+ host: { listeners: { "document:mousedown": "onClickOutside($event)" } },
706
+ providers: [{
707
+ provide: NG_VALUE_ACCESSOR,
708
+ useExisting: forwardRef(() => SelectComponent),
709
+ multi: true
710
+ }],
711
+ viewQueries: [
712
+ {
713
+ propertyName: "filterInput",
714
+ first: true,
715
+ predicate: ["filterInput"],
716
+ descendants: true,
717
+ isSignal: true
718
+ },
719
+ {
720
+ propertyName: "selectContainer",
721
+ first: true,
722
+ predicate: ["selectContainer"],
723
+ descendants: true,
724
+ isSignal: true
725
+ },
726
+ {
727
+ propertyName: "selectTrigger",
728
+ first: true,
729
+ predicate: ["selectTrigger"],
730
+ descendants: true,
731
+ isSignal: true
732
+ },
733
+ {
734
+ propertyName: "dropdownContainer",
735
+ first: true,
736
+ predicate: ["dropdownContainer"],
737
+ descendants: true,
738
+ isSignal: true
739
+ }
740
+ ],
741
+ ngImport: i0,
742
+ template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"shk-control flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class.shk-control-disabled]=\"isDisabled()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n shkPortal\n (keydown)=\"onKeydown($event)\"\n class=\"shk-select-panel fixed _shk-bg-surface-50 border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700\"\n [class.shk-select-option-disabled]=\"isOptionDisabled(option)\"\n [class.shk-select-option-selected]=\"!multiple() && option.value !== null && isSelected(option)\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n <span class=\"shk-select-option-label flex-1 min-w-0\">{{ option.label }}</span>\n @if (option.value !== null && isSelected(option)) {\n <svg [shkIcon]=\"getIcon('check')\" class=\"shk-select-check w-4 h-4 shrink-0\"></svg>\n }\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando más resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>",
743
+ styles: [".shk-select-panel{padding:.25rem;border-radius:.625rem;box-shadow:0 10px 24px -6px #0000001f,0 4px 8px -4px #0000000f;animation:shk-select-in .12s ease-out}@keyframes shk-select-in{0%{opacity:0;transform:translateY(-4px) scale(.98)}}@keyframes shk-spin{to{transform:rotate(360deg)}}.shk-select-option{border-radius:.375rem;transition:background-color .1s ease}.shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-select-option:hover:not(.shk-select-option-disabled),.dark .shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-200)}.shk-select-option-label{overflow-wrap:anywhere}.spinner{width:1rem;height:1rem;animation:shk-spin .9s linear infinite;transform-origin:center}.spinner .path{stroke:var(--shk-surface-400);stroke-linecap:round;stroke-dasharray:90,150;stroke-dashoffset:0}.shk-select-option-disabled{cursor:not-allowed}.shk-select-option-selected{color:var(--shk-primary-700);font-weight:500}:host-context(.dark) .shk-select-option-selected,.dark .shk-select-option-selected{color:var(--shk-primary-400)}.shk-select-check{color:var(--shk-primary-600)}:host-context(.dark) .shk-select-check,.dark .shk-select-check{color:var(--shk-primary-400)}.select-option-active{background-color:var(--shk-primary-50);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--shk-primary-500) 35%,transparent);color:var(--shk-primary-700)}:host-context(.dark) .select-option-active,.dark .select-option-active{background-color:color-mix(in srgb,var(--shk-primary-900) 40%,transparent);color:var(--shk-primary-300)}\n"],
744
+ dependencies: [
745
+ {
746
+ kind: "directive",
747
+ type: PortalDirective,
748
+ selector: "[shkPortal]"
749
+ },
750
+ {
751
+ kind: "ngmodule",
752
+ type: CommonModule
753
+ },
754
+ {
755
+ kind: "ngmodule",
756
+ type: ReactiveFormsModule
757
+ },
758
+ {
759
+ kind: "ngmodule",
760
+ type: FormsModule
761
+ },
762
+ {
763
+ kind: "ngmodule",
764
+ type: TranslocoModule
765
+ },
766
+ {
767
+ kind: "directive",
768
+ type: ShkIconDirective,
769
+ selector: "svg[shkIcon]",
770
+ inputs: [
771
+ "shkIcon",
772
+ "size",
773
+ "strokeWidth",
774
+ "color"
775
+ ]
776
+ },
777
+ {
778
+ kind: "pipe",
779
+ type: i1.TranslocoPipe,
780
+ name: "transloco"
781
+ }
782
+ ],
783
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
784
+ });
785
+ }
786
+ };
787
+ i0.ɵɵngDeclareClassMetadata({
788
+ minVersion: "12.0.0",
789
+ version: "22.3.2",
790
+ ngImport: i0,
791
+ type: SelectComponent,
792
+ decorators: [{
793
+ type: Component,
794
+ args: [{
795
+ selector: "shk-select",
796
+ imports: [
797
+ PortalDirective,
798
+ CommonModule,
799
+ ReactiveFormsModule,
800
+ FormsModule,
801
+ TranslocoModule,
802
+ ShkIconDirective
803
+ ],
804
+ changeDetection: ChangeDetectionStrategy.OnPush,
805
+ providers: [{
806
+ provide: NG_VALUE_ACCESSOR,
807
+ useExisting: forwardRef(() => SelectComponent),
808
+ multi: true
809
+ }],
810
+ template: "<div\n #selectContainer\n class=\"relative w-full font-sans outline-none\"\n>\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div\n #selectTrigger\n class=\"shk-control flex justify-between items-center w-full px-3 py-2 border _shk-border rounded-lg _shk-bg-surface-50 transition-colors duration-150 cursor-pointer min-h-[2.5rem] _shk-text-surface-700 focus-within:outline-none focus-within:[background-color:var(--shk-surface-50)] dark:focus-within:[background-color:var(--shk-surface-100)] focus-within:ring-1 focus-within:[--tw-ring-color:var(--shk-primary-500)] focus-within:[border-color:var(--shk-primary-500)] focus:outline-none focus:ring-1 focus:[--tw-ring-color:var(--shk-primary-500)] focus:[border-color:var(--shk-primary-500)] sm:text-sm\"\n [attr.tabindex]=\"isDisabled() ? -1 : 0\"\n (keydown)=\"onKeydown($event)\"\n (click)=\"toggleDropdown()\"\n [class.open]=\"isOpen()\"\n [class.disabled-select]=\"isDisabled()\"\n [class.shk-control-disabled]=\"isDisabled()\"\n [attr.aria-invalid]=\"shouldShowError() || null\"\n [class._shk-border-red]=\"shouldShowError()\"\n >\n <div class=\"selected-value truncate\">\n @if (isSearchable() && isOpen()) {\n <input\n #filterInput\n type=\"text\"\n class=\"w-full bg-transparent border-0 outline-none p-0 _shk-text-surface-700\"\n placeholder=\"Buscar...\"\n [value]=\"searchTerm()\"\n (input)=\"onInputChange($event)\"\n (keydown)=\"handleKeyDown($event)\"\n (click)=\"$event.stopPropagation()\"\n />\n } @else {\n <span\n [class._shk-text-surface-400]=\"!hasSelectedValues()\"\n [class._shk-text-surface-800]=\"hasSelectedValues()\"\n >\n {{ displayValue() }}\n </span>\n }\n </div>\n <div\n class=\"text-xs transition-transform duration-200 shrink-0 ml-2\"\n [class.rotate-180]=\"isOpen()\"\n >\n <svg\n [shkIcon]=\"getIcon('chevron-down')\"\n class=\"w-4 h-4 _shk-text-surface-400\"\n ></svg>\n </div>\n </div>\n\n @if (isOpen()) {\n <div\n #dropdownContainer\n shkPortal\n (keydown)=\"onKeydown($event)\"\n class=\"shk-select-panel fixed _shk-bg-surface-50 border _shk-border rounded-lg max-h-[240px] overflow-y-auto z-[9999] shadow-lg _shk-scrollbar\"\n [style.top]=\"dropdownPosition().top + 'px'\"\n [style.left]=\"dropdownPosition().left + 'px'\"\n [style.width]=\"dropdownPosition().width + 'px'\"\n >\n @if (showCustomOption()) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm\"\n (click)=\"onCustomOptionClick()\"\n >\n <span class=\"font-semibold _shk-text-primary\">Crear nuevo:</span>\n <span class=\"_shk-text-surface-700 ml-1\">{{ searchTerm() }}</span>\n </div>\n }\n\n @for (option of regularOptions(); track trackByFn($index, option); let i = $index) {\n <div\n class=\"shk-select-option flex items-center gap-2 px-3 py-2 cursor-pointer hover:[background-color:var(--shk-surface-50)] dark:hover:[background-color:var(--shk-surface-200)] text-sm _shk-text-surface-700\"\n [class.shk-select-option-disabled]=\"isOptionDisabled(option)\"\n [class.shk-select-option-selected]=\"!multiple() && option.value !== null && isSelected(option)\"\n [class.opacity-50]=\"isOptionDisabled(option)\"\n [class.select-option-active]=\"focusedIndex() === i\"\n [class._shk-text-surface-400]=\"option.value === null\"\n (click)=\"!isOptionDisabled(option) && onOptionClick(option)\"\n >\n @if (multiple()) {\n <input\n type=\"checkbox\"\n [checked]=\"isSelected(option)\"\n [disabled]=\"isOptionDisabled(option)\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"!isOptionDisabled(option) && toggleOption(option)\"\n class=\"flex-shrink-0 [accent-color:var(--shk-primary-600)]\"\n />\n {{ option.label }}\n } @else {\n <span class=\"shk-select-option-label flex-1 min-w-0\">{{ option.label }}</span>\n @if (option.value !== null && isSelected(option)) {\n <svg [shkIcon]=\"getIcon('check')\" class=\"shk-select-check w-4 h-4 shrink-0\"></svg>\n }\n }\n </div>\n }\n\n <div class=\"px-3 py-2 text-center\">\n @if (isLoading() && regularOptions().length === 0) {\n <div class=\"flex items-center justify-center gap-2 text-sm _shk-text-surface-500\">\n <svg class=\"spinner\" viewBox=\"0 0 50 50\">\n <circle\n class=\"path\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n </svg>\n Cargando más resultados...\n </div>\n }\n\n @if (!isLoading() && isAllDataLoaded() && regularOptions().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n No se encontraron coincidencias\n </div>\n }\n\n @if (options().length === 0) {\n <div class=\"text-sm _shk-text-surface-400 italic\">\n {{ emptyMessageKey() | transloco }}\n </div>\n }\n </div>\n\n @if (usePagination() && totalPages() > 1) {\n <div class=\"flex justify-between items-center px-3 py-2 border-t _shk-border\">\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === 1\"\n (click)=\"$event.stopPropagation(); previousPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-left')\" class=\"w-4 h-4\"></svg>\n </button>\n <span class=\"text-sm _shk-text-surface-600\">\n {{ currentPage() }} de {{ totalPages() }}\n </span>\n <button\n class=\"bg-transparent border-0 cursor-pointer px-2 py-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-50 disabled:cursor-not-allowed _shk-text-surface-600\"\n [disabled]=\"currentPage() === totalPages()\"\n (click)=\"$event.stopPropagation(); nextPage()\"\n >\n <svg [shkIcon]=\"getIcon('chevron-right')\" class=\"w-4 h-4\"></svg>\n </button>\n </div>\n }\n </div>\n }\n\n @if (shouldShowError()) {\n <div class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\" tabindex=\"-1\">\n <ul class=\"list-disc pl-4 space-y-1\">\n @for (error of getErrorMessages(); track error) {\n <li>{{ error }}</li>\n }\n </ul>\n </div>\n }\n</div>",
811
+ styles: [".shk-select-panel{padding:.25rem;border-radius:.625rem;box-shadow:0 10px 24px -6px #0000001f,0 4px 8px -4px #0000000f;animation:shk-select-in .12s ease-out}@keyframes shk-select-in{0%{opacity:0;transform:translateY(-4px) scale(.98)}}@keyframes shk-spin{to{transform:rotate(360deg)}}.shk-select-option{border-radius:.375rem;transition:background-color .1s ease}.shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-100)}:host-context(.dark) .shk-select-option:hover:not(.shk-select-option-disabled),.dark .shk-select-option:hover:not(.shk-select-option-disabled){background-color:var(--shk-surface-200)}.shk-select-option-label{overflow-wrap:anywhere}.spinner{width:1rem;height:1rem;animation:shk-spin .9s linear infinite;transform-origin:center}.spinner .path{stroke:var(--shk-surface-400);stroke-linecap:round;stroke-dasharray:90,150;stroke-dashoffset:0}.shk-select-option-disabled{cursor:not-allowed}.shk-select-option-selected{color:var(--shk-primary-700);font-weight:500}:host-context(.dark) .shk-select-option-selected,.dark .shk-select-option-selected{color:var(--shk-primary-400)}.shk-select-check{color:var(--shk-primary-600)}:host-context(.dark) .shk-select-check,.dark .shk-select-check{color:var(--shk-primary-400)}.select-option-active{background-color:var(--shk-primary-50);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--shk-primary-500) 35%,transparent);color:var(--shk-primary-700)}:host-context(.dark) .select-option-active,.dark .select-option-active{background-color:color-mix(in srgb,var(--shk-primary-900) 40%,transparent);color:var(--shk-primary-300)}\n"]
812
+ }]
813
+ }],
814
+ ctorParameters: () => [{ type: ElementRef }],
815
+ propDecorators: {
816
+ options: [{
817
+ type: i0.Input,
818
+ args: [{
819
+ isSignal: true,
820
+ alias: "options",
821
+ required: false
822
+ }]
823
+ }],
824
+ multiple: [{
825
+ type: i0.Input,
826
+ args: [{
827
+ isSignal: true,
828
+ alias: "multiple",
829
+ required: false
830
+ }]
831
+ }],
832
+ validCombinations: [{
833
+ type: i0.Input,
834
+ args: [{
835
+ isSignal: true,
836
+ alias: "validCombinations",
837
+ required: false
838
+ }]
839
+ }],
840
+ placeholder: [{
841
+ type: i0.Input,
842
+ args: [{
843
+ isSignal: true,
844
+ alias: "placeholder",
845
+ required: false
846
+ }]
847
+ }],
848
+ label: [{
849
+ type: i0.Input,
850
+ args: [{
851
+ isSignal: true,
852
+ alias: "label",
853
+ required: false
854
+ }]
855
+ }],
856
+ isLoading: [{
857
+ type: i0.Input,
858
+ args: [{
859
+ isSignal: true,
860
+ alias: "isLoading",
861
+ required: false
862
+ }]
863
+ }],
864
+ isAllDataLoaded: [{
865
+ type: i0.Input,
866
+ args: [{
867
+ isSignal: true,
868
+ alias: "isAllDataLoaded",
869
+ required: false
870
+ }]
871
+ }],
872
+ allowCustomEntries: [{
873
+ type: i0.Input,
874
+ args: [{
875
+ isSignal: true,
876
+ alias: "allowCustomEntries",
877
+ required: false
878
+ }]
879
+ }],
880
+ formGroup: [{
881
+ type: i0.Input,
882
+ args: [{
883
+ isSignal: true,
884
+ alias: "formGroup",
885
+ required: false
886
+ }]
887
+ }],
888
+ isSearchable: [{
889
+ type: i0.Input,
890
+ args: [{
891
+ isSignal: true,
892
+ alias: "isSearchable",
893
+ required: false
894
+ }]
895
+ }],
896
+ itemsPerPage: [{
897
+ type: i0.Input,
898
+ args: [{
899
+ isSignal: true,
900
+ alias: "itemsPerPage",
901
+ required: false
902
+ }]
903
+ }],
904
+ control: [{
905
+ type: i0.Input,
906
+ args: [{
907
+ isSignal: true,
908
+ alias: "control",
909
+ required: false
910
+ }]
911
+ }],
912
+ usePagination: [{
913
+ type: i0.Input,
914
+ args: [{
915
+ isSignal: true,
916
+ alias: "usePagination",
917
+ required: false
918
+ }]
919
+ }],
920
+ disabled: [{
921
+ type: i0.Input,
922
+ args: [{
923
+ isSignal: true,
924
+ alias: "disabled",
925
+ required: false
926
+ }]
927
+ }],
928
+ errorMessages: [{
929
+ type: i0.Input,
930
+ args: [{
931
+ isSignal: true,
932
+ alias: "errorMessages",
933
+ required: false
934
+ }]
935
+ }],
936
+ preserveSearchOnLoad: [{
937
+ type: i0.Input,
938
+ args: [{
939
+ isSignal: true,
940
+ alias: "preserveSearchOnLoad",
941
+ required: false
942
+ }]
943
+ }],
944
+ emptyMessageKey: [{
945
+ type: i0.Input,
946
+ args: [{
947
+ isSignal: true,
948
+ alias: "emptyMessageKey",
949
+ required: false
950
+ }]
951
+ }],
952
+ dropdownUpward: [{
953
+ type: i0.Input,
954
+ args: [{
955
+ isSignal: true,
956
+ alias: "dropdownUpward",
957
+ required: false
958
+ }]
959
+ }],
960
+ showEmptyOption: [{
961
+ type: i0.Input,
962
+ args: [{
963
+ isSignal: true,
964
+ alias: "showEmptyOption",
965
+ required: false
966
+ }]
967
+ }],
968
+ selectionChange: [{
969
+ type: i0.Output,
970
+ args: ["selectionChange"]
971
+ }],
972
+ touch: [{
973
+ type: i0.Output,
974
+ args: ["touch"]
975
+ }],
976
+ search: [{
977
+ type: i0.Output,
978
+ args: ["search"]
979
+ }],
980
+ filterInput: [{
981
+ type: i0.ViewChild,
982
+ args: ["filterInput", { isSignal: true }]
983
+ }],
984
+ selectContainer: [{
985
+ type: i0.ViewChild,
986
+ args: ["selectContainer", { isSignal: true }]
987
+ }],
988
+ selectTrigger: [{
989
+ type: i0.ViewChild,
990
+ args: ["selectTrigger", { isSignal: true }]
991
+ }],
992
+ dropdownContainer: [{
993
+ type: i0.ViewChild,
994
+ args: ["dropdownContainer", { isSignal: true }]
995
+ }],
996
+ value: [{
997
+ type: i0.Input,
998
+ args: [{
999
+ isSignal: true,
1000
+ alias: "value",
1001
+ required: false
1002
+ }]
1003
+ }, {
1004
+ type: i0.Output,
1005
+ args: ["valueChange"]
1006
+ }],
1007
+ onClickOutside: [{
1008
+ type: HostListener,
1009
+ args: ["document:mousedown", ["$event"]]
1010
+ }]
1011
+ }
1012
+ });
819
1013
  export { SelectComponent };
820
- //# sourceMappingURL=shirkasoft-ui-components-select.mjs.map
1014
+
1015
+ //# sourceMappingURL=shirkasoft-ui-components-select.mjs.map