@govtechsg/sgds-web-component 1.1.0-rc.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/dropdown-element.cjs.js +0 -1
- package/base/dropdown-element.cjs.js.map +1 -1
- package/base/dropdown-element.d.ts +1 -2
- package/base/dropdown-element.js +0 -1
- package/base/dropdown-element.js.map +1 -1
- package/components/ActionCard/index.umd.js +3 -1
- package/components/ActionCard/index.umd.js.map +1 -1
- package/components/Button/index.umd.js +3 -1
- package/components/Button/index.umd.js.map +1 -1
- package/components/Checkbox/index.umd.js +3 -1
- package/components/Checkbox/index.umd.js.map +1 -1
- package/components/ComboBox/index.umd.js +43 -26
- package/components/ComboBox/index.umd.js.map +1 -1
- package/components/Datepicker/datepicker-calendar.cjs.js +29 -14
- package/components/Datepicker/datepicker-calendar.cjs.js.map +1 -1
- package/components/Datepicker/datepicker-calendar.js +29 -14
- package/components/Datepicker/datepicker-calendar.js.map +1 -1
- package/components/Datepicker/datepicker-header.cjs.js +35 -17
- package/components/Datepicker/datepicker-header.cjs.js.map +1 -1
- package/components/Datepicker/datepicker-header.d.ts +2 -0
- package/components/Datepicker/datepicker-header.js +35 -18
- package/components/Datepicker/datepicker-header.js.map +1 -1
- package/components/Datepicker/datepicker-input.cjs.js +150 -0
- package/components/Datepicker/datepicker-input.cjs.js.map +1 -0
- package/components/Datepicker/datepicker-input.d.ts +24 -0
- package/components/Datepicker/datepicker-input.js +141 -0
- package/components/Datepicker/datepicker-input.js.map +1 -0
- package/components/Datepicker/index.js.map +1 -1
- package/components/Datepicker/index.umd.js +16655 -7545
- package/components/Datepicker/index.umd.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.cjs.js +207 -150
- package/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
- package/components/Datepicker/sgds-datepicker.cjs2.js +1 -1
- package/components/Datepicker/sgds-datepicker.d.ts +38 -13
- package/components/Datepicker/sgds-datepicker.js +209 -152
- package/components/Datepicker/sgds-datepicker.js.map +1 -1
- package/components/Datepicker/sgds-datepicker2.js +1 -1
- package/components/Dropdown/index.umd.js +8 -3
- package/components/Dropdown/index.umd.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.cjs.js +5 -1
- package/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
- package/components/Dropdown/sgds-dropdown.d.ts +4 -3
- package/components/Dropdown/sgds-dropdown.js +5 -1
- package/components/Dropdown/sgds-dropdown.js.map +1 -1
- package/components/FileUpload/index.umd.js +3 -1
- package/components/FileUpload/index.umd.js.map +1 -1
- package/components/Input/index.umd.js +43 -25
- package/components/Input/index.umd.js.map +1 -1
- package/components/Input/sgds-input.cjs.js +40 -24
- package/components/Input/sgds-input.cjs.js.map +1 -1
- package/components/Input/sgds-input.d.ts +15 -9
- package/components/Input/sgds-input.js +40 -24
- package/components/Input/sgds-input.js.map +1 -1
- package/components/Mainnav/index.umd.js +0 -1
- package/components/Mainnav/index.umd.js.map +1 -1
- package/components/QuantityToggle/index.umd.js +3 -1
- package/components/QuantityToggle/index.umd.js.map +1 -1
- package/components/Radio/index.umd.js +3 -1
- package/components/Radio/index.umd.js.map +1 -1
- package/components/Textarea/index.umd.js +3 -1
- package/components/Textarea/index.umd.js.map +1 -1
- package/components/index.umd.js +9905 -791
- package/components/index.umd.js.map +1 -1
- package/index.umd.js +9905 -791
- package/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/react/datepicker/index.cjs.js +1 -2
- package/react/datepicker/index.cjs.js.map +1 -1
- package/react/datepicker/index.js +1 -2
- package/react/datepicker/index.js.map +1 -1
- package/utils/form.cjs.js +3 -1
- package/utils/form.cjs.js.map +1 -1
- package/utils/form.js +3 -1
- package/utils/form.js.map +1 -1
- package/utils/time.cjs.js +18 -4
- package/utils/time.cjs.js.map +1 -1
- package/utils/time.d.ts +17 -0
- package/utils/time.js +18 -4
- package/utils/time.js.map +1 -1
|
@@ -5,11 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var lit = require('lit');
|
|
7
7
|
var decorators_js = require('lit/decorators.js');
|
|
8
|
-
var classMap_js = require('lit/directives/class-map.js');
|
|
9
8
|
var sgdsElement = require('../../base/sgds-element.cjs.js');
|
|
10
9
|
var time = require('../../utils/time.cjs.js');
|
|
11
10
|
var watch = require('../../utils/watch.cjs.js');
|
|
12
11
|
var datepickerCalendar = require('./datepicker-calendar.cjs2.js');
|
|
12
|
+
var classMap_js = require('lit/directives/class-map.js');
|
|
13
|
+
var dateFns = require('date-fns');
|
|
13
14
|
|
|
14
15
|
const TODAY_DATE = new Date();
|
|
15
16
|
const keyPressAction = {
|
|
@@ -40,10 +41,7 @@ class DatepickerCalendar extends sgdsElement["default"] {
|
|
|
40
41
|
/** @internal */
|
|
41
42
|
this.selectedDate = [];
|
|
42
43
|
/** @internal */
|
|
43
|
-
this.displayDate = TODAY_DATE;
|
|
44
|
-
/** @internal */
|
|
45
44
|
this.mode = "single";
|
|
46
|
-
this.focusedDate = time.setTimeToNoon(this.displayDate);
|
|
47
45
|
}
|
|
48
46
|
/**Shifts focus from Input to Calendar */
|
|
49
47
|
focusOnCalendar(toBlurEl) {
|
|
@@ -55,9 +53,11 @@ class DatepickerCalendar extends sgdsElement["default"] {
|
|
|
55
53
|
this.addEventListener("keydown", this._handleKeyPress);
|
|
56
54
|
}
|
|
57
55
|
firstUpdated() {
|
|
58
|
-
if (this.selectedDate.length > 0) {
|
|
59
|
-
|
|
60
|
-
}
|
|
56
|
+
// if (this.selectedDate.length > 0) {
|
|
57
|
+
// this.focusedDate = setTimeToNoon(this.selectedDate[0]);
|
|
58
|
+
// } else {
|
|
59
|
+
// this.focusedDate = this.displayDate && setTimeToNoon(this.displayDate);
|
|
60
|
+
// }
|
|
61
61
|
}
|
|
62
62
|
updated() {
|
|
63
63
|
/** For KeyboardNavigation (switching months) and ClickNavigation:
|
|
@@ -70,19 +70,33 @@ class DatepickerCalendar extends sgdsElement["default"] {
|
|
|
70
70
|
}
|
|
71
71
|
_updateFocusedDate() {
|
|
72
72
|
this.focusedDate = time.setTimeToNoon(this.displayDate);
|
|
73
|
+
if (this.focusedDate.getFullYear() < 1900) {
|
|
74
|
+
this.focusedDate.setFullYear(1900);
|
|
75
|
+
}
|
|
73
76
|
}
|
|
74
77
|
_setFocusedDate(shift) {
|
|
78
|
+
const currentFocusedDate = this.focusedDate.getDate();
|
|
79
|
+
const currentFocusedMonth = this.focusedDate.getMonth();
|
|
80
|
+
const currentFocusedYear = this.focusedDate.getFullYear();
|
|
75
81
|
switch (this.view) {
|
|
76
82
|
case "days": {
|
|
77
|
-
|
|
83
|
+
const newFocusedDate = time.setTimeToNoon(new Date(currentFocusedYear, currentFocusedMonth, currentFocusedDate + shift));
|
|
84
|
+
if (dateFns.isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || dateFns.isEqual(newFocusedDate, new Date(0, 0, 1, 12)))
|
|
85
|
+
this.focusedDate = newFocusedDate;
|
|
78
86
|
break;
|
|
79
87
|
}
|
|
80
88
|
case "months": {
|
|
81
|
-
|
|
89
|
+
const newFocusedDate = time.setTimeToNoon(new Date(currentFocusedYear, currentFocusedMonth + shift, currentFocusedDate));
|
|
90
|
+
if (dateFns.isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || dateFns.isEqual(newFocusedDate, new Date(0, 0, 1, 12))) {
|
|
91
|
+
this.focusedDate = newFocusedDate;
|
|
92
|
+
}
|
|
82
93
|
break;
|
|
83
94
|
}
|
|
84
95
|
case "years": {
|
|
85
|
-
|
|
96
|
+
const newFocusedDate = time.setTimeToNoon(new Date(currentFocusedYear + shift, currentFocusedMonth, currentFocusedDate));
|
|
97
|
+
if (newFocusedDate.getFullYear() >= 1900) {
|
|
98
|
+
this.focusedDate = newFocusedDate;
|
|
99
|
+
}
|
|
86
100
|
break;
|
|
87
101
|
}
|
|
88
102
|
}
|
|
@@ -272,7 +286,7 @@ class DatepickerCalendar extends sgdsElement["default"] {
|
|
|
272
286
|
})}
|
|
273
287
|
@click=${clickHandler}
|
|
274
288
|
tabindex=${this.focusedDate === new Date(date) ? "3" : "-1"}
|
|
275
|
-
disabled=${beforeMinDate || afterMinDate}
|
|
289
|
+
?disabled=${beforeMinDate || afterMinDate}
|
|
276
290
|
>
|
|
277
291
|
${day}
|
|
278
292
|
</td>`);
|
|
@@ -294,9 +308,9 @@ class DatepickerCalendar extends sgdsElement["default"] {
|
|
|
294
308
|
<thead>
|
|
295
309
|
<tr>
|
|
296
310
|
${DatepickerCalendar.DAY_LABELS.map((label, index) => lit.html `
|
|
297
|
-
<
|
|
311
|
+
<th key=${index}>
|
|
298
312
|
<small>${label}</small>
|
|
299
|
-
</
|
|
313
|
+
</th>
|
|
300
314
|
`)}
|
|
301
315
|
</tr>
|
|
302
316
|
</thead>
|
|
@@ -359,6 +373,7 @@ class DatepickerCalendar extends sgdsElement["default"] {
|
|
|
359
373
|
@click=${() => this._onClickYear(y)}
|
|
360
374
|
data-year=${y}
|
|
361
375
|
tabindex="3"
|
|
376
|
+
?disabled=${y < 1900}
|
|
362
377
|
>
|
|
363
378
|
${y}
|
|
364
379
|
</button>
|
|
@@ -419,7 +434,7 @@ tslib.__decorate([
|
|
|
419
434
|
decorators_js.property()
|
|
420
435
|
], DatepickerCalendar.prototype, "focusedTabIndex", void 0);
|
|
421
436
|
tslib.__decorate([
|
|
422
|
-
watch.watch("displayDate"
|
|
437
|
+
watch.watch("displayDate")
|
|
423
438
|
], DatepickerCalendar.prototype, "_updateFocusedDate", null);
|
|
424
439
|
|
|
425
440
|
exports.DatepickerCalendar = DatepickerCalendar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datepicker-calendar.cjs.js","sources":["../../../src/components/Datepicker/datepicker-calendar.ts"],"sourcesContent":["import { HTMLTemplateResult, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { createYearViewArray, setTimeToNoon } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-calendar.scss\";\nimport { ViewEnum } from \"./types\";\n\nconst TODAY_DATE = new Date();\n\nconst keyPressAction = {\n ArrowUp: {\n days: -7,\n months: -3,\n years: -3\n },\n ArrowDown: {\n days: 7,\n months: 3,\n years: 3\n },\n ArrowRight: {\n days: 1,\n months: 1,\n years: 1\n },\n ArrowLeft: {\n days: -1,\n months: -1,\n years: -1\n }\n};\nexport class DatepickerCalendar extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n static DAY_LABELS = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\n /** @internal */\n static daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n /** @internal */\n static MONTHVIEW_LABELS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\n /** @internal */\n @property({ type: Array }) selectedDate: Date[] = [];\n\n /** @internal */\n @property({ attribute: false }) displayDate: Date = TODAY_DATE;\n\n /** @internal */\n @property({ type: String }) minDate?: string;\n\n /** @internal */\n @property({ type: String }) maxDate?: string;\n\n /** @internal */\n @property({ type: String, reflect: true }) mode: \"single\" | \"range\" = \"single\";\n\n private focusedDate: Date = setTimeToNoon(this.displayDate);\n\n /** @internal */\n @property() view: ViewEnum;\n\n /** @internal */\n @property({ type: Boolean }) show: boolean;\n\n @property()\n focusedTabIndex: number;\n\n /**Shifts focus from Input to Calendar */\n public focusOnCalendar(toBlurEl: HTMLElement) {\n toBlurEl.blur();\n this._focusOnCalendarCell();\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", this._handleKeyPress);\n }\n\n firstUpdated() {\n if (this.selectedDate.length > 0) {\n this.focusedDate = setTimeToNoon(this.selectedDate[0]);\n }\n }\n updated() {\n /** For KeyboardNavigation (switching months) and ClickNavigation:\n * Runs after render has completed and td of next month has appeared.\n * For the case when calendar view changes to the next month\n * */\n if (this.focusedTabIndex === 3) {\n this._focusOnCalendarCell();\n }\n }\n\n @watch(\"displayDate\", { waitUntilFirstUpdate: true })\n _updateFocusedDate() {\n this.focusedDate = setTimeToNoon(this.displayDate);\n }\n\n private _setFocusedDate(shift: number) {\n switch (this.view) {\n case \"days\": {\n this.focusedDate = setTimeToNoon(new Date(this.focusedDate.setDate(this.focusedDate.getDate() + shift)));\n break;\n }\n case \"months\": {\n this.focusedDate = setTimeToNoon(new Date(this.focusedDate.setMonth(this.focusedDate.getMonth() + shift)));\n break;\n }\n case \"years\": {\n this.focusedDate = setTimeToNoon(\n new Date(this.focusedDate.setFullYear(this.focusedDate.getFullYear() + shift))\n );\n break;\n }\n }\n }\n private _handleEnterDateKeyboard(event: KeyboardEvent) {\n const targetElement = event.composedPath()[0] as HTMLElement;\n if (targetElement.classList.contains(\"disabled\")) return;\n\n switch (this.view) {\n case \"days\":\n this._onClickDay(event);\n break;\n case \"months\": {\n const { month } = targetElement.dataset;\n this._onClickMonth(parseInt(month));\n break;\n }\n case \"years\": {\n const { year } = targetElement.dataset;\n this._onClickYear(parseInt(year));\n }\n }\n }\n private _handleKeyPress(event: KeyboardEvent) {\n if (event.key === \"Enter\") {\n event.preventDefault();\n this._handleEnterDateKeyboard(event);\n return;\n }\n if (event.key === \"Tab\") {\n const targetEl: HTMLElement = this._getFocusedTarget();\n if (this.focusedTabIndex !== 3) targetEl.blur();\n return;\n }\n if (event.key.includes(\"Arrow\")) {\n event.preventDefault();\n this._blurCalendarCell();\n const keyShiftObject = keyPressAction[event.key];\n const shiftNumber = keyShiftObject[this.view];\n this._setFocusedDate(shiftNumber);\n\n this._focusOnCalendarCell();\n }\n }\n\n private _generateIncrementDates(): Date[] {\n const start = setTimeToNoon(this.selectedDate[0]);\n\n if (this.selectedDate.length < 2) {\n return [start];\n }\n\n const end = setTimeToNoon(this.selectedDate[1]);\n const arr: Date[] = [];\n if (start.getTime() < end.getTime()) {\n for (let dt = start; dt <= end; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n } else {\n for (let dt = end; dt <= start; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n }\n return arr;\n }\n\n private _onClickDay(event: MouseEvent | KeyboardEvent) {\n const { day, date } = (event.composedPath()[0] as HTMLTableCellElement).dataset;\n\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setDate(parseInt(day));\n /** update new focused date for mouse click */\n if (event.type === \"click\") {\n this.focusedDate = setTimeToNoon(new Date(date));\n }\n\n if (this.mode === \"single\") {\n // Single mode: Select a single date\n\n this.selectedDate = [displayDateClone];\n\n // Emit event with selected date\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n } else if (this.mode === \"range\") {\n // Range mode: Select a range of dates\n const selectedDates = [...this.selectedDate];\n\n if (selectedDates.length === 0 || selectedDates.length === 2) {\n // No dates selected yet or both dates already selected,\n // start a new range by clearing the selected dates array\n selectedDates.length = 0;\n }\n\n // Add the selected date to the range\n selectedDates.push(displayDateClone);\n\n // Update the selectedDate property\n this.selectedDate = selectedDates;\n\n // Emit event with the range of selected dates\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n }\n\n // Check if the selected date is before minDate or after maxDate\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n\n const selectedDate = setTimeToNoon(displayDateClone);\n if ((minimumDate && selectedDate < minimumDate) || (maximumDate && selectedDate > maximumDate)) {\n event.stopPropagation();\n event.preventDefault();\n }\n }\n\n private _onClickMonth(month: number, year: number = this.focusedDate.getFullYear()) {\n const displayDateClone = new Date(this.displayDate);\n this.view = \"days\";\n displayDateClone.setMonth(month);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.emit(\"sgds-view\", { detail: this.view });\n //once clicked, should change view to days, and hold value and change view\n this.emit(\"sgds-selectmonth\", { detail: this.displayDate });\n }\n\n private _onClickYear(year: number) {\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.view = \"months\";\n this.emit(\"sgds-view\", { detail: this.view });\n\n this.emit(\"sgds-selectyear\", { detail: this.displayDate });\n }\n\n private _getFocusedTarget(): HTMLElement {\n const queryObj = {\n days: `td[data-date=\"${this.focusedDate.toISOString()}\"]`,\n months: `button[data-month=\"${this.focusedDate.getMonth()}\"][data-year=\"${this.focusedDate.getFullYear()}\"]`,\n years: `button[data-year=\"${this.focusedDate.getFullYear()}\"]`\n };\n const queryString = queryObj[this.view];\n const targetEl: HTMLElement = this.shadowRoot.querySelector(`${queryString}`);\n return targetEl;\n }\n private _blurCalendarCell() {\n const targetEl = this._getFocusedTarget();\n targetEl.setAttribute(\"tabindex\", \"-1\");\n targetEl.blur();\n }\n private _focusOnCalendarCell() {\n const targetEl = this._getFocusedTarget();\n if (targetEl) {\n targetEl.setAttribute(\"tabindex\", \"3\");\n targetEl.focus();\n this.emit(\"sgds-update-focus\", { detail: this.focusedDate });\n } else {\n /** Change month view */\n this.emit(\"sgds-change-calendar\", { detail: this.focusedDate });\n }\n }\n private _generateDays() {\n const selectedDates = this.selectedDate.map(d => setTimeToNoon(d));\n\n const rangeSelectedDates = this._generateIncrementDates();\n\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n const year = this.displayDate.getFullYear();\n const month = this.displayDate.getMonth();\n const firstDateOfMonth = new Date(year, month, 1);\n const startingDayOfMonth = firstDateOfMonth.getDay();\n let monthLength = DatepickerCalendar.daysInMonth[month];\n if (month === 1) {\n if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {\n monthLength = 29;\n }\n }\n\n const weeks = [];\n let day = 1;\n for (let i = 0; i < 9; i++) {\n const week = [];\n for (let j = 0; j <= 6; j++) {\n if (day <= monthLength && (i > 0 || j >= startingDayOfMonth)) {\n const date = new Date(year, month, day, 12, 0, 0, 0).toISOString();\n\n const beforeMinDate = minimumDate && Date.parse(date) < Date.parse(minimumDate.toISOString());\n const afterMinDate = maximumDate && Date.parse(date) > Date.parse(maximumDate.toISOString());\n const clickHandler = beforeMinDate || afterMinDate ? undefined : this._onClickDay;\n\n const isCurrentMonth = TODAY_DATE.getMonth() === this.displayDate.getMonth();\n const isCurrentYear = TODAY_DATE.getFullYear() === this.displayDate.getFullYear();\n const isCurrentDay = TODAY_DATE.getDate() === day;\n\n const isSelected =\n selectedDates.length > 0 && rangeSelectedDates.some(d => Date.parse(date) === Date.parse(d.toISOString()));\n const isFirstSelectedDate = selectedDates.length > 0 && rangeSelectedDates[0].toISOString() === date;\n const isLastSelectedDate =\n selectedDates.length > 1 && rangeSelectedDates[rangeSelectedDates.length - 1].toISOString() === date;\n\n week.push(\n html`<td\n key=${j}\n data-date=${date}\n data-day=${day}\n class=${classMap({\n today: isCurrentDay && isCurrentMonth && isCurrentYear,\n \"selected-ends\": isFirstSelectedDate || isLastSelectedDate,\n active: isSelected,\n disabled: beforeMinDate || afterMinDate\n })}\n @click=${clickHandler}\n tabindex=${this.focusedDate === new Date(date) ? \"3\" : \"-1\"}\n disabled=${beforeMinDate || afterMinDate}\n >\n ${day}\n </td>`\n );\n day++;\n } else {\n week.push(html`<td key=${j}></td>`);\n }\n }\n\n weeks.push(\n html`<tr key=${i}>\n ${week}\n </tr>`\n );\n if (day > monthLength) {\n break;\n }\n }\n\n const dayView = html`\n <table class=\"text-center\">\n <thead>\n <tr>\n ${DatepickerCalendar.DAY_LABELS.map(\n (label: string, index: number) =>\n html`\n <td key=${index}>\n <small>${label}</small>\n </td>\n `\n )}\n </tr>\n </thead>\n <tbody>\n ${weeks}\n </tbody>\n </table>\n `;\n return dayView;\n }\n\n private _generateMonths() {\n const rangeDates = this._generateIncrementDates();\n const selectedTime = rangeDates.map(e => setTimeToNoon(new Date(e.getFullYear(), e.getMonth())).getTime());\n\n const year = this.displayDate.getFullYear();\n\n const monthView = html`\n <div class=\"sgds monthpicker\">\n ${DatepickerCalendar.MONTHVIEW_LABELS.map((m, idx) => {\n const isCurrentMonth = idx === TODAY_DATE.getMonth() && year === TODAY_DATE.getFullYear();\n const time = setTimeToNoon(new Date(year, idx)).getTime();\n const isFirstSelectedMonth = rangeDates[0].getMonth() === idx;\n const isFirstSelectedYear = rangeDates[0].getFullYear() === year;\n const isLastSelectedMonth = rangeDates[rangeDates.length - 1].getMonth() === idx;\n const isLastSelectedYear = rangeDates[rangeDates.length - 1].getFullYear() === year;\n return html` <button\n class=${classMap({\n active: selectedTime.includes(time),\n today: isCurrentMonth,\n month: true,\n \"selected-ends\":\n (isFirstSelectedMonth && isFirstSelectedYear) || (isLastSelectedMonth && isLastSelectedYear)\n })}\n @click=${() => this._onClickMonth(idx)}\n data-month=${idx}\n data-year=${year}\n tabindex=\"3\"\n >\n ${m}\n </button>`;\n })}\n </div>\n `;\n return monthView;\n }\n\n private _generateYears() {\n const selectedYears = this._generateIncrementDates().map(e => e.getFullYear());\n const CURRENT_YEAR = TODAY_DATE.getFullYear();\n\n const yearArray = createYearViewArray(this.displayDate, CURRENT_YEAR);\n\n const yearView = html`\n <div class=\"sgds yearpicker\">\n ${yearArray.map(y => {\n const isFirstSelectedYear = selectedYears[0] === y;\n const isLastSectedYear = selectedYears[selectedYears.length - 1] === y;\n return html`\n <button\n class=${classMap({\n active: selectedYears.includes(y),\n year: true,\n today: CURRENT_YEAR === y,\n \"selected-ends\": isFirstSelectedYear || isLastSectedYear\n })}\n @click=${() => this._onClickYear(y)}\n data-year=${y}\n tabindex=\"3\"\n >\n ${y}\n </button>\n `;\n })}\n </div>\n `;\n return yearView;\n }\n render() {\n let viewContent: HTMLTemplateResult;\n\n switch (this.view) {\n case \"days\":\n viewContent = html` ${this._generateDays()} `;\n break;\n case \"months\":\n viewContent = html` ${this._generateMonths()} `;\n break;\n case \"years\":\n viewContent = html` ${this._generateYears()} `;\n break;\n default:\n viewContent = html` ${this._generateDays()} `; // Set a default view\n break;\n }\n\n return html` <div class=\"datepicker-body\">${viewContent}</div> `;\n }\n}\n\nexport default DatepickerCalendar;\n"],"names":["SgdsElement","setTimeToNoon","html","classMap","time","createYearViewArray","styles","__decorate","property","watch"],"mappings":";;;;;;;;;;;;;AASA,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;AAE9B,MAAM,cAAc,GAAG;AACrB,IAAA,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,CAAC,CAAC;AACV,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AACD,IAAA,SAAS,EAAE;QACT,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,CAAC,CAAC;AACV,KAAA;CACF,CAAC;AACI,MAAO,kBAAmB,SAAQA,sBAAW,CAAA;AAAnD,IAAA,WAAA,GAAA;;;QAa6B,IAAY,CAAA,YAAA,GAAW,EAAE,CAAC;;QAGrB,IAAW,CAAA,WAAA,GAAS,UAAU,CAAC;;QASpB,IAAI,CAAA,IAAA,GAAuB,QAAQ,CAAC;AAEvE,QAAA,IAAA,CAAA,WAAW,GAASC,kBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAgZ7D;;AApYQ,IAAA,eAAe,CAAC,QAAqB,EAAA;QAC1C,QAAQ,CAAC,IAAI,EAAE,CAAC;QAChB,IAAI,CAAC,oBAAoB,EAAE,CAAC;KAC7B;IAED,iBAA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,EAAE,MAAM,EAAE,CAAC;AAAkB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGFD,gBAAA,CAAA;IAA1CC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAqC,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAKnED,gBAAA,CAAA;AAAX,IAAAC,sBAAQ,EAAE;AAAgB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGED,gBAAA,CAAA;AAA5B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAe,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG3CD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,EAAE;AACa,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AA6BxBD,gBAAA,CAAA;IADCE,WAAK,CAAC,aAAa,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAGpD,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,IAAA,CAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"datepicker-calendar.cjs.js","sources":["../../../src/components/Datepicker/datepicker-calendar.ts"],"sourcesContent":["import { HTMLTemplateResult, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { createYearViewArray, setTimeToNoon } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-calendar.scss\";\nimport { ViewEnum } from \"./types\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { isAfter, isEqual } from \"date-fns\";\n\nconst TODAY_DATE = new Date();\n\nconst keyPressAction = {\n ArrowUp: {\n days: -7,\n months: -3,\n years: -3\n },\n ArrowDown: {\n days: 7,\n months: 3,\n years: 3\n },\n ArrowRight: {\n days: 1,\n months: 1,\n years: 1\n },\n ArrowLeft: {\n days: -1,\n months: -1,\n years: -1\n }\n};\nexport class DatepickerCalendar extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n static DAY_LABELS = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\n /** @internal */\n static daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n /** @internal */\n static MONTHVIEW_LABELS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\n /** @internal */\n @property({ type: Array }) selectedDate: Date[] = [];\n\n /** @internal */\n @property({ attribute: false }) displayDate: Date;\n\n /** @internal */\n @property({ type: String }) minDate?: string;\n\n /** @internal */\n @property({ type: String }) maxDate?: string;\n\n /** @internal */\n @property({ type: String, reflect: true }) mode: \"single\" | \"range\" = \"single\";\n\n private focusedDate: Date;\n\n /** @internal */\n @property() view: ViewEnum;\n\n /** @internal */\n @property({ type: Boolean }) show: boolean;\n\n @property()\n focusedTabIndex: number;\n\n /**Shifts focus from Input to Calendar */\n public focusOnCalendar(toBlurEl: HTMLElement) {\n toBlurEl.blur();\n this._focusOnCalendarCell();\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", this._handleKeyPress);\n }\n\n firstUpdated() {\n // if (this.selectedDate.length > 0) {\n // this.focusedDate = setTimeToNoon(this.selectedDate[0]);\n // } else {\n // this.focusedDate = this.displayDate && setTimeToNoon(this.displayDate);\n // }\n }\n updated() {\n /** For KeyboardNavigation (switching months) and ClickNavigation:\n * Runs after render has completed and td of next month has appeared.\n * For the case when calendar view changes to the next month\n * */\n\n if (this.focusedTabIndex === 3) {\n this._focusOnCalendarCell();\n }\n }\n\n @watch(\"displayDate\")\n _updateFocusedDate() {\n this.focusedDate = setTimeToNoon(this.displayDate);\n if (this.focusedDate.getFullYear() < 1900) {\n this.focusedDate.setFullYear(1900);\n }\n }\n\n private _setFocusedDate(shift: number) {\n const currentFocusedDate = this.focusedDate.getDate();\n const currentFocusedMonth = this.focusedDate.getMonth();\n const currentFocusedYear = this.focusedDate.getFullYear();\n switch (this.view) {\n case \"days\": {\n const newFocusedDate = setTimeToNoon(\n new Date(currentFocusedYear, currentFocusedMonth, currentFocusedDate + shift)\n );\n if (isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || isEqual(newFocusedDate, new Date(0, 0, 1, 12)))\n this.focusedDate = newFocusedDate;\n break;\n }\n case \"months\": {\n const newFocusedDate = setTimeToNoon(\n new Date(currentFocusedYear, currentFocusedMonth + shift, currentFocusedDate)\n );\n\n if (isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || isEqual(newFocusedDate, new Date(0, 0, 1, 12))) {\n this.focusedDate = newFocusedDate;\n }\n break;\n }\n case \"years\": {\n const newFocusedDate = setTimeToNoon(\n new Date(currentFocusedYear + shift, currentFocusedMonth, currentFocusedDate)\n );\n if (newFocusedDate.getFullYear() >= 1900) {\n this.focusedDate = newFocusedDate;\n }\n break;\n }\n }\n }\n private _handleEnterDateKeyboard(event: KeyboardEvent) {\n const targetElement = event.composedPath()[0] as HTMLElement;\n if (targetElement.classList.contains(\"disabled\")) return;\n\n switch (this.view) {\n case \"days\":\n this._onClickDay(event);\n break;\n case \"months\": {\n const { month } = targetElement.dataset;\n this._onClickMonth(parseInt(month));\n break;\n }\n case \"years\": {\n const { year } = targetElement.dataset;\n this._onClickYear(parseInt(year));\n }\n }\n }\n private _handleKeyPress(event: KeyboardEvent) {\n if (event.key === \"Enter\") {\n event.preventDefault();\n this._handleEnterDateKeyboard(event);\n return;\n }\n if (event.key === \"Tab\") {\n const targetEl: HTMLElement = this._getFocusedTarget();\n if (this.focusedTabIndex !== 3) targetEl.blur();\n return;\n }\n if (event.key.includes(\"Arrow\")) {\n event.preventDefault();\n this._blurCalendarCell();\n const keyShiftObject = keyPressAction[event.key];\n const shiftNumber = keyShiftObject[this.view];\n\n this._setFocusedDate(shiftNumber);\n\n this._focusOnCalendarCell();\n }\n }\n\n private _generateIncrementDates(): Date[] {\n const start = setTimeToNoon(this.selectedDate[0]);\n\n if (this.selectedDate.length < 2) {\n return [start];\n }\n\n const end = setTimeToNoon(this.selectedDate[1]);\n const arr: Date[] = [];\n if (start.getTime() < end.getTime()) {\n for (let dt = start; dt <= end; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n } else {\n for (let dt = end; dt <= start; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n }\n return arr;\n }\n\n private _onClickDay(event: MouseEvent | KeyboardEvent) {\n const { day, date } = (event.composedPath()[0] as HTMLTableCellElement).dataset;\n\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setDate(parseInt(day));\n /** update new focused date for mouse click */\n if (event.type === \"click\") {\n this.focusedDate = setTimeToNoon(new Date(date));\n }\n\n if (this.mode === \"single\") {\n // Single mode: Select a single date\n\n this.selectedDate = [displayDateClone];\n\n // Emit event with selected date\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n } else if (this.mode === \"range\") {\n // Range mode: Select a range of dates\n const selectedDates = [...this.selectedDate];\n\n if (selectedDates.length === 0 || selectedDates.length === 2) {\n // No dates selected yet or both dates already selected,\n // start a new range by clearing the selected dates array\n selectedDates.length = 0;\n }\n\n // Add the selected date to the range\n selectedDates.push(displayDateClone);\n\n // Update the selectedDate property\n this.selectedDate = selectedDates;\n\n // Emit event with the range of selected dates\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n }\n\n // Check if the selected date is before minDate or after maxDate\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n\n const selectedDate = setTimeToNoon(displayDateClone);\n if ((minimumDate && selectedDate < minimumDate) || (maximumDate && selectedDate > maximumDate)) {\n event.stopPropagation();\n event.preventDefault();\n }\n }\n\n private _onClickMonth(month: number, year: number = this.focusedDate.getFullYear()) {\n const displayDateClone = new Date(this.displayDate);\n this.view = \"days\";\n displayDateClone.setMonth(month);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.emit(\"sgds-view\", { detail: this.view });\n //once clicked, should change view to days, and hold value and change view\n this.emit(\"sgds-selectmonth\", { detail: this.displayDate });\n }\n\n private _onClickYear(year: number) {\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.view = \"months\";\n this.emit(\"sgds-view\", { detail: this.view });\n\n this.emit(\"sgds-selectyear\", { detail: this.displayDate });\n }\n\n private _getFocusedTarget(): HTMLElement {\n const queryObj = {\n days: `td[data-date=\"${this.focusedDate.toISOString()}\"]`,\n months: `button[data-month=\"${this.focusedDate.getMonth()}\"][data-year=\"${this.focusedDate.getFullYear()}\"]`,\n years: `button[data-year=\"${this.focusedDate.getFullYear()}\"]`\n };\n const queryString = queryObj[this.view];\n const targetEl: HTMLElement = this.shadowRoot.querySelector(`${queryString}`);\n return targetEl;\n }\n private _blurCalendarCell() {\n const targetEl = this._getFocusedTarget();\n targetEl.setAttribute(\"tabindex\", \"-1\");\n targetEl.blur();\n }\n private _focusOnCalendarCell() {\n const targetEl = this._getFocusedTarget();\n if (targetEl) {\n targetEl.setAttribute(\"tabindex\", \"3\");\n targetEl.focus();\n this.emit(\"sgds-update-focus\", { detail: this.focusedDate });\n } else {\n /** Change month view */\n this.emit(\"sgds-change-calendar\", { detail: this.focusedDate });\n }\n }\n private _generateDays() {\n const selectedDates = this.selectedDate.map(d => setTimeToNoon(d));\n\n const rangeSelectedDates = this._generateIncrementDates();\n\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n const year = this.displayDate.getFullYear();\n const month = this.displayDate.getMonth();\n const firstDateOfMonth = new Date(year, month, 1);\n const startingDayOfMonth = firstDateOfMonth.getDay();\n let monthLength = DatepickerCalendar.daysInMonth[month];\n if (month === 1) {\n if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {\n monthLength = 29;\n }\n }\n\n const weeks = [];\n let day = 1;\n for (let i = 0; i < 9; i++) {\n const week = [];\n for (let j = 0; j <= 6; j++) {\n if (day <= monthLength && (i > 0 || j >= startingDayOfMonth)) {\n const date = new Date(year, month, day, 12, 0, 0, 0).toISOString();\n const beforeMinDate = minimumDate && Date.parse(date) < Date.parse(minimumDate.toISOString());\n const afterMinDate = maximumDate && Date.parse(date) > Date.parse(maximumDate.toISOString());\n const clickHandler = beforeMinDate || afterMinDate ? undefined : this._onClickDay;\n\n const isCurrentMonth = TODAY_DATE.getMonth() === this.displayDate.getMonth();\n const isCurrentYear = TODAY_DATE.getFullYear() === this.displayDate.getFullYear();\n const isCurrentDay = TODAY_DATE.getDate() === day;\n\n const isSelected =\n selectedDates.length > 0 && rangeSelectedDates.some(d => Date.parse(date) === Date.parse(d.toISOString()));\n const isFirstSelectedDate = selectedDates.length > 0 && rangeSelectedDates[0].toISOString() === date;\n const isLastSelectedDate =\n selectedDates.length > 1 && rangeSelectedDates[rangeSelectedDates.length - 1].toISOString() === date;\n\n week.push(\n html`<td\n key=${j}\n data-date=${date}\n data-day=${day}\n class=${classMap({\n today: isCurrentDay && isCurrentMonth && isCurrentYear,\n \"selected-ends\": isFirstSelectedDate || isLastSelectedDate,\n active: isSelected,\n disabled: beforeMinDate || afterMinDate\n })}\n @click=${clickHandler}\n tabindex=${this.focusedDate === new Date(date) ? \"3\" : \"-1\"}\n ?disabled=${beforeMinDate || afterMinDate}\n >\n ${day}\n </td>`\n );\n day++;\n } else {\n week.push(html`<td key=${j}></td>`);\n }\n }\n\n weeks.push(\n html`<tr key=${i}>\n ${week}\n </tr>`\n );\n if (day > monthLength) {\n break;\n }\n }\n\n const dayView = html`\n <table class=\"text-center\">\n <thead>\n <tr>\n ${DatepickerCalendar.DAY_LABELS.map(\n (label: string, index: number) =>\n html`\n <th key=${index}>\n <small>${label}</small>\n </th>\n `\n )}\n </tr>\n </thead>\n <tbody>\n ${weeks}\n </tbody>\n </table>\n `;\n return dayView;\n }\n\n private _generateMonths() {\n const rangeDates = this._generateIncrementDates();\n const selectedTime = rangeDates.map(e => setTimeToNoon(new Date(e.getFullYear(), e.getMonth())).getTime());\n\n const year = this.displayDate.getFullYear();\n\n const monthView = html`\n <div class=\"sgds monthpicker\">\n ${DatepickerCalendar.MONTHVIEW_LABELS.map((m, idx) => {\n const isCurrentMonth = idx === TODAY_DATE.getMonth() && year === TODAY_DATE.getFullYear();\n const time = setTimeToNoon(new Date(year, idx)).getTime();\n const isFirstSelectedMonth = rangeDates[0].getMonth() === idx;\n const isFirstSelectedYear = rangeDates[0].getFullYear() === year;\n const isLastSelectedMonth = rangeDates[rangeDates.length - 1].getMonth() === idx;\n const isLastSelectedYear = rangeDates[rangeDates.length - 1].getFullYear() === year;\n return html` <button\n class=${classMap({\n active: selectedTime.includes(time),\n today: isCurrentMonth,\n month: true,\n \"selected-ends\":\n (isFirstSelectedMonth && isFirstSelectedYear) || (isLastSelectedMonth && isLastSelectedYear)\n })}\n @click=${() => this._onClickMonth(idx)}\n data-month=${idx}\n data-year=${year}\n tabindex=\"3\"\n >\n ${m}\n </button>`;\n })}\n </div>\n `;\n return monthView;\n }\n\n private _generateYears() {\n const selectedYears = this._generateIncrementDates().map(e => e.getFullYear());\n const CURRENT_YEAR = TODAY_DATE.getFullYear();\n\n const yearArray = createYearViewArray(this.displayDate, CURRENT_YEAR);\n\n const yearView = html`\n <div class=\"sgds yearpicker\">\n ${yearArray.map(y => {\n const isFirstSelectedYear = selectedYears[0] === y;\n const isLastSectedYear = selectedYears[selectedYears.length - 1] === y;\n return html`\n <button\n class=${classMap({\n active: selectedYears.includes(y),\n year: true,\n today: CURRENT_YEAR === y,\n \"selected-ends\": isFirstSelectedYear || isLastSectedYear\n })}\n @click=${() => this._onClickYear(y)}\n data-year=${y}\n tabindex=\"3\"\n ?disabled=${y < 1900}\n >\n ${y}\n </button>\n `;\n })}\n </div>\n `;\n return yearView;\n }\n render() {\n let viewContent: HTMLTemplateResult;\n\n switch (this.view) {\n case \"days\":\n viewContent = html` ${this._generateDays()} `;\n break;\n case \"months\":\n viewContent = html` ${this._generateMonths()} `;\n break;\n case \"years\":\n viewContent = html` ${this._generateYears()} `;\n break;\n default:\n viewContent = html` ${this._generateDays()} `; // Set a default view\n break;\n }\n\n return html` <div class=\"datepicker-body\">${viewContent}</div> `;\n }\n}\n\nexport default DatepickerCalendar;\n"],"names":["SgdsElement","setTimeToNoon","isAfter","isEqual","html","classMap","time","createYearViewArray","styles","__decorate","property","watch"],"mappings":";;;;;;;;;;;;;;AAUA,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;AAE9B,MAAM,cAAc,GAAG;AACrB,IAAA,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,CAAC,CAAC;AACV,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AACD,IAAA,SAAS,EAAE;QACT,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,CAAC,CAAC;AACV,KAAA;CACF,CAAC;AACI,MAAO,kBAAmB,SAAQA,sBAAW,CAAA;AAAnD,IAAA,WAAA,GAAA;;;QAa6B,IAAY,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CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAKnED,gBAAA,CAAA;AAAX,IAAAC,sBAAQ,EAAE;AAAgB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGED,gBAAA,CAAA;AAA5B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAe,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG3CD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,EAAE;AACa,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAgCxBD,gBAAA,CAAA;IADCE,WAAK,CAAC,aAAa,CAAC;AAMpB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,IAAA,CAAA;;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
5
4
|
import SgdsElement from '../../base/sgds-element.js';
|
|
6
5
|
import { setTimeToNoon, createYearViewArray } from '../../utils/time.js';
|
|
7
6
|
import { watch } from '../../utils/watch.js';
|
|
8
7
|
import css_248z from './datepicker-calendar2.js';
|
|
8
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
9
|
+
import { isAfter, isEqual } from 'date-fns';
|
|
9
10
|
|
|
10
11
|
const TODAY_DATE = new Date();
|
|
11
12
|
const keyPressAction = {
|
|
@@ -36,10 +37,7 @@ class DatepickerCalendar extends SgdsElement {
|
|
|
36
37
|
/** @internal */
|
|
37
38
|
this.selectedDate = [];
|
|
38
39
|
/** @internal */
|
|
39
|
-
this.displayDate = TODAY_DATE;
|
|
40
|
-
/** @internal */
|
|
41
40
|
this.mode = "single";
|
|
42
|
-
this.focusedDate = setTimeToNoon(this.displayDate);
|
|
43
41
|
}
|
|
44
42
|
/**Shifts focus from Input to Calendar */
|
|
45
43
|
focusOnCalendar(toBlurEl) {
|
|
@@ -51,9 +49,11 @@ class DatepickerCalendar extends SgdsElement {
|
|
|
51
49
|
this.addEventListener("keydown", this._handleKeyPress);
|
|
52
50
|
}
|
|
53
51
|
firstUpdated() {
|
|
54
|
-
if (this.selectedDate.length > 0) {
|
|
55
|
-
|
|
56
|
-
}
|
|
52
|
+
// if (this.selectedDate.length > 0) {
|
|
53
|
+
// this.focusedDate = setTimeToNoon(this.selectedDate[0]);
|
|
54
|
+
// } else {
|
|
55
|
+
// this.focusedDate = this.displayDate && setTimeToNoon(this.displayDate);
|
|
56
|
+
// }
|
|
57
57
|
}
|
|
58
58
|
updated() {
|
|
59
59
|
/** For KeyboardNavigation (switching months) and ClickNavigation:
|
|
@@ -66,19 +66,33 @@ class DatepickerCalendar extends SgdsElement {
|
|
|
66
66
|
}
|
|
67
67
|
_updateFocusedDate() {
|
|
68
68
|
this.focusedDate = setTimeToNoon(this.displayDate);
|
|
69
|
+
if (this.focusedDate.getFullYear() < 1900) {
|
|
70
|
+
this.focusedDate.setFullYear(1900);
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
_setFocusedDate(shift) {
|
|
74
|
+
const currentFocusedDate = this.focusedDate.getDate();
|
|
75
|
+
const currentFocusedMonth = this.focusedDate.getMonth();
|
|
76
|
+
const currentFocusedYear = this.focusedDate.getFullYear();
|
|
71
77
|
switch (this.view) {
|
|
72
78
|
case "days": {
|
|
73
|
-
|
|
79
|
+
const newFocusedDate = setTimeToNoon(new Date(currentFocusedYear, currentFocusedMonth, currentFocusedDate + shift));
|
|
80
|
+
if (isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || isEqual(newFocusedDate, new Date(0, 0, 1, 12)))
|
|
81
|
+
this.focusedDate = newFocusedDate;
|
|
74
82
|
break;
|
|
75
83
|
}
|
|
76
84
|
case "months": {
|
|
77
|
-
|
|
85
|
+
const newFocusedDate = setTimeToNoon(new Date(currentFocusedYear, currentFocusedMonth + shift, currentFocusedDate));
|
|
86
|
+
if (isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || isEqual(newFocusedDate, new Date(0, 0, 1, 12))) {
|
|
87
|
+
this.focusedDate = newFocusedDate;
|
|
88
|
+
}
|
|
78
89
|
break;
|
|
79
90
|
}
|
|
80
91
|
case "years": {
|
|
81
|
-
|
|
92
|
+
const newFocusedDate = setTimeToNoon(new Date(currentFocusedYear + shift, currentFocusedMonth, currentFocusedDate));
|
|
93
|
+
if (newFocusedDate.getFullYear() >= 1900) {
|
|
94
|
+
this.focusedDate = newFocusedDate;
|
|
95
|
+
}
|
|
82
96
|
break;
|
|
83
97
|
}
|
|
84
98
|
}
|
|
@@ -268,7 +282,7 @@ class DatepickerCalendar extends SgdsElement {
|
|
|
268
282
|
})}
|
|
269
283
|
@click=${clickHandler}
|
|
270
284
|
tabindex=${this.focusedDate === new Date(date) ? "3" : "-1"}
|
|
271
|
-
disabled=${beforeMinDate || afterMinDate}
|
|
285
|
+
?disabled=${beforeMinDate || afterMinDate}
|
|
272
286
|
>
|
|
273
287
|
${day}
|
|
274
288
|
</td>`);
|
|
@@ -290,9 +304,9 @@ class DatepickerCalendar extends SgdsElement {
|
|
|
290
304
|
<thead>
|
|
291
305
|
<tr>
|
|
292
306
|
${DatepickerCalendar.DAY_LABELS.map((label, index) => html `
|
|
293
|
-
<
|
|
307
|
+
<th key=${index}>
|
|
294
308
|
<small>${label}</small>
|
|
295
|
-
</
|
|
309
|
+
</th>
|
|
296
310
|
`)}
|
|
297
311
|
</tr>
|
|
298
312
|
</thead>
|
|
@@ -355,6 +369,7 @@ class DatepickerCalendar extends SgdsElement {
|
|
|
355
369
|
@click=${() => this._onClickYear(y)}
|
|
356
370
|
data-year=${y}
|
|
357
371
|
tabindex="3"
|
|
372
|
+
?disabled=${y < 1900}
|
|
358
373
|
>
|
|
359
374
|
${y}
|
|
360
375
|
</button>
|
|
@@ -415,7 +430,7 @@ __decorate([
|
|
|
415
430
|
property()
|
|
416
431
|
], DatepickerCalendar.prototype, "focusedTabIndex", void 0);
|
|
417
432
|
__decorate([
|
|
418
|
-
watch("displayDate"
|
|
433
|
+
watch("displayDate")
|
|
419
434
|
], DatepickerCalendar.prototype, "_updateFocusedDate", null);
|
|
420
435
|
|
|
421
436
|
export { DatepickerCalendar, DatepickerCalendar as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datepicker-calendar.js","sources":["../../../src/components/Datepicker/datepicker-calendar.ts"],"sourcesContent":["import { HTMLTemplateResult, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { createYearViewArray, setTimeToNoon } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-calendar.scss\";\nimport { ViewEnum } from \"./types\";\n\nconst TODAY_DATE = new Date();\n\nconst keyPressAction = {\n ArrowUp: {\n days: -7,\n months: -3,\n years: -3\n },\n ArrowDown: {\n days: 7,\n months: 3,\n years: 3\n },\n ArrowRight: {\n days: 1,\n months: 1,\n years: 1\n },\n ArrowLeft: {\n days: -1,\n months: -1,\n years: -1\n }\n};\nexport class DatepickerCalendar extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n static DAY_LABELS = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\n /** @internal */\n static daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n /** @internal */\n static MONTHVIEW_LABELS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\n /** @internal */\n @property({ type: Array }) selectedDate: Date[] = [];\n\n /** @internal */\n @property({ attribute: false }) displayDate: Date = TODAY_DATE;\n\n /** @internal */\n @property({ type: String }) minDate?: string;\n\n /** @internal */\n @property({ type: String }) maxDate?: string;\n\n /** @internal */\n @property({ type: String, reflect: true }) mode: \"single\" | \"range\" = \"single\";\n\n private focusedDate: Date = setTimeToNoon(this.displayDate);\n\n /** @internal */\n @property() view: ViewEnum;\n\n /** @internal */\n @property({ type: Boolean }) show: boolean;\n\n @property()\n focusedTabIndex: number;\n\n /**Shifts focus from Input to Calendar */\n public focusOnCalendar(toBlurEl: HTMLElement) {\n toBlurEl.blur();\n this._focusOnCalendarCell();\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", this._handleKeyPress);\n }\n\n firstUpdated() {\n if (this.selectedDate.length > 0) {\n this.focusedDate = setTimeToNoon(this.selectedDate[0]);\n }\n }\n updated() {\n /** For KeyboardNavigation (switching months) and ClickNavigation:\n * Runs after render has completed and td of next month has appeared.\n * For the case when calendar view changes to the next month\n * */\n if (this.focusedTabIndex === 3) {\n this._focusOnCalendarCell();\n }\n }\n\n @watch(\"displayDate\", { waitUntilFirstUpdate: true })\n _updateFocusedDate() {\n this.focusedDate = setTimeToNoon(this.displayDate);\n }\n\n private _setFocusedDate(shift: number) {\n switch (this.view) {\n case \"days\": {\n this.focusedDate = setTimeToNoon(new Date(this.focusedDate.setDate(this.focusedDate.getDate() + shift)));\n break;\n }\n case \"months\": {\n this.focusedDate = setTimeToNoon(new Date(this.focusedDate.setMonth(this.focusedDate.getMonth() + shift)));\n break;\n }\n case \"years\": {\n this.focusedDate = setTimeToNoon(\n new Date(this.focusedDate.setFullYear(this.focusedDate.getFullYear() + shift))\n );\n break;\n }\n }\n }\n private _handleEnterDateKeyboard(event: KeyboardEvent) {\n const targetElement = event.composedPath()[0] as HTMLElement;\n if (targetElement.classList.contains(\"disabled\")) return;\n\n switch (this.view) {\n case \"days\":\n this._onClickDay(event);\n break;\n case \"months\": {\n const { month } = targetElement.dataset;\n this._onClickMonth(parseInt(month));\n break;\n }\n case \"years\": {\n const { year } = targetElement.dataset;\n this._onClickYear(parseInt(year));\n }\n }\n }\n private _handleKeyPress(event: KeyboardEvent) {\n if (event.key === \"Enter\") {\n event.preventDefault();\n this._handleEnterDateKeyboard(event);\n return;\n }\n if (event.key === \"Tab\") {\n const targetEl: HTMLElement = this._getFocusedTarget();\n if (this.focusedTabIndex !== 3) targetEl.blur();\n return;\n }\n if (event.key.includes(\"Arrow\")) {\n event.preventDefault();\n this._blurCalendarCell();\n const keyShiftObject = keyPressAction[event.key];\n const shiftNumber = keyShiftObject[this.view];\n this._setFocusedDate(shiftNumber);\n\n this._focusOnCalendarCell();\n }\n }\n\n private _generateIncrementDates(): Date[] {\n const start = setTimeToNoon(this.selectedDate[0]);\n\n if (this.selectedDate.length < 2) {\n return [start];\n }\n\n const end = setTimeToNoon(this.selectedDate[1]);\n const arr: Date[] = [];\n if (start.getTime() < end.getTime()) {\n for (let dt = start; dt <= end; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n } else {\n for (let dt = end; dt <= start; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n }\n return arr;\n }\n\n private _onClickDay(event: MouseEvent | KeyboardEvent) {\n const { day, date } = (event.composedPath()[0] as HTMLTableCellElement).dataset;\n\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setDate(parseInt(day));\n /** update new focused date for mouse click */\n if (event.type === \"click\") {\n this.focusedDate = setTimeToNoon(new Date(date));\n }\n\n if (this.mode === \"single\") {\n // Single mode: Select a single date\n\n this.selectedDate = [displayDateClone];\n\n // Emit event with selected date\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n } else if (this.mode === \"range\") {\n // Range mode: Select a range of dates\n const selectedDates = [...this.selectedDate];\n\n if (selectedDates.length === 0 || selectedDates.length === 2) {\n // No dates selected yet or both dates already selected,\n // start a new range by clearing the selected dates array\n selectedDates.length = 0;\n }\n\n // Add the selected date to the range\n selectedDates.push(displayDateClone);\n\n // Update the selectedDate property\n this.selectedDate = selectedDates;\n\n // Emit event with the range of selected dates\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n }\n\n // Check if the selected date is before minDate or after maxDate\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n\n const selectedDate = setTimeToNoon(displayDateClone);\n if ((minimumDate && selectedDate < minimumDate) || (maximumDate && selectedDate > maximumDate)) {\n event.stopPropagation();\n event.preventDefault();\n }\n }\n\n private _onClickMonth(month: number, year: number = this.focusedDate.getFullYear()) {\n const displayDateClone = new Date(this.displayDate);\n this.view = \"days\";\n displayDateClone.setMonth(month);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.emit(\"sgds-view\", { detail: this.view });\n //once clicked, should change view to days, and hold value and change view\n this.emit(\"sgds-selectmonth\", { detail: this.displayDate });\n }\n\n private _onClickYear(year: number) {\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.view = \"months\";\n this.emit(\"sgds-view\", { detail: this.view });\n\n this.emit(\"sgds-selectyear\", { detail: this.displayDate });\n }\n\n private _getFocusedTarget(): HTMLElement {\n const queryObj = {\n days: `td[data-date=\"${this.focusedDate.toISOString()}\"]`,\n months: `button[data-month=\"${this.focusedDate.getMonth()}\"][data-year=\"${this.focusedDate.getFullYear()}\"]`,\n years: `button[data-year=\"${this.focusedDate.getFullYear()}\"]`\n };\n const queryString = queryObj[this.view];\n const targetEl: HTMLElement = this.shadowRoot.querySelector(`${queryString}`);\n return targetEl;\n }\n private _blurCalendarCell() {\n const targetEl = this._getFocusedTarget();\n targetEl.setAttribute(\"tabindex\", \"-1\");\n targetEl.blur();\n }\n private _focusOnCalendarCell() {\n const targetEl = this._getFocusedTarget();\n if (targetEl) {\n targetEl.setAttribute(\"tabindex\", \"3\");\n targetEl.focus();\n this.emit(\"sgds-update-focus\", { detail: this.focusedDate });\n } else {\n /** Change month view */\n this.emit(\"sgds-change-calendar\", { detail: this.focusedDate });\n }\n }\n private _generateDays() {\n const selectedDates = this.selectedDate.map(d => setTimeToNoon(d));\n\n const rangeSelectedDates = this._generateIncrementDates();\n\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n const year = this.displayDate.getFullYear();\n const month = this.displayDate.getMonth();\n const firstDateOfMonth = new Date(year, month, 1);\n const startingDayOfMonth = firstDateOfMonth.getDay();\n let monthLength = DatepickerCalendar.daysInMonth[month];\n if (month === 1) {\n if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {\n monthLength = 29;\n }\n }\n\n const weeks = [];\n let day = 1;\n for (let i = 0; i < 9; i++) {\n const week = [];\n for (let j = 0; j <= 6; j++) {\n if (day <= monthLength && (i > 0 || j >= startingDayOfMonth)) {\n const date = new Date(year, month, day, 12, 0, 0, 0).toISOString();\n\n const beforeMinDate = minimumDate && Date.parse(date) < Date.parse(minimumDate.toISOString());\n const afterMinDate = maximumDate && Date.parse(date) > Date.parse(maximumDate.toISOString());\n const clickHandler = beforeMinDate || afterMinDate ? undefined : this._onClickDay;\n\n const isCurrentMonth = TODAY_DATE.getMonth() === this.displayDate.getMonth();\n const isCurrentYear = TODAY_DATE.getFullYear() === this.displayDate.getFullYear();\n const isCurrentDay = TODAY_DATE.getDate() === day;\n\n const isSelected =\n selectedDates.length > 0 && rangeSelectedDates.some(d => Date.parse(date) === Date.parse(d.toISOString()));\n const isFirstSelectedDate = selectedDates.length > 0 && rangeSelectedDates[0].toISOString() === date;\n const isLastSelectedDate =\n selectedDates.length > 1 && rangeSelectedDates[rangeSelectedDates.length - 1].toISOString() === date;\n\n week.push(\n html`<td\n key=${j}\n data-date=${date}\n data-day=${day}\n class=${classMap({\n today: isCurrentDay && isCurrentMonth && isCurrentYear,\n \"selected-ends\": isFirstSelectedDate || isLastSelectedDate,\n active: isSelected,\n disabled: beforeMinDate || afterMinDate\n })}\n @click=${clickHandler}\n tabindex=${this.focusedDate === new Date(date) ? \"3\" : \"-1\"}\n disabled=${beforeMinDate || afterMinDate}\n >\n ${day}\n </td>`\n );\n day++;\n } else {\n week.push(html`<td key=${j}></td>`);\n }\n }\n\n weeks.push(\n html`<tr key=${i}>\n ${week}\n </tr>`\n );\n if (day > monthLength) {\n break;\n }\n }\n\n const dayView = html`\n <table class=\"text-center\">\n <thead>\n <tr>\n ${DatepickerCalendar.DAY_LABELS.map(\n (label: string, index: number) =>\n html`\n <td key=${index}>\n <small>${label}</small>\n </td>\n `\n )}\n </tr>\n </thead>\n <tbody>\n ${weeks}\n </tbody>\n </table>\n `;\n return dayView;\n }\n\n private _generateMonths() {\n const rangeDates = this._generateIncrementDates();\n const selectedTime = rangeDates.map(e => setTimeToNoon(new Date(e.getFullYear(), e.getMonth())).getTime());\n\n const year = this.displayDate.getFullYear();\n\n const monthView = html`\n <div class=\"sgds monthpicker\">\n ${DatepickerCalendar.MONTHVIEW_LABELS.map((m, idx) => {\n const isCurrentMonth = idx === TODAY_DATE.getMonth() && year === TODAY_DATE.getFullYear();\n const time = setTimeToNoon(new Date(year, idx)).getTime();\n const isFirstSelectedMonth = rangeDates[0].getMonth() === idx;\n const isFirstSelectedYear = rangeDates[0].getFullYear() === year;\n const isLastSelectedMonth = rangeDates[rangeDates.length - 1].getMonth() === idx;\n const isLastSelectedYear = rangeDates[rangeDates.length - 1].getFullYear() === year;\n return html` <button\n class=${classMap({\n active: selectedTime.includes(time),\n today: isCurrentMonth,\n month: true,\n \"selected-ends\":\n (isFirstSelectedMonth && isFirstSelectedYear) || (isLastSelectedMonth && isLastSelectedYear)\n })}\n @click=${() => this._onClickMonth(idx)}\n data-month=${idx}\n data-year=${year}\n tabindex=\"3\"\n >\n ${m}\n </button>`;\n })}\n </div>\n `;\n return monthView;\n }\n\n private _generateYears() {\n const selectedYears = this._generateIncrementDates().map(e => e.getFullYear());\n const CURRENT_YEAR = TODAY_DATE.getFullYear();\n\n const yearArray = createYearViewArray(this.displayDate, CURRENT_YEAR);\n\n const yearView = html`\n <div class=\"sgds yearpicker\">\n ${yearArray.map(y => {\n const isFirstSelectedYear = selectedYears[0] === y;\n const isLastSectedYear = selectedYears[selectedYears.length - 1] === y;\n return html`\n <button\n class=${classMap({\n active: selectedYears.includes(y),\n year: true,\n today: CURRENT_YEAR === y,\n \"selected-ends\": isFirstSelectedYear || isLastSectedYear\n })}\n @click=${() => this._onClickYear(y)}\n data-year=${y}\n tabindex=\"3\"\n >\n ${y}\n </button>\n `;\n })}\n </div>\n `;\n return yearView;\n }\n render() {\n let viewContent: HTMLTemplateResult;\n\n switch (this.view) {\n case \"days\":\n viewContent = html` ${this._generateDays()} `;\n break;\n case \"months\":\n viewContent = html` ${this._generateMonths()} `;\n break;\n case \"years\":\n viewContent = html` ${this._generateYears()} `;\n break;\n default:\n viewContent = html` ${this._generateDays()} `; // Set a default view\n break;\n }\n\n return html` <div class=\"datepicker-body\">${viewContent}</div> `;\n }\n}\n\nexport default DatepickerCalendar;\n"],"names":["styles"],"mappings":";;;;;;;;;AASA,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;AAE9B,MAAM,cAAc,GAAG;AACrB,IAAA,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,CAAC,CAAC;AACV,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AACD,IAAA,SAAS,EAAE;QACT,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;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A,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"datepicker-calendar.js","sources":["../../../src/components/Datepicker/datepicker-calendar.ts"],"sourcesContent":["import { HTMLTemplateResult, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { createYearViewArray, setTimeToNoon } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-calendar.scss\";\nimport { ViewEnum } from \"./types\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { isAfter, isEqual } from \"date-fns\";\n\nconst TODAY_DATE = new Date();\n\nconst keyPressAction = {\n ArrowUp: {\n days: -7,\n months: -3,\n years: -3\n },\n ArrowDown: {\n days: 7,\n months: 3,\n years: 3\n },\n ArrowRight: {\n days: 1,\n months: 1,\n years: 1\n },\n ArrowLeft: {\n days: -1,\n months: -1,\n years: -1\n }\n};\nexport class DatepickerCalendar extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n static DAY_LABELS = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n\n /** @internal */\n static daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n /** @internal */\n static MONTHVIEW_LABELS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\n /** @internal */\n @property({ type: Array }) selectedDate: Date[] = [];\n\n /** @internal */\n @property({ attribute: false }) displayDate: Date;\n\n /** @internal */\n @property({ type: String }) minDate?: string;\n\n /** @internal */\n @property({ type: String }) maxDate?: string;\n\n /** @internal */\n @property({ type: String, reflect: true }) mode: \"single\" | \"range\" = \"single\";\n\n private focusedDate: Date;\n\n /** @internal */\n @property() view: ViewEnum;\n\n /** @internal */\n @property({ type: Boolean }) show: boolean;\n\n @property()\n focusedTabIndex: number;\n\n /**Shifts focus from Input to Calendar */\n public focusOnCalendar(toBlurEl: HTMLElement) {\n toBlurEl.blur();\n this._focusOnCalendarCell();\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"keydown\", this._handleKeyPress);\n }\n\n firstUpdated() {\n // if (this.selectedDate.length > 0) {\n // this.focusedDate = setTimeToNoon(this.selectedDate[0]);\n // } else {\n // this.focusedDate = this.displayDate && setTimeToNoon(this.displayDate);\n // }\n }\n updated() {\n /** For KeyboardNavigation (switching months) and ClickNavigation:\n * Runs after render has completed and td of next month has appeared.\n * For the case when calendar view changes to the next month\n * */\n\n if (this.focusedTabIndex === 3) {\n this._focusOnCalendarCell();\n }\n }\n\n @watch(\"displayDate\")\n _updateFocusedDate() {\n this.focusedDate = setTimeToNoon(this.displayDate);\n if (this.focusedDate.getFullYear() < 1900) {\n this.focusedDate.setFullYear(1900);\n }\n }\n\n private _setFocusedDate(shift: number) {\n const currentFocusedDate = this.focusedDate.getDate();\n const currentFocusedMonth = this.focusedDate.getMonth();\n const currentFocusedYear = this.focusedDate.getFullYear();\n switch (this.view) {\n case \"days\": {\n const newFocusedDate = setTimeToNoon(\n new Date(currentFocusedYear, currentFocusedMonth, currentFocusedDate + shift)\n );\n if (isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || isEqual(newFocusedDate, new Date(0, 0, 1, 12)))\n this.focusedDate = newFocusedDate;\n break;\n }\n case \"months\": {\n const newFocusedDate = setTimeToNoon(\n new Date(currentFocusedYear, currentFocusedMonth + shift, currentFocusedDate)\n );\n\n if (isAfter(newFocusedDate, new Date(0, 0, 1, 12)) || isEqual(newFocusedDate, new Date(0, 0, 1, 12))) {\n this.focusedDate = newFocusedDate;\n }\n break;\n }\n case \"years\": {\n const newFocusedDate = setTimeToNoon(\n new Date(currentFocusedYear + shift, currentFocusedMonth, currentFocusedDate)\n );\n if (newFocusedDate.getFullYear() >= 1900) {\n this.focusedDate = newFocusedDate;\n }\n break;\n }\n }\n }\n private _handleEnterDateKeyboard(event: KeyboardEvent) {\n const targetElement = event.composedPath()[0] as HTMLElement;\n if (targetElement.classList.contains(\"disabled\")) return;\n\n switch (this.view) {\n case \"days\":\n this._onClickDay(event);\n break;\n case \"months\": {\n const { month } = targetElement.dataset;\n this._onClickMonth(parseInt(month));\n break;\n }\n case \"years\": {\n const { year } = targetElement.dataset;\n this._onClickYear(parseInt(year));\n }\n }\n }\n private _handleKeyPress(event: KeyboardEvent) {\n if (event.key === \"Enter\") {\n event.preventDefault();\n this._handleEnterDateKeyboard(event);\n return;\n }\n if (event.key === \"Tab\") {\n const targetEl: HTMLElement = this._getFocusedTarget();\n if (this.focusedTabIndex !== 3) targetEl.blur();\n return;\n }\n if (event.key.includes(\"Arrow\")) {\n event.preventDefault();\n this._blurCalendarCell();\n const keyShiftObject = keyPressAction[event.key];\n const shiftNumber = keyShiftObject[this.view];\n\n this._setFocusedDate(shiftNumber);\n\n this._focusOnCalendarCell();\n }\n }\n\n private _generateIncrementDates(): Date[] {\n const start = setTimeToNoon(this.selectedDate[0]);\n\n if (this.selectedDate.length < 2) {\n return [start];\n }\n\n const end = setTimeToNoon(this.selectedDate[1]);\n const arr: Date[] = [];\n if (start.getTime() < end.getTime()) {\n for (let dt = start; dt <= end; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n } else {\n for (let dt = end; dt <= start; dt.setDate(dt.getDate() + 1)) {\n arr.push(new Date(dt));\n }\n }\n return arr;\n }\n\n private _onClickDay(event: MouseEvent | KeyboardEvent) {\n const { day, date } = (event.composedPath()[0] as HTMLTableCellElement).dataset;\n\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setDate(parseInt(day));\n /** update new focused date for mouse click */\n if (event.type === \"click\") {\n this.focusedDate = setTimeToNoon(new Date(date));\n }\n\n if (this.mode === \"single\") {\n // Single mode: Select a single date\n\n this.selectedDate = [displayDateClone];\n\n // Emit event with selected date\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n } else if (this.mode === \"range\") {\n // Range mode: Select a range of dates\n const selectedDates = [...this.selectedDate];\n\n if (selectedDates.length === 0 || selectedDates.length === 2) {\n // No dates selected yet or both dates already selected,\n // start a new range by clearing the selected dates array\n selectedDates.length = 0;\n }\n\n // Add the selected date to the range\n selectedDates.push(displayDateClone);\n\n // Update the selectedDate property\n this.selectedDate = selectedDates;\n\n // Emit event with the range of selected dates\n this.emit(\"sgds-selectdates\", { detail: this.selectedDate });\n }\n\n // Check if the selected date is before minDate or after maxDate\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n\n const selectedDate = setTimeToNoon(displayDateClone);\n if ((minimumDate && selectedDate < minimumDate) || (maximumDate && selectedDate > maximumDate)) {\n event.stopPropagation();\n event.preventDefault();\n }\n }\n\n private _onClickMonth(month: number, year: number = this.focusedDate.getFullYear()) {\n const displayDateClone = new Date(this.displayDate);\n this.view = \"days\";\n displayDateClone.setMonth(month);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.emit(\"sgds-view\", { detail: this.view });\n //once clicked, should change view to days, and hold value and change view\n this.emit(\"sgds-selectmonth\", { detail: this.displayDate });\n }\n\n private _onClickYear(year: number) {\n const displayDateClone = new Date(this.displayDate);\n displayDateClone.setFullYear(year);\n this.displayDate = displayDateClone;\n this.view = \"months\";\n this.emit(\"sgds-view\", { detail: this.view });\n\n this.emit(\"sgds-selectyear\", { detail: this.displayDate });\n }\n\n private _getFocusedTarget(): HTMLElement {\n const queryObj = {\n days: `td[data-date=\"${this.focusedDate.toISOString()}\"]`,\n months: `button[data-month=\"${this.focusedDate.getMonth()}\"][data-year=\"${this.focusedDate.getFullYear()}\"]`,\n years: `button[data-year=\"${this.focusedDate.getFullYear()}\"]`\n };\n const queryString = queryObj[this.view];\n const targetEl: HTMLElement = this.shadowRoot.querySelector(`${queryString}`);\n return targetEl;\n }\n private _blurCalendarCell() {\n const targetEl = this._getFocusedTarget();\n targetEl.setAttribute(\"tabindex\", \"-1\");\n targetEl.blur();\n }\n private _focusOnCalendarCell() {\n const targetEl = this._getFocusedTarget();\n if (targetEl) {\n targetEl.setAttribute(\"tabindex\", \"3\");\n targetEl.focus();\n this.emit(\"sgds-update-focus\", { detail: this.focusedDate });\n } else {\n /** Change month view */\n this.emit(\"sgds-change-calendar\", { detail: this.focusedDate });\n }\n }\n private _generateDays() {\n const selectedDates = this.selectedDate.map(d => setTimeToNoon(d));\n\n const rangeSelectedDates = this._generateIncrementDates();\n\n const minimumDate = this.minDate ? setTimeToNoon(new Date(this.minDate)) : null;\n const maximumDate = this.maxDate ? setTimeToNoon(new Date(this.maxDate)) : null;\n const year = this.displayDate.getFullYear();\n const month = this.displayDate.getMonth();\n const firstDateOfMonth = new Date(year, month, 1);\n const startingDayOfMonth = firstDateOfMonth.getDay();\n let monthLength = DatepickerCalendar.daysInMonth[month];\n if (month === 1) {\n if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {\n monthLength = 29;\n }\n }\n\n const weeks = [];\n let day = 1;\n for (let i = 0; i < 9; i++) {\n const week = [];\n for (let j = 0; j <= 6; j++) {\n if (day <= monthLength && (i > 0 || j >= startingDayOfMonth)) {\n const date = new Date(year, month, day, 12, 0, 0, 0).toISOString();\n const beforeMinDate = minimumDate && Date.parse(date) < Date.parse(minimumDate.toISOString());\n const afterMinDate = maximumDate && Date.parse(date) > Date.parse(maximumDate.toISOString());\n const clickHandler = beforeMinDate || afterMinDate ? undefined : this._onClickDay;\n\n const isCurrentMonth = TODAY_DATE.getMonth() === this.displayDate.getMonth();\n const isCurrentYear = TODAY_DATE.getFullYear() === this.displayDate.getFullYear();\n const isCurrentDay = TODAY_DATE.getDate() === day;\n\n const isSelected =\n selectedDates.length > 0 && rangeSelectedDates.some(d => Date.parse(date) === Date.parse(d.toISOString()));\n const isFirstSelectedDate = selectedDates.length > 0 && rangeSelectedDates[0].toISOString() === date;\n const isLastSelectedDate =\n selectedDates.length > 1 && rangeSelectedDates[rangeSelectedDates.length - 1].toISOString() === date;\n\n week.push(\n html`<td\n key=${j}\n data-date=${date}\n data-day=${day}\n class=${classMap({\n today: isCurrentDay && isCurrentMonth && isCurrentYear,\n \"selected-ends\": isFirstSelectedDate || isLastSelectedDate,\n active: isSelected,\n disabled: beforeMinDate || afterMinDate\n })}\n @click=${clickHandler}\n tabindex=${this.focusedDate === new Date(date) ? \"3\" : \"-1\"}\n ?disabled=${beforeMinDate || afterMinDate}\n >\n ${day}\n </td>`\n );\n day++;\n } else {\n week.push(html`<td key=${j}></td>`);\n }\n }\n\n weeks.push(\n html`<tr key=${i}>\n ${week}\n </tr>`\n );\n if (day > monthLength) {\n break;\n }\n }\n\n const dayView = html`\n <table class=\"text-center\">\n <thead>\n <tr>\n ${DatepickerCalendar.DAY_LABELS.map(\n (label: string, index: number) =>\n html`\n <th key=${index}>\n <small>${label}</small>\n </th>\n `\n )}\n </tr>\n </thead>\n <tbody>\n ${weeks}\n </tbody>\n </table>\n `;\n return dayView;\n }\n\n private _generateMonths() {\n const rangeDates = this._generateIncrementDates();\n const selectedTime = rangeDates.map(e => setTimeToNoon(new Date(e.getFullYear(), e.getMonth())).getTime());\n\n const year = this.displayDate.getFullYear();\n\n const monthView = html`\n <div class=\"sgds monthpicker\">\n ${DatepickerCalendar.MONTHVIEW_LABELS.map((m, idx) => {\n const isCurrentMonth = idx === TODAY_DATE.getMonth() && year === TODAY_DATE.getFullYear();\n const time = setTimeToNoon(new Date(year, idx)).getTime();\n const isFirstSelectedMonth = rangeDates[0].getMonth() === idx;\n const isFirstSelectedYear = rangeDates[0].getFullYear() === year;\n const isLastSelectedMonth = rangeDates[rangeDates.length - 1].getMonth() === idx;\n const isLastSelectedYear = rangeDates[rangeDates.length - 1].getFullYear() === year;\n return html` <button\n class=${classMap({\n active: selectedTime.includes(time),\n today: isCurrentMonth,\n month: true,\n \"selected-ends\":\n (isFirstSelectedMonth && isFirstSelectedYear) || (isLastSelectedMonth && isLastSelectedYear)\n })}\n @click=${() => this._onClickMonth(idx)}\n data-month=${idx}\n data-year=${year}\n tabindex=\"3\"\n >\n ${m}\n </button>`;\n })}\n </div>\n `;\n return monthView;\n }\n\n private _generateYears() {\n const selectedYears = this._generateIncrementDates().map(e => e.getFullYear());\n const CURRENT_YEAR = TODAY_DATE.getFullYear();\n\n const yearArray = createYearViewArray(this.displayDate, CURRENT_YEAR);\n\n const yearView = html`\n <div class=\"sgds yearpicker\">\n ${yearArray.map(y => {\n const isFirstSelectedYear = selectedYears[0] === y;\n const isLastSectedYear = selectedYears[selectedYears.length - 1] === y;\n return html`\n <button\n class=${classMap({\n active: selectedYears.includes(y),\n year: true,\n today: CURRENT_YEAR === y,\n \"selected-ends\": isFirstSelectedYear || isLastSectedYear\n })}\n @click=${() => this._onClickYear(y)}\n data-year=${y}\n tabindex=\"3\"\n ?disabled=${y < 1900}\n >\n ${y}\n </button>\n `;\n })}\n </div>\n `;\n return yearView;\n }\n render() {\n let viewContent: HTMLTemplateResult;\n\n switch (this.view) {\n case \"days\":\n viewContent = html` ${this._generateDays()} `;\n break;\n case \"months\":\n viewContent = html` ${this._generateMonths()} `;\n break;\n case \"years\":\n viewContent = html` ${this._generateYears()} `;\n break;\n default:\n viewContent = html` ${this._generateDays()} `; // Set a default view\n break;\n }\n\n return html` <div class=\"datepicker-body\">${viewContent}</div> `;\n }\n}\n\nexport default DatepickerCalendar;\n"],"names":["styles"],"mappings":";;;;;;;;;;AAUA,MAAM,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;AAE9B,MAAM,cAAc,GAAG;AACrB,IAAA,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,CAAC;QACR,MAAM,EAAE,CAAC,CAAC;QACV,KAAK,EAAE,CAAC,CAAC;AACV,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,IAAI,EAAE,CAAC;AACP,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,KAAK,EAAE,CAAC;AACT,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,IA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B,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGF,UAAA,CAAA;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAAqC,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAKnE,UAAA,CAAA;AAAX,IAAA,QAAQ,EAAE;AAAgB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGE,UAAA,CAAA;AAA5B,IAAA,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAAe,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAG3C,UAAA,CAAA;AADC,IAAA,QAAQ,EAAE;AACa,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAgCxB,UAAA,CAAA;IADC,KAAK,CAAC,aAAa,CAAC;AAMpB,CAAA,EAAA,kBAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,IAAA,CAAA;;;;"}
|
|
@@ -3,27 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
+
var dateFns = require('date-fns');
|
|
6
7
|
var lit = require('lit');
|
|
7
8
|
var decorators_js = require('lit/decorators.js');
|
|
9
|
+
var classMap_js = require('lit/directives/class-map.js');
|
|
8
10
|
var sgdsElement = require('../../base/sgds-element.cjs.js');
|
|
9
11
|
var time = require('../../utils/time.cjs.js');
|
|
10
12
|
var watch = require('../../utils/watch.cjs.js');
|
|
11
13
|
var datepickerHeader = require('./datepicker-header.cjs2.js');
|
|
12
14
|
|
|
13
|
-
const MONTH_LABELS = [
|
|
14
|
-
"January",
|
|
15
|
-
"February",
|
|
16
|
-
"March",
|
|
17
|
-
"April",
|
|
18
|
-
"May",
|
|
19
|
-
"June",
|
|
20
|
-
"July",
|
|
21
|
-
"August",
|
|
22
|
-
"September",
|
|
23
|
-
"October",
|
|
24
|
-
"November",
|
|
25
|
-
"December"
|
|
26
|
-
];
|
|
27
15
|
class DatepickerHeader extends sgdsElement["default"] {
|
|
28
16
|
constructor() {
|
|
29
17
|
super(...arguments);
|
|
@@ -34,7 +22,6 @@ class DatepickerHeader extends sgdsElement["default"] {
|
|
|
34
22
|
if (this.focusedTabIndex < 3) {
|
|
35
23
|
const buttonToFocus = this.shadowRoot.querySelector(`button[tabindex="${this.focusedTabIndex}"]`);
|
|
36
24
|
buttonToFocus.focus();
|
|
37
|
-
return;
|
|
38
25
|
}
|
|
39
26
|
return;
|
|
40
27
|
}
|
|
@@ -63,7 +50,7 @@ class DatepickerHeader extends sgdsElement["default"] {
|
|
|
63
50
|
const endLimit = displayYear - yearsPosition + 12 - 1;
|
|
64
51
|
return lit.html ` ${startLimit} - ${endLimit} `;
|
|
65
52
|
}
|
|
66
|
-
return lit.html
|
|
53
|
+
return lit.html `${MONTH_LABELS[displayDate.getMonth()]} ${displayDate.getFullYear()}`;
|
|
67
54
|
}
|
|
68
55
|
/** @internal */
|
|
69
56
|
handleClickPrevious() {
|
|
@@ -116,11 +103,27 @@ class DatepickerHeader extends sgdsElement["default"] {
|
|
|
116
103
|
//emit event to render correct view
|
|
117
104
|
this.emit("sgds-change-calendar", { detail: this.displayDate });
|
|
118
105
|
}
|
|
106
|
+
_removeCaret() {
|
|
107
|
+
const displayYear = this.displayDate.getFullYear();
|
|
108
|
+
const displayMonth = this.displayDate.getMonth();
|
|
109
|
+
const displayMonthYear = new Date(displayYear, displayMonth);
|
|
110
|
+
if (this.view === "months") {
|
|
111
|
+
return displayYear <= 1900;
|
|
112
|
+
}
|
|
113
|
+
if (this.view === "years") {
|
|
114
|
+
return displayYear < 1904;
|
|
115
|
+
}
|
|
116
|
+
return dateFns.isEqual(displayMonthYear, new Date(0, 0, 1)) || dateFns.isBefore(displayMonthYear, new Date(0, 0, 1));
|
|
117
|
+
}
|
|
119
118
|
render() {
|
|
120
119
|
return lit.html `
|
|
121
120
|
<div class="datepicker-header dropdown-header" role="heading">
|
|
122
121
|
<div class="text-center d-flex justify-content-between align-items-center">
|
|
123
|
-
<button
|
|
122
|
+
<button
|
|
123
|
+
@click="${this.handleClickPrevious}"
|
|
124
|
+
tabindex="0"
|
|
125
|
+
class="${classMap_js.classMap({ invisible: this._removeCaret() })}"
|
|
126
|
+
>
|
|
124
127
|
<svg
|
|
125
128
|
xmlns="http://www.w3.org/2000/svg"
|
|
126
129
|
width="16"
|
|
@@ -175,7 +178,22 @@ tslib.__decorate([
|
|
|
175
178
|
tslib.__decorate([
|
|
176
179
|
watch.watch("focusedTabIndex", { waitUntilFirstUpdate: true })
|
|
177
180
|
], DatepickerHeader.prototype, "_handleFocusedTabIndexChange", null);
|
|
181
|
+
const MONTH_LABELS = [
|
|
182
|
+
"January",
|
|
183
|
+
"February",
|
|
184
|
+
"March",
|
|
185
|
+
"April",
|
|
186
|
+
"May",
|
|
187
|
+
"June",
|
|
188
|
+
"July",
|
|
189
|
+
"August",
|
|
190
|
+
"September",
|
|
191
|
+
"October",
|
|
192
|
+
"November",
|
|
193
|
+
"December"
|
|
194
|
+
];
|
|
178
195
|
|
|
179
196
|
exports.DatepickerHeader = DatepickerHeader;
|
|
197
|
+
exports.MONTH_LABELS = MONTH_LABELS;
|
|
180
198
|
exports["default"] = DatepickerHeader;
|
|
181
199
|
//# sourceMappingURL=datepicker-header.cjs.js.map
|