@mekari/pixel3-date-picker 0.0.1-dev.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/dist/calendar-panel.d.mts +231 -0
- package/dist/calendar-panel.d.ts +231 -0
- package/dist/calendar-panel.js +1498 -0
- package/dist/calendar-panel.mjs +25 -0
- package/dist/chunk-26Y3AVJW.mjs +115 -0
- package/dist/chunk-3VROFGJH.mjs +34 -0
- package/dist/chunk-3YYRUEIF.mjs +257 -0
- package/dist/chunk-5PISTT2K.mjs +131 -0
- package/dist/chunk-AGAA7XTC.mjs +20 -0
- package/dist/chunk-EJCSF5VR.mjs +492 -0
- package/dist/chunk-EQWT6VDG.mjs +34 -0
- package/dist/chunk-FTR7OMCT.mjs +0 -0
- package/dist/chunk-HJ4V3PM6.mjs +125 -0
- package/dist/chunk-J5BK7Z2U.mjs +46 -0
- package/dist/chunk-JZ2KFYWF.mjs +127 -0
- package/dist/chunk-LVCRFE25.mjs +153 -0
- package/dist/chunk-NIUQXHGQ.mjs +56 -0
- package/dist/chunk-NVULZQVI.mjs +119 -0
- package/dist/chunk-OY5PVQH5.mjs +31 -0
- package/dist/chunk-Q3Z5ZITX.mjs +155 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/chunk-V36XV4LV.mjs +129 -0
- package/dist/chunk-V6D6W7RO.mjs +0 -0
- package/dist/chunk-VACMCDOZ.mjs +8 -0
- package/dist/components/calendar/index.d.mts +11 -0
- package/dist/components/calendar/index.d.ts +11 -0
- package/dist/components/calendar/index.js +548 -0
- package/dist/components/calendar/index.mjs +23 -0
- package/dist/components/calendar/table-date.d.mts +97 -0
- package/dist/components/calendar/table-date.d.ts +97 -0
- package/dist/components/calendar/table-date.js +305 -0
- package/dist/components/calendar/table-date.mjs +13 -0
- package/dist/components/calendar/table-month.d.mts +90 -0
- package/dist/components/calendar/table-month.d.ts +90 -0
- package/dist/components/calendar/table-month.js +294 -0
- package/dist/components/calendar/table-month.mjs +14 -0
- package/dist/components/calendar/table-year.d.mts +71 -0
- package/dist/components/calendar/table-year.d.ts +71 -0
- package/dist/components/calendar/table-year.js +288 -0
- package/dist/components/calendar/table-year.mjs +14 -0
- package/dist/components/parts/date.d.mts +38 -0
- package/dist/components/parts/date.d.ts +38 -0
- package/dist/components/parts/date.js +70 -0
- package/dist/components/parts/date.mjs +7 -0
- package/dist/components/parts/day.d.mts +6 -0
- package/dist/components/parts/day.d.ts +6 -0
- package/dist/components/parts/day.js +44 -0
- package/dist/components/parts/day.mjs +7 -0
- package/dist/components/parts/index.d.mts +9 -0
- package/dist/components/parts/index.d.ts +9 -0
- package/dist/components/parts/index.js +157 -0
- package/dist/components/parts/index.mjs +20 -0
- package/dist/components/parts/month.d.mts +29 -0
- package/dist/components/parts/month.d.ts +29 -0
- package/dist/components/parts/month.js +58 -0
- package/dist/components/parts/month.mjs +7 -0
- package/dist/components/parts/year.d.mts +29 -0
- package/dist/components/parts/year.d.ts +29 -0
- package/dist/components/parts/year.js +58 -0
- package/dist/components/parts/year.mjs +7 -0
- package/dist/composables/useCalendar.d.mts +90 -0
- package/dist/composables/useCalendar.d.ts +90 -0
- package/dist/composables/useCalendar.js +184 -0
- package/dist/composables/useCalendar.mjs +8 -0
- package/dist/composables/useCalendarRange.d.mts +277 -0
- package/dist/composables/useCalendarRange.d.ts +277 -0
- package/dist/composables/useCalendarRange.js +160 -0
- package/dist/composables/useCalendarRange.mjs +8 -0
- package/dist/date-picker.d.mts +237 -0
- package/dist/date-picker.d.ts +237 -0
- package/dist/date-picker.js +1851 -0
- package/dist/date-picker.mjs +25 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1853 -0
- package/dist/index.mjs +25 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modules/date-picker.context.d.mts +20 -0
- package/dist/modules/date-picker.context.d.ts +20 -0
- package/dist/modules/date-picker.context.js +33 -0
- package/dist/modules/date-picker.context.mjs +9 -0
- package/dist/modules/date-picker.hooks.d.mts +53 -0
- package/dist/modules/date-picker.hooks.d.ts +53 -0
- package/dist/modules/date-picker.hooks.js +337 -0
- package/dist/modules/date-picker.hooks.mjs +10 -0
- package/dist/modules/date-picker.locales.d.mts +27 -0
- package/dist/modules/date-picker.locales.d.ts +27 -0
- package/dist/modules/date-picker.locales.js +84 -0
- package/dist/modules/date-picker.locales.mjs +8 -0
- package/dist/modules/date-picker.props.d.mts +217 -0
- package/dist/modules/date-picker.props.d.ts +217 -0
- package/dist/modules/date-picker.props.js +181 -0
- package/dist/modules/date-picker.props.mjs +11 -0
- package/dist/utils/base.d.mts +20 -0
- package/dist/utils/base.d.ts +20 -0
- package/dist/utils/base.js +80 -0
- package/dist/utils/base.mjs +13 -0
- package/dist/utils/date.d.mts +19 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.js +147 -0
- package/dist/utils/date.mjs +29 -0
- package/package.json +49 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calendarPanelProps,
|
|
3
|
+
calendarPanelRangeProps
|
|
4
|
+
} from "./chunk-Q3Z5ZITX.mjs";
|
|
5
|
+
import {
|
|
6
|
+
TableDate
|
|
7
|
+
} from "./chunk-LVCRFE25.mjs";
|
|
8
|
+
import {
|
|
9
|
+
TableMonth
|
|
10
|
+
} from "./chunk-5PISTT2K.mjs";
|
|
11
|
+
import {
|
|
12
|
+
TableYear
|
|
13
|
+
} from "./chunk-HJ4V3PM6.mjs";
|
|
14
|
+
import {
|
|
15
|
+
useCalendar
|
|
16
|
+
} from "./chunk-NVULZQVI.mjs";
|
|
17
|
+
import {
|
|
18
|
+
useCalendarRange
|
|
19
|
+
} from "./chunk-JZ2KFYWF.mjs";
|
|
20
|
+
import {
|
|
21
|
+
useDatePickerContext
|
|
22
|
+
} from "./chunk-VACMCDOZ.mjs";
|
|
23
|
+
import {
|
|
24
|
+
addDays,
|
|
25
|
+
createDate,
|
|
26
|
+
isDateBetween,
|
|
27
|
+
startOfWeek
|
|
28
|
+
} from "./chunk-26Y3AVJW.mjs";
|
|
29
|
+
import {
|
|
30
|
+
getLocale
|
|
31
|
+
} from "./chunk-OY5PVQH5.mjs";
|
|
32
|
+
import {
|
|
33
|
+
__name
|
|
34
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
35
|
+
|
|
36
|
+
// src/calendar-panel.tsx
|
|
37
|
+
import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
|
|
38
|
+
import { defineComponent, ref, watch } from "vue";
|
|
39
|
+
import { isToday, isEqual } from "date-fns";
|
|
40
|
+
import { calendarPanelRangeRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
41
|
+
var CalendarPanel = defineComponent({
|
|
42
|
+
name: "CalendarPanel",
|
|
43
|
+
props: calendarPanelProps,
|
|
44
|
+
emits: ["update:modelValue", "mouseEnter", "mouseLeave", "updateCalendar"],
|
|
45
|
+
setup(props, {
|
|
46
|
+
emit
|
|
47
|
+
}) {
|
|
48
|
+
const {
|
|
49
|
+
locale
|
|
50
|
+
} = useDatePickerContext();
|
|
51
|
+
const restValue = ref(props.modelValue);
|
|
52
|
+
const {
|
|
53
|
+
currentDate: currentPanelDate,
|
|
54
|
+
currentPanel,
|
|
55
|
+
changePanel,
|
|
56
|
+
getDates,
|
|
57
|
+
getMonths,
|
|
58
|
+
getYears,
|
|
59
|
+
nextMonth,
|
|
60
|
+
previousMonth,
|
|
61
|
+
nextYear,
|
|
62
|
+
previousYear,
|
|
63
|
+
getLabel,
|
|
64
|
+
changeMonth,
|
|
65
|
+
changeYear
|
|
66
|
+
} = useCalendar(props.modelValue || props.defaultValue, locale);
|
|
67
|
+
function onSelectDate(date) {
|
|
68
|
+
currentPanelDate.value = date;
|
|
69
|
+
restValue.value = date;
|
|
70
|
+
emit("update:modelValue", restValue.value);
|
|
71
|
+
}
|
|
72
|
+
__name(onSelectDate, "onSelectDate");
|
|
73
|
+
function onSelectMonth(value, year) {
|
|
74
|
+
if (props.type === "month") {
|
|
75
|
+
const day = 1;
|
|
76
|
+
const month = value;
|
|
77
|
+
const date = new Date(year, month, day);
|
|
78
|
+
restValue.value = date;
|
|
79
|
+
emit("update:modelValue", restValue.value);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
changeMonth(value);
|
|
83
|
+
changePanel("date");
|
|
84
|
+
}
|
|
85
|
+
__name(onSelectMonth, "onSelectMonth");
|
|
86
|
+
function onSelectYear(value) {
|
|
87
|
+
if (props.type === "year") {
|
|
88
|
+
const day = 1;
|
|
89
|
+
const month = currentPanelDate.value.getMonth();
|
|
90
|
+
const year = value;
|
|
91
|
+
const date = new Date(year, month, day);
|
|
92
|
+
restValue.value = date;
|
|
93
|
+
emit("update:modelValue", restValue.value);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
changeYear(value);
|
|
97
|
+
changePanel("month");
|
|
98
|
+
}
|
|
99
|
+
__name(onSelectYear, "onSelectYear");
|
|
100
|
+
function getDateStatus(date) {
|
|
101
|
+
let status = "default";
|
|
102
|
+
if (isToday(date))
|
|
103
|
+
status = "today";
|
|
104
|
+
if (isEqual(props.modelValue, date)) {
|
|
105
|
+
status = "selected";
|
|
106
|
+
}
|
|
107
|
+
const isCurrentMonth = currentPanelDate.value.getMonth() === date.getMonth();
|
|
108
|
+
if (!isCurrentMonth)
|
|
109
|
+
status = "notThisMonth";
|
|
110
|
+
if (props.getDateStatus && props.getDateStatus(date)) {
|
|
111
|
+
status = props.getDateStatus(date);
|
|
112
|
+
if (props.isHideNotThisMonthDate && !isCurrentMonth) {
|
|
113
|
+
status = "notThisMonth";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
status,
|
|
118
|
+
isDisabled: props.disabledDate ? props.disabledDate(date) : false,
|
|
119
|
+
// TODO : Handle show pin bar
|
|
120
|
+
isShowPinbar: false
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
__name(getDateStatus, "getDateStatus");
|
|
124
|
+
function getMonthStatus(month, year) {
|
|
125
|
+
let status = "default";
|
|
126
|
+
const isCurrentMonth = currentPanelDate.value.getMonth() === month && year === (/* @__PURE__ */ new Date()).getFullYear();
|
|
127
|
+
if (isCurrentMonth)
|
|
128
|
+
status = "today";
|
|
129
|
+
if (props.type === "month" && props.modelValue) {
|
|
130
|
+
const isMonthEqual = props.modelValue.getMonth() === month;
|
|
131
|
+
const isYearEqual = props.modelValue.getFullYear() === currentPanelDate.value.getFullYear();
|
|
132
|
+
const isSelected = isMonthEqual && isYearEqual;
|
|
133
|
+
if (isSelected)
|
|
134
|
+
status = "selected";
|
|
135
|
+
}
|
|
136
|
+
if (props.getMonthStatus && props.getMonthStatus(month, year)) {
|
|
137
|
+
status = props.getMonthStatus(month, year);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
status,
|
|
141
|
+
isDisabled: props.disabledMonth(month, year) || false
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
__name(getMonthStatus, "getMonthStatus");
|
|
145
|
+
function getYearStatus(year) {
|
|
146
|
+
var _a;
|
|
147
|
+
let status = "default";
|
|
148
|
+
const isCurrentYear = (/* @__PURE__ */ new Date()).getFullYear() === year;
|
|
149
|
+
if (isCurrentYear)
|
|
150
|
+
status = "today";
|
|
151
|
+
const isSelected = ((_a = props.modelValue) == null ? void 0 : _a.getFullYear()) === year;
|
|
152
|
+
if (isSelected)
|
|
153
|
+
status = "selected";
|
|
154
|
+
if (props.getYearStatus && props.getYearStatus(year)) {
|
|
155
|
+
status = props.getYearStatus(year);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
status,
|
|
159
|
+
isDisabled: props.disabledYear(year) || false
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
__name(getYearStatus, "getYearStatus");
|
|
163
|
+
function initCalendar() {
|
|
164
|
+
if (props.calendar) {
|
|
165
|
+
const calendarDate = props.calendar;
|
|
166
|
+
currentPanelDate.value = calendarDate;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
__name(initCalendar, "initCalendar");
|
|
170
|
+
watch(() => props.modelValue, (newValue) => {
|
|
171
|
+
if (newValue)
|
|
172
|
+
restValue.value = newValue;
|
|
173
|
+
}, {
|
|
174
|
+
immediate: true
|
|
175
|
+
});
|
|
176
|
+
watch(() => props.type, (newValue) => {
|
|
177
|
+
if (newValue)
|
|
178
|
+
currentPanel.value = newValue;
|
|
179
|
+
}, {
|
|
180
|
+
immediate: true
|
|
181
|
+
});
|
|
182
|
+
watch(() => currentPanelDate.value, (newValue) => {
|
|
183
|
+
if (newValue) {
|
|
184
|
+
emit("updateCalendar", newValue);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
watch(() => props.calendar, () => {
|
|
188
|
+
initCalendar();
|
|
189
|
+
}, {
|
|
190
|
+
immediate: true
|
|
191
|
+
});
|
|
192
|
+
return () => {
|
|
193
|
+
if (currentPanel.value === "date") {
|
|
194
|
+
return _createVNode(TableDate, {
|
|
195
|
+
"days": locale.value.days,
|
|
196
|
+
"dates": getDates.value,
|
|
197
|
+
"headerLabel": getLabel.value,
|
|
198
|
+
"shortcutLabel": locale.value.todayText,
|
|
199
|
+
"onNext": nextMonth,
|
|
200
|
+
"onPrevious": previousMonth,
|
|
201
|
+
"onClickHeaderLabel": () => changePanel("year"),
|
|
202
|
+
"onSelect": onSelectDate,
|
|
203
|
+
"getDateStatus": getDateStatus,
|
|
204
|
+
"isShowShortcut": props.isShowShortcut,
|
|
205
|
+
"onMouseEnter": (value) => emit("mouseEnter", value),
|
|
206
|
+
"onMouseLeave": () => emit("mouseLeave"),
|
|
207
|
+
"isHideNotThisMonthDate": props.isHideNotThisMonthDate
|
|
208
|
+
}, null);
|
|
209
|
+
}
|
|
210
|
+
if (currentPanel.value === "month") {
|
|
211
|
+
return _createVNode(TableMonth, {
|
|
212
|
+
"calendar": currentPanelDate.value,
|
|
213
|
+
"months": getMonths.value,
|
|
214
|
+
"headerLabel": getLabel.value,
|
|
215
|
+
"shortcutLabel": locale.value.thisMonthText,
|
|
216
|
+
"onNext": nextYear,
|
|
217
|
+
"onPrevious": previousYear,
|
|
218
|
+
"onClickHeaderLabel": () => changePanel("year"),
|
|
219
|
+
"onSelect": onSelectMonth,
|
|
220
|
+
"getMonthStatus": getMonthStatus,
|
|
221
|
+
"onMouseEnter": (value) => emit("mouseEnter", value),
|
|
222
|
+
"onMouseLeave": () => emit("mouseLeave"),
|
|
223
|
+
"isShowShortcut": props.isShowShortcut
|
|
224
|
+
}, null);
|
|
225
|
+
}
|
|
226
|
+
if (currentPanel.value === "year") {
|
|
227
|
+
return _createVNode(TableYear, {
|
|
228
|
+
"years": getYears.value,
|
|
229
|
+
"headerLabel": getLabel.value,
|
|
230
|
+
"shortcutLabel": locale.value.thisYearText,
|
|
231
|
+
"onNext": (year) => changeYear(year),
|
|
232
|
+
"onPrevious": (year) => changeYear(year),
|
|
233
|
+
"onSelect": onSelectYear,
|
|
234
|
+
"getYearStatus": getYearStatus,
|
|
235
|
+
"onMouseEnter": (value) => emit("mouseEnter", value),
|
|
236
|
+
"onMouseLeave": () => emit("mouseLeave"),
|
|
237
|
+
"isShowShortcut": props.isShowShortcut
|
|
238
|
+
}, null);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
var CalendarPanelRange = defineComponent({
|
|
244
|
+
name: "CalendarPanelRange",
|
|
245
|
+
props: calendarPanelRangeProps,
|
|
246
|
+
emits: ["update:modelValue"],
|
|
247
|
+
setup(props, {
|
|
248
|
+
emit
|
|
249
|
+
}) {
|
|
250
|
+
var _a;
|
|
251
|
+
const {
|
|
252
|
+
startDate,
|
|
253
|
+
endDate,
|
|
254
|
+
hoveredDate,
|
|
255
|
+
calendars,
|
|
256
|
+
setStartDate,
|
|
257
|
+
setEndDate,
|
|
258
|
+
setHoveredDate,
|
|
259
|
+
getDateRangeStatus,
|
|
260
|
+
getCurrentDates,
|
|
261
|
+
updateStartCalendar,
|
|
262
|
+
updateEndCalendar
|
|
263
|
+
} = useCalendarRange(props);
|
|
264
|
+
if ((_a = props.modelValue) == null ? void 0 : _a.length) {
|
|
265
|
+
updateStartCalendar(props.modelValue[0]);
|
|
266
|
+
updateEndCalendar(props.modelValue[1]);
|
|
267
|
+
}
|
|
268
|
+
function onSelectDate(date) {
|
|
269
|
+
if (props.type === "week" || props.type === "biweek") {
|
|
270
|
+
const gap = {
|
|
271
|
+
week: 6,
|
|
272
|
+
biweek: 13
|
|
273
|
+
};
|
|
274
|
+
const startDate2 = startOfWeek(date, getLocale().formatLocale.firstDayOfWeek);
|
|
275
|
+
const endDate2 = addDays(startDate2, gap[props.type]);
|
|
276
|
+
setStartDate(startDate2);
|
|
277
|
+
setEndDate(endDate2);
|
|
278
|
+
emit("update:modelValue", getCurrentDates.value);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (startDate.value && endDate.value) {
|
|
282
|
+
setStartDate(void 0);
|
|
283
|
+
setEndDate(void 0);
|
|
284
|
+
setStartDate(date);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (startDate.value && !endDate.value) {
|
|
288
|
+
setEndDate(date);
|
|
289
|
+
if (startDate.value && endDate.value) {
|
|
290
|
+
emit("update:modelValue", getCurrentDates.value);
|
|
291
|
+
}
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (!startDate.value && !endDate.value) {
|
|
295
|
+
setStartDate(date);
|
|
296
|
+
if (startDate.value && endDate.value) {
|
|
297
|
+
emit("update:modelValue", getCurrentDates.value);
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
__name(onSelectDate, "onSelectDate");
|
|
303
|
+
function getDateStatus(date) {
|
|
304
|
+
var _a2, _b;
|
|
305
|
+
let status = "default";
|
|
306
|
+
if (isToday(date))
|
|
307
|
+
status = "today";
|
|
308
|
+
const {
|
|
309
|
+
inRange,
|
|
310
|
+
hoverInRange
|
|
311
|
+
} = getDateRangeStatus(date);
|
|
312
|
+
if (inRange || hoverInRange) {
|
|
313
|
+
status = "range";
|
|
314
|
+
}
|
|
315
|
+
if (startDate.value && !endDate.value && isEqual(hoveredDate.value, date)) {
|
|
316
|
+
status = "selected";
|
|
317
|
+
}
|
|
318
|
+
if (isEqual(startDate.value, date)) {
|
|
319
|
+
status = "selected";
|
|
320
|
+
}
|
|
321
|
+
if (isEqual(endDate.value, date)) {
|
|
322
|
+
status = "selected";
|
|
323
|
+
}
|
|
324
|
+
if (props.type === "week") {
|
|
325
|
+
if ((_a2 = props.modelValue) == null ? void 0 : _a2.length) {
|
|
326
|
+
const startDate2 = startOfWeek(props.modelValue[0], getLocale().formatLocale.firstDayOfWeek);
|
|
327
|
+
const endDate2 = addDays(startDate2, 6);
|
|
328
|
+
if (isDateBetween(date, startDate2, endDate2)) {
|
|
329
|
+
status = "weekSelectedMiddle";
|
|
330
|
+
if (isEqual(startDate2, date))
|
|
331
|
+
status = "weekSelectedStart";
|
|
332
|
+
if (isEqual(endDate2, date))
|
|
333
|
+
status = "weekSelectedEnd";
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (hoveredDate.value) {
|
|
337
|
+
const startDate2 = startOfWeek(hoveredDate.value, getLocale().formatLocale.firstDayOfWeek);
|
|
338
|
+
const endDate2 = addDays(startDate2, 6);
|
|
339
|
+
if (isDateBetween(date, startDate2, endDate2)) {
|
|
340
|
+
status = "weekHoveredMiddle";
|
|
341
|
+
if (isEqual(startDate2, date))
|
|
342
|
+
status = "weekHoveredStart";
|
|
343
|
+
if (isEqual(endDate2, date))
|
|
344
|
+
status = "weekHoveredEnd";
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (props.type === "biweek") {
|
|
349
|
+
const getBiweekDates = /* @__PURE__ */ __name((date2) => {
|
|
350
|
+
const firstWeekStartDate = startOfWeek(date2, getLocale().formatLocale.firstDayOfWeek);
|
|
351
|
+
const firstWeekEndDate = addDays(firstWeekStartDate, 6);
|
|
352
|
+
const secondWeekStartDate = startOfWeek(addDays(firstWeekStartDate, 7), getLocale().formatLocale.firstDayOfWeek);
|
|
353
|
+
const secondWeekEndDate = addDays(secondWeekStartDate, 6);
|
|
354
|
+
return {
|
|
355
|
+
firstWeekStartDate,
|
|
356
|
+
firstWeekEndDate,
|
|
357
|
+
secondWeekStartDate,
|
|
358
|
+
secondWeekEndDate
|
|
359
|
+
};
|
|
360
|
+
}, "getBiweekDates");
|
|
361
|
+
if ((_b = props.modelValue) == null ? void 0 : _b.length) {
|
|
362
|
+
const {
|
|
363
|
+
firstWeekStartDate,
|
|
364
|
+
firstWeekEndDate,
|
|
365
|
+
secondWeekStartDate,
|
|
366
|
+
secondWeekEndDate
|
|
367
|
+
} = getBiweekDates(props.modelValue[0]);
|
|
368
|
+
if (isDateBetween(date, firstWeekStartDate, secondWeekEndDate)) {
|
|
369
|
+
status = "weekSelectedMiddle";
|
|
370
|
+
if (isEqual(firstWeekStartDate, date))
|
|
371
|
+
status = "weekSelectedStart";
|
|
372
|
+
if (isEqual(firstWeekEndDate, date))
|
|
373
|
+
status = "weekSelectedEnd";
|
|
374
|
+
if (isEqual(secondWeekStartDate, date))
|
|
375
|
+
status = "weekSelectedStart";
|
|
376
|
+
if (isEqual(secondWeekEndDate, date))
|
|
377
|
+
status = "weekSelectedEnd";
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (hoveredDate.value) {
|
|
381
|
+
const {
|
|
382
|
+
firstWeekStartDate,
|
|
383
|
+
firstWeekEndDate,
|
|
384
|
+
secondWeekStartDate,
|
|
385
|
+
secondWeekEndDate
|
|
386
|
+
} = getBiweekDates(hoveredDate.value);
|
|
387
|
+
if (isDateBetween(date, firstWeekStartDate, secondWeekEndDate)) {
|
|
388
|
+
status = "weekHoveredMiddle";
|
|
389
|
+
if (isEqual(firstWeekStartDate, date))
|
|
390
|
+
status = "weekHoveredStart";
|
|
391
|
+
if (isEqual(firstWeekEndDate, date))
|
|
392
|
+
status = "weekHoveredEnd";
|
|
393
|
+
if (isEqual(secondWeekStartDate, date))
|
|
394
|
+
status = "weekHoveredStart";
|
|
395
|
+
if (isEqual(secondWeekEndDate, date))
|
|
396
|
+
status = "weekHoveredEnd";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return status;
|
|
401
|
+
}
|
|
402
|
+
__name(getDateStatus, "getDateStatus");
|
|
403
|
+
function getMonthStatus(month, year) {
|
|
404
|
+
let status = "default";
|
|
405
|
+
const parseToDate = createDate(year, month);
|
|
406
|
+
const {
|
|
407
|
+
inRange,
|
|
408
|
+
hoverInRange
|
|
409
|
+
} = getDateRangeStatus(parseToDate);
|
|
410
|
+
if (inRange || hoverInRange) {
|
|
411
|
+
status = "range";
|
|
412
|
+
}
|
|
413
|
+
if (startDate.value && !endDate.value && isEqual(hoveredDate.value, parseToDate)) {
|
|
414
|
+
status = "selected";
|
|
415
|
+
}
|
|
416
|
+
if (isEqual(startDate.value, parseToDate)) {
|
|
417
|
+
status = "selected";
|
|
418
|
+
}
|
|
419
|
+
if (isEqual(endDate.value, parseToDate)) {
|
|
420
|
+
status = "selected";
|
|
421
|
+
}
|
|
422
|
+
return status;
|
|
423
|
+
}
|
|
424
|
+
__name(getMonthStatus, "getMonthStatus");
|
|
425
|
+
function getYearStatus(year) {
|
|
426
|
+
var _a2, _b, _c;
|
|
427
|
+
let status = "default";
|
|
428
|
+
const parseToDate = createDate(year);
|
|
429
|
+
const {
|
|
430
|
+
inRange,
|
|
431
|
+
hoverInRange
|
|
432
|
+
} = getDateRangeStatus(parseToDate);
|
|
433
|
+
if (inRange || hoverInRange) {
|
|
434
|
+
status = "range";
|
|
435
|
+
}
|
|
436
|
+
if (startDate.value && !endDate.value && ((_a2 = hoveredDate.value) == null ? void 0 : _a2.getFullYear()) === parseToDate.getFullYear()) {
|
|
437
|
+
status = "selected";
|
|
438
|
+
}
|
|
439
|
+
if (((_b = startDate.value) == null ? void 0 : _b.getFullYear()) === parseToDate.getFullYear()) {
|
|
440
|
+
status = "selected";
|
|
441
|
+
}
|
|
442
|
+
if (((_c = endDate.value) == null ? void 0 : _c.getFullYear()) === parseToDate.getFullYear()) {
|
|
443
|
+
status = "selected";
|
|
444
|
+
}
|
|
445
|
+
return status;
|
|
446
|
+
}
|
|
447
|
+
__name(getYearStatus, "getYearStatus");
|
|
448
|
+
return () => {
|
|
449
|
+
const isWeekAndBiweek = props.type === "week" || props.type === "biweek";
|
|
450
|
+
const classes = isWeekAndBiweek ? "" : calendarPanelRangeRecipe();
|
|
451
|
+
const calendarPanelAttrs = {
|
|
452
|
+
isRange: true,
|
|
453
|
+
type: props.type,
|
|
454
|
+
isHideNotThisMonthDate: props.type === "week" || props.type === "biweek" ? false : true,
|
|
455
|
+
isShowShortcut: false,
|
|
456
|
+
getDateStatus,
|
|
457
|
+
getMonthStatus,
|
|
458
|
+
getYearStatus,
|
|
459
|
+
"onUpdate:modelValue": (date) => onSelectDate(date),
|
|
460
|
+
onMouseEnter: (date) => setHoveredDate(date),
|
|
461
|
+
onMouseLeave: () => setHoveredDate(void 0)
|
|
462
|
+
};
|
|
463
|
+
const leftNode = _createVNode(CalendarPanel, _mergeProps({
|
|
464
|
+
"data-pixel-parts": "CalendarPanelLeft"
|
|
465
|
+
}, calendarPanelAttrs, {
|
|
466
|
+
"onUpdateCalendar": (value) => updateStartCalendar(value),
|
|
467
|
+
"calendar": calendars.value[0]
|
|
468
|
+
}), null);
|
|
469
|
+
const rightNode = _createVNode(CalendarPanel, _mergeProps({
|
|
470
|
+
"data-pixel-parts": "CalendarPanelRight"
|
|
471
|
+
}, calendarPanelAttrs, {
|
|
472
|
+
"onUpdateCalendar": (value) => updateEndCalendar(value),
|
|
473
|
+
"calendar": calendars.value[1]
|
|
474
|
+
}), null);
|
|
475
|
+
const weekAndBiweekNode = _createVNode(CalendarPanel, _mergeProps({
|
|
476
|
+
"data-pixel-parts": "CalendarPanel"
|
|
477
|
+
}, calendarPanelAttrs, {
|
|
478
|
+
"onUpdateCalendar": (value) => updateStartCalendar(value),
|
|
479
|
+
"calendar": props.modelValue[0],
|
|
480
|
+
"type": "date"
|
|
481
|
+
}), null);
|
|
482
|
+
return _createVNode("div", {
|
|
483
|
+
"class": classes
|
|
484
|
+
}, [isWeekAndBiweek ? weekAndBiweekNode : [leftNode, rightNode]]);
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
export {
|
|
490
|
+
CalendarPanel,
|
|
491
|
+
CalendarPanelRange
|
|
492
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/components/parts/year.tsx
|
|
2
|
+
import { createVNode as _createVNode } from "vue";
|
|
3
|
+
import { defineComponent } from "vue";
|
|
4
|
+
import { yearItemRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
5
|
+
var YearItem = defineComponent({
|
|
6
|
+
name: "YearItem",
|
|
7
|
+
props: {
|
|
8
|
+
status: {
|
|
9
|
+
type: String
|
|
10
|
+
},
|
|
11
|
+
isDisabled: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
setup(props, {
|
|
17
|
+
slots
|
|
18
|
+
}) {
|
|
19
|
+
return () => {
|
|
20
|
+
const classes = yearItemRecipe({
|
|
21
|
+
status: props.status
|
|
22
|
+
});
|
|
23
|
+
return _createVNode("button", {
|
|
24
|
+
"disabled": props.isDisabled,
|
|
25
|
+
"data-status": props.status,
|
|
26
|
+
"class": classes
|
|
27
|
+
}, [slots.default()]);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
YearItem
|
|
34
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
YearItem
|
|
3
|
+
} from "./chunk-EQWT6VDG.mjs";
|
|
4
|
+
import {
|
|
5
|
+
createDate
|
|
6
|
+
} from "./chunk-26Y3AVJW.mjs";
|
|
7
|
+
import {
|
|
8
|
+
chunk
|
|
9
|
+
} from "./chunk-NIUQXHGQ.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__name
|
|
12
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
13
|
+
|
|
14
|
+
// src/components/calendar/table-year.tsx
|
|
15
|
+
import { createTextVNode as _createTextVNode, createVNode as _createVNode } from "vue";
|
|
16
|
+
import { defineComponent, computed } from "vue";
|
|
17
|
+
import { MpButton } from "@mekari/pixel3-button";
|
|
18
|
+
import { tableYearSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
19
|
+
var TableYear = defineComponent({
|
|
20
|
+
name: "TableYear",
|
|
21
|
+
props: {
|
|
22
|
+
years: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
headerLabel: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ""
|
|
29
|
+
},
|
|
30
|
+
shortcutLabel: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ""
|
|
33
|
+
},
|
|
34
|
+
getYearStatus: {
|
|
35
|
+
type: Function,
|
|
36
|
+
default: () => {
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
isShowShortcut: {
|
|
40
|
+
type: Boolean
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
emits: ["next", "previous", "select", "mouseEnter", "mouseLeave"],
|
|
44
|
+
setup(props, {
|
|
45
|
+
emit
|
|
46
|
+
}) {
|
|
47
|
+
const {
|
|
48
|
+
headerRoot,
|
|
49
|
+
headerLabel,
|
|
50
|
+
yearItemRoot,
|
|
51
|
+
yearItemWrapper,
|
|
52
|
+
shortcutLabelWrapper
|
|
53
|
+
} = tableYearSlotRecipe();
|
|
54
|
+
const getYears = computed(() => {
|
|
55
|
+
return chunk(props.years, 4);
|
|
56
|
+
});
|
|
57
|
+
function onNextButton() {
|
|
58
|
+
const lastYear = props.years[props.years.length - 1];
|
|
59
|
+
emit("next", lastYear + 1);
|
|
60
|
+
}
|
|
61
|
+
__name(onNextButton, "onNextButton");
|
|
62
|
+
function onPreviousButton() {
|
|
63
|
+
const firstYear = props.years[0];
|
|
64
|
+
emit("previous", firstYear - 1);
|
|
65
|
+
}
|
|
66
|
+
__name(onPreviousButton, "onPreviousButton");
|
|
67
|
+
function onSelectYear(year) {
|
|
68
|
+
emit("select", year);
|
|
69
|
+
}
|
|
70
|
+
__name(onSelectYear, "onSelectYear");
|
|
71
|
+
function getMonthAttrs(year) {
|
|
72
|
+
const {
|
|
73
|
+
status,
|
|
74
|
+
isDisabled
|
|
75
|
+
} = props.getYearStatus(year);
|
|
76
|
+
return {
|
|
77
|
+
status: isDisabled ? "disabled" : status,
|
|
78
|
+
isDisabled,
|
|
79
|
+
onClick: () => onSelectYear(year),
|
|
80
|
+
onMouseenter: () => {
|
|
81
|
+
emit("mouseEnter", createDate(year));
|
|
82
|
+
},
|
|
83
|
+
onMouseleave: () => {
|
|
84
|
+
emit("mouseLeave");
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
__name(getMonthAttrs, "getMonthAttrs");
|
|
89
|
+
return () => {
|
|
90
|
+
return _createVNode("div", null, [_createVNode("div", {
|
|
91
|
+
"data-pixel-parts": "Header",
|
|
92
|
+
"class": headerRoot
|
|
93
|
+
}, [_createVNode(MpButton, {
|
|
94
|
+
"left-icon": "chevrons-left",
|
|
95
|
+
"variant": "ghost",
|
|
96
|
+
"size": "sm",
|
|
97
|
+
"onClick": onPreviousButton
|
|
98
|
+
}, null), _createVNode("button", {
|
|
99
|
+
"class": headerLabel
|
|
100
|
+
}, [props.headerLabel]), _createVNode(MpButton, {
|
|
101
|
+
"right-icon": "chevrons-right",
|
|
102
|
+
"variant": "ghost",
|
|
103
|
+
"size": "sm",
|
|
104
|
+
"onClick": onNextButton
|
|
105
|
+
}, null)]), _createVNode("div", {
|
|
106
|
+
"class": yearItemRoot
|
|
107
|
+
}, [getYears.value.map((data) => _createVNode("div", {
|
|
108
|
+
"class": yearItemWrapper
|
|
109
|
+
}, [data.map((year) => _createVNode(YearItem, getMonthAttrs(year), {
|
|
110
|
+
default: () => [_createTextVNode(" "), year, _createTextVNode(" ")]
|
|
111
|
+
}))]))]), props.isShowShortcut && _createVNode("div", {
|
|
112
|
+
"class": shortcutLabelWrapper
|
|
113
|
+
}, [_createVNode(MpButton, {
|
|
114
|
+
"variant": "ghost",
|
|
115
|
+
"onClick": () => onSelectYear((/* @__PURE__ */ new Date()).getFullYear())
|
|
116
|
+
}, {
|
|
117
|
+
default: () => [props.shortcutLabel]
|
|
118
|
+
})])]);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
export {
|
|
124
|
+
TableYear
|
|
125
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/components/parts/date.tsx
|
|
2
|
+
import { createVNode as _createVNode } from "vue";
|
|
3
|
+
import { defineComponent } from "vue";
|
|
4
|
+
import { dateItemRecipe, pinbarSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
5
|
+
var Date = defineComponent({
|
|
6
|
+
name: "Date",
|
|
7
|
+
props: {
|
|
8
|
+
status: {
|
|
9
|
+
type: String
|
|
10
|
+
},
|
|
11
|
+
isDisabled: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
isShowPinbar: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
setup(props, {
|
|
21
|
+
slots
|
|
22
|
+
}) {
|
|
23
|
+
return () => {
|
|
24
|
+
const dateItemClasses = dateItemRecipe({
|
|
25
|
+
status: props.status
|
|
26
|
+
});
|
|
27
|
+
const {
|
|
28
|
+
root,
|
|
29
|
+
pinbar
|
|
30
|
+
} = pinbarSlotRecipe();
|
|
31
|
+
return _createVNode("button", {
|
|
32
|
+
"disabled": props.isDisabled,
|
|
33
|
+
"data-status": props.status,
|
|
34
|
+
"class": dateItemClasses
|
|
35
|
+
}, [slots.default(), props.isShowPinbar && _createVNode("div", {
|
|
36
|
+
"class": root
|
|
37
|
+
}, [_createVNode("div", {
|
|
38
|
+
"class": pinbar
|
|
39
|
+
}, null)])]);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
Date
|
|
46
|
+
};
|