@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,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getNextMonth,
|
|
3
|
+
startOfMonth
|
|
4
|
+
} from "./chunk-26Y3AVJW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__name
|
|
7
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
8
|
+
|
|
9
|
+
// src/composables/useCalendarRange.ts
|
|
10
|
+
import { ref, computed } from "vue";
|
|
11
|
+
function useCalendarRange(props) {
|
|
12
|
+
const leftCalendar = startOfMonth(/* @__PURE__ */ new Date());
|
|
13
|
+
const rightCalendar = startOfMonth(getNextMonth(/* @__PURE__ */ new Date()));
|
|
14
|
+
const startDate = ref(props.modelValue[0]);
|
|
15
|
+
const endDate = ref(props.modelValue[1]);
|
|
16
|
+
const hoveredDate = ref();
|
|
17
|
+
const calendars = ref([leftCalendar, rightCalendar]);
|
|
18
|
+
const getCurrentDates = computed(() => {
|
|
19
|
+
if (startDate.value && !endDate.value)
|
|
20
|
+
return [startDate.value];
|
|
21
|
+
if (startDate.value && endDate.value)
|
|
22
|
+
return [startDate.value, endDate.value];
|
|
23
|
+
return [];
|
|
24
|
+
});
|
|
25
|
+
const calendarMinDiff = computed(() => {
|
|
26
|
+
const map = {
|
|
27
|
+
date: 1,
|
|
28
|
+
// type:date min 1 month
|
|
29
|
+
month: 1 * 12,
|
|
30
|
+
// type:month min 1 year
|
|
31
|
+
year: 10 * 12
|
|
32
|
+
// type:year min 10 year
|
|
33
|
+
};
|
|
34
|
+
return map[props.type] || map.date;
|
|
35
|
+
});
|
|
36
|
+
const calendarMaxDiff = computed(() => Infinity);
|
|
37
|
+
function setStartDate(date) {
|
|
38
|
+
startDate.value = date;
|
|
39
|
+
}
|
|
40
|
+
__name(setStartDate, "setStartDate");
|
|
41
|
+
function setEndDate(date) {
|
|
42
|
+
endDate.value = date;
|
|
43
|
+
}
|
|
44
|
+
__name(setEndDate, "setEndDate");
|
|
45
|
+
function setHoveredDate(date) {
|
|
46
|
+
hoveredDate.value = date;
|
|
47
|
+
}
|
|
48
|
+
__name(setHoveredDate, "setHoveredDate");
|
|
49
|
+
function getDateRangeStatus(cellDate) {
|
|
50
|
+
const status = {
|
|
51
|
+
inRange: false,
|
|
52
|
+
hoverInRange: false,
|
|
53
|
+
activeDragRange: false
|
|
54
|
+
};
|
|
55
|
+
const isInRange = /* @__PURE__ */ __name((data, range, fn = (v) => v.getTime()) => {
|
|
56
|
+
const value = fn(data);
|
|
57
|
+
let [min, max] = range.map(fn);
|
|
58
|
+
if (min > max) {
|
|
59
|
+
[min, max] = [max, min];
|
|
60
|
+
}
|
|
61
|
+
return value > min && value < max;
|
|
62
|
+
}, "isInRange");
|
|
63
|
+
if (getCurrentDates.value.length === 2 && isInRange(cellDate, getCurrentDates.value)) {
|
|
64
|
+
status.inRange = true;
|
|
65
|
+
}
|
|
66
|
+
if (getCurrentDates.value.length === 1 && hoveredDate.value && isInRange(cellDate, [getCurrentDates.value[0], hoveredDate.value])) {
|
|
67
|
+
status.hoverInRange = true;
|
|
68
|
+
}
|
|
69
|
+
if (getCurrentDates.value[0]) {
|
|
70
|
+
status.activeDragRange = true;
|
|
71
|
+
}
|
|
72
|
+
return status;
|
|
73
|
+
}
|
|
74
|
+
__name(getDateRangeStatus, "getDateRangeStatus");
|
|
75
|
+
function updateStartCalendar(value) {
|
|
76
|
+
updateCalendars([value, calendars.value[1]], 1);
|
|
77
|
+
}
|
|
78
|
+
__name(updateStartCalendar, "updateStartCalendar");
|
|
79
|
+
function updateEndCalendar(value) {
|
|
80
|
+
updateCalendars([calendars.value[0], value], 0);
|
|
81
|
+
}
|
|
82
|
+
__name(updateEndCalendar, "updateEndCalendar");
|
|
83
|
+
function updateCalendars(value, adjustIndex = 1) {
|
|
84
|
+
const gap = getCalendarGap(value);
|
|
85
|
+
if (gap) {
|
|
86
|
+
const calendar = new Date(value[adjustIndex]);
|
|
87
|
+
calendar.setMonth(calendar.getMonth() + (adjustIndex === 0 ? -gap : gap));
|
|
88
|
+
value[adjustIndex] = calendar;
|
|
89
|
+
}
|
|
90
|
+
calendars.value = value;
|
|
91
|
+
}
|
|
92
|
+
__name(updateCalendars, "updateCalendars");
|
|
93
|
+
function getCalendarGap(calendars2) {
|
|
94
|
+
const [calendarLeft, calendarRight] = calendars2;
|
|
95
|
+
const yearDiff = calendarRight.getFullYear() - calendarLeft.getFullYear();
|
|
96
|
+
const monthDiff = calendarRight.getMonth() - calendarLeft.getMonth();
|
|
97
|
+
const diff = yearDiff * 12 + monthDiff;
|
|
98
|
+
const min = calendarMinDiff.value;
|
|
99
|
+
const max = calendarMaxDiff.value;
|
|
100
|
+
if (diff < min) {
|
|
101
|
+
return min - diff;
|
|
102
|
+
}
|
|
103
|
+
if (diff > max) {
|
|
104
|
+
return max - diff;
|
|
105
|
+
}
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
__name(getCalendarGap, "getCalendarGap");
|
|
109
|
+
return {
|
|
110
|
+
startDate,
|
|
111
|
+
endDate,
|
|
112
|
+
hoveredDate,
|
|
113
|
+
calendars,
|
|
114
|
+
getCurrentDates,
|
|
115
|
+
setStartDate,
|
|
116
|
+
setEndDate,
|
|
117
|
+
setHoveredDate,
|
|
118
|
+
getDateRangeStatus,
|
|
119
|
+
updateStartCalendar,
|
|
120
|
+
updateEndCalendar
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
__name(useCalendarRange, "useCalendarRange");
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
useCalendarRange
|
|
127
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Day
|
|
3
|
+
} from "./chunk-AGAA7XTC.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Date as Date2
|
|
6
|
+
} from "./chunk-J5BK7Z2U.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-date.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 { tableDateSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
19
|
+
var TableDate = defineComponent({
|
|
20
|
+
name: "TableDate",
|
|
21
|
+
props: {
|
|
22
|
+
days: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
dates: {
|
|
27
|
+
type: Array,
|
|
28
|
+
default: () => []
|
|
29
|
+
},
|
|
30
|
+
headerLabel: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ""
|
|
33
|
+
},
|
|
34
|
+
shortcutLabel: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
38
|
+
getDateStatus: {
|
|
39
|
+
type: Function,
|
|
40
|
+
default: () => {
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
isShowShortcut: {
|
|
44
|
+
type: Boolean
|
|
45
|
+
},
|
|
46
|
+
isRange: {
|
|
47
|
+
type: Boolean
|
|
48
|
+
},
|
|
49
|
+
isHideNotThisMonthDate: {
|
|
50
|
+
type: Boolean
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
emits: ["next", "previous", "changePanel", "select", "clickHeaderLabel", "mouseEnter", "mouseLeave"],
|
|
54
|
+
setup(props, {
|
|
55
|
+
emit
|
|
56
|
+
}) {
|
|
57
|
+
const {
|
|
58
|
+
headerRoot,
|
|
59
|
+
headerLabel,
|
|
60
|
+
dayWrapper,
|
|
61
|
+
dateItemRoot,
|
|
62
|
+
dateItemWrapper,
|
|
63
|
+
shortcutLabelWrapper
|
|
64
|
+
} = tableDateSlotRecipe();
|
|
65
|
+
const getDates = computed(() => {
|
|
66
|
+
return chunk(props.dates, 7);
|
|
67
|
+
});
|
|
68
|
+
function onNextButton() {
|
|
69
|
+
emit("next");
|
|
70
|
+
}
|
|
71
|
+
__name(onNextButton, "onNextButton");
|
|
72
|
+
function onPreviousButton() {
|
|
73
|
+
emit("previous");
|
|
74
|
+
}
|
|
75
|
+
__name(onPreviousButton, "onPreviousButton");
|
|
76
|
+
function onSelectDate(date) {
|
|
77
|
+
emit("select", date);
|
|
78
|
+
}
|
|
79
|
+
__name(onSelectDate, "onSelectDate");
|
|
80
|
+
function onSelectToday() {
|
|
81
|
+
const today = /* @__PURE__ */ new Date();
|
|
82
|
+
onSelectDate(today);
|
|
83
|
+
}
|
|
84
|
+
__name(onSelectToday, "onSelectToday");
|
|
85
|
+
function getDateAttrs(date) {
|
|
86
|
+
const {
|
|
87
|
+
status,
|
|
88
|
+
isDisabled,
|
|
89
|
+
isShowPinbar
|
|
90
|
+
} = props.getDateStatus(date);
|
|
91
|
+
return {
|
|
92
|
+
status: isDisabled ? "disabled" : status,
|
|
93
|
+
isDisabled,
|
|
94
|
+
isShowPinbar,
|
|
95
|
+
onClick: () => onSelectDate(date),
|
|
96
|
+
onMouseenter: () => {
|
|
97
|
+
emit("mouseEnter", date);
|
|
98
|
+
},
|
|
99
|
+
onMouseleave: () => {
|
|
100
|
+
emit("mouseLeave");
|
|
101
|
+
},
|
|
102
|
+
style: {
|
|
103
|
+
visibility: props.isHideNotThisMonthDate && status === "notThisMonth" ? "hidden" : ""
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
__name(getDateAttrs, "getDateAttrs");
|
|
108
|
+
return () => {
|
|
109
|
+
return _createVNode("div", null, [_createVNode("div", {
|
|
110
|
+
"data-pixel-parts": "Header",
|
|
111
|
+
"class": headerRoot
|
|
112
|
+
}, [_createVNode(MpButton, {
|
|
113
|
+
"left-icon": "chevrons-left",
|
|
114
|
+
"variant": "ghost",
|
|
115
|
+
"size": "sm",
|
|
116
|
+
"onClick": onPreviousButton
|
|
117
|
+
}, null), _createVNode("button", {
|
|
118
|
+
"class": headerLabel,
|
|
119
|
+
"onClick": () => emit("clickHeaderLabel")
|
|
120
|
+
}, [props.headerLabel]), _createVNode(MpButton, {
|
|
121
|
+
"right-icon": "chevrons-right",
|
|
122
|
+
"variant": "ghost",
|
|
123
|
+
"size": "sm",
|
|
124
|
+
"onClick": onNextButton
|
|
125
|
+
}, null)]), _createVNode("div", {
|
|
126
|
+
"data-pixel-parts": "Content",
|
|
127
|
+
"class": dayWrapper
|
|
128
|
+
}, [props.days.map((day) => _createVNode(Day, null, {
|
|
129
|
+
default: () => [_createTextVNode(" "), day, _createTextVNode(" ")]
|
|
130
|
+
}))]), _createVNode("div", {
|
|
131
|
+
"data-pixel-parts": "Content",
|
|
132
|
+
"class": dateItemRoot
|
|
133
|
+
}, [getDates.value.map((dates, index) => _createVNode("div", {
|
|
134
|
+
"class": dateItemWrapper,
|
|
135
|
+
"data-row-index": index
|
|
136
|
+
}, [dates.map((date) => _createVNode(Date2, getDateAttrs(date), {
|
|
137
|
+
default: () => [_createTextVNode(" "), date.getDate(), _createTextVNode(" ")]
|
|
138
|
+
}))]))]), props.isShowShortcut && _createVNode("div", {
|
|
139
|
+
"data-pixel-parts": "Shortcut",
|
|
140
|
+
"class": shortcutLabelWrapper
|
|
141
|
+
}, [_createVNode(MpButton, {
|
|
142
|
+
"variant": "ghost",
|
|
143
|
+
"onClick": onSelectToday
|
|
144
|
+
}, {
|
|
145
|
+
default: () => [props.shortcutLabel]
|
|
146
|
+
})])]);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
TableDate
|
|
153
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
4
|
+
|
|
5
|
+
// src/utils/base.ts
|
|
6
|
+
function chunk(arr, size) {
|
|
7
|
+
if (!Array.isArray(arr)) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
const result = [];
|
|
11
|
+
const len = arr.length;
|
|
12
|
+
let i = 0;
|
|
13
|
+
size = size || len;
|
|
14
|
+
while (i < len) {
|
|
15
|
+
result.push(arr.slice(i, i += size));
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
__name(chunk, "chunk");
|
|
20
|
+
var isObject = /* @__PURE__ */ __name((value) => {
|
|
21
|
+
return !!value && value.constructor === Object;
|
|
22
|
+
}, "isObject");
|
|
23
|
+
var pick = /* @__PURE__ */ __name((obj, keys) => {
|
|
24
|
+
if (!obj)
|
|
25
|
+
return {};
|
|
26
|
+
return keys.reduce((acc, key) => {
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
28
|
+
acc[key] = obj[key];
|
|
29
|
+
return acc;
|
|
30
|
+
}, {});
|
|
31
|
+
}, "pick");
|
|
32
|
+
var assign = /* @__PURE__ */ __name((initial, override) => {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!initial || !override)
|
|
35
|
+
return (_a = initial != null ? initial : override) != null ? _a : {};
|
|
36
|
+
return Object.entries({
|
|
37
|
+
...initial,
|
|
38
|
+
...override
|
|
39
|
+
}).reduce((acc, [key, value]) => {
|
|
40
|
+
return {
|
|
41
|
+
...acc,
|
|
42
|
+
[key]: (() => {
|
|
43
|
+
if (isObject(initial[key]))
|
|
44
|
+
return assign(initial[key], value);
|
|
45
|
+
return value;
|
|
46
|
+
})()
|
|
47
|
+
};
|
|
48
|
+
}, {});
|
|
49
|
+
}, "assign");
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
chunk,
|
|
53
|
+
isObject,
|
|
54
|
+
pick,
|
|
55
|
+
assign
|
|
56
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCalendar,
|
|
3
|
+
getNextMonth,
|
|
4
|
+
getPreviousMonth,
|
|
5
|
+
isValidDate
|
|
6
|
+
} from "./chunk-26Y3AVJW.mjs";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
10
|
+
|
|
11
|
+
// src/composables/useCalendar.ts
|
|
12
|
+
import { computed, ref } from "vue";
|
|
13
|
+
import { setYear, addYears, setMonth } from "date-fns";
|
|
14
|
+
function useCalendar(date, locale) {
|
|
15
|
+
const currentDate = ref(isValidDate(date) ? date : /* @__PURE__ */ new Date());
|
|
16
|
+
const currentPanel = ref("date");
|
|
17
|
+
const nextMonth = /* @__PURE__ */ __name(() => {
|
|
18
|
+
currentDate.value = getNextMonth(currentDate.value);
|
|
19
|
+
}, "nextMonth");
|
|
20
|
+
const previousMonth = /* @__PURE__ */ __name(() => {
|
|
21
|
+
currentDate.value = getPreviousMonth(currentDate.value);
|
|
22
|
+
}, "previousMonth");
|
|
23
|
+
const nextYear = /* @__PURE__ */ __name(() => {
|
|
24
|
+
currentDate.value = addYears(currentDate.value, 1);
|
|
25
|
+
}, "nextYear");
|
|
26
|
+
const previousYear = /* @__PURE__ */ __name(() => {
|
|
27
|
+
currentDate.value = addYears(currentDate.value, -1);
|
|
28
|
+
}, "previousYear");
|
|
29
|
+
const changeYear = /* @__PURE__ */ __name((year) => {
|
|
30
|
+
currentDate.value = setYear(currentDate.value, year);
|
|
31
|
+
}, "changeYear");
|
|
32
|
+
const changeMonth = /* @__PURE__ */ __name((month) => {
|
|
33
|
+
currentDate.value = setMonth(currentDate.value, month);
|
|
34
|
+
}, "changeMonth");
|
|
35
|
+
const getSplitDates = computed(() => {
|
|
36
|
+
return {
|
|
37
|
+
day: currentDate.value.getDay(),
|
|
38
|
+
month: currentDate.value.getMonth(),
|
|
39
|
+
year: currentDate.value.getFullYear(),
|
|
40
|
+
monthLabel: locale.value.months[currentDate.value.getMonth()]
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const getDates = computed(() => {
|
|
44
|
+
const {
|
|
45
|
+
year,
|
|
46
|
+
month
|
|
47
|
+
} = getSplitDates.value;
|
|
48
|
+
const arr = getCalendar({
|
|
49
|
+
firstDayOfWeek: locale.value.formatLocale.firstDayOfWeek || 0,
|
|
50
|
+
year,
|
|
51
|
+
month
|
|
52
|
+
});
|
|
53
|
+
return arr;
|
|
54
|
+
});
|
|
55
|
+
const getMonths = computed(() => {
|
|
56
|
+
const monthsLocale = locale.value.formatLocale.monthsShort || locale.value.months;
|
|
57
|
+
const months = monthsLocale.map((text, month) => {
|
|
58
|
+
return {
|
|
59
|
+
text,
|
|
60
|
+
month
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
return months;
|
|
64
|
+
});
|
|
65
|
+
const getYears = computed(() => {
|
|
66
|
+
const {
|
|
67
|
+
year
|
|
68
|
+
} = getSplitDates.value;
|
|
69
|
+
const firstYear = Math.floor(year / 10) * 10;
|
|
70
|
+
const years = [];
|
|
71
|
+
for (let i = 0; i < 10; i++) {
|
|
72
|
+
years.push(firstYear + i);
|
|
73
|
+
}
|
|
74
|
+
return years;
|
|
75
|
+
});
|
|
76
|
+
const getLabel = computed(() => {
|
|
77
|
+
const {
|
|
78
|
+
year,
|
|
79
|
+
monthLabel
|
|
80
|
+
} = getSplitDates.value;
|
|
81
|
+
if (currentPanel.value === "date")
|
|
82
|
+
return `${monthLabel} ${year}`;
|
|
83
|
+
if (currentPanel.value === "month")
|
|
84
|
+
return `${year}`;
|
|
85
|
+
if (currentPanel.value === "year")
|
|
86
|
+
return `${getYears.value[0]} - ${getYears.value[9]}`;
|
|
87
|
+
return "";
|
|
88
|
+
});
|
|
89
|
+
function changePanel(value) {
|
|
90
|
+
currentPanel.value = value;
|
|
91
|
+
}
|
|
92
|
+
__name(changePanel, "changePanel");
|
|
93
|
+
function setPanelDate(date2) {
|
|
94
|
+
currentDate.value = date2;
|
|
95
|
+
}
|
|
96
|
+
__name(setPanelDate, "setPanelDate");
|
|
97
|
+
return {
|
|
98
|
+
currentDate,
|
|
99
|
+
currentPanel,
|
|
100
|
+
nextMonth,
|
|
101
|
+
previousMonth,
|
|
102
|
+
nextYear,
|
|
103
|
+
previousYear,
|
|
104
|
+
changeYear,
|
|
105
|
+
changeMonth,
|
|
106
|
+
getDates,
|
|
107
|
+
getMonths,
|
|
108
|
+
getYears,
|
|
109
|
+
getLabel,
|
|
110
|
+
getSplitDates,
|
|
111
|
+
changePanel,
|
|
112
|
+
setPanelDate
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
__name(useCalendar, "useCalendar");
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
useCalendar
|
|
119
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assign
|
|
3
|
+
} from "./chunk-NIUQXHGQ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
7
|
+
|
|
8
|
+
// src/modules/date-picker.locales.ts
|
|
9
|
+
import en from "date-format-parse/lib/locale/en";
|
|
10
|
+
var locales = {
|
|
11
|
+
formatLocale: en,
|
|
12
|
+
days: en.weekdaysMin,
|
|
13
|
+
months: en.monthsShort,
|
|
14
|
+
yearFormat: "YYYY",
|
|
15
|
+
monthFormat: "MMM",
|
|
16
|
+
monthBeforeYear: true,
|
|
17
|
+
todayText: "Today",
|
|
18
|
+
thisMonthText: "This Month",
|
|
19
|
+
thisYearText: "This Year"
|
|
20
|
+
};
|
|
21
|
+
function getLocale(config) {
|
|
22
|
+
if (!config) {
|
|
23
|
+
return locales;
|
|
24
|
+
}
|
|
25
|
+
return assign(locales, config);
|
|
26
|
+
}
|
|
27
|
+
__name(getLocale, "getLocale");
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
getLocale
|
|
31
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/modules/date-picker.props.ts
|
|
2
|
+
var calendarPanelProps = {
|
|
3
|
+
modelValue: {
|
|
4
|
+
type: Date
|
|
5
|
+
},
|
|
6
|
+
defaultValue: {
|
|
7
|
+
type: Date
|
|
8
|
+
},
|
|
9
|
+
type: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: "date"
|
|
12
|
+
},
|
|
13
|
+
calendar: {
|
|
14
|
+
type: Date
|
|
15
|
+
},
|
|
16
|
+
isRange: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
20
|
+
isShowShortcut: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: true
|
|
23
|
+
},
|
|
24
|
+
disabledDate: {
|
|
25
|
+
type: Function,
|
|
26
|
+
default: () => {
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
disabledMonth: {
|
|
30
|
+
type: Function,
|
|
31
|
+
default: () => {
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
disabledYear: {
|
|
35
|
+
type: Function,
|
|
36
|
+
default: () => {
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
getDateStatus: {
|
|
40
|
+
type: Function,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
getMonthStatus: {
|
|
44
|
+
type: Function,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
getYearStatus: {
|
|
48
|
+
type: Function,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
isHideNotThisMonthDate: {
|
|
52
|
+
type: Boolean
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var calendarPanelRangeProps = {
|
|
56
|
+
...calendarPanelProps,
|
|
57
|
+
modelValue: {
|
|
58
|
+
type: Array
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var datePickerProps = {
|
|
62
|
+
id: {
|
|
63
|
+
type: String
|
|
64
|
+
},
|
|
65
|
+
modelValue: {
|
|
66
|
+
type: [String, Number, Date, Array]
|
|
67
|
+
},
|
|
68
|
+
type: calendarPanelProps.type,
|
|
69
|
+
valueType: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: "date"
|
|
72
|
+
},
|
|
73
|
+
format: {
|
|
74
|
+
type: String
|
|
75
|
+
},
|
|
76
|
+
rangeSeparator: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: " - "
|
|
79
|
+
},
|
|
80
|
+
placeholder: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: ""
|
|
83
|
+
},
|
|
84
|
+
errorMessage: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: "Format tanggal/waktu salah"
|
|
87
|
+
},
|
|
88
|
+
disabledMessage: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: ""
|
|
91
|
+
},
|
|
92
|
+
lang: {
|
|
93
|
+
type: Object,
|
|
94
|
+
default: () => {
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
inputAttr: {
|
|
98
|
+
type: Object,
|
|
99
|
+
default: () => ({})
|
|
100
|
+
},
|
|
101
|
+
contentAttr: {
|
|
102
|
+
type: Object,
|
|
103
|
+
default: () => ({})
|
|
104
|
+
},
|
|
105
|
+
isRange: calendarPanelProps.isRange,
|
|
106
|
+
isReadOnly: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: false
|
|
109
|
+
},
|
|
110
|
+
isDisabled: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: false
|
|
113
|
+
},
|
|
114
|
+
isClearable: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: true
|
|
117
|
+
},
|
|
118
|
+
isInvalid: {
|
|
119
|
+
type: Boolean,
|
|
120
|
+
default: false
|
|
121
|
+
},
|
|
122
|
+
usePortal: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: false
|
|
125
|
+
},
|
|
126
|
+
isKeepAlive: {
|
|
127
|
+
type: Boolean,
|
|
128
|
+
default: false
|
|
129
|
+
},
|
|
130
|
+
isInline: {
|
|
131
|
+
type: Boolean,
|
|
132
|
+
default: false
|
|
133
|
+
},
|
|
134
|
+
isNotClickable: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
default: false
|
|
137
|
+
},
|
|
138
|
+
isDisableHeader: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
default: false
|
|
141
|
+
},
|
|
142
|
+
isShowShortcut: {
|
|
143
|
+
type: Boolean,
|
|
144
|
+
default: false
|
|
145
|
+
},
|
|
146
|
+
disabledDate: calendarPanelProps.disabledDate,
|
|
147
|
+
disabledMonth: calendarPanelProps.disabledMonth,
|
|
148
|
+
disabledYear: calendarPanelProps.disabledYear
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
calendarPanelProps,
|
|
153
|
+
calendarPanelRangeProps,
|
|
154
|
+
datePickerProps
|
|
155
|
+
};
|