shirkasoft-ui-components 1.14.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +12 -9
  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 +1697 -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 +555 -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 +585 -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 +1076 -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 +749 -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 +129 -133
  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 +561 -398
  68. package/types/shirkasoft-ui-components-fieldset.d.ts +135 -60
  69. package/types/shirkasoft-ui-components-file-upload.d.ts +210 -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 +232 -113
  76. package/types/shirkasoft-ui-components-rail-sidebar.d.ts +262 -142
  77. package/types/shirkasoft-ui-components-select.d.ts +335 -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 +263 -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 +47 -15
  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,1441 +1,1698 @@
1
- import * as i1 from '@angular/common';
2
- import { CommonModule } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { inject, ElementRef, ChangeDetectorRef, DestroyRef, Injector, input, computed, viewChild, signal, model, output, effect, untracked, afterNextRender, forwardRef, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
5
- import { ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
6
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
- import { TranslocoService } from '@jsverse/transloco';
8
- import { PortalDirective } from 'shirkasoft-ui-components/utils';
9
- import { ShkConfigService, resolveDateFormat, typedDateLayout, formatDate, formatDateStyle } from 'shirkasoft-ui-components/config';
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
- * Date/time picker implemented as a ControlValueAccessor.
18
- *
19
- * - `view="date"` (default): opens straight on the day grid; ‹ › move month by
20
- * month, clicking the title jumps to months/years, days of the neighbouring
21
- * months are clickable, "Today" button and Cancel / Apply footer.
22
- * - `[range]="true"`: two months side by side to pick a start and end date.
23
- * - `view="week" | "month" | "year"`, `showTime`, `timeOnly`, `valueFormat`,
24
- * min/max constraints and locale-aware labels.
25
- */
26
- class DatePickerComponent {
27
- /** Internal alias kept for the existing implementation. */
28
- get _value() {
29
- return this.value;
30
- }
31
- constructor() {
32
- this.elementRef = inject(ElementRef);
33
- this.cdr = inject(ChangeDetectorRef);
34
- this.destroyRef = inject(DestroyRef);
35
- this.injector = inject(Injector);
36
- this.transloco = inject(TranslocoService);
37
- /** HTML id for the input (for label/for pairing). */
38
- this.id = input('', ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
39
- /** Granularity of the picker ('date' | 'week' | 'month' | 'year'). */
40
- this.view = input('date', ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
41
- /**
42
- * First day of the week (0=Sunday ... 6=Saturday). When not set it uses the
43
- * `dates.weekStart` option, else the locale: Sunday for 'en', Monday otherwise.
44
- */
45
- this.weekStart = input(null, ...(ngDevMode ? [{ debugName: "weekStart" }] : /* istanbul ignore next */ []));
46
- /** Selects a date range (start + end) showing two months side by side. */
47
- this.range = input(false, ...(ngDevMode ? [{ debugName: "range" }] : /* istanbul ignore next */ []));
48
- /** ISO dates (YYYY-MM-DD) marked with a dot under the day number. */
49
- this.markedDates = input([], ...(ngDevMode ? [{ debugName: "markedDates" }] : /* istanbul ignore next */ []));
50
- /** Label shown above the input. */
51
- this.label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
52
- /** Placeholder of the input. */
53
- this.placeholder = input('', ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
54
- /** FormGroup used to resolve the control from `controlName` (or `label`). */
55
- this.formGroup = input(undefined, ...(ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []));
56
- /** Name of the control inside `formGroup`. Takes precedence over `label`. */
57
- this.controlName = input('', ...(ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []));
58
- /** Directly bound FormControl. */
59
- this.control = input(undefined, ...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
60
- /** Disables the picker. */
61
- this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
62
- /** Custom error message displayed (overrides translated ones). */
63
- this.errorMessage = input('', ...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
64
- /** Per-validation-key custom error messages. */
65
- this.errorMessages = input({}, ...(ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []));
66
- /** Minimum allowed date (YYYY-MM-DD) or year/month string. */
67
- this.minValue = input('', ...(ngDevMode ? [{ debugName: "minValue" }] : /* istanbul ignore next */ []));
68
- /** Maximum allowed date (YYYY-MM-DD) or year/month string. */
69
- this.maxValue = input('', ...(ngDevMode ? [{ debugName: "maxValue" }] : /* istanbul ignore next */ []));
70
- /** Locale for month/day names and labels. Empty = the `dates.locale` option ('es'). */
71
- this.locale = input('', ...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
72
- /**
73
- * Date pattern for typing and for `displayStyle: 'format'` (e.g. 'dd/MM/yyyy',
74
- * 'yyyy-MM-dd'). Empty = the `dates.format` option (automatic by locale).
75
- */
76
- this.dateFormat = input('', ...(ngDevMode ? [{ debugName: "dateFormat" }] : /* istanbul ignore next */ []));
77
- /** How the selected date is shown. Unset = the `dates.displayStyle` option ('long'). */
78
- this.displayStyle = input(undefined, ...(ngDevMode ? [{ debugName: "displayStyle" }] : /* istanbul ignore next */ []));
79
- /** Edits only the time portion of the value. */
80
- this.timeOnly = input(false, ...(ngDevMode ? [{ debugName: "timeOnly" }] : /* istanbul ignore next */ []));
81
- /** Shows the time selectors alongside the date. */
82
- this.showTime = input(false, ...(ngDevMode ? [{ debugName: "showTime" }] : /* istanbul ignore next */ []));
83
- /** Hour format: '12' or '24'. Unset = the `dates.hourFormat` option ('24'). */
84
- this.hourFormat = input(undefined, ...(ngDevMode ? [{ debugName: "hourFormat" }] : /* istanbul ignore next */ []));
85
- /** Whether the seconds selector is shown. */
86
- this.showSeconds = input(false, ...(ngDevMode ? [{ debugName: "showSeconds" }] : /* istanbul ignore next */ []));
87
- /** Step (in minutes) for the minute selector. */
88
- this.minuteStep = input(1, ...(ngDevMode ? [{ debugName: "minuteStep" }] : /* istanbul ignore next */ []));
89
- /**
90
- * Format of the value received from and emitted to the form control.
91
- * Tokens: YYYY, MM, DD, HH, mm, ss (e.g. 'DD-MM-YYYY', 'DD/MM/YYYY HH:mm').
92
- * Empty (default) keeps the ISO format ('YYYY-MM-DD', 'YYYY-MM', 'YYYY',
93
- * 'YYYY-MM-DDTHH:mm', 'HH:mm'). In range mode it applies to each end.
94
- */
95
- this.valueFormat = input('', ...(ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []));
96
- /** Library-wide options (dates.*), used when the matching input is not set. */
97
- this.config = inject(ShkConfigService);
98
- /** Locale actually used: `locale` input, else the `dates.locale` option. */
99
- this.effectiveLocale = computed(() => this.locale() || this.config.get('dates.locale')(), ...(ngDevMode ? [{ debugName: "effectiveLocale" }] : /* istanbul ignore next */ []));
100
- /** Hour format actually used: `hourFormat` input, else the `dates.hourFormat` option. */
101
- this.effectiveHourFormat = computed(() => this.hourFormat() ?? this.config.get('dates.hourFormat')(), ...(ngDevMode ? [{ debugName: "effectiveHourFormat" }] : /* istanbul ignore next */ []));
102
- /** Date pattern actually used (input, option, or automatic by locale). */
103
- this.effectiveDateFormat = computed(() => resolveDateFormat(this.dateFormat() || this.config.get('dates.format')(), this.effectiveLocale()), ...(ngDevMode ? [{ debugName: "effectiveDateFormat" }] : /* istanbul ignore next */ []));
104
- /** Field order and separator for typing dates, derived from the pattern. */
105
- this.typedLayout = computed(() => typedDateLayout(this.effectiveDateFormat()), ...(ngDevMode ? [{ debugName: "typedLayout" }] : /* istanbul ignore next */ []));
106
- /** Display style actually used. */
107
- this.effectiveDisplayStyle = computed(() => this.displayStyle() ?? this.config.get('dates.displayStyle')(), ...(ngDevMode ? [{ debugName: "effectiveDisplayStyle" }] : /* istanbul ignore next */ []));
108
- /** Overlay (backdrop + calendar), rendered in <body> while open (shkPortal). */
109
- this.overlay = viewChild('overlay', ...(ngDevMode ? [{ debugName: "overlay" }] : /* istanbul ignore next */ []));
110
- /** Field the calendar is anchored to. */
111
- this.anchor = viewChild('anchor', ...(ngDevMode ? [{ debugName: "anchor" }] : /* istanbul ignore next */ []));
112
- /** Calendar panel, measured to place it below or above the field. */
113
- this.panel = viewChild('panel', ...(ngDevMode ? [{ debugName: "panel" }] : /* istanbul ignore next */ []));
114
- /** Fixed position of the calendar next to its field (null until measured). */
115
- this.panelPosition = signal(null, ...(ngDevMode ? [{ debugName: "panelPosition" }] : /* istanbul ignore next */ []));
116
- /** Whether the dropdown calendar is open. */
117
- this.isOpen = signal(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
118
- /** Panel being shown right now (the user can jump from days to months/years). */
119
- this.currentView = signal('date', ...(ngDevMode ? [{ debugName: "currentView" }] : /* istanbul ignore next */ []));
120
- /** Year currently displayed (first month in range mode). */
121
- this.viewYear = signal(new Date().getFullYear(), ...(ngDevMode ? [{ debugName: "viewYear" }] : /* istanbul ignore next */ []));
122
- /** Month currently displayed, 0-based (first month in range mode). */
123
- this.viewMonth = signal(new Date().getMonth(), ...(ngDevMode ? [{ debugName: "viewMonth" }] : /* istanbul ignore next */ []));
124
- /** First year of the 12-year page shown in year view. */
125
- this.viewDecade = signal(Math.floor(new Date().getFullYear() / 12) * 12, ...(ngDevMode ? [{ debugName: "viewDecade" }] : /* istanbul ignore next */ []));
126
- /** Hour selected on the clock. */
127
- this.viewHour = signal(0, ...(ngDevMode ? [{ debugName: "viewHour" }] : /* istanbul ignore next */ []));
128
- /** Minute selected on the clock. */
129
- this.viewMinute = signal(0, ...(ngDevMode ? [{ debugName: "viewMinute" }] : /* istanbul ignore next */ []));
130
- /** Second selected in the seconds selector. */
131
- this.viewSecond = signal(0, ...(ngDevMode ? [{ debugName: "viewSecond" }] : /* istanbul ignore next */ []));
132
- /** AM/PM of the hour being edited, derived from `viewHour`. */
133
- this.viewMeridiem = computed(() => (this.viewHour() >= 12 ? 'PM' : 'AM'), ...(ngDevMode ? [{ debugName: "viewMeridiem" }] : /* istanbul ignore next */ []));
134
- /** Date picked in the panel but not applied yet (single mode). */
135
- this.pendingDate = signal(null, ...(ngDevMode ? [{ debugName: "pendingDate" }] : /* istanbul ignore next */ []));
136
- /** Range start picked in the panel but not applied yet. */
137
- this.rangeStart = signal(null, ...(ngDevMode ? [{ debugName: "rangeStart" }] : /* istanbul ignore next */ []));
138
- /** Range end picked in the panel but not applied yet. */
139
- this.rangeEnd = signal(null, ...(ngDevMode ? [{ debugName: "rangeEnd" }] : /* istanbul ignore next */ []));
140
- /** Day under the mouse while choosing the range end (live preview). */
141
- this.hoverDate = signal(null, ...(ngDevMode ? [{ debugName: "hoverDate" }] : /* istanbul ignore next */ []));
142
- /** Text edited in the small input(s) inside the panel. */
143
- this.panelText = signal('', ...(ngDevMode ? [{ debugName: "panelText" }] : /* istanbul ignore next */ []));
144
- this.rangeStartText = signal('', ...(ngDevMode ? [{ debugName: "rangeStartText" }] : /* istanbul ignore next */ []));
145
- this.rangeEndText = signal('', ...(ngDevMode ? [{ debugName: "rangeEndText" }] : /* istanbul ignore next */ []));
146
- /** Which panel input holds an unparseable date. */
147
- this.panelTextError = signal(null, ...(ngDevMode ? [{ debugName: "panelTextError" }] : /* istanbul ignore next */ []));
148
- /** Whether the user is typing in the main input field. */
149
- this.isTyping = signal(false, ...(ngDevMode ? [{ debugName: "isTyping" }] : /* istanbul ignore next */ []));
150
- /** The raw text being typed by the user. */
151
- this.typedValue = signal('', ...(ngDevMode ? [{ debugName: "typedValue" }] : /* istanbul ignore next */ []));
152
- /** Whether the typed value is valid. */
153
- this.typingValid = signal(null, ...(ngDevMode ? [{ debugName: "typingValid" }] : /* istanbul ignore next */ []));
154
- /** Value: ISO string, or "start|end" ISO pair in range mode. */
155
- this.value = model(null, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
156
- /** Disabled state coming from the reactive form infrastructure. */
157
- this._disabledState = signal(false, ...(ngDevMode ? [{ debugName: "_disabledState" }] : /* istanbul ignore next */ []));
158
- this.subscribed = signal(false, ...(ngDevMode ? [{ debugName: "subscribed" }] : /* istanbul ignore next */ []));
159
- this.valueSubscribed = signal(false, ...(ngDevMode ? [{ debugName: "valueSubscribed" }] : /* istanbul ignore next */ []));
160
- /** Counter used to recompute the error helpers reactively. */
161
- this.errorTracker = signal(0, ...(ngDevMode ? [{ debugName: "errorTracker" }] : /* istanbul ignore next */ []));
162
- /** Whether an error was displayed at some point. */
163
- this.hadError = signal(false, ...(ngDevMode ? [{ debugName: "hadError" }] : /* istanbul ignore next */ []));
164
- this.onChange = () => { };
165
- this.onTouched = () => { };
166
- /** Whether the picker is disabled (input or reactive form). */
167
- this.isDisabled = computed(() => this.disabled() || this._disabledState(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
168
- /** Resolves the control from `control` input or `formGroup`+`controlName`. */
169
- this.actualControl = computed(() => {
170
- const ctrl = this.control();
171
- if (ctrl)
172
- return ctrl;
173
- const fg = this.formGroup();
174
- if (!fg)
175
- return undefined;
176
- const name = this.controlName() || this.label();
177
- if (!name)
178
- return undefined;
179
- return fg.get(name) ?? undefined;
180
- }, ...(ngDevMode ? [{ debugName: "actualControl" }] : /* istanbul ignore next */ []));
181
- this.shouldShowError = computed(() => {
182
- this.errorTracker();
183
- const ctrl = this.actualControl();
184
- return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);
185
- }, ...(ngDevMode ? [{ debugName: "shouldShowError" }] : /* istanbul ignore next */ []));
186
- this.wasFixedError = computed(() => {
187
- this.errorTracker();
188
- const ctrl = this.actualControl();
189
- return this.hadError() && ctrl?.valid && ctrl?.touched;
190
- }, ...(ngDevMode ? [{ debugName: "wasFixedError" }] : /* istanbul ignore next */ []));
191
- this.getErrorMessages = computed(() => {
192
- this.errorTracker();
193
- const customError = this.errorMessage();
194
- if (customError)
195
- return [customError];
196
- const ctrl = this.actualControl();
197
- if (!ctrl?.errors)
198
- return [];
199
- const customErrors = this.errorMessages();
200
- return Object.keys(ctrl.errors).map((key) => {
201
- if (customErrors[key])
202
- return customErrors[key];
203
- return key === 'required'
204
- ? this.transloco.translate('validation.required')
205
- : this.transloco.translate('validation.invalid');
206
- });
207
- }, ...(ngDevMode ? [{ debugName: "getErrorMessages" }] : /* istanbul ignore next */ []));
208
- /** Short UI texts in the picker's locale. */
209
- this.texts = computed(() => this.effectiveLocale().startsWith('en')
210
- ? {
211
- today: 'Today', now: 'Now', cancel: 'Cancel', apply: 'Apply', hour: 'Hour', minute: 'Min', second: 'Sec', week: 'Week',
212
- open: 'Open calendar', prevMonth: 'Previous month', nextMonth: 'Next month', prevYear: 'Previous year',
213
- nextYear: 'Next year', prevYears: 'Previous years', nextYears: 'Next years',
214
- }
215
- : {
216
- today: 'Hoy', now: 'Ahora', cancel: 'Cancelar', apply: 'Aplicar', hour: 'Hora', minute: 'Min', second: 'Seg', week: 'Semana',
217
- open: 'Abrir calendario', prevMonth: 'Mes anterior', nextMonth: 'Mes siguiente', prevYear: 'Año anterior',
218
- nextYear: 'Año siguiente', prevYears: 'Años anteriores', nextYears: 'Años siguientes',
219
- }, ...(ngDevMode ? [{ debugName: "texts" }] : /* istanbul ignore next */ []));
220
- /** Today (ISO) and the current hour, refreshed every time the panel opens. */
221
- this.todayISO = signal(this.toISODate(new Date()), ...(ngDevMode ? [{ debugName: "todayISO" }] : /* istanbul ignore next */ []));
222
- this.currentHour = signal(new Date().getHours(), ...(ngDevMode ? [{ debugName: "currentHour" }] : /* istanbul ignore next */ []));
223
- /** Minute step actually used (1-30), shared by the column and "Now". */
224
- this.effectiveStep = computed(() => Math.max(1, Math.min(30, this.minuteStep() || 1)), ...(ngDevMode ? [{ debugName: "effectiveStep" }] : /* istanbul ignore next */ []));
225
- /** Whether the time columns are shown (not in range mode: a range has no time). */
226
- this.showTimeColumns = computed(() => this.timeOnly() || (this.showTime() && !this.range()), ...(ngDevMode ? [{ debugName: "showTimeColumns" }] : /* istanbul ignore next */ []));
227
- /** Pending month change after clicking a neighbouring-month day (lets dblclick through). */
228
- this.outsideNavTimer = null;
229
- /** Timestamp of the last wheel navigation (throttles trackpads). */
230
- this.lastWheelNav = 0;
231
- /** First day of the week actually used by the grids. */
232
- this.firstDayOfWeek = computed(() => {
233
- const ws = this.weekStart() ?? this.config.get('dates.weekStart')();
234
- if (ws !== null && ws !== undefined)
235
- return ((ws % 7) + 7) % 7;
236
- return this.effectiveLocale().startsWith('en') ? 0 : 1;
237
- }, ...(ngDevMode ? [{ debugName: "firstDayOfWeek" }] : /* istanbul ignore next */ []));
238
- /** Date the calendar highlights (pending selection or committed value). */
239
- this.displayedDate = computed(() => {
240
- if (this.timeOnly() || this.range())
241
- return null;
242
- const pending = this.pendingDate();
243
- if (pending)
244
- return pending;
245
- const current = this._value();
246
- return current ? this.datePartOf(current) : null;
247
- }, ...(ngDevMode ? [{ debugName: "displayedDate" }] : /* istanbul ignore next */ []));
248
- /** Human-readable label for the selected value in the main input. */
249
- this.displayLabel = computed(() => {
250
- const value = this._value();
251
- if (!value)
252
- return '';
253
- if (this.timeOnly())
254
- return this.formatTimeFromValue(value);
255
- if (this.range()) {
256
- const [start, end] = value.split('|');
257
- return `${this.formatMedium(start)} – ${this.formatMedium(end)}`;
258
- }
259
- const datePart = this.datePartOf(value);
260
- const timePart = value.includes('T') ? value.split('T')[1] : null;
261
- const v = this.view();
262
- let label;
263
- if (v === 'year') {
264
- label = datePart;
265
- }
266
- else if (v === 'month') {
267
- const [y, m] = datePart.split('-').map(Number);
268
- label = this.capitalize(new Intl.DateTimeFormat(this.effectiveLocale(), { month: 'long', year: 'numeric' }).format(new Date(y, m - 1, 1)));
269
- }
270
- else if (v === 'week') {
271
- const start = this.parseISO(datePart);
272
- label = this.formatWeekRange(start, this.addDays(start, 6));
273
- }
274
- else {
275
- label = this.formatDisplay(datePart);
276
- }
277
- if (this.showTime() && timePart)
278
- label += ' ' + this.formatTimeFromValue(timePart);
279
- return label;
280
- }, ...(ngDevMode ? [{ debugName: "displayLabel" }] : /* istanbul ignore next */ []));
281
- /** Localized short month names (Ene, Feb...). */
282
- this.monthNames = computed(() => {
283
- const fmt = new Intl.DateTimeFormat(this.effectiveLocale(), { month: 'short' });
284
- return Array.from({ length: 12 }, (_, i) => this.capitalize(fmt.format(new Date(2000, i, 1)).replace('.', '')));
285
- }, ...(ngDevMode ? [{ debugName: "monthNames" }] : /* istanbul ignore next */ []));
286
- /** Localized long month names (Enero, Febrero...) for the headers. */
287
- this.monthLongNames = computed(() => {
288
- const fmt = new Intl.DateTimeFormat(this.effectiveLocale(), { month: 'long' });
289
- return Array.from({ length: 12 }, (_, i) => this.capitalize(fmt.format(new Date(2000, i, 1))));
290
- }, ...(ngDevMode ? [{ debugName: "monthLongNames" }] : /* istanbul ignore next */ []));
291
- /** Localized short weekday names, starting at `firstDayOfWeek`. */
292
- this.dayNames = computed(() => {
293
- const fmt = new Intl.DateTimeFormat(this.effectiveLocale(), { weekday: 'short' });
294
- const first = this.firstDayOfWeek();
295
- // 2024-01-07 is a Sunday.
296
- return Array.from({ length: 7 }, (_, i) => {
297
- const name = fmt.format(new Date(2024, 0, 7 + ((first + i) % 7))).replace('.', '');
298
- return this.capitalize(name.slice(0, 2));
299
- });
300
- }, ...(ngDevMode ? [{ debugName: "dayNames" }] : /* istanbul ignore next */ []));
301
- /** Months rendered in the day view: one, or two consecutive in range mode. */
302
- this.visibleMonths = computed(() => {
303
- const y = this.viewYear();
304
- const m = this.viewMonth();
305
- const months = [this.buildMonth(y, m)];
306
- if (this.range()) {
307
- const next = new Date(y, m + 1, 1);
308
- months.push(this.buildMonth(next.getFullYear(), next.getMonth()));
309
- }
310
- return months;
311
- }, ...(ngDevMode ? [{ debugName: "visibleMonths" }] : /* istanbul ignore next */ []));
312
- /** Set of marked ISO dates for O(1) lookups in the grid. */
313
- this.markedSet = computed(() => new Set(this.markedDates()), ...(ngDevMode ? [{ debugName: "markedSet" }] : /* istanbul ignore next */ []));
314
- /** Weeks of the viewed month (rows aligned to the first weekday), for week view. */
315
- this.monthWeeks = computed(() => {
316
- const year = this.viewYear();
317
- const month = this.viewMonth();
318
- const first = new Date(year, month, 1);
319
- const last = new Date(year, month + 1, 0);
320
- let cursor = this.startOfWeek(first);
321
- const weeks = [];
322
- let index = 0;
323
- while (cursor.getTime() <= last.getTime()) {
324
- index++;
325
- const start = cursor;
326
- const end = this.addDays(start, 6);
327
- weeks.push({ index, start, end, range: this.formatWeekRange(start, end) });
328
- cursor = this.addDays(start, 7);
329
- }
330
- return weeks;
331
- }, ...(ngDevMode ? [{ debugName: "monthWeeks" }] : /* istanbul ignore next */ []));
332
- /** 12 years of the page shown in year view. */
333
- this.decadeYears = computed(() => {
334
- const start = this.viewDecade();
335
- return Array.from({ length: 12 }, (_, i) => start + i);
336
- }, ...(ngDevMode ? [{ debugName: "decadeYears" }] : /* istanbul ignore next */ []));
337
- /** Title of the header for the current view. */
338
- this.headerTitle = computed(() => {
339
- const v = this.currentView();
340
- if (v === 'year')
341
- return `${this.viewDecade()} – ${this.viewDecade() + 11}`;
342
- if (v === 'month')
343
- return String(this.viewYear());
344
- return `${this.monthLongNames()[this.viewMonth()]} ${this.viewYear()}`;
345
- }, ...(ngDevMode ? [{ debugName: "headerTitle" }] : /* istanbul ignore next */ []));
346
- /** Whether ‹ is allowed by `minValue`. */
347
- this.canGoPrev = computed(() => {
348
- const min = this.minValue();
349
- if (!min)
350
- return true;
351
- const minY = Number(min.slice(0, 4));
352
- const v = this.currentView();
353
- if (v === 'date' || v === 'week') {
354
- // Last day of the previous month must still be >= min.
355
- const lastPrev = this.toISODate(new Date(this.viewYear(), this.viewMonth(), 0));
356
- return lastPrev.slice(0, min.length) >= min.slice(0, 10);
357
- }
358
- if (v === 'month')
359
- return this.viewYear() > minY;
360
- return this.viewDecade() > minY;
361
- }, ...(ngDevMode ? [{ debugName: "canGoPrev" }] : /* istanbul ignore next */ []));
362
- /** Whether › is allowed by `maxValue`. */
363
- this.canGoNext = computed(() => {
364
- const max = this.maxValue();
365
- if (!max)
366
- return true;
367
- const maxY = Number(max.slice(0, 4));
368
- const v = this.currentView();
369
- if (v === 'date' || v === 'week') {
370
- // First day after the last visible month must still be <= max.
371
- const extra = this.range() ? 2 : 1;
372
- const firstNext = this.toISODate(new Date(this.viewYear(), this.viewMonth() + extra, 1));
373
- return firstNext.slice(0, max.length) <= max.slice(0, 10);
374
- }
375
- if (v === 'month')
376
- return this.viewYear() < maxY;
377
- return this.viewDecade() + 11 < maxY;
378
- }, ...(ngDevMode ? [{ debugName: "canGoNext" }] : /* istanbul ignore next */ []));
379
- /** Whether the Cancel / Apply footer is shown. */
380
- this.showFooter = computed(() => this.timeOnly() || this.range() || this.view() === 'date' || this.showTime(), ...(ngDevMode ? [{ debugName: "showFooter" }] : /* istanbul ignore next */ []));
381
- /** Whether "Apply" has something to apply. */
382
- this.canApply = computed(() => {
383
- if (this.timeOnly())
384
- return true;
385
- if (this.range())
386
- return !!this.rangeStart();
387
- return !!this.pendingDate();
388
- }, ...(ngDevMode ? [{ debugName: "canApply" }] : /* istanbul ignore next */ []));
389
- /** Input format for typing (placeholder), from the date pattern: 'DD/MM/YYYY', 'YYYY-MM-DD'… */
390
- this.inputFormat = computed(() => {
391
- const { order, separator } = this.typedLayout();
392
- const names = { d: 'DD', m: 'MM', y: 'YYYY' };
393
- return order.map((field) => names[field]).join(separator);
394
- }, ...(ngDevMode ? [{ debugName: "inputFormat" }] : /* istanbul ignore next */ []));
395
- /** Emitted on close/blur so Signal Forms can mark the field as touched. */
396
- this.touch = output();
397
- /** Whether the title can be clicked to zoom out. */
398
- this.canZoomOut = computed(() => this.currentView() !== 'year', ...(ngDevMode ? [{ debugName: "canZoomOut" }] : /* istanbul ignore next */ []));
399
- /** Effective range end: the picked one or, while choosing, the hovered day. */
400
- this.effectiveEnd = computed(() => {
401
- const start = this.rangeStart();
402
- const end = this.rangeEnd();
403
- if (end)
404
- return end;
405
- const hover = this.hoverDate();
406
- return start && hover && hover > start ? hover : null;
407
- }, ...(ngDevMode ? [{ debugName: "effectiveEnd" }] : /* istanbul ignore next */ []));
408
- // ---------------------------------------------------------------------------
409
- // Time columns (Hour | Min | Sec | AM/PM)
410
- // ---------------------------------------------------------------------------
411
- /** Hour options: 00-23, or 12,01..11 of the current half in 12-hour format. */
412
- this.hourOptions = computed(() => {
413
- if (this.effectiveHourFormat() === '12') {
414
- const pm = this.viewMeridiem() === 'PM' ? 12 : 0;
415
- return [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map((h) => ({
416
- value: (h % 12) + pm,
417
- label: this.pad2(h),
418
- }));
419
- }
420
- return Array.from({ length: 24 }, (_, h) => ({ value: h, label: this.pad2(h) }));
421
- }, ...(ngDevMode ? [{ debugName: "hourOptions" }] : /* istanbul ignore next */ []));
422
- /** Minute options, stepped by `minuteStep`. */
423
- this.minuteOptions = computed(() => {
424
- const step = this.effectiveStep();
425
- return Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step);
426
- }, ...(ngDevMode ? [{ debugName: "minuteOptions" }] : /* istanbul ignore next */ []));
427
- /** Second options (0-59). */
428
- this.secondOptions = Array.from({ length: 60 }, (_, i) => i);
429
- /** Time being edited, formatted for the time input. */
430
- this.timeText = computed(() => this.formatTime(this.viewHour(), this.viewMinute(), this.viewSecond()), ...(ngDevMode ? [{ debugName: "timeText" }] : /* istanbul ignore next */ []));
431
- /** Whether the time typed in the panel could not be read. */
432
- this.timeTextError = signal(false, ...(ngDevMode ? [{ debugName: "timeTextError" }] : /* istanbul ignore next */ []));
433
- // Page or container scroll: keep the calendar next to its field.
434
- const doc = this.elementRef.nativeElement.ownerDocument;
435
- const onScroll = () => this.onViewportChange();
436
- doc.addEventListener('scroll', onScroll, true);
437
- this.destroyRef.onDestroy(() => {
438
- doc.removeEventListener('scroll', onScroll, true);
439
- this.cancelOutsideNav();
440
- });
441
- // Every view has a different height: re-position when it changes.
442
- effect(() => {
443
- this.currentView();
444
- if (untracked(() => this.isOpen()))
445
- this.schedulePosition();
446
- });
447
- // Keep the small inputs in the panel in sync with the picked dates.
448
- effect(() => {
449
- const pending = this.pendingDate();
450
- const start = this.rangeStart();
451
- const end = this.rangeEnd();
452
- untracked(() => {
453
- this.panelText.set(pending ? this.formatTyped(pending) : '');
454
- this.rangeStartText.set(start ? this.formatTyped(start) : '');
455
- this.rangeEndText.set(end ? this.formatTyped(end) : '');
456
- this.panelTextError.set(null);
457
- });
458
- });
459
- // Attach error-state subscriptions to the validated control once found.
460
- effect(() => {
461
- const ctrl = this.actualControl();
462
- if (!ctrl) {
463
- this.subscribed.set(false);
464
- return;
465
- }
466
- if (this.subscribed())
467
- return;
468
- if (ctrl.invalid && ctrl.touched)
469
- this.hadError.set(true);
470
- ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
471
- this.errorTracker.update((v) => v + 1);
472
- if (ctrl.invalid && ctrl.touched)
473
- this.hadError.set(true);
474
- });
475
- this.subscribed.set(true);
476
- });
477
- // One-way sync from the reactive control to the internal value signal.
478
- effect(() => {
479
- const ctrl = this.actualControl();
480
- if (!ctrl || this.valueSubscribed())
481
- return;
482
- this.writeValue(ctrl.value);
483
- ctrl.valueChanges
484
- .pipe(takeUntilDestroyed(this.destroyRef))
485
- .subscribe((value) => this.writeValue(value));
486
- this.valueSubscribed.set(true);
487
- });
488
- }
489
- // ---------------------------------------------------------------------------
490
- // Overlay
491
- // ---------------------------------------------------------------------------
492
- onDocumentClick(event) {
493
- if (!this.isOpen())
494
- return;
495
- const target = event.target;
496
- const overlay = this.overlay()?.nativeElement;
497
- if (!this.elementRef.nativeElement.contains(target) && !overlay?.contains(target)) {
498
- this.close();
499
- }
500
- }
501
- onViewportChange() {
502
- if (this.isOpen())
503
- this.positionPanel();
504
- }
505
- onEscape() {
506
- this.close();
507
- }
508
- schedulePosition() {
509
- afterNextRender(() => this.positionPanel(), { injector: this.injector });
510
- }
511
- /** Places the calendar below the field (above if no room), inside the viewport. */
512
- positionPanel() {
513
- const anchor = this.anchor()?.nativeElement;
514
- const panel = this.panel()?.nativeElement;
515
- if (!anchor || !panel)
516
- return;
517
- const margin = 8;
518
- const gap = 4;
519
- const rect = anchor.getBoundingClientRect();
520
- const height = panel.offsetHeight;
521
- const width = panel.offsetWidth;
522
- let top = rect.bottom + gap;
523
- if (top + height > window.innerHeight - margin && rect.top - gap - height >= margin) {
524
- top = rect.top - gap - height;
525
- }
526
- top = Math.max(margin, Math.min(top, window.innerHeight - height - margin));
527
- const left = Math.max(margin, Math.min(rect.left, window.innerWidth - width - margin));
528
- this.panelPosition.set({ top, left });
529
- }
530
- /** Opens/closes the dropdown, syncing the calendar to the current value. */
531
- toggle() {
532
- if (this.isDisabled())
533
- return;
534
- if (this.isOpen()) {
535
- this.close();
536
- return;
537
- }
538
- const now = new Date();
539
- this.todayISO.set(this.toISODate(now));
540
- this.currentHour.set(now.getHours());
541
- this.syncViewToValue();
542
- this.currentView.set(this.view());
543
- this.isTyping.set(false);
544
- this.panelPosition.set(null);
545
- this.isOpen.set(true);
546
- this.timeTextError.set(false);
547
- this.schedulePosition();
548
- if (this.showTimeColumns())
549
- this.scheduleTimeScroll();
550
- }
551
- /** Closes the dropdown (discarding unapplied changes) and marks as touched. */
552
- close() {
553
- if (!this.isOpen())
554
- return;
555
- this.touch.emit();
556
- this.cancelOutsideNav();
557
- this.isOpen.set(false);
558
- this.hoverDate.set(null);
559
- this.onTouched();
560
- const ctrl = this.actualControl();
561
- if (ctrl)
562
- ctrl.markAsTouched();
563
- this.errorTracker.update((v) => v + 1);
564
- if (ctrl?.invalid && ctrl?.touched)
565
- this.hadError.set(true);
566
- }
567
- /** Aligns the calendar and the pending selection with the current value. */
568
- syncViewToValue() {
569
- const val = this._value();
570
- const now = new Date();
571
- this.pendingDate.set(null);
572
- this.rangeStart.set(null);
573
- this.rangeEnd.set(null);
574
- this.hoverDate.set(null);
575
- if (!val) {
576
- this.goToDate(now);
577
- this.setNowTime(now);
578
- return;
579
- }
580
- if (this.range()) {
581
- const [start, end] = val.split('|');
582
- this.rangeStart.set(start);
583
- this.rangeEnd.set(end);
584
- this.goToDate(this.parseISO(start));
585
- return;
586
- }
587
- if (this.timeOnly()) {
588
- this.setClockFrom(val);
589
- return;
590
- }
591
- const datePart = this.datePartOf(val);
592
- const v = this.view();
593
- if (v === 'year') {
594
- this.viewYear.set(Number(datePart));
595
- this.viewDecade.set(this.decadeOf(Number(datePart)));
596
- }
597
- else if (v === 'month') {
598
- this.viewYear.set(Number(datePart.slice(0, 4)));
599
- this.viewMonth.set(Number(datePart.slice(5, 7)) - 1);
600
- }
601
- else {
602
- this.goToDate(this.parseISO(datePart));
603
- }
604
- if (val.includes('T'))
605
- this.setClockFrom(val.split('T')[1]);
606
- this.pendingDate.set(datePart);
607
- }
608
- // ---------------------------------------------------------------------------
609
- // Navigation
610
- // ---------------------------------------------------------------------------
611
- /** ‹ : previous month (days/weeks), year (months) or 12 years (years). */
612
- prev() {
613
- this.shift(-1);
614
- }
615
- /** › : next month (days/weeks), year (months) or 12 years (years). */
616
- next() {
617
- this.shift(1);
618
- }
619
- shift(dir) {
620
- const v = this.currentView();
621
- if (v === 'year') {
622
- this.viewDecade.update((d) => d + 12 * dir);
623
- }
624
- else if (v === 'month') {
625
- this.viewYear.update((y) => y + dir);
626
- }
627
- else {
628
- this.goToDate(new Date(this.viewYear(), this.viewMonth() + dir, 1));
629
- }
630
- }
631
- /** Clicking the title zooms out: days → months → years. */
632
- zoomOut() {
633
- const v = this.currentView();
634
- if (v === 'date' || v === 'week') {
635
- this.currentView.set('month');
636
- }
637
- else if (v === 'month') {
638
- this.viewDecade.set(this.decadeOf(this.viewYear()));
639
- this.currentView.set('year');
640
- }
641
- }
642
- /** Mouse wheel over the grid moves back/forward (quick browsing). */
643
- onWheel(event) {
644
- if (Math.abs(event.deltaY) < 20)
645
- return;
646
- event.preventDefault();
647
- // One step per gesture: trackpads fire dozens of events per flick.
648
- const now = Date.now();
649
- if (now - this.lastWheelNav < DatePickerComponent.WHEEL_THROTTLE_MS)
650
- return;
651
- this.lastWheelNav = now;
652
- if (event.deltaY > 0 ? this.canGoNext() : this.canGoPrev()) {
653
- this.shift(event.deltaY > 0 ? 1 : -1);
654
- }
655
- }
656
- /** Keyboard shortcuts inside the panel: PageUp/PageDown change month. */
657
- onPanelKeydown(event) {
658
- if (event.key === 'PageUp' && this.canGoPrev()) {
659
- event.preventDefault();
660
- this.prev();
661
- }
662
- else if (event.key === 'PageDown' && this.canGoNext()) {
663
- event.preventDefault();
664
- this.next();
665
- }
666
- }
667
- /** "Today": jumps to today's month and, in single mode, picks today. */
668
- goToday() {
669
- const today = new Date();
670
- this.currentView.set(this.view() === 'week' ? 'week' : 'date');
671
- this.goToDate(today);
672
- if (!this.range() && !this.isDisabledDate(this.toISODate(today))) {
673
- this.pendingDate.set(this.toISODate(today));
674
- }
675
- }
676
- // ---------------------------------------------------------------------------
677
- // Selection
678
- // ---------------------------------------------------------------------------
679
- /** Click on a day cell. */
680
- selectDay(cell) {
681
- if (this.isDisabledDate(cell.iso))
682
- return;
683
- if (this.range()) {
684
- const start = this.rangeStart();
685
- const end = this.rangeEnd();
686
- if (!start || end || cell.iso < start) {
687
- this.rangeStart.set(cell.iso);
688
- this.rangeEnd.set(null);
689
- }
690
- else {
691
- this.rangeEnd.set(cell.iso);
692
- this.hoverDate.set(null);
693
- }
694
- return;
695
- }
696
- this.pendingDate.set(cell.iso);
697
- // A day of the neighbouring month also brings that month into view. It is
698
- // delayed so a double click can still reach the same cell (quickApply).
699
- this.cancelOutsideNav();
700
- if (!cell.inMonth) {
701
- this.outsideNavTimer = setTimeout(() => {
702
- this.outsideNavTimer = null;
703
- this.goToDate(this.parseISO(cell.iso));
704
- this.cdr.markForCheck();
705
- }, DatePickerComponent.DBLCLICK_DELAY_MS);
706
- }
707
- }
708
- cancelOutsideNav() {
709
- if (this.outsideNavTimer !== null) {
710
- clearTimeout(this.outsideNavTimer);
711
- this.outsideNavTimer = null;
712
- }
713
- }
714
- /** Double click on a day: pick it and apply in one go. */
715
- quickApply(cell) {
716
- if (this.range() || this.showTime() || this.isDisabledDate(cell.iso))
717
- return;
718
- this.cancelOutsideNav();
719
- this.pendingDate.set(cell.iso);
720
- this.apply();
721
- }
722
- /** Hover on a day while choosing the range end (live band preview). */
723
- onDayHover(cell) {
724
- if (!this.range() || !this.rangeStart() || this.rangeEnd())
725
- return;
726
- this.hoverDate.set(cell?.iso ?? null);
727
- }
728
- /** Selects a month in the month grid. */
729
- selectMonth(monthIndex) {
730
- this.viewMonth.set(monthIndex);
731
- if (this.view() === 'month') {
732
- this.setValue(`${this.viewYear()}-${String(monthIndex + 1).padStart(2, '0')}`);
733
- return;
734
- }
735
- // Zoomed out from the day/week grid: go back to it on that month.
736
- this.currentView.set(this.view() === 'week' ? 'week' : 'date');
737
- }
738
- /** Selects a year in the year grid. */
739
- selectYear(year) {
740
- this.viewYear.set(year);
741
- if (this.view() === 'year') {
742
- this.setValue(String(year));
743
- return;
744
- }
745
- this.currentView.set('month');
746
- }
747
- /** Selects a week (emits its start date YYYY-MM-DD). */
748
- selectWeek(start) {
749
- const value = this.toISODate(start);
750
- if (this.showTime()) {
751
- this.pendingDate.set(value);
752
- return;
753
- }
754
- this.setValue(value);
755
- }
756
- /** Commits what is picked in the panel (date, date+time, time or range). */
757
- apply() {
758
- if (!this.canApply())
759
- return;
760
- const time = this.buildTime(this.viewHour(), this.viewMinute(), this.viewSecond());
761
- if (this.timeOnly()) {
762
- this.setValue(time);
763
- return;
764
- }
765
- if (this.range()) {
766
- const start = this.rangeStart();
767
- this.setValue(`${start}|${this.rangeEnd() ?? start}`);
768
- return;
769
- }
770
- const date = this.pendingDate();
771
- this.setValue(this.showTime() ? `${date}T${time}` : date);
772
- }
773
- /** Clears the value. */
774
- clear() {
775
- this._value.set(null);
776
- this.onChange(null);
777
- const ctrl = this.actualControl();
778
- if (ctrl) {
779
- ctrl.setValue(null);
780
- ctrl.markAsDirty();
781
- }
782
- }
783
- setValue(value, close = true) {
784
- this._value.set(value);
785
- const output = this.toOutputValue(value);
786
- this.onChange(output);
787
- const ctrl = this.actualControl();
788
- if (ctrl) {
789
- ctrl.setValue(output);
790
- ctrl.markAsDirty();
791
- }
792
- if (close)
793
- this.close();
794
- }
795
- // ---------------------------------------------------------------------------
796
- // Panel inputs (typing inside the calendar)
797
- // ---------------------------------------------------------------------------
798
- /** Commits the date typed in a panel input (Enter / blur). */
799
- commitPanelText(which, event) {
800
- const text = event.target.value.trim();
801
- const current = which === 'single' ? this.pendingDate() : which === 'start' ? this.rangeStart() : this.rangeEnd();
802
- if (!text) {
803
- this.panelTextError.set(null);
804
- return;
805
- }
806
- const iso = this.parseDateText(text);
807
- if (!iso || this.isDisabledDate(iso)) {
808
- this.panelTextError.set(which);
809
- return;
810
- }
811
- this.panelTextError.set(null);
812
- if (iso === current)
813
- return;
814
- if (which === 'single') {
815
- this.pendingDate.set(iso);
816
- }
817
- else if (which === 'start') {
818
- this.rangeStart.set(iso);
819
- if (this.rangeEnd() && this.rangeEnd() < iso)
820
- this.rangeEnd.set(null);
821
- }
822
- else {
823
- if (!this.rangeStart() || iso < this.rangeStart()) {
824
- this.rangeStart.set(iso);
825
- this.rangeEnd.set(null);
826
- }
827
- else {
828
- this.rangeEnd.set(iso);
829
- }
830
- }
831
- this.currentView.set('date');
832
- this.goToDate(this.parseISO(iso));
833
- }
834
- // ---------------------------------------------------------------------------
835
- // Cell state helpers (used by the template)
836
- // ---------------------------------------------------------------------------
837
- isSelectedDate(iso) {
838
- if (this.range())
839
- return iso === this.rangeStart() || iso === this.rangeEnd();
840
- return this.displayedDate() === iso;
841
- }
842
- isInRange(iso) {
843
- const start = this.rangeStart();
844
- const end = this.effectiveEnd();
845
- return !!start && !!end && iso > start && iso < end;
846
- }
847
- isRangeStart(iso) {
848
- return !!this.effectiveEnd() && iso === this.rangeStart();
849
- }
850
- isRangeEnd(iso) {
851
- return !!this.rangeStart() && iso === this.effectiveEnd();
852
- }
853
- isTodayDate(iso) {
854
- return iso === this.todayISO();
855
- }
856
- isMarked(iso) {
857
- return this.markedSet().has(iso);
858
- }
859
- /** Whether a day falls outside minValue / maxValue. */
860
- isDisabledDate(iso) {
861
- const min = this.minValue();
862
- const max = this.maxValue();
863
- if (min && iso.slice(0, min.length) < min.slice(0, 10))
864
- return true;
865
- if (max && iso.slice(0, max.length) > max.slice(0, 10))
866
- return true;
867
- return false;
868
- }
869
- isSelectedMonth(monthIndex) {
870
- const d = this.displayedDate() ?? this.rangeStart();
871
- if (!d || d.length < 7)
872
- return false;
873
- return Number(d.slice(0, 4)) === this.viewYear() && Number(d.slice(5, 7)) - 1 === monthIndex;
874
- }
875
- isCurrentMonth(monthIndex) {
876
- const now = new Date();
877
- return this.viewYear() === now.getFullYear() && monthIndex === now.getMonth();
878
- }
879
- isSelectedYear(year) {
880
- const d = this.displayedDate() ?? this.rangeStart();
881
- return !!d && Number(d.slice(0, 4)) === year;
882
- }
883
- isCurrentYear(year) {
884
- return new Date().getFullYear() === year;
885
- }
886
- isSelectedWeek(start) {
887
- const date = this.displayedDate();
888
- if (!date)
889
- return false;
890
- return this.toISODate(this.startOfWeek(this.parseISO(date))) === this.toISODate(start);
891
- }
892
- isCurrentWeek(start) {
893
- return this.toISODate(this.startOfWeek(new Date())) === this.toISODate(start);
894
- }
895
- weekLabel(index) {
896
- return `${this.texts().week} ${index}`;
897
- }
898
- /** Localized range label for a week (e.g. '2 — 8 feb'). */
899
- formatWeekRange(start, end) {
900
- const loc = this.effectiveLocale();
901
- const dayFmt = new Intl.DateTimeFormat(loc, { day: 'numeric' });
902
- const monthFmt = new Intl.DateTimeFormat(loc, { month: 'short' });
903
- const startLabel = `${dayFmt.format(start)} ${monthFmt.format(start).replace('.', '')}`;
904
- if (start.getMonth() !== end.getMonth() || start.getFullYear() !== end.getFullYear()) {
905
- const year = start.getFullYear() !== end.getFullYear() ? ` ${end.getFullYear()}` : '';
906
- return `${startLabel} — ${dayFmt.format(end)} ${monthFmt.format(end).replace('.', '')}${year}`;
907
- }
908
- return `${startLabel} — ${dayFmt.format(end)}`;
909
- }
910
- /** Current hour, highlighted like "today" in the calendar. */
911
- isCurrentHour(hour) {
912
- return this.currentHour() === hour;
913
- }
914
- selectHour(hour) {
915
- this.viewHour.set(hour);
916
- }
917
- selectMinute(minute) {
918
- this.viewMinute.set(minute);
919
- }
920
- selectSecond(second) {
921
- this.viewSecond.set(second);
922
- }
923
- /** Switches the hour to AM or PM keeping its 1-12 position. */
924
- setMeridiem(meridiem) {
925
- const h = this.viewHour();
926
- if (meridiem === 'PM' && h < 12)
927
- this.viewHour.set(h + 12);
928
- else if (meridiem === 'AM' && h >= 12)
929
- this.viewHour.set(h - 12);
930
- }
931
- /** "Now": sets the current time (minutes rounded to `minuteStep`). */
932
- setNow() {
933
- this.setNowTime(new Date());
934
- this.timeTextError.set(false);
935
- this.scheduleTimeScroll();
936
- }
937
- /**
938
- * Puts `date`'s time in the columns, minutes rounded to the step so the
939
- * value is always one of the listed options.
940
- */
941
- setNowTime(date) {
942
- const step = this.effectiveStep();
943
- let minute = Math.round(date.getMinutes() / step) * step;
944
- let hour = date.getHours();
945
- if (minute >= 60) {
946
- minute = 0;
947
- hour = (hour + 1) % 24;
948
- }
949
- this.viewHour.set(hour);
950
- this.viewMinute.set(minute);
951
- this.viewSecond.set(this.showSeconds() && step === 1 ? date.getSeconds() : 0);
952
- }
953
- /** Commits the time typed in the panel (Enter / blur). */
954
- commitTimeText(event) {
955
- const input = event.target;
956
- const text = input.value.trim();
957
- if (!text || text === this.timeText()) {
958
- this.timeTextError.set(false);
959
- input.value = this.timeText();
960
- return;
961
- }
962
- const time = this.parseTimeOnly(text);
963
- if (!time) {
964
- this.timeTextError.set(true);
965
- return;
966
- }
967
- this.timeTextError.set(false);
968
- this.setClockFrom(time);
969
- input.value = this.timeText();
970
- this.scheduleTimeScroll();
971
- }
972
- /** Centers the selected item of every time column (after the next render). */
973
- scheduleTimeScroll() {
974
- afterNextRender(() => {
975
- const panel = this.panel()?.nativeElement;
976
- panel?.querySelectorAll('.dp-time-col').forEach((col) => {
977
- const sel = col.querySelector('.is-selected');
978
- if (sel)
979
- col.scrollTop = sel.offsetTop - col.clientHeight / 2 + sel.offsetHeight / 2;
980
- });
981
- }, { injector: this.injector });
982
- }
983
- pad2(value) {
984
- return String(value).padStart(2, '0');
985
- }
986
- // ---------------------------------------------------------------------------
987
- // Main input typing
988
- // ---------------------------------------------------------------------------
989
- inputPlaceholder() {
990
- if (this.placeholder())
991
- return this.placeholder();
992
- if (this.timeOnly())
993
- return this.effectiveHourFormat() === '12' ? 'hh:mm AM' : 'HH:mm';
994
- if (this.range())
995
- return `${this.inputFormat()} – ${this.inputFormat()}`;
996
- if (this.view() === 'year')
997
- return 'YYYY';
998
- if (this.view() === 'month')
999
- return 'MM/YYYY';
1000
- if (this.view() === 'week')
1001
- return `${this.texts().week} · MM/YYYY`;
1002
- return this.inputFormat();
1003
- }
1004
- onInputText(event) {
1005
- this.typedValue.set(event.target.value);
1006
- this.typingValid.set(null);
1007
- }
1008
- onInputFocus() {
1009
- this.isTyping.set(true);
1010
- this.typedValue.set(this.typedFormOfValue());
1011
- this.typingValid.set(null);
1012
- }
1013
- /** Validates and commits the typed value on blur or Enter. */
1014
- onInputBlur() {
1015
- const text = this.typedValue().trim();
1016
- this.isTyping.set(false);
1017
- if (!text || text === this.typedFormOfValue())
1018
- return;
1019
- const parsed = this.parseTypedValue(text);
1020
- if (parsed) {
1021
- this.setValue(parsed, false);
1022
- this.typingValid.set(true);
1023
- if (this.isOpen())
1024
- this.syncViewToValue();
1025
- }
1026
- else {
1027
- this.typingValid.set(false);
1028
- setTimeout(() => this.typingValid.set(null), 1500);
1029
- }
1030
- }
1031
- cancelTyping() {
1032
- this.isTyping.set(false);
1033
- this.typedValue.set('');
1034
- this.typingValid.set(null);
1035
- }
1036
- /** Current value written the way the user would type it. */
1037
- typedFormOfValue() {
1038
- const val = this._value();
1039
- if (!val)
1040
- return '';
1041
- if (this.timeOnly())
1042
- return this.formatTimeFromValue(val);
1043
- if (this.range()) {
1044
- const [s, e] = val.split('|');
1045
- return `${this.formatTyped(s)} - ${this.formatTyped(e)}`;
1046
- }
1047
- const v = this.view();
1048
- if (v === 'year')
1049
- return val;
1050
- if (v === 'month')
1051
- return `${val.slice(5, 7)}/${val.slice(0, 4)}`;
1052
- let text = this.formatTyped(this.datePartOf(val));
1053
- if (val.includes('T'))
1054
- text += ' ' + this.formatTimeFromValue(val.split('T')[1]);
1055
- return text;
1056
- }
1057
- parseTypedValue(text) {
1058
- if (this.timeOnly())
1059
- return this.parseTimeOnly(text);
1060
- if (this.range()) {
1061
- const parts = text.split(/\s+[-–]\s+|\s*–\s*/).filter(Boolean);
1062
- if (parts.length !== 2)
1063
- return null;
1064
- const a = this.parseDateText(parts[0]);
1065
- const b = this.parseDateText(parts[1]);
1066
- if (!a || !b)
1067
- return null;
1068
- return a <= b ? `${a}|${b}` : `${b}|${a}`;
1069
- }
1070
- const v = this.view();
1071
- if (v === 'week')
1072
- return null;
1073
- if (v === 'year') {
1074
- const y = Number(text);
1075
- return /^\d{4}$/.test(text) && y >= 1900 && y <= 2100 ? String(y) : null;
1076
- }
1077
- if (v === 'month') {
1078
- const parts = text.split(/[\/\-.\s]+/).filter(Boolean);
1079
- if (parts.length !== 2)
1080
- return null;
1081
- const [a, b] = parts.map(Number);
1082
- const [m, y] = parts[0].length === 4 ? [b, a] : [a, b];
1083
- return m >= 1 && m <= 12 && y >= 1900 && y <= 2100 ? `${y}-${this.pad2(m)}` : null;
1084
- }
1085
- const [datePart, ...timeParts] = text.split(/\s+/);
1086
- const iso = this.parseDateText(datePart);
1087
- if (!iso)
1088
- return null;
1089
- if (!this.showTime())
1090
- return iso;
1091
- const time = timeParts.length ? this.parseTimeOnly(timeParts.join(' ')) : null;
1092
- return `${iso}T${time ?? this.buildTime(this.viewHour(), this.viewMinute(), this.viewSecond())}`;
1093
- }
1094
- /** Parses a typed date in the pattern's field order (or ISO "YYYY-MM-DD") into ISO. */
1095
- parseDateText(text) {
1096
- const parts = text.trim().split(/[\/\-.\s]+/).filter(Boolean);
1097
- if (parts.length !== 3)
1098
- return null;
1099
- const nums = parts.map(Number);
1100
- // A leading 4-digit part is always read as ISO year-month-day.
1101
- const order = parts[0].length === 4 ? ['y', 'm', 'd'] : this.typedLayout().order;
1102
- const field = (f) => nums[order.indexOf(f)];
1103
- const d = field('d');
1104
- const m = field('m');
1105
- let y = field('y');
1106
- if (y < 100)
1107
- y += 2000;
1108
- if (!(y >= 1900 && y <= 2100 && m >= 1 && m <= 12 && d >= 1 && d <= 31))
1109
- return null;
1110
- const date = new Date(y, m - 1, d);
1111
- if (date.getMonth() !== m - 1 || date.getDate() !== d)
1112
- return null;
1113
- return this.toISODate(date);
1114
- }
1115
- parseTimeOnly(text) {
1116
- const match = /^(\d{1,2})[:.](\d{2})(?:[:.](\d{2}))?\s*(am|pm)?$/i.exec(text.trim());
1117
- if (!match)
1118
- return null;
1119
- let h = Number(match[1]);
1120
- const m = Number(match[2]);
1121
- const s = Number(match[3] ?? 0);
1122
- const suffix = match[4]?.toLowerCase();
1123
- if (suffix === 'pm' && h < 12)
1124
- h += 12;
1125
- if (suffix === 'am' && h === 12)
1126
- h = 0;
1127
- if (h > 23 || m > 59 || s > 59)
1128
- return null;
1129
- return this.buildTime(h, m, s);
1130
- }
1131
- // ---------------------------------------------------------------------------
1132
- // Date utilities
1133
- // ---------------------------------------------------------------------------
1134
- /** Builds the 6x7 grid of a month, including days of the neighbouring months. */
1135
- buildMonth(year, month) {
1136
- const first = new Date(year, month, 1);
1137
- const start = this.startOfWeek(first);
1138
- const cells = [];
1139
- for (let i = 0; i < 42; i++) {
1140
- const d = this.addDays(start, i);
1141
- cells.push({ iso: this.toISODate(d), day: d.getDate(), inMonth: d.getMonth() === month });
1142
- }
1143
- return { year, month, cells };
1144
- }
1145
- startOfWeek(date) {
1146
- const offset = (date.getDay() - this.firstDayOfWeek() + 7) % 7;
1147
- return this.addDays(date, -offset);
1148
- }
1149
- addDays(date, days) {
1150
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
1151
- }
1152
- goToDate(date) {
1153
- this.viewYear.set(date.getFullYear());
1154
- this.viewMonth.set(date.getMonth());
1155
- this.viewDecade.set(this.decadeOf(date.getFullYear()));
1156
- }
1157
- decadeOf(year) {
1158
- return Math.floor(year / 12) * 12;
1159
- }
1160
- setClockFrom(time) {
1161
- const [h, m, s] = time.split(':').map(Number);
1162
- this.viewHour.set(h || 0);
1163
- this.viewMinute.set(m || 0);
1164
- this.viewSecond.set(s || 0);
1165
- }
1166
- /** "YYYY-MM-DD" → local Date at noon (DST-safe). */
1167
- parseISO(iso) {
1168
- return new Date(iso.slice(0, 10) + 'T12:00:00');
1169
- }
1170
- datePartOf(value) {
1171
- const i = value.indexOf('T');
1172
- return i >= 0 ? value.slice(0, i) : value;
1173
- }
1174
- toISODate(date) {
1175
- return `${date.getFullYear()}-${this.pad2(date.getMonth() + 1)}-${this.pad2(date.getDate())}`;
1176
- }
1177
- /** ISO date → how the user types it, in the pattern's field order ("31/12/2026"). */
1178
- formatTyped(iso) {
1179
- const [y, m, d] = iso.split('-');
1180
- const parts = { d, m, y };
1181
- const { order, separator } = this.typedLayout();
1182
- return order.map((field) => parts[field]).join(separator);
1183
- }
1184
- /** ISO date → label of a range end ("6 ene 2026", or the pattern with 'format'). */
1185
- formatMedium(iso) {
1186
- return this.effectiveDisplayStyle() === 'format'
1187
- ? formatDate(iso, this.effectiveDateFormat(), this.effectiveLocale())
1188
- : formatDateStyle(iso, 'medium', this.effectiveLocale());
1189
- }
1190
- /** ISO date → label of the selected day, per the display style. */
1191
- formatDisplay(iso) {
1192
- const style = this.effectiveDisplayStyle();
1193
- return style === 'format'
1194
- ? formatDate(iso, this.effectiveDateFormat(), this.effectiveLocale())
1195
- : formatDateStyle(iso, style, this.effectiveLocale());
1196
- }
1197
- capitalize(text) {
1198
- return text.charAt(0).toUpperCase() + text.slice(1);
1199
- }
1200
- formatTimeFromValue(time) {
1201
- const [h, m, s] = time.split(':').map(Number);
1202
- return this.formatTime(h || 0, m || 0, s || 0);
1203
- }
1204
- formatTime(h, m, s) {
1205
- const secs = this.showSeconds() ? `:${this.pad2(s)}` : '';
1206
- if (this.effectiveHourFormat() === '12') {
1207
- return `${this.pad2(h % 12 || 12)}:${this.pad2(m)}${secs} ${h < 12 ? 'AM' : 'PM'}`;
1208
- }
1209
- return `${this.pad2(h)}:${this.pad2(m)}${secs}`;
1210
- }
1211
- buildTime(h, m, s) {
1212
- let time = `${this.pad2(h)}:${this.pad2(m)}`;
1213
- if (this.showSeconds())
1214
- time += `:${this.pad2(s)}`;
1215
- return time;
1216
- }
1217
- // ---------------------------------------------------------------------------
1218
- // Value conversion (ControlValueAccessor)
1219
- // ---------------------------------------------------------------------------
1220
- writeValue(value) {
1221
- this._value.set(this.range() ? this.normalizeRange(value) : this.normalizeValue(value));
1222
- }
1223
- /**
1224
- * Range values: `{ start, end }` or `[start, end]`, each end parsed like a
1225
- * single date. Stored internally as "startISO|endISO".
1226
- */
1227
- normalizeRange(value) {
1228
- if (value === null || value === undefined || value === '')
1229
- return null;
1230
- let start;
1231
- let end;
1232
- if (Array.isArray(value))
1233
- [start, end] = value;
1234
- else if (typeof value === 'object')
1235
- ({ start, end } = value);
1236
- else
1237
- return this.invalidValue(value);
1238
- const s = this.normalizeValue(start);
1239
- const e = this.normalizeValue(end ?? start);
1240
- if (!s)
1241
- return null;
1242
- const a = this.datePartOf(s);
1243
- const b = e ? this.datePartOf(e) : a;
1244
- return a <= b ? `${a}|${b}` : `${b}|${a}`;
1245
- }
1246
- /**
1247
- * Normalizes an incoming value to the internal ISO string:
1248
- * date/week "YYYY-MM-DD" (+ "THH:mm[:ss]" with showTime), month "YYYY-MM",
1249
- * year "YYYY", timeOnly "HH:mm[:ss]". Accepts ISO strings, Date objects,
1250
- * timestamps, `valueFormat` strings and day-first strings (month-first for 'en').
1251
- */
1252
- normalizeValue(value) {
1253
- if (value === null || value === undefined || value === '')
1254
- return null;
1255
- if (value instanceof Date || typeof value === 'number') {
1256
- const d = new Date(value);
1257
- return isNaN(d.getTime()) ? this.invalidValue(value) : this.fromDate(d);
1258
- }
1259
- if (typeof value !== 'string')
1260
- return this.invalidValue(value);
1261
- const str = value.trim();
1262
- if (!str)
1263
- return null;
1264
- if (this.valueFormat()) {
1265
- const parsed = this.parseWithFormat(str, this.valueFormat());
1266
- if (parsed)
1267
- return parsed;
1268
- }
1269
- if (this.timeOnly()) {
1270
- const time = str.includes('T') ? str.split('T')[1] : str;
1271
- const m = /^(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(time);
1272
- if (!m)
1273
- return this.invalidValue(value);
1274
- return this.buildTime(Number(m[1]), Number(m[2]), Number(m[3] ?? 0));
1275
- }
1276
- const [rawDate, rawTime] = str.split(/[T\s]/);
1277
- const parts = rawDate.split(/[-\/.]/).filter(Boolean);
1278
- let y;
1279
- let mo = 1;
1280
- let d = 1;
1281
- if (parts.length === 1 && /^\d{4}$/.test(parts[0])) {
1282
- y = Number(parts[0]);
1283
- }
1284
- else if (parts.length === 2) {
1285
- if (parts[0].length === 4)
1286
- [y, mo] = parts.map(Number);
1287
- else
1288
- [mo, y] = parts.map(Number);
1289
- }
1290
- else if (parts.length === 3) {
1291
- if (parts[0].length === 4)
1292
- [y, mo, d] = parts.map(Number);
1293
- else if (this.effectiveLocale().startsWith('en'))
1294
- [mo, d, y] = parts.map(Number);
1295
- else
1296
- [d, mo, y] = parts.map(Number);
1297
- }
1298
- else {
1299
- return this.invalidValue(value);
1300
- }
1301
- const date = new Date(y, mo - 1, d);
1302
- if (isNaN(date.getTime()) ||
1303
- date.getFullYear() !== y ||
1304
- date.getMonth() !== mo - 1 ||
1305
- date.getDate() !== d) {
1306
- return this.invalidValue(value);
1307
- }
1308
- const t = rawTime ? /^(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(rawTime) : null;
1309
- if (t)
1310
- date.setHours(Number(t[1]), Number(t[2]), Number(t[3] ?? 0));
1311
- return this.fromDate(date, !!t);
1312
- }
1313
- static { this.FORMAT_TOKENS = /YYYY|MM|DD|HH|mm|ss/g; }
1314
- /** Minimum time between two wheel navigations. */
1315
- static { this.WHEEL_THROTTLE_MS = 150; }
1316
- /** How long a neighbouring-month click waits for a possible double click. */
1317
- static { this.DBLCLICK_DELAY_MS = 250; }
1318
- /** Parses a string with the `valueFormat` pattern into the internal ISO value. */
1319
- parseWithFormat(str, format) {
1320
- const tokens = [];
1321
- const pattern = format
1322
- .split(DatePickerComponent.FORMAT_TOKENS)
1323
- .map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
1324
- const found = format.match(DatePickerComponent.FORMAT_TOKENS) ?? [];
1325
- let source = pattern[0];
1326
- found.forEach((tok, i) => {
1327
- tokens.push(tok);
1328
- source += (tok === 'YYYY' ? '(\\d{4})' : '(\\d{1,2})') + pattern[i + 1];
1329
- });
1330
- const match = new RegExp(`^${source}$`).exec(str);
1331
- if (!match)
1332
- return null;
1333
- const get = (tok, def) => {
1334
- const i = tokens.indexOf(tok);
1335
- return i >= 0 ? Number(match[i + 1]) : def;
1336
- };
1337
- const y = get('YYYY', new Date().getFullYear());
1338
- const mo = get('MM', 1);
1339
- const d = get('DD', 1);
1340
- const h = get('HH', 0);
1341
- const mi = get('mm', 0);
1342
- const s = get('ss', 0);
1343
- if (h > 23 || mi > 59 || s > 59)
1344
- return null;
1345
- const date = new Date(y, mo - 1, d, h, mi, s);
1346
- if (date.getFullYear() !== y || date.getMonth() !== mo - 1 || date.getDate() !== d)
1347
- return null;
1348
- return this.fromDate(date, tokens.includes('HH'));
1349
- }
1350
- /** Converts the internal value to what the form control receives. */
1351
- toOutputValue(value) {
1352
- if (this.range()) {
1353
- const [start, end] = value.split('|');
1354
- return { start: this.formatOutput(start), end: this.formatOutput(end) };
1355
- }
1356
- return this.formatOutput(value);
1357
- }
1358
- /** Applies `valueFormat` to one internal ISO value. */
1359
- formatOutput(value) {
1360
- const format = this.valueFormat();
1361
- if (!format || !value)
1362
- return value;
1363
- let y = '', mo = '01', d = '01', h = '00', mi = '00', s = '00';
1364
- if (this.timeOnly()) {
1365
- [h, mi, s = '00'] = value.split(':');
1366
- }
1367
- else {
1368
- const [datePart, timePart] = value.split('T');
1369
- [y, mo = '01', d = '01'] = datePart.split('-');
1370
- if (timePart)
1371
- [h, mi, s = '00'] = timePart.split(':');
1372
- }
1373
- const map = { YYYY: y, MM: mo, DD: d, HH: h, mm: mi, ss: s };
1374
- return format.replace(DatePickerComponent.FORMAT_TOKENS, (tok) => map[tok]);
1375
- }
1376
- /** Builds the internal value from a Date according to the configuration. */
1377
- fromDate(date, hasTime = true) {
1378
- if (this.timeOnly())
1379
- return this.buildTime(date.getHours(), date.getMinutes(), date.getSeconds());
1380
- const iso = this.toISODate(date);
1381
- const v = this.view();
1382
- if (!this.range()) {
1383
- if (v === 'year')
1384
- return iso.slice(0, 4);
1385
- if (v === 'month')
1386
- return iso.slice(0, 7);
1387
- if (this.showTime() && hasTime) {
1388
- return `${iso}T${this.buildTime(date.getHours(), date.getMinutes(), date.getSeconds())}`;
1389
- }
1390
- }
1391
- return iso;
1392
- }
1393
- invalidValue(value) {
1394
- console.warn('[shk-date-picker] Valor de fecha no válido, se ignora:', value);
1395
- return null;
1396
- }
1397
- registerOnChange(fn) {
1398
- this.onChange = fn;
1399
- }
1400
- registerOnTouched(fn) {
1401
- this.onTouched = fn;
1402
- }
1403
- setDisabledState(isDisabled) {
1404
- this._disabledState.set(isDisabled);
1405
- this.cdr.markForCheck();
1406
- }
1407
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: DatePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1408
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.27", type: DatePickerComponent, isStandalone: true, selector: "shk-date-picker", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, view: { classPropertyName: "view", publicName: "view", isSignal: true, isRequired: false, transformFunction: null }, weekStart: { classPropertyName: "weekStart", publicName: "weekStart", isSignal: true, isRequired: false, transformFunction: null }, range: { classPropertyName: "range", publicName: "range", isSignal: true, isRequired: false, transformFunction: null }, markedDates: { classPropertyName: "markedDates", publicName: "markedDates", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, formGroup: { classPropertyName: "formGroup", publicName: "formGroup", isSignal: true, isRequired: false, transformFunction: null }, controlName: { classPropertyName: "controlName", publicName: "controlName", isSignal: true, isRequired: false, transformFunction: null }, control: { classPropertyName: "control", publicName: "control", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, errorMessages: { classPropertyName: "errorMessages", publicName: "errorMessages", isSignal: true, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: true, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, dateFormat: { classPropertyName: "dateFormat", publicName: "dateFormat", isSignal: true, isRequired: false, transformFunction: null }, displayStyle: { classPropertyName: "displayStyle", publicName: "displayStyle", isSignal: true, isRequired: false, transformFunction: null }, timeOnly: { classPropertyName: "timeOnly", publicName: "timeOnly", isSignal: true, isRequired: false, transformFunction: null }, showTime: { classPropertyName: "showTime", publicName: "showTime", isSignal: true, isRequired: false, transformFunction: null }, hourFormat: { classPropertyName: "hourFormat", publicName: "hourFormat", isSignal: true, isRequired: false, transformFunction: null }, showSeconds: { classPropertyName: "showSeconds", publicName: "showSeconds", isSignal: true, isRequired: false, transformFunction: null }, minuteStep: { classPropertyName: "minuteStep", publicName: "minuteStep", isSignal: true, isRequired: false, transformFunction: null }, valueFormat: { classPropertyName: "valueFormat", publicName: "valueFormat", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", touch: "touch" }, host: { listeners: { "document:click": "onDocumentClick($event)", "window:resize": "onViewportChange()", "document:keydown.escape": "onEscape()" } }, providers: [
1409
- {
1410
- provide: NG_VALUE_ACCESSOR,
1411
- useExisting: forwardRef(() => DatePickerComponent),
1412
- multi: true,
1413
- },
1414
- ], viewQueries: [{ propertyName: "overlay", first: true, predicate: ["overlay"], descendants: true, isSignal: true }, { propertyName: "anchor", first: true, predicate: ["anchor"], descendants: true, isSignal: true }, { propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n <div #anchor class=\"relative\">\n <input\n [id]=\"id()\"\n type=\"text\"\n autocomplete=\"off\"\n [disabled]=\"isDisabled()\"\n [placeholder]=\"inputPlaceholder()\"\n [value]=\"isTyping() ? typedValue() : displayLabel()\"\n (input)=\"onInputText($event)\"\n (focus)=\"onInputFocus()\"\n (blur)=\"onInputBlur()\"\n (keydown.enter)=\"$any($event.target).blur()\"\n (keydown.escape)=\"cancelTyping()\"\n (click)=\"toggle()\"\n class=\"date-input-field\"\n [ngClass]=\"{\n 'input-error': shouldShowError() || typingValid() === false,\n 'input-valid': wasFixedError() || typingValid() === true,\n }\"\n [attr.aria-invalid]=\"shouldShowError() || typingValid() === false || null\"\n [attr.aria-describedby]=\"shouldShowError() ? id() + '-error' : null\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"isOpen()\"\n />\n <button\n type=\"button\"\n tabindex=\"-1\"\n [disabled]=\"isDisabled()\"\n (click)=\"toggle()\"\n class=\"absolute right-2 top-1/2 -translate-y-1/2 p-1 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n [attr.aria-label]=\"texts().open\"\n >\n @if (timeOnly()) {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <circle cx=\"12\" cy=\"12\" r=\"9\"></circle>\n <path d=\"M12 7v5l3 2\"></path>\n </svg>\n } @else {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\"></rect>\n <path d=\"M16 2v4M8 2v4M3 10h18\"></path>\n </svg>\n }\n </button>\n </div>\n\n @if (isOpen()) {\n <div #overlay shkPortal class=\"shk-date-picker-overlay\">\n <div class=\"fixed inset-0 z-40\" (click)=\"close()\"></div>\n\n <div\n #panel\n role=\"dialog\"\n class=\"dp-panel fixed z-50 p-4\"\n [style.top.px]=\"panelPosition()?.top ?? 0\"\n [style.left.px]=\"panelPosition()?.left ?? 0\"\n [style.visibility]=\"panelPosition() ? 'visible' : 'hidden'\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onPanelKeydown($event)\"\n >\n <div class=\"flex items-stretch\">\n @if (!timeOnly()) {\n <!-- ================= DAYS ================= -->\n @if (currentView() === 'date') {\n <div class=\"flex gap-6\" (wheel)=\"onWheel($event)\">\n @for (m of visibleMonths(); track m.year * 12 + m.month; let first = $first; let last = $last) {\n <div class=\"w-64\" [class.dp-month-divider]=\"!first\">\n <!-- Header: \u2039 Mes A\u00F1o \u203A -->\n <div class=\"flex items-center justify-between mb-3\">\n @if (first) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">\n {{ monthLongNames()[m.month] }} {{ m.year }}\n </button>\n @if (last) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n </div>\n\n <!-- Typed date + Today (single mode) -->\n @if (!range()) {\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input\"\n [class.input-error]=\"panelTextError() === 'single'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"panelText()\"\n (keydown.enter)=\"commitPanelText('single', $event)\"\n (blur)=\"commitPanelText('single', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n </div>\n }\n\n <!-- Weekday names -->\n <div class=\"grid grid-cols-7\">\n @for (name of dayNames(); track $index) {\n <div class=\"dp-weekday\">{{ name }}</div>\n }\n </div>\n\n <!-- Day grid (6 weeks, neighbouring months included) -->\n <div class=\"grid grid-cols-7\" (mouseleave)=\"onDayHover(null)\">\n @for (cell of m.cells; track cell.iso) {\n <div\n class=\"dp-cell\"\n [class.in-range]=\"(cell.inMonth || !range()) && isInRange(cell.iso)\"\n [class.range-start]=\"(cell.inMonth || !range()) && isRangeStart(cell.iso)\"\n [class.range-end]=\"(cell.inMonth || !range()) && isRangeEnd(cell.iso)\"\n >\n <button\n type=\"button\"\n class=\"dp-day\"\n [class.is-outside]=\"!cell.inMonth\"\n [class.is-today]=\"isTodayDate(cell.iso)\"\n [class.is-selected]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [disabled]=\"isDisabledDate(cell.iso)\"\n [attr.aria-pressed]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [attr.aria-current]=\"isTodayDate(cell.iso) ? 'date' : null\"\n (click)=\"selectDay(cell)\"\n (dblclick)=\"quickApply(cell)\"\n (mouseenter)=\"onDayHover(cell)\"\n >\n {{ cell.day }}\n @if (isMarked(cell.iso)) {\n <span class=\"dp-dot\"></span>\n }\n </button>\n </div>\n }\n </div>\n </div>\n }\n </div>\n }\n\n <!-- ================= WEEKS ================= -->\n @if (currentView() === 'week') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"space-y-1\">\n @for (week of monthWeeks(); track week.index) {\n <button\n type=\"button\"\n (click)=\"selectWeek(week.start)\"\n class=\"dp-chip w-full flex items-center justify-between px-3\"\n [class.is-selected]=\"isSelectedWeek(week.start)\"\n [class.is-current]=\"isCurrentWeek(week.start)\"\n >\n <span class=\"font-medium\">{{ weekLabel(week.index) }}</span>\n <span class=\"text-xs opacity-80\">{{ week.range }}</span>\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= MONTHS ================= -->\n @if (currentView() === 'month') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (name of monthNames(); track $index) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedMonth($index)\"\n [class.is-current]=\"isCurrentMonth($index)\"\n (click)=\"selectMonth($index)\"\n >\n {{ name }}\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= YEARS ================= -->\n @if (currentView() === 'year') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <span class=\"dp-title\">{{ headerTitle() }}</span>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (year of decadeYears(); track year) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedYear(year)\"\n [class.is-current]=\"isCurrentYear(year)\"\n (click)=\"selectYear(year)\"\n >\n {{ year }}\n </button>\n }\n </div>\n </div>\n }\n }\n\n <!-- ================= TIME (columns) ================= -->\n @if (showTimeColumns()) {\n <div\n class=\"flex flex-col\"\n [ngClass]=\"timeOnly() ? 'w-64' : 'w-40 ml-6 dp-month-divider'\"\n >\n <!-- Typed time + Now -->\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input text-center font-semibold tabular-nums\"\n [class.input-error]=\"timeTextError()\"\n [placeholder]=\"effectiveHourFormat() === '12' ? 'hh:mm AM' : 'HH:mm'\"\n [value]=\"timeText()\"\n (keydown.enter)=\"commitTimeText($event)\"\n (blur)=\"commitTimeText($event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"setNow()\">{{ texts().now }}</button>\n </div>\n\n <!-- Column titles -->\n <div class=\"flex\">\n <div class=\"dp-weekday flex-1\">{{ texts().hour }}</div>\n <div class=\"dp-weekday flex-1\">{{ texts().minute }}</div>\n @if (showSeconds()) {\n <div class=\"dp-weekday flex-1\">{{ texts().second }}</div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-weekday flex-1\"></div>\n }\n </div>\n\n <!-- Scrollable columns -->\n <div class=\"relative\" [ngClass]=\"timeOnly() ? 'h-56' : 'flex-1 min-h-[12rem]'\">\n <div class=\"absolute inset-0 flex\">\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().hour\">\n @for (h of hourOptions(); track h.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewHour() === h.value\"\n [class.is-current]=\"isCurrentHour(h.value)\"\n [attr.aria-selected]=\"viewHour() === h.value\"\n (click)=\"selectHour(h.value)\"\n >\n {{ h.label }}\n </button>\n }\n </div>\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().minute\">\n @for (m of minuteOptions(); track m) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewMinute() === m\"\n [attr.aria-selected]=\"viewMinute() === m\"\n (click)=\"selectMinute(m)\"\n >\n {{ pad2(m) }}\n </button>\n }\n </div>\n @if (showSeconds()) {\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().second\">\n @for (sec of secondOptions; track sec) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewSecond() === sec\"\n [attr.aria-selected]=\"viewSecond() === sec\"\n (click)=\"selectSecond(sec)\"\n >\n {{ pad2(sec) }}\n </button>\n }\n </div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-time-col\">\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'AM'\" (click)=\"setMeridiem('AM')\">AM</button>\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'PM'\" (click)=\"setMeridiem('PM')\">PM</button>\n </div>\n }\n </div>\n </div>\n </div>\n }\n </div>\n\n <!-- ================= FOOTER ================= -->\n @if (showFooter()) {\n <div class=\"mt-4 pt-4 border-t dp-divider\">\n @if (range()) {\n <div class=\"flex items-center gap-3\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n <div class=\"flex-1\"></div>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'start'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeStartText()\"\n (keydown.enter)=\"commitPanelText('start', $event)\"\n (blur)=\"commitPanelText('start', $event)\"\n />\n <span class=\"_shk-text-surface-400\">\u2013</span>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'end'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeEndText()\"\n (keydown.enter)=\"commitPanelText('end', $event)\"\n (blur)=\"commitPanelText('end', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n } @else {\n <div class=\"grid grid-cols-2 gap-3 w-64 ml-auto\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n @if (shouldShowError()) {\n <div [id]=\"id() + '-error'\" class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\">\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>\n", styles: [".dp-panel{background-color:#fff;border:1px solid var(--shk-surface-200);border-radius:.75rem;box-shadow:0 12px 32px -8px #0000002e,0 2px 6px #0000000f;color:var(--shk-surface-700)}.dark .dp-panel{background-color:var(--shk-surface-100)}.dp-nav{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-surface-500);transition:background-color .15s,color .15s}.dp-nav:hover:not(:disabled){background-color:var(--shk-surface-100);color:var(--shk-surface-800)}.dark .dp-nav:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-nav:disabled{opacity:.3;cursor:not-allowed}.dp-title{font-size:.875rem;font-weight:600;padding:.25rem .5rem;border-radius:.375rem;color:var(--shk-surface-800);transition:background-color .15s}button.dp-title:hover{background-color:var(--shk-surface-100)}.dark button.dp-title:hover{background-color:var(--shk-surface-200)}.dp-month-divider{position:relative}.dp-month-divider:before{content:\"\";position:absolute;top:-1rem;bottom:0;left:-.75rem;border-left:1px solid var(--shk-surface-200)}.dp-weekday{text-align:center;font-size:.75rem;font-weight:500;color:var(--shk-surface-500);padding:.25rem 0}.dp-cell{position:relative;display:flex;align-items:center;justify-content:center;height:2.25rem}.dp-cell.in-range:before,.dp-cell.range-start:before,.dp-cell.range-end:before{content:\"\";position:absolute;inset:.125rem 0;background-color:color-mix(in srgb,var(--shk-primary-500) 12%,transparent)}.dp-cell.range-start:before{left:50%}.dp-cell.range-end:before{right:50%}.dp-cell.range-start.range-end:before{display:none}.dp-day{position:relative;z-index:1;width:2.125rem;height:2.125rem;border-radius:9999px;font-size:.8125rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-200)}.dp-day.is-outside{color:var(--shk-surface-400)}.dp-day.is-today{font-weight:700;color:var(--shk-primary-600);background-color:color-mix(in srgb,var(--shk-primary-500) 10%,transparent)}.dp-day.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-day:disabled{opacity:.3;cursor:not-allowed;text-decoration:line-through}.dp-dot{position:absolute;left:50%;bottom:.25rem;width:.25rem;height:.25rem;border-radius:9999px;transform:translate(-50%);background-color:var(--shk-primary-500)}.dp-day.is-selected .dp-dot{background-color:#fff}.dp-chip{padding:.5rem 0;font-size:.8125rem;border-radius:.5rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-chip.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-chip.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-btn{display:inline-flex;align-items:center;justify-content:center;padding:.4375rem .875rem;font-size:.8125rem;font-weight:500;border-radius:.5rem;border:1px solid var(--shk-surface-200);color:var(--shk-surface-700);background-color:transparent;transition:background-color .15s,border-color .15s;white-space:nowrap}.dp-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}.dark .dp-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-btn-primary{border-color:var(--shk-primary-500);background-color:var(--shk-primary-500);color:#fff}.dp-btn-primary:hover:not(:disabled){background-color:var(--shk-primary-700)!important;border-color:var(--shk-primary-700)}.dp-btn:disabled{opacity:.5;cursor:not-allowed}.dp-mini-input{width:100%;min-width:0;padding:.4375rem .625rem;font-size:.8125rem;border-radius:.5rem;border:1px solid var(--shk-surface-200);background-color:transparent;color:var(--shk-surface-700);outline:none;transition:border-color .15s,box-shadow .15s}.dp-mini-input:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.dp-mini-input.input-error{border-color:var(--shk-error-500)}.dp-divider{border-color:var(--shk-surface-200)}.dp-time-col{position:relative;flex:1 1 0;min-width:0;overflow-y:auto;scrollbar-width:thin;scroll-behavior:smooth;padding:0 .125rem}.dp-time-col+.dp-time-col{border-left:1px solid var(--shk-surface-200)}.dp-time-item{display:flex;align-items:center;justify-content:center;width:100%;height:2rem;margin:.125rem 0;border-radius:.5rem;font-size:.8125rem;font-variant-numeric:tabular-nums;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-time-item.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-time-item.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.date-input-field{width:100%;padding:.5rem 2.5rem .5rem .75rem;font-size:.875rem;border-radius:.5rem;outline:none;transition:border-color .15s,box-shadow .15s;background-color:var(--shk-surface-50);color:var(--shk-surface-700);border:1px solid var(--shk-surface-200);text-overflow:ellipsis}:host-context(.dark) .date-input-field,.dark .date-input-field{background-color:var(--shk-surface-100)}.date-input-field::placeholder{color:var(--shk-surface-400)}.date-input-field:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.date-input-field:disabled{background-color:var(--shk-surface-100);color:var(--shk-surface-500);cursor:not-allowed}:host-context(.dark) .date-input-field:disabled,.dark .date-input-field:disabled{background-color:var(--shk-surface-50);color:var(--shk-surface-400)}.date-input-field.input-error,:host-context(.dark) .date-input-field.input-error,.dark .date-input-field.input-error{border-color:var(--shk-error-500)}.date-input-field.input-error:focus,:host-context(.dark) .date-input-field.input-error:focus,.dark .date-input-field.input-error:focus{box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-error-500) 22%,transparent)}.date-input-field.input-valid,:host-context(.dark) .date-input-field.input-valid,.dark .date-input-field.input-valid{border-color:#22c55e}.date-input-field.input-valid:focus,:host-context(.dark) .date-input-field.input-valid:focus,.dark .date-input-field.input-valid:focus{box-shadow:0 0 0 3px #22c55e33}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: PortalDirective, selector: "[shkPortal]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1415
- }
1416
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.27", ngImport: i0, type: DatePickerComponent, decorators: [{
1417
- type: Component,
1418
- args: [{ selector: 'shk-date-picker', imports: [CommonModule, ReactiveFormsModule, PortalDirective], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
1419
- {
1420
- provide: NG_VALUE_ACCESSOR,
1421
- useExisting: forwardRef(() => DatePickerComponent),
1422
- multi: true,
1423
- },
1424
- ], template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n <div #anchor class=\"relative\">\n <input\n [id]=\"id()\"\n type=\"text\"\n autocomplete=\"off\"\n [disabled]=\"isDisabled()\"\n [placeholder]=\"inputPlaceholder()\"\n [value]=\"isTyping() ? typedValue() : displayLabel()\"\n (input)=\"onInputText($event)\"\n (focus)=\"onInputFocus()\"\n (blur)=\"onInputBlur()\"\n (keydown.enter)=\"$any($event.target).blur()\"\n (keydown.escape)=\"cancelTyping()\"\n (click)=\"toggle()\"\n class=\"date-input-field\"\n [ngClass]=\"{\n 'input-error': shouldShowError() || typingValid() === false,\n 'input-valid': wasFixedError() || typingValid() === true,\n }\"\n [attr.aria-invalid]=\"shouldShowError() || typingValid() === false || null\"\n [attr.aria-describedby]=\"shouldShowError() ? id() + '-error' : null\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"isOpen()\"\n />\n <button\n type=\"button\"\n tabindex=\"-1\"\n [disabled]=\"isDisabled()\"\n (click)=\"toggle()\"\n class=\"absolute right-2 top-1/2 -translate-y-1/2 p-1 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n [attr.aria-label]=\"texts().open\"\n >\n @if (timeOnly()) {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <circle cx=\"12\" cy=\"12\" r=\"9\"></circle>\n <path d=\"M12 7v5l3 2\"></path>\n </svg>\n } @else {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\"></rect>\n <path d=\"M16 2v4M8 2v4M3 10h18\"></path>\n </svg>\n }\n </button>\n </div>\n\n @if (isOpen()) {\n <div #overlay shkPortal class=\"shk-date-picker-overlay\">\n <div class=\"fixed inset-0 z-40\" (click)=\"close()\"></div>\n\n <div\n #panel\n role=\"dialog\"\n class=\"dp-panel fixed z-50 p-4\"\n [style.top.px]=\"panelPosition()?.top ?? 0\"\n [style.left.px]=\"panelPosition()?.left ?? 0\"\n [style.visibility]=\"panelPosition() ? 'visible' : 'hidden'\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onPanelKeydown($event)\"\n >\n <div class=\"flex items-stretch\">\n @if (!timeOnly()) {\n <!-- ================= DAYS ================= -->\n @if (currentView() === 'date') {\n <div class=\"flex gap-6\" (wheel)=\"onWheel($event)\">\n @for (m of visibleMonths(); track m.year * 12 + m.month; let first = $first; let last = $last) {\n <div class=\"w-64\" [class.dp-month-divider]=\"!first\">\n <!-- Header: \u2039 Mes A\u00F1o \u203A -->\n <div class=\"flex items-center justify-between mb-3\">\n @if (first) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">\n {{ monthLongNames()[m.month] }} {{ m.year }}\n </button>\n @if (last) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n </div>\n\n <!-- Typed date + Today (single mode) -->\n @if (!range()) {\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input\"\n [class.input-error]=\"panelTextError() === 'single'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"panelText()\"\n (keydown.enter)=\"commitPanelText('single', $event)\"\n (blur)=\"commitPanelText('single', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n </div>\n }\n\n <!-- Weekday names -->\n <div class=\"grid grid-cols-7\">\n @for (name of dayNames(); track $index) {\n <div class=\"dp-weekday\">{{ name }}</div>\n }\n </div>\n\n <!-- Day grid (6 weeks, neighbouring months included) -->\n <div class=\"grid grid-cols-7\" (mouseleave)=\"onDayHover(null)\">\n @for (cell of m.cells; track cell.iso) {\n <div\n class=\"dp-cell\"\n [class.in-range]=\"(cell.inMonth || !range()) && isInRange(cell.iso)\"\n [class.range-start]=\"(cell.inMonth || !range()) && isRangeStart(cell.iso)\"\n [class.range-end]=\"(cell.inMonth || !range()) && isRangeEnd(cell.iso)\"\n >\n <button\n type=\"button\"\n class=\"dp-day\"\n [class.is-outside]=\"!cell.inMonth\"\n [class.is-today]=\"isTodayDate(cell.iso)\"\n [class.is-selected]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [disabled]=\"isDisabledDate(cell.iso)\"\n [attr.aria-pressed]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [attr.aria-current]=\"isTodayDate(cell.iso) ? 'date' : null\"\n (click)=\"selectDay(cell)\"\n (dblclick)=\"quickApply(cell)\"\n (mouseenter)=\"onDayHover(cell)\"\n >\n {{ cell.day }}\n @if (isMarked(cell.iso)) {\n <span class=\"dp-dot\"></span>\n }\n </button>\n </div>\n }\n </div>\n </div>\n }\n </div>\n }\n\n <!-- ================= WEEKS ================= -->\n @if (currentView() === 'week') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"space-y-1\">\n @for (week of monthWeeks(); track week.index) {\n <button\n type=\"button\"\n (click)=\"selectWeek(week.start)\"\n class=\"dp-chip w-full flex items-center justify-between px-3\"\n [class.is-selected]=\"isSelectedWeek(week.start)\"\n [class.is-current]=\"isCurrentWeek(week.start)\"\n >\n <span class=\"font-medium\">{{ weekLabel(week.index) }}</span>\n <span class=\"text-xs opacity-80\">{{ week.range }}</span>\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= MONTHS ================= -->\n @if (currentView() === 'month') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (name of monthNames(); track $index) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedMonth($index)\"\n [class.is-current]=\"isCurrentMonth($index)\"\n (click)=\"selectMonth($index)\"\n >\n {{ name }}\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= YEARS ================= -->\n @if (currentView() === 'year') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <span class=\"dp-title\">{{ headerTitle() }}</span>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (year of decadeYears(); track year) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedYear(year)\"\n [class.is-current]=\"isCurrentYear(year)\"\n (click)=\"selectYear(year)\"\n >\n {{ year }}\n </button>\n }\n </div>\n </div>\n }\n }\n\n <!-- ================= TIME (columns) ================= -->\n @if (showTimeColumns()) {\n <div\n class=\"flex flex-col\"\n [ngClass]=\"timeOnly() ? 'w-64' : 'w-40 ml-6 dp-month-divider'\"\n >\n <!-- Typed time + Now -->\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input text-center font-semibold tabular-nums\"\n [class.input-error]=\"timeTextError()\"\n [placeholder]=\"effectiveHourFormat() === '12' ? 'hh:mm AM' : 'HH:mm'\"\n [value]=\"timeText()\"\n (keydown.enter)=\"commitTimeText($event)\"\n (blur)=\"commitTimeText($event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"setNow()\">{{ texts().now }}</button>\n </div>\n\n <!-- Column titles -->\n <div class=\"flex\">\n <div class=\"dp-weekday flex-1\">{{ texts().hour }}</div>\n <div class=\"dp-weekday flex-1\">{{ texts().minute }}</div>\n @if (showSeconds()) {\n <div class=\"dp-weekday flex-1\">{{ texts().second }}</div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-weekday flex-1\"></div>\n }\n </div>\n\n <!-- Scrollable columns -->\n <div class=\"relative\" [ngClass]=\"timeOnly() ? 'h-56' : 'flex-1 min-h-[12rem]'\">\n <div class=\"absolute inset-0 flex\">\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().hour\">\n @for (h of hourOptions(); track h.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewHour() === h.value\"\n [class.is-current]=\"isCurrentHour(h.value)\"\n [attr.aria-selected]=\"viewHour() === h.value\"\n (click)=\"selectHour(h.value)\"\n >\n {{ h.label }}\n </button>\n }\n </div>\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().minute\">\n @for (m of minuteOptions(); track m) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewMinute() === m\"\n [attr.aria-selected]=\"viewMinute() === m\"\n (click)=\"selectMinute(m)\"\n >\n {{ pad2(m) }}\n </button>\n }\n </div>\n @if (showSeconds()) {\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().second\">\n @for (sec of secondOptions; track sec) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewSecond() === sec\"\n [attr.aria-selected]=\"viewSecond() === sec\"\n (click)=\"selectSecond(sec)\"\n >\n {{ pad2(sec) }}\n </button>\n }\n </div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-time-col\">\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'AM'\" (click)=\"setMeridiem('AM')\">AM</button>\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'PM'\" (click)=\"setMeridiem('PM')\">PM</button>\n </div>\n }\n </div>\n </div>\n </div>\n }\n </div>\n\n <!-- ================= FOOTER ================= -->\n @if (showFooter()) {\n <div class=\"mt-4 pt-4 border-t dp-divider\">\n @if (range()) {\n <div class=\"flex items-center gap-3\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n <div class=\"flex-1\"></div>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'start'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeStartText()\"\n (keydown.enter)=\"commitPanelText('start', $event)\"\n (blur)=\"commitPanelText('start', $event)\"\n />\n <span class=\"_shk-text-surface-400\">\u2013</span>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'end'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeEndText()\"\n (keydown.enter)=\"commitPanelText('end', $event)\"\n (blur)=\"commitPanelText('end', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n } @else {\n <div class=\"grid grid-cols-2 gap-3 w-64 ml-auto\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n @if (shouldShowError()) {\n <div [id]=\"id() + '-error'\" class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\">\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>\n", styles: [".dp-panel{background-color:#fff;border:1px solid var(--shk-surface-200);border-radius:.75rem;box-shadow:0 12px 32px -8px #0000002e,0 2px 6px #0000000f;color:var(--shk-surface-700)}.dark .dp-panel{background-color:var(--shk-surface-100)}.dp-nav{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-surface-500);transition:background-color .15s,color .15s}.dp-nav:hover:not(:disabled){background-color:var(--shk-surface-100);color:var(--shk-surface-800)}.dark .dp-nav:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-nav:disabled{opacity:.3;cursor:not-allowed}.dp-title{font-size:.875rem;font-weight:600;padding:.25rem .5rem;border-radius:.375rem;color:var(--shk-surface-800);transition:background-color .15s}button.dp-title:hover{background-color:var(--shk-surface-100)}.dark button.dp-title:hover{background-color:var(--shk-surface-200)}.dp-month-divider{position:relative}.dp-month-divider:before{content:\"\";position:absolute;top:-1rem;bottom:0;left:-.75rem;border-left:1px solid var(--shk-surface-200)}.dp-weekday{text-align:center;font-size:.75rem;font-weight:500;color:var(--shk-surface-500);padding:.25rem 0}.dp-cell{position:relative;display:flex;align-items:center;justify-content:center;height:2.25rem}.dp-cell.in-range:before,.dp-cell.range-start:before,.dp-cell.range-end:before{content:\"\";position:absolute;inset:.125rem 0;background-color:color-mix(in srgb,var(--shk-primary-500) 12%,transparent)}.dp-cell.range-start:before{left:50%}.dp-cell.range-end:before{right:50%}.dp-cell.range-start.range-end:before{display:none}.dp-day{position:relative;z-index:1;width:2.125rem;height:2.125rem;border-radius:9999px;font-size:.8125rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-200)}.dp-day.is-outside{color:var(--shk-surface-400)}.dp-day.is-today{font-weight:700;color:var(--shk-primary-600);background-color:color-mix(in srgb,var(--shk-primary-500) 10%,transparent)}.dp-day.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-day:disabled{opacity:.3;cursor:not-allowed;text-decoration:line-through}.dp-dot{position:absolute;left:50%;bottom:.25rem;width:.25rem;height:.25rem;border-radius:9999px;transform:translate(-50%);background-color:var(--shk-primary-500)}.dp-day.is-selected .dp-dot{background-color:#fff}.dp-chip{padding:.5rem 0;font-size:.8125rem;border-radius:.5rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-chip.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-chip.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-btn{display:inline-flex;align-items:center;justify-content:center;padding:.4375rem .875rem;font-size:.8125rem;font-weight:500;border-radius:.5rem;border:1px solid var(--shk-surface-200);color:var(--shk-surface-700);background-color:transparent;transition:background-color .15s,border-color .15s;white-space:nowrap}.dp-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}.dark .dp-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-btn-primary{border-color:var(--shk-primary-500);background-color:var(--shk-primary-500);color:#fff}.dp-btn-primary:hover:not(:disabled){background-color:var(--shk-primary-700)!important;border-color:var(--shk-primary-700)}.dp-btn:disabled{opacity:.5;cursor:not-allowed}.dp-mini-input{width:100%;min-width:0;padding:.4375rem .625rem;font-size:.8125rem;border-radius:.5rem;border:1px solid var(--shk-surface-200);background-color:transparent;color:var(--shk-surface-700);outline:none;transition:border-color .15s,box-shadow .15s}.dp-mini-input:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.dp-mini-input.input-error{border-color:var(--shk-error-500)}.dp-divider{border-color:var(--shk-surface-200)}.dp-time-col{position:relative;flex:1 1 0;min-width:0;overflow-y:auto;scrollbar-width:thin;scroll-behavior:smooth;padding:0 .125rem}.dp-time-col+.dp-time-col{border-left:1px solid var(--shk-surface-200)}.dp-time-item{display:flex;align-items:center;justify-content:center;width:100%;height:2rem;margin:.125rem 0;border-radius:.5rem;font-size:.8125rem;font-variant-numeric:tabular-nums;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-time-item.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-time-item.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.date-input-field{width:100%;padding:.5rem 2.5rem .5rem .75rem;font-size:.875rem;border-radius:.5rem;outline:none;transition:border-color .15s,box-shadow .15s;background-color:var(--shk-surface-50);color:var(--shk-surface-700);border:1px solid var(--shk-surface-200);text-overflow:ellipsis}:host-context(.dark) .date-input-field,.dark .date-input-field{background-color:var(--shk-surface-100)}.date-input-field::placeholder{color:var(--shk-surface-400)}.date-input-field:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.date-input-field:disabled{background-color:var(--shk-surface-100);color:var(--shk-surface-500);cursor:not-allowed}:host-context(.dark) .date-input-field:disabled,.dark .date-input-field:disabled{background-color:var(--shk-surface-50);color:var(--shk-surface-400)}.date-input-field.input-error,:host-context(.dark) .date-input-field.input-error,.dark .date-input-field.input-error{border-color:var(--shk-error-500)}.date-input-field.input-error:focus,:host-context(.dark) .date-input-field.input-error:focus,.dark .date-input-field.input-error:focus{box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-error-500) 22%,transparent)}.date-input-field.input-valid,:host-context(.dark) .date-input-field.input-valid,.dark .date-input-field.input-valid{border-color:#22c55e}.date-input-field.input-valid:focus,:host-context(.dark) .date-input-field.input-valid:focus,.dark .date-input-field.input-valid:focus{box-shadow:0 0 0 3px #22c55e33}\n"] }]
1425
- }], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], view: [{ type: i0.Input, args: [{ isSignal: true, alias: "view", required: false }] }], weekStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStart", required: false }] }], range: [{ type: i0.Input, args: [{ isSignal: true, alias: "range", required: false }] }], markedDates: [{ type: i0.Input, args: [{ isSignal: true, alias: "markedDates", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], formGroup: [{ type: i0.Input, args: [{ isSignal: true, alias: "formGroup", required: false }] }], controlName: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlName", required: false }] }], control: [{ type: i0.Input, args: [{ isSignal: true, alias: "control", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], errorMessages: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessages", required: false }] }], minValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "minValue", required: false }] }], maxValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxValue", required: false }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: false }] }], dateFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateFormat", required: false }] }], displayStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayStyle", required: false }] }], timeOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "timeOnly", required: false }] }], showTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTime", required: false }] }], hourFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "hourFormat", required: false }] }], showSeconds: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSeconds", required: false }] }], minuteStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "minuteStep", required: false }] }], valueFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueFormat", required: false }] }], overlay: [{ type: i0.ViewChild, args: ['overlay', { isSignal: true }] }], anchor: [{ type: i0.ViewChild, args: ['anchor', { isSignal: true }] }], panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], onDocumentClick: [{
1426
- type: HostListener,
1427
- args: ['document:click', ['$event']]
1428
- }], onViewportChange: [{
1429
- type: HostListener,
1430
- args: ['window:resize']
1431
- }], onEscape: [{
1432
- type: HostListener,
1433
- args: ['document:keydown.escape']
1434
- }], touch: [{ type: i0.Output, args: ["touch"] }] } });
1435
-
1436
- /**
1437
- * Generated bundle index. Do not edit.
1438
- */
1439
-
1
+ import * as i1 from "@angular/common";
2
+ import { CommonModule } from "@angular/common";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, ElementRef, HostListener, Injector, afterNextRender, computed, effect, forwardRef, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
5
+ import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";
6
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
7
+ import { TranslocoService } from "@jsverse/transloco";
8
+ import { PortalDirective, errorMessagesFromMap, signalErrorsToMap } from "shirkasoft-ui-components/utils";
9
+ import { ShkConfigService, formatDate, formatDateStyle, resolveDateFormat, typedDateLayout } from "shirkasoft-ui-components/config";
10
+ var DatePickerComponent = class DatePickerComponent {
11
+ get _value() {
12
+ return this.value;
13
+ }
14
+ constructor() {
15
+ this.elementRef = inject(ElementRef);
16
+ this.cdr = inject(ChangeDetectorRef);
17
+ this.destroyRef = inject(DestroyRef);
18
+ this.injector = inject(Injector);
19
+ this.transloco = inject(TranslocoService);
20
+ this.id = input("", ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
21
+ this.view = input("date", ...ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []);
22
+ this.weekStart = input(null, ...ngDevMode ? [{ debugName: "weekStart" }] : /* istanbul ignore next */ []);
23
+ this.range = input(false, ...ngDevMode ? [{ debugName: "range" }] : /* istanbul ignore next */ []);
24
+ this.markedDates = input([], ...ngDevMode ? [{ debugName: "markedDates" }] : /* istanbul ignore next */ []);
25
+ this.label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
26
+ this.placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
27
+ this.formGroup = input(void 0, ...ngDevMode ? [{ debugName: "formGroup" }] : /* istanbul ignore next */ []);
28
+ this.controlName = input("", ...ngDevMode ? [{ debugName: "controlName" }] : /* istanbul ignore next */ []);
29
+ this.control = input(void 0, ...ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []);
30
+ this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
31
+ this.errors = input([], ...ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []);
32
+ this.invalid = input(false, ...ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []);
33
+ this.touched = input(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
34
+ this.dirty = input(false, ...ngDevMode ? [{ debugName: "dirty" }] : /* istanbul ignore next */ []);
35
+ this.errorMessage = input("", ...ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []);
36
+ this.errorMessages = input({}, ...ngDevMode ? [{ debugName: "errorMessages" }] : /* istanbul ignore next */ []);
37
+ this.minValue = input("", ...ngDevMode ? [{ debugName: "minValue" }] : /* istanbul ignore next */ []);
38
+ this.maxValue = input("", ...ngDevMode ? [{ debugName: "maxValue" }] : /* istanbul ignore next */ []);
39
+ this.locale = input("", ...ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []);
40
+ this.dateFormat = input("", ...ngDevMode ? [{ debugName: "dateFormat" }] : /* istanbul ignore next */ []);
41
+ this.displayStyle = input(void 0, ...ngDevMode ? [{ debugName: "displayStyle" }] : /* istanbul ignore next */ []);
42
+ this.timeOnly = input(false, ...ngDevMode ? [{ debugName: "timeOnly" }] : /* istanbul ignore next */ []);
43
+ this.showTime = input(false, ...ngDevMode ? [{ debugName: "showTime" }] : /* istanbul ignore next */ []);
44
+ this.hourFormat = input(void 0, ...ngDevMode ? [{ debugName: "hourFormat" }] : /* istanbul ignore next */ []);
45
+ this.showSeconds = input(false, ...ngDevMode ? [{ debugName: "showSeconds" }] : /* istanbul ignore next */ []);
46
+ this.minuteStep = input(1, ...ngDevMode ? [{ debugName: "minuteStep" }] : /* istanbul ignore next */ []);
47
+ this.valueFormat = input("", ...ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []);
48
+ this.config = inject(ShkConfigService);
49
+ this.effectiveLocale = computed(() => this.locale() || this.config.get("dates.locale")(), ...ngDevMode ? [{ debugName: "effectiveLocale" }] : /* istanbul ignore next */ []);
50
+ this.effectiveHourFormat = computed(() => this.hourFormat() ?? this.config.get("dates.hourFormat")(), ...ngDevMode ? [{ debugName: "effectiveHourFormat" }] : /* istanbul ignore next */ []);
51
+ this.effectiveDateFormat = computed(() => resolveDateFormat(this.dateFormat() || this.config.get("dates.format")(), this.effectiveLocale()), ...ngDevMode ? [{ debugName: "effectiveDateFormat" }] : /* istanbul ignore next */ []);
52
+ this.typedLayout = computed(() => typedDateLayout(this.effectiveDateFormat()), ...ngDevMode ? [{ debugName: "typedLayout" }] : /* istanbul ignore next */ []);
53
+ this.effectiveDisplayStyle = computed(() => this.displayStyle() ?? this.config.get("dates.displayStyle")(), ...ngDevMode ? [{ debugName: "effectiveDisplayStyle" }] : /* istanbul ignore next */ []);
54
+ this.overlay = viewChild("overlay", ...ngDevMode ? [{ debugName: "overlay" }] : /* istanbul ignore next */ []);
55
+ this.anchor = viewChild("anchor", ...ngDevMode ? [{ debugName: "anchor" }] : /* istanbul ignore next */ []);
56
+ this.panel = viewChild("panel", ...ngDevMode ? [{ debugName: "panel" }] : /* istanbul ignore next */ []);
57
+ this.panelPosition = signal(null, ...ngDevMode ? [{ debugName: "panelPosition" }] : /* istanbul ignore next */ []);
58
+ this.isOpen = signal(false, ...ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []);
59
+ this.currentView = signal("date", ...ngDevMode ? [{ debugName: "currentView" }] : /* istanbul ignore next */ []);
60
+ this.viewYear = signal((/* @__PURE__ */ new Date()).getFullYear(), ...ngDevMode ? [{ debugName: "viewYear" }] : /* istanbul ignore next */ []);
61
+ this.viewMonth = signal((/* @__PURE__ */ new Date()).getMonth(), ...ngDevMode ? [{ debugName: "viewMonth" }] : /* istanbul ignore next */ []);
62
+ this.viewDecade = signal(Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 12) * 12, ...ngDevMode ? [{ debugName: "viewDecade" }] : /* istanbul ignore next */ []);
63
+ this.viewHour = signal(0, ...ngDevMode ? [{ debugName: "viewHour" }] : /* istanbul ignore next */ []);
64
+ this.viewMinute = signal(0, ...ngDevMode ? [{ debugName: "viewMinute" }] : /* istanbul ignore next */ []);
65
+ this.viewSecond = signal(0, ...ngDevMode ? [{ debugName: "viewSecond" }] : /* istanbul ignore next */ []);
66
+ this.viewMeridiem = computed(() => this.viewHour() >= 12 ? "PM" : "AM", ...ngDevMode ? [{ debugName: "viewMeridiem" }] : /* istanbul ignore next */ []);
67
+ this.pendingDate = signal(null, ...ngDevMode ? [{ debugName: "pendingDate" }] : /* istanbul ignore next */ []);
68
+ this.rangeStart = signal(null, ...ngDevMode ? [{ debugName: "rangeStart" }] : /* istanbul ignore next */ []);
69
+ this.rangeEnd = signal(null, ...ngDevMode ? [{ debugName: "rangeEnd" }] : /* istanbul ignore next */ []);
70
+ this.hoverDate = signal(null, ...ngDevMode ? [{ debugName: "hoverDate" }] : /* istanbul ignore next */ []);
71
+ this.panelText = signal("", ...ngDevMode ? [{ debugName: "panelText" }] : /* istanbul ignore next */ []);
72
+ this.rangeStartText = signal("", ...ngDevMode ? [{ debugName: "rangeStartText" }] : /* istanbul ignore next */ []);
73
+ this.rangeEndText = signal("", ...ngDevMode ? [{ debugName: "rangeEndText" }] : /* istanbul ignore next */ []);
74
+ this.panelTextError = signal(null, ...ngDevMode ? [{ debugName: "panelTextError" }] : /* istanbul ignore next */ []);
75
+ this.isTyping = signal(false, ...ngDevMode ? [{ debugName: "isTyping" }] : /* istanbul ignore next */ []);
76
+ this.typedValue = signal("", ...ngDevMode ? [{ debugName: "typedValue" }] : /* istanbul ignore next */ []);
77
+ this.typingValid = signal(null, ...ngDevMode ? [{ debugName: "typingValid" }] : /* istanbul ignore next */ []);
78
+ this.value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
79
+ this._disabledState = signal(false, ...ngDevMode ? [{ debugName: "_disabledState" }] : /* istanbul ignore next */ []);
80
+ this.subscribed = signal(false, ...ngDevMode ? [{ debugName: "subscribed" }] : /* istanbul ignore next */ []);
81
+ this.valueSubscribed = signal(false, ...ngDevMode ? [{ debugName: "valueSubscribed" }] : /* istanbul ignore next */ []);
82
+ this.errorTracker = signal(0, ...ngDevMode ? [{ debugName: "errorTracker" }] : /* istanbul ignore next */ []);
83
+ this.hadError = signal(false, ...ngDevMode ? [{ debugName: "hadError" }] : /* istanbul ignore next */ []);
84
+ this.onChange = () => {};
85
+ this.onTouched = () => {};
86
+ this.isDisabled = computed(() => this.disabled() || this._disabledState(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
87
+ this.actualControl = computed(() => {
88
+ const ctrl = this.control();
89
+ if (ctrl) return ctrl;
90
+ const fg = this.formGroup();
91
+ if (!fg) return void 0;
92
+ const name = this.controlName() || this.label();
93
+ if (!name) return void 0;
94
+ return fg.get(name) ?? void 0;
95
+ }, ...ngDevMode ? [{ debugName: "actualControl" }] : /* istanbul ignore next */ []);
96
+ this.usesSignalForms = computed(() => !this.actualControl(), ...ngDevMode ? [{ debugName: "usesSignalForms" }] : /* istanbul ignore next */ []);
97
+ this.shouldShowError = computed(() => {
98
+ if (this.usesSignalForms()) return this.invalid() && (this.touched() || this.dirty());
99
+ this.errorTracker();
100
+ const ctrl = this.actualControl();
101
+ return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);
102
+ }, ...ngDevMode ? [{ debugName: "shouldShowError" }] : /* istanbul ignore next */ []);
103
+ this.wasFixedError = computed(() => {
104
+ if (this.usesSignalForms()) return this.hadError() && !this.invalid() && this.touched();
105
+ this.errorTracker();
106
+ const ctrl = this.actualControl();
107
+ return this.hadError() && ctrl?.valid && ctrl?.touched;
108
+ }, ...ngDevMode ? [{ debugName: "wasFixedError" }] : /* istanbul ignore next */ []);
109
+ this.getErrorMessages = computed(() => {
110
+ this.errorTracker();
111
+ const customError = this.errorMessage();
112
+ if (customError) return [customError];
113
+ const customErrors = this.errorMessages();
114
+ const translate = (key, params) => this.transloco.translate(key, params);
115
+ if (this.usesSignalForms()) return errorMessagesFromMap(signalErrorsToMap(this.errors()), customErrors, translate);
116
+ const ctrl = this.actualControl();
117
+ if (!ctrl?.errors) return [];
118
+ return errorMessagesFromMap(ctrl.errors, customErrors, translate);
119
+ }, ...ngDevMode ? [{ debugName: "getErrorMessages" }] : /* istanbul ignore next */ []);
120
+ this.texts = computed(() => this.effectiveLocale().startsWith("en") ? {
121
+ today: "Today",
122
+ now: "Now",
123
+ cancel: "Cancel",
124
+ apply: "Apply",
125
+ hour: "Hour",
126
+ minute: "Min",
127
+ second: "Sec",
128
+ week: "Week",
129
+ open: "Open calendar",
130
+ prevMonth: "Previous month",
131
+ nextMonth: "Next month",
132
+ prevYear: "Previous year",
133
+ nextYear: "Next year",
134
+ prevYears: "Previous years",
135
+ nextYears: "Next years"
136
+ } : {
137
+ today: "Hoy",
138
+ now: "Ahora",
139
+ cancel: "Cancelar",
140
+ apply: "Aplicar",
141
+ hour: "Hora",
142
+ minute: "Min",
143
+ second: "Seg",
144
+ week: "Semana",
145
+ open: "Abrir calendario",
146
+ prevMonth: "Mes anterior",
147
+ nextMonth: "Mes siguiente",
148
+ prevYear: "Año anterior",
149
+ nextYear: "Año siguiente",
150
+ prevYears: "Años anteriores",
151
+ nextYears: "Años siguientes"
152
+ }, ...ngDevMode ? [{ debugName: "texts" }] : /* istanbul ignore next */ []);
153
+ this.todayISO = signal(this.toISODate(/* @__PURE__ */ new Date()), ...ngDevMode ? [{ debugName: "todayISO" }] : /* istanbul ignore next */ []);
154
+ this.currentHour = signal((/* @__PURE__ */ new Date()).getHours(), ...ngDevMode ? [{ debugName: "currentHour" }] : /* istanbul ignore next */ []);
155
+ this.effectiveStep = computed(() => Math.max(1, Math.min(30, this.minuteStep() || 1)), ...ngDevMode ? [{ debugName: "effectiveStep" }] : /* istanbul ignore next */ []);
156
+ this.showTimeColumns = computed(() => this.timeOnly() || this.showTime() && !this.range(), ...ngDevMode ? [{ debugName: "showTimeColumns" }] : /* istanbul ignore next */ []);
157
+ this.outsideNavTimer = null;
158
+ this.lastWheelNav = 0;
159
+ this.firstDayOfWeek = computed(() => {
160
+ const ws = this.weekStart() ?? this.config.get("dates.weekStart")();
161
+ if (ws !== null && ws !== void 0) return (ws % 7 + 7) % 7;
162
+ return this.effectiveLocale().startsWith("en") ? 0 : 1;
163
+ }, ...ngDevMode ? [{ debugName: "firstDayOfWeek" }] : /* istanbul ignore next */ []);
164
+ this.displayedDate = computed(() => {
165
+ if (this.timeOnly() || this.range()) return null;
166
+ const pending = this.pendingDate();
167
+ if (pending) return pending;
168
+ const current = this._value();
169
+ return current ? this.datePartOf(current) : null;
170
+ }, ...ngDevMode ? [{ debugName: "displayedDate" }] : /* istanbul ignore next */ []);
171
+ this.displayLabel = computed(() => {
172
+ const value = this._value();
173
+ if (!value) return "";
174
+ if (this.timeOnly()) return this.formatTimeFromValue(value);
175
+ if (this.range()) {
176
+ const [start, end] = value.split("|");
177
+ return `${this.formatMedium(start)} – ${this.formatMedium(end)}`;
178
+ }
179
+ const datePart = this.datePartOf(value);
180
+ const timePart = value.includes("T") ? value.split("T")[1] : null;
181
+ const v = this.view();
182
+ let label;
183
+ if (v === "year") label = datePart;
184
+ else if (v === "month") {
185
+ const [y, m] = datePart.split("-").map(Number);
186
+ label = this.capitalize(new Intl.DateTimeFormat(this.effectiveLocale(), {
187
+ month: "long",
188
+ year: "numeric"
189
+ }).format(new Date(y, m - 1, 1)));
190
+ } else if (v === "week") {
191
+ const start = this.parseISO(datePart);
192
+ label = this.formatWeekRange(start, this.addDays(start, 6));
193
+ } else label = this.formatDisplay(datePart);
194
+ if (this.showTime() && timePart) label += " " + this.formatTimeFromValue(timePart);
195
+ return label;
196
+ }, ...ngDevMode ? [{ debugName: "displayLabel" }] : /* istanbul ignore next */ []);
197
+ this.monthNames = computed(() => {
198
+ const fmt = new Intl.DateTimeFormat(this.effectiveLocale(), { month: "short" });
199
+ return Array.from({ length: 12 }, (_, i) => this.capitalize(fmt.format(new Date(2e3, i, 1)).replace(".", "")));
200
+ }, ...ngDevMode ? [{ debugName: "monthNames" }] : /* istanbul ignore next */ []);
201
+ this.monthLongNames = computed(() => {
202
+ const fmt = new Intl.DateTimeFormat(this.effectiveLocale(), { month: "long" });
203
+ return Array.from({ length: 12 }, (_, i) => this.capitalize(fmt.format(new Date(2e3, i, 1))));
204
+ }, ...ngDevMode ? [{ debugName: "monthLongNames" }] : /* istanbul ignore next */ []);
205
+ this.dayNames = computed(() => {
206
+ const fmt = new Intl.DateTimeFormat(this.effectiveLocale(), { weekday: "short" });
207
+ const first = this.firstDayOfWeek();
208
+ return Array.from({ length: 7 }, (_, i) => {
209
+ const name = fmt.format(new Date(2024, 0, 7 + (first + i) % 7)).replace(".", "");
210
+ return this.capitalize(name.slice(0, 2));
211
+ });
212
+ }, ...ngDevMode ? [{ debugName: "dayNames" }] : /* istanbul ignore next */ []);
213
+ this.visibleMonths = computed(() => {
214
+ const y = this.viewYear();
215
+ const m = this.viewMonth();
216
+ const months = [this.buildMonth(y, m)];
217
+ if (this.range()) {
218
+ const next = new Date(y, m + 1, 1);
219
+ months.push(this.buildMonth(next.getFullYear(), next.getMonth()));
220
+ }
221
+ return months;
222
+ }, ...ngDevMode ? [{ debugName: "visibleMonths" }] : /* istanbul ignore next */ []);
223
+ this.markedSet = computed(() => new Set(this.markedDates()), ...ngDevMode ? [{ debugName: "markedSet" }] : /* istanbul ignore next */ []);
224
+ this.monthWeeks = computed(() => {
225
+ const year = this.viewYear();
226
+ const month = this.viewMonth();
227
+ const first = new Date(year, month, 1);
228
+ const last = new Date(year, month + 1, 0);
229
+ let cursor = this.startOfWeek(first);
230
+ const weeks = [];
231
+ let index = 0;
232
+ while (cursor.getTime() <= last.getTime()) {
233
+ index++;
234
+ const start = cursor;
235
+ const end = this.addDays(start, 6);
236
+ weeks.push({
237
+ index,
238
+ start,
239
+ end,
240
+ range: this.formatWeekRange(start, end)
241
+ });
242
+ cursor = this.addDays(start, 7);
243
+ }
244
+ return weeks;
245
+ }, ...ngDevMode ? [{ debugName: "monthWeeks" }] : /* istanbul ignore next */ []);
246
+ this.decadeYears = computed(() => {
247
+ const start = this.viewDecade();
248
+ return Array.from({ length: 12 }, (_, i) => start + i);
249
+ }, ...ngDevMode ? [{ debugName: "decadeYears" }] : /* istanbul ignore next */ []);
250
+ this.headerTitle = computed(() => {
251
+ const v = this.currentView();
252
+ if (v === "year") return `${this.viewDecade()} – ${this.viewDecade() + 11}`;
253
+ if (v === "month") return String(this.viewYear());
254
+ return `${this.monthLongNames()[this.viewMonth()]} ${this.viewYear()}`;
255
+ }, ...ngDevMode ? [{ debugName: "headerTitle" }] : /* istanbul ignore next */ []);
256
+ this.canGoPrev = computed(() => {
257
+ const min = this.minValue();
258
+ if (!min) return true;
259
+ const minY = Number(min.slice(0, 4));
260
+ const v = this.currentView();
261
+ if (v === "date" || v === "week") return this.toISODate(new Date(this.viewYear(), this.viewMonth(), 0)).slice(0, min.length) >= min.slice(0, 10);
262
+ if (v === "month") return this.viewYear() > minY;
263
+ return this.viewDecade() > minY;
264
+ }, ...ngDevMode ? [{ debugName: "canGoPrev" }] : /* istanbul ignore next */ []);
265
+ this.canGoNext = computed(() => {
266
+ const max = this.maxValue();
267
+ if (!max) return true;
268
+ const maxY = Number(max.slice(0, 4));
269
+ const v = this.currentView();
270
+ if (v === "date" || v === "week") {
271
+ const extra = this.range() ? 2 : 1;
272
+ return this.toISODate(new Date(this.viewYear(), this.viewMonth() + extra, 1)).slice(0, max.length) <= max.slice(0, 10);
273
+ }
274
+ if (v === "month") return this.viewYear() < maxY;
275
+ return this.viewDecade() + 11 < maxY;
276
+ }, ...ngDevMode ? [{ debugName: "canGoNext" }] : /* istanbul ignore next */ []);
277
+ this.showFooter = computed(() => this.timeOnly() || this.range() || this.view() === "date" || this.showTime(), ...ngDevMode ? [{ debugName: "showFooter" }] : /* istanbul ignore next */ []);
278
+ this.canApply = computed(() => {
279
+ if (this.timeOnly()) return true;
280
+ if (this.range()) return !!this.rangeStart();
281
+ return !!this.pendingDate();
282
+ }, ...ngDevMode ? [{ debugName: "canApply" }] : /* istanbul ignore next */ []);
283
+ this.inputFormat = computed(() => {
284
+ const { order, separator } = this.typedLayout();
285
+ const names = {
286
+ d: "DD",
287
+ m: "MM",
288
+ y: "YYYY"
289
+ };
290
+ return order.map((field) => names[field]).join(separator);
291
+ }, ...ngDevMode ? [{ debugName: "inputFormat" }] : /* istanbul ignore next */ []);
292
+ this.touch = output();
293
+ this.canZoomOut = computed(() => this.currentView() !== "year", ...ngDevMode ? [{ debugName: "canZoomOut" }] : /* istanbul ignore next */ []);
294
+ this.effectiveEnd = computed(() => {
295
+ const start = this.rangeStart();
296
+ const end = this.rangeEnd();
297
+ if (end) return end;
298
+ const hover = this.hoverDate();
299
+ return start && hover && hover > start ? hover : null;
300
+ }, ...ngDevMode ? [{ debugName: "effectiveEnd" }] : /* istanbul ignore next */ []);
301
+ this.hourOptions = computed(() => {
302
+ if (this.effectiveHourFormat() === "12") {
303
+ const pm = this.viewMeridiem() === "PM" ? 12 : 0;
304
+ return [
305
+ 12,
306
+ 1,
307
+ 2,
308
+ 3,
309
+ 4,
310
+ 5,
311
+ 6,
312
+ 7,
313
+ 8,
314
+ 9,
315
+ 10,
316
+ 11
317
+ ].map((h) => ({
318
+ value: h % 12 + pm,
319
+ label: this.pad2(h)
320
+ }));
321
+ }
322
+ return Array.from({ length: 24 }, (_, h) => ({
323
+ value: h,
324
+ label: this.pad2(h)
325
+ }));
326
+ }, ...ngDevMode ? [{ debugName: "hourOptions" }] : /* istanbul ignore next */ []);
327
+ this.minuteOptions = computed(() => {
328
+ const step = this.effectiveStep();
329
+ return Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step);
330
+ }, ...ngDevMode ? [{ debugName: "minuteOptions" }] : /* istanbul ignore next */ []);
331
+ this.secondOptions = Array.from({ length: 60 }, (_, i) => i);
332
+ this.timeText = computed(() => this.formatTime(this.viewHour(), this.viewMinute(), this.viewSecond()), ...ngDevMode ? [{ debugName: "timeText" }] : /* istanbul ignore next */ []);
333
+ this.timeTextError = signal(false, ...ngDevMode ? [{ debugName: "timeTextError" }] : /* istanbul ignore next */ []);
334
+ effect(() => {
335
+ if (!this.usesSignalForms()) return;
336
+ if (this.invalid() && (this.touched() || this.dirty())) this.hadError.set(true);
337
+ });
338
+ const doc = this.elementRef.nativeElement.ownerDocument;
339
+ const onScroll = () => this.onViewportChange();
340
+ doc.addEventListener("scroll", onScroll, true);
341
+ this.destroyRef.onDestroy(() => {
342
+ doc.removeEventListener("scroll", onScroll, true);
343
+ this.cancelOutsideNav();
344
+ });
345
+ effect(() => {
346
+ this.currentView();
347
+ if (untracked(() => this.isOpen())) this.schedulePosition();
348
+ });
349
+ effect(() => {
350
+ const pending = this.pendingDate();
351
+ const start = this.rangeStart();
352
+ const end = this.rangeEnd();
353
+ untracked(() => {
354
+ this.panelText.set(pending ? this.formatTyped(pending) : "");
355
+ this.rangeStartText.set(start ? this.formatTyped(start) : "");
356
+ this.rangeEndText.set(end ? this.formatTyped(end) : "");
357
+ this.panelTextError.set(null);
358
+ });
359
+ });
360
+ effect(() => {
361
+ const ctrl = this.actualControl();
362
+ if (!ctrl) {
363
+ this.subscribed.set(false);
364
+ return;
365
+ }
366
+ if (this.subscribed()) return;
367
+ if (ctrl.invalid && ctrl.touched) this.hadError.set(true);
368
+ ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
369
+ this.errorTracker.update((v) => v + 1);
370
+ if (ctrl.invalid && ctrl.touched) this.hadError.set(true);
371
+ });
372
+ this.subscribed.set(true);
373
+ });
374
+ effect(() => {
375
+ const ctrl = this.actualControl();
376
+ if (!ctrl || this.valueSubscribed()) return;
377
+ this.writeValue(ctrl.value);
378
+ ctrl.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => this.writeValue(value));
379
+ this.valueSubscribed.set(true);
380
+ });
381
+ }
382
+ onDocumentClick(event) {
383
+ if (!this.isOpen()) return;
384
+ const target = event.target;
385
+ const overlay = this.overlay()?.nativeElement;
386
+ if (!this.elementRef.nativeElement.contains(target) && !overlay?.contains(target)) this.close();
387
+ }
388
+ onViewportChange() {
389
+ if (this.isOpen()) this.positionPanel();
390
+ }
391
+ onEscape() {
392
+ this.close();
393
+ }
394
+ schedulePosition() {
395
+ afterNextRender(() => this.positionPanel(), { injector: this.injector });
396
+ }
397
+ positionPanel() {
398
+ const anchor = this.anchor()?.nativeElement;
399
+ const panel = this.panel()?.nativeElement;
400
+ if (!anchor || !panel) return;
401
+ const margin = 8;
402
+ const gap = 4;
403
+ const rect = anchor.getBoundingClientRect();
404
+ const height = panel.offsetHeight;
405
+ const width = panel.offsetWidth;
406
+ let top = rect.bottom + gap;
407
+ if (top + height > window.innerHeight - margin && rect.top - gap - height >= margin) top = rect.top - gap - height;
408
+ top = Math.max(margin, Math.min(top, window.innerHeight - height - margin));
409
+ const left = Math.max(margin, Math.min(rect.left, window.innerWidth - width - margin));
410
+ this.panelPosition.set({
411
+ top,
412
+ left
413
+ });
414
+ }
415
+ toggle() {
416
+ if (this.isDisabled()) return;
417
+ if (this.isOpen()) {
418
+ this.close();
419
+ return;
420
+ }
421
+ const now = /* @__PURE__ */ new Date();
422
+ this.todayISO.set(this.toISODate(now));
423
+ this.currentHour.set(now.getHours());
424
+ this.syncViewToValue();
425
+ this.currentView.set(this.view());
426
+ this.isTyping.set(false);
427
+ this.panelPosition.set(null);
428
+ this.isOpen.set(true);
429
+ this.timeTextError.set(false);
430
+ this.schedulePosition();
431
+ if (this.showTimeColumns()) this.scheduleTimeScroll();
432
+ }
433
+ close() {
434
+ if (!this.isOpen()) return;
435
+ this.touch.emit();
436
+ this.cancelOutsideNav();
437
+ this.isOpen.set(false);
438
+ this.hoverDate.set(null);
439
+ this.onTouched();
440
+ const ctrl = this.actualControl();
441
+ if (ctrl) ctrl.markAsTouched();
442
+ this.errorTracker.update((v) => v + 1);
443
+ if (ctrl?.invalid && ctrl?.touched) this.hadError.set(true);
444
+ }
445
+ syncViewToValue() {
446
+ const val = this._value();
447
+ const now = /* @__PURE__ */ new Date();
448
+ this.pendingDate.set(null);
449
+ this.rangeStart.set(null);
450
+ this.rangeEnd.set(null);
451
+ this.hoverDate.set(null);
452
+ if (!val) {
453
+ this.goToDate(now);
454
+ this.setNowTime(now);
455
+ return;
456
+ }
457
+ if (this.range()) {
458
+ const [start, end] = val.split("|");
459
+ this.rangeStart.set(start);
460
+ this.rangeEnd.set(end);
461
+ this.goToDate(this.parseISO(start));
462
+ return;
463
+ }
464
+ if (this.timeOnly()) {
465
+ this.setClockFrom(val);
466
+ return;
467
+ }
468
+ const datePart = this.datePartOf(val);
469
+ const v = this.view();
470
+ if (v === "year") {
471
+ this.viewYear.set(Number(datePart));
472
+ this.viewDecade.set(this.decadeOf(Number(datePart)));
473
+ } else if (v === "month") {
474
+ this.viewYear.set(Number(datePart.slice(0, 4)));
475
+ this.viewMonth.set(Number(datePart.slice(5, 7)) - 1);
476
+ } else this.goToDate(this.parseISO(datePart));
477
+ if (val.includes("T")) this.setClockFrom(val.split("T")[1]);
478
+ this.pendingDate.set(datePart);
479
+ }
480
+ prev() {
481
+ this.shift(-1);
482
+ }
483
+ next() {
484
+ this.shift(1);
485
+ }
486
+ shift(dir) {
487
+ const v = this.currentView();
488
+ if (v === "year") this.viewDecade.update((d) => d + 12 * dir);
489
+ else if (v === "month") this.viewYear.update((y) => y + dir);
490
+ else this.goToDate(new Date(this.viewYear(), this.viewMonth() + dir, 1));
491
+ }
492
+ zoomOut() {
493
+ const v = this.currentView();
494
+ if (v === "date" || v === "week") this.currentView.set("month");
495
+ else if (v === "month") {
496
+ this.viewDecade.set(this.decadeOf(this.viewYear()));
497
+ this.currentView.set("year");
498
+ }
499
+ }
500
+ onWheel(event) {
501
+ if (Math.abs(event.deltaY) < 20) return;
502
+ event.preventDefault();
503
+ const now = Date.now();
504
+ if (now - this.lastWheelNav < DatePickerComponent.WHEEL_THROTTLE_MS) return;
505
+ this.lastWheelNav = now;
506
+ if (event.deltaY > 0 ? this.canGoNext() : this.canGoPrev()) this.shift(event.deltaY > 0 ? 1 : -1);
507
+ }
508
+ onPanelKeydown(event) {
509
+ if (event.key === "PageUp" && this.canGoPrev()) {
510
+ event.preventDefault();
511
+ this.prev();
512
+ } else if (event.key === "PageDown" && this.canGoNext()) {
513
+ event.preventDefault();
514
+ this.next();
515
+ }
516
+ }
517
+ goToday() {
518
+ const today = /* @__PURE__ */ new Date();
519
+ this.currentView.set(this.view() === "week" ? "week" : "date");
520
+ this.goToDate(today);
521
+ if (!this.range() && !this.isDisabledDate(this.toISODate(today))) this.pendingDate.set(this.toISODate(today));
522
+ }
523
+ selectDay(cell) {
524
+ if (this.isDisabledDate(cell.iso)) return;
525
+ if (this.range()) {
526
+ const start = this.rangeStart();
527
+ const end = this.rangeEnd();
528
+ if (!start || end || cell.iso < start) {
529
+ this.rangeStart.set(cell.iso);
530
+ this.rangeEnd.set(null);
531
+ } else {
532
+ this.rangeEnd.set(cell.iso);
533
+ this.hoverDate.set(null);
534
+ }
535
+ return;
536
+ }
537
+ this.pendingDate.set(cell.iso);
538
+ this.cancelOutsideNav();
539
+ if (!cell.inMonth) this.outsideNavTimer = setTimeout(() => {
540
+ this.outsideNavTimer = null;
541
+ this.goToDate(this.parseISO(cell.iso));
542
+ this.cdr.markForCheck();
543
+ }, DatePickerComponent.DBLCLICK_DELAY_MS);
544
+ }
545
+ cancelOutsideNav() {
546
+ if (this.outsideNavTimer !== null) {
547
+ clearTimeout(this.outsideNavTimer);
548
+ this.outsideNavTimer = null;
549
+ }
550
+ }
551
+ quickApply(cell) {
552
+ if (this.range() || this.showTime() || this.isDisabledDate(cell.iso)) return;
553
+ this.cancelOutsideNav();
554
+ this.pendingDate.set(cell.iso);
555
+ this.apply();
556
+ }
557
+ onDayHover(cell) {
558
+ if (!this.range() || !this.rangeStart() || this.rangeEnd()) return;
559
+ this.hoverDate.set(cell?.iso ?? null);
560
+ }
561
+ selectMonth(monthIndex) {
562
+ this.viewMonth.set(monthIndex);
563
+ if (this.view() === "month") {
564
+ this.setValue(`${this.viewYear()}-${String(monthIndex + 1).padStart(2, "0")}`);
565
+ return;
566
+ }
567
+ this.currentView.set(this.view() === "week" ? "week" : "date");
568
+ }
569
+ selectYear(year) {
570
+ this.viewYear.set(year);
571
+ if (this.view() === "year") {
572
+ this.setValue(String(year));
573
+ return;
574
+ }
575
+ this.currentView.set("month");
576
+ }
577
+ selectWeek(start) {
578
+ const value = this.toISODate(start);
579
+ if (this.showTime()) {
580
+ this.pendingDate.set(value);
581
+ return;
582
+ }
583
+ this.setValue(value);
584
+ }
585
+ apply() {
586
+ if (!this.canApply()) return;
587
+ const time = this.buildTime(this.viewHour(), this.viewMinute(), this.viewSecond());
588
+ if (this.timeOnly()) {
589
+ this.setValue(time);
590
+ return;
591
+ }
592
+ if (this.range()) {
593
+ const start = this.rangeStart();
594
+ this.setValue(`${start}|${this.rangeEnd() ?? start}`);
595
+ return;
596
+ }
597
+ const date = this.pendingDate();
598
+ this.setValue(this.showTime() ? `${date}T${time}` : date);
599
+ }
600
+ clear() {
601
+ this._value.set(null);
602
+ this.onChange(null);
603
+ const ctrl = this.actualControl();
604
+ if (ctrl) {
605
+ ctrl.setValue(null);
606
+ ctrl.markAsDirty();
607
+ }
608
+ }
609
+ setValue(value, close = true) {
610
+ this._value.set(value);
611
+ const output = this.toOutputValue(value);
612
+ this.onChange(output);
613
+ const ctrl = this.actualControl();
614
+ if (ctrl) {
615
+ ctrl.setValue(output);
616
+ ctrl.markAsDirty();
617
+ }
618
+ if (close) this.close();
619
+ }
620
+ commitPanelText(which, event) {
621
+ const text = event.target.value.trim();
622
+ const current = which === "single" ? this.pendingDate() : which === "start" ? this.rangeStart() : this.rangeEnd();
623
+ if (!text) {
624
+ this.panelTextError.set(null);
625
+ return;
626
+ }
627
+ const iso = this.parseDateText(text);
628
+ if (!iso || this.isDisabledDate(iso)) {
629
+ this.panelTextError.set(which);
630
+ return;
631
+ }
632
+ this.panelTextError.set(null);
633
+ if (iso === current) return;
634
+ if (which === "single") this.pendingDate.set(iso);
635
+ else if (which === "start") {
636
+ this.rangeStart.set(iso);
637
+ if (this.rangeEnd() && this.rangeEnd() < iso) this.rangeEnd.set(null);
638
+ } else if (!this.rangeStart() || iso < this.rangeStart()) {
639
+ this.rangeStart.set(iso);
640
+ this.rangeEnd.set(null);
641
+ } else this.rangeEnd.set(iso);
642
+ this.currentView.set("date");
643
+ this.goToDate(this.parseISO(iso));
644
+ }
645
+ isSelectedDate(iso) {
646
+ if (this.range()) return iso === this.rangeStart() || iso === this.rangeEnd();
647
+ return this.displayedDate() === iso;
648
+ }
649
+ isInRange(iso) {
650
+ const start = this.rangeStart();
651
+ const end = this.effectiveEnd();
652
+ return !!start && !!end && iso > start && iso < end;
653
+ }
654
+ isRangeStart(iso) {
655
+ return !!this.effectiveEnd() && iso === this.rangeStart();
656
+ }
657
+ isRangeEnd(iso) {
658
+ return !!this.rangeStart() && iso === this.effectiveEnd();
659
+ }
660
+ isTodayDate(iso) {
661
+ return iso === this.todayISO();
662
+ }
663
+ isMarked(iso) {
664
+ return this.markedSet().has(iso);
665
+ }
666
+ isDisabledDate(iso) {
667
+ const min = this.minValue();
668
+ const max = this.maxValue();
669
+ if (min && iso.slice(0, min.length) < min.slice(0, 10)) return true;
670
+ if (max && iso.slice(0, max.length) > max.slice(0, 10)) return true;
671
+ return false;
672
+ }
673
+ isSelectedMonth(monthIndex) {
674
+ const d = this.displayedDate() ?? this.rangeStart();
675
+ if (!d || d.length < 7) return false;
676
+ return Number(d.slice(0, 4)) === this.viewYear() && Number(d.slice(5, 7)) - 1 === monthIndex;
677
+ }
678
+ isCurrentMonth(monthIndex) {
679
+ const now = /* @__PURE__ */ new Date();
680
+ return this.viewYear() === now.getFullYear() && monthIndex === now.getMonth();
681
+ }
682
+ isSelectedYear(year) {
683
+ const d = this.displayedDate() ?? this.rangeStart();
684
+ return !!d && Number(d.slice(0, 4)) === year;
685
+ }
686
+ isCurrentYear(year) {
687
+ return (/* @__PURE__ */ new Date()).getFullYear() === year;
688
+ }
689
+ isSelectedWeek(start) {
690
+ const date = this.displayedDate();
691
+ if (!date) return false;
692
+ return this.toISODate(this.startOfWeek(this.parseISO(date))) === this.toISODate(start);
693
+ }
694
+ isCurrentWeek(start) {
695
+ return this.toISODate(this.startOfWeek(/* @__PURE__ */ new Date())) === this.toISODate(start);
696
+ }
697
+ weekLabel(index) {
698
+ return `${this.texts().week} ${index}`;
699
+ }
700
+ formatWeekRange(start, end) {
701
+ const loc = this.effectiveLocale();
702
+ const dayFmt = new Intl.DateTimeFormat(loc, { day: "numeric" });
703
+ const monthFmt = new Intl.DateTimeFormat(loc, { month: "short" });
704
+ const startLabel = `${dayFmt.format(start)} ${monthFmt.format(start).replace(".", "")}`;
705
+ if (start.getMonth() !== end.getMonth() || start.getFullYear() !== end.getFullYear()) {
706
+ const year = start.getFullYear() !== end.getFullYear() ? ` ${end.getFullYear()}` : "";
707
+ return `${startLabel} — ${dayFmt.format(end)} ${monthFmt.format(end).replace(".", "")}${year}`;
708
+ }
709
+ return `${startLabel} — ${dayFmt.format(end)}`;
710
+ }
711
+ isCurrentHour(hour) {
712
+ return this.currentHour() === hour;
713
+ }
714
+ selectHour(hour) {
715
+ this.viewHour.set(hour);
716
+ }
717
+ selectMinute(minute) {
718
+ this.viewMinute.set(minute);
719
+ }
720
+ selectSecond(second) {
721
+ this.viewSecond.set(second);
722
+ }
723
+ setMeridiem(meridiem) {
724
+ const h = this.viewHour();
725
+ if (meridiem === "PM" && h < 12) this.viewHour.set(h + 12);
726
+ else if (meridiem === "AM" && h >= 12) this.viewHour.set(h - 12);
727
+ }
728
+ setNow() {
729
+ this.setNowTime(/* @__PURE__ */ new Date());
730
+ this.timeTextError.set(false);
731
+ this.scheduleTimeScroll();
732
+ }
733
+ setNowTime(date) {
734
+ const step = this.effectiveStep();
735
+ let minute = Math.round(date.getMinutes() / step) * step;
736
+ let hour = date.getHours();
737
+ if (minute >= 60) {
738
+ minute = 0;
739
+ hour = (hour + 1) % 24;
740
+ }
741
+ this.viewHour.set(hour);
742
+ this.viewMinute.set(minute);
743
+ this.viewSecond.set(this.showSeconds() && step === 1 ? date.getSeconds() : 0);
744
+ }
745
+ commitTimeText(event) {
746
+ const input = event.target;
747
+ const text = input.value.trim();
748
+ if (!text || text === this.timeText()) {
749
+ this.timeTextError.set(false);
750
+ input.value = this.timeText();
751
+ return;
752
+ }
753
+ const time = this.parseTimeOnly(text);
754
+ if (!time) {
755
+ this.timeTextError.set(true);
756
+ return;
757
+ }
758
+ this.timeTextError.set(false);
759
+ this.setClockFrom(time);
760
+ input.value = this.timeText();
761
+ this.scheduleTimeScroll();
762
+ }
763
+ scheduleTimeScroll() {
764
+ afterNextRender(() => {
765
+ (this.panel()?.nativeElement)?.querySelectorAll(".dp-time-col").forEach((col) => {
766
+ const sel = col.querySelector(".is-selected");
767
+ if (sel) col.scrollTop = sel.offsetTop - col.clientHeight / 2 + sel.offsetHeight / 2;
768
+ });
769
+ }, { injector: this.injector });
770
+ }
771
+ pad2(value) {
772
+ return String(value).padStart(2, "0");
773
+ }
774
+ inputPlaceholder() {
775
+ if (this.placeholder()) return this.placeholder();
776
+ if (this.timeOnly()) return this.effectiveHourFormat() === "12" ? "hh:mm AM" : "HH:mm";
777
+ if (this.range()) return `${this.inputFormat()} – ${this.inputFormat()}`;
778
+ if (this.view() === "year") return "YYYY";
779
+ if (this.view() === "month") return "MM/YYYY";
780
+ if (this.view() === "week") return `${this.texts().week} · MM/YYYY`;
781
+ return this.inputFormat();
782
+ }
783
+ onInputText(event) {
784
+ this.typedValue.set(event.target.value);
785
+ this.typingValid.set(null);
786
+ }
787
+ onInputFocus() {
788
+ this.isTyping.set(true);
789
+ this.typedValue.set(this.typedFormOfValue());
790
+ this.typingValid.set(null);
791
+ }
792
+ onInputBlur() {
793
+ this.onTouched();
794
+ this.touch.emit();
795
+ this.errorTracker.update((v) => v + 1);
796
+ const text = this.typedValue().trim();
797
+ this.isTyping.set(false);
798
+ if (!text || text === this.typedFormOfValue()) return;
799
+ const parsed = this.parseTypedValue(text);
800
+ if (parsed) {
801
+ this.setValue(parsed, false);
802
+ this.typingValid.set(true);
803
+ if (this.isOpen()) this.syncViewToValue();
804
+ } else {
805
+ this.typingValid.set(false);
806
+ setTimeout(() => this.typingValid.set(null), 1500);
807
+ }
808
+ }
809
+ cancelTyping() {
810
+ this.isTyping.set(false);
811
+ this.typedValue.set("");
812
+ this.typingValid.set(null);
813
+ }
814
+ typedFormOfValue() {
815
+ const val = this._value();
816
+ if (!val) return "";
817
+ if (this.timeOnly()) return this.formatTimeFromValue(val);
818
+ if (this.range()) {
819
+ const [s, e] = val.split("|");
820
+ return `${this.formatTyped(s)} - ${this.formatTyped(e)}`;
821
+ }
822
+ const v = this.view();
823
+ if (v === "year") return val;
824
+ if (v === "month") return `${val.slice(5, 7)}/${val.slice(0, 4)}`;
825
+ let text = this.formatTyped(this.datePartOf(val));
826
+ if (val.includes("T")) text += " " + this.formatTimeFromValue(val.split("T")[1]);
827
+ return text;
828
+ }
829
+ parseTypedValue(text) {
830
+ if (this.timeOnly()) return this.parseTimeOnly(text);
831
+ if (this.range()) {
832
+ const parts = text.split(/\s+[-–]\s+|\s*–\s*/).filter(Boolean);
833
+ if (parts.length !== 2) return null;
834
+ const a = this.parseDateText(parts[0]);
835
+ const b = this.parseDateText(parts[1]);
836
+ if (!a || !b) return null;
837
+ return a <= b ? `${a}|${b}` : `${b}|${a}`;
838
+ }
839
+ const v = this.view();
840
+ if (v === "week") return null;
841
+ if (v === "year") {
842
+ const y = Number(text);
843
+ return /^\d{4}$/.test(text) && y >= 1900 && y <= 2100 ? String(y) : null;
844
+ }
845
+ if (v === "month") {
846
+ const parts = text.split(/[\/\-.\s]+/).filter(Boolean);
847
+ if (parts.length !== 2) return null;
848
+ const [a, b] = parts.map(Number);
849
+ const [m, y] = parts[0].length === 4 ? [b, a] : [a, b];
850
+ return m >= 1 && m <= 12 && y >= 1900 && y <= 2100 ? `${y}-${this.pad2(m)}` : null;
851
+ }
852
+ const [datePart, ...timeParts] = text.split(/\s+/);
853
+ const iso = this.parseDateText(datePart);
854
+ if (!iso) return null;
855
+ if (!this.showTime()) return iso;
856
+ return `${iso}T${(timeParts.length ? this.parseTimeOnly(timeParts.join(" ")) : null) ?? this.buildTime(this.viewHour(), this.viewMinute(), this.viewSecond())}`;
857
+ }
858
+ parseDateText(text) {
859
+ const parts = text.trim().split(/[\/\-.\s]+/).filter(Boolean);
860
+ if (parts.length !== 3) return null;
861
+ const nums = parts.map(Number);
862
+ const order = parts[0].length === 4 ? [
863
+ "y",
864
+ "m",
865
+ "d"
866
+ ] : this.typedLayout().order;
867
+ const field = (f) => nums[order.indexOf(f)];
868
+ const d = field("d");
869
+ const m = field("m");
870
+ let y = field("y");
871
+ if (y < 100) y += 2e3;
872
+ if (!(y >= 1900 && y <= 2100 && m >= 1 && m <= 12 && d >= 1 && d <= 31)) return null;
873
+ const date = new Date(y, m - 1, d);
874
+ if (date.getMonth() !== m - 1 || date.getDate() !== d) return null;
875
+ return this.toISODate(date);
876
+ }
877
+ parseTimeOnly(text) {
878
+ const match = /^(\d{1,2})[:.](\d{2})(?:[:.](\d{2}))?\s*(am|pm)?$/i.exec(text.trim());
879
+ if (!match) return null;
880
+ let h = Number(match[1]);
881
+ const m = Number(match[2]);
882
+ const s = Number(match[3] ?? 0);
883
+ const suffix = match[4]?.toLowerCase();
884
+ if (suffix === "pm" && h < 12) h += 12;
885
+ if (suffix === "am" && h === 12) h = 0;
886
+ if (h > 23 || m > 59 || s > 59) return null;
887
+ return this.buildTime(h, m, s);
888
+ }
889
+ buildMonth(year, month) {
890
+ const first = new Date(year, month, 1);
891
+ const start = this.startOfWeek(first);
892
+ const cells = [];
893
+ for (let i = 0; i < 42; i++) {
894
+ const d = this.addDays(start, i);
895
+ cells.push({
896
+ iso: this.toISODate(d),
897
+ day: d.getDate(),
898
+ inMonth: d.getMonth() === month
899
+ });
900
+ }
901
+ return {
902
+ year,
903
+ month,
904
+ cells
905
+ };
906
+ }
907
+ startOfWeek(date) {
908
+ const offset = (date.getDay() - this.firstDayOfWeek() + 7) % 7;
909
+ return this.addDays(date, -offset);
910
+ }
911
+ addDays(date, days) {
912
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
913
+ }
914
+ goToDate(date) {
915
+ this.viewYear.set(date.getFullYear());
916
+ this.viewMonth.set(date.getMonth());
917
+ this.viewDecade.set(this.decadeOf(date.getFullYear()));
918
+ }
919
+ decadeOf(year) {
920
+ return Math.floor(year / 12) * 12;
921
+ }
922
+ setClockFrom(time) {
923
+ const [h, m, s] = time.split(":").map(Number);
924
+ this.viewHour.set(h || 0);
925
+ this.viewMinute.set(m || 0);
926
+ this.viewSecond.set(s || 0);
927
+ }
928
+ parseISO(iso) {
929
+ return /* @__PURE__ */ new Date(iso.slice(0, 10) + "T12:00:00");
930
+ }
931
+ datePartOf(value) {
932
+ const i = value.indexOf("T");
933
+ return i >= 0 ? value.slice(0, i) : value;
934
+ }
935
+ toISODate(date) {
936
+ return `${date.getFullYear()}-${this.pad2(date.getMonth() + 1)}-${this.pad2(date.getDate())}`;
937
+ }
938
+ formatTyped(iso) {
939
+ const [y, m, d] = iso.split("-");
940
+ const parts = {
941
+ d,
942
+ m,
943
+ y
944
+ };
945
+ const { order, separator } = this.typedLayout();
946
+ return order.map((field) => parts[field]).join(separator);
947
+ }
948
+ formatMedium(iso) {
949
+ return this.effectiveDisplayStyle() === "format" ? formatDate(iso, this.effectiveDateFormat(), this.effectiveLocale()) : formatDateStyle(iso, "medium", this.effectiveLocale());
950
+ }
951
+ formatDisplay(iso) {
952
+ const style = this.effectiveDisplayStyle();
953
+ return style === "format" ? formatDate(iso, this.effectiveDateFormat(), this.effectiveLocale()) : formatDateStyle(iso, style, this.effectiveLocale());
954
+ }
955
+ capitalize(text) {
956
+ return text.charAt(0).toUpperCase() + text.slice(1);
957
+ }
958
+ formatTimeFromValue(time) {
959
+ const [h, m, s] = time.split(":").map(Number);
960
+ return this.formatTime(h || 0, m || 0, s || 0);
961
+ }
962
+ formatTime(h, m, s) {
963
+ const secs = this.showSeconds() ? `:${this.pad2(s)}` : "";
964
+ if (this.effectiveHourFormat() === "12") return `${this.pad2(h % 12 || 12)}:${this.pad2(m)}${secs} ${h < 12 ? "AM" : "PM"}`;
965
+ return `${this.pad2(h)}:${this.pad2(m)}${secs}`;
966
+ }
967
+ buildTime(h, m, s) {
968
+ let time = `${this.pad2(h)}:${this.pad2(m)}`;
969
+ if (this.showSeconds()) time += `:${this.pad2(s)}`;
970
+ return time;
971
+ }
972
+ writeValue(value) {
973
+ this._value.set(this.range() ? this.normalizeRange(value) : this.normalizeValue(value));
974
+ }
975
+ normalizeRange(value) {
976
+ if (value === null || value === void 0 || value === "") return null;
977
+ let start;
978
+ let end;
979
+ if (Array.isArray(value)) [start, end] = value;
980
+ else if (typeof value === "object") ({start, end} = value);
981
+ else return this.invalidValue(value);
982
+ const s = this.normalizeValue(start);
983
+ const e = this.normalizeValue(end ?? start);
984
+ if (!s) return null;
985
+ const a = this.datePartOf(s);
986
+ const b = e ? this.datePartOf(e) : a;
987
+ return a <= b ? `${a}|${b}` : `${b}|${a}`;
988
+ }
989
+ normalizeValue(value) {
990
+ if (value === null || value === void 0 || value === "") return null;
991
+ if (value instanceof Date || typeof value === "number") {
992
+ const d = new Date(value);
993
+ return isNaN(d.getTime()) ? this.invalidValue(value) : this.fromDate(d);
994
+ }
995
+ if (typeof value !== "string") return this.invalidValue(value);
996
+ const str = value.trim();
997
+ if (!str) return null;
998
+ if (this.valueFormat()) {
999
+ const parsed = this.parseWithFormat(str, this.valueFormat());
1000
+ if (parsed) return parsed;
1001
+ }
1002
+ if (this.timeOnly()) {
1003
+ const time = str.includes("T") ? str.split("T")[1] : str;
1004
+ const m = /^(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(time);
1005
+ if (!m) return this.invalidValue(value);
1006
+ return this.buildTime(Number(m[1]), Number(m[2]), Number(m[3] ?? 0));
1007
+ }
1008
+ const [rawDate, rawTime] = str.split(/[T\s]/);
1009
+ const parts = rawDate.split(/[-\/.]/).filter(Boolean);
1010
+ let y;
1011
+ let mo = 1;
1012
+ let d = 1;
1013
+ if (parts.length === 1 && /^\d{4}$/.test(parts[0])) y = Number(parts[0]);
1014
+ else if (parts.length === 2) {
1015
+ if (parts[0].length === 4) [y, mo] = parts.map(Number);
1016
+ else [mo, y] = parts.map(Number);
1017
+ } else if (parts.length === 3) {
1018
+ if (parts[0].length === 4) [y, mo, d] = parts.map(Number);
1019
+ else if (this.effectiveLocale().startsWith("en")) [mo, d, y] = parts.map(Number);
1020
+ else [d, mo, y] = parts.map(Number);
1021
+ } else return this.invalidValue(value);
1022
+ const date = new Date(y, mo - 1, d);
1023
+ if (isNaN(date.getTime()) || date.getFullYear() !== y || date.getMonth() !== mo - 1 || date.getDate() !== d) return this.invalidValue(value);
1024
+ const t = rawTime ? /^(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(rawTime) : null;
1025
+ if (t) date.setHours(Number(t[1]), Number(t[2]), Number(t[3] ?? 0));
1026
+ return this.fromDate(date, !!t);
1027
+ }
1028
+ static {
1029
+ this.FORMAT_TOKENS = /YYYY|MM|DD|HH|mm|ss/g;
1030
+ }
1031
+ static {
1032
+ this.WHEEL_THROTTLE_MS = 150;
1033
+ }
1034
+ static {
1035
+ this.DBLCLICK_DELAY_MS = 250;
1036
+ }
1037
+ parseWithFormat(str, format) {
1038
+ const tokens = [];
1039
+ const pattern = format.split(DatePickerComponent.FORMAT_TOKENS).map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
1040
+ const found = format.match(DatePickerComponent.FORMAT_TOKENS) ?? [];
1041
+ let source = pattern[0];
1042
+ found.forEach((tok, i) => {
1043
+ tokens.push(tok);
1044
+ source += (tok === "YYYY" ? "(\\d{4})" : "(\\d{1,2})") + pattern[i + 1];
1045
+ });
1046
+ const match = new RegExp(`^${source}$`).exec(str);
1047
+ if (!match) return null;
1048
+ const get = (tok, def) => {
1049
+ const i = tokens.indexOf(tok);
1050
+ return i >= 0 ? Number(match[i + 1]) : def;
1051
+ };
1052
+ const y = get("YYYY", (/* @__PURE__ */ new Date()).getFullYear());
1053
+ const mo = get("MM", 1);
1054
+ const d = get("DD", 1);
1055
+ const h = get("HH", 0);
1056
+ const mi = get("mm", 0);
1057
+ const s = get("ss", 0);
1058
+ if (h > 23 || mi > 59 || s > 59) return null;
1059
+ const date = new Date(y, mo - 1, d, h, mi, s);
1060
+ if (date.getFullYear() !== y || date.getMonth() !== mo - 1 || date.getDate() !== d) return null;
1061
+ return this.fromDate(date, tokens.includes("HH"));
1062
+ }
1063
+ toOutputValue(value) {
1064
+ if (this.range()) {
1065
+ const [start, end] = value.split("|");
1066
+ return {
1067
+ start: this.formatOutput(start),
1068
+ end: this.formatOutput(end)
1069
+ };
1070
+ }
1071
+ return this.formatOutput(value);
1072
+ }
1073
+ formatOutput(value) {
1074
+ const format = this.valueFormat();
1075
+ if (!format || !value) return value;
1076
+ let y = "", mo = "01", d = "01", h = "00", mi = "00", s = "00";
1077
+ if (this.timeOnly()) [h, mi, s = "00"] = value.split(":");
1078
+ else {
1079
+ const [datePart, timePart] = value.split("T");
1080
+ [y, mo = "01", d = "01"] = datePart.split("-");
1081
+ if (timePart) [h, mi, s = "00"] = timePart.split(":");
1082
+ }
1083
+ const map = {
1084
+ YYYY: y,
1085
+ MM: mo,
1086
+ DD: d,
1087
+ HH: h,
1088
+ mm: mi,
1089
+ ss: s
1090
+ };
1091
+ return format.replace(DatePickerComponent.FORMAT_TOKENS, (tok) => map[tok]);
1092
+ }
1093
+ fromDate(date, hasTime = true) {
1094
+ if (this.timeOnly()) return this.buildTime(date.getHours(), date.getMinutes(), date.getSeconds());
1095
+ const iso = this.toISODate(date);
1096
+ const v = this.view();
1097
+ if (!this.range()) {
1098
+ if (v === "year") return iso.slice(0, 4);
1099
+ if (v === "month") return iso.slice(0, 7);
1100
+ if (this.showTime() && hasTime) return `${iso}T${this.buildTime(date.getHours(), date.getMinutes(), date.getSeconds())}`;
1101
+ }
1102
+ return iso;
1103
+ }
1104
+ invalidValue(value) {
1105
+ console.warn("[shk-date-picker] Valor de fecha no válido, se ignora:", value);
1106
+ return null;
1107
+ }
1108
+ registerOnChange(fn) {
1109
+ this.onChange = fn;
1110
+ }
1111
+ registerOnTouched(fn) {
1112
+ this.onTouched = fn;
1113
+ }
1114
+ setDisabledState(isDisabled) {
1115
+ this._disabledState.set(isDisabled);
1116
+ this.cdr.markForCheck();
1117
+ }
1118
+ static {
1119
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1120
+ minVersion: "12.0.0",
1121
+ version: "22.3.2",
1122
+ ngImport: i0,
1123
+ type: DatePickerComponent,
1124
+ deps: [],
1125
+ target: i0.ɵɵFactoryTarget.Component
1126
+ });
1127
+ }
1128
+ static {
1129
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1130
+ minVersion: "17.0.0",
1131
+ version: "22.3.2",
1132
+ type: DatePickerComponent,
1133
+ isStandalone: true,
1134
+ selector: "shk-date-picker",
1135
+ inputs: {
1136
+ id: {
1137
+ classPropertyName: "id",
1138
+ publicName: "id",
1139
+ isSignal: true,
1140
+ isRequired: false,
1141
+ transformFunction: null
1142
+ },
1143
+ view: {
1144
+ classPropertyName: "view",
1145
+ publicName: "view",
1146
+ isSignal: true,
1147
+ isRequired: false,
1148
+ transformFunction: null
1149
+ },
1150
+ weekStart: {
1151
+ classPropertyName: "weekStart",
1152
+ publicName: "weekStart",
1153
+ isSignal: true,
1154
+ isRequired: false,
1155
+ transformFunction: null
1156
+ },
1157
+ range: {
1158
+ classPropertyName: "range",
1159
+ publicName: "range",
1160
+ isSignal: true,
1161
+ isRequired: false,
1162
+ transformFunction: null
1163
+ },
1164
+ markedDates: {
1165
+ classPropertyName: "markedDates",
1166
+ publicName: "markedDates",
1167
+ isSignal: true,
1168
+ isRequired: false,
1169
+ transformFunction: null
1170
+ },
1171
+ label: {
1172
+ classPropertyName: "label",
1173
+ publicName: "label",
1174
+ isSignal: true,
1175
+ isRequired: false,
1176
+ transformFunction: null
1177
+ },
1178
+ placeholder: {
1179
+ classPropertyName: "placeholder",
1180
+ publicName: "placeholder",
1181
+ isSignal: true,
1182
+ isRequired: false,
1183
+ transformFunction: null
1184
+ },
1185
+ formGroup: {
1186
+ classPropertyName: "formGroup",
1187
+ publicName: "formGroup",
1188
+ isSignal: true,
1189
+ isRequired: false,
1190
+ transformFunction: null
1191
+ },
1192
+ controlName: {
1193
+ classPropertyName: "controlName",
1194
+ publicName: "controlName",
1195
+ isSignal: true,
1196
+ isRequired: false,
1197
+ transformFunction: null
1198
+ },
1199
+ control: {
1200
+ classPropertyName: "control",
1201
+ publicName: "control",
1202
+ isSignal: true,
1203
+ isRequired: false,
1204
+ transformFunction: null
1205
+ },
1206
+ disabled: {
1207
+ classPropertyName: "disabled",
1208
+ publicName: "disabled",
1209
+ isSignal: true,
1210
+ isRequired: false,
1211
+ transformFunction: null
1212
+ },
1213
+ errors: {
1214
+ classPropertyName: "errors",
1215
+ publicName: "errors",
1216
+ isSignal: true,
1217
+ isRequired: false,
1218
+ transformFunction: null
1219
+ },
1220
+ invalid: {
1221
+ classPropertyName: "invalid",
1222
+ publicName: "invalid",
1223
+ isSignal: true,
1224
+ isRequired: false,
1225
+ transformFunction: null
1226
+ },
1227
+ touched: {
1228
+ classPropertyName: "touched",
1229
+ publicName: "touched",
1230
+ isSignal: true,
1231
+ isRequired: false,
1232
+ transformFunction: null
1233
+ },
1234
+ dirty: {
1235
+ classPropertyName: "dirty",
1236
+ publicName: "dirty",
1237
+ isSignal: true,
1238
+ isRequired: false,
1239
+ transformFunction: null
1240
+ },
1241
+ errorMessage: {
1242
+ classPropertyName: "errorMessage",
1243
+ publicName: "errorMessage",
1244
+ isSignal: true,
1245
+ isRequired: false,
1246
+ transformFunction: null
1247
+ },
1248
+ errorMessages: {
1249
+ classPropertyName: "errorMessages",
1250
+ publicName: "errorMessages",
1251
+ isSignal: true,
1252
+ isRequired: false,
1253
+ transformFunction: null
1254
+ },
1255
+ minValue: {
1256
+ classPropertyName: "minValue",
1257
+ publicName: "minValue",
1258
+ isSignal: true,
1259
+ isRequired: false,
1260
+ transformFunction: null
1261
+ },
1262
+ maxValue: {
1263
+ classPropertyName: "maxValue",
1264
+ publicName: "maxValue",
1265
+ isSignal: true,
1266
+ isRequired: false,
1267
+ transformFunction: null
1268
+ },
1269
+ locale: {
1270
+ classPropertyName: "locale",
1271
+ publicName: "locale",
1272
+ isSignal: true,
1273
+ isRequired: false,
1274
+ transformFunction: null
1275
+ },
1276
+ dateFormat: {
1277
+ classPropertyName: "dateFormat",
1278
+ publicName: "dateFormat",
1279
+ isSignal: true,
1280
+ isRequired: false,
1281
+ transformFunction: null
1282
+ },
1283
+ displayStyle: {
1284
+ classPropertyName: "displayStyle",
1285
+ publicName: "displayStyle",
1286
+ isSignal: true,
1287
+ isRequired: false,
1288
+ transformFunction: null
1289
+ },
1290
+ timeOnly: {
1291
+ classPropertyName: "timeOnly",
1292
+ publicName: "timeOnly",
1293
+ isSignal: true,
1294
+ isRequired: false,
1295
+ transformFunction: null
1296
+ },
1297
+ showTime: {
1298
+ classPropertyName: "showTime",
1299
+ publicName: "showTime",
1300
+ isSignal: true,
1301
+ isRequired: false,
1302
+ transformFunction: null
1303
+ },
1304
+ hourFormat: {
1305
+ classPropertyName: "hourFormat",
1306
+ publicName: "hourFormat",
1307
+ isSignal: true,
1308
+ isRequired: false,
1309
+ transformFunction: null
1310
+ },
1311
+ showSeconds: {
1312
+ classPropertyName: "showSeconds",
1313
+ publicName: "showSeconds",
1314
+ isSignal: true,
1315
+ isRequired: false,
1316
+ transformFunction: null
1317
+ },
1318
+ minuteStep: {
1319
+ classPropertyName: "minuteStep",
1320
+ publicName: "minuteStep",
1321
+ isSignal: true,
1322
+ isRequired: false,
1323
+ transformFunction: null
1324
+ },
1325
+ valueFormat: {
1326
+ classPropertyName: "valueFormat",
1327
+ publicName: "valueFormat",
1328
+ isSignal: true,
1329
+ isRequired: false,
1330
+ transformFunction: null
1331
+ },
1332
+ value: {
1333
+ classPropertyName: "value",
1334
+ publicName: "value",
1335
+ isSignal: true,
1336
+ isRequired: false,
1337
+ transformFunction: null
1338
+ }
1339
+ },
1340
+ outputs: {
1341
+ value: "valueChange",
1342
+ touch: "touch"
1343
+ },
1344
+ host: { listeners: {
1345
+ "document:click": "onDocumentClick($event)",
1346
+ "window:resize": "onViewportChange()",
1347
+ "document:keydown.escape": "onEscape()"
1348
+ } },
1349
+ providers: [{
1350
+ provide: NG_VALUE_ACCESSOR,
1351
+ useExisting: forwardRef(() => DatePickerComponent),
1352
+ multi: true
1353
+ }],
1354
+ viewQueries: [
1355
+ {
1356
+ propertyName: "overlay",
1357
+ first: true,
1358
+ predicate: ["overlay"],
1359
+ descendants: true,
1360
+ isSignal: true
1361
+ },
1362
+ {
1363
+ propertyName: "anchor",
1364
+ first: true,
1365
+ predicate: ["anchor"],
1366
+ descendants: true,
1367
+ isSignal: true
1368
+ },
1369
+ {
1370
+ propertyName: "panel",
1371
+ first: true,
1372
+ predicate: ["panel"],
1373
+ descendants: true,
1374
+ isSignal: true
1375
+ }
1376
+ ],
1377
+ ngImport: i0,
1378
+ template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n <div #anchor class=\"relative\">\n <input\n [id]=\"id()\"\n type=\"text\"\n autocomplete=\"off\"\n [disabled]=\"isDisabled()\"\n [placeholder]=\"inputPlaceholder()\"\n [value]=\"isTyping() ? typedValue() : displayLabel()\"\n (input)=\"onInputText($event)\"\n (focus)=\"onInputFocus()\"\n (blur)=\"onInputBlur()\"\n (keydown.enter)=\"$any($event.target).blur()\"\n (keydown.escape)=\"cancelTyping()\"\n (click)=\"toggle()\"\n class=\"date-input-field\"\n [ngClass]=\"{\n 'input-error': shouldShowError() || typingValid() === false,\n 'input-valid': wasFixedError() || typingValid() === true,\n }\"\n [attr.aria-invalid]=\"shouldShowError() || typingValid() === false || null\"\n [attr.aria-describedby]=\"shouldShowError() ? id() + '-error' : null\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"isOpen()\"\n />\n <button\n type=\"button\"\n tabindex=\"-1\"\n [disabled]=\"isDisabled()\"\n (click)=\"toggle()\"\n class=\"absolute right-2 top-1/2 -translate-y-1/2 p-1 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n [attr.aria-label]=\"texts().open\"\n >\n @if (timeOnly()) {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <circle cx=\"12\" cy=\"12\" r=\"9\"></circle>\n <path d=\"M12 7v5l3 2\"></path>\n </svg>\n } @else {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\"></rect>\n <path d=\"M16 2v4M8 2v4M3 10h18\"></path>\n </svg>\n }\n </button>\n </div>\n\n @if (isOpen()) {\n <div #overlay shkPortal class=\"shk-date-picker-overlay\">\n <div class=\"fixed inset-0 z-40\" (click)=\"close()\"></div>\n\n <div\n #panel\n role=\"dialog\"\n class=\"dp-panel fixed z-50 p-4\"\n [style.top.px]=\"panelPosition()?.top ?? 0\"\n [style.left.px]=\"panelPosition()?.left ?? 0\"\n [style.visibility]=\"panelPosition() ? 'visible' : 'hidden'\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onPanelKeydown($event)\"\n >\n <div class=\"flex items-stretch\">\n @if (!timeOnly()) {\n <!-- ================= DAYS ================= -->\n @if (currentView() === 'date') {\n <div class=\"flex gap-6\" (wheel)=\"onWheel($event)\">\n @for (m of visibleMonths(); track m.year * 12 + m.month; let first = $first; let last = $last) {\n <div class=\"w-64\" [class.dp-month-divider]=\"!first\">\n <!-- Header: ‹ Mes Año › -->\n <div class=\"flex items-center justify-between mb-3\">\n @if (first) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">\n {{ monthLongNames()[m.month] }} {{ m.year }}\n </button>\n @if (last) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n </div>\n\n <!-- Typed date + Today (single mode) -->\n @if (!range()) {\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input\"\n [class.input-error]=\"panelTextError() === 'single'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"panelText()\"\n (keydown.enter)=\"commitPanelText('single', $event)\"\n (blur)=\"commitPanelText('single', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n </div>\n }\n\n <!-- Weekday names -->\n <div class=\"grid grid-cols-7\">\n @for (name of dayNames(); track $index) {\n <div class=\"dp-weekday\">{{ name }}</div>\n }\n </div>\n\n <!-- Day grid (6 weeks, neighbouring months included) -->\n <div class=\"grid grid-cols-7\" (mouseleave)=\"onDayHover(null)\">\n @for (cell of m.cells; track cell.iso) {\n <div\n class=\"dp-cell\"\n [class.in-range]=\"(cell.inMonth || !range()) && isInRange(cell.iso)\"\n [class.range-start]=\"(cell.inMonth || !range()) && isRangeStart(cell.iso)\"\n [class.range-end]=\"(cell.inMonth || !range()) && isRangeEnd(cell.iso)\"\n >\n <button\n type=\"button\"\n class=\"dp-day\"\n [class.is-outside]=\"!cell.inMonth\"\n [class.is-today]=\"isTodayDate(cell.iso)\"\n [class.is-selected]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [disabled]=\"isDisabledDate(cell.iso)\"\n [attr.aria-pressed]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [attr.aria-current]=\"isTodayDate(cell.iso) ? 'date' : null\"\n (click)=\"selectDay(cell)\"\n (dblclick)=\"quickApply(cell)\"\n (mouseenter)=\"onDayHover(cell)\"\n >\n {{ cell.day }}\n @if (isMarked(cell.iso)) {\n <span class=\"dp-dot\"></span>\n }\n </button>\n </div>\n }\n </div>\n </div>\n }\n </div>\n }\n\n <!-- ================= WEEKS ================= -->\n @if (currentView() === 'week') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"space-y-1\">\n @for (week of monthWeeks(); track week.index) {\n <button\n type=\"button\"\n (click)=\"selectWeek(week.start)\"\n class=\"dp-chip w-full flex items-center justify-between px-3\"\n [class.is-selected]=\"isSelectedWeek(week.start)\"\n [class.is-current]=\"isCurrentWeek(week.start)\"\n >\n <span class=\"font-medium\">{{ weekLabel(week.index) }}</span>\n <span class=\"text-xs opacity-80\">{{ week.range }}</span>\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= MONTHS ================= -->\n @if (currentView() === 'month') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (name of monthNames(); track $index) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedMonth($index)\"\n [class.is-current]=\"isCurrentMonth($index)\"\n (click)=\"selectMonth($index)\"\n >\n {{ name }}\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= YEARS ================= -->\n @if (currentView() === 'year') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <span class=\"dp-title\">{{ headerTitle() }}</span>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (year of decadeYears(); track year) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedYear(year)\"\n [class.is-current]=\"isCurrentYear(year)\"\n (click)=\"selectYear(year)\"\n >\n {{ year }}\n </button>\n }\n </div>\n </div>\n }\n }\n\n <!-- ================= TIME (columns) ================= -->\n @if (showTimeColumns()) {\n <div\n class=\"flex flex-col\"\n [ngClass]=\"timeOnly() ? 'w-64' : 'w-40 ml-6 dp-month-divider'\"\n >\n <!-- Typed time + Now -->\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input text-center font-semibold tabular-nums\"\n [class.input-error]=\"timeTextError()\"\n [placeholder]=\"effectiveHourFormat() === '12' ? 'hh:mm AM' : 'HH:mm'\"\n [value]=\"timeText()\"\n (keydown.enter)=\"commitTimeText($event)\"\n (blur)=\"commitTimeText($event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"setNow()\">{{ texts().now }}</button>\n </div>\n\n <!-- Column titles -->\n <div class=\"flex\">\n <div class=\"dp-weekday flex-1\">{{ texts().hour }}</div>\n <div class=\"dp-weekday flex-1\">{{ texts().minute }}</div>\n @if (showSeconds()) {\n <div class=\"dp-weekday flex-1\">{{ texts().second }}</div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-weekday flex-1\"></div>\n }\n </div>\n\n <!-- Scrollable columns -->\n <div class=\"relative\" [ngClass]=\"timeOnly() ? 'h-56' : 'flex-1 min-h-[12rem]'\">\n <div class=\"absolute inset-0 flex\">\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().hour\">\n @for (h of hourOptions(); track h.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewHour() === h.value\"\n [class.is-current]=\"isCurrentHour(h.value)\"\n [attr.aria-selected]=\"viewHour() === h.value\"\n (click)=\"selectHour(h.value)\"\n >\n {{ h.label }}\n </button>\n }\n </div>\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().minute\">\n @for (m of minuteOptions(); track m) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewMinute() === m\"\n [attr.aria-selected]=\"viewMinute() === m\"\n (click)=\"selectMinute(m)\"\n >\n {{ pad2(m) }}\n </button>\n }\n </div>\n @if (showSeconds()) {\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().second\">\n @for (sec of secondOptions; track sec) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewSecond() === sec\"\n [attr.aria-selected]=\"viewSecond() === sec\"\n (click)=\"selectSecond(sec)\"\n >\n {{ pad2(sec) }}\n </button>\n }\n </div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-time-col\">\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'AM'\" (click)=\"setMeridiem('AM')\">AM</button>\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'PM'\" (click)=\"setMeridiem('PM')\">PM</button>\n </div>\n }\n </div>\n </div>\n </div>\n }\n </div>\n\n <!-- ================= FOOTER ================= -->\n @if (showFooter()) {\n <div class=\"mt-4 pt-4 border-t dp-divider\">\n @if (range()) {\n <div class=\"flex items-center gap-3\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n <div class=\"flex-1\"></div>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'start'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeStartText()\"\n (keydown.enter)=\"commitPanelText('start', $event)\"\n (blur)=\"commitPanelText('start', $event)\"\n />\n <span class=\"_shk-text-surface-400\">–</span>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'end'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeEndText()\"\n (keydown.enter)=\"commitPanelText('end', $event)\"\n (blur)=\"commitPanelText('end', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n } @else {\n <div class=\"grid grid-cols-2 gap-3 w-64 ml-auto\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n @if (shouldShowError()) {\n <div [id]=\"id() + '-error'\" class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\">\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>\n",
1379
+ styles: [".dp-panel{background-color:#fff;border:1px solid var(--shk-surface-200);border-radius:.75rem;box-shadow:0 12px 32px -8px #0000002e,0 2px 6px #0000000f;color:var(--shk-surface-700)}.dark .dp-panel{background-color:var(--shk-surface-100)}.dp-nav{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-surface-500);transition:background-color .15s,color .15s}.dp-nav:hover:not(:disabled){background-color:var(--shk-surface-100);color:var(--shk-surface-800)}.dark .dp-nav:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-nav:disabled{opacity:.3;cursor:not-allowed}.dp-title{font-size:.875rem;font-weight:600;padding:.25rem .5rem;border-radius:.375rem;color:var(--shk-surface-800);transition:background-color .15s}button.dp-title:hover{background-color:var(--shk-surface-100)}.dark button.dp-title:hover{background-color:var(--shk-surface-200)}.dp-month-divider{position:relative}.dp-month-divider:before{content:\"\";position:absolute;top:-1rem;bottom:0;left:-.75rem;border-left:1px solid var(--shk-surface-200)}.dp-weekday{text-align:center;font-size:.75rem;font-weight:500;color:var(--shk-surface-500);padding:.25rem 0}.dp-cell{position:relative;display:flex;align-items:center;justify-content:center;height:2.25rem}.dp-cell.in-range:before,.dp-cell.range-start:before,.dp-cell.range-end:before{content:\"\";position:absolute;inset:.125rem 0;background-color:color-mix(in srgb,var(--shk-primary-500) 12%,transparent)}.dp-cell.range-start:before{left:50%}.dp-cell.range-end:before{right:50%}.dp-cell.range-start.range-end:before{display:none}.dp-day{position:relative;z-index:1;width:2.125rem;height:2.125rem;border-radius:9999px;font-size:.8125rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-200)}.dp-day.is-outside{color:var(--shk-surface-400)}.dp-day.is-today{font-weight:700;color:var(--shk-primary-600);background-color:color-mix(in srgb,var(--shk-primary-500) 10%,transparent)}.dp-day.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-day:disabled{opacity:.3;cursor:not-allowed;text-decoration:line-through}.dp-dot{position:absolute;left:50%;bottom:.25rem;width:.25rem;height:.25rem;border-radius:9999px;transform:translate(-50%);background-color:var(--shk-primary-500)}.dp-day.is-selected .dp-dot{background-color:#fff}.dp-chip{padding:.5rem 0;font-size:.8125rem;border-radius:.5rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-chip.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-chip.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-btn{display:inline-flex;align-items:center;justify-content:center;padding:.4375rem .875rem;font-size:.8125rem;font-weight:500;border-radius:.5rem;border:1px solid var(--shk-surface-200);color:var(--shk-surface-700);background-color:transparent;transition:background-color .15s,border-color .15s;white-space:nowrap}.dp-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}.dark .dp-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-btn-primary{border-color:var(--shk-primary-500);background-color:var(--shk-primary-500);color:#fff}.dp-btn-primary:hover:not(:disabled){background-color:var(--shk-primary-700)!important;border-color:var(--shk-primary-700)}.dp-btn:disabled{opacity:.5;cursor:not-allowed}.dp-mini-input{width:100%;min-width:0;padding:.4375rem .625rem;font-size:.8125rem;border-radius:.5rem;border:1px solid var(--shk-surface-200);background-color:transparent;color:var(--shk-surface-700);outline:none;transition:border-color .15s,box-shadow .15s}.dp-mini-input:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.dp-mini-input.input-error{border-color:var(--shk-error-500)}.dp-divider{border-color:var(--shk-surface-200)}.dp-time-col{position:relative;flex:1 1 0;min-width:0;overflow-y:auto;scrollbar-width:thin;scroll-behavior:smooth;padding:0 .125rem}.dp-time-col+.dp-time-col{border-left:1px solid var(--shk-surface-200)}.dp-time-item{display:flex;align-items:center;justify-content:center;width:100%;height:2rem;margin:.125rem 0;border-radius:.5rem;font-size:.8125rem;font-variant-numeric:tabular-nums;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-time-item.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-time-item.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.date-input-field{width:100%;padding:.5rem 2.5rem .5rem .75rem;font-size:.875rem;border-radius:.5rem;outline:none;transition:border-color .15s,box-shadow .15s;background-color:var(--shk-surface-50);color:var(--shk-surface-700);border:1px solid var(--shk-surface-200);text-overflow:ellipsis}:host-context(.dark) .date-input-field,.dark .date-input-field{background-color:var(--shk-surface-100)}.date-input-field::placeholder{color:var(--shk-surface-400)}.date-input-field:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.date-input-field:disabled{background-color:var(--shk-surface-100);color:var(--shk-surface-500);cursor:not-allowed}:host-context(.dark) .date-input-field:disabled,.dark .date-input-field:disabled{background-color:var(--shk-surface-50);color:var(--shk-surface-400)}.date-input-field.input-error,:host-context(.dark) .date-input-field.input-error,.dark .date-input-field.input-error{border-color:var(--shk-error-500)}.date-input-field.input-error:focus,:host-context(.dark) .date-input-field.input-error:focus,.dark .date-input-field.input-error:focus{box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-error-500) 22%,transparent)}.date-input-field.input-valid,:host-context(.dark) .date-input-field.input-valid,.dark .date-input-field.input-valid{border-color:#22c55e}.date-input-field.input-valid:focus,:host-context(.dark) .date-input-field.input-valid:focus,.dark .date-input-field.input-valid:focus{box-shadow:0 0 0 3px #22c55e33}\n"],
1380
+ dependencies: [
1381
+ {
1382
+ kind: "ngmodule",
1383
+ type: CommonModule
1384
+ },
1385
+ {
1386
+ kind: "directive",
1387
+ type: i1.NgClass,
1388
+ selector: "[ngClass]",
1389
+ inputs: ["class", "ngClass"]
1390
+ },
1391
+ {
1392
+ kind: "ngmodule",
1393
+ type: ReactiveFormsModule
1394
+ },
1395
+ {
1396
+ kind: "directive",
1397
+ type: PortalDirective,
1398
+ selector: "[shkPortal]"
1399
+ }
1400
+ ],
1401
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1402
+ });
1403
+ }
1404
+ };
1405
+ i0.ɵɵngDeclareClassMetadata({
1406
+ minVersion: "12.0.0",
1407
+ version: "22.3.2",
1408
+ ngImport: i0,
1409
+ type: DatePickerComponent,
1410
+ decorators: [{
1411
+ type: Component,
1412
+ args: [{
1413
+ selector: "shk-date-picker",
1414
+ imports: [
1415
+ CommonModule,
1416
+ ReactiveFormsModule,
1417
+ PortalDirective
1418
+ ],
1419
+ changeDetection: ChangeDetectionStrategy.OnPush,
1420
+ providers: [{
1421
+ provide: NG_VALUE_ACCESSOR,
1422
+ useExisting: forwardRef(() => DatePickerComponent),
1423
+ multi: true
1424
+ }],
1425
+ template: "<div class=\"relative mb-4\">\n @if (label()) {\n <div class=\"text-sm font-medium _shk-text-surface-700 mb-1\">\n {{ label() }}\n </div>\n }\n\n <div class=\"relative\">\n <div #anchor class=\"relative\">\n <input\n [id]=\"id()\"\n type=\"text\"\n autocomplete=\"off\"\n [disabled]=\"isDisabled()\"\n [placeholder]=\"inputPlaceholder()\"\n [value]=\"isTyping() ? typedValue() : displayLabel()\"\n (input)=\"onInputText($event)\"\n (focus)=\"onInputFocus()\"\n (blur)=\"onInputBlur()\"\n (keydown.enter)=\"$any($event.target).blur()\"\n (keydown.escape)=\"cancelTyping()\"\n (click)=\"toggle()\"\n class=\"date-input-field\"\n [ngClass]=\"{\n 'input-error': shouldShowError() || typingValid() === false,\n 'input-valid': wasFixedError() || typingValid() === true,\n }\"\n [attr.aria-invalid]=\"shouldShowError() || typingValid() === false || null\"\n [attr.aria-describedby]=\"shouldShowError() ? id() + '-error' : null\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"isOpen()\"\n />\n <button\n type=\"button\"\n tabindex=\"-1\"\n [disabled]=\"isDisabled()\"\n (click)=\"toggle()\"\n class=\"absolute right-2 top-1/2 -translate-y-1/2 p-1 _shk-text-surface-400 hover:[color:var(--shk-surface-600)] dark:hover:[color:var(--shk-surface-300)] transition-colors\"\n [attr.aria-label]=\"texts().open\"\n >\n @if (timeOnly()) {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <circle cx=\"12\" cy=\"12\" r=\"9\"></circle>\n <path d=\"M12 7v5l3 2\"></path>\n </svg>\n } @else {\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\"></rect>\n <path d=\"M16 2v4M8 2v4M3 10h18\"></path>\n </svg>\n }\n </button>\n </div>\n\n @if (isOpen()) {\n <div #overlay shkPortal class=\"shk-date-picker-overlay\">\n <div class=\"fixed inset-0 z-40\" (click)=\"close()\"></div>\n\n <div\n #panel\n role=\"dialog\"\n class=\"dp-panel fixed z-50 p-4\"\n [style.top.px]=\"panelPosition()?.top ?? 0\"\n [style.left.px]=\"panelPosition()?.left ?? 0\"\n [style.visibility]=\"panelPosition() ? 'visible' : 'hidden'\"\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onPanelKeydown($event)\"\n >\n <div class=\"flex items-stretch\">\n @if (!timeOnly()) {\n <!-- ================= DAYS ================= -->\n @if (currentView() === 'date') {\n <div class=\"flex gap-6\" (wheel)=\"onWheel($event)\">\n @for (m of visibleMonths(); track m.year * 12 + m.month; let first = $first; let last = $last) {\n <div class=\"w-64\" [class.dp-month-divider]=\"!first\">\n <!-- Header: ‹ Mes Año › -->\n <div class=\"flex items-center justify-between mb-3\">\n @if (first) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">\n {{ monthLongNames()[m.month] }} {{ m.year }}\n </button>\n @if (last) {\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n } @else {\n <span class=\"w-8\"></span>\n }\n </div>\n\n <!-- Typed date + Today (single mode) -->\n @if (!range()) {\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input\"\n [class.input-error]=\"panelTextError() === 'single'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"panelText()\"\n (keydown.enter)=\"commitPanelText('single', $event)\"\n (blur)=\"commitPanelText('single', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n </div>\n }\n\n <!-- Weekday names -->\n <div class=\"grid grid-cols-7\">\n @for (name of dayNames(); track $index) {\n <div class=\"dp-weekday\">{{ name }}</div>\n }\n </div>\n\n <!-- Day grid (6 weeks, neighbouring months included) -->\n <div class=\"grid grid-cols-7\" (mouseleave)=\"onDayHover(null)\">\n @for (cell of m.cells; track cell.iso) {\n <div\n class=\"dp-cell\"\n [class.in-range]=\"(cell.inMonth || !range()) && isInRange(cell.iso)\"\n [class.range-start]=\"(cell.inMonth || !range()) && isRangeStart(cell.iso)\"\n [class.range-end]=\"(cell.inMonth || !range()) && isRangeEnd(cell.iso)\"\n >\n <button\n type=\"button\"\n class=\"dp-day\"\n [class.is-outside]=\"!cell.inMonth\"\n [class.is-today]=\"isTodayDate(cell.iso)\"\n [class.is-selected]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [disabled]=\"isDisabledDate(cell.iso)\"\n [attr.aria-pressed]=\"(cell.inMonth || !range()) && isSelectedDate(cell.iso)\"\n [attr.aria-current]=\"isTodayDate(cell.iso) ? 'date' : null\"\n (click)=\"selectDay(cell)\"\n (dblclick)=\"quickApply(cell)\"\n (mouseenter)=\"onDayHover(cell)\"\n >\n {{ cell.day }}\n @if (isMarked(cell.iso)) {\n <span class=\"dp-dot\"></span>\n }\n </button>\n </div>\n }\n </div>\n </div>\n }\n </div>\n }\n\n <!-- ================= WEEKS ================= -->\n @if (currentView() === 'week') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextMonth\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"space-y-1\">\n @for (week of monthWeeks(); track week.index) {\n <button\n type=\"button\"\n (click)=\"selectWeek(week.start)\"\n class=\"dp-chip w-full flex items-center justify-between px-3\"\n [class.is-selected]=\"isSelectedWeek(week.start)\"\n [class.is-current]=\"isCurrentWeek(week.start)\"\n >\n <span class=\"font-medium\">{{ weekLabel(week.index) }}</span>\n <span class=\"text-xs opacity-80\">{{ week.range }}</span>\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= MONTHS ================= -->\n @if (currentView() === 'month') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <button type=\"button\" class=\"dp-title\" (click)=\"zoomOut()\">{{ headerTitle() }}</button>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYear\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (name of monthNames(); track $index) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedMonth($index)\"\n [class.is-current]=\"isCurrentMonth($index)\"\n (click)=\"selectMonth($index)\"\n >\n {{ name }}\n </button>\n }\n </div>\n </div>\n }\n\n <!-- ================= YEARS ================= -->\n @if (currentView() === 'year') {\n <div class=\"w-64\" (wheel)=\"onWheel($event)\">\n <div class=\"flex items-center justify-between mb-3\">\n <button type=\"button\" class=\"dp-nav\" (click)=\"prev()\" [disabled]=\"!canGoPrev()\" [attr.aria-label]=\"texts().prevYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M15 18l-6-6 6-6\"></path></svg>\n </button>\n <span class=\"dp-title\">{{ headerTitle() }}</span>\n <button type=\"button\" class=\"dp-nav\" (click)=\"next()\" [disabled]=\"!canGoNext()\" [attr.aria-label]=\"texts().nextYears\">\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M9 18l6-6-6-6\"></path></svg>\n </button>\n </div>\n <div class=\"grid grid-cols-3 gap-1\">\n @for (year of decadeYears(); track year) {\n <button\n type=\"button\"\n class=\"dp-chip\"\n [class.is-selected]=\"isSelectedYear(year)\"\n [class.is-current]=\"isCurrentYear(year)\"\n (click)=\"selectYear(year)\"\n >\n {{ year }}\n </button>\n }\n </div>\n </div>\n }\n }\n\n <!-- ================= TIME (columns) ================= -->\n @if (showTimeColumns()) {\n <div\n class=\"flex flex-col\"\n [ngClass]=\"timeOnly() ? 'w-64' : 'w-40 ml-6 dp-month-divider'\"\n >\n <!-- Typed time + Now -->\n <div class=\"flex items-center gap-2 mb-3\">\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input text-center font-semibold tabular-nums\"\n [class.input-error]=\"timeTextError()\"\n [placeholder]=\"effectiveHourFormat() === '12' ? 'hh:mm AM' : 'HH:mm'\"\n [value]=\"timeText()\"\n (keydown.enter)=\"commitTimeText($event)\"\n (blur)=\"commitTimeText($event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"setNow()\">{{ texts().now }}</button>\n </div>\n\n <!-- Column titles -->\n <div class=\"flex\">\n <div class=\"dp-weekday flex-1\">{{ texts().hour }}</div>\n <div class=\"dp-weekday flex-1\">{{ texts().minute }}</div>\n @if (showSeconds()) {\n <div class=\"dp-weekday flex-1\">{{ texts().second }}</div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-weekday flex-1\"></div>\n }\n </div>\n\n <!-- Scrollable columns -->\n <div class=\"relative\" [ngClass]=\"timeOnly() ? 'h-56' : 'flex-1 min-h-[12rem]'\">\n <div class=\"absolute inset-0 flex\">\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().hour\">\n @for (h of hourOptions(); track h.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewHour() === h.value\"\n [class.is-current]=\"isCurrentHour(h.value)\"\n [attr.aria-selected]=\"viewHour() === h.value\"\n (click)=\"selectHour(h.value)\"\n >\n {{ h.label }}\n </button>\n }\n </div>\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().minute\">\n @for (m of minuteOptions(); track m) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewMinute() === m\"\n [attr.aria-selected]=\"viewMinute() === m\"\n (click)=\"selectMinute(m)\"\n >\n {{ pad2(m) }}\n </button>\n }\n </div>\n @if (showSeconds()) {\n <div class=\"dp-time-col\" role=\"listbox\" [attr.aria-label]=\"texts().second\">\n @for (sec of secondOptions; track sec) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"dp-time-item\"\n [class.is-selected]=\"viewSecond() === sec\"\n [attr.aria-selected]=\"viewSecond() === sec\"\n (click)=\"selectSecond(sec)\"\n >\n {{ pad2(sec) }}\n </button>\n }\n </div>\n }\n @if (effectiveHourFormat() === '12') {\n <div class=\"dp-time-col\">\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'AM'\" (click)=\"setMeridiem('AM')\">AM</button>\n <button type=\"button\" class=\"dp-time-item\" [class.is-selected]=\"viewMeridiem() === 'PM'\" (click)=\"setMeridiem('PM')\">PM</button>\n </div>\n }\n </div>\n </div>\n </div>\n }\n </div>\n\n <!-- ================= FOOTER ================= -->\n @if (showFooter()) {\n <div class=\"mt-4 pt-4 border-t dp-divider\">\n @if (range()) {\n <div class=\"flex items-center gap-3\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"goToday()\">{{ texts().today }}</button>\n <div class=\"flex-1\"></div>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'start'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeStartText()\"\n (keydown.enter)=\"commitPanelText('start', $event)\"\n (blur)=\"commitPanelText('start', $event)\"\n />\n <span class=\"_shk-text-surface-400\">–</span>\n <input\n type=\"text\"\n autocomplete=\"off\"\n class=\"dp-mini-input !w-32\"\n [class.input-error]=\"panelTextError() === 'end'\"\n [placeholder]=\"inputFormat()\"\n [value]=\"rangeEndText()\"\n (keydown.enter)=\"commitPanelText('end', $event)\"\n (blur)=\"commitPanelText('end', $event)\"\n />\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n } @else {\n <div class=\"grid grid-cols-2 gap-3 w-64 ml-auto\">\n <button type=\"button\" class=\"dp-btn\" (click)=\"close()\">{{ texts().cancel }}</button>\n <button type=\"button\" class=\"dp-btn dp-btn-primary\" [disabled]=\"!canApply()\" (click)=\"apply()\">\n {{ texts().apply }}\n </button>\n </div>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n @if (shouldShowError()) {\n <div [id]=\"id() + '-error'\" class=\"mt-1 text-xs text-red-500 max-h-20 overflow-y-auto _shk-scrollbar\">\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>\n",
1426
+ styles: [".dp-panel{background-color:#fff;border:1px solid var(--shk-surface-200);border-radius:.75rem;box-shadow:0 12px 32px -8px #0000002e,0 2px 6px #0000000f;color:var(--shk-surface-700)}.dark .dp-panel{background-color:var(--shk-surface-100)}.dp-nav{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;border-radius:9999px;color:var(--shk-surface-500);transition:background-color .15s,color .15s}.dp-nav:hover:not(:disabled){background-color:var(--shk-surface-100);color:var(--shk-surface-800)}.dark .dp-nav:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-nav:disabled{opacity:.3;cursor:not-allowed}.dp-title{font-size:.875rem;font-weight:600;padding:.25rem .5rem;border-radius:.375rem;color:var(--shk-surface-800);transition:background-color .15s}button.dp-title:hover{background-color:var(--shk-surface-100)}.dark button.dp-title:hover{background-color:var(--shk-surface-200)}.dp-month-divider{position:relative}.dp-month-divider:before{content:\"\";position:absolute;top:-1rem;bottom:0;left:-.75rem;border-left:1px solid var(--shk-surface-200)}.dp-weekday{text-align:center;font-size:.75rem;font-weight:500;color:var(--shk-surface-500);padding:.25rem 0}.dp-cell{position:relative;display:flex;align-items:center;justify-content:center;height:2.25rem}.dp-cell.in-range:before,.dp-cell.range-start:before,.dp-cell.range-end:before{content:\"\";position:absolute;inset:.125rem 0;background-color:color-mix(in srgb,var(--shk-primary-500) 12%,transparent)}.dp-cell.range-start:before{left:50%}.dp-cell.range-end:before{right:50%}.dp-cell.range-start.range-end:before{display:none}.dp-day{position:relative;z-index:1;width:2.125rem;height:2.125rem;border-radius:9999px;font-size:.8125rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-day:hover:not(:disabled):not(.is-selected){background-color:var(--shk-surface-200)}.dp-day.is-outside{color:var(--shk-surface-400)}.dp-day.is-today{font-weight:700;color:var(--shk-primary-600);background-color:color-mix(in srgb,var(--shk-primary-500) 10%,transparent)}.dp-day.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-day:disabled{opacity:.3;cursor:not-allowed;text-decoration:line-through}.dp-dot{position:absolute;left:50%;bottom:.25rem;width:.25rem;height:.25rem;border-radius:9999px;transform:translate(-50%);background-color:var(--shk-primary-500)}.dp-day.is-selected .dp-dot{background-color:#fff}.dp-chip{padding:.5rem 0;font-size:.8125rem;border-radius:.5rem;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-chip:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-chip.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-chip.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.dp-btn{display:inline-flex;align-items:center;justify-content:center;padding:.4375rem .875rem;font-size:.8125rem;font-weight:500;border-radius:.5rem;border:1px solid var(--shk-surface-200);color:var(--shk-surface-700);background-color:transparent;transition:background-color .15s,border-color .15s;white-space:nowrap}.dp-btn:hover:not(:disabled){background-color:var(--shk-surface-100)}.dark .dp-btn:hover:not(:disabled){background-color:var(--shk-surface-200)}.dp-btn-primary{border-color:var(--shk-primary-500);background-color:var(--shk-primary-500);color:#fff}.dp-btn-primary:hover:not(:disabled){background-color:var(--shk-primary-700)!important;border-color:var(--shk-primary-700)}.dp-btn:disabled{opacity:.5;cursor:not-allowed}.dp-mini-input{width:100%;min-width:0;padding:.4375rem .625rem;font-size:.8125rem;border-radius:.5rem;border:1px solid var(--shk-surface-200);background-color:transparent;color:var(--shk-surface-700);outline:none;transition:border-color .15s,box-shadow .15s}.dp-mini-input:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.dp-mini-input.input-error{border-color:var(--shk-error-500)}.dp-divider{border-color:var(--shk-surface-200)}.dp-time-col{position:relative;flex:1 1 0;min-width:0;overflow-y:auto;scrollbar-width:thin;scroll-behavior:smooth;padding:0 .125rem}.dp-time-col+.dp-time-col{border-left:1px solid var(--shk-surface-200)}.dp-time-item{display:flex;align-items:center;justify-content:center;width:100%;height:2rem;margin:.125rem 0;border-radius:.5rem;font-size:.8125rem;font-variant-numeric:tabular-nums;color:var(--shk-surface-700);transition:background-color .12s,color .12s}.dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-100)}.dark .dp-time-item:hover:not(.is-selected){background-color:var(--shk-surface-200)}.dp-time-item.is-current{font-weight:700;color:var(--shk-primary-600)}.dp-time-item.is-selected{background-color:var(--shk-primary-500);color:#fff;font-weight:600}.date-input-field{width:100%;padding:.5rem 2.5rem .5rem .75rem;font-size:.875rem;border-radius:.5rem;outline:none;transition:border-color .15s,box-shadow .15s;background-color:var(--shk-surface-50);color:var(--shk-surface-700);border:1px solid var(--shk-surface-200);text-overflow:ellipsis}:host-context(.dark) .date-input-field,.dark .date-input-field{background-color:var(--shk-surface-100)}.date-input-field::placeholder{color:var(--shk-surface-400)}.date-input-field:focus{border-color:var(--shk-primary-500);box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-primary-500) 22%,transparent)}.date-input-field:disabled{background-color:var(--shk-surface-100);color:var(--shk-surface-500);cursor:not-allowed}:host-context(.dark) .date-input-field:disabled,.dark .date-input-field:disabled{background-color:var(--shk-surface-50);color:var(--shk-surface-400)}.date-input-field.input-error,:host-context(.dark) .date-input-field.input-error,.dark .date-input-field.input-error{border-color:var(--shk-error-500)}.date-input-field.input-error:focus,:host-context(.dark) .date-input-field.input-error:focus,.dark .date-input-field.input-error:focus{box-shadow:0 0 0 3px color-mix(in srgb,var(--shk-error-500) 22%,transparent)}.date-input-field.input-valid,:host-context(.dark) .date-input-field.input-valid,.dark .date-input-field.input-valid{border-color:#22c55e}.date-input-field.input-valid:focus,:host-context(.dark) .date-input-field.input-valid:focus,.dark .date-input-field.input-valid:focus{box-shadow:0 0 0 3px #22c55e33}\n"]
1427
+ }]
1428
+ }],
1429
+ ctorParameters: () => [],
1430
+ propDecorators: {
1431
+ id: [{
1432
+ type: i0.Input,
1433
+ args: [{
1434
+ isSignal: true,
1435
+ alias: "id",
1436
+ required: false
1437
+ }]
1438
+ }],
1439
+ view: [{
1440
+ type: i0.Input,
1441
+ args: [{
1442
+ isSignal: true,
1443
+ alias: "view",
1444
+ required: false
1445
+ }]
1446
+ }],
1447
+ weekStart: [{
1448
+ type: i0.Input,
1449
+ args: [{
1450
+ isSignal: true,
1451
+ alias: "weekStart",
1452
+ required: false
1453
+ }]
1454
+ }],
1455
+ range: [{
1456
+ type: i0.Input,
1457
+ args: [{
1458
+ isSignal: true,
1459
+ alias: "range",
1460
+ required: false
1461
+ }]
1462
+ }],
1463
+ markedDates: [{
1464
+ type: i0.Input,
1465
+ args: [{
1466
+ isSignal: true,
1467
+ alias: "markedDates",
1468
+ required: false
1469
+ }]
1470
+ }],
1471
+ label: [{
1472
+ type: i0.Input,
1473
+ args: [{
1474
+ isSignal: true,
1475
+ alias: "label",
1476
+ required: false
1477
+ }]
1478
+ }],
1479
+ placeholder: [{
1480
+ type: i0.Input,
1481
+ args: [{
1482
+ isSignal: true,
1483
+ alias: "placeholder",
1484
+ required: false
1485
+ }]
1486
+ }],
1487
+ formGroup: [{
1488
+ type: i0.Input,
1489
+ args: [{
1490
+ isSignal: true,
1491
+ alias: "formGroup",
1492
+ required: false
1493
+ }]
1494
+ }],
1495
+ controlName: [{
1496
+ type: i0.Input,
1497
+ args: [{
1498
+ isSignal: true,
1499
+ alias: "controlName",
1500
+ required: false
1501
+ }]
1502
+ }],
1503
+ control: [{
1504
+ type: i0.Input,
1505
+ args: [{
1506
+ isSignal: true,
1507
+ alias: "control",
1508
+ required: false
1509
+ }]
1510
+ }],
1511
+ disabled: [{
1512
+ type: i0.Input,
1513
+ args: [{
1514
+ isSignal: true,
1515
+ alias: "disabled",
1516
+ required: false
1517
+ }]
1518
+ }],
1519
+ errors: [{
1520
+ type: i0.Input,
1521
+ args: [{
1522
+ isSignal: true,
1523
+ alias: "errors",
1524
+ required: false
1525
+ }]
1526
+ }],
1527
+ invalid: [{
1528
+ type: i0.Input,
1529
+ args: [{
1530
+ isSignal: true,
1531
+ alias: "invalid",
1532
+ required: false
1533
+ }]
1534
+ }],
1535
+ touched: [{
1536
+ type: i0.Input,
1537
+ args: [{
1538
+ isSignal: true,
1539
+ alias: "touched",
1540
+ required: false
1541
+ }]
1542
+ }],
1543
+ dirty: [{
1544
+ type: i0.Input,
1545
+ args: [{
1546
+ isSignal: true,
1547
+ alias: "dirty",
1548
+ required: false
1549
+ }]
1550
+ }],
1551
+ errorMessage: [{
1552
+ type: i0.Input,
1553
+ args: [{
1554
+ isSignal: true,
1555
+ alias: "errorMessage",
1556
+ required: false
1557
+ }]
1558
+ }],
1559
+ errorMessages: [{
1560
+ type: i0.Input,
1561
+ args: [{
1562
+ isSignal: true,
1563
+ alias: "errorMessages",
1564
+ required: false
1565
+ }]
1566
+ }],
1567
+ minValue: [{
1568
+ type: i0.Input,
1569
+ args: [{
1570
+ isSignal: true,
1571
+ alias: "minValue",
1572
+ required: false
1573
+ }]
1574
+ }],
1575
+ maxValue: [{
1576
+ type: i0.Input,
1577
+ args: [{
1578
+ isSignal: true,
1579
+ alias: "maxValue",
1580
+ required: false
1581
+ }]
1582
+ }],
1583
+ locale: [{
1584
+ type: i0.Input,
1585
+ args: [{
1586
+ isSignal: true,
1587
+ alias: "locale",
1588
+ required: false
1589
+ }]
1590
+ }],
1591
+ dateFormat: [{
1592
+ type: i0.Input,
1593
+ args: [{
1594
+ isSignal: true,
1595
+ alias: "dateFormat",
1596
+ required: false
1597
+ }]
1598
+ }],
1599
+ displayStyle: [{
1600
+ type: i0.Input,
1601
+ args: [{
1602
+ isSignal: true,
1603
+ alias: "displayStyle",
1604
+ required: false
1605
+ }]
1606
+ }],
1607
+ timeOnly: [{
1608
+ type: i0.Input,
1609
+ args: [{
1610
+ isSignal: true,
1611
+ alias: "timeOnly",
1612
+ required: false
1613
+ }]
1614
+ }],
1615
+ showTime: [{
1616
+ type: i0.Input,
1617
+ args: [{
1618
+ isSignal: true,
1619
+ alias: "showTime",
1620
+ required: false
1621
+ }]
1622
+ }],
1623
+ hourFormat: [{
1624
+ type: i0.Input,
1625
+ args: [{
1626
+ isSignal: true,
1627
+ alias: "hourFormat",
1628
+ required: false
1629
+ }]
1630
+ }],
1631
+ showSeconds: [{
1632
+ type: i0.Input,
1633
+ args: [{
1634
+ isSignal: true,
1635
+ alias: "showSeconds",
1636
+ required: false
1637
+ }]
1638
+ }],
1639
+ minuteStep: [{
1640
+ type: i0.Input,
1641
+ args: [{
1642
+ isSignal: true,
1643
+ alias: "minuteStep",
1644
+ required: false
1645
+ }]
1646
+ }],
1647
+ valueFormat: [{
1648
+ type: i0.Input,
1649
+ args: [{
1650
+ isSignal: true,
1651
+ alias: "valueFormat",
1652
+ required: false
1653
+ }]
1654
+ }],
1655
+ overlay: [{
1656
+ type: i0.ViewChild,
1657
+ args: ["overlay", { isSignal: true }]
1658
+ }],
1659
+ anchor: [{
1660
+ type: i0.ViewChild,
1661
+ args: ["anchor", { isSignal: true }]
1662
+ }],
1663
+ panel: [{
1664
+ type: i0.ViewChild,
1665
+ args: ["panel", { isSignal: true }]
1666
+ }],
1667
+ value: [{
1668
+ type: i0.Input,
1669
+ args: [{
1670
+ isSignal: true,
1671
+ alias: "value",
1672
+ required: false
1673
+ }]
1674
+ }, {
1675
+ type: i0.Output,
1676
+ args: ["valueChange"]
1677
+ }],
1678
+ onDocumentClick: [{
1679
+ type: HostListener,
1680
+ args: ["document:click", ["$event"]]
1681
+ }],
1682
+ onViewportChange: [{
1683
+ type: HostListener,
1684
+ args: ["window:resize"]
1685
+ }],
1686
+ onEscape: [{
1687
+ type: HostListener,
1688
+ args: ["document:keydown.escape"]
1689
+ }],
1690
+ touch: [{
1691
+ type: i0.Output,
1692
+ args: ["touch"]
1693
+ }]
1694
+ }
1695
+ });
1440
1696
  export { DatePickerComponent };
1441
- //# sourceMappingURL=shirkasoft-ui-components-date-picker.mjs.map
1697
+
1698
+ //# sourceMappingURL=shirkasoft-ui-components-date-picker.mjs.map