@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,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CalendarPanel,
|
|
3
|
+
CalendarPanelRange
|
|
4
|
+
} from "./chunk-EJCSF5VR.mjs";
|
|
5
|
+
import "./chunk-Q3Z5ZITX.mjs";
|
|
6
|
+
import "./chunk-V6D6W7RO.mjs";
|
|
7
|
+
import "./chunk-LVCRFE25.mjs";
|
|
8
|
+
import "./chunk-5PISTT2K.mjs";
|
|
9
|
+
import "./chunk-HJ4V3PM6.mjs";
|
|
10
|
+
import "./chunk-FTR7OMCT.mjs";
|
|
11
|
+
import "./chunk-AGAA7XTC.mjs";
|
|
12
|
+
import "./chunk-3VROFGJH.mjs";
|
|
13
|
+
import "./chunk-EQWT6VDG.mjs";
|
|
14
|
+
import "./chunk-J5BK7Z2U.mjs";
|
|
15
|
+
import "./chunk-NVULZQVI.mjs";
|
|
16
|
+
import "./chunk-JZ2KFYWF.mjs";
|
|
17
|
+
import "./chunk-VACMCDOZ.mjs";
|
|
18
|
+
import "./chunk-26Y3AVJW.mjs";
|
|
19
|
+
import "./chunk-OY5PVQH5.mjs";
|
|
20
|
+
import "./chunk-NIUQXHGQ.mjs";
|
|
21
|
+
import "./chunk-QZ7VFGWC.mjs";
|
|
22
|
+
export {
|
|
23
|
+
CalendarPanel,
|
|
24
|
+
CalendarPanelRange
|
|
25
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/date.ts
|
|
6
|
+
import { addMonths } from "date-fns";
|
|
7
|
+
function createDate(y, M = 0, d = 1, h = 0, m = 0, s = 0, ms = 0) {
|
|
8
|
+
const date = new Date(y, M, d, h, m, s, ms);
|
|
9
|
+
if (y < 100 && y >= 0) {
|
|
10
|
+
date.setFullYear(y);
|
|
11
|
+
}
|
|
12
|
+
return date;
|
|
13
|
+
}
|
|
14
|
+
__name(createDate, "createDate");
|
|
15
|
+
function isValidDate(date) {
|
|
16
|
+
return date instanceof Date && !isNaN(date);
|
|
17
|
+
}
|
|
18
|
+
__name(isValidDate, "isValidDate");
|
|
19
|
+
function isValidRangeDate(date) {
|
|
20
|
+
return Array.isArray(date) && date.length === 2 && date.every(isValidDate) && date[0] <= date[1];
|
|
21
|
+
}
|
|
22
|
+
__name(isValidRangeDate, "isValidRangeDate");
|
|
23
|
+
function startOfYear(value) {
|
|
24
|
+
const date = new Date(value);
|
|
25
|
+
date.setMonth(0, 1);
|
|
26
|
+
date.setHours(0, 0, 0, 0);
|
|
27
|
+
return date;
|
|
28
|
+
}
|
|
29
|
+
__name(startOfYear, "startOfYear");
|
|
30
|
+
function startOfMonth(value) {
|
|
31
|
+
const date = new Date(value);
|
|
32
|
+
date.setDate(1);
|
|
33
|
+
date.setHours(0, 0, 0, 0);
|
|
34
|
+
return date;
|
|
35
|
+
}
|
|
36
|
+
__name(startOfMonth, "startOfMonth");
|
|
37
|
+
function startOfWeek(value, firstDayOfWeek = 0) {
|
|
38
|
+
if (!(firstDayOfWeek >= 0 && firstDayOfWeek <= 6)) {
|
|
39
|
+
throw new RangeError("weekStartsOn must be between 0 and 6");
|
|
40
|
+
}
|
|
41
|
+
const date = new Date(value);
|
|
42
|
+
const day = date.getDay();
|
|
43
|
+
const diff = (day + 7 - firstDayOfWeek) % 7;
|
|
44
|
+
date.setDate(date.getDate() - diff);
|
|
45
|
+
date.setHours(0, 0, 0, 0);
|
|
46
|
+
return date;
|
|
47
|
+
}
|
|
48
|
+
__name(startOfWeek, "startOfWeek");
|
|
49
|
+
function startOfDay(value) {
|
|
50
|
+
const date = new Date(value);
|
|
51
|
+
date.setHours(0, 0, 0, 0);
|
|
52
|
+
return date;
|
|
53
|
+
}
|
|
54
|
+
__name(startOfDay, "startOfDay");
|
|
55
|
+
function getCalendar({
|
|
56
|
+
firstDayOfWeek,
|
|
57
|
+
year,
|
|
58
|
+
month
|
|
59
|
+
}) {
|
|
60
|
+
const arr = [];
|
|
61
|
+
const calendar = createDate(year, month, 0);
|
|
62
|
+
const lastDayInLastMonth = calendar.getDate();
|
|
63
|
+
const firstDayInLastMonth = lastDayInLastMonth - (calendar.getDay() + 7 - firstDayOfWeek) % 7;
|
|
64
|
+
for (let i = firstDayInLastMonth; i <= lastDayInLastMonth; i++) {
|
|
65
|
+
arr.push(createDate(year, month, i - lastDayInLastMonth));
|
|
66
|
+
}
|
|
67
|
+
calendar.setMonth(month + 1, 0);
|
|
68
|
+
const lastDayInCurrentMonth = calendar.getDate();
|
|
69
|
+
for (let i = 1; i <= lastDayInCurrentMonth; i++) {
|
|
70
|
+
arr.push(createDate(year, month, i));
|
|
71
|
+
}
|
|
72
|
+
const lastMonthLength = lastDayInLastMonth - firstDayInLastMonth + 1;
|
|
73
|
+
const nextMonthLength = 6 * 7 - lastMonthLength - lastDayInCurrentMonth;
|
|
74
|
+
for (let i = 1; i <= nextMonthLength; i++) {
|
|
75
|
+
arr.push(createDate(year, month, lastDayInCurrentMonth + i));
|
|
76
|
+
}
|
|
77
|
+
return arr;
|
|
78
|
+
}
|
|
79
|
+
__name(getCalendar, "getCalendar");
|
|
80
|
+
function getNextMonth(date) {
|
|
81
|
+
return addMonths(date, 1);
|
|
82
|
+
}
|
|
83
|
+
__name(getNextMonth, "getNextMonth");
|
|
84
|
+
function getPreviousMonth(date) {
|
|
85
|
+
return addMonths(date, -1);
|
|
86
|
+
}
|
|
87
|
+
__name(getPreviousMonth, "getPreviousMonth");
|
|
88
|
+
function addDays(value, days) {
|
|
89
|
+
const date = new Date(value);
|
|
90
|
+
date.setDate(date.getDate() + days);
|
|
91
|
+
return date;
|
|
92
|
+
}
|
|
93
|
+
__name(addDays, "addDays");
|
|
94
|
+
function isDateBetween(date, min, max) {
|
|
95
|
+
const _date = new Date(date);
|
|
96
|
+
const _min = new Date(min);
|
|
97
|
+
const _max = new Date(max);
|
|
98
|
+
return _date.getTime() >= _min.getTime() && _date.getTime() <= _max.getTime();
|
|
99
|
+
}
|
|
100
|
+
__name(isDateBetween, "isDateBetween");
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
createDate,
|
|
104
|
+
isValidDate,
|
|
105
|
+
isValidRangeDate,
|
|
106
|
+
startOfYear,
|
|
107
|
+
startOfMonth,
|
|
108
|
+
startOfWeek,
|
|
109
|
+
startOfDay,
|
|
110
|
+
getCalendar,
|
|
111
|
+
getNextMonth,
|
|
112
|
+
getPreviousMonth,
|
|
113
|
+
addDays,
|
|
114
|
+
isDateBetween
|
|
115
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/components/parts/month.tsx
|
|
2
|
+
import { createVNode as _createVNode } from "vue";
|
|
3
|
+
import { defineComponent } from "vue";
|
|
4
|
+
import { monthItemRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
5
|
+
var Month = defineComponent({
|
|
6
|
+
name: "Month",
|
|
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 = monthItemRecipe({
|
|
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
|
+
Month
|
|
34
|
+
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isValidDate,
|
|
3
|
+
isValidRangeDate
|
|
4
|
+
} from "./chunk-26Y3AVJW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
getLocale
|
|
7
|
+
} from "./chunk-OY5PVQH5.mjs";
|
|
8
|
+
import {
|
|
9
|
+
isObject
|
|
10
|
+
} from "./chunk-NIUQXHGQ.mjs";
|
|
11
|
+
import {
|
|
12
|
+
__name
|
|
13
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
14
|
+
|
|
15
|
+
// src/modules/date-picker.hooks.ts
|
|
16
|
+
import { ref, computed, nextTick } from "vue";
|
|
17
|
+
import { getUniqueId } from "@mekari/pixel3-utils";
|
|
18
|
+
import { parse, format } from "date-format-parse";
|
|
19
|
+
function useDatePicker(props, emit) {
|
|
20
|
+
const getId = props.id || getUniqueId("", "datepicker").value;
|
|
21
|
+
const currentLabel = ref("");
|
|
22
|
+
const isOutside = ref(true);
|
|
23
|
+
const isPopoverOpen = ref(false);
|
|
24
|
+
const isInnerInvalid = ref(false);
|
|
25
|
+
const userInput = ref(null);
|
|
26
|
+
const innerValueDate = ref();
|
|
27
|
+
const isUseRange = computed(() => {
|
|
28
|
+
if (props.isRange || props.type === "biweek" || props.type === "week")
|
|
29
|
+
return true;
|
|
30
|
+
return false;
|
|
31
|
+
});
|
|
32
|
+
const innerFormat = computed(() => {
|
|
33
|
+
const format2 = {
|
|
34
|
+
date: "DD-MM-YYYY",
|
|
35
|
+
datetime: "DD-MM-YYYY HH:mm:ss",
|
|
36
|
+
year: "YYYY",
|
|
37
|
+
month: "YYYY-MM",
|
|
38
|
+
time: "HH:mm:ss",
|
|
39
|
+
week: "DD-MM-YYYY",
|
|
40
|
+
biweek: "DD-MM-YYYY"
|
|
41
|
+
};
|
|
42
|
+
return props.format || format2[props.type] || format2.date;
|
|
43
|
+
});
|
|
44
|
+
const innerValue = computed(() => {
|
|
45
|
+
if (isUseRange.value) {
|
|
46
|
+
if (isValidRangeDate(props.modelValue)) {
|
|
47
|
+
const startDate = valueToDate(props.modelValue[0]);
|
|
48
|
+
const endDate = valueToDate(props.modelValue[1]);
|
|
49
|
+
return [startDate, endDate];
|
|
50
|
+
}
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
return valueToDate(props.modelValue);
|
|
54
|
+
});
|
|
55
|
+
const text = computed(() => {
|
|
56
|
+
if (userInput.value !== null)
|
|
57
|
+
return userInput.value;
|
|
58
|
+
if (!innerValue.value)
|
|
59
|
+
return "";
|
|
60
|
+
if (isUseRange.value) {
|
|
61
|
+
if (!isValidRangeDate(innerValue.value))
|
|
62
|
+
return "";
|
|
63
|
+
} else {
|
|
64
|
+
if (!isValidDate(innerValue.value))
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(innerValue.value)) {
|
|
68
|
+
return innerValue.value.map((v) => formatDate(v)).join(props.rangeSeparator);
|
|
69
|
+
}
|
|
70
|
+
return formatDate(innerValue.value);
|
|
71
|
+
});
|
|
72
|
+
const locale = computed(() => {
|
|
73
|
+
if (isObject(props.lang)) {
|
|
74
|
+
return getLocale(props.lang);
|
|
75
|
+
}
|
|
76
|
+
return getLocale();
|
|
77
|
+
});
|
|
78
|
+
function onOpenPopover() {
|
|
79
|
+
if (props.isReadOnly)
|
|
80
|
+
return;
|
|
81
|
+
isPopoverOpen.value = true;
|
|
82
|
+
}
|
|
83
|
+
__name(onOpenPopover, "onOpenPopover");
|
|
84
|
+
function onClosePopover() {
|
|
85
|
+
isPopoverOpen.value = false;
|
|
86
|
+
}
|
|
87
|
+
__name(onClosePopover, "onClosePopover");
|
|
88
|
+
function onBlur() {
|
|
89
|
+
onClosePopover();
|
|
90
|
+
const inputEl = document.getElementById(`${getId}-control`);
|
|
91
|
+
inputEl == null ? void 0 : inputEl.blur();
|
|
92
|
+
}
|
|
93
|
+
__name(onBlur, "onBlur");
|
|
94
|
+
function handleForceFocusToInput() {
|
|
95
|
+
const inputEl = document.getElementById(`${getId}-control`);
|
|
96
|
+
inputEl == null ? void 0 : inputEl.focus();
|
|
97
|
+
}
|
|
98
|
+
__name(handleForceFocusToInput, "handleForceFocusToInput");
|
|
99
|
+
function onClear() {
|
|
100
|
+
isOutside.value = true;
|
|
101
|
+
userInput.value = null;
|
|
102
|
+
emit("update:modelValue", "");
|
|
103
|
+
onBlur();
|
|
104
|
+
}
|
|
105
|
+
__name(onClear, "onClear");
|
|
106
|
+
function onInputChange(e) {
|
|
107
|
+
var _a;
|
|
108
|
+
if (e) {
|
|
109
|
+
const target = e.target;
|
|
110
|
+
userInput.value = typeof e === "string" ? e : target.value;
|
|
111
|
+
if (userInput.value === null)
|
|
112
|
+
return;
|
|
113
|
+
const text2 = ((_a = userInput.value) == null ? void 0 : _a.trim()) || "";
|
|
114
|
+
if (text2 === "") {
|
|
115
|
+
onClear();
|
|
116
|
+
isInnerInvalid.value = false;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let date;
|
|
120
|
+
if (isUseRange.value) {
|
|
121
|
+
let arr = text2.split(props.rangeSeparator);
|
|
122
|
+
if (arr.length !== 2) {
|
|
123
|
+
arr = text2.split(props.rangeSeparator.trim());
|
|
124
|
+
}
|
|
125
|
+
date = arr.map((v) => parseDate(v.trim()));
|
|
126
|
+
} else {
|
|
127
|
+
date = parseDate(text2);
|
|
128
|
+
}
|
|
129
|
+
if (isValidValueAndNotDisabled(date)) {
|
|
130
|
+
innerValueDate.value = date;
|
|
131
|
+
nextTick(() => {
|
|
132
|
+
isOutside.value = true;
|
|
133
|
+
isInnerInvalid.value = false;
|
|
134
|
+
onBlur();
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
isInnerInvalid.value = true;
|
|
138
|
+
emit("error", text2);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
__name(onInputChange, "onInputChange");
|
|
143
|
+
function onEmitModelValue(value) {
|
|
144
|
+
userInput.value = null;
|
|
145
|
+
innerValueDate.value = value;
|
|
146
|
+
if (isUseRange.value) {
|
|
147
|
+
const dates = value;
|
|
148
|
+
const startDate = dateToValue(new Date(dates[0]));
|
|
149
|
+
const endDate = dateToValue(new Date(dates[1]));
|
|
150
|
+
emit("update:modelValue", [startDate, endDate]);
|
|
151
|
+
} else {
|
|
152
|
+
emit("update:modelValue", dateToValue(new Date(value)));
|
|
153
|
+
}
|
|
154
|
+
nextTick(() => {
|
|
155
|
+
isOutside.value = true;
|
|
156
|
+
onBlur();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
__name(onEmitModelValue, "onEmitModelValue");
|
|
160
|
+
function parseDate(value) {
|
|
161
|
+
const backupDate = /* @__PURE__ */ new Date();
|
|
162
|
+
return parse(value, innerFormat.value, {
|
|
163
|
+
locale: locale.value.formatLocale,
|
|
164
|
+
backupDate
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
__name(parseDate, "parseDate");
|
|
168
|
+
function formatDate(date) {
|
|
169
|
+
return format(date, innerFormat.value, {
|
|
170
|
+
locale: locale.value.formatLocale
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
__name(formatDate, "formatDate");
|
|
174
|
+
function valueToDate(value) {
|
|
175
|
+
switch (props.valueType) {
|
|
176
|
+
case "date":
|
|
177
|
+
return value instanceof Date ? new Date(value.getTime()) : /* @__PURE__ */ new Date(NaN);
|
|
178
|
+
case "timestamp":
|
|
179
|
+
return typeof value === "number" ? new Date(value) : /* @__PURE__ */ new Date(NaN);
|
|
180
|
+
case "string":
|
|
181
|
+
return typeof value === "string" ? parseDate(value) : /* @__PURE__ */ new Date(NaN);
|
|
182
|
+
default:
|
|
183
|
+
return typeof value === "string" ? parseDate(value) : /* @__PURE__ */ new Date(NaN);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
__name(valueToDate, "valueToDate");
|
|
187
|
+
function dateToValue(date) {
|
|
188
|
+
if (!isValidDate(date))
|
|
189
|
+
return null;
|
|
190
|
+
switch (props.valueType) {
|
|
191
|
+
case "date":
|
|
192
|
+
return date;
|
|
193
|
+
case "timestamp":
|
|
194
|
+
return date.getTime();
|
|
195
|
+
case "string":
|
|
196
|
+
return formatDate(date);
|
|
197
|
+
default:
|
|
198
|
+
return formatDate(date);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
__name(dateToValue, "dateToValue");
|
|
202
|
+
function isValidValue(value) {
|
|
203
|
+
if (isUseRange.value)
|
|
204
|
+
return isValidRangeDate(value);
|
|
205
|
+
return isValidDate(value);
|
|
206
|
+
}
|
|
207
|
+
__name(isValidValue, "isValidValue");
|
|
208
|
+
function isValidValueAndNotDisabled(value) {
|
|
209
|
+
if (!isValidValue(value))
|
|
210
|
+
return false;
|
|
211
|
+
const disabledDate = typeof props.disabledDate === "function" ? props.disabledDate : () => false;
|
|
212
|
+
if (!Array.isArray(value)) {
|
|
213
|
+
value = [value];
|
|
214
|
+
}
|
|
215
|
+
return value.every((v) => !disabledDate(v));
|
|
216
|
+
}
|
|
217
|
+
__name(isValidValueAndNotDisabled, "isValidValueAndNotDisabled");
|
|
218
|
+
const rootAttrs = {
|
|
219
|
+
style: {
|
|
220
|
+
width: "100%",
|
|
221
|
+
position: "relative"
|
|
222
|
+
},
|
|
223
|
+
onMouseenter: () => {
|
|
224
|
+
isOutside.value = false;
|
|
225
|
+
},
|
|
226
|
+
onMouseleave: () => {
|
|
227
|
+
isOutside.value = true;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
return {
|
|
231
|
+
rootAttrs,
|
|
232
|
+
isOutside,
|
|
233
|
+
isPopoverOpen,
|
|
234
|
+
currentLabel,
|
|
235
|
+
userInput,
|
|
236
|
+
innerFormat,
|
|
237
|
+
innerValueDate,
|
|
238
|
+
innerValue,
|
|
239
|
+
isUseRange,
|
|
240
|
+
onOpenPopover,
|
|
241
|
+
onClosePopover,
|
|
242
|
+
onClear,
|
|
243
|
+
onInputChange,
|
|
244
|
+
getId,
|
|
245
|
+
onBlur,
|
|
246
|
+
handleForceFocusToInput,
|
|
247
|
+
text,
|
|
248
|
+
locale,
|
|
249
|
+
isInnerInvalid,
|
|
250
|
+
onEmitModelValue
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
__name(useDatePicker, "useDatePicker");
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
useDatePicker
|
|
257
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Month
|
|
3
|
+
} from "./chunk-3VROFGJH.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-month.tsx
|
|
15
|
+
import { createVNode as _createVNode } from "vue";
|
|
16
|
+
import { defineComponent, computed } from "vue";
|
|
17
|
+
import { MpButton } from "@mekari/pixel3-button";
|
|
18
|
+
import { tableMonthSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
19
|
+
var TableMonth = defineComponent({
|
|
20
|
+
name: "TableMonth",
|
|
21
|
+
props: {
|
|
22
|
+
calendar: {
|
|
23
|
+
type: Date,
|
|
24
|
+
default: () => /* @__PURE__ */ new Date()
|
|
25
|
+
},
|
|
26
|
+
months: {
|
|
27
|
+
type: Array,
|
|
28
|
+
default: () => []
|
|
29
|
+
},
|
|
30
|
+
headerLabel: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ""
|
|
33
|
+
},
|
|
34
|
+
shortcutLabel: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
38
|
+
getMonthStatus: {
|
|
39
|
+
type: Function,
|
|
40
|
+
default: () => {
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
isShowShortcut: {
|
|
44
|
+
type: Boolean
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
emits: ["next", "previous", "select", "clickHeaderLabel", "mouseEnter", "mouseLeave"],
|
|
48
|
+
setup(props, {
|
|
49
|
+
emit
|
|
50
|
+
}) {
|
|
51
|
+
const {
|
|
52
|
+
headerRoot,
|
|
53
|
+
headerLabel,
|
|
54
|
+
monthItemRoot,
|
|
55
|
+
monthItemWrapper,
|
|
56
|
+
shortcutLabelWrapper
|
|
57
|
+
} = tableMonthSlotRecipe();
|
|
58
|
+
const getMonths = computed(() => {
|
|
59
|
+
return chunk(props.months, 3);
|
|
60
|
+
});
|
|
61
|
+
const getCalendarYear = computed(() => props.calendar.getFullYear());
|
|
62
|
+
function onNextButton() {
|
|
63
|
+
emit("next");
|
|
64
|
+
}
|
|
65
|
+
__name(onNextButton, "onNextButton");
|
|
66
|
+
function onPreviousButton() {
|
|
67
|
+
emit("previous", "previousMonth");
|
|
68
|
+
}
|
|
69
|
+
__name(onPreviousButton, "onPreviousButton");
|
|
70
|
+
function onSelectMonth(month, year) {
|
|
71
|
+
emit("select", month, year);
|
|
72
|
+
}
|
|
73
|
+
__name(onSelectMonth, "onSelectMonth");
|
|
74
|
+
function getMonthAttrs(month) {
|
|
75
|
+
const {
|
|
76
|
+
status,
|
|
77
|
+
isDisabled
|
|
78
|
+
} = props.getMonthStatus(month, getCalendarYear.value);
|
|
79
|
+
return {
|
|
80
|
+
status: isDisabled ? "disabled" : status,
|
|
81
|
+
isDisabled,
|
|
82
|
+
onClick: () => onSelectMonth(month, getCalendarYear.value),
|
|
83
|
+
onMouseenter: () => {
|
|
84
|
+
emit("mouseEnter", createDate(getCalendarYear.value, month));
|
|
85
|
+
},
|
|
86
|
+
onMouseleave: () => {
|
|
87
|
+
emit("mouseLeave");
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
__name(getMonthAttrs, "getMonthAttrs");
|
|
92
|
+
return () => {
|
|
93
|
+
return _createVNode("div", null, [_createVNode("div", {
|
|
94
|
+
"data-pixel-parts": "Header",
|
|
95
|
+
"class": headerRoot
|
|
96
|
+
}, [_createVNode(MpButton, {
|
|
97
|
+
"left-icon": "chevrons-left",
|
|
98
|
+
"variant": "ghost",
|
|
99
|
+
"size": "sm",
|
|
100
|
+
"onClick": onPreviousButton
|
|
101
|
+
}, null), _createVNode("button", {
|
|
102
|
+
"class": headerLabel,
|
|
103
|
+
"onClick": () => emit("clickHeaderLabel")
|
|
104
|
+
}, [props.headerLabel]), _createVNode(MpButton, {
|
|
105
|
+
"right-icon": "chevrons-right",
|
|
106
|
+
"variant": "ghost",
|
|
107
|
+
"size": "sm",
|
|
108
|
+
"onClick": onNextButton
|
|
109
|
+
}, null)]), _createVNode("div", {
|
|
110
|
+
"data-pixel-parts": "Content",
|
|
111
|
+
"class": monthItemRoot
|
|
112
|
+
}, [getMonths.value.map((data) => _createVNode("div", {
|
|
113
|
+
"class": monthItemWrapper
|
|
114
|
+
}, [data.map((month) => _createVNode(Month, getMonthAttrs(month.month), {
|
|
115
|
+
default: () => [" ", month.text, " "]
|
|
116
|
+
}))]))]), props.isShowShortcut && _createVNode("div", {
|
|
117
|
+
"data-pixel-parts": "Shortcut",
|
|
118
|
+
"class": shortcutLabelWrapper
|
|
119
|
+
}, [_createVNode(MpButton, {
|
|
120
|
+
"variant": "ghost",
|
|
121
|
+
"onClick": () => onSelectMonth((/* @__PURE__ */ new Date()).getMonth(), getCalendarYear.value)
|
|
122
|
+
}, {
|
|
123
|
+
default: () => [props.shortcutLabel]
|
|
124
|
+
})])]);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
TableMonth
|
|
131
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/components/parts/day.tsx
|
|
2
|
+
import { createVNode as _createVNode } from "vue";
|
|
3
|
+
import { defineComponent } from "vue";
|
|
4
|
+
import { dayItemRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
5
|
+
var Day = defineComponent({
|
|
6
|
+
name: "Day",
|
|
7
|
+
setup(props, {
|
|
8
|
+
slots
|
|
9
|
+
}) {
|
|
10
|
+
return () => {
|
|
11
|
+
return _createVNode("div", {
|
|
12
|
+
"class": dayItemRecipe()
|
|
13
|
+
}, [slots.default()]);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
Day
|
|
20
|
+
};
|