ember-power-calendar 1.7.0 → 1.8.1
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/package.json +20 -18
- package/dist/days-utils-9ZHdudOZ.js +0 -167
- package/dist/days-utils-9ZHdudOZ.js.map +0 -1
- package/dist/days-utils-B18Yv-dd.js +0 -168
- package/dist/days-utils-B18Yv-dd.js.map +0 -1
- package/dist/days-utils-B9NerfuG.js +0 -167
- package/dist/days-utils-B9NerfuG.js.map +0 -1
- package/dist/days-utils-BPuOmlHd.js +0 -168
- package/dist/days-utils-BPuOmlHd.js.map +0 -1
- package/dist/days-utils-BW4J6t_T.js +0 -166
- package/dist/days-utils-BW4J6t_T.js.map +0 -1
- package/dist/days-utils-BqkRi8g4.js +0 -166
- package/dist/days-utils-BqkRi8g4.js.map +0 -1
- package/dist/days-utils-BvQTa2u0.js +0 -167
- package/dist/days-utils-BvQTa2u0.js.map +0 -1
- package/dist/days-utils-C4fpdyiI.js +0 -168
- package/dist/days-utils-C4fpdyiI.js.map +0 -1
- package/dist/days-utils-D13uOiMt.js +0 -163
- package/dist/days-utils-D13uOiMt.js.map +0 -1
- package/dist/days-utils-D17Wjt5c.js +0 -166
- package/dist/days-utils-D17Wjt5c.js.map +0 -1
- package/dist/days-utils-D1aF6ZU9.js +0 -168
- package/dist/days-utils-D1aF6ZU9.js.map +0 -1
- package/dist/days-utils-DN7aFB6t.js +0 -168
- package/dist/days-utils-DN7aFB6t.js.map +0 -1
- package/dist/days-utils-DTP-IwuT.js +0 -166
- package/dist/days-utils-DTP-IwuT.js.map +0 -1
- package/dist/days-utils-DX3xRN_X.js +0 -168
- package/dist/days-utils-DX3xRN_X.js.map +0 -1
- package/dist/days-utils-DufXScU2.js +0 -168
- package/dist/days-utils-DufXScU2.js.map +0 -1
- package/dist/days-utils-b4HePqhp.js +0 -168
- package/dist/days-utils-b4HePqhp.js.map +0 -1
- package/dist/days-utils-dWtkrnT8.js +0 -168
- package/dist/days-utils-dWtkrnT8.js.map +0 -1
- package/dist/days-utils-wZXeSi0W.js +0 -166
- package/dist/days-utils-wZXeSi0W.js.map +0 -1
- package/dist/days-utils-yUufVLwW.js +0 -166
- package/dist/days-utils-yUufVLwW.js.map +0 -1
- package/dist/utils-CNYv9_pR.js +0 -23
- package/dist/utils-CNYv9_pR.js.map +0 -1
- package/dist/utils-D-RRxMcK.js +0 -22
- package/dist/utils-D-RRxMcK.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-power-calendar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Powerful and customizable calendar component for Ember",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"author": "Miguel Camba",
|
|
14
|
+
"sass": "./ember-power-calendar.scss",
|
|
15
|
+
"style": "./dist/vendor/ember-power-calendar.css",
|
|
14
16
|
"exports": {
|
|
15
17
|
".": {
|
|
16
18
|
"types": "./declarations/index.d.ts",
|
|
19
|
+
"sass": "./ember-power-calendar.scss",
|
|
17
20
|
"default": "./dist/index.js"
|
|
18
21
|
},
|
|
19
22
|
"./*": {
|
|
@@ -46,21 +49,6 @@
|
|
|
46
49
|
"scss",
|
|
47
50
|
"vendor"
|
|
48
51
|
],
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "rollup --config",
|
|
51
|
-
"format": "prettier . --cache --write",
|
|
52
|
-
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
|
|
53
|
-
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
|
|
54
|
-
"lint:format": "prettier . --cache --check",
|
|
55
|
-
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
56
|
-
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
57
|
-
"lint:js": "eslint . --cache",
|
|
58
|
-
"lint:js:fix": "eslint . --fix",
|
|
59
|
-
"lint:types": "glint",
|
|
60
|
-
"prepack": "rollup --config",
|
|
61
|
-
"start": "rollup --config --watch",
|
|
62
|
-
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
|
|
63
|
-
},
|
|
64
52
|
"dependencies": {
|
|
65
53
|
"@embroider/addon-shim": "^1.10.0",
|
|
66
54
|
"decorator-transforms": "^2.3.0",
|
|
@@ -69,7 +57,7 @@
|
|
|
69
57
|
"ember-assign-helper": "^0.5.1",
|
|
70
58
|
"ember-element-helper": "^0.8.7",
|
|
71
59
|
"ember-modifier": "^4.2.0",
|
|
72
|
-
"ember-truth-helpers": "^4.0.3"
|
|
60
|
+
"ember-truth-helpers": "^4.0.3 || ^5.0.0"
|
|
73
61
|
},
|
|
74
62
|
"devDependencies": {
|
|
75
63
|
"@babel/core": "^7.27.1",
|
|
@@ -134,5 +122,19 @@
|
|
|
134
122
|
"./services/power-calendar.js": "./dist/_app_/services/power-calendar.js",
|
|
135
123
|
"./test-support/helpers.js": "./dist/_app_/test-support/helpers.js"
|
|
136
124
|
}
|
|
125
|
+
},
|
|
126
|
+
"scripts": {
|
|
127
|
+
"build": "rollup --config",
|
|
128
|
+
"format": "prettier . --cache --write",
|
|
129
|
+
"lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\" --prefixColors auto",
|
|
130
|
+
"lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\" --prefixColors auto && pnpm run format",
|
|
131
|
+
"lint:format": "prettier . --cache --check",
|
|
132
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
133
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
134
|
+
"lint:js": "eslint . --cache",
|
|
135
|
+
"lint:js:fix": "eslint . --fix",
|
|
136
|
+
"lint:types": "glint",
|
|
137
|
+
"start": "rollup --config --watch",
|
|
138
|
+
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
|
|
137
139
|
}
|
|
138
|
-
}
|
|
140
|
+
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import * as s from '@ember/service';
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
import { localeStartOfWeek, endOf, endOfWeek, startOf, startOfWeek, formatDate, normalizeCalendarDay, isSame, isBefore, isAfter } from './utils.js';
|
|
4
|
-
|
|
5
|
-
var service = s.service ?? s.inject;
|
|
6
|
-
|
|
7
|
-
const WEEK_DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
8
|
-
function localeStartOfWeekOrFallback(startOfWeek, locale) {
|
|
9
|
-
if (startOfWeek) {
|
|
10
|
-
return parseInt(startOfWeek, 10);
|
|
11
|
-
}
|
|
12
|
-
return localeStartOfWeek(locale);
|
|
13
|
-
}
|
|
14
|
-
function weekdaysNames(localeStartOfWeek, weekdayFormat, weekdays, weekdaysMin, weekdaysShort) {
|
|
15
|
-
let weekdaysNames;
|
|
16
|
-
if (weekdayFormat === 'long') {
|
|
17
|
-
weekdaysNames = weekdays;
|
|
18
|
-
} else if (weekdayFormat === 'min') {
|
|
19
|
-
weekdaysNames = weekdaysMin;
|
|
20
|
-
} else {
|
|
21
|
-
weekdaysNames = weekdaysShort;
|
|
22
|
-
}
|
|
23
|
-
return weekdaysNames.slice(localeStartOfWeek).concat(weekdaysNames.slice(0, localeStartOfWeek));
|
|
24
|
-
}
|
|
25
|
-
function firstDay(currentCenter, localeStartOfWeek) {
|
|
26
|
-
const firstDay = startOf(currentCenter, 'month');
|
|
27
|
-
return startOfWeek(firstDay, localeStartOfWeek);
|
|
28
|
-
}
|
|
29
|
-
function weeks(days, showDaysAround) {
|
|
30
|
-
const weeks = [];
|
|
31
|
-
let i = 0;
|
|
32
|
-
while (days[i]) {
|
|
33
|
-
let daysOfWeek = days.slice(i, i + 7);
|
|
34
|
-
if (!showDaysAround) {
|
|
35
|
-
daysOfWeek = daysOfWeek.filter(d => d.isCurrentMonth);
|
|
36
|
-
}
|
|
37
|
-
weeks.push({
|
|
38
|
-
id: `week-of-${daysOfWeek[0]?.id}`,
|
|
39
|
-
days: daysOfWeek,
|
|
40
|
-
missingDays: 7 - daysOfWeek.length
|
|
41
|
-
});
|
|
42
|
-
i += 7;
|
|
43
|
-
}
|
|
44
|
-
return weeks;
|
|
45
|
-
}
|
|
46
|
-
function handleDayKeyDown(e, focusedId, days) {
|
|
47
|
-
if (!focusedId) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
let day, index;
|
|
51
|
-
for (let i = 0; i < days.length; i++) {
|
|
52
|
-
if (days[i]?.id === focusedId) {
|
|
53
|
-
index = i;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (index === undefined) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (e.key === 'ArrowUp') {
|
|
61
|
-
e.preventDefault();
|
|
62
|
-
const newIndex = index - 7;
|
|
63
|
-
day = days[newIndex];
|
|
64
|
-
if (day?.isDisabled) {
|
|
65
|
-
for (let i = newIndex + 1; i <= index; i++) {
|
|
66
|
-
day = days[i];
|
|
67
|
-
if (!day?.isDisabled) {
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
} else if (e.key === 'ArrowDown') {
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
const newIndex = index + 7;
|
|
75
|
-
day = days[newIndex];
|
|
76
|
-
if (day?.isDisabled) {
|
|
77
|
-
for (let i = newIndex - 1; i >= index; i--) {
|
|
78
|
-
day = days[i];
|
|
79
|
-
if (!day?.isDisabled) {
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} else if (e.key === 'ArrowLeft') {
|
|
85
|
-
day = days[index - 1];
|
|
86
|
-
if (day?.isDisabled) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
} else if (e.key === 'ArrowRight') {
|
|
90
|
-
day = days[index + 1];
|
|
91
|
-
if (day?.isDisabled) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
return day;
|
|
98
|
-
}
|
|
99
|
-
function focusDate(uniqueId, id) {
|
|
100
|
-
const dayElement = document.querySelector(`[data-power-calendar-id="${uniqueId}"] [data-date="${id}"]`);
|
|
101
|
-
if (dayElement) {
|
|
102
|
-
dayElement.focus();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function buildDay(date, today, calendar, focusedId, currentCenter, dayIsSelected, minDate, maxDate, disabledDates, dayIsDisabledExtended) {
|
|
106
|
-
const id = formatDate(date, 'YYYY-MM-DD');
|
|
107
|
-
let isDisabled = false;
|
|
108
|
-
if (typeof dayIsDisabledExtended === 'function') {
|
|
109
|
-
isDisabled = dayIsDisabledExtended(date, calendar, minDate, maxDate, disabledDates);
|
|
110
|
-
} else {
|
|
111
|
-
isDisabled = dayIsDisabled(date, calendar, minDate, maxDate, disabledDates);
|
|
112
|
-
}
|
|
113
|
-
return normalizeCalendarDay({
|
|
114
|
-
id,
|
|
115
|
-
number: date.getDate(),
|
|
116
|
-
date: new Date(date),
|
|
117
|
-
isDisabled: isDisabled,
|
|
118
|
-
isFocused: focusedId === id,
|
|
119
|
-
isCurrentMonth: isSame(date, currentCenter, 'month'),
|
|
120
|
-
isToday: isSame(date, today, 'day'),
|
|
121
|
-
isSelected: dayIsSelected(date, calendar)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function dayIsDisabled(date, calendar, minDate, maxDate, disabledDates) {
|
|
125
|
-
const isDisabled = !calendar.actions.select;
|
|
126
|
-
if (isDisabled) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
if (minDate && isBefore(date, startOf(minDate, 'day'))) {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
if (maxDate && isAfter(date, endOf(maxDate, 'day'))) {
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
if (disabledDates) {
|
|
136
|
-
const disabledInRange = disabledDates.some(d => {
|
|
137
|
-
const isSameDay = isSame(date, d, 'day');
|
|
138
|
-
const isWeekDayIncludes = WEEK_DAYS.indexOf(d) !== -1 && formatDate(date, 'ddd') === d;
|
|
139
|
-
return isSameDay || isWeekDayIncludes;
|
|
140
|
-
});
|
|
141
|
-
if (disabledInRange) {
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
function lastDay(localeStartOfWeek, currentCenter) {
|
|
148
|
-
assert('The center of the calendar is an invalid date.', !isNaN(currentCenter.getTime()));
|
|
149
|
-
const lastDay = endOf(currentCenter, 'month');
|
|
150
|
-
return endOfWeek(lastDay, localeStartOfWeek);
|
|
151
|
-
}
|
|
152
|
-
function handleClick(e, days, calendar) {
|
|
153
|
-
const dayEl = e.target?.closest('[data-date]');
|
|
154
|
-
if (dayEl) {
|
|
155
|
-
const dateStr = dayEl.dataset['date'];
|
|
156
|
-
const day = days.find(d => d.id === dateStr);
|
|
157
|
-
if (day) {
|
|
158
|
-
if (calendar.actions.select) {
|
|
159
|
-
calendar.actions.select(day, calendar, e);
|
|
160
|
-
}
|
|
161
|
-
return day;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export { lastDay as a, buildDay as b, weeks as c, dayIsDisabled as d, focusDate as e, firstDay as f, handleClick as g, handleDayKeyDown as h, localeStartOfWeekOrFallback as l, service as s, weekdaysNames as w };
|
|
167
|
-
//# sourceMappingURL=days-utils-9ZHdudOZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"days-utils-9ZHdudOZ.js","sources":["../src/-private/service.ts","../src/-private/days-utils.ts"],"sourcesContent":["import * as s from '@ember/service';\n\nexport default s.service ?? s.inject;\n","import { assert } from '@ember/debug';\nimport type { CalendarAPI } from '../components/power-calendar.ts';\nimport {\n endOf,\n endOfWeek,\n formatDate,\n isAfter,\n isBefore,\n isSame,\n localeStartOfWeek,\n normalizeCalendarDay,\n startOf,\n startOfWeek,\n type PowerCalendarDay,\n} from '../utils.ts';\n\nexport const WEEK_DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];\nexport type TWeekdayFormat = 'min' | 'short' | 'long';\n\nexport interface Week {\n id: string;\n days: PowerCalendarDay[];\n missingDays: number;\n}\n\nexport function localeStartOfWeekOrFallback(\n startOfWeek: string | undefined,\n locale: string,\n): number {\n if (startOfWeek) {\n return parseInt(startOfWeek, 10);\n }\n return localeStartOfWeek(locale);\n}\n\nexport function weekdaysNames(\n localeStartOfWeek: number,\n weekdayFormat: TWeekdayFormat,\n weekdays: string[],\n weekdaysMin: string[],\n weekdaysShort: string[],\n): string[] {\n let weekdaysNames;\n if (weekdayFormat === 'long') {\n weekdaysNames = weekdays;\n } else if (weekdayFormat === 'min') {\n weekdaysNames = weekdaysMin;\n } else {\n weekdaysNames = weekdaysShort;\n }\n return weekdaysNames\n .slice(localeStartOfWeek)\n .concat(weekdaysNames.slice(0, localeStartOfWeek));\n}\n\nexport function firstDay(currentCenter: Date, localeStartOfWeek: number): Date {\n const firstDay = startOf(currentCenter, 'month');\n return startOfWeek(firstDay, localeStartOfWeek);\n}\n\nexport function weeks(\n days: PowerCalendarDay[],\n showDaysAround: boolean,\n): Week[] {\n const weeks: Week[] = [];\n let i = 0;\n while (days[i]) {\n let daysOfWeek = days.slice(i, i + 7);\n if (!showDaysAround) {\n daysOfWeek = daysOfWeek.filter((d) => d.isCurrentMonth);\n }\n weeks.push({\n id: `week-of-${daysOfWeek[0]?.id}`,\n days: daysOfWeek,\n missingDays: 7 - daysOfWeek.length,\n });\n i += 7;\n }\n return weeks;\n}\n\nexport function handleDayKeyDown(\n e: KeyboardEvent,\n focusedId: string | null,\n days: PowerCalendarDay[],\n): PowerCalendarDay | undefined {\n if (!focusedId) {\n return;\n }\n let day, index: number | undefined;\n for (let i = 0; i < days.length; i++) {\n if (days[i]?.id === focusedId) {\n index = i;\n break;\n }\n }\n\n if (index === undefined) {\n return;\n }\n\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n const newIndex = index - 7;\n day = days[newIndex];\n if (day?.isDisabled) {\n for (let i = newIndex + 1; i <= index; i++) {\n day = days[i];\n if (!day?.isDisabled) {\n break;\n }\n }\n }\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n const newIndex = index + 7;\n day = days[newIndex];\n if (day?.isDisabled) {\n for (let i = newIndex - 1; i >= index; i--) {\n day = days[i];\n if (!day?.isDisabled) {\n break;\n }\n }\n }\n } else if (e.key === 'ArrowLeft') {\n day = days[index - 1];\n if (day?.isDisabled) {\n return;\n }\n } else if (e.key === 'ArrowRight') {\n day = days[index + 1];\n if (day?.isDisabled) {\n return;\n }\n } else {\n return;\n }\n\n return day;\n}\n\nexport function focusDate(uniqueId: string, id: string): void {\n const dayElement: HTMLElement | null = document.querySelector(\n `[data-power-calendar-id=\"${uniqueId}\"] [data-date=\"${id}\"]`,\n );\n if (dayElement) {\n dayElement.focus();\n }\n}\n\nexport function buildDay(\n date: Date,\n today: Date,\n calendar: CalendarAPI,\n focusedId: string | null,\n currentCenter: Date,\n dayIsSelected: (date: Date, calendar: CalendarAPI) => boolean,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n dayIsDisabledExtended?: (\n date: Date,\n calendar: CalendarAPI,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n ) => boolean,\n): PowerCalendarDay {\n const id = formatDate(date, 'YYYY-MM-DD');\n\n let isDisabled = false;\n if (typeof dayIsDisabledExtended === 'function') {\n isDisabled = dayIsDisabledExtended(\n date,\n calendar,\n minDate,\n maxDate,\n disabledDates,\n );\n } else {\n isDisabled = dayIsDisabled(date, calendar, minDate, maxDate, disabledDates);\n }\n\n return normalizeCalendarDay({\n id,\n number: date.getDate(),\n date: new Date(date),\n isDisabled: isDisabled,\n isFocused: focusedId === id,\n isCurrentMonth: isSame(date, currentCenter, 'month'),\n isToday: isSame(date, today, 'day'),\n isSelected: dayIsSelected(date, calendar),\n } as PowerCalendarDay);\n}\n\nexport function dayIsDisabled(\n date: Date,\n calendar: CalendarAPI,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n): boolean {\n const isDisabled = !calendar.actions.select;\n if (isDisabled) {\n return true;\n }\n\n if (minDate && isBefore(date, startOf(minDate, 'day'))) {\n return true;\n }\n\n if (maxDate && isAfter(date, endOf(maxDate, 'day'))) {\n return true;\n }\n\n if (disabledDates) {\n const disabledInRange = disabledDates.some((d) => {\n const isSameDay = isSame(date, d as Date, 'day');\n const isWeekDayIncludes =\n WEEK_DAYS.indexOf(d as string) !== -1 && formatDate(date, 'ddd') === d;\n return isSameDay || isWeekDayIncludes;\n });\n\n if (disabledInRange) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function lastDay(localeStartOfWeek: number, currentCenter: Date): Date {\n assert(\n 'The center of the calendar is an invalid date.',\n !isNaN(currentCenter.getTime()),\n );\n const lastDay = endOf(currentCenter, 'month');\n return endOfWeek(lastDay, localeStartOfWeek);\n}\n\nexport function handleClick(\n e: MouseEvent,\n days: PowerCalendarDay[],\n calendar: CalendarAPI,\n): PowerCalendarDay | undefined {\n const dayEl: HTMLElement | null | undefined = (\n e.target as HTMLElement | null\n )?.closest('[data-date]');\n if (dayEl) {\n const dateStr = dayEl.dataset['date'];\n const day = days.find((d) => d.id === dateStr);\n if (day) {\n if (calendar.actions.select) {\n calendar.actions.select(day, calendar, e);\n }\n\n return day;\n }\n }\n}\n"],"names":["s","service","inject","WEEK_DAYS","localeStartOfWeekOrFallback","startOfWeek","locale","parseInt","localeStartOfWeek","weekdaysNames","weekdayFormat","weekdays","weekdaysMin","weekdaysShort","slice","concat","firstDay","currentCenter","startOf","weeks","days","showDaysAround","i","daysOfWeek","filter","d","isCurrentMonth","push","id","missingDays","length","handleDayKeyDown","e","focusedId","day","index","undefined","key","preventDefault","newIndex","isDisabled","focusDate","uniqueId","dayElement","document","querySelector","focus","buildDay","date","today","calendar","dayIsSelected","minDate","maxDate","disabledDates","dayIsDisabledExtended","formatDate","dayIsDisabled","normalizeCalendarDay","number","getDate","Date","isFocused","isSame","isToday","isSelected","actions","select","isBefore","isAfter","endOf","disabledInRange","some","isSameDay","isWeekDayIncludes","indexOf","lastDay","assert","isNaN","getTime","endOfWeek","handleClick","dayEl","target","closest","dateStr","dataset","find"],"mappings":";;;;AAEA,cAAeA,CAAC,CAACC,OAAO,IAAID,CAAC,CAACE,MAAM;;ACc7B,MAAMC,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;AASnE,SAASC,2BAA2BA,CACzCC,WAA+B,EAC/BC,MAAc,EACN;AACR,EAAA,IAAID,WAAW,EAAE;AACf,IAAA,OAAOE,QAAQ,CAACF,WAAW,EAAE,EAAE,CAAC;AAClC;EACA,OAAOG,iBAAiB,CAACF,MAAM,CAAC;AAClC;AAEO,SAASG,aAAaA,CAC3BD,iBAAyB,EACzBE,aAA6B,EAC7BC,QAAkB,EAClBC,WAAqB,EACrBC,aAAuB,EACb;AACV,EAAA,IAAIJ,aAAa;EACjB,IAAIC,aAAa,KAAK,MAAM,EAAE;AAC5BD,IAAAA,aAAa,GAAGE,QAAQ;AAC1B,GAAC,MAAM,IAAID,aAAa,KAAK,KAAK,EAAE;AAClCD,IAAAA,aAAa,GAAGG,WAAW;AAC7B,GAAC,MAAM;AACLH,IAAAA,aAAa,GAAGI,aAAa;AAC/B;AACA,EAAA,OAAOJ,aAAa,CACjBK,KAAK,CAACN,iBAAiB,CAAC,CACxBO,MAAM,CAACN,aA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AAI;AACb;AACF;AAEA,EAAA,OAAO,KAAK;AACd;AAEO,SAASK,OAAOA,CAACpE,iBAAyB,EAAES,aAAmB,EAAQ;AAC5E4D,EAAAA,MAAM,CACJ,gDAAgD,EAChD,CAACC,KAAK,CAAC7D,aAAa,CAAC8D,OAAO,EAAE,CAChC,CAAC;AACD,EAAA,MAAMH,OAAO,GAAGN,KAAK,CAACrD,aAAa,EAAE,OAAO,CAAC;AAC7C,EAAA,OAAO+D,SAAS,CAACJ,OAAO,EAAEpE,iBAAiB,CAAC;AAC9C;AAEO,SAASyE,WAAWA,CACzBjD,CAAa,EACbZ,IAAwB,EACxB8B,QAAqB,EACS;EAC9B,MAAMgC,KAAqC,GACzClD,CAAC,CAACmD,MAAM,EACPC,OAAO,CAAC,aAAa,CAAC;AACzB,EAAA,IAAIF,KAAK,EAAE;AACT,IAAA,MAAMG,OAAO,GAAGH,KAAK,CAACI,OAAO,CAAC,MAAM,CAAC;AACrC,IAAA,MAAMpD,GAAG,GAAGd,IAAI,CAACmE,IAAI,CAAE9D,CAAC,IAAKA,CAAC,CAACG,EAAE,KAAKyD,OAAO,CAAC;AAC9C,IAAA,IAAInD,GAAG,EAAE;AACP,MAAA,IAAIgB,QAAQ,CAACgB,OAAO,CAACC,MAAM,EAAE;QAC3BjB,QAAQ,CAACgB,OAAO,CAACC,MAAM,CAACjC,GAAG,EAAEgB,QAAQ,EAAElB,CAAC,CAAC;AAC3C;AAEA,MAAA,OAAOE,GAAG;AACZ;AACF;AACF;;;;"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import * as s from '@ember/service';
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
import { localeStartOfWeek, endOf, endOfWeek, startOf, startOfWeek, formatDate, normalizeCalendarDay, isSame, isBefore, isAfter } from './utils.js';
|
|
4
|
-
|
|
5
|
-
var service = s.service ?? s.inject;
|
|
6
|
-
|
|
7
|
-
const WEEK_DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
8
|
-
function localeStartOfWeekOrFallback(startOfWeek, locale) {
|
|
9
|
-
if (startOfWeek) {
|
|
10
|
-
return parseInt(startOfWeek, 10);
|
|
11
|
-
}
|
|
12
|
-
return localeStartOfWeek(locale);
|
|
13
|
-
}
|
|
14
|
-
function weekdaysNames(localeStartOfWeek, weekdayFormat, weekdays, weekdaysMin, weekdaysShort) {
|
|
15
|
-
let weekdaysNames;
|
|
16
|
-
if (weekdayFormat === 'long') {
|
|
17
|
-
weekdaysNames = weekdays;
|
|
18
|
-
} else if (weekdayFormat === 'min') {
|
|
19
|
-
weekdaysNames = weekdaysMin;
|
|
20
|
-
} else {
|
|
21
|
-
weekdaysNames = weekdaysShort;
|
|
22
|
-
}
|
|
23
|
-
return weekdaysNames.slice(localeStartOfWeek).concat(weekdaysNames.slice(0, localeStartOfWeek));
|
|
24
|
-
}
|
|
25
|
-
function firstDay(currentCenter, localeStartOfWeek) {
|
|
26
|
-
const firstDay = startOf(currentCenter, 'month');
|
|
27
|
-
return startOfWeek(firstDay, localeStartOfWeek);
|
|
28
|
-
}
|
|
29
|
-
function weeks(days, showDaysAround) {
|
|
30
|
-
const weeks = [];
|
|
31
|
-
let i = 0;
|
|
32
|
-
while (days[i]) {
|
|
33
|
-
let daysOfWeek = days.slice(i, i + 7);
|
|
34
|
-
if (!showDaysAround) {
|
|
35
|
-
daysOfWeek = daysOfWeek.filter(d => d.isCurrentMonth);
|
|
36
|
-
}
|
|
37
|
-
weeks.push({
|
|
38
|
-
id: `week-of-${daysOfWeek[0]?.id}`,
|
|
39
|
-
days: daysOfWeek,
|
|
40
|
-
missingDays: 7 - daysOfWeek.length
|
|
41
|
-
});
|
|
42
|
-
i += 7;
|
|
43
|
-
}
|
|
44
|
-
return weeks;
|
|
45
|
-
}
|
|
46
|
-
function handleDayKeyDown(e, focusedId, days) {
|
|
47
|
-
if (!focusedId) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
let day, index;
|
|
51
|
-
for (let i = 0; i < days.length; i++) {
|
|
52
|
-
if (days[i]?.id === focusedId) {
|
|
53
|
-
index = i;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
console.log(index, focusedId, e.key);
|
|
58
|
-
if (!index) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (e.key === 'ArrowUp') {
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
const newIndex = index - 7;
|
|
64
|
-
day = days[newIndex];
|
|
65
|
-
if (day?.isDisabled) {
|
|
66
|
-
for (let i = newIndex + 1; i <= index; i++) {
|
|
67
|
-
day = days[i];
|
|
68
|
-
if (!day?.isDisabled) {
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} else if (e.key === 'ArrowDown') {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
const newIndex = index + 7;
|
|
76
|
-
day = days[newIndex];
|
|
77
|
-
if (day?.isDisabled) {
|
|
78
|
-
for (let i = newIndex - 1; i >= index; i--) {
|
|
79
|
-
day = days[i];
|
|
80
|
-
if (!day?.isDisabled) {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else if (e.key === 'ArrowLeft') {
|
|
86
|
-
day = days[index - 1];
|
|
87
|
-
if (day?.isDisabled) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
} else if (e.key === 'ArrowRight') {
|
|
91
|
-
day = days[index + 1];
|
|
92
|
-
console.log('ArrowRight', day, index);
|
|
93
|
-
if (day?.isDisabled) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
return day;
|
|
100
|
-
}
|
|
101
|
-
function focusDate(uniqueId, id) {
|
|
102
|
-
const dayElement = document.querySelector(`[data-power-calendar-id="${uniqueId}"] [data-date="${id}"]`);
|
|
103
|
-
if (dayElement) {
|
|
104
|
-
dayElement.focus();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function buildDay(date, today, calendar, focusedId, currentCenter, dayIsSelected, minDate, maxDate, disabledDates, dayIsDisabledExtended) {
|
|
108
|
-
const id = formatDate(date, 'YYYY-MM-DD');
|
|
109
|
-
let isDisabled = false;
|
|
110
|
-
if (typeof dayIsDisabledExtended === 'function') {
|
|
111
|
-
isDisabled = dayIsDisabledExtended(date, calendar, minDate, maxDate, disabledDates);
|
|
112
|
-
} else {
|
|
113
|
-
isDisabled = dayIsDisabled(date, calendar, minDate, maxDate, disabledDates);
|
|
114
|
-
}
|
|
115
|
-
return normalizeCalendarDay({
|
|
116
|
-
id,
|
|
117
|
-
number: date.getDate(),
|
|
118
|
-
date: new Date(date),
|
|
119
|
-
isDisabled: isDisabled,
|
|
120
|
-
isFocused: focusedId === id,
|
|
121
|
-
isCurrentMonth: isSame(date, currentCenter, 'month'),
|
|
122
|
-
isToday: isSame(date, today, 'day'),
|
|
123
|
-
isSelected: dayIsSelected(date, calendar)
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function dayIsDisabled(date, calendar, minDate, maxDate, disabledDates) {
|
|
127
|
-
const isDisabled = !calendar.actions.select;
|
|
128
|
-
if (isDisabled) {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
if (minDate && isBefore(date, startOf(minDate, 'day'))) {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
if (maxDate && isAfter(date, endOf(maxDate, 'day'))) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
if (disabledDates) {
|
|
138
|
-
const disabledInRange = disabledDates.some(d => {
|
|
139
|
-
const isSameDay = isSame(date, d, 'day');
|
|
140
|
-
const isWeekDayIncludes = WEEK_DAYS.indexOf(d) !== -1 && formatDate(date, 'ddd') === d;
|
|
141
|
-
return isSameDay || isWeekDayIncludes;
|
|
142
|
-
});
|
|
143
|
-
if (disabledInRange) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
function lastDay(localeStartOfWeek, currentCenter) {
|
|
150
|
-
assert('The center of the calendar is an invalid date.', !isNaN(currentCenter.getTime()));
|
|
151
|
-
const lastDay = endOf(currentCenter, 'month');
|
|
152
|
-
return endOfWeek(lastDay, localeStartOfWeek);
|
|
153
|
-
}
|
|
154
|
-
function handleClick(e, days, calendar) {
|
|
155
|
-
const dayEl = e.target?.closest('[data-date]');
|
|
156
|
-
if (dayEl) {
|
|
157
|
-
const dateStr = dayEl.dataset['date'];
|
|
158
|
-
const day = days.find(d => d.id === dateStr);
|
|
159
|
-
if (day) {
|
|
160
|
-
if (calendar.actions.select) {
|
|
161
|
-
calendar.actions.select(day, calendar, e);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export { lastDay as a, buildDay as b, weeks as c, focusDate as d, handleClick as e, firstDay as f, dayIsDisabled as g, handleDayKeyDown as h, localeStartOfWeekOrFallback as l, service as s, weekdaysNames as w };
|
|
168
|
-
//# sourceMappingURL=days-utils-B18Yv-dd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"days-utils-B18Yv-dd.js","sources":["../src/-private/service.ts","../src/-private/days-utils.ts"],"sourcesContent":["import * as s from '@ember/service';\n\nexport default s.service ?? s.inject;\n","import { assert } from '@ember/debug';\nimport type { CalendarAPI } from '../components/power-calendar.ts';\nimport {\n endOf,\n endOfWeek,\n formatDate,\n isAfter,\n isBefore,\n isSame,\n localeStartOfWeek,\n normalizeCalendarDay,\n startOf,\n startOfWeek,\n type PowerCalendarDay,\n} from '../utils.ts';\n\nexport const WEEK_DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];\nexport type TWeekdayFormat = 'min' | 'short' | 'long';\n\nexport interface Week {\n id: string;\n days: PowerCalendarDay[];\n missingDays: number;\n}\n\nexport function localeStartOfWeekOrFallback(\n startOfWeek: string | undefined,\n locale: string,\n): number {\n if (startOfWeek) {\n return parseInt(startOfWeek, 10);\n }\n return localeStartOfWeek(locale);\n}\n\nexport function weekdaysNames(\n localeStartOfWeek: number,\n weekdayFormat: TWeekdayFormat,\n weekdays: string[],\n weekdaysMin: string[],\n weekdaysShort: string[],\n): string[] {\n let weekdaysNames;\n if (weekdayFormat === 'long') {\n weekdaysNames = weekdays;\n } else if (weekdayFormat === 'min') {\n weekdaysNames = weekdaysMin;\n } else {\n weekdaysNames = weekdaysShort;\n }\n return weekdaysNames\n .slice(localeStartOfWeek)\n .concat(weekdaysNames.slice(0, localeStartOfWeek));\n}\n\nexport function firstDay(currentCenter: Date, localeStartOfWeek: number): Date {\n const firstDay = startOf(currentCenter, 'month');\n return startOfWeek(firstDay, localeStartOfWeek);\n}\n\nexport function weeks(\n days: PowerCalendarDay[],\n showDaysAround: boolean,\n): Week[] {\n const weeks: Week[] = [];\n let i = 0;\n while (days[i]) {\n let daysOfWeek = days.slice(i, i + 7);\n if (!showDaysAround) {\n daysOfWeek = daysOfWeek.filter((d) => d.isCurrentMonth);\n }\n weeks.push({\n id: `week-of-${daysOfWeek[0]?.id}`,\n days: daysOfWeek,\n missingDays: 7 - daysOfWeek.length,\n });\n i += 7;\n }\n return weeks;\n}\n\nexport function handleDayKeyDown(\n e: KeyboardEvent,\n focusedId: string | null,\n days: PowerCalendarDay[],\n): PowerCalendarDay | undefined {\n if (!focusedId) {\n return;\n }\n let day, index: number | undefined;\n for (let i = 0; i < days.length; i++) {\n if (days[i]?.id === focusedId) {\n index = i;\n break;\n }\n }\n\n console.log(index, focusedId, e.key);\n\n if (!index) {\n return;\n }\n\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n const newIndex = index - 7;\n day = days[newIndex];\n if (day?.isDisabled) {\n for (let i = newIndex + 1; i <= index; i++) {\n day = days[i];\n if (!day?.isDisabled) {\n break;\n }\n }\n }\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n const newIndex = index + 7;\n day = days[newIndex];\n if (day?.isDisabled) {\n for (let i = newIndex - 1; i >= index; i--) {\n day = days[i];\n if (!day?.isDisabled) {\n break;\n }\n }\n }\n } else if (e.key === 'ArrowLeft') {\n day = days[index - 1];\n if (day?.isDisabled) {\n return;\n }\n } else if (e.key === 'ArrowRight') {\n day = days[index + 1];\n console.log('ArrowRight', day, index);\n if (day?.isDisabled) {\n return;\n }\n } else {\n return;\n }\n\n return day;\n}\n\nexport function focusDate(uniqueId: string, id: string): void {\n const dayElement: HTMLElement | null = document.querySelector(\n `[data-power-calendar-id=\"${uniqueId}\"] [data-date=\"${id}\"]`,\n );\n if (dayElement) {\n dayElement.focus();\n }\n}\n\nexport function buildDay(\n date: Date,\n today: Date,\n calendar: CalendarAPI,\n focusedId: string | null,\n currentCenter: Date,\n dayIsSelected: (date: Date, calendar: CalendarAPI) => boolean,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n dayIsDisabledExtended?: (\n date: Date,\n calendar: CalendarAPI,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n ) => boolean,\n): PowerCalendarDay {\n const id = formatDate(date, 'YYYY-MM-DD');\n\n let isDisabled = false;\n if (typeof dayIsDisabledExtended === 'function') {\n isDisabled = dayIsDisabledExtended(\n date,\n calendar,\n minDate,\n maxDate,\n disabledDates,\n );\n } else {\n isDisabled = dayIsDisabled(date, calendar, minDate, maxDate, disabledDates);\n }\n\n return normalizeCalendarDay({\n id,\n number: date.getDate(),\n date: new Date(date),\n isDisabled: isDisabled,\n isFocused: focusedId === id,\n isCurrentMonth: isSame(date, currentCenter, 'month'),\n isToday: isSame(date, today, 'day'),\n isSelected: dayIsSelected(date, calendar),\n } as PowerCalendarDay);\n}\n\nexport function dayIsDisabled(\n date: Date,\n calendar: CalendarAPI,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n): boolean {\n const isDisabled = !calendar.actions.select;\n if (isDisabled) {\n return true;\n }\n\n if (minDate && isBefore(date, startOf(minDate, 'day'))) {\n return true;\n }\n\n if (maxDate && isAfter(date, endOf(maxDate, 'day'))) {\n return true;\n }\n\n if (disabledDates) {\n const disabledInRange = disabledDates.some((d) => {\n const isSameDay = isSame(date, d as Date, 'day');\n const isWeekDayIncludes =\n WEEK_DAYS.indexOf(d as string) !== -1 && formatDate(date, 'ddd') === d;\n return isSameDay || isWeekDayIncludes;\n });\n\n if (disabledInRange) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function lastDay(localeStartOfWeek: number, currentCenter: Date): Date {\n assert(\n 'The center of the calendar is an invalid date.',\n !isNaN(currentCenter.getTime()),\n );\n const lastDay = endOf(currentCenter, 'month');\n return endOfWeek(lastDay, localeStartOfWeek);\n}\n\nexport function handleClick(\n e: MouseEvent,\n days: PowerCalendarDay[],\n calendar: CalendarAPI,\n): void {\n const dayEl: HTMLElement | null | undefined = (\n e.target as HTMLElement | null\n )?.closest('[data-date]');\n if (dayEl) {\n const dateStr = dayEl.dataset['date'];\n const day = days.find((d) => d.id === dateStr);\n if (day) {\n if (calendar.actions.select) {\n calendar.actions.select(day, calendar, e);\n }\n }\n }\n}\n"],"names":["s","service","inject","WEEK_DAYS","localeStartOfWeekOrFallback","startOfWeek","locale","parseInt","localeStartOfWeek","weekdaysNames","weekdayFormat","weekdays","weekdaysMin","weekdaysShort","slice","concat","firstDay","currentCenter","startOf","weeks","days","showDaysAround","i","daysOfWeek","filter","d","isCurrentMonth","push","id","missingDays","length","handleDayKeyDown","e","focusedId","day","index","console","log","key","preventDefault","newIndex","isDisabled","focusDate","uniqueId","dayElement","document","querySelector","focus","buildDay","date","today","calendar","dayIsSelected","minDate","maxDate","disabledDates","dayIsDisabledExtended","formatDate","dayIsDisabled","normalizeCalendarDay","number","getDate","Date","isFocused","isSame","isToday","isSelected","actions","select","isBefore","isAfter","endOf","disabledInRange","some","isSameDay","isWeekDayIncludes","indexOf","lastDay","assert","isNaN","getTime","endOfWeek","handleClick","dayEl","target","closest","dateStr","dataset","find"],"mappings":";;;;AAEA,cAAeA,CAAC,CAACC,OAAO,IAAID,CAAC,CAACE,MAAM;;ACc7B,MAAMC,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;AASnE,SAASC,2BAA2BA,CACzCC,WAA+B,EAC/BC,MAAc,EACN;AACR,EAAA,IAAID,WAAW,EAAE;AACf,IAAA,OAAOE,QAAQ,CAACF,WAAW,EAAE,EAAE,CAAC;AAClC;EACA,OAAOG,iBAAiB,CAACF,MAAM,CAAC;AAClC;AAEO,SAASG,aAAaA,CAC3BD,iBAAyB,EACzBE,aAA6B,EAC7BC,QAAkB,EAClBC,WAAqB,EACrBC,aAAuB,EACb;AACV,EAAA,IAAIJ,aAAa;EACjB,IAAIC,aAAa,KAAK,MAAM,EAAE;AAC5BD,IAAAA,aAAa,GAAGE,QAAQ;AAC1B,GAAC,MAAM,IAAID,aAAa,KAAK,KAAK,EAAE;AAClCD,IAAAA,aAAa,GAAGG,WAAW;AAC7B,GAAC,MAAM;AACLH,IAAAA,aAAa,GAAGI,aAAa;AAC/B;AACA,EAAA,OAAOJ,aAAa,CACjBK,KAAK,CAACN,iBAAiB,CAAC,CACxBO,MAAM,CAACN,aAAa,CAACK,KAAK,CAAC,CAAC,EAAEN,iBAAiB,CAAC,CAAC;AACtD;AAEO,SAASQ,QAAQA,CAACC,aAAmB,EAAET,iBAAyB,EAAQ;AAC7E,EAAA,MAAMQ,QAAQ,GAAGE,OAAO,CAACD,aAAa,EAAE,OAAO,CAAC;AAChD,EAAA,OAAOZ,WAAW,CAACW,QAAQ,EAAER,iBAAiB,CAAC;AACjD;AAEO,SAASW,KAAKA,CACnBC,IAAwB,EACxBC,cAAuB,EACf;EACR,MAAMF,KAAa,GAAG,EAAE;EACxB,IAAIG,CAAC,GAAG,CA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AAGN,KAAK,CAACtD,aAAa,EAAE,OAAO,CAAC;AAC7C,EAAA,OAAOgE,SAAS,CAACJ,OAAO,EAAErE,iBAAiB,CAAC;AAC9C;AAEO,SAAS0E,WAAWA,CACzBlD,CAAa,EACbZ,IAAwB,EACxB+B,QAAqB,EACf;EACN,MAAMgC,KAAqC,GACzCnD,CAAC,CAACoD,MAAM,EACPC,OAAO,CAAC,aAAa,CAAC;AACzB,EAAA,IAAIF,KAAK,EAAE;AACT,IAAA,MAAMG,OAAO,GAAGH,KAAK,CAACI,OAAO,CAAC,MAAM,CAAC;AACrC,IAAA,MAAMrD,GAAG,GAAGd,IAAI,CAACoE,IAAI,CAAE/D,CAAC,IAAKA,CAAC,CAACG,EAAE,KAAK0D,OAAO,CAAC;AAC9C,IAAA,IAAIpD,GAAG,EAAE;AACP,MAAA,IAAIiB,QAAQ,CAACgB,OAAO,CAACC,MAAM,EAAE;QAC3BjB,QAAQ,CAACgB,OAAO,CAACC,MAAM,CAAClC,GAAG,EAAEiB,QAAQ,EAAEnB,CAAC,CAAC;AAC3C;AACF;AACF;AACF;;;;"}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import * as s from '@ember/service';
|
|
2
|
-
import { assert } from '@ember/debug';
|
|
3
|
-
import { localeStartOfWeek, endOf, endOfWeek, startOf, startOfWeek, formatDate, normalizeCalendarDay, isSame, isBefore, isAfter } from './utils.js';
|
|
4
|
-
|
|
5
|
-
var service = s.service ?? s.inject;
|
|
6
|
-
|
|
7
|
-
const WEEK_DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
|
8
|
-
function localeStartOfWeekOrFallback(startOfWeek, locale) {
|
|
9
|
-
if (startOfWeek) {
|
|
10
|
-
return parseInt(startOfWeek, 10);
|
|
11
|
-
}
|
|
12
|
-
return localeStartOfWeek(locale);
|
|
13
|
-
}
|
|
14
|
-
function weekdaysNames(localeStartOfWeek, weekdayFormat, weekdays, weekdaysMin, weekdaysShort) {
|
|
15
|
-
let weekdaysNames;
|
|
16
|
-
if (weekdayFormat === 'long') {
|
|
17
|
-
weekdaysNames = weekdays;
|
|
18
|
-
} else if (weekdayFormat === 'min') {
|
|
19
|
-
weekdaysNames = weekdaysMin;
|
|
20
|
-
} else {
|
|
21
|
-
weekdaysNames = weekdaysShort;
|
|
22
|
-
}
|
|
23
|
-
return weekdaysNames.slice(localeStartOfWeek).concat(weekdaysNames.slice(0, localeStartOfWeek));
|
|
24
|
-
}
|
|
25
|
-
function firstDay(currentCenter, localeStartOfWeek) {
|
|
26
|
-
const firstDay = startOf(currentCenter, 'month');
|
|
27
|
-
return startOfWeek(firstDay, localeStartOfWeek);
|
|
28
|
-
}
|
|
29
|
-
function weeks(days, showDaysAround) {
|
|
30
|
-
const weeks = [];
|
|
31
|
-
let i = 0;
|
|
32
|
-
while (days[i]) {
|
|
33
|
-
let daysOfWeek = days.slice(i, i + 7);
|
|
34
|
-
if (!showDaysAround) {
|
|
35
|
-
daysOfWeek = daysOfWeek.filter(d => d.isCurrentMonth);
|
|
36
|
-
}
|
|
37
|
-
weeks.push({
|
|
38
|
-
id: `week-of-${daysOfWeek[0]?.id}`,
|
|
39
|
-
days: daysOfWeek,
|
|
40
|
-
missingDays: 7 - daysOfWeek.length
|
|
41
|
-
});
|
|
42
|
-
i += 7;
|
|
43
|
-
}
|
|
44
|
-
return weeks;
|
|
45
|
-
}
|
|
46
|
-
function handleDayKeyDown(e, focusedId, days) {
|
|
47
|
-
if (!focusedId) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
let day, index;
|
|
51
|
-
for (let i = 0; i < days.length; i++) {
|
|
52
|
-
if (days[i]?.id === focusedId) {
|
|
53
|
-
index = i;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (!index) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (e.key === 'ArrowUp') {
|
|
61
|
-
e.preventDefault();
|
|
62
|
-
console.log(index);
|
|
63
|
-
const newIndex = Math.max(index - 7, 0);
|
|
64
|
-
day = days[newIndex];
|
|
65
|
-
if (day?.isDisabled) {
|
|
66
|
-
for (let i = newIndex + 1; i <= index; i++) {
|
|
67
|
-
day = days[i];
|
|
68
|
-
if (!day?.isDisabled) {
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} else if (e.key === 'ArrowDown') {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
const newIndex = Math.min(index + 7, days.length - 1);
|
|
76
|
-
day = days[newIndex];
|
|
77
|
-
if (day?.isDisabled) {
|
|
78
|
-
for (let i = newIndex - 1; i >= index; i--) {
|
|
79
|
-
day = days[i];
|
|
80
|
-
if (!day?.isDisabled) {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else if (e.key === 'ArrowLeft') {
|
|
86
|
-
day = days[Math.max(index - 1, 0)];
|
|
87
|
-
if (day?.isDisabled) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
} else if (e.key === 'ArrowRight') {
|
|
91
|
-
day = days[Math.min(index + 1, days.length - 1)];
|
|
92
|
-
if (day?.isDisabled) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
return day;
|
|
99
|
-
}
|
|
100
|
-
function focusDate(uniqueId, id) {
|
|
101
|
-
const dayElement = document.querySelector(`[data-power-calendar-id="${uniqueId}"] [data-date="${id}"]`);
|
|
102
|
-
if (dayElement) {
|
|
103
|
-
dayElement.focus();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function buildDay(date, today, calendar, focusedId, currentCenter, dayIsSelected, minDate, maxDate, disabledDates, dayIsDisabledExtended) {
|
|
107
|
-
const id = formatDate(date, 'YYYY-MM-DD');
|
|
108
|
-
let isDisabled = false;
|
|
109
|
-
if (typeof dayIsDisabledExtended === 'function') {
|
|
110
|
-
isDisabled = dayIsDisabledExtended(date, calendar, minDate, maxDate, disabledDates);
|
|
111
|
-
} else {
|
|
112
|
-
isDisabled = dayIsDisabled(date, calendar, minDate, maxDate, disabledDates);
|
|
113
|
-
}
|
|
114
|
-
return normalizeCalendarDay({
|
|
115
|
-
id,
|
|
116
|
-
number: date.getDate(),
|
|
117
|
-
date: new Date(date),
|
|
118
|
-
isDisabled: isDisabled,
|
|
119
|
-
isFocused: focusedId === id,
|
|
120
|
-
isCurrentMonth: isSame(date, currentCenter, 'month'),
|
|
121
|
-
isToday: isSame(date, today, 'day'),
|
|
122
|
-
isSelected: dayIsSelected(date, calendar)
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function dayIsDisabled(date, calendar, minDate, maxDate, disabledDates) {
|
|
126
|
-
const isDisabled = !calendar.actions.select;
|
|
127
|
-
if (isDisabled) {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
if (minDate && isBefore(date, startOf(minDate, 'day'))) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
if (maxDate && isAfter(date, endOf(maxDate, 'day'))) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
if (disabledDates) {
|
|
137
|
-
const disabledInRange = disabledDates.some(d => {
|
|
138
|
-
const isSameDay = isSame(date, d, 'day');
|
|
139
|
-
const isWeekDayIncludes = WEEK_DAYS.indexOf(d) !== -1 && formatDate(date, 'ddd') === d;
|
|
140
|
-
return isSameDay || isWeekDayIncludes;
|
|
141
|
-
});
|
|
142
|
-
if (disabledInRange) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
function lastDay(localeStartOfWeek, currentCenter) {
|
|
149
|
-
assert('The center of the calendar is an invalid date.', !isNaN(currentCenter.getTime()));
|
|
150
|
-
const lastDay = endOf(currentCenter, 'month');
|
|
151
|
-
return endOfWeek(lastDay, localeStartOfWeek);
|
|
152
|
-
}
|
|
153
|
-
function handleClick(e, days, calendar) {
|
|
154
|
-
const dayEl = e.target?.closest('[data-date]');
|
|
155
|
-
if (dayEl) {
|
|
156
|
-
const dateStr = dayEl.dataset['date'];
|
|
157
|
-
const day = days.find(d => d.id === dateStr);
|
|
158
|
-
if (day) {
|
|
159
|
-
if (calendar.actions.select) {
|
|
160
|
-
calendar.actions.select(day, calendar, e);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export { lastDay as a, buildDay as b, weeks as c, focusDate as d, handleClick as e, firstDay as f, dayIsDisabled as g, handleDayKeyDown as h, localeStartOfWeekOrFallback as l, service as s, weekdaysNames as w };
|
|
167
|
-
//# sourceMappingURL=days-utils-B9NerfuG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"days-utils-B9NerfuG.js","sources":["../src/-private/service.ts","../src/-private/days-utils.ts"],"sourcesContent":["import * as s from '@ember/service';\n\nexport default s.service ?? s.inject;\n","import { assert } from '@ember/debug';\nimport type { CalendarAPI } from '../components/power-calendar.ts';\nimport {\n endOf,\n endOfWeek,\n formatDate,\n isAfter,\n isBefore,\n isSame,\n localeStartOfWeek,\n normalizeCalendarDay,\n startOf,\n startOfWeek,\n type PowerCalendarDay,\n} from '../utils.ts';\n\nexport const WEEK_DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];\nexport type TWeekdayFormat = 'min' | 'short' | 'long';\n\nexport interface Week {\n id: string;\n days: PowerCalendarDay[];\n missingDays: number;\n}\n\nexport function localeStartOfWeekOrFallback(\n startOfWeek: string | undefined,\n locale: string,\n): number {\n if (startOfWeek) {\n return parseInt(startOfWeek, 10);\n }\n return localeStartOfWeek(locale);\n}\n\nexport function weekdaysNames(\n localeStartOfWeek: number,\n weekdayFormat: TWeekdayFormat,\n weekdays: string[],\n weekdaysMin: string[],\n weekdaysShort: string[],\n): string[] {\n let weekdaysNames;\n if (weekdayFormat === 'long') {\n weekdaysNames = weekdays;\n } else if (weekdayFormat === 'min') {\n weekdaysNames = weekdaysMin;\n } else {\n weekdaysNames = weekdaysShort;\n }\n return weekdaysNames\n .slice(localeStartOfWeek)\n .concat(weekdaysNames.slice(0, localeStartOfWeek));\n}\n\nexport function firstDay(currentCenter: Date, localeStartOfWeek: number): Date {\n const firstDay = startOf(currentCenter, 'month');\n return startOfWeek(firstDay, localeStartOfWeek);\n}\n\nexport function weeks(\n days: PowerCalendarDay[],\n showDaysAround: boolean,\n): Week[] {\n const weeks: Week[] = [];\n let i = 0;\n while (days[i]) {\n let daysOfWeek = days.slice(i, i + 7);\n if (!showDaysAround) {\n daysOfWeek = daysOfWeek.filter((d) => d.isCurrentMonth);\n }\n weeks.push({\n id: `week-of-${daysOfWeek[0]?.id}`,\n days: daysOfWeek,\n missingDays: 7 - daysOfWeek.length,\n });\n i += 7;\n }\n return weeks;\n}\n\nexport function handleDayKeyDown(\n e: KeyboardEvent,\n focusedId: string | null,\n days: PowerCalendarDay[],\n): PowerCalendarDay | undefined {\n if (!focusedId) {\n return;\n }\n let day, index: number | undefined;\n for (let i = 0; i < days.length; i++) {\n if (days[i]?.id === focusedId) {\n index = i;\n break;\n }\n }\n\n if (!index) {\n return;\n }\n\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n console.log(index);\n const newIndex = Math.max(index - 7, 0);\n day = days[newIndex];\n if (day?.isDisabled) {\n for (let i = newIndex + 1; i <= index; i++) {\n day = days[i];\n if (!day?.isDisabled) {\n break;\n }\n }\n }\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n const newIndex = Math.min(index + 7, days.length - 1);\n day = days[newIndex];\n if (day?.isDisabled) {\n for (let i = newIndex - 1; i >= index; i--) {\n day = days[i];\n if (!day?.isDisabled) {\n break;\n }\n }\n }\n } else if (e.key === 'ArrowLeft') {\n day = days[Math.max(index - 1, 0)];\n if (day?.isDisabled) {\n return;\n }\n } else if (e.key === 'ArrowRight') {\n day = days[Math.min(index + 1, days.length - 1)];\n if (day?.isDisabled) {\n return;\n }\n } else {\n return;\n }\n\n return day;\n}\n\nexport function focusDate(uniqueId: string, id: string): void {\n const dayElement: HTMLElement | null = document.querySelector(\n `[data-power-calendar-id=\"${uniqueId}\"] [data-date=\"${id}\"]`,\n );\n if (dayElement) {\n dayElement.focus();\n }\n}\n\nexport function buildDay(\n date: Date,\n today: Date,\n calendar: CalendarAPI,\n focusedId: string | null,\n currentCenter: Date,\n dayIsSelected: (date: Date, calendar: CalendarAPI) => boolean,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n dayIsDisabledExtended?: (\n date: Date,\n calendar: CalendarAPI,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n ) => boolean,\n): PowerCalendarDay {\n const id = formatDate(date, 'YYYY-MM-DD');\n\n let isDisabled = false;\n if (typeof dayIsDisabledExtended === 'function') {\n isDisabled = dayIsDisabledExtended(\n date,\n calendar,\n minDate,\n maxDate,\n disabledDates,\n );\n } else {\n isDisabled = dayIsDisabled(date, calendar, minDate, maxDate, disabledDates);\n }\n\n return normalizeCalendarDay({\n id,\n number: date.getDate(),\n date: new Date(date),\n isDisabled: isDisabled,\n isFocused: focusedId === id,\n isCurrentMonth: isSame(date, currentCenter, 'month'),\n isToday: isSame(date, today, 'day'),\n isSelected: dayIsSelected(date, calendar),\n } as PowerCalendarDay);\n}\n\nexport function dayIsDisabled(\n date: Date,\n calendar: CalendarAPI,\n minDate?: Date,\n maxDate?: Date,\n disabledDates?: Array<Date | string>,\n): boolean {\n const isDisabled = !calendar.actions.select;\n if (isDisabled) {\n return true;\n }\n\n if (minDate && isBefore(date, startOf(minDate, 'day'))) {\n return true;\n }\n\n if (maxDate && isAfter(date, endOf(maxDate, 'day'))) {\n return true;\n }\n\n if (disabledDates) {\n const disabledInRange = disabledDates.some((d) => {\n const isSameDay = isSame(date, d as Date, 'day');\n const isWeekDayIncludes =\n WEEK_DAYS.indexOf(d as string) !== -1 && formatDate(date, 'ddd') === d;\n return isSameDay || isWeekDayIncludes;\n });\n\n if (disabledInRange) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function lastDay(localeStartOfWeek: number, currentCenter: Date): Date {\n assert(\n 'The center of the calendar is an invalid date.',\n !isNaN(currentCenter.getTime()),\n );\n const lastDay = endOf(currentCenter, 'month');\n return endOfWeek(lastDay, localeStartOfWeek);\n}\n\nexport function handleClick(\n e: MouseEvent,\n days: PowerCalendarDay[],\n calendar: CalendarAPI,\n): void {\n const dayEl: HTMLElement | null | undefined = (\n e.target as HTMLElement | null\n )?.closest('[data-date]');\n if (dayEl) {\n const dateStr = dayEl.dataset['date'];\n const day = days.find((d) => d.id === dateStr);\n if (day) {\n if (calendar.actions.select) {\n calendar.actions.select(day, calendar, e);\n }\n }\n }\n}\n"],"names":["s","service","inject","WEEK_DAYS","localeStartOfWeekOrFallback","startOfWeek","locale","parseInt","localeStartOfWeek","weekdaysNames","weekdayFormat","weekdays","weekdaysMin","weekdaysShort","slice","concat","firstDay","currentCenter","startOf","weeks","days","showDaysAround","i","daysOfWeek","filter","d","isCurrentMonth","push","id","missingDays","length","handleDayKeyDown","e","focusedId","day","index","key","preventDefault","console","log","newIndex","Math","max","isDisabled","min","focusDate","uniqueId","dayElement","document","querySelector","focus","buildDay","date","today","calendar","dayIsSelected","minDate","maxDate","disabledDates","dayIsDisabledExtended","formatDate","dayIsDisabled","normalizeCalendarDay","number","getDate","Date","isFocused","isSame","isToday","isSelected","actions","select","isBefore","isAfter","endOf","disabledInRange","some","isSameDay","isWeekDayIncludes","indexOf","lastDay","assert","isNaN","getTime","endOfWeek","handleClick","dayEl","target","closest","dateStr","dataset","find"],"mappings":";;;;AAEA,cAAeA,CAAC,CAACC,OAAO,IAAID,CAAC,CAACE,MAAM;;ACc7B,MAAMC,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,K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