shirkasoft-ui-components 1.13.16 → 1.13.18

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.
@@ -2,7 +2,6 @@ import * as i1 from '@angular/common';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
4
  import { inject, ElementRef, ChangeDetectorRef, DestroyRef, Injector, input, viewChild, signal, computed, effect, untracked, afterNextRender, forwardRef, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
5
- import * as i2 from '@angular/forms';
6
5
  import { ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
7
6
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
8
7
  import { TranslocoService } from '@jsverse/transloco';
@@ -14,27 +13,16 @@ import { PortalDirective } from 'shirkasoft-ui-components/utils';
14
13
  * Belongs to Shirkasoft.
15
14
  */
16
15
  /**
17
- * Date/time picker implemented as a ControlValueAccessor. Supports choosing a
18
- * day, month or year, optional time selection (with seconds/12-hour format),
19
- * min/max constraints and locale-aware labels.
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.
20
24
  */
21
25
  class DatePickerComponent {
22
- /** Localized range label for a week (e.g. '2 — 8 feb'). */
23
- formatWeekRange(start, end) {
24
- const loc = this.locale();
25
- const dayFmt = new Intl.DateTimeFormat(loc, { day: 'numeric' });
26
- const monthFmt = new Intl.DateTimeFormat(loc, { month: 'short' });
27
- const startLabel = `${dayFmt.format(start)} ${monthFmt.format(start).replace('.', '')}`;
28
- if (start.getMonth() !== end.getMonth() || start.getFullYear() !== end.getFullYear()) {
29
- const year = start.getFullYear() !== end.getFullYear() ? ` ${end.getFullYear()}` : '';
30
- return `${startLabel} — ${dayFmt.format(end)} ${monthFmt.format(end).replace('.', '')}${year}`;
31
- }
32
- return `${startLabel} — ${dayFmt.format(end)}`;
33
- }
34
- /** Localized label for a week row ('Semana N' / 'Week N'). */
35
- weekLabel(index) {
36
- return this.locale() === 'en' ? `Week ${index}` : `Semana ${index}`;
37
- }
38
26
  constructor() {
39
27
  this.elementRef = inject(ElementRef);
40
28
  this.cdr = inject(ChangeDetectorRef);
@@ -45,8 +33,15 @@ class DatePickerComponent {
45
33
  this.id = input('', ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
46
34
  /** Granularity of the picker ('date' | 'week' | 'month' | 'year'). */
47
35
  this.view = input('date', ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
48
- /** First day of the week (0=Sunday ... 6=Saturday), used by week view. */
49
- this.weekStart = input(0, ...(ngDevMode ? [{ debugName: "weekStart" }] : /* 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 */ []));
50
45
  /** Label shown above the input. */
51
46
  this.label = input('', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
52
47
  /** Placeholder of the input. */
@@ -83,7 +78,7 @@ class DatePickerComponent {
83
78
  * Format of the value received from and emitted to the form control.
84
79
  * Tokens: YYYY, MM, DD, HH, mm, ss (e.g. 'DD-MM-YYYY', 'DD/MM/YYYY HH:mm').
85
80
  * Empty (default) keeps the ISO format ('YYYY-MM-DD', 'YYYY-MM', 'YYYY',
86
- * 'YYYY-MM-DDTHH:mm', 'HH:mm').
81
+ * 'YYYY-MM-DDTHH:mm', 'HH:mm'). In range mode it applies to each end.
87
82
  */
88
83
  this.valueFormat = input('', ...(ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []));
89
84
  /** Overlay (backdrop + calendar), rendered in <body> while open (shkPortal). */
@@ -96,55 +91,59 @@ class DatePickerComponent {
96
91
  this.panelPosition = signal(null, ...(ngDevMode ? [{ debugName: "panelPosition" }] : /* istanbul ignore next */ []));
97
92
  /** Whether the dropdown calendar is open. */
98
93
  this.isOpen = signal(false, ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
99
- /** Year currently displayed in the calendar. */
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). */
100
97
  this.viewYear = signal(new Date().getFullYear(), ...(ngDevMode ? [{ debugName: "viewYear" }] : /* istanbul ignore next */ []));
101
- /** Month currently displayed in the calendar (0-based). */
98
+ /** Month currently displayed, 0-based (first month in range mode). */
102
99
  this.viewMonth = signal(new Date().getMonth(), ...(ngDevMode ? [{ debugName: "viewMonth" }] : /* istanbul ignore next */ []));
103
- /** Starting year of the decade shown in year view. */
104
- this.viewDecade = signal(Math.floor(new Date().getFullYear() / 10) * 10, ...(ngDevMode ? [{ debugName: "viewDecade" }] : /* istanbul ignore next */ []));
105
- /** Hour selected in the time selectors. */
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. */
106
103
  this.viewHour = signal(0, ...(ngDevMode ? [{ debugName: "viewHour" }] : /* istanbul ignore next */ []));
107
- /** Minute selected in the time selectors. */
104
+ /** Minute selected on the clock. */
108
105
  this.viewMinute = signal(0, ...(ngDevMode ? [{ debugName: "viewMinute" }] : /* istanbul ignore next */ []));
109
- /** Second selected in the time selectors. */
106
+ /** Second selected in the seconds selector. */
110
107
  this.viewSecond = signal(0, ...(ngDevMode ? [{ debugName: "viewSecond" }] : /* istanbul ignore next */ []));
111
- /** Meridiem selected in 12-hour format. */
112
- this.viewMeridiem = signal('AM', ...(ngDevMode ? [{ debugName: "viewMeridiem" }] : /* istanbul ignore next */ []));
113
- /** Date part selected but not yet committed until the time is confirmed. */
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). */
114
111
  this.pendingDate = signal(null, ...(ngDevMode ? [{ debugName: "pendingDate" }] : /* istanbul ignore next */ []));
115
- /** Selected year during the selection flow (year -> month -> day). */
116
- this.selectedYearValue = signal(null, ...(ngDevMode ? [{ debugName: "selectedYearValue" }] : /* istanbul ignore next */ []));
117
- /** Selected month during the selection flow. */
118
- this.selectedMonthValue = signal(null, ...(ngDevMode ? [{ debugName: "selectedMonthValue" }] : /* istanbul ignore next */ []));
119
- /** Analog clock mode: 'hours' or 'minutes'. */
120
- this.clockMode = signal('hours', ...(ngDevMode ? [{ debugName: "clockMode" }] : /* istanbul ignore next */ []));
121
- /** Internal view state for drill-down navigation (separates from input `view`). */
122
- this.currentView = signal('year', ...(ngDevMode ? [{ debugName: "currentView" }] : /* istanbul ignore next */ []));
123
- /** Whether the user is typing in the input field. */
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. */
124
125
  this.isTyping = signal(false, ...(ngDevMode ? [{ debugName: "isTyping" }] : /* istanbul ignore next */ []));
125
126
  /** The raw text being typed by the user. */
126
127
  this.typedValue = signal('', ...(ngDevMode ? [{ debugName: "typedValue" }] : /* istanbul ignore next */ []));
127
128
  /** Whether the typed value is valid. */
128
129
  this.typingValid = signal(null, ...(ngDevMode ? [{ debugName: "typingValid" }] : /* istanbul ignore next */ []));
129
- /** Underlying value (mirrors the reactive control). */
130
+ /** Underlying value: ISO string, or "start|end" ISO pair in range mode. */
130
131
  this._value = signal(null, ...(ngDevMode ? [{ debugName: "_value" }] : /* istanbul ignore next */ []));
131
132
  /** Disabled state coming from the reactive form infrastructure. */
132
133
  this._disabledState = signal(false, ...(ngDevMode ? [{ debugName: "_disabledState" }] : /* istanbul ignore next */ []));
133
- /** Whether status subscriptions have been attached to the control. */
134
134
  this.subscribed = signal(false, ...(ngDevMode ? [{ debugName: "subscribed" }] : /* istanbul ignore next */ []));
135
135
  this.valueSubscribed = signal(false, ...(ngDevMode ? [{ debugName: "valueSubscribed" }] : /* istanbul ignore next */ []));
136
136
  /** Counter used to recompute the error helpers reactively. */
137
137
  this.errorTracker = signal(0, ...(ngDevMode ? [{ debugName: "errorTracker" }] : /* istanbul ignore next */ []));
138
138
  /** Whether an error was displayed at some point. */
139
139
  this.hadError = signal(false, ...(ngDevMode ? [{ debugName: "hadError" }] : /* istanbul ignore next */ []));
140
- /** ControlValueAccessor callbacks. */
141
140
  this.onChange = () => { };
142
141
  this.onTouched = () => { };
143
- /** Current value of the picker. */
142
+ /** Current value of the picker (internal ISO representation). */
144
143
  this.value = computed(() => this._value(), ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
145
144
  /** Whether the picker is disabled (input or reactive form). */
146
145
  this.isDisabled = computed(() => this.disabled() || this._disabledState(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
147
- /** Resolves the control from `control` input or `formGroup`+`label`. */
146
+ /** Resolves the control from `control` input or `formGroup`+`controlName`. */
148
147
  this.actualControl = computed(() => {
149
148
  const ctrl = this.control();
150
149
  if (ctrl)
@@ -157,19 +156,16 @@ class DatePickerComponent {
157
156
  return undefined;
158
157
  return fg.get(name) ?? undefined;
159
158
  }, ...(ngDevMode ? [{ debugName: "actualControl" }] : /* istanbul ignore next */ []));
160
- /** Whether the bound control should show its error message. */
161
159
  this.shouldShowError = computed(() => {
162
160
  this.errorTracker();
163
161
  const ctrl = this.actualControl();
164
162
  return ctrl?.invalid && (ctrl?.dirty || ctrl?.touched);
165
163
  }, ...(ngDevMode ? [{ debugName: "shouldShowError" }] : /* istanbul ignore next */ []));
166
- /** Whether an error was fixed (invalid before, now valid and touched). */
167
164
  this.wasFixedError = computed(() => {
168
165
  this.errorTracker();
169
166
  const ctrl = this.actualControl();
170
167
  return this.hadError() && ctrl?.valid && ctrl?.touched;
171
168
  }, ...(ngDevMode ? [{ debugName: "wasFixedError" }] : /* istanbul ignore next */ []));
172
- /** Validation error messages to display, custom or translated. */
173
169
  this.getErrorMessages = computed(() => {
174
170
  this.errorTracker();
175
171
  const customError = this.errorMessage();
@@ -179,37 +175,64 @@ class DatePickerComponent {
179
175
  if (!ctrl?.errors)
180
176
  return [];
181
177
  const customErrors = this.errorMessages();
182
- const t = this.transloco;
183
178
  return Object.keys(ctrl.errors).map((key) => {
184
179
  if (customErrors[key])
185
180
  return customErrors[key];
186
- switch (key) {
187
- case 'required':
188
- return t.translate('validation.required');
189
- default:
190
- return t.translate('validation.invalid');
191
- }
181
+ return key === 'required'
182
+ ? this.transloco.translate('validation.required')
183
+ : this.transloco.translate('validation.invalid');
192
184
  });
193
185
  }, ...(ngDevMode ? [{ debugName: "getErrorMessages" }] : /* istanbul ignore next */ []));
194
- /** Date part displayed in the calendar (pending date or committed value). */
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). */
195
217
  this.displayedDate = computed(() => {
196
- if (this.timeOnly())
218
+ if (this.timeOnly() || this.range())
197
219
  return null;
198
- const value = this.pendingDate();
199
- if (value)
200
- return value;
220
+ const pending = this.pendingDate();
221
+ if (pending)
222
+ return pending;
201
223
  const current = this._value();
202
- if (!current)
203
- return null;
204
- return this.datePartOf(current);
224
+ return current ? this.datePartOf(current) : null;
205
225
  }, ...(ngDevMode ? [{ debugName: "displayedDate" }] : /* istanbul ignore next */ []));
206
- /** Human-readable label for the selected value in the input. */
226
+ /** Human-readable label for the selected value in the main input. */
207
227
  this.displayLabel = computed(() => {
208
228
  const value = this._value();
209
229
  if (!value)
210
230
  return '';
211
- if (this.timeOnly()) {
231
+ if (this.timeOnly())
212
232
  return this.formatTimeFromValue(value);
233
+ if (this.range()) {
234
+ const [start, end] = value.split('|');
235
+ return `${this.formatMedium(start)} – ${this.formatMedium(end)}`;
213
236
  }
214
237
  const datePart = this.datePartOf(value);
215
238
  const timePart = value.includes('T') ? value.split('T')[1] : null;
@@ -220,172 +243,191 @@ class DatePickerComponent {
220
243
  }
221
244
  else if (v === 'month') {
222
245
  const [y, m] = datePart.split('-').map(Number);
223
- const fmt = new Intl.DateTimeFormat(this.locale(), {
224
- month: 'long',
225
- year: 'numeric',
226
- });
227
- label = fmt.format(new Date(y, m - 1, 1));
228
- label = label.charAt(0).toUpperCase() + label.slice(1);
246
+ label = this.capitalize(new Intl.DateTimeFormat(this.locale(), { month: 'long', year: 'numeric' }).format(new Date(y, m - 1, 1)));
229
247
  }
230
248
  else if (v === 'week') {
231
- const start = new Date(datePart + 'T12:00:00');
232
- label = this.formatWeekRange(start, new Date(start.getFullYear(), start.getMonth(), start.getDate() + 6));
249
+ const start = this.parseISO(datePart);
250
+ label = this.formatWeekRange(start, this.addDays(start, 6));
233
251
  }
234
252
  else {
235
- const fmt = new Intl.DateTimeFormat(this.locale(), {
236
- dateStyle: 'long',
237
- });
238
- label = fmt.format(new Date(datePart + 'T12:00:00'));
253
+ label = new Intl.DateTimeFormat(this.locale(), { dateStyle: 'long' }).format(this.parseISO(datePart));
239
254
  }
240
- if (this.showTime() && timePart) {
255
+ if (this.showTime() && timePart)
241
256
  label += ' ' + this.formatTimeFromValue(timePart);
242
- }
243
257
  return label;
244
258
  }, ...(ngDevMode ? [{ debugName: "displayLabel" }] : /* istanbul ignore next */ []));
245
- /** Localized short month names for the year view. */
259
+ /** Localized short month names (Ene, Feb...). */
246
260
  this.monthNames = computed(() => {
247
261
  const fmt = new Intl.DateTimeFormat(this.locale(), { month: 'short' });
248
- return Array.from({ length: 12 }, (_, i) => {
249
- const name = fmt.format(new Date(2000, i, 1)).replace('.', '');
250
- return name.charAt(0).toUpperCase() + name.slice(1);
251
- });
262
+ return Array.from({ length: 12 }, (_, i) => this.capitalize(fmt.format(new Date(2000, i, 1)).replace('.', '')));
252
263
  }, ...(ngDevMode ? [{ debugName: "monthNames" }] : /* istanbul ignore next */ []));
253
- /** Localized short weekday names for the calendar header. */
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`. */
254
270
  this.dayNames = computed(() => {
255
271
  const fmt = new Intl.DateTimeFormat(this.locale(), { weekday: 'short' });
272
+ const first = this.firstDayOfWeek();
273
+ // 2024-01-07 is a Sunday.
256
274
  return Array.from({ length: 7 }, (_, i) => {
257
- const name = fmt.format(new Date(2024, 0, i + 1));
258
- return name.charAt(0).toUpperCase() + name.slice(1, 3);
275
+ const name = fmt.format(new Date(2024, 0, 7 + ((first + i) % 7))).replace('.', '');
276
+ return this.capitalize(name.slice(0, 2));
259
277
  });
260
278
  }, ...(ngDevMode ? [{ debugName: "dayNames" }] : /* istanbul ignore next */ []));
261
- /** Number of days in the currently viewed month. */
262
- this.daysInMonth = computed(() => {
263
- return new Date(this.viewYear(), this.viewMonth() + 1, 0).getDate();
264
- }, ...(ngDevMode ? [{ debugName: "daysInMonth" }] : /* istanbul ignore next */ []));
265
- /** Weekday index (0=Sunday) of the first day of the viewed month. */
266
- this.firstDayOfMonth = computed(() => {
267
- return new Date(this.viewYear(), this.viewMonth(), 1).getDay();
268
- }, ...(ngDevMode ? [{ debugName: "firstDayOfMonth" }] : /* istanbul ignore next */ []));
269
- /** Calendar grid: nulls for leading blanks then the days of the month. */
270
- this.calendarDays = computed(() => {
271
- const totalDays = this.daysInMonth();
272
- const firstDay = this.firstDayOfMonth();
273
- const days = [];
274
- for (let i = 0; i < firstDay; i++)
275
- days.push(null);
276
- for (let i = 1; i <= totalDays; i++)
277
- days.push(i);
278
- return days;
279
- }, ...(ngDevMode ? [{ debugName: "calendarDays" }] : /* istanbul ignore next */ []));
280
- /** Weeks of the viewed month (rows aligned to `weekStart`), for week view. */
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. */
281
293
  this.monthWeeks = computed(() => {
282
294
  const year = this.viewYear();
283
295
  const month = this.viewMonth();
284
- const ws = this.weekStart();
285
296
  const first = new Date(year, month, 1);
286
297
  const last = new Date(year, month + 1, 0);
287
- const anchor = new Date(first.getFullYear(), first.getMonth(), first.getDate() - ((first.getDay() - ws + 7) % 7));
298
+ let cursor = this.startOfWeek(first);
288
299
  const weeks = [];
289
- let cursor = anchor;
290
300
  let index = 0;
291
301
  while (cursor.getTime() <= last.getTime()) {
292
302
  index++;
293
303
  const start = cursor;
294
- const end = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 6);
304
+ const end = this.addDays(start, 6);
295
305
  weeks.push({ index, start, end, range: this.formatWeekRange(start, end) });
296
- cursor = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 7);
306
+ cursor = this.addDays(start, 7);
297
307
  }
298
308
  return weeks;
299
309
  }, ...(ngDevMode ? [{ debugName: "monthWeeks" }] : /* istanbul ignore next */ []));
300
- /** Whether the prev navigation button is allowed by `minValue`. */
301
- this.canGoPrev = computed(() => {
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(() => {
302
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(() => {
303
326
  const min = this.minValue();
327
+ if (!min)
328
+ return true;
329
+ const minY = Number(min.slice(0, 4));
330
+ const v = this.currentView();
304
331
  if (v === 'date' || v === 'week') {
305
- if (!min)
306
- return true;
307
- const prev = new Date(this.viewYear(), this.viewMonth() - 1, 1);
308
- return prev >= new Date(min + 'T12:00:00');
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);
309
335
  }
310
- if (v === 'month') {
311
- const minY = min ? Number(min.split('-')[0]) : undefined;
312
- return minY === undefined || this.viewYear() > minY;
313
- }
314
- // year view
315
- const minY = min ? Number(min.split('-')[0]) : undefined;
316
- return minY === undefined || this.viewYear() > minY;
336
+ if (v === 'month')
337
+ return this.viewYear() > minY;
338
+ return this.viewDecade() > minY;
317
339
  }, ...(ngDevMode ? [{ debugName: "canGoPrev" }] : /* istanbul ignore next */ []));
318
- /** Whether the next navigation button is allowed by `maxValue`. */
340
+ /** Whether › is allowed by `maxValue`. */
319
341
  this.canGoNext = computed(() => {
320
- const v = this.currentView();
321
342
  const max = this.maxValue();
343
+ if (!max)
344
+ return true;
345
+ const maxY = Number(max.slice(0, 4));
346
+ const v = this.currentView();
322
347
  if (v === 'date' || v === 'week') {
323
- if (!max)
324
- return true;
325
- const next = new Date(this.viewYear(), this.viewMonth() + 1, 1);
326
- return next <= new Date(max + 'T12:00:00');
327
- }
328
- if (v === 'month') {
329
- const maxY = max ? Number(max.split('-')[0]) : undefined;
330
- return maxY === undefined || this.viewYear() < maxY;
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);
331
352
  }
332
- // year view
333
- const maxY = max ? Number(max.split('-')[0]) : undefined;
334
- return maxY === undefined || this.viewYear() < maxY;
353
+ if (v === 'month')
354
+ return this.viewYear() < maxY;
355
+ return this.viewDecade() + 11 < maxY;
335
356
  }, ...(ngDevMode ? [{ debugName: "canGoNext" }] : /* istanbul ignore next */ []));
336
- /** Year of the displayed date, if any. */
337
- this.selectedYear = computed(() => {
338
- const value = this.displayedDate();
339
- return value ? Number(value.split('-')[0]) : null;
340
- }, ...(ngDevMode ? [{ debugName: "selectedYear" }] : /* istanbul ignore next */ []));
341
- /** Month index (0-based) of the displayed date, if any. */
342
- this.selectedMonth = computed(() => {
343
- const value = this.displayedDate();
344
- return value ? Number(value.split('-')[1]) - 1 : null;
345
- }, ...(ngDevMode ? [{ debugName: "selectedMonth" }] : /* istanbul ignore next */ []));
346
- /** Day of the displayed date, if any (date view only). */
347
- this.selectedDay = computed(() => {
348
- const value = this.displayedDate();
349
- return value && this.view() === 'date' ? Number(value.split('-')[2]) : null;
350
- }, ...(ngDevMode ? [{ debugName: "selectedDay" }] : /* istanbul ignore next */ []));
351
- /** 12 years of the viewed decade for the year view. */
352
- this.decadeYears = computed(() => {
353
- const start = this.viewDecade();
354
- return Array.from({ length: 12 }, (_, i) => start + i);
355
- }, ...(ngDevMode ? [{ debugName: "decadeYears" }] : /* istanbul ignore next */ []));
356
- /** Angle (in degrees) of the analog clock hand based on current mode. */
357
- this.clockHandAngle = computed(() => {
358
- if (this.clockMode() === 'hours') {
359
- const h = this.viewHour();
360
- const display = this.hourFormat() === '12' ? h % 12 || 12 : h % 12 || 12;
361
- return (display % 12) * 30;
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
+ }));
362
391
  }
363
- return this.viewMinute() * 6;
364
- }, ...(ngDevMode ? [{ debugName: "clockHandAngle" }] : /* istanbul ignore next */ []));
365
- /** Hours to display on the analog clock face (1-12). */
366
- this.clockHours = computed(() => Array.from({ length: 12 }, (_, i) => i + 1), ...(ngDevMode ? [{ debugName: "clockHours" }] : /* istanbul ignore next */ []));
367
- /** Minutes to display on the analog clock face (0-55, step 5). */
368
- this.clockMinutes = computed(() => Array.from({ length: 12 }, (_, i) => i * 5), ...(ngDevMode ? [{ debugName: "clockMinutes" }] : /* istanbul ignore next */ []));
369
- /** The input format string based on locale. */
370
- this.inputFormat = computed(() => {
371
- const loc = this.locale();
372
- return loc === 'en' ? 'MM/DD/YYYY' : 'DD/MM/YYYY';
373
- }, ...(ngDevMode ? [{ debugName: "inputFormat" }] : /* istanbul ignore next */ []));
374
- /** (Unused legacy placeholder) plain year list. */
375
- this.years = [];
376
- // Scroll de la pagina o de cualquier contenedor (modal, tabla...): el
377
- // calendario sigue a su campo. En captura porque el scroll no burbujea.
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.
378
406
  const doc = this.elementRef.nativeElement.ownerDocument;
379
407
  const onScroll = () => this.onViewportChange();
380
408
  doc.addEventListener('scroll', onScroll, true);
381
- this.destroyRef.onDestroy(() => doc.removeEventListener('scroll', onScroll, true));
382
- // Cada vista (anio, mes, dia, hora) tiene otro alto: se recoloca al cambiar.
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.
383
414
  effect(() => {
384
415
  this.currentView();
385
- this.clockMode();
386
416
  if (untracked(() => this.isOpen()))
387
417
  this.schedulePosition();
388
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
+ });
389
431
  // Attach error-state subscriptions to the validated control once found.
390
432
  effect(() => {
391
433
  const ctrl = this.actualControl();
@@ -397,9 +439,7 @@ class DatePickerComponent {
397
439
  return;
398
440
  if (ctrl.invalid && ctrl.touched)
399
441
  this.hadError.set(true);
400
- ctrl.statusChanges
401
- .pipe(takeUntilDestroyed(this.destroyRef))
402
- .subscribe(() => {
442
+ ctrl.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
403
443
  this.errorTracker.update((v) => v + 1);
404
444
  if (ctrl.invalid && ctrl.touched)
405
445
  this.hadError.set(true);
@@ -409,20 +449,18 @@ class DatePickerComponent {
409
449
  // One-way sync from the reactive control to the internal value signal.
410
450
  effect(() => {
411
451
  const ctrl = this.actualControl();
412
- if (!ctrl)
452
+ if (!ctrl || this.valueSubscribed())
413
453
  return;
414
- if (!this.valueSubscribed()) {
415
- this.writeValue(ctrl.value);
416
- ctrl.valueChanges
417
- .pipe(takeUntilDestroyed(this.destroyRef))
418
- .subscribe((value) => {
419
- this.writeValue(value);
420
- });
421
- this.valueSubscribed.set(true);
422
- }
454
+ this.writeValue(ctrl.value);
455
+ ctrl.valueChanges
456
+ .pipe(takeUntilDestroyed(this.destroyRef))
457
+ .subscribe((value) => this.writeValue(value));
458
+ this.valueSubscribed.set(true);
423
459
  });
424
460
  }
425
- /** Closes the dropdown when clicking outside the component. */
461
+ // ---------------------------------------------------------------------------
462
+ // Overlay
463
+ // ---------------------------------------------------------------------------
426
464
  onDocumentClick(event) {
427
465
  if (!this.isOpen())
428
466
  return;
@@ -432,23 +470,17 @@ class DatePickerComponent {
432
470
  this.close();
433
471
  }
434
472
  }
435
- /** Keeps the calendar next to its field when the page scrolls or resizes. */
436
473
  onViewportChange() {
437
474
  if (this.isOpen())
438
475
  this.positionPanel();
439
476
  }
440
- /**
441
- * Positions the panel right after Angular renders it. A bare
442
- * requestAnimationFrame can run before the render (e.g. with eventCoalescing),
443
- * find no panel and leave the calendar hidden forever.
444
- */
477
+ onEscape() {
478
+ this.close();
479
+ }
445
480
  schedulePosition() {
446
481
  afterNextRender(() => this.positionPanel(), { injector: this.injector });
447
482
  }
448
- /**
449
- * Places the calendar right below the field; above it when there is no room
450
- * below, and always inside the viewport (8px margin).
451
- */
483
+ /** Places the calendar below the field (above if no room), inside the viewport. */
452
484
  positionPanel() {
453
485
  const anchor = this.anchor()?.nativeElement;
454
486
  const panel = this.panel()?.nativeElement;
@@ -467,165 +499,258 @@ class DatePickerComponent {
467
499
  const left = Math.max(margin, Math.min(rect.left, window.innerWidth - width - margin));
468
500
  this.panelPosition.set({ top, left });
469
501
  }
470
- /** Closes the dropdown on Escape. */
471
- onEscape() {
472
- this.close();
473
- }
474
502
  /** Opens/closes the dropdown, syncing the calendar to the current value. */
475
503
  toggle() {
476
504
  if (this.isDisabled())
477
505
  return;
478
506
  if (this.isOpen()) {
479
507
  this.close();
508
+ return;
480
509
  }
481
- else {
482
- this.syncViewToValue();
483
- this.currentView.set(this.view() === 'week' ? 'week' : 'year');
484
- this.selectedYearValue.set(null);
485
- this.selectedMonthValue.set(null);
486
- this.clockMode.set('hours');
487
- this.isTyping.set(false);
488
- this.panelPosition.set(null);
489
- this.isOpen.set(true);
490
- // Se mide cuando el panel ya esta en el DOM (oculto hasta entonces).
491
- this.schedulePosition();
492
- }
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);
493
537
  }
494
- /** Aligns the calendar view signals with the current value (or today). */
538
+ /** Aligns the calendar and the pending selection with the current value. */
495
539
  syncViewToValue() {
496
540
  const val = this._value();
497
- const v = this.view();
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);
498
546
  if (!val) {
499
- const now = new Date();
500
- this.viewYear.set(now.getFullYear());
501
- this.viewMonth.set(now.getMonth());
502
- this.viewDecade.set(Math.floor(now.getFullYear() / 10) * 10);
503
- this.viewHour.set(now.getHours());
504
- this.viewMinute.set(now.getMinutes());
505
- this.viewSecond.set(now.getSeconds());
506
- this.pendingDate.set(this.toISODate(now));
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);
507
560
  return;
508
561
  }
509
562
  const datePart = this.datePartOf(val);
510
- const timePart = val.includes('T') ? val.split('T')[1] : undefined;
563
+ const v = this.view();
511
564
  if (v === 'year') {
512
565
  this.viewYear.set(Number(datePart));
513
- this.viewDecade.set(Math.floor(Number(datePart) / 10) * 10);
566
+ this.viewDecade.set(this.decadeOf(Number(datePart)));
514
567
  }
515
568
  else if (v === 'month') {
516
- this.viewYear.set(Number(datePart.split('-')[0]));
517
- }
518
- else if (v === 'week') {
519
- const d = new Date(datePart + 'T12:00:00');
520
- this.viewYear.set(d.getFullYear());
521
- this.viewMonth.set(d.getMonth());
569
+ this.viewYear.set(Number(datePart.slice(0, 4)));
570
+ this.viewMonth.set(Number(datePart.slice(5, 7)) - 1);
522
571
  }
523
572
  else {
524
- const d = new Date(datePart + 'T12:00:00');
525
- this.viewYear.set(d.getFullYear());
526
- this.viewMonth.set(d.getMonth());
527
- }
528
- const time = timePart ?? (this.timeOnly() ? val : undefined);
529
- if (time) {
530
- const [h, m, ss] = time.split(':').map(Number);
531
- this.viewHour.set(h || 0);
532
- this.viewMinute.set(m || 0);
533
- this.viewSecond.set(ss || 0);
534
- if (this.hourFormat() === '12') {
535
- this.viewMeridiem.set(h >= 12 ? 'PM' : 'AM');
536
- }
573
+ this.goToDate(this.parseISO(datePart));
537
574
  }
575
+ if (val.includes('T'))
576
+ this.setClockFrom(val.split('T')[1]);
538
577
  this.pendingDate.set(datePart);
539
578
  }
540
- /** Closes the dropdown, marks the control as touched and refreshes errors. */
541
- close() {
542
- if (!this.isOpen())
543
- return;
544
- this.isOpen.set(false);
545
- this.onTouched();
546
- const ctrl = this.actualControl();
547
- if (ctrl)
548
- ctrl.markAsTouched();
549
- this.errorTracker.update((v) => v + 1);
550
- if (ctrl?.invalid && ctrl?.touched)
551
- this.hadError.set(true);
552
- }
553
- /** Navigates the calendar to the previous year/month/decade. */
579
+ // ---------------------------------------------------------------------------
580
+ // Navigation
581
+ // ---------------------------------------------------------------------------
582
+ /** ‹ : previous month (days/weeks), year (months) or 12 years (years). */
554
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) {
555
591
  const v = this.currentView();
556
592
  if (v === 'year') {
557
- this.viewDecade.update((d) => d - 12);
558
- this.viewYear.update((y) => y - 12);
593
+ this.viewDecade.update((d) => d + 12 * dir);
559
594
  }
560
595
  else if (v === 'month') {
561
- this.viewYear.update((y) => y - 1);
596
+ this.viewYear.update((y) => y + dir);
562
597
  }
563
598
  else {
564
- this.viewMonth.update((m) => {
565
- if (m === 0) {
566
- this.viewYear.update((y) => y - 1);
567
- return 11;
568
- }
569
- return m - 1;
570
- });
599
+ this.goToDate(new Date(this.viewYear(), this.viewMonth() + dir, 1));
571
600
  }
572
601
  }
573
- /** Navigates the calendar to the next year/month/decade. */
574
- next() {
602
+ /** Clicking the title zooms out: days → months → years. */
603
+ zoomOut() {
575
604
  const v = this.currentView();
576
- if (v === 'year') {
577
- this.viewDecade.update((d) => d + 12);
578
- this.viewYear.update((y) => y + 12);
605
+ if (v === 'date' || v === 'week') {
606
+ this.currentView.set('month');
579
607
  }
580
608
  else if (v === 'month') {
581
- this.viewYear.update((y) => y + 1);
609
+ this.viewDecade.set(this.decadeOf(this.viewYear()));
610
+ this.currentView.set('year');
582
611
  }
583
- else {
584
- this.viewMonth.update((m) => {
585
- if (m === 11) {
586
- this.viewYear.update((y) => y + 1);
587
- return 0;
588
- }
589
- return m + 1;
590
- });
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);
591
625
  }
592
626
  }
593
- /** Selects a year - stores it and navigates to month selection. */
594
- selectYear(year) {
595
- this.selectedYearValue.set(year);
596
- this.viewYear.set(year);
597
- this.currentView.set('month');
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
+ }
598
678
  }
599
- /** Selects a month - stores it and navigates to day selection. */
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. */
600
700
  selectMonth(monthIndex) {
601
- this.selectedMonthValue.set(monthIndex);
602
701
  this.viewMonth.set(monthIndex);
603
- this.currentView.set('date');
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');
604
708
  }
605
- /** Selects a day - completes the date selection. */
606
- selectDay(day) {
607
- const year = this.selectedYearValue() ?? this.viewYear();
608
- const month = this.selectedMonthValue() ?? this.viewMonth();
609
- const m = String(month + 1).padStart(2, '0');
610
- const d = String(day).padStart(2, '0');
611
- const value = `${year}-${m}-${d}`;
612
- if (this.showTime()) {
613
- this.pendingDate.set(value);
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));
614
714
  return;
615
715
  }
616
- this.setValue(value);
716
+ this.currentView.set('month');
617
717
  }
618
- /** Selects a week - emits its start date (YYYY-MM-DD). */
718
+ /** Selects a week (emits its start date YYYY-MM-DD). */
619
719
  selectWeek(start) {
620
- const value = `${start.getFullYear()}-` +
621
- `${String(start.getMonth() + 1).padStart(2, '0')}-` +
622
- `${String(start.getDate()).padStart(2, '0')}`;
720
+ const value = this.toISODate(start);
623
721
  if (this.showTime()) {
624
722
  this.pendingDate.set(value);
625
723
  return;
626
724
  }
627
725
  this.setValue(value);
628
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
+ }
629
754
  setValue(value, close = true) {
630
755
  this._value.set(value);
631
756
  const output = this.toOutputValue(value);
@@ -638,452 +763,451 @@ class DatePickerComponent {
638
763
  if (close)
639
764
  this.close();
640
765
  }
641
- /** Confirms the selected time and commits the combined date+time value. */
642
- confirmTime() {
643
- const h = this.viewHour();
644
- const m = this.viewMinute();
645
- const s = this.viewSecond();
646
- let time = `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
647
- if (this.showSeconds())
648
- time += `:${String(s).padStart(2, '0')}`;
649
- if (this.timeOnly()) {
650
- this.setValue(time);
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);
651
775
  return;
652
776
  }
653
- const datePart = this.pendingDate() ??
654
- `${this.viewYear()}-${String(this.viewMonth() + 1).padStart(2, '0')}-01`;
655
- this.setValue(`${datePart}T${time}`);
656
- }
657
- /** Reads the hour selected in the time selector. */
658
- onHourChange(event) {
659
- this.viewHour.set(Number(event.target.value));
660
- }
661
- /** Reads the minute selected in the time selector. */
662
- onMinuteChange(event) {
663
- this.viewMinute.set(Number(event.target.value));
664
- }
665
- /** Reads the second selected in the time selector. */
666
- onSecondChange(event) {
667
- this.viewSecond.set(Number(event.target.value));
668
- }
669
- /** Current meridiem ("AM"/"PM") for the 12-hour format. */
670
- meridiem() {
671
- return this.viewMeridiem();
672
- }
673
- /** Reads the meridiem selected in the time selector. */
674
- onMeridiemChange(event) {
675
- this.viewMeridiem.set(event.target.value);
676
- }
677
- /** Splits the date part from a full ISO "date" or "dateTtime" value. */
678
- datePartOf(value) {
679
- const i = value.indexOf('T');
680
- return i >= 0 ? value.slice(0, i) : value;
681
- }
682
- /** Formats a raw time string ("HH:mm[:ss]") using the configured format. */
683
- formatTimeFromValue(time) {
684
- const [h, m, ss] = time.split(':').map(Number);
685
- return this.formatTime(h || 0, m || 0, ss || 0);
686
- }
687
- /** Formats hour/minute/second according to hour format and seconds option. */
688
- formatTime(h, m, s) {
689
- if (this.hourFormat() === '12') {
690
- const h12 = h % 12 || 12;
691
- const suffix = h < 12 ? ' AM' : ' PM';
692
- return `${String(h12).padStart(2, '0')}:${String(m).padStart(2, '0')}${suffix}`;
777
+ const iso = this.parseDateText(text);
778
+ if (!iso || this.isDisabledDate(iso)) {
779
+ this.panelTextError.set(which);
780
+ return;
693
781
  }
694
- let label = `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
695
- if (this.showSeconds())
696
- label += `:${String(s).padStart(2, '0')}`;
697
- return label;
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;
698
839
  }
699
- /** Formats a Date as a YYYY-MM-DD ISO string. */
700
- toISODate(date) {
701
- return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
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;
702
845
  }
703
- /** Whether the given day matches the currently selected date. */
704
- isSelectedDay(day) {
705
- return (this.selectedYear() === this.viewYear() &&
706
- this.selectedMonth() === this.viewMonth() &&
707
- this.selectedDay() === day);
846
+ isCurrentMonth(monthIndex) {
847
+ const now = new Date();
848
+ return this.viewYear() === now.getFullYear() && monthIndex === now.getMonth();
708
849
  }
709
- /** Hours available in the time selector ('12' maps to 0..11 or 12..23). */
710
- hoursRange() {
711
- if (this.hourFormat() === '12') {
712
- const oneToTwelve = Array.from({ length: 12 }, (_, i) => i + 1);
713
- return this.viewMeridiem() === 'PM'
714
- ? oneToTwelve.map((h) => (h === 12 ? 12 : h + 12))
715
- : oneToTwelve.map((h) => (h === 12 ? 0 : h));
716
- }
717
- return Array.from({ length: 24 }, (_, i) => i);
850
+ isSelectedYear(year) {
851
+ const d = this.displayedDate() ?? this.rangeStart();
852
+ return !!d && Number(d.slice(0, 4)) === year;
718
853
  }
719
- /** Minutes available in the time selector, stepped by `minuteStep`. */
720
- minutesRange() {
721
- const step = this.minuteStep();
722
- return Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step);
854
+ isCurrentYear(year) {
855
+ return new Date().getFullYear() === year;
723
856
  }
724
- /** Seconds available in the time selector (0..59). */
725
- secondsRange() {
726
- return Array.from({ length: 60 }, (_, i) => i);
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);
727
862
  }
728
- /** Formats an hour for display in the selector (12-hour aware). */
729
- hourDisplay(hour) {
730
- if (this.hourFormat() === '12') {
731
- return String(hour % 12 || 12).padStart(2, '0');
732
- }
733
- return String(hour).padStart(2, '0');
863
+ isCurrentWeek(start) {
864
+ return this.toISODate(this.startOfWeek(new Date())) === this.toISODate(start);
734
865
  }
735
- /** Pads a minute value with a leading zero. */
736
- minutesLabel(value) {
737
- return String(value).padStart(2, '0');
866
+ weekLabel(index) {
867
+ return `${this.texts().week} ${index}`;
738
868
  }
739
- /** Returns the position (x, y) for a clock number at the given index (0-11). */
740
- getClockNumberPosition(index) {
741
- const angle = (index * 30 - 90) * (Math.PI / 180);
742
- const radius = 76;
743
- const x = 100 + radius * Math.cos(angle);
744
- const y = 100 + radius * Math.sin(angle);
745
- return { x, y };
746
- }
747
- /** Returns the position (x, y) for a minute marker at the given index (0-59). */
748
- getMinuteMarkerPosition(index) {
749
- const angle = (index * 6 - 90) * (Math.PI / 180);
750
- const radius = 88;
751
- const x = 100 + radius * Math.cos(angle);
752
- const y = 100 + radius * Math.sin(angle);
753
- return { x, y, rotation: index * 6 };
754
- }
755
- /** Handles click on the analog clock face. */
756
- onClockClick(event, mode) {
757
- const target = event.currentTarget;
758
- const rect = target.getBoundingClientRect();
759
- const centerX = rect.left + rect.width / 2;
760
- const centerY = rect.top + rect.height / 2;
761
- const dx = event.clientX - centerX;
762
- const dy = event.clientY - centerY;
763
- let angle = Math.atan2(dy, dx) * (180 / Math.PI) + 90;
764
- if (angle < 0)
765
- angle += 360;
766
- if (mode === 'hours') {
767
- let hour = Math.round(angle / 30) % 12;
768
- if (hour === 0)
769
- hour = 12;
770
- let actualHour = hour;
771
- if (this.hourFormat() === '12') {
772
- if (this.viewMeridiem() === 'PM' && hour !== 12) {
773
- actualHour = hour + 12;
774
- }
775
- else if (this.viewMeridiem() === 'AM' && hour === 12) {
776
- actualHour = 0;
777
- }
778
- }
779
- else {
780
- actualHour = hour === 12 ? 12 : hour;
781
- if (this.viewHour() >= 12 && hour !== 12) {
782
- actualHour = hour + 12;
783
- }
784
- else if (this.viewHour() < 12 && hour === 12) {
785
- actualHour = 12;
786
- }
787
- }
788
- this.viewHour.set(actualHour);
789
- this.clockMode.set('minutes');
790
- }
791
- else {
792
- const minute = Math.round(angle / 6) % 60;
793
- const stepped = Math.round(minute / this.minuteStep()) * this.minuteStep();
794
- this.viewMinute.set(stepped % 60);
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}`;
795
878
  }
879
+ return `${startLabel} — ${dayFmt.format(end)}`;
796
880
  }
797
- /** Switches the clock mode between hours and minutes. */
798
- toggleClockMode() {
799
- this.clockMode.update((m) => (m === 'hours' ? 'minutes' : 'hours'));
800
- }
801
- /** Whether the given hour number matches the current selection on the clock face. */
802
- isClockHourSelected(hour12) {
803
- const h = this.viewHour();
804
- if (this.hourFormat() === '12') {
805
- const display = h % 12 || 12;
806
- return display === hour12;
807
- }
808
- const display = h % 12 || 12;
809
- return display === hour12;
810
- }
811
- /** Whether the given minute value matches the current selection. */
812
- isClockMinuteSelected(minute) {
813
- return this.viewMinute() === minute;
814
- }
815
- /** Formats the clock display time for the header above the clock. */
816
- clockDisplayTime() {
817
- return this.formatTime(this.viewHour(), this.viewMinute(), this.viewSecond());
818
- }
819
- /** Returns SVG line coordinates for a clock hand from center to angle. */
820
- clockHandLine(length = 60) {
821
- const angle = this.clockHandAngle();
822
- // clockHandAngle: 0=12h, 90=3h, 180=6h, 270=9h
823
- // SVG cos/sin: 0=3h, 90=6h, 180=9h, 270=12h → offset -90°
824
- const rad = ((angle - 90) * Math.PI) / 180;
825
- return {
826
- x2: 100 + length * Math.cos(rad),
827
- y2: 100 + length * Math.sin(rad),
828
- };
881
+ /** Current hour, highlighted like "today" in the calendar. */
882
+ isCurrentHour(hour) {
883
+ return this.currentHour() === hour;
829
884
  }
830
- /** Returns SVG text position for a clock number at the given index (0-11). */
831
- clockNumberPos(index) {
832
- const angle = ((index % 12) * 30 - 90) * (Math.PI / 180);
833
- return {
834
- x: 100 + 68 * Math.cos(angle),
835
- y: 100 + 68 * Math.sin(angle),
836
- };
885
+ selectHour(hour) {
886
+ this.viewHour.set(hour);
837
887
  }
838
- /** Returns SVG text position for a minute label at the given minute (0-55). */
839
- clockMinutePos(minute) {
840
- const angle = (minute * 6 - 90) * (Math.PI / 180);
841
- return {
842
- x: 100 + 68 * Math.cos(angle),
843
- y: 100 + 68 * Math.sin(angle),
844
- };
888
+ selectMinute(minute) {
889
+ this.viewMinute.set(minute);
845
890
  }
846
- /** Returns SVG line coordinates for a minute marker. */
847
- clockMinuteMarker(i) {
848
- const angle = (i * 6 - 90) * (Math.PI / 180);
849
- const outerR = 84;
850
- const innerR = i % 5 === 0 ? 78 : 82;
851
- return {
852
- x1: 100 + outerR * Math.cos(angle),
853
- y1: 100 + outerR * Math.sin(angle),
854
- x2: 100 + innerR * Math.cos(angle),
855
- y2: 100 + innerR * Math.sin(angle),
856
- };
891
+ selectSecond(second) {
892
+ this.viewSecond.set(second);
857
893
  }
858
- /** Drills down from year view to month view for the selected year. */
859
- drillDownToMonth(year) {
860
- this.selectedYearValue.set(year);
861
- this.viewYear.set(year);
862
- this.currentView.set('month');
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);
863
901
  }
864
- /** Drills down from month view to date view for the selected month. */
865
- drillDownToDate(monthIndex) {
866
- this.selectedMonthValue.set(monthIndex);
867
- this.viewMonth.set(monthIndex);
868
- this.currentView.set('date');
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();
869
907
  }
870
- /** Goes back one level in drill-down navigation. */
871
- drillUp() {
872
- const v = this.currentView();
873
- if (v === 'date') {
874
- this.selectedMonthValue.set(null);
875
- this.currentView.set('month');
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;
876
919
  }
877
- else if (v === 'month') {
878
- this.selectedYearValue.set(null);
879
- this.currentView.set('year');
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;
880
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 });
881
953
  }
882
- /** Returns to the initial view (year selection). */
883
- drillToInitial() {
884
- this.selectedYearValue.set(null);
885
- this.selectedMonthValue.set(null);
886
- this.currentView.set('year');
954
+ pad2(value) {
955
+ return String(value).padStart(2, '0');
887
956
  }
888
- /** Formats input placeholder based on locale. */
957
+ // ---------------------------------------------------------------------------
958
+ // Main input typing
959
+ // ---------------------------------------------------------------------------
889
960
  inputPlaceholder() {
961
+ if (this.placeholder())
962
+ return this.placeholder();
890
963
  if (this.timeOnly())
891
- return this.inputFormat();
964
+ return this.hourFormat() === '12' ? 'hh:mm AM' : 'HH:mm';
965
+ if (this.range())
966
+ return `${this.inputFormat()} – ${this.inputFormat()}`;
892
967
  if (this.view() === 'year')
893
968
  return 'YYYY';
894
969
  if (this.view() === 'month')
895
970
  return 'MM/YYYY';
896
- if (this.view() === 'week') {
897
- return this.locale() === 'en' ? 'Week · MM/YYYY' : 'Semana · MM/YYYY';
898
- }
971
+ if (this.view() === 'week')
972
+ return `${this.texts().week} · MM/YYYY`;
899
973
  return this.inputFormat();
900
974
  }
901
- /** Handles text input in the date field. */
902
975
  onInputText(event) {
903
- const value = event.target.value;
904
- this.typedValue.set(value);
976
+ this.typedValue.set(event.target.value);
905
977
  this.typingValid.set(null);
906
978
  }
907
- /** Handles focus on the input field. */
908
979
  onInputFocus() {
909
980
  this.isTyping.set(true);
910
- const val = this._value();
911
- if (val) {
912
- if (this.timeOnly()) {
913
- this.typedValue.set(val);
914
- }
915
- else {
916
- this.typedValue.set(val);
917
- }
918
- }
919
- else {
920
- this.typedValue.set('');
921
- }
981
+ this.typedValue.set(this.typedFormOfValue());
922
982
  this.typingValid.set(null);
923
983
  }
924
984
  /** Validates and commits the typed value on blur or Enter. */
925
985
  onInputBlur() {
926
986
  const text = this.typedValue().trim();
927
- if (!text) {
928
- this.isTyping.set(false);
987
+ this.isTyping.set(false);
988
+ if (!text || text === this.typedFormOfValue())
929
989
  return;
930
- }
931
- const parsed = this.parseTypedDate(text);
990
+ const parsed = this.parseTypedValue(text);
932
991
  if (parsed) {
933
- this.setValue(parsed);
992
+ this.setValue(parsed, false);
934
993
  this.typingValid.set(true);
994
+ if (this.isOpen())
995
+ this.syncViewToValue();
935
996
  }
936
997
  else {
937
998
  this.typingValid.set(false);
938
999
  setTimeout(() => this.typingValid.set(null), 1500);
939
1000
  }
940
- this.isTyping.set(false);
941
1001
  }
942
- /** Cancels typing and reverts to the previous value. */
943
1002
  cancelTyping() {
944
1003
  this.isTyping.set(false);
945
1004
  this.typedValue.set('');
946
1005
  this.typingValid.set(null);
947
1006
  }
948
- /** Parses a typed date string according to the locale format. */
949
- parseTypedDate(text) {
950
- const clean = text.replace(/[\/\-\.\s]/g, '/').trim();
951
- const parts = clean.split('/').filter(Boolean);
952
- if (this.timeOnly()) {
953
- return this.parseTimeOnly(clean);
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)}`;
954
1017
  }
955
- if (this.view() === 'week')
956
- return null;
957
- if (this.view() === 'year') {
958
- const y = Number(parts[0]);
959
- if (parts.length === 1 && y >= 1900 && y <= 2100)
960
- return String(y);
961
- return null;
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}`;
962
1040
  }
963
- if (this.view() === 'month') {
964
- if (parts.length === 2) {
965
- let m, y;
966
- if (this.locale() === 'en') {
967
- m = Number(parts[0]);
968
- y = Number(parts[1]);
969
- }
970
- else {
971
- m = Number(parts[0]);
972
- y = Number(parts[1]);
973
- }
974
- if (m >= 1 && m <= 12 && y >= 1900 && y <= 2100) {
975
- return `${y}-${String(m).padStart(2, '0')}`;
976
- }
977
- }
1041
+ const v = this.view();
1042
+ if (v === 'week')
978
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;
979
1047
  }
980
- // date view
981
- if (parts.length >= 3) {
982
- let d, m, y;
983
- if (this.locale() === 'en') {
984
- m = Number(parts[0]);
985
- d = Number(parts[1]);
986
- y = Number(parts[2]);
987
- }
988
- else {
989
- d = Number(parts[0]);
990
- m = Number(parts[1]);
991
- y = Number(parts[2]);
992
- }
993
- if (y >= 1900 && y <= 2100 && m >= 1 && m <= 12 && d >= 1 && d <= 31) {
994
- const date = new Date(y, m - 1, d);
995
- if (date.getMonth() === m - 1 && date.getDate() === d) {
996
- let result = `${y}-${String(m).padStart(2, '0')}-${String(d).padStart(2, '0')}`;
997
- if (this.showTime()) {
998
- const time = `${String(this.viewHour()).padStart(2, '0')}:${String(this.viewMinute()).padStart(2, '0')}`;
999
- result += `T${time}`;
1000
- }
1001
- return result;
1002
- }
1003
- }
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;
1004
1055
  }
1005
- return null;
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);
1006
1085
  }
1007
- /** Parses time-only input. */
1008
1086
  parseTimeOnly(text) {
1009
- const clean = text.replace(/[\.]/g, ':').trim();
1010
- const parts = clean.split(':').filter(Boolean);
1011
- if (parts.length >= 2) {
1012
- let h = Number(parts[0]);
1013
- const m = Number(parts[1]);
1014
- const s = parts.length >= 3 ? Number(parts[2]) : 0;
1015
- if (this.hourFormat() === '12') {
1016
- const isPM = /pm/i.test(text);
1017
- const isAM = /am/i.test(text);
1018
- if (isPM && h < 12)
1019
- h += 12;
1020
- if (isAM && h === 12)
1021
- h = 0;
1022
- }
1023
- if (h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59) {
1024
- let result = `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
1025
- if (this.showSeconds())
1026
- result += `:${String(s).padStart(2, '0')}`;
1027
- return result;
1028
- }
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 });
1029
1113
  }
1030
- return null;
1114
+ return { year, month, cells };
1031
1115
  }
1032
- /** Whether the given day is today's date. */
1033
- isToday(day) {
1034
- const now = new Date();
1035
- return (this.viewYear() === now.getFullYear() &&
1036
- this.viewMonth() === now.getMonth() &&
1037
- day === now.getDate());
1038
- }
1039
- /** ISO date (YYYY-MM-DD) of the week start containing the given date. */
1040
- weekStartISO(date) {
1041
- const ws = this.weekStart();
1042
- const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - ((date.getDay() - ws + 7) % 7));
1043
- return (`${start.getFullYear()}-` +
1044
- `${String(start.getMonth() + 1).padStart(2, '0')}-` +
1045
- `${String(start.getDate()).padStart(2, '0')}`);
1046
- }
1047
- /** Whether the given week row contains the displayed/selected date. */
1048
- isSelectedWeek(start) {
1049
- const date = this.displayedDate();
1050
- if (!date)
1051
- return false;
1052
- return this.weekStartISO(new Date(date + 'T12:00:00')) === this.weekStartISO(start);
1116
+ startOfWeek(date) {
1117
+ const offset = (date.getDay() - this.firstDayOfWeek() + 7) % 7;
1118
+ return this.addDays(date, -offset);
1053
1119
  }
1054
- /** Whether the given week row contains today's date. */
1055
- isCurrentWeek(start) {
1056
- return this.weekStartISO(new Date()) === this.weekStartISO(start);
1120
+ addDays(date, days) {
1121
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
1057
1122
  }
1058
- /** Whether the given month matches the selected month and year. */
1059
- isSelectedMonth(monthIndex) {
1060
- return this.selectedMonthValue() === monthIndex;
1123
+ goToDate(date) {
1124
+ this.viewYear.set(date.getFullYear());
1125
+ this.viewMonth.set(date.getMonth());
1126
+ this.viewDecade.set(this.decadeOf(date.getFullYear()));
1061
1127
  }
1062
- isCurrentMonth(monthIndex) {
1063
- const now = new Date();
1064
- return this.viewYear() === now.getFullYear() && monthIndex === now.getMonth();
1128
+ decadeOf(year) {
1129
+ return Math.floor(year / 12) * 12;
1065
1130
  }
1066
- isSelectedYear(year) {
1067
- return this.selectedYearValue() === year;
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);
1068
1136
  }
1069
- isCurrentYear(year) {
1070
- return new Date().getFullYear() === year;
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}`;
1071
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
+ // ---------------------------------------------------------------------------
1072
1180
  writeValue(value) {
1073
- this._value.set(this.normalizeValue(value));
1181
+ this._value.set(this.range() ? this.normalizeRange(value) : this.normalizeValue(value));
1074
1182
  }
1075
1183
  /**
1076
- * Normalizes an incoming value to the internal ISO string format expected
1077
- * for the current configuration:
1078
- * - date/week: "YYYY-MM-DD" (or "YYYY-MM-DDTHH:mm[:ss]" with showTime)
1079
- * - month: "YYYY-MM"
1080
- * - year: "YYYY"
1081
- * - timeOnly: "HH:mm[:ss]"
1082
- *
1083
- * Accepts ISO strings, `Date` objects, timestamps and day-first strings
1084
- * ("DD-MM-YYYY", "DD/MM/YYYY", "DD.MM.YYYY"; month-first when locale is
1085
- * 'en'). Values that cannot be interpreted are discarded (returns null)
1086
- * instead of breaking the formatted label.
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').
1087
1211
  */
1088
1212
  normalizeValue(value) {
1089
1213
  if (value === null || value === undefined || value === '')
@@ -1115,33 +1239,21 @@ class DatePickerComponent {
1115
1239
  let mo = 1;
1116
1240
  let d = 1;
1117
1241
  if (parts.length === 1 && /^\d{4}$/.test(parts[0])) {
1118
- // "YYYY"
1119
1242
  y = Number(parts[0]);
1120
1243
  }
1121
1244
  else if (parts.length === 2) {
1122
- // "YYYY-MM" or "MM-YYYY"
1123
- if (parts[0].length === 4) {
1124
- y = Number(parts[0]);
1125
- mo = Number(parts[1]);
1126
- }
1127
- else {
1128
- mo = Number(parts[0]);
1129
- y = Number(parts[1]);
1130
- }
1245
+ if (parts[0].length === 4)
1246
+ [y, mo] = parts.map(Number);
1247
+ else
1248
+ [mo, y] = parts.map(Number);
1131
1249
  }
1132
1250
  else if (parts.length === 3) {
1133
- if (parts[0].length === 4) {
1134
- // "YYYY-MM-DD"
1251
+ if (parts[0].length === 4)
1135
1252
  [y, mo, d] = parts.map(Number);
1136
- }
1137
- else if (this.locale() === 'en') {
1138
- // "MM-DD-YYYY"
1253
+ else if (this.locale().startsWith('en'))
1139
1254
  [mo, d, y] = parts.map(Number);
1140
- }
1141
- else {
1142
- // "DD-MM-YYYY"
1255
+ else
1143
1256
  [d, mo, y] = parts.map(Number);
1144
- }
1145
1257
  }
1146
1258
  else {
1147
1259
  return this.invalidValue(value);
@@ -1154,17 +1266,16 @@ class DatePickerComponent {
1154
1266
  return this.invalidValue(value);
1155
1267
  }
1156
1268
  const t = rawTime ? /^(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(rawTime) : null;
1157
- if (t) {
1269
+ if (t)
1158
1270
  date.setHours(Number(t[1]), Number(t[2]), Number(t[3] ?? 0));
1159
- }
1160
1271
  return this.fromDate(date, !!t);
1161
1272
  }
1162
- /** Matches the tokens supported by `valueFormat`. */
1163
1273
  static { this.FORMAT_TOKENS = /YYYY|MM|DD|HH|mm|ss/g; }
1164
- /**
1165
- * Parses a string using the `valueFormat` pattern and returns the internal
1166
- * ISO value, or null if it does not match.
1167
- */
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. */
1168
1279
  parseWithFormat(str, format) {
1169
1280
  const tokens = [];
1170
1281
  const pattern = format
@@ -1183,8 +1294,7 @@ class DatePickerComponent {
1183
1294
  const i = tokens.indexOf(tok);
1184
1295
  return i >= 0 ? Number(match[i + 1]) : def;
1185
1296
  };
1186
- const now = new Date();
1187
- const y = get('YYYY', now.getFullYear());
1297
+ const y = get('YYYY', new Date().getFullYear());
1188
1298
  const mo = get('MM', 1);
1189
1299
  const d = get('DD', 1);
1190
1300
  const h = get('HH', 0);
@@ -1193,13 +1303,20 @@ class DatePickerComponent {
1193
1303
  if (h > 23 || mi > 59 || s > 59)
1194
1304
  return null;
1195
1305
  const date = new Date(y, mo - 1, d, h, mi, s);
1196
- if (date.getFullYear() !== y || date.getMonth() !== mo - 1 || date.getDate() !== d) {
1306
+ if (date.getFullYear() !== y || date.getMonth() !== mo - 1 || date.getDate() !== d)
1197
1307
  return null;
1198
- }
1199
1308
  return this.fromDate(date, tokens.includes('HH'));
1200
1309
  }
1201
- /** Converts the internal ISO value to the configured `valueFormat`. */
1310
+ /** Converts the internal value to what the form control receives. */
1202
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) {
1203
1320
  const format = this.valueFormat();
1204
1321
  if (!format || !value)
1205
1322
  return value;
@@ -1213,35 +1330,26 @@ class DatePickerComponent {
1213
1330
  if (timePart)
1214
1331
  [h, mi, s = '00'] = timePart.split(':');
1215
1332
  }
1216
- const map = {
1217
- YYYY: y, MM: mo, DD: d, HH: h, mm: mi, ss: s,
1218
- };
1333
+ const map = { YYYY: y, MM: mo, DD: d, HH: h, mm: mi, ss: s };
1219
1334
  return format.replace(DatePickerComponent.FORMAT_TOKENS, (tok) => map[tok]);
1220
1335
  }
1221
1336
  /** Builds the internal value from a Date according to the configuration. */
1222
1337
  fromDate(date, hasTime = true) {
1223
- if (this.timeOnly()) {
1338
+ if (this.timeOnly())
1224
1339
  return this.buildTime(date.getHours(), date.getMinutes(), date.getSeconds());
1225
- }
1226
1340
  const iso = this.toISODate(date);
1227
1341
  const v = this.view();
1228
- if (v === 'year')
1229
- return iso.slice(0, 4);
1230
- if (v === 'month')
1231
- return iso.slice(0, 7);
1232
- if (this.showTime() && hasTime) {
1233
- return `${iso}T${this.buildTime(date.getHours(), date.getMinutes(), date.getSeconds())}`;
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
+ }
1234
1350
  }
1235
1351
  return iso;
1236
1352
  }
1237
- /** Formats "HH:mm[:ss]" honoring the showSeconds option. */
1238
- buildTime(h, m, s) {
1239
- let time = `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
1240
- if (this.showSeconds())
1241
- time += `:${String(s).padStart(2, '0')}`;
1242
- return time;
1243
- }
1244
- /** Warns about an unparseable value and discards it. */
1245
1353
  invalidValue(value) {
1246
1354
  console.warn('[shk-date-picker] Valor de fecha no válido, se ignora:', value);
1247
1355
  return null;
@@ -1257,13 +1365,13 @@ class DatePickerComponent {
1257
1365
  this.cdr.markForCheck();
1258
1366
  }
1259
1367
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: DatePickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1260
- 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 }, 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: [
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: [
1261
1369
  {
1262
1370
  provide: NG_VALUE_ACCESSOR,
1263
1371
  useExisting: forwardRef(() => DatePickerComponent),
1264
1372
  multi: true,
1265
1373
  },
1266
- ], 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 [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 />\n <button\n type=\"button\"\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 >\n <svg\n class=\"w-4 h-4\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n >\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\"></rect>\n <path d=\"M16 2v4M8 2v4M3 10h18\"></path>\n </svg>\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 <!-- Calendario junto al campo que lo abrio: debajo, o encima si no cabe -->\n <div\n #panel\n class=\"fixed z-50 w-72 p-4 bg-white dark:[background-color:var(--shk-surface-100)] _shk-border dark:[border-color:var(--shk-surface-200)] rounded-lg shadow-xl\"\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 >\n <!-- DATE VIEW -->\n @if (!timeOnly() && currentView() === 'date') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"drillUp()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ monthNames()[viewMonth()] }} {{ selectedYearValue() ?? viewYear() }}\n </span>\n <button\n type=\"button\"\n (click)=\"drillToInitial()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\n <div class=\"grid grid-cols-7 gap-0 mb-1\">\n @for (name of dayNames(); track $index) {\n <div class=\"text-center text-xs font-medium _shk-text-surface-400 dark:[color:var(--shk-surface-400)] py-1\">\n {{ name }}\n </div>\n }\n </div>\n\n <div class=\"grid grid-cols-7 gap-0\">\n @for (day of calendarDays(); track $index) {\n @if (day !== null) {\n <button\n type=\"button\"\n (click)=\"selectDay(day)\"\n class=\"py-1.5 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': isSelectedDay(day),\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isToday(day) && !isSelectedDay(day),\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': !isSelectedDay(day) && !isToday(day),\n }\"\n >\n {{ day }}\n </button>\n } @else {\n <div></div>\n }\n }\n </div>\n }\n\n <!-- WEEK VIEW -->\n @if (!timeOnly() && currentView() === 'week') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"!canGoPrev()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ monthNames()[viewMonth()] }} {{ viewYear() }}\n </span>\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"!canGoNext()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\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=\"w-full flex items-center justify-between py-1.5 px-2 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': isSelectedWeek(week.start),\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isCurrentWeek(week.start) && !isSelectedWeek(week.start),\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': !isSelectedWeek(week.start) && !isCurrentWeek(week.start),\n }\"\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 }\n\n <!-- MONTH VIEW -->\n @if (!timeOnly() && currentView() === 'month') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"drillUp()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ selectedYearValue() ?? viewYear() }}\n </span>\n <button\n type=\"button\"\n (click)=\"drillToInitial()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\n <div class=\"grid grid-cols-3 gap-1\">\n @for (name of monthNames(); track $index) {\n <button\n type=\"button\"\n (click)=\"selectMonth($index)\"\n class=\"py-2 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': selectedMonthValue() === $index,\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isCurrentMonth($index) && selectedMonthValue() !== $index,\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': selectedMonthValue() !== $index && !isCurrentMonth($index),\n }\"\n >\n {{ name }}\n </button>\n }\n </div>\n }\n\n <!-- YEAR VIEW -->\n @if (!timeOnly() && currentView() === 'year') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"!canGoPrev()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ viewDecade() }} - {{ viewDecade() + 11 }}\n </span>\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"!canGoNext()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\n <div class=\"grid grid-cols-3 gap-1\">\n @for (year of decadeYears(); track year) {\n <button\n type=\"button\"\n (click)=\"selectYear(year)\"\n class=\"py-2 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': selectedYearValue() === year,\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isCurrentYear(year) && selectedYearValue() !== year,\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': selectedYearValue() !== year && !isCurrentYear(year),\n }\"\n >\n {{ year }}\n </button>\n }\n </div>\n }\n\n <!-- ANALOG CLOCK TIME PICKER -->\n @if (timeOnly() || showTime()) {\n <div class=\"mt-3 pt-3 _shk-border dark:[border-color:var(--shk-surface-200)]\">\n <!-- Clock display time -->\n <div class=\"text-center mb-2\">\n <span class=\"text-lg font-semibold _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\">\n {{ clockDisplayTime() }}\n </span>\n </div>\n\n <!-- Analog clock face -->\n <div class=\"clock-container\">\n <svg\n viewBox=\"0 0 200 200\"\n class=\"w-full h-full cursor-pointer\"\n (click)=\"onClockClick($event, clockMode())\"\n >\n <!-- Clock face background -->\n <circle cx=\"100\" cy=\"100\" r=\"96\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1\"\n class=\"_shk-text-surface-200 dark:[color:var(--shk-surface-200)]\" />\n\n <!-- Minute markers -->\n @if (clockMode() === 'minutes') {\n @for (i of [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59]; track i) {\n <line\n [attr.x1]=\"clockMinuteMarker(i).x1\"\n [attr.y1]=\"clockMinuteMarker(i).y1\"\n [attr.x2]=\"clockMinuteMarker(i).x2\"\n [attr.y2]=\"clockMinuteMarker(i).y2\"\n [attr.stroke-width]=\"i % 5 === 0 ? 2 : 1\"\n [class]=\"i % 5 === 0 ? '_shk-text-surface-500 dark:[color:var(--shk-surface-500)]' : '_shk-text-surface-300 dark:[color:var(--shk-surface-400)]'\"\n stroke=\"currentColor\"\n />\n }\n <!-- Minute numbers (00, 05, 10, ...) -->\n @for (m of [0,5,10,15,20,25,30,35,40,45,50,55]; track m) {\n <text\n [attr.x]=\"clockMinutePos(m).x\"\n [attr.y]=\"clockMinutePos(m).y\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n class=\"text-[9px] _shk-text-surface-500 dark:[color:var(--shk-surface-400)]\"\n [class._shk-text-primary]=\"viewMinute() === m\"\n >\n {{ m.toString().padStart(2, '0') }}\n </text>\n }\n }\n\n <!-- Hour numbers -->\n @if (clockMode() === 'hours') {\n @for (h of clockHours(); track h) {\n <text\n [attr.x]=\"clockNumberPos(h).x\"\n [attr.y]=\"clockNumberPos(h).y\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n class=\"text-sm font-medium\"\n [class._shk-text-primary]=\"isClockHourSelected(h)\"\n [class._shk-text-surface-700]=\"!isClockHourSelected(h)\"\n >\n {{ h }}\n </text>\n }\n }\n\n <!-- Clock hand -->\n <line\n x1=\"100\" y1=\"100\"\n [attr.x2]=\"clockHandLine(60).x2\"\n [attr.y2]=\"clockHandLine(60).y2\"\n class=\"_shk-text-primary\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n />\n\n <!-- Center dot -->\n <circle cx=\"100\" cy=\"100\" r=\"4\" class=\"fill-current _shk-text-primary\" />\n </svg>\n </div>\n\n <!-- Mode toggle: Hours / Minutes -->\n <div class=\"clock-mode-toggle\">\n <button\n type=\"button\"\n (click)=\"clockMode.set('hours')\"\n class=\"clock-mode-btn\"\n [class.active]=\"clockMode() === 'hours'\"\n >\n {{ 'Horas' }}\n </button>\n <button\n type=\"button\"\n (click)=\"clockMode.set('minutes')\"\n class=\"clock-mode-btn\"\n [class.active]=\"clockMode() === 'minutes'\"\n >\n {{ 'Minutos' }}\n </button>\n </div>\n\n <!-- AM/PM toggle for 12h format -->\n @if (hourFormat() === '12') {\n <div class=\"flex items-center justify-center gap-2 mt-2\">\n <button\n type=\"button\"\n (click)=\"viewMeridiem.set('AM')\"\n class=\"px-3 py-1 text-xs font-medium rounded-full transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white': viewMeridiem() === 'AM',\n '_shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': viewMeridiem() !== 'AM'\n }\"\n >\n AM\n </button>\n <button\n type=\"button\"\n (click)=\"viewMeridiem.set('PM')\"\n class=\"px-3 py-1 text-xs font-medium rounded-full transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white': viewMeridiem() === 'PM',\n '_shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': viewMeridiem() !== 'PM'\n }\"\n >\n PM\n </button>\n </div>\n }\n\n <!-- Seconds selector (if enabled) -->\n @if (showSeconds()) {\n <div class=\"flex items-center justify-center gap-1 mt-2\">\n <span class=\"text-xs _shk-text-surface-400\">Seg:</span>\n <select\n class=\"px-2 py-1 text-xs _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] _shk-border dark:[border-color:var(--shk-surface-200)] rounded-md\"\n [value]=\"viewSecond()\"\n (change)=\"onSecondChange($event)\"\n aria-label=\"Segundos\"\n >\n @for (seconds of secondsRange(); track seconds) {\n <option [value]=\"seconds\">{{ minutesLabel(seconds) }}</option>\n }\n </select>\n </div>\n }\n\n <!-- Confirm button -->\n <button\n type=\"button\"\n (click)=\"confirmTime()\"\n class=\"mt-3 w-full py-2 text-sm _shk-bg-primary _shk-text-white rounded-lg hover:[background-color:var(--shk-primary-700)] transition-colors\"\n >\n {{ timeOnly() ? 'Confirmar' : 'Introducir hora' }}\n </button>\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: [".clock-container{position:relative;width:200px;height:200px;margin:0 auto}.clock-face{width:100%;height:100%;border-radius:50%;border:2px solid var(--shk-surface-200);position:relative;background-color:var(--shk-surface-50)}:host-context(.dark) .clock-face,.dark .clock-face{border-color:var(--shk-surface-200);background-color:var(--shk-surface-100)}.clock-number{position:absolute;width:32px;height:32px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;border-radius:50%;transform:translate(-50%,-50%);cursor:pointer;transition:background-color .15s,color .15s;-webkit-user-select:none;user-select:none;color:var(--shk-surface-700)}:host-context(.dark) .clock-number,.dark .clock-number{color:var(--shk-surface-700)}.clock-number:hover{background-color:var(--shk-surface-100)}:host-context(.dark) .clock-number:hover,.dark .clock-number:hover{background-color:var(--shk-surface-200)}.clock-number.selected{background-color:var(--shk-primary-500);color:#fff}.clock-number.current{font-weight:700}.clock-hand{position:absolute;bottom:50%;left:50%;width:2px;background-color:var(--shk-primary-500);transform-origin:bottom center;border-radius:1px;pointer-events:none;transition:transform .2s ease-out}.clock-center{position:absolute;top:50%;left:50%;width:8px;height:8px;border-radius:50%;background-color:var(--shk-primary-500);transform:translate(-50%,-50%);pointer-events:none;z-index:2}.clock-minute-marker{position:absolute;width:1px;height:8px;background-color:var(--shk-surface-300);top:6px;left:50%;transform-origin:center 94px}:host-context(.dark) .clock-minute-marker,.dark .clock-minute-marker{background-color:var(--shk-surface-400)}.clock-minute-marker.major{width:2px;height:12px;background-color:var(--shk-surface-400)}:host-context(.dark) .clock-minute-marker.major,.dark .clock-minute-marker.major{background-color:var(--shk-surface-500)}.clock-mode-toggle{display:flex;align-items:center;justify-content:center;gap:.5rem;margin-top:.75rem}.clock-mode-btn{padding:.25rem .75rem;font-size:.75rem;font-weight:500;border-radius:9999px;cursor:pointer;transition:background-color .15s,color .15s;border:none;background:transparent;color:var(--shk-surface-500)}:host-context(.dark) .clock-mode-btn,.dark .clock-mode-btn{color:var(--shk-surface-400)}.clock-mode-btn.active{background-color:var(--shk-primary-500);color:#fff}.clock-mode-btn:hover:not(.active){background-color:var(--shk-surface-100)}:host-context(.dark) .clock-mode-btn:hover:not(.active),.dark .clock-mode-btn:hover:not(.active){background-color:var(--shk-surface-200)}.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)}:host-context(.dark) .date-input-field,.dark .date-input-field{background-color:var(--shk-surface-100);color:var(--shk-surface-700);border-color:var(--shk-surface-200)}.date-input-field::placeholder{color:var(--shk-surface-400)}:host-context(.dark) .date-input-field::placeholder,.dark .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);border-color:var(--shk-surface-200);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{border-color:var(--shk-error-500);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{border-color:#22c55e;box-shadow:0 0 0 3px #22c55e33}.date-input-field{text-overflow:ellipsis}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: PortalDirective, selector: "[shkPortal]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
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 }); }
1267
1375
  }
1268
1376
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: DatePickerComponent, decorators: [{
1269
1377
  type: Component,
@@ -1273,8 +1381,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImpo
1273
1381
  useExisting: forwardRef(() => DatePickerComponent),
1274
1382
  multi: true,
1275
1383
  },
1276
- ], 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 [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 />\n <button\n type=\"button\"\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 >\n <svg\n class=\"w-4 h-4\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n >\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"18\" rx=\"2\"></rect>\n <path d=\"M16 2v4M8 2v4M3 10h18\"></path>\n </svg>\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 <!-- Calendario junto al campo que lo abrio: debajo, o encima si no cabe -->\n <div\n #panel\n class=\"fixed z-50 w-72 p-4 bg-white dark:[background-color:var(--shk-surface-100)] _shk-border dark:[border-color:var(--shk-surface-200)] rounded-lg shadow-xl\"\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 >\n <!-- DATE VIEW -->\n @if (!timeOnly() && currentView() === 'date') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"drillUp()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ monthNames()[viewMonth()] }} {{ selectedYearValue() ?? viewYear() }}\n </span>\n <button\n type=\"button\"\n (click)=\"drillToInitial()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\n <div class=\"grid grid-cols-7 gap-0 mb-1\">\n @for (name of dayNames(); track $index) {\n <div class=\"text-center text-xs font-medium _shk-text-surface-400 dark:[color:var(--shk-surface-400)] py-1\">\n {{ name }}\n </div>\n }\n </div>\n\n <div class=\"grid grid-cols-7 gap-0\">\n @for (day of calendarDays(); track $index) {\n @if (day !== null) {\n <button\n type=\"button\"\n (click)=\"selectDay(day)\"\n class=\"py-1.5 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': isSelectedDay(day),\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isToday(day) && !isSelectedDay(day),\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': !isSelectedDay(day) && !isToday(day),\n }\"\n >\n {{ day }}\n </button>\n } @else {\n <div></div>\n }\n }\n </div>\n }\n\n <!-- WEEK VIEW -->\n @if (!timeOnly() && currentView() === 'week') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"!canGoPrev()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ monthNames()[viewMonth()] }} {{ viewYear() }}\n </span>\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"!canGoNext()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\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=\"w-full flex items-center justify-between py-1.5 px-2 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': isSelectedWeek(week.start),\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isCurrentWeek(week.start) && !isSelectedWeek(week.start),\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': !isSelectedWeek(week.start) && !isCurrentWeek(week.start),\n }\"\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 }\n\n <!-- MONTH VIEW -->\n @if (!timeOnly() && currentView() === 'month') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"drillUp()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ selectedYearValue() ?? viewYear() }}\n </span>\n <button\n type=\"button\"\n (click)=\"drillToInitial()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\n <div class=\"grid grid-cols-3 gap-1\">\n @for (name of monthNames(); track $index) {\n <button\n type=\"button\"\n (click)=\"selectMonth($index)\"\n class=\"py-2 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': selectedMonthValue() === $index,\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isCurrentMonth($index) && selectedMonthValue() !== $index,\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': selectedMonthValue() !== $index && !isCurrentMonth($index),\n }\"\n >\n {{ name }}\n </button>\n }\n </div>\n }\n\n <!-- YEAR VIEW -->\n @if (!timeOnly() && currentView() === 'year') {\n <div class=\"flex items-center justify-between mb-3\">\n <button\n type=\"button\"\n (click)=\"prev()\"\n [disabled]=\"!canGoPrev()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M15 18l-6-6 6-6\"></path>\n </svg>\n </button>\n <span class=\"text-sm font-medium _shk-text-surface-700 dark:[color:var(--shk-surface-600)]\">\n {{ viewDecade() }} - {{ viewDecade() + 11 }}\n </span>\n <button\n type=\"button\"\n (click)=\"next()\"\n [disabled]=\"!canGoNext()\"\n class=\"p-1 rounded hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)] disabled:opacity-30 disabled:cursor-not-allowed\"\n >\n <svg class=\"w-4 h-4\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\">\n <path d=\"M9 18l6-6-6-6\"></path>\n </svg>\n </button>\n </div>\n\n <div class=\"grid grid-cols-3 gap-1\">\n @for (year of decadeYears(); track year) {\n <button\n type=\"button\"\n (click)=\"selectYear(year)\"\n class=\"py-2 text-sm rounded transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white hover:[background-color:var(--shk-primary-700)]': selectedYearValue() === year,\n 'ring-1 [--tw-ring-color:var(--shk-primary-500)] _shk-text-surface-700 dark:[color:var(--shk-surface-700)]': isCurrentYear(year) && selectedYearValue() !== year,\n '_shk-text-surface-700 dark:[color:var(--shk-surface-700)] hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': selectedYearValue() !== year && !isCurrentYear(year),\n }\"\n >\n {{ year }}\n </button>\n }\n </div>\n }\n\n <!-- ANALOG CLOCK TIME PICKER -->\n @if (timeOnly() || showTime()) {\n <div class=\"mt-3 pt-3 _shk-border dark:[border-color:var(--shk-surface-200)]\">\n <!-- Clock display time -->\n <div class=\"text-center mb-2\">\n <span class=\"text-lg font-semibold _shk-text-surface-700 dark:[color:var(--shk-surface-700)]\">\n {{ clockDisplayTime() }}\n </span>\n </div>\n\n <!-- Analog clock face -->\n <div class=\"clock-container\">\n <svg\n viewBox=\"0 0 200 200\"\n class=\"w-full h-full cursor-pointer\"\n (click)=\"onClockClick($event, clockMode())\"\n >\n <!-- Clock face background -->\n <circle cx=\"100\" cy=\"100\" r=\"96\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1\"\n class=\"_shk-text-surface-200 dark:[color:var(--shk-surface-200)]\" />\n\n <!-- Minute markers -->\n @if (clockMode() === 'minutes') {\n @for (i of [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59]; track i) {\n <line\n [attr.x1]=\"clockMinuteMarker(i).x1\"\n [attr.y1]=\"clockMinuteMarker(i).y1\"\n [attr.x2]=\"clockMinuteMarker(i).x2\"\n [attr.y2]=\"clockMinuteMarker(i).y2\"\n [attr.stroke-width]=\"i % 5 === 0 ? 2 : 1\"\n [class]=\"i % 5 === 0 ? '_shk-text-surface-500 dark:[color:var(--shk-surface-500)]' : '_shk-text-surface-300 dark:[color:var(--shk-surface-400)]'\"\n stroke=\"currentColor\"\n />\n }\n <!-- Minute numbers (00, 05, 10, ...) -->\n @for (m of [0,5,10,15,20,25,30,35,40,45,50,55]; track m) {\n <text\n [attr.x]=\"clockMinutePos(m).x\"\n [attr.y]=\"clockMinutePos(m).y\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n class=\"text-[9px] _shk-text-surface-500 dark:[color:var(--shk-surface-400)]\"\n [class._shk-text-primary]=\"viewMinute() === m\"\n >\n {{ m.toString().padStart(2, '0') }}\n </text>\n }\n }\n\n <!-- Hour numbers -->\n @if (clockMode() === 'hours') {\n @for (h of clockHours(); track h) {\n <text\n [attr.x]=\"clockNumberPos(h).x\"\n [attr.y]=\"clockNumberPos(h).y\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n class=\"text-sm font-medium\"\n [class._shk-text-primary]=\"isClockHourSelected(h)\"\n [class._shk-text-surface-700]=\"!isClockHourSelected(h)\"\n >\n {{ h }}\n </text>\n }\n }\n\n <!-- Clock hand -->\n <line\n x1=\"100\" y1=\"100\"\n [attr.x2]=\"clockHandLine(60).x2\"\n [attr.y2]=\"clockHandLine(60).y2\"\n class=\"_shk-text-primary\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n />\n\n <!-- Center dot -->\n <circle cx=\"100\" cy=\"100\" r=\"4\" class=\"fill-current _shk-text-primary\" />\n </svg>\n </div>\n\n <!-- Mode toggle: Hours / Minutes -->\n <div class=\"clock-mode-toggle\">\n <button\n type=\"button\"\n (click)=\"clockMode.set('hours')\"\n class=\"clock-mode-btn\"\n [class.active]=\"clockMode() === 'hours'\"\n >\n {{ 'Horas' }}\n </button>\n <button\n type=\"button\"\n (click)=\"clockMode.set('minutes')\"\n class=\"clock-mode-btn\"\n [class.active]=\"clockMode() === 'minutes'\"\n >\n {{ 'Minutos' }}\n </button>\n </div>\n\n <!-- AM/PM toggle for 12h format -->\n @if (hourFormat() === '12') {\n <div class=\"flex items-center justify-center gap-2 mt-2\">\n <button\n type=\"button\"\n (click)=\"viewMeridiem.set('AM')\"\n class=\"px-3 py-1 text-xs font-medium rounded-full transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white': viewMeridiem() === 'AM',\n '_shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': viewMeridiem() !== 'AM'\n }\"\n >\n AM\n </button>\n <button\n type=\"button\"\n (click)=\"viewMeridiem.set('PM')\"\n class=\"px-3 py-1 text-xs font-medium rounded-full transition-colors\"\n [ngClass]=\"{\n '_shk-bg-primary _shk-text-white': viewMeridiem() === 'PM',\n '_shk-text-surface-500 hover:[background-color:var(--shk-surface-100)] dark:hover:[background-color:var(--shk-surface-200)]': viewMeridiem() !== 'PM'\n }\"\n >\n PM\n </button>\n </div>\n }\n\n <!-- Seconds selector (if enabled) -->\n @if (showSeconds()) {\n <div class=\"flex items-center justify-center gap-1 mt-2\">\n <span class=\"text-xs _shk-text-surface-400\">Seg:</span>\n <select\n class=\"px-2 py-1 text-xs _shk-bg-surface-50 dark:[background-color:var(--shk-surface-100)] _shk-border dark:[border-color:var(--shk-surface-200)] rounded-md\"\n [value]=\"viewSecond()\"\n (change)=\"onSecondChange($event)\"\n aria-label=\"Segundos\"\n >\n @for (seconds of secondsRange(); track seconds) {\n <option [value]=\"seconds\">{{ minutesLabel(seconds) }}</option>\n }\n </select>\n </div>\n }\n\n <!-- Confirm button -->\n <button\n type=\"button\"\n (click)=\"confirmTime()\"\n class=\"mt-3 w-full py-2 text-sm _shk-bg-primary _shk-text-white rounded-lg hover:[background-color:var(--shk-primary-700)] transition-colors\"\n >\n {{ timeOnly() ? 'Confirmar' : 'Introducir hora' }}\n </button>\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: [".clock-container{position:relative;width:200px;height:200px;margin:0 auto}.clock-face{width:100%;height:100%;border-radius:50%;border:2px solid var(--shk-surface-200);position:relative;background-color:var(--shk-surface-50)}:host-context(.dark) .clock-face,.dark .clock-face{border-color:var(--shk-surface-200);background-color:var(--shk-surface-100)}.clock-number{position:absolute;width:32px;height:32px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:500;border-radius:50%;transform:translate(-50%,-50%);cursor:pointer;transition:background-color .15s,color .15s;-webkit-user-select:none;user-select:none;color:var(--shk-surface-700)}:host-context(.dark) .clock-number,.dark .clock-number{color:var(--shk-surface-700)}.clock-number:hover{background-color:var(--shk-surface-100)}:host-context(.dark) .clock-number:hover,.dark .clock-number:hover{background-color:var(--shk-surface-200)}.clock-number.selected{background-color:var(--shk-primary-500);color:#fff}.clock-number.current{font-weight:700}.clock-hand{position:absolute;bottom:50%;left:50%;width:2px;background-color:var(--shk-primary-500);transform-origin:bottom center;border-radius:1px;pointer-events:none;transition:transform .2s ease-out}.clock-center{position:absolute;top:50%;left:50%;width:8px;height:8px;border-radius:50%;background-color:var(--shk-primary-500);transform:translate(-50%,-50%);pointer-events:none;z-index:2}.clock-minute-marker{position:absolute;width:1px;height:8px;background-color:var(--shk-surface-300);top:6px;left:50%;transform-origin:center 94px}:host-context(.dark) .clock-minute-marker,.dark .clock-minute-marker{background-color:var(--shk-surface-400)}.clock-minute-marker.major{width:2px;height:12px;background-color:var(--shk-surface-400)}:host-context(.dark) .clock-minute-marker.major,.dark .clock-minute-marker.major{background-color:var(--shk-surface-500)}.clock-mode-toggle{display:flex;align-items:center;justify-content:center;gap:.5rem;margin-top:.75rem}.clock-mode-btn{padding:.25rem .75rem;font-size:.75rem;font-weight:500;border-radius:9999px;cursor:pointer;transition:background-color .15s,color .15s;border:none;background:transparent;color:var(--shk-surface-500)}:host-context(.dark) .clock-mode-btn,.dark .clock-mode-btn{color:var(--shk-surface-400)}.clock-mode-btn.active{background-color:var(--shk-primary-500);color:#fff}.clock-mode-btn:hover:not(.active){background-color:var(--shk-surface-100)}:host-context(.dark) .clock-mode-btn:hover:not(.active),.dark .clock-mode-btn:hover:not(.active){background-color:var(--shk-surface-200)}.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)}:host-context(.dark) .date-input-field,.dark .date-input-field{background-color:var(--shk-surface-100);color:var(--shk-surface-700);border-color:var(--shk-surface-200)}.date-input-field::placeholder{color:var(--shk-surface-400)}:host-context(.dark) .date-input-field::placeholder,.dark .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);border-color:var(--shk-surface-200);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{border-color:var(--shk-error-500);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{border-color:#22c55e;box-shadow:0 0 0 3px #22c55e33}.date-input-field{text-overflow:ellipsis}\n"] }]
1277
- }], 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 }] }], 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: [{
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: [{
1278
1386
  type: HostListener,
1279
1387
  args: ['document:click', ['$event']]
1280
1388
  }], onViewportChange: [{