@nutui/nutui 3.1.22 → 3.1.23-beta.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/nutui.es.js +20418 -4214
- package/dist/nutui.umd.js +20524 -4216
- package/dist/packages/_es/ActionSheet.js +149 -17
- package/dist/packages/_es/Address.js +535 -110
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +59 -17
- package/dist/packages/_es/Audio.js +257 -53
- package/dist/packages/_es/AudioOperate.js +100 -13
- package/dist/packages/_es/Avatar.js +162 -38
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -30
- package/dist/packages/_es/CalendarItem.js +1 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -147
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +109 -32
- package/dist/packages/_es/CollapseItem.js +253 -59
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +20 -8
- package/dist/packages/_es/CountDown.js +238 -56
- package/dist/packages/_es/CountUp.js +539 -140
- package/dist/packages/_es/DatePicker.js +315 -98
- package/dist/packages/_es/Dialog.js +289 -60
- package/dist/packages/_es/Divider.js +65 -13
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -58
- package/dist/packages/_es/Ellipsis.js +200 -58
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +137 -26
- package/dist/packages/_es/ImagePreview.js +547 -76
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -57
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -18
- package/dist/packages/_es/Menu.js +168 -44
- package/dist/packages/_es/MenuItem.js +173 -37
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -74
- package/dist/packages/_es/Notify.js +227 -72
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -130
- package/dist/packages/_es/OverLay.js +98 -24
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +460 -129
- package/dist/packages/_es/Popover.js +957 -318
- package/dist/packages/_es/Popup.js +299 -55
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -84
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -83
- package/dist/packages/_es/Rate.js +192 -36
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -37
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -24
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -41
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -84
- package/dist/packages/_es/Step.js +115 -20
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -17
- package/dist/packages/_es/Swipe.js +178 -41
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -18
- package/dist/packages/_es/Tabs.js +202 -43
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -18
- package/dist/packages/_es/TimePannel.js +48 -14
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -71
- package/dist/packages/_es/Uploader.js +455 -104
- package/dist/packages/_es/Video.js +332 -74
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +780 -164
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/imagepreview/index.scss +6 -1
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/smartips/attributes.json +8 -0
- package/dist/smartips/tags.json +3 -1
- package/dist/smartips/web-types.json +19 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +41 -41
- package/dist/styles/themes/jdb.scss +41 -41
- package/dist/styles/themes/jdt.scss +41 -41
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +5 -5
- package/dist/types/__VUE/address/index.vue.d.ts +7 -7
- package/dist/types/__VUE/avatar/index.vue.d.ts +4 -4
- package/dist/types/__VUE/avatargroup/index.vue.d.ts +2 -2
- package/dist/types/__VUE/backtop/index.vue.d.ts +2 -2
- package/dist/types/__VUE/badge/index.vue.d.ts +2 -2
- package/dist/types/__VUE/button/index.vue.d.ts +8 -8
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +4 -4
- package/dist/types/__VUE/cell/index.vue.d.ts +6 -6
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapseitem/index.vue.d.ts +2 -2
- package/dist/types/__VUE/comment/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +4 -4
- package/dist/types/__VUE/dialog/index.vue.d.ts +4 -4
- package/dist/types/__VUE/fixednav/index.vue.d.ts +4 -4
- package/dist/types/__VUE/grid/index.vue.d.ts +4 -4
- package/dist/types/__VUE/image/index.vue.d.ts +4 -4
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
- package/dist/types/__VUE/input/index.vue.d.ts +4 -4
- package/dist/types/__VUE/inputnumber/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/noticebar/index.vue.d.ts +3 -3
- package/dist/types/__VUE/notify/index.vue.d.ts +2 -2
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +5 -5
- package/dist/types/__VUE/picker/Column.vue.d.ts +1 -1
- package/dist/types/__VUE/picker/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
- package/dist/types/__VUE/popup/index.vue.d.ts +6 -6
- package/dist/types/__VUE/radio/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +4 -4
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/skeleton/index.vue.d.ts +4 -4
- package/dist/types/__VUE/sku/index.vue.d.ts +5 -5
- package/dist/types/__VUE/step/index.vue.d.ts +2 -2
- package/dist/types/__VUE/sticky/index.vue.d.ts +4 -4
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/swiper/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbaritem/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tag/index.vue.d.ts +2 -2
- package/dist/types/__VUE/timeselect/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +4 -4
- package/dist/types/__VUE/uploader/index.vue.d.ts +4 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,174 +1,790 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { ref
|
|
7
|
-
import { c as
|
|
8
|
-
import { r as
|
|
9
|
-
import { u as
|
|
10
|
-
import { _ as
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} }, { create: T, translate: S } = y("calendar-item"), b = T({ props: { type: { type: String, default: "one" }, isAutoBackFill: { type: Boolean, default: false }, toDateAnimation: { type: Boolean, default: true }, poppable: { type: Boolean, default: true }, showTitle: { type: Boolean, default: true }, showSubTitle: { type: Boolean, default: true }, showToday: { type: Boolean, default: true }, title: { type: String, default: "" }, confirmText: { type: String, default: "" }, startText: { type: String, default: "" }, endText: { type: String, default: "" }, defaultValue: { type: [String, Array], default: null }, startDate: { type: String, default: v.getDay(0) }, endDate: { type: String, default: v.getDay(365) } }, emits: ["choose", "update", "close", "select"], setup(l2, { emit: o2, slots: s2 }) {
|
|
35
|
-
const c2 = t(S("weekdays")), u2 = t(null), i2 = t(null), D2 = t(null), h2 = t(null), p2 = t(0), m2 = e(() => T2.monthsData.slice(T2.defaultRange[0], T2.defaultRange[1])), d2 = e(() => s2.btn), y2 = e(() => s2.topInfo), w2 = e(() => s2.bottomInfo), T2 = a({ yearMonthTitle: "", defaultRange: [], currDate: "", propStartDate: "", propEndDate: "", unLoadPrev: false, touchParams: { startY: 0, endY: 0, startTime: 0, endTime: 0, lastY: 0, lastTime: 0 }, transformY: 0, translateY: 0, scrollDistance: 0, defaultData: [], chooseData: [], monthsData: [], dayPrefix: "calendar-month-day", startData: "", endData: "", isRange: l2.type === "range", timer: 0, currentIndex: 0, avgHeight: 0, monthsNum: 0 }), b2 = (t2) => t2.split("-"), x2 = (t2) => v.isEqual(T2.currDate[0], t2), $2 = (t2) => v.isEqual(T2.currDate[1], t2), k2 = (t2, e2) => e2.curData[0] + "-" + e2.curData[1] + "-" + v.getNumTwoBit(+t2.day), A2 = (t2, e2) => {
|
|
36
|
-
const a2 = k2(t2, e2), { type: r2 } = l2;
|
|
37
|
-
return t2.type == "curr" ? v.isEqual(T2.currDate, a2) || r2 == "range" && (x2(a2) || $2(a2)) || r2 == "multiple" && ((t3) => T2.currDate.length > 0 && T2.currDate.some((e3) => v.isEqual(e3, t3)))(a2) ? `${T2.dayPrefix}-active` : T2.propStartDate && v.compareDate(a2, T2.propStartDate) || T2.propEndDate && v.compareDate(T2.propEndDate, a2) ? `${T2.dayPrefix}-disabled` : r2 == "range" && Array.isArray(T2.currDate) && Object.values(T2.currDate).length == 2 && v.compareDate(T2.currDate[0], a2) && v.compareDate(a2, T2.currDate[1]) ? `${T2.dayPrefix}-choose` : null : `${T2.dayPrefix}-disabled`;
|
|
38
|
-
}, H2 = () => {
|
|
39
|
-
const { type: t2 } = l2;
|
|
40
|
-
if (t2 == "range" && T2.chooseData.length == 2 || t2 != "range") {
|
|
41
|
-
let t3 = T2.chooseData.slice(0);
|
|
42
|
-
o2("choose", t3), l2.poppable && o2("update");
|
|
6
|
+
import { ref, computed, reactive, watch, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, renderSlot, Fragment, renderList, normalizeStyle, createTextVNode } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { r as requestAniFrame } from "./raf.js";
|
|
9
|
+
import { u as useExpose } from "./index3.js";
|
|
10
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
11
|
+
const Utils = {
|
|
12
|
+
isLeapYear: function(y) {
|
|
13
|
+
return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
|
|
14
|
+
},
|
|
15
|
+
getWhatDay: function(year, month, day) {
|
|
16
|
+
const date = new Date(year + "/" + month + "/" + day);
|
|
17
|
+
const index = date.getDay();
|
|
18
|
+
const dayNames = [
|
|
19
|
+
"\u661F\u671F\u65E5",
|
|
20
|
+
"\u661F\u671F\u4E00",
|
|
21
|
+
"\u661F\u671F\u4E8C",
|
|
22
|
+
"\u661F\u671F\u4E09",
|
|
23
|
+
"\u661F\u671F\u56DB",
|
|
24
|
+
"\u661F\u671F\u4E94",
|
|
25
|
+
"\u661F\u671F\u516D"
|
|
26
|
+
];
|
|
27
|
+
return dayNames[index];
|
|
28
|
+
},
|
|
29
|
+
getMonthPreDay: function(year, month) {
|
|
30
|
+
const date = new Date(year + "/" + month + "/01");
|
|
31
|
+
let day = date.getDay();
|
|
32
|
+
if (day == 0) {
|
|
33
|
+
day = 7;
|
|
43
34
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (T2.currDate.length > 0) {
|
|
50
|
-
let t3 = "";
|
|
51
|
-
T2.currDate.forEach((e3, a3) => {
|
|
52
|
-
e3 == n2[3] && (t3 = a3);
|
|
53
|
-
}), a2 ? T2.chooseData.push([...n2]) : t3 !== "" ? (T2.currDate.splice(t3, 1), T2.chooseData.splice(t3, 1)) : (T2.currDate.push(n2[3]), T2.chooseData.push([...n2]));
|
|
54
|
-
} else
|
|
55
|
-
T2.currDate = [n2[3]], T2.chooseData = [[...n2]];
|
|
56
|
-
else if (r2 == "range") {
|
|
57
|
-
let t3 = Object.values(T2.currDate).length;
|
|
58
|
-
t3 == 2 || t3 == 0 ? T2.currDate = [n2[3]] : v.compareDate(T2.currDate[0], n2[3]) ? Array.isArray(T2.currDate) && T2.currDate.push(n2[3]) : Array.isArray(T2.currDate) && T2.currDate.unshift(n2[3]), T2.chooseData.length != 2 && T2.chooseData.length ? v.compareDate(T2.chooseData[0][3], n2[3]) ? T2.chooseData = [...T2.chooseData, [...n2]] : T2.chooseData = [[...n2], ...T2.chooseData] : T2.chooseData = [[...n2]];
|
|
59
|
-
} else
|
|
60
|
-
T2.currDate = n2[3], T2.chooseData = [...n2];
|
|
61
|
-
a2 || (o2("select", T2.chooseData), !l2.isAutoBackFill && l2.poppable || H2());
|
|
35
|
+
return day;
|
|
36
|
+
},
|
|
37
|
+
getMonthDays: function(year, month) {
|
|
38
|
+
if (/^0/.test(month)) {
|
|
39
|
+
month = month.split("")[1];
|
|
62
40
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
return [
|
|
42
|
+
0,
|
|
43
|
+
31,
|
|
44
|
+
this.isLeapYear(Number(year)) ? 29 : 28,
|
|
45
|
+
31,
|
|
46
|
+
30,
|
|
47
|
+
31,
|
|
48
|
+
30,
|
|
49
|
+
31,
|
|
50
|
+
31,
|
|
51
|
+
30,
|
|
52
|
+
31,
|
|
53
|
+
30,
|
|
54
|
+
31
|
|
55
|
+
][month];
|
|
56
|
+
},
|
|
57
|
+
getNumTwoBit: function(n) {
|
|
58
|
+
n = Number(n);
|
|
59
|
+
return (n > 9 ? "" : "0") + n;
|
|
60
|
+
},
|
|
61
|
+
date2Str: function(date, split) {
|
|
62
|
+
split = split || "-";
|
|
63
|
+
const y = date.getFullYear();
|
|
64
|
+
const m = this.getNumTwoBit(date.getMonth() + 1);
|
|
65
|
+
const d = this.getNumTwoBit(date.getDate());
|
|
66
|
+
return [y, m, d].join(split);
|
|
67
|
+
},
|
|
68
|
+
getDay: function(i) {
|
|
69
|
+
i = i || 0;
|
|
70
|
+
let date = new Date();
|
|
71
|
+
const diff = i * (1e3 * 60 * 60 * 24);
|
|
72
|
+
date = new Date(date.getTime() + diff);
|
|
73
|
+
return this.date2Str(date);
|
|
74
|
+
},
|
|
75
|
+
compareDate: function(date1, date2) {
|
|
76
|
+
const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
|
|
77
|
+
const endTime = new Date(date2.replace("-", "/").replace("-", "/"));
|
|
78
|
+
if (startTime >= endTime) {
|
|
79
|
+
return false;
|
|
72
80
|
}
|
|
73
|
-
return
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
81
|
+
return true;
|
|
82
|
+
},
|
|
83
|
+
isEqual: function(date1, date2) {
|
|
84
|
+
const startTime = new Date(date1).getTime();
|
|
85
|
+
const endTime = new Date(date2).getTime();
|
|
86
|
+
if (startTime == endTime) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const { create, translate } = createComponent("calendar-item");
|
|
93
|
+
const _sfc_main = create({
|
|
94
|
+
props: {
|
|
95
|
+
type: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: "one"
|
|
98
|
+
},
|
|
99
|
+
isAutoBackFill: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false
|
|
102
|
+
},
|
|
103
|
+
toDateAnimation: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: true
|
|
106
|
+
},
|
|
107
|
+
poppable: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
default: true
|
|
110
|
+
},
|
|
111
|
+
showTitle: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: true
|
|
114
|
+
},
|
|
115
|
+
showSubTitle: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: true
|
|
118
|
+
},
|
|
119
|
+
showToday: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: true
|
|
122
|
+
},
|
|
123
|
+
title: {
|
|
124
|
+
type: String,
|
|
125
|
+
default: ""
|
|
126
|
+
},
|
|
127
|
+
confirmText: {
|
|
128
|
+
type: String,
|
|
129
|
+
default: ""
|
|
130
|
+
},
|
|
131
|
+
startText: {
|
|
132
|
+
type: String,
|
|
133
|
+
default: ""
|
|
134
|
+
},
|
|
135
|
+
endText: {
|
|
136
|
+
type: String,
|
|
137
|
+
default: ""
|
|
138
|
+
},
|
|
139
|
+
defaultValue: {
|
|
140
|
+
type: [String, Array],
|
|
141
|
+
default: null
|
|
142
|
+
},
|
|
143
|
+
startDate: {
|
|
144
|
+
type: String,
|
|
145
|
+
default: Utils.getDay(0)
|
|
146
|
+
},
|
|
147
|
+
endDate: {
|
|
148
|
+
type: String,
|
|
149
|
+
default: Utils.getDay(365)
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
emits: ["choose", "update", "close", "select"],
|
|
153
|
+
setup(props, { emit, slots }) {
|
|
154
|
+
const weeks = ref(translate("weekdays"));
|
|
155
|
+
const months = ref(null);
|
|
156
|
+
const monthsPanel = ref(null);
|
|
157
|
+
const weeksPanel = ref(null);
|
|
158
|
+
const viewArea = ref(null);
|
|
159
|
+
const viewHeight = ref(0);
|
|
160
|
+
const compConthsData = computed(() => {
|
|
161
|
+
return state.monthsData.slice(state.defaultRange[0], state.defaultRange[1]);
|
|
162
|
+
});
|
|
163
|
+
const showTopBtn = computed(() => {
|
|
164
|
+
return slots.btn;
|
|
165
|
+
});
|
|
166
|
+
const topInfo = computed(() => {
|
|
167
|
+
return slots.topInfo;
|
|
168
|
+
});
|
|
169
|
+
const bottomInfo = computed(() => {
|
|
170
|
+
return slots.bottomInfo;
|
|
171
|
+
});
|
|
172
|
+
const state = reactive({
|
|
173
|
+
yearMonthTitle: "",
|
|
174
|
+
defaultRange: [],
|
|
175
|
+
currDate: "",
|
|
176
|
+
propStartDate: "",
|
|
177
|
+
propEndDate: "",
|
|
178
|
+
unLoadPrev: false,
|
|
179
|
+
touchParams: {
|
|
180
|
+
startY: 0,
|
|
181
|
+
endY: 0,
|
|
182
|
+
startTime: 0,
|
|
183
|
+
endTime: 0,
|
|
184
|
+
lastY: 0,
|
|
185
|
+
lastTime: 0
|
|
186
|
+
},
|
|
187
|
+
transformY: 0,
|
|
188
|
+
translateY: 0,
|
|
189
|
+
scrollDistance: 0,
|
|
190
|
+
defaultData: [],
|
|
191
|
+
chooseData: [],
|
|
192
|
+
monthsData: [],
|
|
193
|
+
dayPrefix: "calendar-month-day",
|
|
194
|
+
startData: "",
|
|
195
|
+
endData: "",
|
|
196
|
+
isRange: props.type === "range",
|
|
197
|
+
timer: 0,
|
|
198
|
+
currentIndex: 0,
|
|
199
|
+
avgHeight: 0,
|
|
200
|
+
monthsNum: 0
|
|
201
|
+
});
|
|
202
|
+
const splitDate = (date) => {
|
|
203
|
+
return date.split("-");
|
|
204
|
+
};
|
|
205
|
+
const isStart = (currDate) => {
|
|
206
|
+
return Utils.isEqual(state.currDate[0], currDate);
|
|
207
|
+
};
|
|
208
|
+
const isEnd = (currDate) => {
|
|
209
|
+
return Utils.isEqual(state.currDate[1], currDate);
|
|
210
|
+
};
|
|
211
|
+
const isMultiple = (currDate) => {
|
|
212
|
+
if (state.currDate.length > 0) {
|
|
213
|
+
return state.currDate.some((item) => {
|
|
214
|
+
return Utils.isEqual(item, currDate);
|
|
215
|
+
});
|
|
216
|
+
} else {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const getCurrDate = (day, month) => {
|
|
221
|
+
return month.curData[0] + "-" + month.curData[1] + "-" + Utils.getNumTwoBit(+day.day);
|
|
222
|
+
};
|
|
223
|
+
const getClass = (day, month) => {
|
|
224
|
+
const currDate = getCurrDate(day, month);
|
|
225
|
+
const { type } = props;
|
|
226
|
+
if (day.type == "curr") {
|
|
227
|
+
if (Utils.isEqual(state.currDate, currDate) || type == "range" && (isStart(currDate) || isEnd(currDate)) || type == "multiple" && isMultiple(currDate)) {
|
|
228
|
+
return `${state.dayPrefix}-active`;
|
|
229
|
+
} else if (state.propStartDate && Utils.compareDate(currDate, state.propStartDate) || state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) {
|
|
230
|
+
return `${state.dayPrefix}-disabled`;
|
|
231
|
+
} else if (type == "range" && Array.isArray(state.currDate) && Object.values(state.currDate).length == 2 && Utils.compareDate(state.currDate[0], currDate) && Utils.compareDate(currDate, state.currDate[1])) {
|
|
232
|
+
return `${state.dayPrefix}-choose`;
|
|
233
|
+
} else {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
return `${state.dayPrefix}-disabled`;
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
const confirm = () => {
|
|
241
|
+
const { type } = props;
|
|
242
|
+
if (type == "range" && state.chooseData.length == 2 || type != "range") {
|
|
243
|
+
let chooseData = state.chooseData.slice(0);
|
|
244
|
+
emit("choose", chooseData);
|
|
245
|
+
if (props.poppable) {
|
|
246
|
+
emit("update");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const chooseDay = (day, month, isFirst) => {
|
|
251
|
+
if (getClass(day, month) != `${state.dayPrefix}-disabled`) {
|
|
252
|
+
const { type } = props;
|
|
253
|
+
let days = [...month.curData];
|
|
254
|
+
days[2] = typeof day.day == "number" ? Utils.getNumTwoBit(day.day) : day.day;
|
|
255
|
+
days[3] = `${days[0]}-${days[1]}-${days[2]}`;
|
|
256
|
+
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
257
|
+
if (type == "multiple") {
|
|
258
|
+
if (state.currDate.length > 0) {
|
|
259
|
+
let hasIndex = "";
|
|
260
|
+
state.currDate.forEach((item, index) => {
|
|
261
|
+
if (item == days[3]) {
|
|
262
|
+
hasIndex = index;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
if (isFirst) {
|
|
266
|
+
state.chooseData.push([...days]);
|
|
267
|
+
} else {
|
|
268
|
+
if (hasIndex !== "") {
|
|
269
|
+
state.currDate.splice(hasIndex, 1);
|
|
270
|
+
state.chooseData.splice(hasIndex, 1);
|
|
271
|
+
} else {
|
|
272
|
+
state.currDate.push(days[3]);
|
|
273
|
+
state.chooseData.push([...days]);
|
|
274
|
+
}
|
|
134
275
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
276
|
+
} else {
|
|
277
|
+
state.currDate = [days[3]];
|
|
278
|
+
state.chooseData = [[...days]];
|
|
279
|
+
}
|
|
280
|
+
} else if (type == "range") {
|
|
281
|
+
let curDataLength = Object.values(state.currDate).length;
|
|
282
|
+
if (curDataLength == 2 || curDataLength == 0) {
|
|
283
|
+
state.currDate = [days[3]];
|
|
284
|
+
} else {
|
|
285
|
+
if (Utils.compareDate(state.currDate[0], days[3])) {
|
|
286
|
+
Array.isArray(state.currDate) && state.currDate.push(days[3]);
|
|
287
|
+
} else {
|
|
288
|
+
Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (state.chooseData.length == 2 || !state.chooseData.length) {
|
|
292
|
+
state.chooseData = [[...days]];
|
|
293
|
+
} else {
|
|
294
|
+
if (Utils.compareDate(state.chooseData[0][3], days[3])) {
|
|
295
|
+
state.chooseData = [...state.chooseData, [...days]];
|
|
296
|
+
} else {
|
|
297
|
+
state.chooseData = [[...days], ...state.chooseData];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
state.currDate = days[3];
|
|
302
|
+
state.chooseData = [...days];
|
|
303
|
+
}
|
|
304
|
+
if (!isFirst) {
|
|
305
|
+
emit("select", state.chooseData);
|
|
306
|
+
if (props.isAutoBackFill || !props.poppable) {
|
|
307
|
+
confirm();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
const getCurrData = (type) => {
|
|
313
|
+
const monthData = type == "prev" ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
|
|
314
|
+
let year = parseInt(monthData.curData[0]);
|
|
315
|
+
let month = parseInt(monthData.curData[1].toString().replace(/^0/, ""));
|
|
316
|
+
switch (type) {
|
|
317
|
+
case "prev":
|
|
318
|
+
month == 1 && (year -= 1);
|
|
319
|
+
month = month == 1 ? 12 : --month;
|
|
320
|
+
break;
|
|
321
|
+
case "next":
|
|
322
|
+
month == 12 && (year += 1);
|
|
323
|
+
month = month == 12 ? 1 : ++month;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
return [year, Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month))];
|
|
327
|
+
};
|
|
328
|
+
const getDaysStatus = (days, type, dateInfo) => {
|
|
329
|
+
let { year, month } = dateInfo;
|
|
330
|
+
if (type == "prev" && days >= 7) {
|
|
331
|
+
days -= 7;
|
|
332
|
+
}
|
|
333
|
+
return Array.from(Array(days), (v, k) => {
|
|
334
|
+
return {
|
|
335
|
+
day: k + 1,
|
|
336
|
+
type,
|
|
337
|
+
year,
|
|
338
|
+
month
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
const getPreDaysStatus = (days, type, dateInfo, preCurrMonthDays) => {
|
|
343
|
+
let { year, month } = dateInfo;
|
|
344
|
+
if (type == "prev" && days >= 7) {
|
|
345
|
+
days -= 7;
|
|
346
|
+
}
|
|
347
|
+
let months2 = Array.from(Array(preCurrMonthDays), (v, k) => {
|
|
348
|
+
return {
|
|
349
|
+
day: k + 1,
|
|
350
|
+
type,
|
|
351
|
+
year,
|
|
352
|
+
month
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
return months2.slice(preCurrMonthDays - days);
|
|
356
|
+
};
|
|
357
|
+
const getMonth = (curData, type) => {
|
|
358
|
+
const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
359
|
+
let preMonth = curData[1] - 1;
|
|
360
|
+
let preYear = curData[0];
|
|
361
|
+
if (preMonth <= 0) {
|
|
362
|
+
preMonth = 12;
|
|
363
|
+
preYear += 1;
|
|
364
|
+
}
|
|
365
|
+
const currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
|
|
366
|
+
const preCurrMonthDays = Utils.getMonthDays(preYear + "", preMonth + "");
|
|
367
|
+
const title = {
|
|
368
|
+
year: curData[0],
|
|
369
|
+
month: curData[1]
|
|
370
|
+
};
|
|
371
|
+
const monthInfo = {
|
|
372
|
+
curData,
|
|
373
|
+
title: translate("monthTitle", title.year, title.month),
|
|
374
|
+
monthData: [
|
|
375
|
+
...getPreDaysStatus(preMonthDays, "prev", { month: preMonth, year: preYear }, preCurrMonthDays),
|
|
376
|
+
...getDaysStatus(currMonthDays, "curr", title)
|
|
377
|
+
]
|
|
378
|
+
};
|
|
379
|
+
monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
|
|
380
|
+
let cssScrollHeight = 0;
|
|
381
|
+
if (state.monthsData.length > 0) {
|
|
382
|
+
cssScrollHeight = state.monthsData[state.monthsData.length - 1].cssScrollHeight + state.monthsData[state.monthsData.length - 1].cssHeight;
|
|
383
|
+
}
|
|
384
|
+
monthInfo.cssScrollHeight = cssScrollHeight;
|
|
385
|
+
if (type == "next") {
|
|
386
|
+
if (!state.endData || !Utils.compareDate(`${state.endData[0]}-${state.endData[1]}-${Utils.getMonthDays(state.endData[0], state.endData[1])}`, `${curData[0]}-${curData[1]}-${curData[2]}`)) {
|
|
387
|
+
state.monthsData.push(monthInfo);
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
if (!state.startData || !Utils.compareDate(`${curData[0]}-${curData[1]}-${curData[2]}`, `${state.startData[0]}-${state.startData[1]}-01`)) {
|
|
391
|
+
state.monthsData.unshift(monthInfo);
|
|
392
|
+
} else {
|
|
393
|
+
state.unLoadPrev = true;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const initData = () => {
|
|
398
|
+
let propStartDate = props.startDate ? props.startDate : Utils.getDay(0);
|
|
399
|
+
let propEndDate = props.endDate ? props.endDate : Utils.getDay(365);
|
|
400
|
+
state.propStartDate = propStartDate;
|
|
401
|
+
state.propEndDate = propEndDate;
|
|
402
|
+
state.startData = splitDate(propStartDate);
|
|
403
|
+
state.endData = splitDate(propEndDate);
|
|
404
|
+
if (props.defaultValue || Array.isArray(props.defaultValue) && props.defaultValue.length > 0) {
|
|
405
|
+
state.currDate = props.type != "one" ? [...props.defaultValue] : props.defaultValue;
|
|
139
406
|
}
|
|
407
|
+
const startDate = {
|
|
408
|
+
year: Number(state.startData[0]),
|
|
409
|
+
month: Number(state.startData[1])
|
|
410
|
+
};
|
|
411
|
+
const endDate = {
|
|
412
|
+
year: Number(state.endData[0]),
|
|
413
|
+
month: Number(state.endData[1])
|
|
414
|
+
};
|
|
415
|
+
let monthsNum = endDate.month - startDate.month;
|
|
416
|
+
if (endDate.year - startDate.year > 0) {
|
|
417
|
+
monthsNum = monthsNum + 12 * (endDate.year - startDate.year);
|
|
418
|
+
}
|
|
419
|
+
if (monthsNum <= 0) {
|
|
420
|
+
monthsNum = 1;
|
|
421
|
+
}
|
|
422
|
+
getMonth(state.startData, "next");
|
|
423
|
+
let i = 1;
|
|
424
|
+
do {
|
|
425
|
+
getMonth(getCurrData("next"), "next");
|
|
426
|
+
} while (i++ < monthsNum);
|
|
427
|
+
state.monthsNum = monthsNum;
|
|
428
|
+
if (props.type == "range" && Array.isArray(state.currDate)) {
|
|
429
|
+
if (state.currDate.length > 0) {
|
|
430
|
+
if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
|
|
431
|
+
state.currDate.splice(0, 1, propStartDate);
|
|
432
|
+
}
|
|
433
|
+
if (propEndDate && Utils.compareDate(propEndDate, state.currDate[1])) {
|
|
434
|
+
state.currDate.splice(1, 1, propEndDate);
|
|
435
|
+
}
|
|
436
|
+
state.defaultData = [...splitDate(state.currDate[0]), ...splitDate(state.currDate[1])];
|
|
437
|
+
}
|
|
438
|
+
} else if (props.type == "multiple" && Array.isArray(state.currDate)) {
|
|
439
|
+
if (state.currDate.length > 0) {
|
|
440
|
+
let defaultArr = [];
|
|
441
|
+
let obj = {};
|
|
442
|
+
state.currDate.forEach((item, index) => {
|
|
443
|
+
if (propStartDate && !Utils.compareDate(item, propStartDate) && propEndDate && !Utils.compareDate(propEndDate, item)) {
|
|
444
|
+
if (!obj.hasOwnProperty(item)) {
|
|
445
|
+
defaultArr.push(item);
|
|
446
|
+
obj[item] = item;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
state.currDate = [...defaultArr];
|
|
451
|
+
state.defaultData = [...splitDate(defaultArr[0])];
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
if (state.currDate) {
|
|
455
|
+
if (propStartDate && Utils.compareDate(state.currDate, propStartDate)) {
|
|
456
|
+
state.currDate = propStartDate;
|
|
457
|
+
} else if (propEndDate && !Utils.compareDate(state.currDate, propEndDate)) {
|
|
458
|
+
state.currDate = propEndDate;
|
|
459
|
+
}
|
|
460
|
+
state.defaultData = [...splitDate(state.currDate)];
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
let current = 0;
|
|
464
|
+
let lastCurrent = 0;
|
|
465
|
+
if (state.defaultData.length > 0) {
|
|
466
|
+
state.monthsData.forEach((item, index) => {
|
|
467
|
+
if (item.title == translate("monthTitle", state.defaultData[0], state.defaultData[1])) {
|
|
468
|
+
current = index;
|
|
469
|
+
}
|
|
470
|
+
if (props.type == "range") {
|
|
471
|
+
if (item.title == translate("monthTitle", state.defaultData[3], state.defaultData[4])) {
|
|
472
|
+
lastCurrent = index;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
setDefaultRange(monthsNum, current);
|
|
478
|
+
state.currentIndex = current;
|
|
479
|
+
state.yearMonthTitle = state.monthsData[state.currentIndex].title;
|
|
480
|
+
if (state.defaultData.length > 0) {
|
|
481
|
+
if (props.type == "range") {
|
|
482
|
+
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
483
|
+
chooseDay({ day: state.defaultData[5], type: "curr" }, state.monthsData[lastCurrent], true);
|
|
484
|
+
} else if (props.type == "multiple") {
|
|
485
|
+
[...state.currDate].forEach((item) => {
|
|
486
|
+
let dateArr = splitDate(item);
|
|
487
|
+
let current2 = state.currentIndex;
|
|
488
|
+
state.monthsData.forEach((item2, index) => {
|
|
489
|
+
if (item2.title == translate("monthTitle", dateArr[0], dateArr[1])) {
|
|
490
|
+
current2 = index;
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
chooseDay({ day: dateArr[2], type: "curr" }, state.monthsData[current2], true);
|
|
494
|
+
});
|
|
495
|
+
} else {
|
|
496
|
+
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
let lastItem = state.monthsData[state.monthsData.length - 1];
|
|
500
|
+
let containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
|
|
501
|
+
requestAniFrame(() => {
|
|
502
|
+
if ((months == null ? void 0 : months.value) && (monthsPanel == null ? void 0 : monthsPanel.value) && (viewArea == null ? void 0 : viewArea.value)) {
|
|
503
|
+
viewHeight.value = months.value.clientHeight;
|
|
504
|
+
monthsPanel.value.style.height = `${containerHeight}px`;
|
|
505
|
+
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
|
|
509
|
+
};
|
|
510
|
+
const scrollToDate = (date) => {
|
|
511
|
+
if (Utils.compareDate(date, state.propStartDate)) {
|
|
512
|
+
date = state.propStartDate;
|
|
513
|
+
} else if (!Utils.compareDate(date, state.propEndDate)) {
|
|
514
|
+
date = state.propEndDate;
|
|
515
|
+
}
|
|
516
|
+
let dateArr = splitDate(date);
|
|
517
|
+
state.monthsData.forEach((item, index) => {
|
|
518
|
+
if (item.title == translate("monthTitle", dateArr[0], dateArr[1])) {
|
|
519
|
+
if (months.value) {
|
|
520
|
+
let distance = state.monthsData[index].cssScrollHeight - months.value.scrollTop;
|
|
521
|
+
if (props.toDateAnimation) {
|
|
522
|
+
let flag = 0;
|
|
523
|
+
let interval = setInterval(() => {
|
|
524
|
+
flag++;
|
|
525
|
+
if (months.value) {
|
|
526
|
+
let offset = distance / 10;
|
|
527
|
+
months.value.scrollTop = months.value.scrollTop + offset;
|
|
528
|
+
}
|
|
529
|
+
if (flag >= 10) {
|
|
530
|
+
clearInterval(interval);
|
|
531
|
+
if (months.value) {
|
|
532
|
+
months.value.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}, 40);
|
|
536
|
+
} else {
|
|
537
|
+
months.value.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
};
|
|
543
|
+
useExpose({
|
|
544
|
+
scrollToDate
|
|
140
545
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
546
|
+
const setDefaultRange = (monthsNum, current) => {
|
|
547
|
+
if (monthsNum >= 3) {
|
|
548
|
+
if (current > 0 && current < monthsNum) {
|
|
549
|
+
state.defaultRange = [current - 1, current + 3];
|
|
550
|
+
} else if (current == 0) {
|
|
551
|
+
state.defaultRange = [current, current + 4];
|
|
552
|
+
} else if (current == monthsNum) {
|
|
553
|
+
state.defaultRange = [current - 2, current + 2];
|
|
554
|
+
}
|
|
555
|
+
} else {
|
|
556
|
+
state.defaultRange = [0, monthsNum + 2];
|
|
557
|
+
}
|
|
558
|
+
let defaultScrollTop = state.monthsData[state.defaultRange[0]].cssScrollHeight;
|
|
559
|
+
state.translateY = defaultScrollTop;
|
|
560
|
+
};
|
|
561
|
+
const isActive = (day, month) => {
|
|
562
|
+
return props.type == "range" && day.type == "curr" && getClass(day, month) == "calendar-month-day-active";
|
|
563
|
+
};
|
|
564
|
+
const isStartTip = (day, month) => {
|
|
565
|
+
return isActive(day, month) && isStart(getCurrDate(day, month));
|
|
566
|
+
};
|
|
567
|
+
const isEndTip = (day, month) => {
|
|
568
|
+
if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
|
|
569
|
+
return isActive(day, month);
|
|
570
|
+
}
|
|
571
|
+
return false;
|
|
572
|
+
};
|
|
573
|
+
const rangeTip = (day, month) => {
|
|
574
|
+
if (state.currDate.length >= 2) {
|
|
575
|
+
return Utils.isEqual(state.currDate[0], state.currDate[1]);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
const isCurrDay = (dateInfo) => {
|
|
579
|
+
const date = `${dateInfo.year}-${dateInfo.month}-${dateInfo.day < 10 ? "0" + dateInfo.day : dateInfo.day}`;
|
|
580
|
+
return Utils.isEqual(date, Utils.date2Str(new Date()));
|
|
581
|
+
};
|
|
582
|
+
const mothsViewScroll = (e) => {
|
|
583
|
+
if (state.monthsData.length <= 1) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
const currentScrollTop = e.target.scrollTop;
|
|
587
|
+
let current = Math.floor(currentScrollTop / state.avgHeight);
|
|
588
|
+
if (current == 0) {
|
|
589
|
+
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
590
|
+
current += 1;
|
|
591
|
+
}
|
|
592
|
+
} else if (current > 0 && current < state.monthsNum - 1) {
|
|
593
|
+
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
594
|
+
current += 1;
|
|
595
|
+
}
|
|
596
|
+
if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
|
|
597
|
+
current -= 1;
|
|
598
|
+
}
|
|
599
|
+
} else {
|
|
600
|
+
const viewPosition = Math.round(currentScrollTop + viewHeight.value);
|
|
601
|
+
if (viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight && currentScrollTop > state.monthsData[current - 1].cssScrollHeight) {
|
|
602
|
+
current -= 1;
|
|
603
|
+
}
|
|
604
|
+
if (current + 1 <= state.monthsNum && viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight) {
|
|
605
|
+
current += 1;
|
|
606
|
+
}
|
|
607
|
+
if (current >= 1 && currentScrollTop < state.monthsData[current - 1].cssScrollHeight) {
|
|
608
|
+
current -= 1;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (state.currentIndex !== current) {
|
|
612
|
+
state.currentIndex = current;
|
|
613
|
+
setDefaultRange(state.monthsNum, current);
|
|
614
|
+
}
|
|
615
|
+
state.yearMonthTitle = state.monthsData[current].title;
|
|
616
|
+
};
|
|
617
|
+
const resetRender = () => {
|
|
618
|
+
state.chooseData.splice(0);
|
|
619
|
+
state.monthsData.splice(0);
|
|
620
|
+
initData();
|
|
621
|
+
};
|
|
622
|
+
initData();
|
|
623
|
+
watch(() => props.defaultValue, (val) => {
|
|
624
|
+
if (val) {
|
|
625
|
+
if (props.poppable) {
|
|
626
|
+
resetRender();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
return {
|
|
631
|
+
weeks,
|
|
632
|
+
compConthsData,
|
|
633
|
+
showTopBtn,
|
|
634
|
+
topInfo,
|
|
635
|
+
bottomInfo,
|
|
636
|
+
rangeTip,
|
|
637
|
+
mothsViewScroll,
|
|
638
|
+
getClass,
|
|
639
|
+
isStartTip,
|
|
640
|
+
isEndTip,
|
|
641
|
+
chooseDay,
|
|
642
|
+
isCurrDay,
|
|
643
|
+
confirm,
|
|
644
|
+
monthsPanel,
|
|
645
|
+
months,
|
|
646
|
+
weeksPanel,
|
|
647
|
+
viewArea,
|
|
648
|
+
...toRefs(state),
|
|
649
|
+
...toRefs(props),
|
|
650
|
+
translate
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
const _hoisted_1 = {
|
|
655
|
+
key: 0,
|
|
656
|
+
class: "calendar-title"
|
|
657
|
+
};
|
|
658
|
+
const _hoisted_2 = {
|
|
659
|
+
key: 1,
|
|
660
|
+
class: "calendar-top-slot"
|
|
661
|
+
};
|
|
662
|
+
const _hoisted_3 = {
|
|
663
|
+
key: 2,
|
|
664
|
+
class: "calendar-curr-month"
|
|
665
|
+
};
|
|
666
|
+
const _hoisted_4 = {
|
|
667
|
+
class: "calendar-weeks",
|
|
668
|
+
ref: "weeksPanel"
|
|
669
|
+
};
|
|
670
|
+
const _hoisted_5 = {
|
|
671
|
+
class: "calendar-months-panel",
|
|
672
|
+
ref: "monthsPanel"
|
|
673
|
+
};
|
|
674
|
+
const _hoisted_6 = { class: "calendar-month-title" };
|
|
675
|
+
const _hoisted_7 = { class: "calendar-month-con" };
|
|
676
|
+
const _hoisted_8 = ["onClick"];
|
|
677
|
+
const _hoisted_9 = { class: "calendar-day" };
|
|
678
|
+
const _hoisted_10 = {
|
|
679
|
+
key: 0,
|
|
680
|
+
class: "calendar-curr-tips calendar-curr-tips-top"
|
|
681
|
+
};
|
|
682
|
+
const _hoisted_11 = {
|
|
683
|
+
key: 1,
|
|
684
|
+
class: "calendar-curr-tips calendar-curr-tips-bottom"
|
|
685
|
+
};
|
|
686
|
+
const _hoisted_12 = {
|
|
687
|
+
key: 2,
|
|
688
|
+
class: "calendar-curr-tip-curr"
|
|
689
|
+
};
|
|
690
|
+
const _hoisted_13 = {
|
|
691
|
+
key: 4,
|
|
692
|
+
class: "calendar-day-tip"
|
|
693
|
+
};
|
|
694
|
+
const _hoisted_14 = {
|
|
695
|
+
key: 0,
|
|
696
|
+
class: "nut-calendar-footer"
|
|
697
|
+
};
|
|
698
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
699
|
+
return openBlock(), createElementBlock("view", {
|
|
700
|
+
class: normalizeClass(["nut-calendar nut-calendar-taro", {
|
|
701
|
+
"nut-calendar-tile": !_ctx.poppable,
|
|
702
|
+
"nut-calendar-nofooter": _ctx.isAutoBackFill
|
|
703
|
+
}])
|
|
704
|
+
}, [
|
|
705
|
+
createElementVNode("view", {
|
|
706
|
+
class: normalizeClass(["nut-calendar-header", { "nut-calendar-header-tile": !_ctx.poppable }])
|
|
707
|
+
}, [
|
|
708
|
+
_ctx.showTitle ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(_ctx.title || _ctx.translate("title")), 1)) : createCommentVNode("", true),
|
|
709
|
+
_ctx.showTopBtn ? (openBlock(), createElementBlock("view", _hoisted_2, [
|
|
710
|
+
renderSlot(_ctx.$slots, "btn")
|
|
711
|
+
])) : createCommentVNode("", true),
|
|
712
|
+
_ctx.showSubTitle ? (openBlock(), createElementBlock("view", _hoisted_3, toDisplayString(_ctx.yearMonthTitle), 1)) : createCommentVNode("", true),
|
|
713
|
+
createElementVNode("view", _hoisted_4, [
|
|
714
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (item, index) => {
|
|
715
|
+
return openBlock(), createElementBlock("view", {
|
|
716
|
+
class: "calendar-week-item",
|
|
717
|
+
key: index
|
|
718
|
+
}, toDisplayString(item), 1);
|
|
719
|
+
}), 128))
|
|
720
|
+
], 512)
|
|
721
|
+
], 2),
|
|
722
|
+
createElementVNode("view", {
|
|
723
|
+
class: "nut-calendar-content",
|
|
724
|
+
ref: "months",
|
|
725
|
+
onScroll: _cache[0] || (_cache[0] = (...args) => _ctx.mothsViewScroll && _ctx.mothsViewScroll(...args))
|
|
726
|
+
}, [
|
|
727
|
+
createElementVNode("view", _hoisted_5, [
|
|
728
|
+
createElementVNode("view", {
|
|
729
|
+
class: "viewArea",
|
|
730
|
+
ref: "viewArea",
|
|
731
|
+
style: normalizeStyle({ transform: `translateY(${_ctx.translateY}px)` })
|
|
732
|
+
}, [
|
|
733
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.compConthsData, (month, index) => {
|
|
734
|
+
return openBlock(), createElementBlock("view", {
|
|
735
|
+
class: "calendar-month",
|
|
736
|
+
key: index
|
|
737
|
+
}, [
|
|
738
|
+
createElementVNode("view", _hoisted_6, toDisplayString(month.title), 1),
|
|
739
|
+
createElementVNode("view", _hoisted_7, [
|
|
740
|
+
createElementVNode("view", {
|
|
741
|
+
class: normalizeClass(["calendar-month-item", _ctx.type === "range" ? "month-item-range" : ""])
|
|
742
|
+
}, [
|
|
743
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(month.monthData, (day, i) => {
|
|
744
|
+
return openBlock(), createElementBlock("view", {
|
|
745
|
+
key: i,
|
|
746
|
+
class: normalizeClass(["calendar-month-day", _ctx.getClass(day, month)]),
|
|
747
|
+
onClick: ($event) => _ctx.chooseDay(day, month)
|
|
748
|
+
}, [
|
|
749
|
+
createElementVNode("view", _hoisted_9, [
|
|
750
|
+
renderSlot(_ctx.$slots, "day", {
|
|
751
|
+
date: day.type == "curr" ? day : ""
|
|
752
|
+
}, () => [
|
|
753
|
+
createTextVNode(toDisplayString(day.type == "curr" ? day.day : ""), 1)
|
|
754
|
+
])
|
|
755
|
+
]),
|
|
756
|
+
_ctx.topInfo ? (openBlock(), createElementBlock("view", _hoisted_10, [
|
|
757
|
+
renderSlot(_ctx.$slots, "topInfo", {
|
|
758
|
+
date: day.type == "curr" ? day : ""
|
|
759
|
+
})
|
|
760
|
+
])) : createCommentVNode("", true),
|
|
761
|
+
_ctx.bottomInfo ? (openBlock(), createElementBlock("view", _hoisted_11, [
|
|
762
|
+
renderSlot(_ctx.$slots, "bottomInfo", {
|
|
763
|
+
date: day.type == "curr" ? day : ""
|
|
764
|
+
})
|
|
765
|
+
])) : createCommentVNode("", true),
|
|
766
|
+
!_ctx.bottomInfo && _ctx.showToday && _ctx.isCurrDay(day) ? (openBlock(), createElementBlock("view", _hoisted_12, toDisplayString(_ctx.translate("today")), 1)) : createCommentVNode("", true),
|
|
767
|
+
_ctx.isStartTip(day, month) ? (openBlock(), createElementBlock("view", {
|
|
768
|
+
key: 3,
|
|
769
|
+
class: normalizeClass(["calendar-day-tip", { "calendar-curr-tips-top": _ctx.rangeTip(day, month) }])
|
|
770
|
+
}, toDisplayString(_ctx.startText || _ctx.translate("start")), 3)) : createCommentVNode("", true),
|
|
771
|
+
_ctx.isEndTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_13, toDisplayString(_ctx.endText || _ctx.translate("end")), 1)) : createCommentVNode("", true)
|
|
772
|
+
], 10, _hoisted_8);
|
|
773
|
+
}), 128))
|
|
774
|
+
], 2)
|
|
775
|
+
])
|
|
776
|
+
]);
|
|
777
|
+
}), 128))
|
|
778
|
+
], 4)
|
|
779
|
+
], 512)
|
|
780
|
+
], 544),
|
|
781
|
+
_ctx.poppable && !_ctx.isAutoBackFill ? (openBlock(), createElementBlock("view", _hoisted_14, [
|
|
782
|
+
createElementVNode("view", {
|
|
783
|
+
class: "calendar-confirm-btn",
|
|
784
|
+
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.confirm && _ctx.confirm(...args))
|
|
785
|
+
}, toDisplayString(_ctx.confirmText || _ctx.translate("confirm")), 1)
|
|
786
|
+
])) : createCommentVNode("", true)
|
|
787
|
+
], 2);
|
|
788
|
+
}
|
|
789
|
+
var CalendarItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
790
|
+
export { CalendarItem as C, Utils as U };
|