@nutui/nutui 4.2.8 → 4.3.0-beta.2
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 +4 -2
- package/dist/nutui.js +6306 -5969
- package/dist/nutui.umd.js +1 -1
- package/dist/packages/addresslist/AddressList.js +4 -3
- package/dist/packages/audiooperate/AudioOperate.js +3 -2
- package/dist/packages/avatarcropper/AvatarCropper.js +3 -2
- package/dist/packages/button/Button.js +58 -39
- package/dist/packages/calendar/Calendar.js +2 -1
- package/dist/packages/calendarcard/CalendarCard.js +529 -0
- package/dist/packages/calendarcard/index.css +1 -0
- package/dist/packages/calendarcard/index.mjs +2 -0
- package/dist/packages/calendarcard/index.scss +92 -0
- package/dist/packages/calendarcard/style/css.mjs +2 -0
- package/dist/packages/calendarcard/style/index.mjs +2 -0
- package/dist/packages/calendaritem/CalendarItem.js +817 -7
- package/dist/packages/date-djiVNSnJ.js +145 -0
- package/dist/packages/dialog/Dialog.js +4 -3
- package/dist/packages/divider/Divider.js +40 -18
- package/dist/packages/invoice/Invoice.js +3 -2
- package/dist/packages/locale/lang/baseLang.d.ts +8 -0
- package/dist/packages/locale/lang/en-US.d.ts +8 -0
- package/dist/packages/locale/lang/en-US.js +8 -0
- package/dist/packages/locale/lang/id-ID.d.ts +8 -0
- package/dist/packages/locale/lang/id-ID.js +8 -0
- package/dist/packages/locale/lang/zh-CN.d.ts +8 -0
- package/dist/packages/locale/lang/zh-CN.js +8 -0
- package/dist/packages/locale/lang/zh-TW.d.ts +8 -0
- package/dist/packages/locale/lang/zh-TW.js +8 -0
- package/dist/packages/signature/Signature.js +3 -2
- package/dist/packages/with-install-p59gYYU_.js +12 -0
- package/dist/smartips/web-types.json +62 -1
- package/dist/style.css +1 -1
- package/dist/styles/base-jdb.css +1 -1
- package/dist/styles/base-jddkh.css +1 -1
- package/dist/styles/base-jdt.css +1 -1
- package/dist/styles/themes/default.scss +1 -0
- package/dist/styles/themes/jdb.scss +1 -0
- package/dist/styles/themes/jddkh.scss +1 -0
- package/dist/styles/themes/jdt.scss +1 -0
- package/dist/styles/variables-jdb.scss +1 -0
- package/dist/styles/variables-jddkh.scss +1 -0
- package/dist/styles/variables-jdt.scss +1 -0
- package/dist/styles/variables.scss +1 -0
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +7 -7
- package/dist/types/__VUE/address/index.vue.d.ts +11 -11
- package/dist/types/__VUE/addresslist/index.vue.d.ts +5 -5
- package/dist/types/__VUE/animate/index.vue.d.ts +4 -4
- package/dist/types/__VUE/audio/index.vue.d.ts +6 -6
- package/dist/types/__VUE/audiooperate/index.vue.d.ts +4 -4
- package/dist/types/__VUE/avatar/index.vue.d.ts +5 -5
- package/dist/types/__VUE/avatarcropper/index.vue.d.ts +7 -7
- package/dist/types/__VUE/avatargroup/index.vue.d.ts +5 -5
- package/dist/types/__VUE/backtop/index.vue.d.ts +6 -6
- package/dist/types/__VUE/badge/index.vue.d.ts +6 -6
- package/dist/types/__VUE/barrage/index.vue.d.ts +5 -5
- package/dist/types/__VUE/button/{index.vue.d.ts → button.vue.d.ts} +36 -27
- package/dist/types/__VUE/button/index.d.ts +5 -0
- package/dist/types/__VUE/calendar/index.vue.d.ts +7 -7
- package/dist/types/__VUE/calendarcard/calendar-card.vue.d.ts +112 -0
- package/dist/types/__VUE/calendarcard/icon.d.ts +12 -0
- package/dist/types/__VUE/calendarcard/index.d.ts +5 -0
- package/dist/types/__VUE/calendarcard/types.d.ts +12 -0
- package/dist/types/__VUE/calendarcard/utils.d.ts +19 -0
- package/dist/types/__VUE/calendaritem/index.vue.d.ts +10 -10
- package/dist/types/__VUE/card/index.vue.d.ts +4 -4
- package/dist/types/__VUE/cascader/cascader-item.vue.d.ts +4 -4
- package/dist/types/__VUE/cascader/index.vue.d.ts +7 -7
- package/dist/types/__VUE/category/index.vue.d.ts +4 -4
- package/dist/types/__VUE/categorypane/index.vue.d.ts +4 -4
- package/dist/types/__VUE/cell/index.vue.d.ts +7 -7
- package/dist/types/__VUE/cellgroup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/checkbox/index.vue.d.ts +6 -6
- package/dist/types/__VUE/checkboxgroup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/circleprogress/index.vue.d.ts +5 -5
- package/dist/types/__VUE/col/index.vue.d.ts +4 -4
- package/dist/types/__VUE/collapse/index.vue.d.ts +4 -4
- package/dist/types/__VUE/collapseitem/index.vue.d.ts +7 -7
- package/dist/types/__VUE/comment/components/CmtBottom.vue.d.ts +1 -1
- package/dist/types/__VUE/comment/components/CmtHeader.vue.d.ts +1 -1
- package/dist/types/__VUE/comment/components/CmtImages.vue.d.ts +1 -1
- package/dist/types/__VUE/comment/index.vue.d.ts +9 -9
- package/dist/types/__VUE/configprovider/index.vue.d.ts +5 -5
- package/dist/types/__VUE/countdown/index.vue.d.ts +4 -4
- package/dist/types/__VUE/countup/index.vue.d.ts +8 -8
- package/dist/types/__VUE/datepicker/index.vue.d.ts +9 -9
- package/dist/types/__VUE/dialog/index.vue.d.ts +7 -7
- package/dist/types/__VUE/divider/divider.vue.d.ts +56 -0
- package/dist/types/__VUE/divider/index.d.ts +5 -0
- package/dist/types/__VUE/drag/index.vue.d.ts +4 -4
- package/dist/types/__VUE/ecard/index.vue.d.ts +7 -7
- package/dist/types/__VUE/elevator/index.vue.d.ts +4 -4
- package/dist/types/__VUE/ellipsis/index.vue.d.ts +7 -7
- package/dist/types/__VUE/empty/index.vue.d.ts +4 -4
- package/dist/types/__VUE/fixednav/index.vue.d.ts +6 -6
- package/dist/types/__VUE/form/index.vue.d.ts +4 -4
- package/dist/types/__VUE/formitem/index.vue.d.ts +4 -4
- package/dist/types/__VUE/grid/index.vue.d.ts +6 -6
- package/dist/types/__VUE/griditem/index.vue.d.ts +4 -4
- package/dist/types/__VUE/image/index.vue.d.ts +8 -8
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +5 -5
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +9 -9
- package/dist/types/__VUE/indicator/index.vue.d.ts +4 -4
- package/dist/types/__VUE/infiniteloading/index.vue.d.ts +4 -4
- package/dist/types/__VUE/input/index.vue.d.ts +15 -15
- package/dist/types/__VUE/inputnumber/index.vue.d.ts +7 -7
- package/dist/types/__VUE/invoice/index.vue.d.ts +6 -6
- package/dist/types/__VUE/layout/index.vue.d.ts +4 -4
- package/dist/types/__VUE/list/index.vue.d.ts +6 -6
- package/dist/types/__VUE/menu/index.vue.d.ts +7 -7
- package/dist/types/__VUE/menuitem/index.vue.d.ts +4 -4
- package/dist/types/__VUE/navbar/index.vue.d.ts +6 -6
- package/dist/types/__VUE/noticebar/index.vue.d.ts +7 -7
- package/dist/types/__VUE/notify/index.vue.d.ts +7 -7
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +8 -8
- package/dist/types/__VUE/overlay/index.vue.d.ts +4 -4
- package/dist/types/__VUE/pagination/index.vue.d.ts +5 -5
- package/dist/types/__VUE/picker/Column.vue.d.ts +7 -7
- package/dist/types/__VUE/picker/baseProps.d.ts +4 -4
- package/dist/types/__VUE/picker/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popover/index.vue.d.ts +9 -9
- package/dist/types/__VUE/popup/index.vue.d.ts +6 -6
- package/dist/types/__VUE/price/index.vue.d.ts +4 -4
- package/dist/types/__VUE/progress/index.vue.d.ts +6 -6
- package/dist/types/__VUE/pullrefresh/index.vue.d.ts +4 -4
- package/dist/types/__VUE/radio/index.vue.d.ts +8 -8
- package/dist/types/__VUE/radiogroup/index.vue.d.ts +7 -7
- package/dist/types/__VUE/range/index.vue.d.ts +8 -8
- package/dist/types/__VUE/rate/index.vue.d.ts +9 -9
- package/dist/types/__VUE/row/index.vue.d.ts +5 -5
- package/dist/types/__VUE/searchbar/index.vue.d.ts +15 -15
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +5 -5
- package/dist/types/__VUE/sidenavbar/index.vue.d.ts +4 -4
- package/dist/types/__VUE/sidenavbaritem/index.vue.d.ts +4 -4
- package/dist/types/__VUE/signature/index.vue.d.ts +6 -6
- package/dist/types/__VUE/skeleton/index.vue.d.ts +7 -7
- package/dist/types/__VUE/sku/components/SkuStepper.vue.d.ts +2 -2
- package/dist/types/__VUE/sku/index.vue.d.ts +6 -6
- package/dist/types/__VUE/space/index.vue.d.ts +4 -4
- package/dist/types/__VUE/step/index.vue.d.ts +4 -4
- package/dist/types/__VUE/steps/index.vue.d.ts +4 -4
- package/dist/types/__VUE/sticky/index.vue.d.ts +5 -5
- package/dist/types/__VUE/subsidenavbar/index.vue.d.ts +4 -4
- package/dist/types/__VUE/swipe/index.vue.d.ts +4 -4
- package/dist/types/__VUE/swipegroup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/swiper/index.vue.d.ts +5 -5
- package/dist/types/__VUE/swiperitem/index.vue.d.ts +4 -4
- package/dist/types/__VUE/switch/index.vue.d.ts +13 -13
- package/dist/types/__VUE/tabbar/index.vue.d.ts +6 -6
- package/dist/types/__VUE/tabbaritem/index.vue.d.ts +6 -6
- package/dist/types/__VUE/table/index.vue.d.ts +4 -4
- package/dist/types/__VUE/table/renderColumn.d.ts +4 -4
- package/dist/types/__VUE/tabpane/index.vue.d.ts +5 -5
- package/dist/types/__VUE/tabs/index.vue.d.ts +10 -10
- package/dist/types/__VUE/tag/index.vue.d.ts +8 -8
- package/dist/types/__VUE/textarea/index.vue.d.ts +11 -11
- package/dist/types/__VUE/timedetail/index.vue.d.ts +4 -4
- package/dist/types/__VUE/timepannel/index.vue.d.ts +4 -4
- package/dist/types/__VUE/timeselect/index.vue.d.ts +5 -5
- package/dist/types/__VUE/toast/index.vue.d.ts +10 -10
- package/dist/types/__VUE/tour/index.vue.d.ts +9 -9
- package/dist/types/__VUE/trendarrow/index.vue.d.ts +5 -5
- package/dist/types/__VUE/uploader/index.vue.d.ts +10 -10
- package/dist/types/__VUE/video/index.vue.d.ts +5 -5
- package/dist/types/__VUE/watermark/index.vue.d.ts +7 -7
- package/dist/types/index.d.ts +8 -4
- package/dist/types/locale/lang/baseLang.d.ts +8 -0
- package/dist/types/locale/lang/en-US.d.ts +8 -0
- package/dist/types/locale/lang/id-ID.d.ts +8 -0
- package/dist/types/locale/lang/zh-CN.d.ts +8 -0
- package/dist/types/locale/lang/zh-TW.d.ts +8 -0
- package/dist/types/utils/canvas.d.ts +1 -1
- package/dist/types/utils/create/renderIcon.d.ts +2 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/with-install.d.ts +5 -0
- package/package.json +1 -1
- package/dist/packages/index-kWulbKuH.js +0 -961
- package/dist/types/__VUE/address/address-list.d.ts +0 -30
- package/dist/types/__VUE/divider/index.vue.d.ts +0 -71
- package/dist/types/__VUE/icon/index.vue.d.ts +0 -13
- package/dist/types/__VUE/invoice/types.d.ts +0 -6
- package/dist/types/__VUE/picker/doc.en.d.ts +0 -90
- package/dist/types/__VUE/sku/data.d.ts +0 -22
- package/dist/types/__VUE/tour/type.d.ts +0 -2
- /package/dist/types/__VUE/button/{type.d.ts → types.d.ts} +0 -0
|
@@ -1,961 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { ref, computed, reactive, onMounted, watch, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, renderSlot, Fragment, renderList, normalizeStyle, createTextVNode } from "vue";
|
|
21
|
-
import { c as createComponent } from "./component-TCzwHGVq.js";
|
|
22
|
-
import { r as requestAniFrame } from "./raf-MQjoO-Ag.js";
|
|
23
|
-
import { u as useLocale } from "./index-s3RgMhc7.js";
|
|
24
|
-
import { _ as _export_sfc } from "./_plugin-vue_export-helper-yVxbj29m.js";
|
|
25
|
-
const Utils = {
|
|
26
|
-
/**
|
|
27
|
-
* 是否为闫年
|
|
28
|
-
* @return {Boolse} true|false
|
|
29
|
-
*/
|
|
30
|
-
isLeapYear: function(y) {
|
|
31
|
-
return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* 返回星期数
|
|
35
|
-
* @return {String}
|
|
36
|
-
*/
|
|
37
|
-
getWhatDay: function(year, month, day) {
|
|
38
|
-
const date = /* @__PURE__ */ new Date(year + "/" + month + "/" + day);
|
|
39
|
-
const index = date.getDay();
|
|
40
|
-
const dayNames = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
|
41
|
-
return dayNames[index];
|
|
42
|
-
},
|
|
43
|
-
/**
|
|
44
|
-
* 返回星期数
|
|
45
|
-
* @return {Number}
|
|
46
|
-
*/
|
|
47
|
-
getMonthPreDay: function(year, month) {
|
|
48
|
-
const date = /* @__PURE__ */ new Date(year + "/" + month + "/01");
|
|
49
|
-
let day = date.getDay();
|
|
50
|
-
if (day == 0) {
|
|
51
|
-
day = 7;
|
|
52
|
-
}
|
|
53
|
-
return day;
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* 返回月份天数
|
|
57
|
-
* @return {Number}
|
|
58
|
-
*/
|
|
59
|
-
getMonthDays: function(year, month) {
|
|
60
|
-
if (/^0/.test(month)) {
|
|
61
|
-
month = month.split("")[1];
|
|
62
|
-
}
|
|
63
|
-
return [0, 31, this.isLeapYear(Number(year)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* 补齐数字位数
|
|
67
|
-
* @return {string}
|
|
68
|
-
*/
|
|
69
|
-
getNumTwoBit: function(n) {
|
|
70
|
-
n = Number(n);
|
|
71
|
-
return (n > 9 ? "" : "0") + n;
|
|
72
|
-
},
|
|
73
|
-
/**
|
|
74
|
-
* 日期对象转成字符串
|
|
75
|
-
* @return {string}
|
|
76
|
-
*/
|
|
77
|
-
date2Str: function(date, split) {
|
|
78
|
-
split = split || "-";
|
|
79
|
-
const y = date.getFullYear();
|
|
80
|
-
const m = this.getNumTwoBit(date.getMonth() + 1);
|
|
81
|
-
const d = this.getNumTwoBit(date.getDate());
|
|
82
|
-
return [y, m, d].join(split);
|
|
83
|
-
},
|
|
84
|
-
/**
|
|
85
|
-
* 返回日期格式字符串
|
|
86
|
-
* @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
|
|
87
|
-
* @return {string} '2014-12-31'
|
|
88
|
-
*/
|
|
89
|
-
getDay: function(i) {
|
|
90
|
-
i = i || 0;
|
|
91
|
-
let date = /* @__PURE__ */ new Date();
|
|
92
|
-
const diff = i * (1e3 * 60 * 60 * 24);
|
|
93
|
-
date = new Date(date.getTime() + diff);
|
|
94
|
-
return this.date2Str(date);
|
|
95
|
-
},
|
|
96
|
-
/**
|
|
97
|
-
* 时间比较
|
|
98
|
-
* @return {Boolean}
|
|
99
|
-
*/
|
|
100
|
-
compareDate: function(date1, date2) {
|
|
101
|
-
const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
|
|
102
|
-
const endTime = new Date(date2.replace("-", "/").replace("-", "/"));
|
|
103
|
-
if (startTime >= endTime) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
return true;
|
|
107
|
-
},
|
|
108
|
-
/**
|
|
109
|
-
* 时间是否相等
|
|
110
|
-
* @return {Boolean}
|
|
111
|
-
*/
|
|
112
|
-
isEqual: function(date1, date2) {
|
|
113
|
-
const startTime = new Date(date1).getTime();
|
|
114
|
-
const endTime = new Date(date2).getTime();
|
|
115
|
-
if (startTime == endTime) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
return false;
|
|
119
|
-
},
|
|
120
|
-
getMonthWeek: function(year, month, date, firstDayOfWeek = 0) {
|
|
121
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
|
|
122
|
-
let w = dateNow.getDay();
|
|
123
|
-
let d = dateNow.getDate();
|
|
124
|
-
let remainder = 6 - w;
|
|
125
|
-
if (firstDayOfWeek !== 0) {
|
|
126
|
-
w = w == 0 ? 7 : w;
|
|
127
|
-
remainder = 7 - w;
|
|
128
|
-
}
|
|
129
|
-
return Math.ceil((d + remainder) / 7);
|
|
130
|
-
},
|
|
131
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
132
|
-
getYearWeek: function(year, month, date, firstDayOfWeek = 0) {
|
|
133
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
|
|
134
|
-
const dateFirst = new Date(Number(year), 0, 1);
|
|
135
|
-
const dataNumber = Math.round((dateNow.valueOf() - dateFirst.valueOf()) / 864e5);
|
|
136
|
-
return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7);
|
|
137
|
-
},
|
|
138
|
-
getWeekDate: function(year, month, date, firstDayOfWeek = 0) {
|
|
139
|
-
const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
|
|
140
|
-
const nowTime = dateNow.getTime();
|
|
141
|
-
let day = dateNow.getDay();
|
|
142
|
-
if (firstDayOfWeek === 0) {
|
|
143
|
-
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
144
|
-
const SundayTime = nowTime - day * oneDayTime;
|
|
145
|
-
const SaturdayTime = nowTime + (6 - day) * oneDayTime;
|
|
146
|
-
const sunday = this.date2Str(new Date(SundayTime));
|
|
147
|
-
const saturday = this.date2Str(new Date(SaturdayTime));
|
|
148
|
-
return [sunday, saturday];
|
|
149
|
-
} else {
|
|
150
|
-
day = day == 0 ? 7 : day;
|
|
151
|
-
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
152
|
-
const MondayTime = nowTime - (day - 1) * oneDayTime;
|
|
153
|
-
const SundayTime = nowTime + (7 - day) * oneDayTime;
|
|
154
|
-
const monday = this.date2Str(new Date(MondayTime));
|
|
155
|
-
const sunday = this.date2Str(new Date(SundayTime));
|
|
156
|
-
return [monday, sunday];
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
formatResultDate: function(date) {
|
|
160
|
-
let days = [...date.split("-")];
|
|
161
|
-
days[2] = Utils.getNumTwoBit(Number(days[2]));
|
|
162
|
-
days[3] = `${days[0]}-${days[1]}-${days[2]}`;
|
|
163
|
-
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
164
|
-
return days;
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
const { create } = createComponent("calendar-item");
|
|
168
|
-
const cN = "NutCalendarItem";
|
|
169
|
-
const _sfc_main = create({
|
|
170
|
-
props: {
|
|
171
|
-
type: {
|
|
172
|
-
type: String,
|
|
173
|
-
default: "one"
|
|
174
|
-
},
|
|
175
|
-
isAutoBackFill: {
|
|
176
|
-
type: Boolean,
|
|
177
|
-
default: false
|
|
178
|
-
},
|
|
179
|
-
toDateAnimation: {
|
|
180
|
-
type: Boolean,
|
|
181
|
-
default: true
|
|
182
|
-
},
|
|
183
|
-
poppable: {
|
|
184
|
-
type: Boolean,
|
|
185
|
-
default: true
|
|
186
|
-
},
|
|
187
|
-
showTitle: {
|
|
188
|
-
type: Boolean,
|
|
189
|
-
default: true
|
|
190
|
-
},
|
|
191
|
-
showSubTitle: {
|
|
192
|
-
type: Boolean,
|
|
193
|
-
default: true
|
|
194
|
-
},
|
|
195
|
-
showToday: {
|
|
196
|
-
type: Boolean,
|
|
197
|
-
default: true
|
|
198
|
-
},
|
|
199
|
-
title: {
|
|
200
|
-
type: String,
|
|
201
|
-
default: ""
|
|
202
|
-
},
|
|
203
|
-
confirmText: {
|
|
204
|
-
type: String,
|
|
205
|
-
default: ""
|
|
206
|
-
},
|
|
207
|
-
startText: {
|
|
208
|
-
type: String,
|
|
209
|
-
default: ""
|
|
210
|
-
},
|
|
211
|
-
endText: {
|
|
212
|
-
type: String,
|
|
213
|
-
default: ""
|
|
214
|
-
},
|
|
215
|
-
defaultValue: {
|
|
216
|
-
type: [String, Array],
|
|
217
|
-
default: ""
|
|
218
|
-
},
|
|
219
|
-
startDate: {
|
|
220
|
-
type: String,
|
|
221
|
-
default: Utils.getDay(0)
|
|
222
|
-
},
|
|
223
|
-
endDate: {
|
|
224
|
-
type: String,
|
|
225
|
-
default: Utils.getDay(365)
|
|
226
|
-
},
|
|
227
|
-
firstDayOfWeek: {
|
|
228
|
-
type: Number,
|
|
229
|
-
default: 0
|
|
230
|
-
},
|
|
231
|
-
disabledDate: Function
|
|
232
|
-
},
|
|
233
|
-
emits: ["choose", "update", "close", "select"],
|
|
234
|
-
setup(props, { emit, slots, expose }) {
|
|
235
|
-
const translate = useLocale(cN);
|
|
236
|
-
const weekdays = translate("weekdays").map((day, index) => ({
|
|
237
|
-
day,
|
|
238
|
-
weekend: index === 0 || index === 6
|
|
239
|
-
}));
|
|
240
|
-
const weeks = ref([...weekdays.slice(props.firstDayOfWeek, 7), ...weekdays.slice(0, props.firstDayOfWeek)]);
|
|
241
|
-
const months = ref(null);
|
|
242
|
-
const monthsPanel = ref(null);
|
|
243
|
-
const weeksPanel = ref(null);
|
|
244
|
-
const viewArea = ref(null);
|
|
245
|
-
const viewHeight = ref(0);
|
|
246
|
-
const compConthsData = computed(() => {
|
|
247
|
-
return state.monthsData.slice(state.defaultRange[0], state.defaultRange[1]);
|
|
248
|
-
});
|
|
249
|
-
const showTopBtn = computed(() => {
|
|
250
|
-
return slots.btn;
|
|
251
|
-
});
|
|
252
|
-
const topInfo = computed(() => {
|
|
253
|
-
return slots["top-info"];
|
|
254
|
-
});
|
|
255
|
-
const bottomInfo = computed(() => {
|
|
256
|
-
return slots["bottom-info"];
|
|
257
|
-
});
|
|
258
|
-
const state = reactive({
|
|
259
|
-
yearMonthTitle: "",
|
|
260
|
-
defaultRange: [],
|
|
261
|
-
currDate: "",
|
|
262
|
-
propStartDate: "",
|
|
263
|
-
propEndDate: "",
|
|
264
|
-
unLoadPrev: false,
|
|
265
|
-
touchParams: {
|
|
266
|
-
startY: 0,
|
|
267
|
-
endY: 0,
|
|
268
|
-
startTime: 0,
|
|
269
|
-
endTime: 0,
|
|
270
|
-
lastY: 0,
|
|
271
|
-
lastTime: 0
|
|
272
|
-
},
|
|
273
|
-
transformY: 0,
|
|
274
|
-
translateY: 0,
|
|
275
|
-
scrollDistance: 0,
|
|
276
|
-
defaultData: [],
|
|
277
|
-
chooseData: [],
|
|
278
|
-
monthsData: [],
|
|
279
|
-
dayPrefix: "nut-calendar__day",
|
|
280
|
-
startData: "",
|
|
281
|
-
endData: "",
|
|
282
|
-
isRange: props.type === "range",
|
|
283
|
-
timer: 0,
|
|
284
|
-
currentIndex: 0,
|
|
285
|
-
avgHeight: 0,
|
|
286
|
-
monthsNum: 0
|
|
287
|
-
});
|
|
288
|
-
const splitDate = (date) => {
|
|
289
|
-
return date.split("-");
|
|
290
|
-
};
|
|
291
|
-
const isStart = (currDate) => {
|
|
292
|
-
return Utils.isEqual(state.currDate[0], currDate);
|
|
293
|
-
};
|
|
294
|
-
const isEnd = (currDate) => {
|
|
295
|
-
return Utils.isEqual(state.currDate[1], currDate);
|
|
296
|
-
};
|
|
297
|
-
const isMultiple = (currDate) => {
|
|
298
|
-
var _a, _b;
|
|
299
|
-
if (((_a = state.currDate) == null ? void 0 : _a.length) > 0) {
|
|
300
|
-
return (_b = state.currDate) == null ? void 0 : _b.some((item) => {
|
|
301
|
-
return Utils.isEqual(item, currDate);
|
|
302
|
-
});
|
|
303
|
-
} else {
|
|
304
|
-
return false;
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
const getCurrDate = (day, month) => {
|
|
308
|
-
return month.curData[0] + "-" + month.curData[1] + "-" + Utils.getNumTwoBit(+day.day);
|
|
309
|
-
};
|
|
310
|
-
const getClass = (day, month, index) => {
|
|
311
|
-
const res = [];
|
|
312
|
-
if (typeof index === "number" && ((index + 1 + props.firstDayOfWeek) % 7 === 0 || (index + props.firstDayOfWeek) % 7 === 0)) {
|
|
313
|
-
res.push("weekend");
|
|
314
|
-
}
|
|
315
|
-
const currDate = getCurrDate(day, month);
|
|
316
|
-
const { type } = props;
|
|
317
|
-
if (day.type == "curr") {
|
|
318
|
-
if (Utils.isEqual(state.currDate, currDate) || (type == "range" || type == "week") && (isStart(currDate) || isEnd(currDate)) || type == "multiple" && isMultiple(currDate)) {
|
|
319
|
-
res.push(`${state.dayPrefix}--active`);
|
|
320
|
-
} else if (state.propStartDate && Utils.compareDate(currDate, state.propStartDate) || state.propEndDate && Utils.compareDate(state.propEndDate, currDate) || props.disabledDate && props.disabledDate(currDate)) {
|
|
321
|
-
res.push(`${state.dayPrefix}--disabled`);
|
|
322
|
-
} else if ((type == "range" || type == "week") && Array.isArray(state.currDate) && Object.values(state.currDate).length == 2 && Utils.compareDate(state.currDate[0], currDate) && Utils.compareDate(currDate, state.currDate[1])) {
|
|
323
|
-
res.push(`${state.dayPrefix}--choose`);
|
|
324
|
-
}
|
|
325
|
-
} else {
|
|
326
|
-
res.push(`${state.dayPrefix}--disabled`);
|
|
327
|
-
}
|
|
328
|
-
return res;
|
|
329
|
-
};
|
|
330
|
-
const confirm = () => {
|
|
331
|
-
const { type } = props;
|
|
332
|
-
if (type == "range" && state.chooseData.length == 2 || type != "range") {
|
|
333
|
-
let selectData = state.chooseData.slice(0);
|
|
334
|
-
if (type == "week") {
|
|
335
|
-
if (state.chooseData.length !== 2) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
selectData = {
|
|
339
|
-
weekDate: [handleWeekDate(state.chooseData[0]), handleWeekDate(state.chooseData[1])]
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
emit("choose", selectData);
|
|
343
|
-
if (props.poppable) {
|
|
344
|
-
emit("update");
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
const chooseDay = (day, month, isFirst = false) => {
|
|
349
|
-
var _a, _b;
|
|
350
|
-
if (!getClass(day, month).includes(`${state.dayPrefix}--disabled`)) {
|
|
351
|
-
const { type } = props;
|
|
352
|
-
let [y, m] = month.curData;
|
|
353
|
-
let days = [...month.curData];
|
|
354
|
-
days[2] = Utils.getNumTwoBit(Number(day.day));
|
|
355
|
-
days[3] = `${days[0]}-${days[1]}-${days[2]}`;
|
|
356
|
-
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
357
|
-
if (type == "multiple") {
|
|
358
|
-
if (((_a = state.currDate) == null ? void 0 : _a.length) > 0) {
|
|
359
|
-
let hasIndex = void 0;
|
|
360
|
-
(_b = state.currDate) == null ? void 0 : _b.forEach((item, index) => {
|
|
361
|
-
if (item == days[3]) {
|
|
362
|
-
hasIndex = index;
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
if (isFirst) {
|
|
366
|
-
state.chooseData.push([...days]);
|
|
367
|
-
} else {
|
|
368
|
-
if (hasIndex !== void 0) {
|
|
369
|
-
state.currDate.splice(hasIndex, 1);
|
|
370
|
-
state.chooseData.splice(hasIndex, 1);
|
|
371
|
-
} else {
|
|
372
|
-
state.currDate.push(days[3]);
|
|
373
|
-
state.chooseData.push([...days]);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
} else {
|
|
377
|
-
state.currDate = [days[3]];
|
|
378
|
-
state.chooseData = [[...days]];
|
|
379
|
-
}
|
|
380
|
-
} else if (type == "range") {
|
|
381
|
-
let curDataLength = Object.values(state.currDate).length;
|
|
382
|
-
if (curDataLength == 2 || curDataLength == 0) {
|
|
383
|
-
state.currDate = [days[3]];
|
|
384
|
-
} else {
|
|
385
|
-
if (Utils.compareDate(state.currDate[0], days[3])) {
|
|
386
|
-
Array.isArray(state.currDate) && state.currDate.push(days[3]);
|
|
387
|
-
} else {
|
|
388
|
-
Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
if (state.chooseData.length == 2 || !state.chooseData.length) {
|
|
392
|
-
state.chooseData = [[...days]];
|
|
393
|
-
} else {
|
|
394
|
-
if (Utils.compareDate(state.chooseData[0][3], days[3])) {
|
|
395
|
-
state.chooseData = [...state.chooseData, [...days]];
|
|
396
|
-
} else {
|
|
397
|
-
state.chooseData = [[...days], ...state.chooseData];
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
} else if (type == "week") {
|
|
401
|
-
let weekArr = Utils.getWeekDate(y, m, day.day, props.firstDayOfWeek);
|
|
402
|
-
if (state.propStartDate && Utils.compareDate(weekArr[0], state.propStartDate)) {
|
|
403
|
-
weekArr.splice(0, 1, state.propStartDate);
|
|
404
|
-
}
|
|
405
|
-
if (state.propEndDate && Utils.compareDate(state.propEndDate, weekArr[1])) {
|
|
406
|
-
weekArr.splice(1, 1, state.propEndDate);
|
|
407
|
-
}
|
|
408
|
-
state.currDate = weekArr;
|
|
409
|
-
state.chooseData = [Utils.formatResultDate(weekArr[0]), Utils.formatResultDate(weekArr[1])];
|
|
410
|
-
} else {
|
|
411
|
-
state.currDate = days[3];
|
|
412
|
-
state.chooseData = [...days];
|
|
413
|
-
}
|
|
414
|
-
if (!isFirst) {
|
|
415
|
-
let selectData = state.chooseData;
|
|
416
|
-
if (type == "week") {
|
|
417
|
-
selectData = {
|
|
418
|
-
weekDate: [
|
|
419
|
-
handleWeekDate(state.chooseData[0]),
|
|
420
|
-
handleWeekDate(state.chooseData[1])
|
|
421
|
-
]
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
emit("select", selectData);
|
|
425
|
-
if (props.isAutoBackFill || !props.poppable) {
|
|
426
|
-
confirm();
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
const handleWeekDate = (weekDate) => {
|
|
432
|
-
let [y, m, d] = weekDate;
|
|
433
|
-
let obj = {
|
|
434
|
-
date: weekDate,
|
|
435
|
-
monthWeekNum: Utils.getMonthWeek(y, m, d, props.firstDayOfWeek),
|
|
436
|
-
yearWeekNum: Utils.getYearWeek(y, m, d, props.firstDayOfWeek)
|
|
437
|
-
};
|
|
438
|
-
return obj;
|
|
439
|
-
};
|
|
440
|
-
const getCurrData = (type) => {
|
|
441
|
-
const monthData = type == "prev" ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
|
|
442
|
-
let year = parseInt(monthData.curData[0]);
|
|
443
|
-
let month = parseInt(monthData.curData[1].toString().replace(/^0/, ""));
|
|
444
|
-
switch (type) {
|
|
445
|
-
case "prev":
|
|
446
|
-
month == 1 && (year -= 1);
|
|
447
|
-
month = month == 1 ? 12 : --month;
|
|
448
|
-
break;
|
|
449
|
-
case "next":
|
|
450
|
-
month == 12 && (year += 1);
|
|
451
|
-
month = month == 12 ? 1 : ++month;
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
return [year + "", Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month)) + ""];
|
|
455
|
-
};
|
|
456
|
-
const getDaysStatus = (days, type, dateInfo) => {
|
|
457
|
-
let { year, month } = dateInfo;
|
|
458
|
-
if (type == "prev" && days >= 7) {
|
|
459
|
-
days -= 7;
|
|
460
|
-
}
|
|
461
|
-
return Array.from(Array(days), (v, k) => {
|
|
462
|
-
return {
|
|
463
|
-
day: String(k + 1),
|
|
464
|
-
type,
|
|
465
|
-
year,
|
|
466
|
-
month
|
|
467
|
-
};
|
|
468
|
-
});
|
|
469
|
-
};
|
|
470
|
-
const getPreDaysStatus = (days, type, dateInfo, preCurrMonthDays) => {
|
|
471
|
-
days = days - props.firstDayOfWeek;
|
|
472
|
-
let { year, month } = dateInfo;
|
|
473
|
-
if (type == "prev" && days >= 7) {
|
|
474
|
-
days -= 7;
|
|
475
|
-
}
|
|
476
|
-
let months2 = Array.from(Array(preCurrMonthDays), (v, k) => {
|
|
477
|
-
return {
|
|
478
|
-
day: String(k + 1),
|
|
479
|
-
type,
|
|
480
|
-
year,
|
|
481
|
-
month
|
|
482
|
-
};
|
|
483
|
-
});
|
|
484
|
-
return months2.slice(preCurrMonthDays - days);
|
|
485
|
-
};
|
|
486
|
-
const getMonth = (curData, type) => {
|
|
487
|
-
const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
488
|
-
let preMonth = Number(curData[1]) - 1;
|
|
489
|
-
let preYear = Number(curData[0]);
|
|
490
|
-
if (preMonth <= 0) {
|
|
491
|
-
preMonth = 12;
|
|
492
|
-
preYear += 1;
|
|
493
|
-
}
|
|
494
|
-
const currMonthDays = Utils.getMonthDays(String(curData[0]), String(curData[1]));
|
|
495
|
-
const preCurrMonthDays = Utils.getMonthDays(preYear + "", preMonth + "");
|
|
496
|
-
const title = {
|
|
497
|
-
year: curData[0],
|
|
498
|
-
month: curData[1]
|
|
499
|
-
};
|
|
500
|
-
const monthInfo = {
|
|
501
|
-
curData,
|
|
502
|
-
title: translate("monthTitle", title.year, title.month),
|
|
503
|
-
monthData: [
|
|
504
|
-
...getPreDaysStatus(
|
|
505
|
-
preMonthDays,
|
|
506
|
-
"prev",
|
|
507
|
-
{ month: String(preMonth), year: String(preYear) },
|
|
508
|
-
preCurrMonthDays
|
|
509
|
-
),
|
|
510
|
-
...getDaysStatus(currMonthDays, "curr", title)
|
|
511
|
-
],
|
|
512
|
-
cssHeight: 0,
|
|
513
|
-
cssScrollHeight: 0
|
|
514
|
-
};
|
|
515
|
-
monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
|
|
516
|
-
let cssScrollHeight = 0;
|
|
517
|
-
if (state.monthsData.length > 0) {
|
|
518
|
-
cssScrollHeight = state.monthsData[state.monthsData.length - 1].cssScrollHeight + state.monthsData[state.monthsData.length - 1].cssHeight;
|
|
519
|
-
}
|
|
520
|
-
monthInfo.cssScrollHeight = cssScrollHeight;
|
|
521
|
-
if (type == "next") {
|
|
522
|
-
if (!state.endData || !Utils.compareDate(
|
|
523
|
-
`${state.endData[0]}-${state.endData[1]}-${Utils.getMonthDays(state.endData[0], state.endData[1])}`,
|
|
524
|
-
`${curData[0]}-${curData[1]}-${curData[2]}`
|
|
525
|
-
)) {
|
|
526
|
-
state.monthsData.push(monthInfo);
|
|
527
|
-
}
|
|
528
|
-
} else {
|
|
529
|
-
if (!state.startData || !Utils.compareDate(
|
|
530
|
-
`${curData[0]}-${curData[1]}-${curData[2]}`,
|
|
531
|
-
`${state.startData[0]}-${state.startData[1]}-01`
|
|
532
|
-
)) {
|
|
533
|
-
state.monthsData.unshift(monthInfo);
|
|
534
|
-
} else {
|
|
535
|
-
state.unLoadPrev = true;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
const initData = () => {
|
|
540
|
-
let propStartDate = props.startDate ? props.startDate : Utils.getDay(0);
|
|
541
|
-
let propEndDate = props.endDate ? props.endDate : Utils.getDay(365);
|
|
542
|
-
state.propStartDate = propStartDate;
|
|
543
|
-
state.propEndDate = propEndDate;
|
|
544
|
-
state.startData = splitDate(propStartDate);
|
|
545
|
-
state.endData = splitDate(propEndDate);
|
|
546
|
-
if (props.defaultValue || Array.isArray(props.defaultValue) && props.defaultValue.length > 0) {
|
|
547
|
-
state.currDate = props.type !== "one" ? [...props.defaultValue] : props.defaultValue;
|
|
548
|
-
}
|
|
549
|
-
const startDate = {
|
|
550
|
-
year: Number(state.startData[0]),
|
|
551
|
-
month: Number(state.startData[1])
|
|
552
|
-
};
|
|
553
|
-
const endDate = {
|
|
554
|
-
year: Number(state.endData[0]),
|
|
555
|
-
month: Number(state.endData[1])
|
|
556
|
-
};
|
|
557
|
-
let monthsNum = endDate.month - startDate.month;
|
|
558
|
-
if (endDate.year - startDate.year > 0) {
|
|
559
|
-
monthsNum = monthsNum + 12 * (endDate.year - startDate.year);
|
|
560
|
-
}
|
|
561
|
-
if (monthsNum <= 0) {
|
|
562
|
-
monthsNum = 1;
|
|
563
|
-
}
|
|
564
|
-
getMonth(state.startData, "next");
|
|
565
|
-
let i = 1;
|
|
566
|
-
do {
|
|
567
|
-
getMonth(getCurrData("next"), "next");
|
|
568
|
-
} while (i++ < monthsNum);
|
|
569
|
-
state.monthsNum = monthsNum;
|
|
570
|
-
if (props.type == "range" && Array.isArray(state.currDate)) {
|
|
571
|
-
if (state.currDate.length > 0) {
|
|
572
|
-
if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
|
|
573
|
-
state.currDate.splice(0, 1, propStartDate);
|
|
574
|
-
}
|
|
575
|
-
if (propEndDate && Utils.compareDate(propEndDate, state.currDate[1])) {
|
|
576
|
-
state.currDate.splice(1, 1, propEndDate);
|
|
577
|
-
}
|
|
578
|
-
state.defaultData = [...splitDate(state.currDate[0]), ...splitDate(state.currDate[1])];
|
|
579
|
-
}
|
|
580
|
-
} else if (props.type == "multiple" && Array.isArray(state.currDate)) {
|
|
581
|
-
if (state.currDate.length > 0) {
|
|
582
|
-
let defaultArr = [];
|
|
583
|
-
let obj = {};
|
|
584
|
-
state.currDate.forEach((item) => {
|
|
585
|
-
if (propStartDate && !Utils.compareDate(item, propStartDate) && propEndDate && !Utils.compareDate(propEndDate, item)) {
|
|
586
|
-
if (!Object.hasOwnProperty.call(obj, item)) {
|
|
587
|
-
defaultArr.push(item);
|
|
588
|
-
obj[item] = item;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
state.currDate = [...defaultArr];
|
|
593
|
-
state.defaultData = [...splitDate(defaultArr[0])];
|
|
594
|
-
}
|
|
595
|
-
} else if (props.type == "week" && Array.isArray(state.currDate)) {
|
|
596
|
-
if (state.currDate.length > 0) {
|
|
597
|
-
let [y, m, d] = splitDate(state.currDate[0]);
|
|
598
|
-
let weekArr = Utils.getWeekDate(y, m, d, props.firstDayOfWeek);
|
|
599
|
-
state.currDate = weekArr;
|
|
600
|
-
if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
|
|
601
|
-
state.currDate.splice(0, 1, propStartDate);
|
|
602
|
-
}
|
|
603
|
-
if (propEndDate && Utils.compareDate(propEndDate, state.currDate[1])) {
|
|
604
|
-
state.currDate.splice(1, 1, propEndDate);
|
|
605
|
-
}
|
|
606
|
-
state.defaultData = [...splitDate(state.currDate[0]), ...splitDate(state.currDate[1])];
|
|
607
|
-
}
|
|
608
|
-
} else {
|
|
609
|
-
if (state.currDate) {
|
|
610
|
-
if (propStartDate && Utils.compareDate(state.currDate, propStartDate)) {
|
|
611
|
-
state.currDate = propStartDate;
|
|
612
|
-
} else if (propEndDate && !Utils.compareDate(state.currDate, propEndDate)) {
|
|
613
|
-
state.currDate = propEndDate;
|
|
614
|
-
}
|
|
615
|
-
state.defaultData = [...splitDate(state.currDate)];
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
let current = 0;
|
|
619
|
-
let lastCurrent = 0;
|
|
620
|
-
if (state.defaultData.length > 0) {
|
|
621
|
-
state.monthsData.forEach((item, index) => {
|
|
622
|
-
if (item.title == translate("monthTitle", state.defaultData[0], state.defaultData[1])) {
|
|
623
|
-
current = index;
|
|
624
|
-
}
|
|
625
|
-
if (props.type == "range" || props.type == "week") {
|
|
626
|
-
if (item.title == translate("monthTitle", state.defaultData[3], state.defaultData[4])) {
|
|
627
|
-
lastCurrent = index;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
setDefaultRange(monthsNum, current);
|
|
633
|
-
state.currentIndex = current;
|
|
634
|
-
state.yearMonthTitle = state.monthsData[state.currentIndex].title;
|
|
635
|
-
if (state.defaultData.length > 0) {
|
|
636
|
-
if (state.isRange) {
|
|
637
|
-
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
638
|
-
chooseDay({ day: state.defaultData[5], type: "curr" }, state.monthsData[lastCurrent], true);
|
|
639
|
-
} else if (props.type == "week") {
|
|
640
|
-
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
641
|
-
} else if (props.type == "multiple") {
|
|
642
|
-
[...state.currDate].forEach((item) => {
|
|
643
|
-
let dateArr = splitDate(item);
|
|
644
|
-
let current2 = state.currentIndex;
|
|
645
|
-
state.monthsData.forEach((item2, index) => {
|
|
646
|
-
if (item2.title == translate("monthTitle", dateArr[0], dateArr[1])) {
|
|
647
|
-
current2 = index;
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
chooseDay({ day: dateArr[2], type: "curr" }, state.monthsData[current2], true);
|
|
651
|
-
});
|
|
652
|
-
} else {
|
|
653
|
-
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
let lastItem = state.monthsData[state.monthsData.length - 1];
|
|
657
|
-
let containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
|
|
658
|
-
requestAniFrame(() => {
|
|
659
|
-
if ((months == null ? void 0 : months.value) && (monthsPanel == null ? void 0 : monthsPanel.value) && (viewArea == null ? void 0 : viewArea.value)) {
|
|
660
|
-
viewHeight.value = months.value.clientHeight;
|
|
661
|
-
monthsPanel.value.style.height = `${containerHeight}px`;
|
|
662
|
-
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
|
|
666
|
-
};
|
|
667
|
-
const scrollToDate = (date) => {
|
|
668
|
-
if (Utils.compareDate(date, state.propStartDate)) {
|
|
669
|
-
date = state.propStartDate;
|
|
670
|
-
} else if (!Utils.compareDate(date, state.propEndDate)) {
|
|
671
|
-
date = state.propEndDate;
|
|
672
|
-
}
|
|
673
|
-
let dateArr = splitDate(date);
|
|
674
|
-
state.monthsData.forEach((item, index) => {
|
|
675
|
-
if (item.title == translate("monthTitle", dateArr[0], dateArr[1])) {
|
|
676
|
-
if (months.value) {
|
|
677
|
-
let distance = state.monthsData[index].cssScrollHeight - months.value.scrollTop;
|
|
678
|
-
if (props.toDateAnimation) {
|
|
679
|
-
let flag = 0;
|
|
680
|
-
let interval = setInterval(() => {
|
|
681
|
-
flag++;
|
|
682
|
-
if (months.value) {
|
|
683
|
-
let offset = distance / 10;
|
|
684
|
-
months.value.scrollTop = months.value.scrollTop + offset;
|
|
685
|
-
}
|
|
686
|
-
if (flag >= 10) {
|
|
687
|
-
clearInterval(interval);
|
|
688
|
-
if (months.value) {
|
|
689
|
-
months.value.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}, 40);
|
|
693
|
-
} else {
|
|
694
|
-
months.value.scrollTop = state.monthsData[index].cssScrollHeight;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
});
|
|
699
|
-
};
|
|
700
|
-
const initPosition = () => {
|
|
701
|
-
if (months == null ? void 0 : months.value) {
|
|
702
|
-
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
expose({
|
|
706
|
-
scrollToDate,
|
|
707
|
-
initPosition
|
|
708
|
-
});
|
|
709
|
-
const setDefaultRange = (monthsNum, current) => {
|
|
710
|
-
if (monthsNum >= 3) {
|
|
711
|
-
if (current > 0 && current < monthsNum) {
|
|
712
|
-
state.defaultRange = [current - 1, current + 3];
|
|
713
|
-
} else if (current == 0) {
|
|
714
|
-
state.defaultRange = [current, current + 4];
|
|
715
|
-
} else if (current == monthsNum) {
|
|
716
|
-
state.defaultRange = [current - 2, current + 2];
|
|
717
|
-
}
|
|
718
|
-
} else {
|
|
719
|
-
state.defaultRange = [0, monthsNum + 2];
|
|
720
|
-
}
|
|
721
|
-
let defaultScrollTop = state.monthsData[state.defaultRange[0]].cssScrollHeight;
|
|
722
|
-
state.translateY = defaultScrollTop;
|
|
723
|
-
};
|
|
724
|
-
const isActive = (day, month) => {
|
|
725
|
-
return (props.type == "range" || props.type == "week") && day.type == "curr" && getClass(day, month).includes("nut-calendar__day--active");
|
|
726
|
-
};
|
|
727
|
-
const isStartTip = (day, month) => {
|
|
728
|
-
return isActive(day, month) && isStart(getCurrDate(day, month));
|
|
729
|
-
};
|
|
730
|
-
const isEndTip = (day, month) => {
|
|
731
|
-
if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
|
|
732
|
-
return isActive(day, month);
|
|
733
|
-
}
|
|
734
|
-
return false;
|
|
735
|
-
};
|
|
736
|
-
const rangeTip = () => {
|
|
737
|
-
if (state.currDate.length >= 2) {
|
|
738
|
-
return Utils.isEqual(state.currDate[0], state.currDate[1]);
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
const isCurrDay = (dateInfo) => {
|
|
742
|
-
const date = `${dateInfo.year}-${dateInfo.month}-${Number(dateInfo.day) < 10 ? "0" + dateInfo.day : dateInfo.day}`;
|
|
743
|
-
return Utils.isEqual(date, Utils.date2Str(/* @__PURE__ */ new Date()));
|
|
744
|
-
};
|
|
745
|
-
const mothsViewScroll = (e) => {
|
|
746
|
-
if (state.monthsData.length <= 1) {
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
const currentScrollTop = e.target.scrollTop;
|
|
750
|
-
let current = Math.floor(currentScrollTop / state.avgHeight);
|
|
751
|
-
if (current == 0) {
|
|
752
|
-
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
753
|
-
current += 1;
|
|
754
|
-
}
|
|
755
|
-
} else if (current > 0 && current < state.monthsNum - 1) {
|
|
756
|
-
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
757
|
-
current += 1;
|
|
758
|
-
}
|
|
759
|
-
if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
|
|
760
|
-
current -= 1;
|
|
761
|
-
}
|
|
762
|
-
} else {
|
|
763
|
-
const viewPosition = Math.round(currentScrollTop + viewHeight.value);
|
|
764
|
-
if (viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight && currentScrollTop > state.monthsData[current - 1].cssScrollHeight) {
|
|
765
|
-
current -= 1;
|
|
766
|
-
}
|
|
767
|
-
if (current + 1 <= state.monthsNum && viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight) {
|
|
768
|
-
current += 1;
|
|
769
|
-
}
|
|
770
|
-
if (current >= 1 && currentScrollTop < state.monthsData[current - 1].cssScrollHeight) {
|
|
771
|
-
current -= 1;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
if (state.currentIndex !== current) {
|
|
775
|
-
state.currentIndex = current;
|
|
776
|
-
setDefaultRange(state.monthsNum, current);
|
|
777
|
-
}
|
|
778
|
-
state.yearMonthTitle = state.monthsData[current].title;
|
|
779
|
-
};
|
|
780
|
-
const resetRender = () => {
|
|
781
|
-
state.chooseData.splice(0);
|
|
782
|
-
state.monthsData.splice(0);
|
|
783
|
-
initData();
|
|
784
|
-
};
|
|
785
|
-
onMounted(() => {
|
|
786
|
-
initData();
|
|
787
|
-
});
|
|
788
|
-
watch(
|
|
789
|
-
() => props.defaultValue,
|
|
790
|
-
(val) => {
|
|
791
|
-
if (val) {
|
|
792
|
-
if (props.poppable) {
|
|
793
|
-
resetRender();
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
);
|
|
798
|
-
return __spreadProps(__spreadValues(__spreadValues({
|
|
799
|
-
weeks,
|
|
800
|
-
compConthsData,
|
|
801
|
-
showTopBtn,
|
|
802
|
-
topInfo,
|
|
803
|
-
bottomInfo,
|
|
804
|
-
rangeTip,
|
|
805
|
-
mothsViewScroll,
|
|
806
|
-
getClass,
|
|
807
|
-
isStartTip,
|
|
808
|
-
isEndTip,
|
|
809
|
-
chooseDay,
|
|
810
|
-
isCurrDay,
|
|
811
|
-
confirm,
|
|
812
|
-
months
|
|
813
|
-
}, toRefs(state)), toRefs(props)), {
|
|
814
|
-
translate,
|
|
815
|
-
monthsPanel,
|
|
816
|
-
weeksPanel,
|
|
817
|
-
viewArea
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
});
|
|
821
|
-
const _hoisted_1 = { class: "nut-calendar__header" };
|
|
822
|
-
const _hoisted_2 = {
|
|
823
|
-
key: 0,
|
|
824
|
-
class: "nut-calendar__header-title"
|
|
825
|
-
};
|
|
826
|
-
const _hoisted_3 = {
|
|
827
|
-
key: 1,
|
|
828
|
-
class: "nut-calendar__header-slot"
|
|
829
|
-
};
|
|
830
|
-
const _hoisted_4 = {
|
|
831
|
-
key: 2,
|
|
832
|
-
class: "nut-calendar__header-subtitle"
|
|
833
|
-
};
|
|
834
|
-
const _hoisted_5 = {
|
|
835
|
-
ref: "weeksPanel",
|
|
836
|
-
class: "nut-calendar__weekdays"
|
|
837
|
-
};
|
|
838
|
-
const _hoisted_6 = {
|
|
839
|
-
ref: "monthsPanel",
|
|
840
|
-
class: "nut-calendar__panel"
|
|
841
|
-
};
|
|
842
|
-
const _hoisted_7 = { class: "nut-calendar__month-title" };
|
|
843
|
-
const _hoisted_8 = { class: "nut-calendar__days" };
|
|
844
|
-
const _hoisted_9 = ["onClick"];
|
|
845
|
-
const _hoisted_10 = { class: "nut-calendar__day-value" };
|
|
846
|
-
const _hoisted_11 = {
|
|
847
|
-
key: 0,
|
|
848
|
-
class: "nut-calendar__day-tips nut-calendar__day-tips--top"
|
|
849
|
-
};
|
|
850
|
-
const _hoisted_12 = {
|
|
851
|
-
key: 1,
|
|
852
|
-
class: "nut-calendar__day-tips nut-calendar__day-tips--bottom"
|
|
853
|
-
};
|
|
854
|
-
const _hoisted_13 = {
|
|
855
|
-
key: 2,
|
|
856
|
-
class: "nut-calendar__day-tips--curr"
|
|
857
|
-
};
|
|
858
|
-
const _hoisted_14 = {
|
|
859
|
-
key: 4,
|
|
860
|
-
class: "nut-calendar__day-tip"
|
|
861
|
-
};
|
|
862
|
-
const _hoisted_15 = {
|
|
863
|
-
key: 0,
|
|
864
|
-
class: "nut-calendar__footer"
|
|
865
|
-
};
|
|
866
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
867
|
-
return openBlock(), createElementBlock("view", {
|
|
868
|
-
class: normalizeClass(["nut-calendar", {
|
|
869
|
-
"nut-calendar--nopop": !_ctx.poppable,
|
|
870
|
-
"nut-calendar--nofooter": _ctx.isAutoBackFill
|
|
871
|
-
}])
|
|
872
|
-
}, [
|
|
873
|
-
createElementVNode("view", _hoisted_1, [
|
|
874
|
-
_ctx.showTitle ? (openBlock(), createElementBlock("view", _hoisted_2, toDisplayString(_ctx.title || _ctx.translate("title")), 1)) : createCommentVNode("", true),
|
|
875
|
-
_ctx.showTopBtn ? (openBlock(), createElementBlock("view", _hoisted_3, [
|
|
876
|
-
renderSlot(_ctx.$slots, "btn")
|
|
877
|
-
])) : createCommentVNode("", true),
|
|
878
|
-
_ctx.showSubTitle ? (openBlock(), createElementBlock("view", _hoisted_4, toDisplayString(_ctx.yearMonthTitle), 1)) : createCommentVNode("", true),
|
|
879
|
-
createElementVNode("view", _hoisted_5, [
|
|
880
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (item, index) => {
|
|
881
|
-
return openBlock(), createElementBlock("view", {
|
|
882
|
-
key: index,
|
|
883
|
-
class: normalizeClass(["nut-calendar__weekday", { weekend: item.weekend }])
|
|
884
|
-
}, toDisplayString(item.day), 3);
|
|
885
|
-
}), 128))
|
|
886
|
-
], 512)
|
|
887
|
-
]),
|
|
888
|
-
createElementVNode("view", {
|
|
889
|
-
ref: "months",
|
|
890
|
-
class: "nut-calendar__content",
|
|
891
|
-
onScroll: _cache[0] || (_cache[0] = (...args) => _ctx.mothsViewScroll && _ctx.mothsViewScroll(...args))
|
|
892
|
-
}, [
|
|
893
|
-
createElementVNode("view", _hoisted_6, [
|
|
894
|
-
createElementVNode("view", {
|
|
895
|
-
ref: "viewArea",
|
|
896
|
-
class: "nut-calendar__body",
|
|
897
|
-
style: normalizeStyle({ transform: `translateY(${_ctx.translateY}px)` })
|
|
898
|
-
}, [
|
|
899
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.compConthsData, (month, index) => {
|
|
900
|
-
return openBlock(), createElementBlock("view", {
|
|
901
|
-
key: index,
|
|
902
|
-
class: "nut-calendar__month"
|
|
903
|
-
}, [
|
|
904
|
-
createElementVNode("view", _hoisted_7, toDisplayString(month.title), 1),
|
|
905
|
-
createElementVNode("view", _hoisted_8, [
|
|
906
|
-
createElementVNode("view", {
|
|
907
|
-
class: normalizeClass(["nut-calendar__days-item", _ctx.type === "range" ? "nut-calendar__days-item--range" : ""])
|
|
908
|
-
}, [
|
|
909
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(month.monthData, (day, i) => {
|
|
910
|
-
return openBlock(), createElementBlock("view", {
|
|
911
|
-
key: i,
|
|
912
|
-
class: normalizeClass(["nut-calendar__day", _ctx.getClass(day, month, i)]),
|
|
913
|
-
onClick: ($event) => _ctx.chooseDay(day, month)
|
|
914
|
-
}, [
|
|
915
|
-
createElementVNode("view", _hoisted_10, [
|
|
916
|
-
renderSlot(_ctx.$slots, "day", {
|
|
917
|
-
date: day.type == "curr" ? day : ""
|
|
918
|
-
}, () => [
|
|
919
|
-
createTextVNode(toDisplayString(day.type == "curr" ? day.day : ""), 1)
|
|
920
|
-
])
|
|
921
|
-
]),
|
|
922
|
-
_ctx.topInfo ? (openBlock(), createElementBlock("view", _hoisted_11, [
|
|
923
|
-
renderSlot(_ctx.$slots, "top-info", {
|
|
924
|
-
date: day.type == "curr" ? day : ""
|
|
925
|
-
})
|
|
926
|
-
])) : createCommentVNode("", true),
|
|
927
|
-
_ctx.bottomInfo ? (openBlock(), createElementBlock("view", _hoisted_12, [
|
|
928
|
-
renderSlot(_ctx.$slots, "bottom-info", {
|
|
929
|
-
date: day.type == "curr" ? day : ""
|
|
930
|
-
})
|
|
931
|
-
])) : createCommentVNode("", true),
|
|
932
|
-
!_ctx.bottomInfo && _ctx.showToday && _ctx.isCurrDay(day) ? (openBlock(), createElementBlock("view", _hoisted_13, toDisplayString(_ctx.translate("today")), 1)) : createCommentVNode("", true),
|
|
933
|
-
_ctx.isStartTip(day, month) ? (openBlock(), createElementBlock("view", {
|
|
934
|
-
key: 3,
|
|
935
|
-
class: normalizeClass(["nut-calendar__day-tip", { "nut-calendar__day-tips--top": _ctx.rangeTip() }])
|
|
936
|
-
}, toDisplayString(_ctx.startText || _ctx.translate("start")), 3)) : createCommentVNode("", true),
|
|
937
|
-
_ctx.isEndTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_14, toDisplayString(_ctx.endText || _ctx.translate("end")), 1)) : createCommentVNode("", true)
|
|
938
|
-
], 10, _hoisted_9);
|
|
939
|
-
}), 128))
|
|
940
|
-
], 2)
|
|
941
|
-
])
|
|
942
|
-
]);
|
|
943
|
-
}), 128))
|
|
944
|
-
], 4)
|
|
945
|
-
], 512)
|
|
946
|
-
], 544),
|
|
947
|
-
_ctx.poppable && !_ctx.isAutoBackFill ? (openBlock(), createElementBlock("view", _hoisted_15, [
|
|
948
|
-
renderSlot(_ctx.$slots, "footer-info", { date: _ctx.chooseData }, () => [
|
|
949
|
-
createElementVNode("view", {
|
|
950
|
-
class: "nut-calendar__confirm",
|
|
951
|
-
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.confirm && _ctx.confirm(...args))
|
|
952
|
-
}, toDisplayString(_ctx.confirmText || _ctx.translate("confirm")), 1)
|
|
953
|
-
])
|
|
954
|
-
])) : createCommentVNode("", true)
|
|
955
|
-
], 2);
|
|
956
|
-
}
|
|
957
|
-
const NutCalendarItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
958
|
-
export {
|
|
959
|
-
NutCalendarItem as N,
|
|
960
|
-
Utils as U
|
|
961
|
-
};
|