@ship-ui/core 0.19.5 → 0.22.2
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 +3 -0
- package/assets/mcp/components.json +66 -4243
- package/bin/mcp/index.js +6027 -273
- package/bin/ship-fg-scanner +0 -0
- package/bin/ship-fg.mjs +14 -12
- package/bin/src/subset.ts +3 -1
- package/fesm2022/ship-ui-core-sh-form-field-experimental.mjs +42 -0
- package/fesm2022/ship-ui-core-sh-form-field-experimental.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-accordion.mjs +127 -0
- package/fesm2022/ship-ui-core-ship-accordion.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-alert.mjs +305 -0
- package/fesm2022/ship-ui-core-ship-alert.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-blueprint.mjs +1156 -0
- package/fesm2022/ship-ui-core-ship-blueprint.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-button-group.mjs +41 -0
- package/fesm2022/ship-ui-core-ship-button-group.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-button.mjs +38 -0
- package/fesm2022/ship-ui-core-ship-button.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-card.mjs +35 -0
- package/fesm2022/ship-ui-core-ship-card.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-checkbox.mjs +113 -0
- package/fesm2022/ship-ui-core-ship-checkbox.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-chip.mjs +44 -0
- package/fesm2022/ship-ui-core-ship-chip.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-color-picker.mjs +947 -0
- package/fesm2022/ship-ui-core-ship-color-picker.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-datepicker.mjs +951 -0
- package/fesm2022/ship-ui-core-ship-datepicker.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-dialog.mjs +263 -0
- package/fesm2022/ship-ui-core-ship-dialog.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-divider.mjs +22 -0
- package/fesm2022/ship-ui-core-ship-divider.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-event-card.mjs +50 -0
- package/fesm2022/ship-ui-core-ship-event-card.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-file-upload.mjs +112 -0
- package/fesm2022/ship-ui-core-ship-file-upload.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-form-field.mjs +310 -0
- package/fesm2022/ship-ui-core-ship-form-field.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-icon.mjs +81 -0
- package/fesm2022/ship-ui-core-ship-icon.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-list.mjs +22 -0
- package/fesm2022/ship-ui-core-ship-list.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-menu.mjs +545 -0
- package/fesm2022/ship-ui-core-ship-menu.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-popover.mjs +286 -0
- package/fesm2022/ship-ui-core-ship-popover.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-progress-bar.mjs +37 -0
- package/fesm2022/ship-ui-core-ship-progress-bar.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-radio.mjs +102 -0
- package/fesm2022/ship-ui-core-ship-radio.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-range-slider.mjs +277 -0
- package/fesm2022/ship-ui-core-ship-range-slider.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-select.mjs +971 -0
- package/fesm2022/ship-ui-core-ship-select.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-sidenav.mjs +248 -0
- package/fesm2022/ship-ui-core-ship-sidenav.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-sortable.mjs +485 -0
- package/fesm2022/ship-ui-core-ship-sortable.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-spinner.mjs +28 -0
- package/fesm2022/ship-ui-core-ship-spinner.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-stepper.mjs +76 -0
- package/fesm2022/ship-ui-core-ship-stepper.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-table-filter-bar.mjs +28 -0
- package/fesm2022/ship-ui-core-ship-table-filter-bar.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-table.mjs +442 -0
- package/fesm2022/ship-ui-core-ship-table.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-tabs.mjs +38 -0
- package/fesm2022/ship-ui-core-ship-tabs.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-theme-toggle.mjs +119 -0
- package/fesm2022/ship-ui-core-ship-theme-toggle.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-toggle-card.mjs +75 -0
- package/fesm2022/ship-ui-core-ship-toggle-card.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-toggle.mjs +105 -0
- package/fesm2022/ship-ui-core-ship-toggle.mjs.map +1 -0
- package/fesm2022/ship-ui-core-ship-virtual-scroll.mjs +186 -0
- package/fesm2022/ship-ui-core-ship-virtual-scroll.mjs.map +1 -0
- package/fesm2022/ship-ui-core.mjs +880 -8782
- package/fesm2022/ship-ui-core.mjs.map +1 -1
- package/package.json +147 -3
- package/styles/core.scss +43 -0
- package/styles/helpers.scss +2 -0
- package/styles/index.scss +12 -123
- package/types/ship-ui-core-sh-form-field-experimental.d.ts +11 -0
- package/types/ship-ui-core-ship-accordion.d.ts +19 -0
- package/types/ship-ui-core-ship-alert.d.ts +68 -0
- package/types/ship-ui-core-ship-blueprint.d.ts +112 -0
- package/types/ship-ui-core-ship-button-group.d.ts +15 -0
- package/types/ship-ui-core-ship-button.d.ts +13 -0
- package/types/ship-ui-core-ship-card.d.ts +11 -0
- package/types/ship-ui-core-ship-checkbox.d.ts +22 -0
- package/types/ship-ui-core-ship-chip.d.ts +15 -0
- package/types/ship-ui-core-ship-color-picker.d.ts +105 -0
- package/types/ship-ui-core-ship-datepicker.d.ts +96 -0
- package/types/ship-ui-core-ship-dialog.d.ts +76 -0
- package/types/ship-ui-core-ship-divider.d.ts +8 -0
- package/types/ship-ui-core-ship-event-card.d.ts +11 -0
- package/types/ship-ui-core-ship-file-upload.d.ts +20 -0
- package/types/ship-ui-core-ship-form-field.d.ts +32 -0
- package/types/ship-ui-core-ship-icon.d.ts +18 -0
- package/types/ship-ui-core-ship-list.d.ts +8 -0
- package/types/ship-ui-core-ship-menu.d.ts +49 -0
- package/types/ship-ui-core-ship-popover.d.ts +40 -0
- package/types/ship-ui-core-ship-progress-bar.d.ts +14 -0
- package/types/ship-ui-core-ship-radio.d.ts +22 -0
- package/types/ship-ui-core-ship-range-slider.d.ts +31 -0
- package/types/ship-ui-core-ship-select.d.ts +81 -0
- package/types/ship-ui-core-ship-sidenav.d.ts +36 -0
- package/types/ship-ui-core-ship-sortable.d.ts +72 -0
- package/types/ship-ui-core-ship-spinner.d.ts +10 -0
- package/types/ship-ui-core-ship-stepper.d.ts +13 -0
- package/types/ship-ui-core-ship-table-filter-bar.d.ts +8 -0
- package/types/ship-ui-core-ship-table.d.ts +69 -0
- package/types/ship-ui-core-ship-tabs.d.ts +14 -0
- package/types/ship-ui-core-ship-theme-toggle.d.ts +28 -0
- package/types/ship-ui-core-ship-toggle-card.d.ts +15 -0
- package/types/ship-ui-core-ship-toggle.d.ts +21 -0
- package/types/ship-ui-core-ship-virtual-scroll.d.ts +22 -0
- package/types/ship-ui-core.d.ts +88 -1070
- package/styles/components/ship-accordion.scss +0 -113
- package/styles/components/ship-alert-container.scss +0 -49
- package/styles/components/ship-alert.scss +0 -177
- package/styles/components/ship-blueprint.scss +0 -242
- package/styles/components/ship-button-group.scss +0 -165
- package/styles/components/ship-button.scss +0 -141
- package/styles/components/ship-card.scss +0 -57
- package/styles/components/ship-checkbox.scss +0 -116
- package/styles/components/ship-chip.scss +0 -104
- package/styles/components/ship-color-picker.scss +0 -150
- package/styles/components/ship-datepicker.scss +0 -317
- package/styles/components/ship-dialog.scss +0 -152
- package/styles/components/ship-divider.scss +0 -27
- package/styles/components/ship-event-card.scss +0 -51
- package/styles/components/ship-file-upload.scss +0 -47
- package/styles/components/ship-form-field.scss +0 -408
- package/styles/components/ship-icon.scss +0 -54
- package/styles/components/ship-list.scss +0 -165
- package/styles/components/ship-menu.scss +0 -237
- package/styles/components/ship-popover.scss +0 -205
- package/styles/components/ship-progress-bar.scss +0 -173
- package/styles/components/ship-radio.scss +0 -113
- package/styles/components/ship-range-slider.scss +0 -421
- package/styles/components/ship-select.scss +0 -153
- package/styles/components/ship-sidenav.scss +0 -195
- package/styles/components/ship-sortable.scss +0 -45
- package/styles/components/ship-spinner.scss +0 -53
- package/styles/components/ship-stepper.scss +0 -158
- package/styles/components/ship-table.scss +0 -443
- package/styles/components/ship-tabs.scss +0 -125
- package/styles/components/ship-theme-toggle.scss +0 -41
- package/styles/components/ship-toggle-card.scss +0 -69
- package/styles/components/ship-toggle.scss +0 -255
- package/styles/components/ship-tooltip.scss +0 -151
- package/styles/components/ship-virtual-scroll.scss +0 -12
|
@@ -0,0 +1,951 @@
|
|
|
1
|
+
import { DatePipe } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { model, input, output, viewChild, signal, computed, effect, inject, ElementRef, HostListener, ChangeDetectionStrategy, ViewEncapsulation, Component, contentChild } from '@angular/core';
|
|
4
|
+
import { NgControl } from '@angular/forms';
|
|
5
|
+
import { ShipFormFieldPopover } from '@ship-ui/core/ship-form-field';
|
|
6
|
+
import { ShipIcon } from '@ship-ui/core/ship-icon';
|
|
7
|
+
import { classMutationSignal, contentProjectionSignal } from '@ship-ui/core';
|
|
8
|
+
|
|
9
|
+
class ShipDatepicker {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.#INIT_DATE = new Date(new Date().setHours(0, 0, 0, 0));
|
|
12
|
+
this.date = model(null, /* @ts-ignore */
|
|
13
|
+
...(ngDevMode ? [{ debugName: "date" }] : /* istanbul ignore next */ []));
|
|
14
|
+
this.endDate = model(null, /* @ts-ignore */
|
|
15
|
+
...(ngDevMode ? [{ debugName: "endDate" }] : /* istanbul ignore next */ []));
|
|
16
|
+
this.asRange = input(false, /* @ts-ignore */
|
|
17
|
+
...(ngDevMode ? [{ debugName: "asRange" }] : /* istanbul ignore next */ []));
|
|
18
|
+
this.activeRangeSelection = input(null, /* @ts-ignore */
|
|
19
|
+
...(ngDevMode ? [{ debugName: "activeRangeSelection" }] : /* istanbul ignore next */ []));
|
|
20
|
+
this.monthsToShow = input(1, /* @ts-ignore */
|
|
21
|
+
...(ngDevMode ? [{ debugName: "monthsToShow" }] : /* istanbul ignore next */ []));
|
|
22
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
24
|
+
this.tabbedOut = output();
|
|
25
|
+
this.startOfWeek = input(1, /* @ts-ignore */
|
|
26
|
+
...(ngDevMode ? [{ debugName: "startOfWeek" }] : /* istanbul ignore next */ []));
|
|
27
|
+
this.weekdayLabels = input(['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], /* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [{ debugName: "weekdayLabels" }] : /* istanbul ignore next */ []));
|
|
29
|
+
this.daysRef = viewChild('daysRef', /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "daysRef" }] : /* istanbul ignore next */ []));
|
|
31
|
+
this.currentDate = signal(this.date() ?? this.#INIT_DATE, /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "currentDate" }] : /* istanbul ignore next */ []));
|
|
33
|
+
this.monthOffsets = computed(() => {
|
|
34
|
+
return Array.from({ length: this.monthsToShow() }, (_, i) => i);
|
|
35
|
+
}, /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "monthOffsets" }] : /* istanbul ignore next */ []));
|
|
37
|
+
this.selectedDateStylePosition = signal(null, /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "selectedDateStylePosition" }] : /* istanbul ignore next */ []));
|
|
39
|
+
this.weekdays = computed(() => {
|
|
40
|
+
const startOfWeek = this.startOfWeek();
|
|
41
|
+
const weekdayLabels = this.weekdayLabels();
|
|
42
|
+
return weekdayLabels.slice(startOfWeek).concat(weekdayLabels.slice(0, startOfWeek));
|
|
43
|
+
}, /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "weekdays" }] : /* istanbul ignore next */ []));
|
|
45
|
+
this.currentClasses = classMutationSignal();
|
|
46
|
+
this.someEffect = effect(() => {
|
|
47
|
+
const _ = this.currentClasses();
|
|
48
|
+
this.#findSelectedAndCalc();
|
|
49
|
+
}, /* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "someEffect" }] : /* istanbul ignore next */ []));
|
|
51
|
+
this.#newDateEffect = effect(() => {
|
|
52
|
+
if (this.monthsToShow() > 1)
|
|
53
|
+
return;
|
|
54
|
+
this.#setDateAsCurrent();
|
|
55
|
+
}, /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "#newDateEffect" }] : /* istanbul ignore next */ []));
|
|
57
|
+
this.focusedDate = signal(null, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "focusedDate" }] : /* istanbul ignore next */ []));
|
|
59
|
+
this.#selfRef = inject(ElementRef);
|
|
60
|
+
}
|
|
61
|
+
#INIT_DATE;
|
|
62
|
+
getLastVisibleMonth() {
|
|
63
|
+
const lastMonthOffset = this.monthsToShow() - 1;
|
|
64
|
+
return this.getOffsetDate(lastMonthOffset);
|
|
65
|
+
}
|
|
66
|
+
getOffsetDate(monthOffset) {
|
|
67
|
+
const date = new Date(this.currentDate());
|
|
68
|
+
date.setMonth(date.getMonth() + monthOffset);
|
|
69
|
+
return date;
|
|
70
|
+
}
|
|
71
|
+
getMonthDates(monthOffset) {
|
|
72
|
+
const offsetDate = this.getOffsetDate(monthOffset);
|
|
73
|
+
return this.#generateMonthDates(offsetDate, this.startOfWeek());
|
|
74
|
+
}
|
|
75
|
+
#newDateEffect;
|
|
76
|
+
ngOnInit() {
|
|
77
|
+
if (this.monthsToShow() === 1)
|
|
78
|
+
return;
|
|
79
|
+
this.#setDateAsCurrent();
|
|
80
|
+
}
|
|
81
|
+
#setDateAsCurrent() {
|
|
82
|
+
const newDate = this.date();
|
|
83
|
+
if (newDate && !isNaN(newDate.getTime())) {
|
|
84
|
+
this.currentDate.set(newDate);
|
|
85
|
+
}
|
|
86
|
+
this.#findSelectedAndCalc();
|
|
87
|
+
}
|
|
88
|
+
#findSelectedAndCalc() {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
const selectedElement = this.daysRef()?.nativeElement.querySelector('.sel');
|
|
91
|
+
if (!selectedElement) {
|
|
92
|
+
return this.selectedDateStylePosition.update((x) => (x ? { ...x, opacity: '0' } : null));
|
|
93
|
+
}
|
|
94
|
+
this.setSelectedDateStylePosition(selectedElement);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
#generateMonthDates(date, startOfWeek) {
|
|
98
|
+
const year = date.getFullYear();
|
|
99
|
+
const month = date.getMonth();
|
|
100
|
+
const firstDay = new Date(year, month, 1).getDay();
|
|
101
|
+
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
102
|
+
const dates = [];
|
|
103
|
+
let offset = firstDay - startOfWeek;
|
|
104
|
+
if (offset < 0) {
|
|
105
|
+
offset += 7;
|
|
106
|
+
}
|
|
107
|
+
const lastDayOfPrevMonth = new Date(year, month, 0).getDate();
|
|
108
|
+
for (let i = offset - 1; i >= 0; i--) {
|
|
109
|
+
dates.push(new Date(year, month - 1, lastDayOfPrevMonth - i, 0, 0, 0, 0));
|
|
110
|
+
}
|
|
111
|
+
for (let i = 1; i <= daysInMonth; i++) {
|
|
112
|
+
dates.push(new Date(year, month, i, 0, 0, 0, 0));
|
|
113
|
+
}
|
|
114
|
+
let nextMonthDay = 1;
|
|
115
|
+
while (dates.length % 7 !== 0) {
|
|
116
|
+
dates.push(new Date(year, month + 1, nextMonthDay++, 0, 0, 0, 0));
|
|
117
|
+
}
|
|
118
|
+
return dates;
|
|
119
|
+
}
|
|
120
|
+
nextMonth() {
|
|
121
|
+
this.currentDate.update((currentDate) => {
|
|
122
|
+
const newDate = new Date(currentDate);
|
|
123
|
+
newDate.setMonth(currentDate.getMonth() + 1);
|
|
124
|
+
return newDate;
|
|
125
|
+
});
|
|
126
|
+
this.#findSelectedAndCalc();
|
|
127
|
+
}
|
|
128
|
+
previousMonth() {
|
|
129
|
+
this.currentDate.update((currentDate) => {
|
|
130
|
+
const newDate = new Date(currentDate);
|
|
131
|
+
newDate.setMonth(currentDate.getMonth() - 1);
|
|
132
|
+
return newDate;
|
|
133
|
+
});
|
|
134
|
+
this.#findSelectedAndCalc();
|
|
135
|
+
}
|
|
136
|
+
setDate(newDate, selectedElement) {
|
|
137
|
+
this.focusedDate.set(newDate);
|
|
138
|
+
const createDateWithExistingTime = (newDate, existingDate) => {
|
|
139
|
+
let hours = 0, minutes = 0, seconds = 0, milliseconds = 0;
|
|
140
|
+
if (existingDate) {
|
|
141
|
+
if (typeof existingDate === 'string' || typeof existingDate === 'number') {
|
|
142
|
+
existingDate = new Date(existingDate);
|
|
143
|
+
}
|
|
144
|
+
if (existingDate instanceof Date && !isNaN(existingDate.getTime())) {
|
|
145
|
+
hours = existingDate.getHours();
|
|
146
|
+
minutes = existingDate.getMinutes();
|
|
147
|
+
seconds = existingDate.getSeconds();
|
|
148
|
+
milliseconds = existingDate.getMilliseconds();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return new Date(newDate.getFullYear(), newDate.getMonth(), newDate.getDate(), hours, minutes, seconds, milliseconds);
|
|
152
|
+
};
|
|
153
|
+
if (!this.asRange()) {
|
|
154
|
+
this.date.set(createDateWithExistingTime(newDate, this.date()));
|
|
155
|
+
this.endDate.set(null);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
const startDate = this.date();
|
|
159
|
+
const endDate = this.endDate();
|
|
160
|
+
const selectionMode = this.activeRangeSelection();
|
|
161
|
+
if (selectionMode === 'start') {
|
|
162
|
+
const utcDate = createDateWithExistingTime(newDate, startDate);
|
|
163
|
+
this.date.set(utcDate);
|
|
164
|
+
if (endDate && utcDate > endDate) {
|
|
165
|
+
this.endDate.set(null);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else if (selectionMode === 'end') {
|
|
169
|
+
if (!startDate || newDate < startDate) {
|
|
170
|
+
const newStart = createDateWithExistingTime(newDate, startDate);
|
|
171
|
+
this.date.set(newStart);
|
|
172
|
+
this.endDate.set(null);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const utcDate = createDateWithExistingTime(newDate, endDate);
|
|
176
|
+
this.endDate.set(utcDate);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
if (!startDate) {
|
|
181
|
+
const utcDate = createDateWithExistingTime(newDate, startDate);
|
|
182
|
+
this.date.set(utcDate);
|
|
183
|
+
}
|
|
184
|
+
else if (!endDate) {
|
|
185
|
+
if (newDate < startDate) {
|
|
186
|
+
const newStart = createDateWithExistingTime(newDate, startDate);
|
|
187
|
+
this.date.set(newStart);
|
|
188
|
+
this.endDate.set(null);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const utcDate = createDateWithExistingTime(newDate, endDate);
|
|
192
|
+
this.endDate.set(utcDate);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const utcDate = createDateWithExistingTime(newDate, startDate);
|
|
197
|
+
this.date.set(utcDate);
|
|
198
|
+
this.endDate.set(null);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (this.asRange())
|
|
203
|
+
return;
|
|
204
|
+
this.setSelectedDateStylePosition(selectedElement);
|
|
205
|
+
}
|
|
206
|
+
isDateSelected(date) {
|
|
207
|
+
let startDate = this.date();
|
|
208
|
+
let endDate = this.endDate();
|
|
209
|
+
if (typeof startDate === 'string' || typeof startDate === 'number')
|
|
210
|
+
startDate = new Date(startDate);
|
|
211
|
+
if (typeof endDate === 'string' || typeof endDate === 'number')
|
|
212
|
+
endDate = new Date(endDate);
|
|
213
|
+
if (!startDate || !(startDate instanceof Date) || isNaN(startDate.getTime()))
|
|
214
|
+
return null;
|
|
215
|
+
const startOfDay = (date) => {
|
|
216
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
|
|
217
|
+
};
|
|
218
|
+
const endOfDay = (date) => {
|
|
219
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999);
|
|
220
|
+
};
|
|
221
|
+
const currentDate = startOfDay(date);
|
|
222
|
+
const rangeStart = startOfDay(startDate);
|
|
223
|
+
const rangeEnd = endDate ? endOfDay(endDate) : null;
|
|
224
|
+
let classes = [];
|
|
225
|
+
if (this.asRange()) {
|
|
226
|
+
if (rangeEnd === null) {
|
|
227
|
+
if (currentDate.getTime() === rangeStart.getTime()) {
|
|
228
|
+
classes.push('sel first last');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
if (currentDate.getTime() === rangeStart.getTime()) {
|
|
233
|
+
classes.push('first');
|
|
234
|
+
}
|
|
235
|
+
if (currentDate.getTime() === startOfDay(rangeEnd).getTime()) {
|
|
236
|
+
classes.push('last');
|
|
237
|
+
}
|
|
238
|
+
if (currentDate >= rangeStart && currentDate <= rangeEnd) {
|
|
239
|
+
classes.push('sel');
|
|
240
|
+
const dayOfWeek = currentDate.getDay();
|
|
241
|
+
const startOfWeek = this.startOfWeek();
|
|
242
|
+
if (dayOfWeek === startOfWeek) {
|
|
243
|
+
classes.push('week-start');
|
|
244
|
+
}
|
|
245
|
+
const endOfWeek = (startOfWeek + 6) % 7;
|
|
246
|
+
if (dayOfWeek === endOfWeek) {
|
|
247
|
+
classes.push('week-end');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const nextDate = new Date(currentDate);
|
|
251
|
+
nextDate.setDate(currentDate.getDate() + 1);
|
|
252
|
+
const prevDate = new Date(currentDate);
|
|
253
|
+
prevDate.setDate(currentDate.getDate() - 1);
|
|
254
|
+
const isFirstOfMonth = currentDate.getDate() === 1;
|
|
255
|
+
const isLastOfMonth = nextDate.getMonth() !== currentDate.getMonth();
|
|
256
|
+
if (isFirstOfMonth) {
|
|
257
|
+
classes.push('month-start');
|
|
258
|
+
}
|
|
259
|
+
if (isLastOfMonth) {
|
|
260
|
+
classes.push('month-end');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
if (currentDate.getTime() === rangeStart.getTime()) {
|
|
266
|
+
classes.push('sel');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return classes.join(' ') || null;
|
|
270
|
+
}
|
|
271
|
+
setSelectedDateStylePosition(selectedElement) {
|
|
272
|
+
this.selectedDateStylePosition.set({
|
|
273
|
+
transform: `translate(${selectedElement.offsetLeft}px, ${selectedElement.offsetTop}px)`,
|
|
274
|
+
opacity: '1',
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
getMonthName(date) {
|
|
278
|
+
return date.toLocaleString('default', { month: 'long' });
|
|
279
|
+
}
|
|
280
|
+
getFullYear(date) {
|
|
281
|
+
return date.getFullYear();
|
|
282
|
+
}
|
|
283
|
+
// Rest of the component methods remain the same, but update isCurrentMonth:
|
|
284
|
+
isCurrentMonth(date, monthOffset) {
|
|
285
|
+
const offsetDate = this.getOffsetDate(monthOffset);
|
|
286
|
+
return date.getMonth() === offsetDate.getMonth();
|
|
287
|
+
}
|
|
288
|
+
#selfRef;
|
|
289
|
+
isSameDay(d1, d2) {
|
|
290
|
+
if (!d1 || !d2)
|
|
291
|
+
return false;
|
|
292
|
+
return d1.getFullYear() === d2.getFullYear() &&
|
|
293
|
+
d1.getMonth() === d2.getMonth() &&
|
|
294
|
+
d1.getDate() === d2.getDate();
|
|
295
|
+
}
|
|
296
|
+
getAriaLabel(date) {
|
|
297
|
+
return date.toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
|
298
|
+
}
|
|
299
|
+
getTabIndex(date) {
|
|
300
|
+
const focused = this.focusedDate();
|
|
301
|
+
const selected = this.date();
|
|
302
|
+
const today = new Date();
|
|
303
|
+
if (focused) {
|
|
304
|
+
return this.isSameDay(date, focused) ? 0 : -1;
|
|
305
|
+
}
|
|
306
|
+
if (selected) {
|
|
307
|
+
return this.isSameDay(date, selected) ? 0 : -1;
|
|
308
|
+
}
|
|
309
|
+
return this.isSameDay(date, today) ? 0 : -1;
|
|
310
|
+
}
|
|
311
|
+
isDateSelectedBool(date) {
|
|
312
|
+
const classes = this.isDateSelected(date);
|
|
313
|
+
return classes ? classes.includes('sel') : false;
|
|
314
|
+
}
|
|
315
|
+
onKeydown(event, date) {
|
|
316
|
+
let newDate = new Date(date);
|
|
317
|
+
let handled = false;
|
|
318
|
+
switch (event.key) {
|
|
319
|
+
case 'ArrowRight':
|
|
320
|
+
newDate.setDate(date.getDate() + 1);
|
|
321
|
+
handled = true;
|
|
322
|
+
break;
|
|
323
|
+
case 'ArrowLeft':
|
|
324
|
+
newDate.setDate(date.getDate() - 1);
|
|
325
|
+
handled = true;
|
|
326
|
+
break;
|
|
327
|
+
case 'ArrowDown':
|
|
328
|
+
newDate.setDate(date.getDate() + 7);
|
|
329
|
+
handled = true;
|
|
330
|
+
break;
|
|
331
|
+
case 'ArrowUp':
|
|
332
|
+
newDate.setDate(date.getDate() - 7);
|
|
333
|
+
handled = true;
|
|
334
|
+
break;
|
|
335
|
+
case 'PageDown':
|
|
336
|
+
newDate.setMonth(date.getMonth() + 1);
|
|
337
|
+
handled = true;
|
|
338
|
+
break;
|
|
339
|
+
case 'PageUp':
|
|
340
|
+
newDate.setMonth(date.getMonth() - 1);
|
|
341
|
+
handled = true;
|
|
342
|
+
break;
|
|
343
|
+
// Space and Enter are natively handled by the button's click event
|
|
344
|
+
}
|
|
345
|
+
if (handled) {
|
|
346
|
+
event.preventDefault();
|
|
347
|
+
this.ensureDateVisible(newDate);
|
|
348
|
+
this.focusedDate.set(newDate);
|
|
349
|
+
setTimeout(() => {
|
|
350
|
+
const buttons = this.#selfRef.nativeElement.querySelectorAll('button');
|
|
351
|
+
if (buttons) {
|
|
352
|
+
const targetAria = this.getAriaLabel(newDate);
|
|
353
|
+
for (let i = 0; i < buttons.length; i++) {
|
|
354
|
+
if (buttons[i].getAttribute('aria-label') === targetAria) {
|
|
355
|
+
buttons[i].focus();
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
ensureDateVisible(date) {
|
|
364
|
+
const start = this.currentDate();
|
|
365
|
+
const end = this.getLastVisibleMonth();
|
|
366
|
+
if (date < new Date(start.getFullYear(), start.getMonth(), 1)) {
|
|
367
|
+
this.currentDate.set(new Date(date.getFullYear(), date.getMonth(), 1));
|
|
368
|
+
this.#findSelectedAndCalc();
|
|
369
|
+
}
|
|
370
|
+
else if (date > new Date(end.getFullYear(), end.getMonth() + 1, 0)) {
|
|
371
|
+
const newStart = new Date(date);
|
|
372
|
+
newStart.setMonth(newStart.getMonth() - this.monthsToShow() + 1);
|
|
373
|
+
newStart.setDate(1);
|
|
374
|
+
this.currentDate.set(newStart);
|
|
375
|
+
this.#findSelectedAndCalc();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
focusActiveDate() {
|
|
379
|
+
setTimeout(() => {
|
|
380
|
+
const activeBtn = this.#selfRef.nativeElement.querySelector('button[tabindex="0"]');
|
|
381
|
+
if (activeBtn)
|
|
382
|
+
activeBtn.focus();
|
|
383
|
+
}, 50);
|
|
384
|
+
}
|
|
385
|
+
onFocusOut(event) {
|
|
386
|
+
setTimeout(() => {
|
|
387
|
+
const activeElement = document.activeElement;
|
|
388
|
+
if (activeElement &&
|
|
389
|
+
activeElement !== document.body &&
|
|
390
|
+
!this.#selfRef.nativeElement.contains(activeElement)) {
|
|
391
|
+
this.tabbedOut.emit();
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipDatepicker, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
396
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ShipDatepicker, isStandalone: true, selector: "sh-datepicker", inputs: { date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, endDate: { classPropertyName: "endDate", publicName: "endDate", isSignal: true, isRequired: false, transformFunction: null }, asRange: { classPropertyName: "asRange", publicName: "asRange", isSignal: true, isRequired: false, transformFunction: null }, activeRangeSelection: { classPropertyName: "activeRangeSelection", publicName: "activeRangeSelection", isSignal: true, isRequired: false, transformFunction: null }, monthsToShow: { classPropertyName: "monthsToShow", publicName: "monthsToShow", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, startOfWeek: { classPropertyName: "startOfWeek", publicName: "startOfWeek", isSignal: true, isRequired: false, transformFunction: null }, weekdayLabels: { classPropertyName: "weekdayLabels", publicName: "weekdayLabels", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange", endDate: "endDateChange", tabbedOut: "tabbedOut" }, host: { listeners: { "focusout": "onFocusOut($event)" }, properties: { "class.as-range": "asRange()", "class": "\"columns-\" + monthsToShow()", "class.disabled": "disabled()" } }, viewQueries: [{ propertyName: "daysRef", first: true, predicate: ["daysRef"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
397
|
+
<header>
|
|
398
|
+
<button tabindex="-1" (click)="previousMonth()"><sh-icon>caret-left</sh-icon></button>
|
|
399
|
+
<div class="title">
|
|
400
|
+
{{ getMonthName(currentDate()!) }}
|
|
401
|
+
@if (monthsToShow() > 1) {
|
|
402
|
+
- {{ getMonthName(getLastVisibleMonth()) }}
|
|
403
|
+
}
|
|
404
|
+
{{ getFullYear(currentDate()!) }}
|
|
405
|
+
</div>
|
|
406
|
+
<button tabindex="-1" (click)="nextMonth()"><sh-icon>caret-right</sh-icon></button>
|
|
407
|
+
</header>
|
|
408
|
+
|
|
409
|
+
<section class="months-container">
|
|
410
|
+
@for (monthOffset of monthOffsets(); track monthOffset) {
|
|
411
|
+
<div class="month">
|
|
412
|
+
<nav class="weekdays">
|
|
413
|
+
@for (day of weekdays(); track $index) {
|
|
414
|
+
<div>{{ day }}</div>
|
|
415
|
+
}
|
|
416
|
+
</nav>
|
|
417
|
+
|
|
418
|
+
<div class="days" #daysRef>
|
|
419
|
+
@for (calDate of getMonthDates(monthOffset); track $index) {
|
|
420
|
+
<button
|
|
421
|
+
type="button"
|
|
422
|
+
#elementRef
|
|
423
|
+
[class.out-of-scope]="!isCurrentMonth(calDate, monthOffset)"
|
|
424
|
+
[class]="isDateSelected(calDate)"
|
|
425
|
+
[attr.aria-label]="getAriaLabel(calDate)"
|
|
426
|
+
[attr.tabindex]="getTabIndex(calDate)"
|
|
427
|
+
[attr.aria-selected]="isDateSelectedBool(calDate)"
|
|
428
|
+
(keydown)="onKeydown($event, calDate)"
|
|
429
|
+
(click)="setDate(calDate, elementRef)">
|
|
430
|
+
{{ calDate.getDate() }}
|
|
431
|
+
</button>
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
@if (!asRange()) {
|
|
435
|
+
<article class="days">
|
|
436
|
+
<div class="sel-el" [style]="selectedDateStylePosition()"></div>
|
|
437
|
+
</article>
|
|
438
|
+
}
|
|
439
|
+
</div>
|
|
440
|
+
</div>
|
|
441
|
+
}
|
|
442
|
+
</section>
|
|
443
|
+
`, isInline: true, styles: ["sh-daterange-input sh-form-field-popover .input-wrap .input,sh-datepicker-input sh-form-field-popover .input-wrap .input{display:grid;grid-template-columns:1fr auto auto;align-items:center}sh-daterange-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap [suffix],sh-datepicker-input sh-form-field-popover .input-wrap [suffix]{margin-right:.75rem}sh-daterange-input sh-form-field-popover .masked-value,sh-datepicker-input sh-form-field-popover .masked-value{font:var(--paragraph-30B);color:var(--base-8);display:flex;gap:.25rem}sh-daterange-input sh-form-field-popover .masked-value.active-start .start-val,sh-datepicker-input sh-form-field-popover .masked-value.active-start .start-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value.active-end .end-val,sh-datepicker-input sh-form-field-popover .masked-value.active-end .end-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value+input+input,sh-daterange-input sh-form-field-popover .masked-value+input,sh-datepicker-input sh-form-field-popover .masked-value+input+input,sh-datepicker-input sh-form-field-popover .masked-value+input{opacity:0;height:0;width:0;margin:0}sh-daterange-input sh-form-field-popover [suffix]+[suffix].default-indicator,sh-datepicker-input sh-form-field-popover [suffix]+[suffix].default-indicator{display:none}sh-daterange-input sh-datepicker,sh-datepicker-input sh-datepicker{z-index:10000;position:relative;--dp-width: 15rem}sh-daterange-input sh-popover .popover-content{--dp-width: 18.75rem;min-width:var(--dp-width)}sh-daterange-input sh-form-field-popover.columns-1 sh-popover .popover-content{--dp-width: 18.75rem }sh-daterange-input sh-form-field-popover.columns-2 sh-popover .popover-content{--dp-width: 38.5rem }sh-daterange-input sh-form-field-popover.columns-3 sh-popover .popover-content{--dp-width: 58.25rem }sh-datepicker-input.sharp sh-datepicker,sh-daterange-input.sharp sh-datepicker,sh-datepicker.sharp{--dp-sel-s: var(--shape-1);--dp-ar: 1/.8;--dp-day-g: .5rem 0}sh-datepicker{--dp-sel-bg: var(--base-8);--dp-sel-bw: 0;--dp-sel-bc: transparent;--dp-sel-s: 50%;--dp-sel-c: #fff;--dp-day-c: var(--base-8);--dp-day-g: .25rem 0;--dp-day-f: var(--paragraph-20);--dp-width: 18.75rem;--dp-ar: 1/1;width:100%;padding:.5rem;max-width:var(--dp-width);display:flex;flex-direction:column}sh-datepicker.disabled{opacity:.5;pointer-events:none;-webkit-user-select:none;user-select:none;cursor:initial}sh-datepicker.columns-1{--dp-width: 18.75rem }sh-datepicker.columns-2{--dp-width: 38.5rem }sh-datepicker.columns-3{--dp-width: 58.25rem }sh-datepicker.columns-4{--dp-width: 78rem }sh-datepicker.columns-5{--dp-width: 97.75rem }sh-datepicker.columns-6{--dp-width: 117.5rem }sh-datepicker.columns-7{--dp-width: 137.25rem }sh-datepicker.columns-8{--dp-width: 157rem }sh-datepicker.columns-9{--dp-width: 176.75rem }sh-datepicker.columns-10{--dp-width: 196.5rem }sh-datepicker.columns-11{--dp-width: 216.25rem }sh-datepicker.columns-12{--dp-width: 236rem }sh-datepicker.as-range section .days>div.sel,sh-datepicker.as-range section .days>button.sel{background:var(--dp-sel-bg);opacity:.5;border-radius:0}sh-datepicker.as-range section .days>div.month-start,sh-datepicker.as-range section .days>div.week-start,sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>button.month-start,sh-datepicker.as-range section .days>button.week-start,sh-datepicker.as-range section .days>button.first{border-top-left-radius:var(--dp-sel-s);border-bottom-left-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.month-end,sh-datepicker.as-range section .days>div.week-end,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.month-end,sh-datepicker.as-range section .days>button.week-end,sh-datepicker.as-range section .days>button.last{border-top-right-radius:var(--dp-sel-s);border-bottom-right-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.first,sh-datepicker.as-range section .days>button.last{opacity:1}sh-datepicker.as-range .month .days>div.out-of-scope,sh-datepicker.as-range .month .days>button.out-of-scope{opacity:0;pointer-events:none}sh-datepicker header{display:flex;align-items:center;justify-content:space-between;padding:.25rem 0;gap:0}sh-datepicker header .title{font:var(--paragraph-20)}sh-datepicker header button{appearance:none;background-color:transparent;border:0;cursor:pointer;height:2rem;color:var(--base-8)}sh-datepicker header button:focus{outline:none}sh-datepicker .months-container{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1rem}sh-datepicker .month{display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:1fr 6fr;gap:var(--dp-day-g);align-items:flex-start}sh-datepicker .month .days,sh-datepicker .month .weekdays{display:grid;grid-column:1/-1;gap:var(--dp-day-g);grid-template-columns:subgrid;position:relative}sh-datepicker .month .days>.days,sh-datepicker .month .weekdays>.days{position:absolute;top:0;left:0;width:100%;height:100%;display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:repeat(7,1fr);gap:var(--dp-day-g);z-index:0}sh-datepicker .month .days>div,sh-datepicker .month .days>button,sh-datepicker .month .weekdays>div,sh-datepicker .month .weekdays>button{appearance:none;background:transparent;border:none;padding:0;margin:0;display:flex;align-items:center;justify-content:center;aspect-ratio:var(--dp-ar);cursor:pointer;position:relative;z-index:1;color:var(--dp-day-c);font:var(--dp-day-f);-webkit-user-select:none;user-select:none;border-radius:var(--dp-sel-s)}sh-datepicker .month .days>div:focus-visible,sh-datepicker .month .days>button:focus-visible,sh-datepicker .month .weekdays>div:focus-visible,sh-datepicker .month .weekdays>button:focus-visible{outline:2px solid var(--primary-10, #005fcc);outline-offset:-2px}sh-datepicker .month .days>div.sel,sh-datepicker .month .days>button.sel,sh-datepicker .month .weekdays>div.sel,sh-datepicker .month .weekdays>button.sel{color:var(--dp-sel-c);transition:color 75ms linear}sh-datepicker .month .days>div.out-of-scope,sh-datepicker .month .days>button.out-of-scope,sh-datepicker .month .weekdays>div.out-of-scope,sh-datepicker .month .weekdays>button.out-of-scope{opacity:.4}sh-datepicker .month .days>div.sel-el,sh-datepicker .month .days>button.sel-el,sh-datepicker .month .weekdays>div.sel-el,sh-datepicker .month .weekdays>button.sel-el{position:relative;top:0;left:0;transition:transform 75ms linear,opacity 75ms linear;background:var(--dp-sel-bg);border-radius:var(--dp-sel-s);border:var(--dp-sel-bw) solid var(--dp-sel-bc);opacity:0;box-sizing:border-box}sh-datepicker .month .weekdays>div{color:var(--base-12)}sh-datepicker.primary{--dp-sel-bg: var(--primary-8)}sh-datepicker.accent{--dp-sel-bg: var(--accent-8)}sh-datepicker.warn{--dp-sel-bg: var(--warn-8)}sh-datepicker.error{--dp-sel-bg: var(--error-8)}sh-datepicker.success{--dp-sel-bg: var(--success-8)}sh-datepicker.raised{--dp-sel-bg: var(--base-g2)}sh-datepicker.raised.primary{--dp-sel-bg: var(--primary-g2)}sh-datepicker.raised.accent{--dp-sel-bg: var(--accent-g2)}sh-datepicker.raised.warn{--dp-sel-bg: var(--warn-g2)}sh-datepicker.raised.error{--dp-sel-bg: var(--error-g2)}sh-datepicker.raised.success{--dp-sel-bg: var(--success-g2)}\n"], dependencies: [{ kind: "component", type: ShipIcon, selector: "sh-icon", inputs: ["color", "size"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
444
|
+
}
|
|
445
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipDatepicker, decorators: [{
|
|
446
|
+
type: Component,
|
|
447
|
+
args: [{ selector: 'sh-datepicker', encapsulation: ViewEncapsulation.None, imports: [ShipIcon], template: `
|
|
448
|
+
<header>
|
|
449
|
+
<button tabindex="-1" (click)="previousMonth()"><sh-icon>caret-left</sh-icon></button>
|
|
450
|
+
<div class="title">
|
|
451
|
+
{{ getMonthName(currentDate()!) }}
|
|
452
|
+
@if (monthsToShow() > 1) {
|
|
453
|
+
- {{ getMonthName(getLastVisibleMonth()) }}
|
|
454
|
+
}
|
|
455
|
+
{{ getFullYear(currentDate()!) }}
|
|
456
|
+
</div>
|
|
457
|
+
<button tabindex="-1" (click)="nextMonth()"><sh-icon>caret-right</sh-icon></button>
|
|
458
|
+
</header>
|
|
459
|
+
|
|
460
|
+
<section class="months-container">
|
|
461
|
+
@for (monthOffset of monthOffsets(); track monthOffset) {
|
|
462
|
+
<div class="month">
|
|
463
|
+
<nav class="weekdays">
|
|
464
|
+
@for (day of weekdays(); track $index) {
|
|
465
|
+
<div>{{ day }}</div>
|
|
466
|
+
}
|
|
467
|
+
</nav>
|
|
468
|
+
|
|
469
|
+
<div class="days" #daysRef>
|
|
470
|
+
@for (calDate of getMonthDates(monthOffset); track $index) {
|
|
471
|
+
<button
|
|
472
|
+
type="button"
|
|
473
|
+
#elementRef
|
|
474
|
+
[class.out-of-scope]="!isCurrentMonth(calDate, monthOffset)"
|
|
475
|
+
[class]="isDateSelected(calDate)"
|
|
476
|
+
[attr.aria-label]="getAriaLabel(calDate)"
|
|
477
|
+
[attr.tabindex]="getTabIndex(calDate)"
|
|
478
|
+
[attr.aria-selected]="isDateSelectedBool(calDate)"
|
|
479
|
+
(keydown)="onKeydown($event, calDate)"
|
|
480
|
+
(click)="setDate(calDate, elementRef)">
|
|
481
|
+
{{ calDate.getDate() }}
|
|
482
|
+
</button>
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
@if (!asRange()) {
|
|
486
|
+
<article class="days">
|
|
487
|
+
<div class="sel-el" [style]="selectedDateStylePosition()"></div>
|
|
488
|
+
</article>
|
|
489
|
+
}
|
|
490
|
+
</div>
|
|
491
|
+
</div>
|
|
492
|
+
}
|
|
493
|
+
</section>
|
|
494
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
495
|
+
'[class.as-range]': 'asRange()',
|
|
496
|
+
'[class]': '"columns-" + monthsToShow()',
|
|
497
|
+
'[class.disabled]': 'disabled()',
|
|
498
|
+
}, styles: ["sh-daterange-input sh-form-field-popover .input-wrap .input,sh-datepicker-input sh-form-field-popover .input-wrap .input{display:grid;grid-template-columns:1fr auto auto;align-items:center}sh-daterange-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap [suffix],sh-datepicker-input sh-form-field-popover .input-wrap [suffix]{margin-right:.75rem}sh-daterange-input sh-form-field-popover .masked-value,sh-datepicker-input sh-form-field-popover .masked-value{font:var(--paragraph-30B);color:var(--base-8);display:flex;gap:.25rem}sh-daterange-input sh-form-field-popover .masked-value.active-start .start-val,sh-datepicker-input sh-form-field-popover .masked-value.active-start .start-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value.active-end .end-val,sh-datepicker-input sh-form-field-popover .masked-value.active-end .end-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value+input+input,sh-daterange-input sh-form-field-popover .masked-value+input,sh-datepicker-input sh-form-field-popover .masked-value+input+input,sh-datepicker-input sh-form-field-popover .masked-value+input{opacity:0;height:0;width:0;margin:0}sh-daterange-input sh-form-field-popover [suffix]+[suffix].default-indicator,sh-datepicker-input sh-form-field-popover [suffix]+[suffix].default-indicator{display:none}sh-daterange-input sh-datepicker,sh-datepicker-input sh-datepicker{z-index:10000;position:relative;--dp-width: 15rem}sh-daterange-input sh-popover .popover-content{--dp-width: 18.75rem;min-width:var(--dp-width)}sh-daterange-input sh-form-field-popover.columns-1 sh-popover .popover-content{--dp-width: 18.75rem }sh-daterange-input sh-form-field-popover.columns-2 sh-popover .popover-content{--dp-width: 38.5rem }sh-daterange-input sh-form-field-popover.columns-3 sh-popover .popover-content{--dp-width: 58.25rem }sh-datepicker-input.sharp sh-datepicker,sh-daterange-input.sharp sh-datepicker,sh-datepicker.sharp{--dp-sel-s: var(--shape-1);--dp-ar: 1/.8;--dp-day-g: .5rem 0}sh-datepicker{--dp-sel-bg: var(--base-8);--dp-sel-bw: 0;--dp-sel-bc: transparent;--dp-sel-s: 50%;--dp-sel-c: #fff;--dp-day-c: var(--base-8);--dp-day-g: .25rem 0;--dp-day-f: var(--paragraph-20);--dp-width: 18.75rem;--dp-ar: 1/1;width:100%;padding:.5rem;max-width:var(--dp-width);display:flex;flex-direction:column}sh-datepicker.disabled{opacity:.5;pointer-events:none;-webkit-user-select:none;user-select:none;cursor:initial}sh-datepicker.columns-1{--dp-width: 18.75rem }sh-datepicker.columns-2{--dp-width: 38.5rem }sh-datepicker.columns-3{--dp-width: 58.25rem }sh-datepicker.columns-4{--dp-width: 78rem }sh-datepicker.columns-5{--dp-width: 97.75rem }sh-datepicker.columns-6{--dp-width: 117.5rem }sh-datepicker.columns-7{--dp-width: 137.25rem }sh-datepicker.columns-8{--dp-width: 157rem }sh-datepicker.columns-9{--dp-width: 176.75rem }sh-datepicker.columns-10{--dp-width: 196.5rem }sh-datepicker.columns-11{--dp-width: 216.25rem }sh-datepicker.columns-12{--dp-width: 236rem }sh-datepicker.as-range section .days>div.sel,sh-datepicker.as-range section .days>button.sel{background:var(--dp-sel-bg);opacity:.5;border-radius:0}sh-datepicker.as-range section .days>div.month-start,sh-datepicker.as-range section .days>div.week-start,sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>button.month-start,sh-datepicker.as-range section .days>button.week-start,sh-datepicker.as-range section .days>button.first{border-top-left-radius:var(--dp-sel-s);border-bottom-left-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.month-end,sh-datepicker.as-range section .days>div.week-end,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.month-end,sh-datepicker.as-range section .days>button.week-end,sh-datepicker.as-range section .days>button.last{border-top-right-radius:var(--dp-sel-s);border-bottom-right-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.first,sh-datepicker.as-range section .days>button.last{opacity:1}sh-datepicker.as-range .month .days>div.out-of-scope,sh-datepicker.as-range .month .days>button.out-of-scope{opacity:0;pointer-events:none}sh-datepicker header{display:flex;align-items:center;justify-content:space-between;padding:.25rem 0;gap:0}sh-datepicker header .title{font:var(--paragraph-20)}sh-datepicker header button{appearance:none;background-color:transparent;border:0;cursor:pointer;height:2rem;color:var(--base-8)}sh-datepicker header button:focus{outline:none}sh-datepicker .months-container{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1rem}sh-datepicker .month{display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:1fr 6fr;gap:var(--dp-day-g);align-items:flex-start}sh-datepicker .month .days,sh-datepicker .month .weekdays{display:grid;grid-column:1/-1;gap:var(--dp-day-g);grid-template-columns:subgrid;position:relative}sh-datepicker .month .days>.days,sh-datepicker .month .weekdays>.days{position:absolute;top:0;left:0;width:100%;height:100%;display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:repeat(7,1fr);gap:var(--dp-day-g);z-index:0}sh-datepicker .month .days>div,sh-datepicker .month .days>button,sh-datepicker .month .weekdays>div,sh-datepicker .month .weekdays>button{appearance:none;background:transparent;border:none;padding:0;margin:0;display:flex;align-items:center;justify-content:center;aspect-ratio:var(--dp-ar);cursor:pointer;position:relative;z-index:1;color:var(--dp-day-c);font:var(--dp-day-f);-webkit-user-select:none;user-select:none;border-radius:var(--dp-sel-s)}sh-datepicker .month .days>div:focus-visible,sh-datepicker .month .days>button:focus-visible,sh-datepicker .month .weekdays>div:focus-visible,sh-datepicker .month .weekdays>button:focus-visible{outline:2px solid var(--primary-10, #005fcc);outline-offset:-2px}sh-datepicker .month .days>div.sel,sh-datepicker .month .days>button.sel,sh-datepicker .month .weekdays>div.sel,sh-datepicker .month .weekdays>button.sel{color:var(--dp-sel-c);transition:color 75ms linear}sh-datepicker .month .days>div.out-of-scope,sh-datepicker .month .days>button.out-of-scope,sh-datepicker .month .weekdays>div.out-of-scope,sh-datepicker .month .weekdays>button.out-of-scope{opacity:.4}sh-datepicker .month .days>div.sel-el,sh-datepicker .month .days>button.sel-el,sh-datepicker .month .weekdays>div.sel-el,sh-datepicker .month .weekdays>button.sel-el{position:relative;top:0;left:0;transition:transform 75ms linear,opacity 75ms linear;background:var(--dp-sel-bg);border-radius:var(--dp-sel-s);border:var(--dp-sel-bw) solid var(--dp-sel-bc);opacity:0;box-sizing:border-box}sh-datepicker .month .weekdays>div{color:var(--base-12)}sh-datepicker.primary{--dp-sel-bg: var(--primary-8)}sh-datepicker.accent{--dp-sel-bg: var(--accent-8)}sh-datepicker.warn{--dp-sel-bg: var(--warn-8)}sh-datepicker.error{--dp-sel-bg: var(--error-8)}sh-datepicker.success{--dp-sel-bg: var(--success-8)}sh-datepicker.raised{--dp-sel-bg: var(--base-g2)}sh-datepicker.raised.primary{--dp-sel-bg: var(--primary-g2)}sh-datepicker.raised.accent{--dp-sel-bg: var(--accent-g2)}sh-datepicker.raised.warn{--dp-sel-bg: var(--warn-g2)}sh-datepicker.raised.error{--dp-sel-bg: var(--error-g2)}sh-datepicker.raised.success{--dp-sel-bg: var(--success-g2)}\n"] }]
|
|
499
|
+
}], propDecorators: { date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], endDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "endDate", required: false }] }, { type: i0.Output, args: ["endDateChange"] }], asRange: [{ type: i0.Input, args: [{ isSignal: true, alias: "asRange", required: false }] }], activeRangeSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeRangeSelection", required: false }] }], monthsToShow: [{ type: i0.Input, args: [{ isSignal: true, alias: "monthsToShow", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], tabbedOut: [{ type: i0.Output, args: ["tabbedOut"] }], startOfWeek: [{ type: i0.Input, args: [{ isSignal: true, alias: "startOfWeek", required: false }] }], weekdayLabels: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekdayLabels", required: false }] }], daysRef: [{ type: i0.ViewChild, args: ['daysRef', { isSignal: true }] }], onFocusOut: [{
|
|
500
|
+
type: HostListener,
|
|
501
|
+
args: ['focusout', ['$event']]
|
|
502
|
+
}] } });
|
|
503
|
+
|
|
504
|
+
class ShipDatepickerInput {
|
|
505
|
+
constructor() {
|
|
506
|
+
// #INIT_DATE = this.#getUTCDate(new Date());
|
|
507
|
+
this.#selfRef = inject(ElementRef);
|
|
508
|
+
this.ngControl = contentChild(NgControl, /* @ts-ignore */
|
|
509
|
+
...(ngDevMode ? [{ debugName: "ngControl" }] : /* istanbul ignore next */ []));
|
|
510
|
+
this.#datePipe = inject(DatePipe);
|
|
511
|
+
this.#inputRef = signal(null, /* @ts-ignore */
|
|
512
|
+
...(ngDevMode ? [{ debugName: "#inputRef" }] : /* istanbul ignore next */ []));
|
|
513
|
+
this.masking = input('mediumDate', /* @ts-ignore */
|
|
514
|
+
...(ngDevMode ? [{ debugName: "masking" }] : /* istanbul ignore next */ []));
|
|
515
|
+
this.closed = output();
|
|
516
|
+
this._maskedDate = computed(() => {
|
|
517
|
+
const date = this.internalDate();
|
|
518
|
+
const mask = this.masking();
|
|
519
|
+
if (!mask)
|
|
520
|
+
return date;
|
|
521
|
+
if (!date)
|
|
522
|
+
return null;
|
|
523
|
+
return this.#datePipe.transform(date, mask);
|
|
524
|
+
}, /* @ts-ignore */
|
|
525
|
+
...(ngDevMode ? [{ debugName: "_maskedDate" }] : /* istanbul ignore next */ []));
|
|
526
|
+
this.internalDate = signal(null, /* @ts-ignore */
|
|
527
|
+
...(ngDevMode ? [{ debugName: "internalDate" }] : /* istanbul ignore next */ []));
|
|
528
|
+
this.isOpen = model(false, /* @ts-ignore */
|
|
529
|
+
...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
530
|
+
this.currentClass = classMutationSignal();
|
|
531
|
+
this.#inputObserver = contentProjectionSignal('#input-wrap input');
|
|
532
|
+
this.datepicker = viewChild(ShipDatepicker, /* @ts-ignore */
|
|
533
|
+
...(ngDevMode ? [{ debugName: "datepicker" }] : /* istanbul ignore next */ []));
|
|
534
|
+
this.#isOpenEffect = effect(() => {
|
|
535
|
+
if (this.isOpen()) {
|
|
536
|
+
setTimeout(() => {
|
|
537
|
+
this.datepicker()?.focusActiveDate();
|
|
538
|
+
}, 50);
|
|
539
|
+
}
|
|
540
|
+
}, /* @ts-ignore */
|
|
541
|
+
...(ngDevMode ? [{ debugName: "#isOpenEffect" }] : /* istanbul ignore next */ []));
|
|
542
|
+
this.#inputRefEffect = effect(() => {
|
|
543
|
+
const inputs = this.#inputObserver();
|
|
544
|
+
if (!inputs.length)
|
|
545
|
+
return;
|
|
546
|
+
const input = inputs[0];
|
|
547
|
+
if (!input)
|
|
548
|
+
return;
|
|
549
|
+
this.#createCustomInputEventListener(input);
|
|
550
|
+
input.addEventListener('inputValueChanged', (event) => {
|
|
551
|
+
const val = event.detail.value;
|
|
552
|
+
if (!val) {
|
|
553
|
+
this.internalDate.set(null);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
let newD = new Date(val);
|
|
557
|
+
if (isNaN(newD.getTime())) {
|
|
558
|
+
// If it's a time-only string like "14:30" or "14:30:00"
|
|
559
|
+
if (typeof val === 'string' && /^(\d{2}):(\d{2})/.test(val)) {
|
|
560
|
+
const match = val.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);
|
|
561
|
+
if (match) {
|
|
562
|
+
const current = this.internalDate() || new Date();
|
|
563
|
+
newD = new Date(current);
|
|
564
|
+
newD.setHours(parseInt(match[1], 10), parseInt(match[2], 10), match[3] ? parseInt(match[3], 10) : 0, 0);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (!isNaN(newD.getTime())) {
|
|
569
|
+
this.internalDate.set(newD);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
input.addEventListener('focus', () => {
|
|
573
|
+
this.isOpen.set(true);
|
|
574
|
+
// Removed input.blur() so users can actually type or use Shift+Tab to navigate backward
|
|
575
|
+
});
|
|
576
|
+
this.#inputRef.set(input);
|
|
577
|
+
input.autocomplete = 'off';
|
|
578
|
+
if (typeof input.value === 'string') {
|
|
579
|
+
this.internalDate.set(input.value ? new Date(input.value) : null);
|
|
580
|
+
}
|
|
581
|
+
}, /* @ts-ignore */
|
|
582
|
+
...(ngDevMode ? [{ debugName: "#inputRefEffect" }] : /* istanbul ignore next */ []));
|
|
583
|
+
}
|
|
584
|
+
// #INIT_DATE = this.#getUTCDate(new Date());
|
|
585
|
+
#selfRef;
|
|
586
|
+
#datePipe;
|
|
587
|
+
#inputRef;
|
|
588
|
+
#inputObserver;
|
|
589
|
+
#isOpenEffect;
|
|
590
|
+
onFocusOut(event) {
|
|
591
|
+
setTimeout(() => {
|
|
592
|
+
const activeElement = document.activeElement;
|
|
593
|
+
if (activeElement &&
|
|
594
|
+
activeElement !== document.body &&
|
|
595
|
+
!this.#selfRef.nativeElement.contains(activeElement)) {
|
|
596
|
+
this.isOpen.set(false);
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
onDateChange(date) {
|
|
601
|
+
this.internalDate.set(date);
|
|
602
|
+
const control = this.ngControl()?.control;
|
|
603
|
+
if (control) {
|
|
604
|
+
control.setValue(date);
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
const input = this.#inputRef();
|
|
608
|
+
if (input) {
|
|
609
|
+
input.value = date ? date.toString() : '';
|
|
610
|
+
input.dispatchEvent(new Event('input'));
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
close() {
|
|
615
|
+
this.closed.emit(this.internalDate());
|
|
616
|
+
}
|
|
617
|
+
#inputRefEffect;
|
|
618
|
+
#createCustomInputEventListener(input) {
|
|
619
|
+
Object.defineProperty(input, 'value', {
|
|
620
|
+
configurable: true,
|
|
621
|
+
get() {
|
|
622
|
+
const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
|
|
623
|
+
return descriptor.get.call(this);
|
|
624
|
+
},
|
|
625
|
+
set(newVal) {
|
|
626
|
+
const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
|
|
627
|
+
descriptor.set.call(this, newVal);
|
|
628
|
+
const inputEvent = new CustomEvent('inputValueChanged', {
|
|
629
|
+
bubbles: true,
|
|
630
|
+
cancelable: true,
|
|
631
|
+
detail: {
|
|
632
|
+
value: newVal,
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
this.dispatchEvent(inputEvent);
|
|
636
|
+
return newVal;
|
|
637
|
+
},
|
|
638
|
+
});
|
|
639
|
+
return input;
|
|
640
|
+
}
|
|
641
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipDatepickerInput, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
642
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ShipDatepickerInput, isStandalone: true, selector: "sh-datepicker-input", inputs: { masking: { classPropertyName: "masking", publicName: "masking", isSignal: true, isRequired: false, transformFunction: null }, isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed", isOpen: "isOpenChange" }, host: { listeners: { "focusout": "onFocusOut($event)" } }, providers: [DatePipe], queries: [{ propertyName: "ngControl", first: true, predicate: NgControl, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "datepicker", first: true, predicate: ShipDatepicker, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
643
|
+
<sh-form-field-popover (closed)="close()" [(isOpen)]="isOpen">
|
|
644
|
+
<ng-content select="label" ngProjectAs="label" />
|
|
645
|
+
|
|
646
|
+
<ng-content select="[prefix]" ngProjectAs="[prefix]" />
|
|
647
|
+
<ng-content select="[textPrefix]" ngProjectAs="[textPrefix]" />
|
|
648
|
+
|
|
649
|
+
<div id="input-wrap" class="input" ngProjectAs="input">
|
|
650
|
+
@if (this.masking()) {
|
|
651
|
+
<div class="masked-value">
|
|
652
|
+
{{ _maskedDate() }}
|
|
653
|
+
</div>
|
|
654
|
+
}
|
|
655
|
+
<ng-content select="input" />
|
|
656
|
+
</div>
|
|
657
|
+
|
|
658
|
+
<ng-content select="[textSuffix]" ngProjectAs="[textSuffix]" />
|
|
659
|
+
<ng-content select="[suffix]" ngProjectAs="[suffix]" />
|
|
660
|
+
<sh-icon class="default-indicator" suffix>calendar</sh-icon>
|
|
661
|
+
|
|
662
|
+
<div popoverContent>
|
|
663
|
+
@if (this.isOpen()) {
|
|
664
|
+
<sh-datepicker [date]="internalDate()" (dateChange)="onDateChange($event)" (tabbedOut)="isOpen.set(false)" [class]="currentClass()" />
|
|
665
|
+
}
|
|
666
|
+
</div>
|
|
667
|
+
</sh-form-field-popover>
|
|
668
|
+
|
|
669
|
+
<ng-template #defaultIndicator></ng-template>
|
|
670
|
+
`, isInline: true, styles: ["sh-daterange-input sh-form-field-popover .input-wrap .input,sh-datepicker-input sh-form-field-popover .input-wrap .input{display:grid;grid-template-columns:1fr auto auto;align-items:center}sh-daterange-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap [suffix],sh-datepicker-input sh-form-field-popover .input-wrap [suffix]{margin-right:.75rem}sh-daterange-input sh-form-field-popover .masked-value,sh-datepicker-input sh-form-field-popover .masked-value{font:var(--paragraph-30B);color:var(--base-8);display:flex;gap:.25rem}sh-daterange-input sh-form-field-popover .masked-value.active-start .start-val,sh-datepicker-input sh-form-field-popover .masked-value.active-start .start-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value.active-end .end-val,sh-datepicker-input sh-form-field-popover .masked-value.active-end .end-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value+input+input,sh-daterange-input sh-form-field-popover .masked-value+input,sh-datepicker-input sh-form-field-popover .masked-value+input+input,sh-datepicker-input sh-form-field-popover .masked-value+input{opacity:0;height:0;width:0;margin:0}sh-daterange-input sh-form-field-popover [suffix]+[suffix].default-indicator,sh-datepicker-input sh-form-field-popover [suffix]+[suffix].default-indicator{display:none}sh-daterange-input sh-datepicker,sh-datepicker-input sh-datepicker{z-index:10000;position:relative;--dp-width: 15rem}sh-daterange-input sh-popover .popover-content{--dp-width: 18.75rem;min-width:var(--dp-width)}sh-daterange-input sh-form-field-popover.columns-1 sh-popover .popover-content{--dp-width: 18.75rem }sh-daterange-input sh-form-field-popover.columns-2 sh-popover .popover-content{--dp-width: 38.5rem }sh-daterange-input sh-form-field-popover.columns-3 sh-popover .popover-content{--dp-width: 58.25rem }sh-datepicker-input.sharp sh-datepicker,sh-daterange-input.sharp sh-datepicker,sh-datepicker.sharp{--dp-sel-s: var(--shape-1);--dp-ar: 1/.8;--dp-day-g: .5rem 0}sh-datepicker{--dp-sel-bg: var(--base-8);--dp-sel-bw: 0;--dp-sel-bc: transparent;--dp-sel-s: 50%;--dp-sel-c: #fff;--dp-day-c: var(--base-8);--dp-day-g: .25rem 0;--dp-day-f: var(--paragraph-20);--dp-width: 18.75rem;--dp-ar: 1/1;width:100%;padding:.5rem;max-width:var(--dp-width);display:flex;flex-direction:column}sh-datepicker.disabled{opacity:.5;pointer-events:none;-webkit-user-select:none;user-select:none;cursor:initial}sh-datepicker.columns-1{--dp-width: 18.75rem }sh-datepicker.columns-2{--dp-width: 38.5rem }sh-datepicker.columns-3{--dp-width: 58.25rem }sh-datepicker.columns-4{--dp-width: 78rem }sh-datepicker.columns-5{--dp-width: 97.75rem }sh-datepicker.columns-6{--dp-width: 117.5rem }sh-datepicker.columns-7{--dp-width: 137.25rem }sh-datepicker.columns-8{--dp-width: 157rem }sh-datepicker.columns-9{--dp-width: 176.75rem }sh-datepicker.columns-10{--dp-width: 196.5rem }sh-datepicker.columns-11{--dp-width: 216.25rem }sh-datepicker.columns-12{--dp-width: 236rem }sh-datepicker.as-range section .days>div.sel,sh-datepicker.as-range section .days>button.sel{background:var(--dp-sel-bg);opacity:.5;border-radius:0}sh-datepicker.as-range section .days>div.month-start,sh-datepicker.as-range section .days>div.week-start,sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>button.month-start,sh-datepicker.as-range section .days>button.week-start,sh-datepicker.as-range section .days>button.first{border-top-left-radius:var(--dp-sel-s);border-bottom-left-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.month-end,sh-datepicker.as-range section .days>div.week-end,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.month-end,sh-datepicker.as-range section .days>button.week-end,sh-datepicker.as-range section .days>button.last{border-top-right-radius:var(--dp-sel-s);border-bottom-right-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.first,sh-datepicker.as-range section .days>button.last{opacity:1}sh-datepicker.as-range .month .days>div.out-of-scope,sh-datepicker.as-range .month .days>button.out-of-scope{opacity:0;pointer-events:none}sh-datepicker header{display:flex;align-items:center;justify-content:space-between;padding:.25rem 0;gap:0}sh-datepicker header .title{font:var(--paragraph-20)}sh-datepicker header button{appearance:none;background-color:transparent;border:0;cursor:pointer;height:2rem;color:var(--base-8)}sh-datepicker header button:focus{outline:none}sh-datepicker .months-container{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1rem}sh-datepicker .month{display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:1fr 6fr;gap:var(--dp-day-g);align-items:flex-start}sh-datepicker .month .days,sh-datepicker .month .weekdays{display:grid;grid-column:1/-1;gap:var(--dp-day-g);grid-template-columns:subgrid;position:relative}sh-datepicker .month .days>.days,sh-datepicker .month .weekdays>.days{position:absolute;top:0;left:0;width:100%;height:100%;display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:repeat(7,1fr);gap:var(--dp-day-g);z-index:0}sh-datepicker .month .days>div,sh-datepicker .month .days>button,sh-datepicker .month .weekdays>div,sh-datepicker .month .weekdays>button{appearance:none;background:transparent;border:none;padding:0;margin:0;display:flex;align-items:center;justify-content:center;aspect-ratio:var(--dp-ar);cursor:pointer;position:relative;z-index:1;color:var(--dp-day-c);font:var(--dp-day-f);-webkit-user-select:none;user-select:none;border-radius:var(--dp-sel-s)}sh-datepicker .month .days>div:focus-visible,sh-datepicker .month .days>button:focus-visible,sh-datepicker .month .weekdays>div:focus-visible,sh-datepicker .month .weekdays>button:focus-visible{outline:2px solid var(--primary-10, #005fcc);outline-offset:-2px}sh-datepicker .month .days>div.sel,sh-datepicker .month .days>button.sel,sh-datepicker .month .weekdays>div.sel,sh-datepicker .month .weekdays>button.sel{color:var(--dp-sel-c);transition:color 75ms linear}sh-datepicker .month .days>div.out-of-scope,sh-datepicker .month .days>button.out-of-scope,sh-datepicker .month .weekdays>div.out-of-scope,sh-datepicker .month .weekdays>button.out-of-scope{opacity:.4}sh-datepicker .month .days>div.sel-el,sh-datepicker .month .days>button.sel-el,sh-datepicker .month .weekdays>div.sel-el,sh-datepicker .month .weekdays>button.sel-el{position:relative;top:0;left:0;transition:transform 75ms linear,opacity 75ms linear;background:var(--dp-sel-bg);border-radius:var(--dp-sel-s);border:var(--dp-sel-bw) solid var(--dp-sel-bc);opacity:0;box-sizing:border-box}sh-datepicker .month .weekdays>div{color:var(--base-12)}sh-datepicker.primary{--dp-sel-bg: var(--primary-8)}sh-datepicker.accent{--dp-sel-bg: var(--accent-8)}sh-datepicker.warn{--dp-sel-bg: var(--warn-8)}sh-datepicker.error{--dp-sel-bg: var(--error-8)}sh-datepicker.success{--dp-sel-bg: var(--success-8)}sh-datepicker.raised{--dp-sel-bg: var(--base-g2)}sh-datepicker.raised.primary{--dp-sel-bg: var(--primary-g2)}sh-datepicker.raised.accent{--dp-sel-bg: var(--accent-g2)}sh-datepicker.raised.warn{--dp-sel-bg: var(--warn-g2)}sh-datepicker.raised.error{--dp-sel-bg: var(--error-g2)}sh-datepicker.raised.success{--dp-sel-bg: var(--success-g2)}\n"], dependencies: [{ kind: "component", type: ShipDatepicker, selector: "sh-datepicker", inputs: ["date", "endDate", "asRange", "activeRangeSelection", "monthsToShow", "disabled", "startOfWeek", "weekdayLabels"], outputs: ["dateChange", "endDateChange", "tabbedOut"] }, { kind: "component", type: ShipFormFieldPopover, selector: "sh-form-field-popover", inputs: ["isOpen", "color", "variant", "size", "readonly"], outputs: ["isOpenChange", "closed"] }, { kind: "component", type: ShipIcon, selector: "sh-icon", inputs: ["color", "size"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
671
|
+
}
|
|
672
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipDatepickerInput, decorators: [{
|
|
673
|
+
type: Component,
|
|
674
|
+
args: [{ selector: 'sh-datepicker-input', encapsulation: ViewEncapsulation.None, imports: [ShipDatepicker, ShipFormFieldPopover, ShipIcon], providers: [DatePipe], template: `
|
|
675
|
+
<sh-form-field-popover (closed)="close()" [(isOpen)]="isOpen">
|
|
676
|
+
<ng-content select="label" ngProjectAs="label" />
|
|
677
|
+
|
|
678
|
+
<ng-content select="[prefix]" ngProjectAs="[prefix]" />
|
|
679
|
+
<ng-content select="[textPrefix]" ngProjectAs="[textPrefix]" />
|
|
680
|
+
|
|
681
|
+
<div id="input-wrap" class="input" ngProjectAs="input">
|
|
682
|
+
@if (this.masking()) {
|
|
683
|
+
<div class="masked-value">
|
|
684
|
+
{{ _maskedDate() }}
|
|
685
|
+
</div>
|
|
686
|
+
}
|
|
687
|
+
<ng-content select="input" />
|
|
688
|
+
</div>
|
|
689
|
+
|
|
690
|
+
<ng-content select="[textSuffix]" ngProjectAs="[textSuffix]" />
|
|
691
|
+
<ng-content select="[suffix]" ngProjectAs="[suffix]" />
|
|
692
|
+
<sh-icon class="default-indicator" suffix>calendar</sh-icon>
|
|
693
|
+
|
|
694
|
+
<div popoverContent>
|
|
695
|
+
@if (this.isOpen()) {
|
|
696
|
+
<sh-datepicker [date]="internalDate()" (dateChange)="onDateChange($event)" (tabbedOut)="isOpen.set(false)" [class]="currentClass()" />
|
|
697
|
+
}
|
|
698
|
+
</div>
|
|
699
|
+
</sh-form-field-popover>
|
|
700
|
+
|
|
701
|
+
<ng-template #defaultIndicator></ng-template>
|
|
702
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["sh-daterange-input sh-form-field-popover .input-wrap .input,sh-datepicker-input sh-form-field-popover .input-wrap .input{display:grid;grid-template-columns:1fr auto auto;align-items:center}sh-daterange-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap [suffix],sh-datepicker-input sh-form-field-popover .input-wrap [suffix]{margin-right:.75rem}sh-daterange-input sh-form-field-popover .masked-value,sh-datepicker-input sh-form-field-popover .masked-value{font:var(--paragraph-30B);color:var(--base-8);display:flex;gap:.25rem}sh-daterange-input sh-form-field-popover .masked-value.active-start .start-val,sh-datepicker-input sh-form-field-popover .masked-value.active-start .start-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value.active-end .end-val,sh-datepicker-input sh-form-field-popover .masked-value.active-end .end-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value+input+input,sh-daterange-input sh-form-field-popover .masked-value+input,sh-datepicker-input sh-form-field-popover .masked-value+input+input,sh-datepicker-input sh-form-field-popover .masked-value+input{opacity:0;height:0;width:0;margin:0}sh-daterange-input sh-form-field-popover [suffix]+[suffix].default-indicator,sh-datepicker-input sh-form-field-popover [suffix]+[suffix].default-indicator{display:none}sh-daterange-input sh-datepicker,sh-datepicker-input sh-datepicker{z-index:10000;position:relative;--dp-width: 15rem}sh-daterange-input sh-popover .popover-content{--dp-width: 18.75rem;min-width:var(--dp-width)}sh-daterange-input sh-form-field-popover.columns-1 sh-popover .popover-content{--dp-width: 18.75rem }sh-daterange-input sh-form-field-popover.columns-2 sh-popover .popover-content{--dp-width: 38.5rem }sh-daterange-input sh-form-field-popover.columns-3 sh-popover .popover-content{--dp-width: 58.25rem }sh-datepicker-input.sharp sh-datepicker,sh-daterange-input.sharp sh-datepicker,sh-datepicker.sharp{--dp-sel-s: var(--shape-1);--dp-ar: 1/.8;--dp-day-g: .5rem 0}sh-datepicker{--dp-sel-bg: var(--base-8);--dp-sel-bw: 0;--dp-sel-bc: transparent;--dp-sel-s: 50%;--dp-sel-c: #fff;--dp-day-c: var(--base-8);--dp-day-g: .25rem 0;--dp-day-f: var(--paragraph-20);--dp-width: 18.75rem;--dp-ar: 1/1;width:100%;padding:.5rem;max-width:var(--dp-width);display:flex;flex-direction:column}sh-datepicker.disabled{opacity:.5;pointer-events:none;-webkit-user-select:none;user-select:none;cursor:initial}sh-datepicker.columns-1{--dp-width: 18.75rem }sh-datepicker.columns-2{--dp-width: 38.5rem }sh-datepicker.columns-3{--dp-width: 58.25rem }sh-datepicker.columns-4{--dp-width: 78rem }sh-datepicker.columns-5{--dp-width: 97.75rem }sh-datepicker.columns-6{--dp-width: 117.5rem }sh-datepicker.columns-7{--dp-width: 137.25rem }sh-datepicker.columns-8{--dp-width: 157rem }sh-datepicker.columns-9{--dp-width: 176.75rem }sh-datepicker.columns-10{--dp-width: 196.5rem }sh-datepicker.columns-11{--dp-width: 216.25rem }sh-datepicker.columns-12{--dp-width: 236rem }sh-datepicker.as-range section .days>div.sel,sh-datepicker.as-range section .days>button.sel{background:var(--dp-sel-bg);opacity:.5;border-radius:0}sh-datepicker.as-range section .days>div.month-start,sh-datepicker.as-range section .days>div.week-start,sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>button.month-start,sh-datepicker.as-range section .days>button.week-start,sh-datepicker.as-range section .days>button.first{border-top-left-radius:var(--dp-sel-s);border-bottom-left-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.month-end,sh-datepicker.as-range section .days>div.week-end,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.month-end,sh-datepicker.as-range section .days>button.week-end,sh-datepicker.as-range section .days>button.last{border-top-right-radius:var(--dp-sel-s);border-bottom-right-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.first,sh-datepicker.as-range section .days>button.last{opacity:1}sh-datepicker.as-range .month .days>div.out-of-scope,sh-datepicker.as-range .month .days>button.out-of-scope{opacity:0;pointer-events:none}sh-datepicker header{display:flex;align-items:center;justify-content:space-between;padding:.25rem 0;gap:0}sh-datepicker header .title{font:var(--paragraph-20)}sh-datepicker header button{appearance:none;background-color:transparent;border:0;cursor:pointer;height:2rem;color:var(--base-8)}sh-datepicker header button:focus{outline:none}sh-datepicker .months-container{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1rem}sh-datepicker .month{display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:1fr 6fr;gap:var(--dp-day-g);align-items:flex-start}sh-datepicker .month .days,sh-datepicker .month .weekdays{display:grid;grid-column:1/-1;gap:var(--dp-day-g);grid-template-columns:subgrid;position:relative}sh-datepicker .month .days>.days,sh-datepicker .month .weekdays>.days{position:absolute;top:0;left:0;width:100%;height:100%;display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:repeat(7,1fr);gap:var(--dp-day-g);z-index:0}sh-datepicker .month .days>div,sh-datepicker .month .days>button,sh-datepicker .month .weekdays>div,sh-datepicker .month .weekdays>button{appearance:none;background:transparent;border:none;padding:0;margin:0;display:flex;align-items:center;justify-content:center;aspect-ratio:var(--dp-ar);cursor:pointer;position:relative;z-index:1;color:var(--dp-day-c);font:var(--dp-day-f);-webkit-user-select:none;user-select:none;border-radius:var(--dp-sel-s)}sh-datepicker .month .days>div:focus-visible,sh-datepicker .month .days>button:focus-visible,sh-datepicker .month .weekdays>div:focus-visible,sh-datepicker .month .weekdays>button:focus-visible{outline:2px solid var(--primary-10, #005fcc);outline-offset:-2px}sh-datepicker .month .days>div.sel,sh-datepicker .month .days>button.sel,sh-datepicker .month .weekdays>div.sel,sh-datepicker .month .weekdays>button.sel{color:var(--dp-sel-c);transition:color 75ms linear}sh-datepicker .month .days>div.out-of-scope,sh-datepicker .month .days>button.out-of-scope,sh-datepicker .month .weekdays>div.out-of-scope,sh-datepicker .month .weekdays>button.out-of-scope{opacity:.4}sh-datepicker .month .days>div.sel-el,sh-datepicker .month .days>button.sel-el,sh-datepicker .month .weekdays>div.sel-el,sh-datepicker .month .weekdays>button.sel-el{position:relative;top:0;left:0;transition:transform 75ms linear,opacity 75ms linear;background:var(--dp-sel-bg);border-radius:var(--dp-sel-s);border:var(--dp-sel-bw) solid var(--dp-sel-bc);opacity:0;box-sizing:border-box}sh-datepicker .month .weekdays>div{color:var(--base-12)}sh-datepicker.primary{--dp-sel-bg: var(--primary-8)}sh-datepicker.accent{--dp-sel-bg: var(--accent-8)}sh-datepicker.warn{--dp-sel-bg: var(--warn-8)}sh-datepicker.error{--dp-sel-bg: var(--error-8)}sh-datepicker.success{--dp-sel-bg: var(--success-8)}sh-datepicker.raised{--dp-sel-bg: var(--base-g2)}sh-datepicker.raised.primary{--dp-sel-bg: var(--primary-g2)}sh-datepicker.raised.accent{--dp-sel-bg: var(--accent-g2)}sh-datepicker.raised.warn{--dp-sel-bg: var(--warn-g2)}sh-datepicker.raised.error{--dp-sel-bg: var(--error-g2)}sh-datepicker.raised.success{--dp-sel-bg: var(--success-g2)}\n"] }]
|
|
703
|
+
}], propDecorators: { ngControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => NgControl), { isSignal: true }] }], masking: [{ type: i0.Input, args: [{ isSignal: true, alias: "masking", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }], isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: false }] }, { type: i0.Output, args: ["isOpenChange"] }], datepicker: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ShipDatepicker), { isSignal: true }] }], onFocusOut: [{
|
|
704
|
+
type: HostListener,
|
|
705
|
+
args: ['focusout', ['$event']]
|
|
706
|
+
}] } });
|
|
707
|
+
|
|
708
|
+
class ShipDaterangeInput {
|
|
709
|
+
#selfRef;
|
|
710
|
+
#inputObserver;
|
|
711
|
+
#datePipe;
|
|
712
|
+
#isOpenEffect;
|
|
713
|
+
get classes() {
|
|
714
|
+
return `${this.#selfRef.nativeElement.classList.value}`;
|
|
715
|
+
}
|
|
716
|
+
constructor() {
|
|
717
|
+
this.#selfRef = inject(ElementRef);
|
|
718
|
+
this.#inputObserver = contentProjectionSignal('input', {
|
|
719
|
+
childList: true,
|
|
720
|
+
subtree: true,
|
|
721
|
+
});
|
|
722
|
+
this.#datePipe = inject(DatePipe);
|
|
723
|
+
this.monthsToShow = input(1, /* @ts-ignore */
|
|
724
|
+
...(ngDevMode ? [{ debugName: "monthsToShow" }] : /* istanbul ignore next */ []));
|
|
725
|
+
this.masking = input('mediumDate', /* @ts-ignore */
|
|
726
|
+
...(ngDevMode ? [{ debugName: "masking" }] : /* istanbul ignore next */ []));
|
|
727
|
+
this.closed = output();
|
|
728
|
+
this.startDate = signal(null, /* @ts-ignore */
|
|
729
|
+
...(ngDevMode ? [{ debugName: "startDate" }] : /* istanbul ignore next */ []));
|
|
730
|
+
this.endDate = signal(null, /* @ts-ignore */
|
|
731
|
+
...(ngDevMode ? [{ debugName: "endDate" }] : /* istanbul ignore next */ []));
|
|
732
|
+
this.activeInput = signal('start', /* @ts-ignore */
|
|
733
|
+
...(ngDevMode ? [{ debugName: "activeInput" }] : /* istanbul ignore next */ []));
|
|
734
|
+
this.isOpen = model(false, /* @ts-ignore */
|
|
735
|
+
...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
736
|
+
this.datepicker = viewChild(ShipDatepicker, /* @ts-ignore */
|
|
737
|
+
...(ngDevMode ? [{ debugName: "datepicker" }] : /* istanbul ignore next */ []));
|
|
738
|
+
this.#isOpenEffect = effect(() => {
|
|
739
|
+
if (this.isOpen()) {
|
|
740
|
+
setTimeout(() => {
|
|
741
|
+
this.datepicker()?.focusActiveDate();
|
|
742
|
+
}, 50);
|
|
743
|
+
}
|
|
744
|
+
}, /* @ts-ignore */
|
|
745
|
+
...(ngDevMode ? [{ debugName: "#isOpenEffect" }] : /* istanbul ignore next */ []));
|
|
746
|
+
this._maskedStartDate = computed(() => {
|
|
747
|
+
const date = this.startDate();
|
|
748
|
+
const mask = this.masking();
|
|
749
|
+
if (!mask || !date)
|
|
750
|
+
return null;
|
|
751
|
+
return this.#datePipe.transform(date, mask);
|
|
752
|
+
}, /* @ts-ignore */
|
|
753
|
+
...(ngDevMode ? [{ debugName: "_maskedStartDate" }] : /* istanbul ignore next */ []));
|
|
754
|
+
this._maskedEndDate = computed(() => {
|
|
755
|
+
const date = this.endDate();
|
|
756
|
+
const mask = this.masking();
|
|
757
|
+
if (!mask || !date)
|
|
758
|
+
return null;
|
|
759
|
+
return this.#datePipe.transform(date, mask);
|
|
760
|
+
}, /* @ts-ignore */
|
|
761
|
+
...(ngDevMode ? [{ debugName: "_maskedEndDate" }] : /* istanbul ignore next */ []));
|
|
762
|
+
effect(() => {
|
|
763
|
+
const inputs = this.#inputObserver();
|
|
764
|
+
if (inputs.length === 0)
|
|
765
|
+
return;
|
|
766
|
+
if (inputs[0])
|
|
767
|
+
this.setupInput(inputs[0], true);
|
|
768
|
+
if (inputs[1])
|
|
769
|
+
this.setupInput(inputs[1], false);
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
setupInput(element, isStart) {
|
|
773
|
+
if (element._hasCustomFocusEvent)
|
|
774
|
+
return;
|
|
775
|
+
element._hasCustomFocusEvent = true;
|
|
776
|
+
element.autocomplete = 'off';
|
|
777
|
+
// Set tabindex -1 on the second input to prevent users from having to Shift+Tab
|
|
778
|
+
// multiple times to exit the component when masking is enabled.
|
|
779
|
+
if (!isStart) {
|
|
780
|
+
element.tabIndex = -1;
|
|
781
|
+
}
|
|
782
|
+
element.addEventListener('focus', () => {
|
|
783
|
+
this.activeInput.set(isStart ? 'start' : 'end');
|
|
784
|
+
if (element._ignoreNextFocus) {
|
|
785
|
+
element._ignoreNextFocus = false;
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
this.isOpen.set(true);
|
|
789
|
+
});
|
|
790
|
+
// Handle initial value
|
|
791
|
+
if (element.value) {
|
|
792
|
+
try {
|
|
793
|
+
const date = new Date(element.value);
|
|
794
|
+
if (!isNaN(date.getTime())) {
|
|
795
|
+
if (isStart) {
|
|
796
|
+
this.startDate.set(date);
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
this.endDate.set(date);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
catch (e) {
|
|
804
|
+
console.warn('Invalid date value:', element.value);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
onFocusOut(event) {
|
|
809
|
+
setTimeout(() => {
|
|
810
|
+
const activeElement = document.activeElement;
|
|
811
|
+
if (activeElement &&
|
|
812
|
+
activeElement !== document.body &&
|
|
813
|
+
!this.#selfRef.nativeElement.contains(activeElement)) {
|
|
814
|
+
this.isOpen.set(false);
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
onStartDateChange(date) {
|
|
819
|
+
this.startDate.set(date);
|
|
820
|
+
const inputs = this.#inputObserver();
|
|
821
|
+
if (inputs[0])
|
|
822
|
+
this.updateInputValue([inputs[0]], date);
|
|
823
|
+
// Automatically switch to end date selection
|
|
824
|
+
this.activeInput.set('end');
|
|
825
|
+
}
|
|
826
|
+
onEndDateChange(date) {
|
|
827
|
+
this.endDate.set(date);
|
|
828
|
+
const inputs = this.#inputObserver();
|
|
829
|
+
if (inputs[1])
|
|
830
|
+
this.updateInputValue([inputs[1]], date);
|
|
831
|
+
if (this.startDate() && date) {
|
|
832
|
+
this.isOpen.set(false);
|
|
833
|
+
const inputs = this.#inputObserver();
|
|
834
|
+
if (inputs[0] && document.activeElement !== inputs[0]) {
|
|
835
|
+
inputs[0]._ignoreNextFocus = true;
|
|
836
|
+
inputs[0].focus();
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
updateInputValue(inputs, date) {
|
|
841
|
+
inputs.forEach((input) => {
|
|
842
|
+
if (this.masking()) {
|
|
843
|
+
input.value = this.#datePipe.transform(date, this.masking()) ?? '';
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
input.value = date ? date.toUTCString() : '';
|
|
847
|
+
}
|
|
848
|
+
this.dispatchInputEvent(input);
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
dispatchInputEvent(input) {
|
|
852
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
853
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
854
|
+
}
|
|
855
|
+
close() {
|
|
856
|
+
this.closed.emit({
|
|
857
|
+
start: this.startDate(),
|
|
858
|
+
end: this.endDate(),
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipDaterangeInput, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
862
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: ShipDaterangeInput, isStandalone: true, selector: "sh-daterange-input", inputs: { monthsToShow: { classPropertyName: "monthsToShow", publicName: "monthsToShow", isSignal: true, isRequired: false, transformFunction: null }, masking: { classPropertyName: "masking", publicName: "masking", isSignal: true, isRequired: false, transformFunction: null }, isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed", isOpen: "isOpenChange" }, host: { listeners: { "focusout": "onFocusOut($event)" } }, providers: [DatePipe], viewQueries: [{ propertyName: "datepicker", first: true, predicate: ShipDatepicker, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
863
|
+
<sh-form-field-popover [class]="'columns-' + monthsToShow()" (closed)="close()" [(isOpen)]="isOpen">
|
|
864
|
+
<ng-content select="label" ngProjectAs="label" />
|
|
865
|
+
|
|
866
|
+
<ng-content select="[prefix]" ngProjectAs="[prefix]" />
|
|
867
|
+
<ng-content select="[textPrefix]" ngProjectAs="[textPrefix]" />
|
|
868
|
+
|
|
869
|
+
<div class="input" ngProjectAs="input" #inputWrap [class.active-start]="isOpen() && activeInput() === 'start'" [class.active-end]="isOpen() && activeInput() === 'end'">
|
|
870
|
+
@if (this.masking()) {
|
|
871
|
+
<div class="masked-value" [class.active-start]="isOpen() && activeInput() === 'start'" [class.active-end]="isOpen() && activeInput() === 'end'">
|
|
872
|
+
<span class="start-val">{{ _maskedStartDate() ?? 'N/A' }}</span>
|
|
873
|
+
<span class="separator">-</span>
|
|
874
|
+
<span class="end-val">{{ _maskedEndDate() ?? 'N/A' }}</span>
|
|
875
|
+
</div>
|
|
876
|
+
}
|
|
877
|
+
<ng-content select="input" />
|
|
878
|
+
</div>
|
|
879
|
+
|
|
880
|
+
<ng-content select="[textSuffix]" ngProjectAs="[textSuffix]" />
|
|
881
|
+
<ng-content select="[suffix]" ngProjectAs="[suffix]" />
|
|
882
|
+
<sh-icon class="default-indicator" suffix>calendar</sh-icon>
|
|
883
|
+
|
|
884
|
+
<div popoverContent>
|
|
885
|
+
@if (this.isOpen()) {
|
|
886
|
+
<sh-datepicker
|
|
887
|
+
[date]="startDate()"
|
|
888
|
+
[endDate]="endDate()"
|
|
889
|
+
[activeRangeSelection]="activeInput()"
|
|
890
|
+
[class]="classes"
|
|
891
|
+
(dateChange)="onStartDateChange($event)"
|
|
892
|
+
(endDateChange)="onEndDateChange($event)"
|
|
893
|
+
(tabbedOut)="isOpen.set(false)"
|
|
894
|
+
[monthsToShow]="monthsToShow()"
|
|
895
|
+
[asRange]="true" />
|
|
896
|
+
}
|
|
897
|
+
</div>
|
|
898
|
+
</sh-form-field-popover>
|
|
899
|
+
`, isInline: true, styles: ["sh-daterange-input sh-form-field-popover .input-wrap .input,sh-datepicker-input sh-form-field-popover .input-wrap .input{display:grid;grid-template-columns:1fr auto auto;align-items:center}sh-daterange-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap [suffix],sh-datepicker-input sh-form-field-popover .input-wrap [suffix]{margin-right:.75rem}sh-daterange-input sh-form-field-popover .masked-value,sh-datepicker-input sh-form-field-popover .masked-value{font:var(--paragraph-30B);color:var(--base-8);display:flex;gap:.25rem}sh-daterange-input sh-form-field-popover .masked-value.active-start .start-val,sh-datepicker-input sh-form-field-popover .masked-value.active-start .start-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value.active-end .end-val,sh-datepicker-input sh-form-field-popover .masked-value.active-end .end-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value+input+input,sh-daterange-input sh-form-field-popover .masked-value+input,sh-datepicker-input sh-form-field-popover .masked-value+input+input,sh-datepicker-input sh-form-field-popover .masked-value+input{opacity:0;height:0;width:0;margin:0}sh-daterange-input sh-form-field-popover [suffix]+[suffix].default-indicator,sh-datepicker-input sh-form-field-popover [suffix]+[suffix].default-indicator{display:none}sh-daterange-input sh-datepicker,sh-datepicker-input sh-datepicker{z-index:10000;position:relative;--dp-width: 15rem}sh-daterange-input sh-popover .popover-content{--dp-width: 18.75rem;min-width:var(--dp-width)}sh-daterange-input sh-form-field-popover.columns-1 sh-popover .popover-content{--dp-width: 18.75rem }sh-daterange-input sh-form-field-popover.columns-2 sh-popover .popover-content{--dp-width: 38.5rem }sh-daterange-input sh-form-field-popover.columns-3 sh-popover .popover-content{--dp-width: 58.25rem }sh-datepicker-input.sharp sh-datepicker,sh-daterange-input.sharp sh-datepicker,sh-datepicker.sharp{--dp-sel-s: var(--shape-1);--dp-ar: 1/.8;--dp-day-g: .5rem 0}sh-datepicker{--dp-sel-bg: var(--base-8);--dp-sel-bw: 0;--dp-sel-bc: transparent;--dp-sel-s: 50%;--dp-sel-c: #fff;--dp-day-c: var(--base-8);--dp-day-g: .25rem 0;--dp-day-f: var(--paragraph-20);--dp-width: 18.75rem;--dp-ar: 1/1;width:100%;padding:.5rem;max-width:var(--dp-width);display:flex;flex-direction:column}sh-datepicker.disabled{opacity:.5;pointer-events:none;-webkit-user-select:none;user-select:none;cursor:initial}sh-datepicker.columns-1{--dp-width: 18.75rem }sh-datepicker.columns-2{--dp-width: 38.5rem }sh-datepicker.columns-3{--dp-width: 58.25rem }sh-datepicker.columns-4{--dp-width: 78rem }sh-datepicker.columns-5{--dp-width: 97.75rem }sh-datepicker.columns-6{--dp-width: 117.5rem }sh-datepicker.columns-7{--dp-width: 137.25rem }sh-datepicker.columns-8{--dp-width: 157rem }sh-datepicker.columns-9{--dp-width: 176.75rem }sh-datepicker.columns-10{--dp-width: 196.5rem }sh-datepicker.columns-11{--dp-width: 216.25rem }sh-datepicker.columns-12{--dp-width: 236rem }sh-datepicker.as-range section .days>div.sel,sh-datepicker.as-range section .days>button.sel{background:var(--dp-sel-bg);opacity:.5;border-radius:0}sh-datepicker.as-range section .days>div.month-start,sh-datepicker.as-range section .days>div.week-start,sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>button.month-start,sh-datepicker.as-range section .days>button.week-start,sh-datepicker.as-range section .days>button.first{border-top-left-radius:var(--dp-sel-s);border-bottom-left-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.month-end,sh-datepicker.as-range section .days>div.week-end,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.month-end,sh-datepicker.as-range section .days>button.week-end,sh-datepicker.as-range section .days>button.last{border-top-right-radius:var(--dp-sel-s);border-bottom-right-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.first,sh-datepicker.as-range section .days>button.last{opacity:1}sh-datepicker.as-range .month .days>div.out-of-scope,sh-datepicker.as-range .month .days>button.out-of-scope{opacity:0;pointer-events:none}sh-datepicker header{display:flex;align-items:center;justify-content:space-between;padding:.25rem 0;gap:0}sh-datepicker header .title{font:var(--paragraph-20)}sh-datepicker header button{appearance:none;background-color:transparent;border:0;cursor:pointer;height:2rem;color:var(--base-8)}sh-datepicker header button:focus{outline:none}sh-datepicker .months-container{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1rem}sh-datepicker .month{display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:1fr 6fr;gap:var(--dp-day-g);align-items:flex-start}sh-datepicker .month .days,sh-datepicker .month .weekdays{display:grid;grid-column:1/-1;gap:var(--dp-day-g);grid-template-columns:subgrid;position:relative}sh-datepicker .month .days>.days,sh-datepicker .month .weekdays>.days{position:absolute;top:0;left:0;width:100%;height:100%;display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:repeat(7,1fr);gap:var(--dp-day-g);z-index:0}sh-datepicker .month .days>div,sh-datepicker .month .days>button,sh-datepicker .month .weekdays>div,sh-datepicker .month .weekdays>button{appearance:none;background:transparent;border:none;padding:0;margin:0;display:flex;align-items:center;justify-content:center;aspect-ratio:var(--dp-ar);cursor:pointer;position:relative;z-index:1;color:var(--dp-day-c);font:var(--dp-day-f);-webkit-user-select:none;user-select:none;border-radius:var(--dp-sel-s)}sh-datepicker .month .days>div:focus-visible,sh-datepicker .month .days>button:focus-visible,sh-datepicker .month .weekdays>div:focus-visible,sh-datepicker .month .weekdays>button:focus-visible{outline:2px solid var(--primary-10, #005fcc);outline-offset:-2px}sh-datepicker .month .days>div.sel,sh-datepicker .month .days>button.sel,sh-datepicker .month .weekdays>div.sel,sh-datepicker .month .weekdays>button.sel{color:var(--dp-sel-c);transition:color 75ms linear}sh-datepicker .month .days>div.out-of-scope,sh-datepicker .month .days>button.out-of-scope,sh-datepicker .month .weekdays>div.out-of-scope,sh-datepicker .month .weekdays>button.out-of-scope{opacity:.4}sh-datepicker .month .days>div.sel-el,sh-datepicker .month .days>button.sel-el,sh-datepicker .month .weekdays>div.sel-el,sh-datepicker .month .weekdays>button.sel-el{position:relative;top:0;left:0;transition:transform 75ms linear,opacity 75ms linear;background:var(--dp-sel-bg);border-radius:var(--dp-sel-s);border:var(--dp-sel-bw) solid var(--dp-sel-bc);opacity:0;box-sizing:border-box}sh-datepicker .month .weekdays>div{color:var(--base-12)}sh-datepicker.primary{--dp-sel-bg: var(--primary-8)}sh-datepicker.accent{--dp-sel-bg: var(--accent-8)}sh-datepicker.warn{--dp-sel-bg: var(--warn-8)}sh-datepicker.error{--dp-sel-bg: var(--error-8)}sh-datepicker.success{--dp-sel-bg: var(--success-8)}sh-datepicker.raised{--dp-sel-bg: var(--base-g2)}sh-datepicker.raised.primary{--dp-sel-bg: var(--primary-g2)}sh-datepicker.raised.accent{--dp-sel-bg: var(--accent-g2)}sh-datepicker.raised.warn{--dp-sel-bg: var(--warn-g2)}sh-datepicker.raised.error{--dp-sel-bg: var(--error-g2)}sh-datepicker.raised.success{--dp-sel-bg: var(--success-g2)}\n"], dependencies: [{ kind: "component", type: ShipDatepicker, selector: "sh-datepicker", inputs: ["date", "endDate", "asRange", "activeRangeSelection", "monthsToShow", "disabled", "startOfWeek", "weekdayLabels"], outputs: ["dateChange", "endDateChange", "tabbedOut"] }, { kind: "component", type: ShipFormFieldPopover, selector: "sh-form-field-popover", inputs: ["isOpen", "color", "variant", "size", "readonly"], outputs: ["isOpenChange", "closed"] }, { kind: "component", type: ShipIcon, selector: "sh-icon", inputs: ["color", "size"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
900
|
+
}
|
|
901
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: ShipDaterangeInput, decorators: [{
|
|
902
|
+
type: Component,
|
|
903
|
+
args: [{ selector: 'sh-daterange-input', encapsulation: ViewEncapsulation.None, imports: [ShipDatepicker, ShipFormFieldPopover, ShipIcon], providers: [DatePipe], template: `
|
|
904
|
+
<sh-form-field-popover [class]="'columns-' + monthsToShow()" (closed)="close()" [(isOpen)]="isOpen">
|
|
905
|
+
<ng-content select="label" ngProjectAs="label" />
|
|
906
|
+
|
|
907
|
+
<ng-content select="[prefix]" ngProjectAs="[prefix]" />
|
|
908
|
+
<ng-content select="[textPrefix]" ngProjectAs="[textPrefix]" />
|
|
909
|
+
|
|
910
|
+
<div class="input" ngProjectAs="input" #inputWrap [class.active-start]="isOpen() && activeInput() === 'start'" [class.active-end]="isOpen() && activeInput() === 'end'">
|
|
911
|
+
@if (this.masking()) {
|
|
912
|
+
<div class="masked-value" [class.active-start]="isOpen() && activeInput() === 'start'" [class.active-end]="isOpen() && activeInput() === 'end'">
|
|
913
|
+
<span class="start-val">{{ _maskedStartDate() ?? 'N/A' }}</span>
|
|
914
|
+
<span class="separator">-</span>
|
|
915
|
+
<span class="end-val">{{ _maskedEndDate() ?? 'N/A' }}</span>
|
|
916
|
+
</div>
|
|
917
|
+
}
|
|
918
|
+
<ng-content select="input" />
|
|
919
|
+
</div>
|
|
920
|
+
|
|
921
|
+
<ng-content select="[textSuffix]" ngProjectAs="[textSuffix]" />
|
|
922
|
+
<ng-content select="[suffix]" ngProjectAs="[suffix]" />
|
|
923
|
+
<sh-icon class="default-indicator" suffix>calendar</sh-icon>
|
|
924
|
+
|
|
925
|
+
<div popoverContent>
|
|
926
|
+
@if (this.isOpen()) {
|
|
927
|
+
<sh-datepicker
|
|
928
|
+
[date]="startDate()"
|
|
929
|
+
[endDate]="endDate()"
|
|
930
|
+
[activeRangeSelection]="activeInput()"
|
|
931
|
+
[class]="classes"
|
|
932
|
+
(dateChange)="onStartDateChange($event)"
|
|
933
|
+
(endDateChange)="onEndDateChange($event)"
|
|
934
|
+
(tabbedOut)="isOpen.set(false)"
|
|
935
|
+
[monthsToShow]="monthsToShow()"
|
|
936
|
+
[asRange]="true" />
|
|
937
|
+
}
|
|
938
|
+
</div>
|
|
939
|
+
</sh-form-field-popover>
|
|
940
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["sh-daterange-input sh-form-field-popover .input-wrap .input,sh-datepicker-input sh-form-field-popover .input-wrap .input{display:grid;grid-template-columns:1fr auto auto;align-items:center}sh-daterange-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-start input:first-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type,sh-datepicker-input sh-form-field-popover .input-wrap .input.active-end input:last-of-type{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .input-wrap [suffix],sh-datepicker-input sh-form-field-popover .input-wrap [suffix]{margin-right:.75rem}sh-daterange-input sh-form-field-popover .masked-value,sh-datepicker-input sh-form-field-popover .masked-value{font:var(--paragraph-30B);color:var(--base-8);display:flex;gap:.25rem}sh-daterange-input sh-form-field-popover .masked-value.active-start .start-val,sh-datepicker-input sh-form-field-popover .masked-value.active-start .start-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value.active-end .end-val,sh-datepicker-input sh-form-field-popover .masked-value.active-end .end-val{color:var(--primary-8)}sh-daterange-input sh-form-field-popover .masked-value+input+input,sh-daterange-input sh-form-field-popover .masked-value+input,sh-datepicker-input sh-form-field-popover .masked-value+input+input,sh-datepicker-input sh-form-field-popover .masked-value+input{opacity:0;height:0;width:0;margin:0}sh-daterange-input sh-form-field-popover [suffix]+[suffix].default-indicator,sh-datepicker-input sh-form-field-popover [suffix]+[suffix].default-indicator{display:none}sh-daterange-input sh-datepicker,sh-datepicker-input sh-datepicker{z-index:10000;position:relative;--dp-width: 15rem}sh-daterange-input sh-popover .popover-content{--dp-width: 18.75rem;min-width:var(--dp-width)}sh-daterange-input sh-form-field-popover.columns-1 sh-popover .popover-content{--dp-width: 18.75rem }sh-daterange-input sh-form-field-popover.columns-2 sh-popover .popover-content{--dp-width: 38.5rem }sh-daterange-input sh-form-field-popover.columns-3 sh-popover .popover-content{--dp-width: 58.25rem }sh-datepicker-input.sharp sh-datepicker,sh-daterange-input.sharp sh-datepicker,sh-datepicker.sharp{--dp-sel-s: var(--shape-1);--dp-ar: 1/.8;--dp-day-g: .5rem 0}sh-datepicker{--dp-sel-bg: var(--base-8);--dp-sel-bw: 0;--dp-sel-bc: transparent;--dp-sel-s: 50%;--dp-sel-c: #fff;--dp-day-c: var(--base-8);--dp-day-g: .25rem 0;--dp-day-f: var(--paragraph-20);--dp-width: 18.75rem;--dp-ar: 1/1;width:100%;padding:.5rem;max-width:var(--dp-width);display:flex;flex-direction:column}sh-datepicker.disabled{opacity:.5;pointer-events:none;-webkit-user-select:none;user-select:none;cursor:initial}sh-datepicker.columns-1{--dp-width: 18.75rem }sh-datepicker.columns-2{--dp-width: 38.5rem }sh-datepicker.columns-3{--dp-width: 58.25rem }sh-datepicker.columns-4{--dp-width: 78rem }sh-datepicker.columns-5{--dp-width: 97.75rem }sh-datepicker.columns-6{--dp-width: 117.5rem }sh-datepicker.columns-7{--dp-width: 137.25rem }sh-datepicker.columns-8{--dp-width: 157rem }sh-datepicker.columns-9{--dp-width: 176.75rem }sh-datepicker.columns-10{--dp-width: 196.5rem }sh-datepicker.columns-11{--dp-width: 216.25rem }sh-datepicker.columns-12{--dp-width: 236rem }sh-datepicker.as-range section .days>div.sel,sh-datepicker.as-range section .days>button.sel{background:var(--dp-sel-bg);opacity:.5;border-radius:0}sh-datepicker.as-range section .days>div.month-start,sh-datepicker.as-range section .days>div.week-start,sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>button.month-start,sh-datepicker.as-range section .days>button.week-start,sh-datepicker.as-range section .days>button.first{border-top-left-radius:var(--dp-sel-s);border-bottom-left-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.month-end,sh-datepicker.as-range section .days>div.week-end,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.month-end,sh-datepicker.as-range section .days>button.week-end,sh-datepicker.as-range section .days>button.last{border-top-right-radius:var(--dp-sel-s);border-bottom-right-radius:var(--dp-sel-s)}sh-datepicker.as-range section .days>div.first,sh-datepicker.as-range section .days>div.last,sh-datepicker.as-range section .days>button.first,sh-datepicker.as-range section .days>button.last{opacity:1}sh-datepicker.as-range .month .days>div.out-of-scope,sh-datepicker.as-range .month .days>button.out-of-scope{opacity:0;pointer-events:none}sh-datepicker header{display:flex;align-items:center;justify-content:space-between;padding:.25rem 0;gap:0}sh-datepicker header .title{font:var(--paragraph-20)}sh-datepicker header button{appearance:none;background-color:transparent;border:0;cursor:pointer;height:2rem;color:var(--base-8)}sh-datepicker header button:focus{outline:none}sh-datepicker .months-container{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:1rem}sh-datepicker .month{display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:1fr 6fr;gap:var(--dp-day-g);align-items:flex-start}sh-datepicker .month .days,sh-datepicker .month .weekdays{display:grid;grid-column:1/-1;gap:var(--dp-day-g);grid-template-columns:subgrid;position:relative}sh-datepicker .month .days>.days,sh-datepicker .month .weekdays>.days{position:absolute;top:0;left:0;width:100%;height:100%;display:grid;grid-template-columns:repeat(7,1fr);grid-template-rows:repeat(7,1fr);gap:var(--dp-day-g);z-index:0}sh-datepicker .month .days>div,sh-datepicker .month .days>button,sh-datepicker .month .weekdays>div,sh-datepicker .month .weekdays>button{appearance:none;background:transparent;border:none;padding:0;margin:0;display:flex;align-items:center;justify-content:center;aspect-ratio:var(--dp-ar);cursor:pointer;position:relative;z-index:1;color:var(--dp-day-c);font:var(--dp-day-f);-webkit-user-select:none;user-select:none;border-radius:var(--dp-sel-s)}sh-datepicker .month .days>div:focus-visible,sh-datepicker .month .days>button:focus-visible,sh-datepicker .month .weekdays>div:focus-visible,sh-datepicker .month .weekdays>button:focus-visible{outline:2px solid var(--primary-10, #005fcc);outline-offset:-2px}sh-datepicker .month .days>div.sel,sh-datepicker .month .days>button.sel,sh-datepicker .month .weekdays>div.sel,sh-datepicker .month .weekdays>button.sel{color:var(--dp-sel-c);transition:color 75ms linear}sh-datepicker .month .days>div.out-of-scope,sh-datepicker .month .days>button.out-of-scope,sh-datepicker .month .weekdays>div.out-of-scope,sh-datepicker .month .weekdays>button.out-of-scope{opacity:.4}sh-datepicker .month .days>div.sel-el,sh-datepicker .month .days>button.sel-el,sh-datepicker .month .weekdays>div.sel-el,sh-datepicker .month .weekdays>button.sel-el{position:relative;top:0;left:0;transition:transform 75ms linear,opacity 75ms linear;background:var(--dp-sel-bg);border-radius:var(--dp-sel-s);border:var(--dp-sel-bw) solid var(--dp-sel-bc);opacity:0;box-sizing:border-box}sh-datepicker .month .weekdays>div{color:var(--base-12)}sh-datepicker.primary{--dp-sel-bg: var(--primary-8)}sh-datepicker.accent{--dp-sel-bg: var(--accent-8)}sh-datepicker.warn{--dp-sel-bg: var(--warn-8)}sh-datepicker.error{--dp-sel-bg: var(--error-8)}sh-datepicker.success{--dp-sel-bg: var(--success-8)}sh-datepicker.raised{--dp-sel-bg: var(--base-g2)}sh-datepicker.raised.primary{--dp-sel-bg: var(--primary-g2)}sh-datepicker.raised.accent{--dp-sel-bg: var(--accent-g2)}sh-datepicker.raised.warn{--dp-sel-bg: var(--warn-g2)}sh-datepicker.raised.error{--dp-sel-bg: var(--error-g2)}sh-datepicker.raised.success{--dp-sel-bg: var(--success-g2)}\n"] }]
|
|
941
|
+
}], ctorParameters: () => [], propDecorators: { monthsToShow: [{ type: i0.Input, args: [{ isSignal: true, alias: "monthsToShow", required: false }] }], masking: [{ type: i0.Input, args: [{ isSignal: true, alias: "masking", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }], isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: false }] }, { type: i0.Output, args: ["isOpenChange"] }], datepicker: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ShipDatepicker), { isSignal: true }] }], onFocusOut: [{
|
|
942
|
+
type: HostListener,
|
|
943
|
+
args: ['focusout', ['$event']]
|
|
944
|
+
}] } });
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Generated bundle index. Do not edit.
|
|
948
|
+
*/
|
|
949
|
+
|
|
950
|
+
export { ShipDatepicker, ShipDatepickerInput, ShipDaterangeInput };
|
|
951
|
+
//# sourceMappingURL=ship-ui-core-ship-datepicker.mjs.map
|