shirkasoft-ui-components 1.13.18 → 2.0.0

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