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