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