@nutui/nutui 4.3.2 → 4.3.4
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/CHANGELOG.md +40 -0
- package/dist/nutui.es.js +2 -4
- package/dist/nutui.js +7000 -7518
- package/dist/nutui.umd.js +1 -1
- package/dist/packages/{Interceptor-WYVtGbGC.js → Interceptor-DlY2h6Y7.js} +2 -2
- package/dist/packages/actionsheet/ActionSheet.js +3 -3
- package/dist/packages/address/Address.js +5 -5
- package/dist/packages/addresslist/AddressList.js +6 -6
- package/dist/packages/animate/Animate.js +1 -1
- package/dist/packages/audio/Audio.js +2 -2
- package/dist/packages/audiooperate/AudioOperate.js +3 -3
- package/dist/packages/avatar/Avatar.js +2 -2
- package/dist/packages/avatarcropper/AvatarCropper.js +5 -5
- package/dist/packages/avatargroup/AvatarGroup.js +3 -3
- package/dist/packages/backtop/Backtop.js +80 -90
- package/dist/packages/badge/Badge.js +2 -2
- package/dist/packages/barrage/Barrage.js +2 -2
- package/dist/packages/button/Button.js +1 -1
- package/dist/packages/calendar/Calendar.js +817 -6
- package/dist/packages/calendar/index.scss +0 -1
- package/dist/packages/calendarcard/CalendarCard.js +4 -4
- package/dist/packages/card/Card.js +4 -4
- package/dist/packages/cascader/Cascader.js +4 -4
- package/dist/packages/category/Category.js +4 -4
- package/dist/packages/categorypane/CategoryPane.js +5 -5
- package/dist/packages/cell/Cell.js +4 -4
- package/dist/packages/cellgroup/CellGroup.js +2 -2
- package/dist/packages/checkbox/Checkbox.js +4 -4
- package/dist/packages/checkboxgroup/CheckboxGroup.js +2 -2
- package/dist/packages/circleprogress/CircleProgress.js +91 -98
- package/dist/packages/col/Col.js +2 -2
- package/dist/packages/collapse/Collapse.js +2 -2
- package/dist/packages/collapseitem/CollapseItem.js +3 -3
- package/dist/packages/comment/Comment.js +6 -6
- package/dist/packages/{common-4inKawxR.js → common-Chr7cC9o.js} +2 -2
- package/dist/packages/{common-FZL3qC99.js → common-DRG0ue26.js} +1 -1
- package/dist/packages/configprovider/ConfigProvider.js +1 -1
- package/dist/packages/countdown/Countdown.js +4 -4
- package/dist/packages/countup/Countup.js +9 -9
- package/dist/packages/{date-djiVNSnJ.js → date-DHXcwF1m.js} +2 -2
- package/dist/packages/datepicker/DatePicker.js +3 -3
- package/dist/packages/dialog/Dialog.js +8 -8
- package/dist/packages/divider/Divider.js +1 -1
- package/dist/packages/drag/Drag.js +3 -3
- package/dist/packages/ecard/Ecard.js +5 -5
- package/dist/packages/elevator/Elevator.js +2 -2
- package/dist/packages/ellipsis/Ellipsis.js +4 -4
- package/dist/packages/empty/Empty.js +67 -52
- package/dist/packages/fixednav/FixedNav.js +3 -3
- package/dist/packages/form/Form.js +4 -4
- package/dist/packages/formitem/FormItem.js +4 -4
- package/dist/packages/grid/Grid.js +2 -2
- package/dist/packages/griditem/GridItem.js +5 -5
- package/dist/packages/image/Image.js +3 -3
- package/dist/packages/imagepreview/ImagePreview.js +8 -8
- package/dist/packages/{index-s3RgMhc7.js → index-CFigyH92.js} +1 -1
- package/dist/packages/{index--uVlasFu.js → index-Do4_KY74.js} +2 -2
- package/dist/packages/{index-BqB5dTeo.js → index-uHBD4dfS.js} +2 -2
- package/dist/packages/{index.vue_vue_type_script_lang-n0HbjvfF.js → index.vue_vue_type_script_lang-CTQUvlgN.js} +4 -4
- package/dist/packages/{index.vue_vue_type_script_lang-54PRh3YM.js → index.vue_vue_type_script_lang-CaSiRl9x.js} +2 -2
- package/dist/packages/indicator/Indicator.js +56 -50
- package/dist/packages/infiniteloading/InfiniteLoading.js +6 -6
- package/dist/packages/input/Input.js +10 -10
- package/dist/packages/inputnumber/InputNumber.js +85 -104
- package/dist/packages/invoice/Invoice.js +87 -138
- package/dist/packages/layout/Layout.js +2 -2
- package/dist/packages/list/List.js +3 -3
- package/dist/packages/locale/lang/en-US.js +1 -1
- package/dist/packages/locale/lang/id-ID.js +1 -1
- package/dist/packages/locale/lang/index.js +2 -2
- package/dist/packages/locale/lang/zh-CN.js +1 -1
- package/dist/packages/locale/lang/zh-TW.js +1 -1
- package/dist/packages/menu/Menu.js +5 -5
- package/dist/packages/menuitem/MenuItem.js +5 -5
- package/dist/packages/{mountComponent-uInXoTMp.js → mountComponent-DBQ88Fjz.js} +1 -1
- package/dist/packages/navbar/Navbar.js +103 -115
- package/dist/packages/noticebar/Noticebar.js +3 -3
- package/dist/packages/notify/Notify.js +3 -3
- package/dist/packages/numberkeyboard/NumberKeyboard.js +4 -4
- package/dist/packages/overlay/Overlay.js +3 -3
- package/dist/packages/pagination/Pagination.js +3 -3
- package/dist/packages/picker/Picker.js +7 -10
- package/dist/packages/popover/Popover.js +5 -5
- package/dist/packages/popup/Popup.js +2 -2
- package/dist/packages/price/Price.js +1 -1
- package/dist/packages/progress/Progress.js +96 -115
- package/dist/packages/pullrefresh/PullRefresh.js +7 -7
- package/dist/packages/radio/Radio.js +1 -1
- package/dist/packages/radiogroup/RadioGroup.js +1 -1
- package/dist/packages/range/Range.js +6 -6
- package/dist/packages/rate/Rate.js +102 -144
- package/dist/packages/row/Row.js +2 -2
- package/dist/packages/searchbar/Searchbar.js +5 -5
- package/dist/packages/shortpassword/ShortPassword.js +5 -5
- package/dist/packages/sidenavbar/SideNavbar.js +2 -2
- package/dist/packages/sidenavbaritem/SideNavbarItem.js +2 -2
- package/dist/packages/signature/Signature.js +3 -3
- package/dist/packages/skeleton/Skeleton.js +13 -13
- package/dist/packages/sku/Sku.js +6 -6
- package/dist/packages/space/Space.js +1 -1
- package/dist/packages/step/Step.js +3 -3
- package/dist/packages/steps/Steps.js +2 -2
- package/dist/packages/sticky/Sticky.js +4 -4
- package/dist/packages/subsidenavbar/SubSideNavbar.js +2 -2
- package/dist/packages/swipe/Swipe.js +98 -112
- package/dist/packages/swipegroup/SwipeGroup.js +42 -24
- package/dist/packages/swiper/Swiper.js +7 -7
- package/dist/packages/swiperitem/SwiperItem.js +3 -3
- package/dist/packages/switch/Switch.js +68 -86
- package/dist/packages/tabbar/Tabbar.js +78 -78
- package/dist/packages/tabbaritem/TabbarItem.js +89 -113
- package/dist/packages/table/Table.js +3 -3
- package/dist/packages/tabpane/TabPane.js +2 -2
- package/dist/packages/tabs/Tabs.js +9 -9
- package/dist/packages/tag/Tag.js +57 -66
- package/dist/packages/textarea/Textarea.js +113 -127
- package/dist/packages/timedetail/TimeDetail.js +2 -2
- package/dist/packages/timepannel/TimePannel.js +2 -2
- package/dist/packages/timeselect/TimeSelect.js +4 -4
- package/dist/packages/toast/Toast.js +6 -6
- package/dist/packages/tour/Tour.js +3 -3
- package/dist/packages/trendarrow/TrendArrow.js +51 -83
- package/dist/packages/uploader/Uploader.js +9 -9
- package/dist/packages/{useChildren-GU_NVfD8.js → useChildren-BZ4-J79J.js} +2 -2
- package/dist/packages/useParent-D6DiuxZZ.js +21 -0
- package/dist/packages/{util-4Jkyw4BJ.js → util-DnfK0Qan.js} +2 -2
- package/dist/packages/video/Video.js +16 -16
- package/dist/packages/watermark/Watermark.js +2 -2
- package/dist/smartips/web-types.json +2 -2
- 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 +0 -1
- package/dist/styles/themes/jdb.scss +0 -1
- package/dist/styles/themes/jddkh.scss +0 -1
- package/dist/styles/themes/jdt.scss +0 -1
- package/dist/styles/variables-jdb.scss +0 -1
- package/dist/styles/variables-jddkh.scss +0 -1
- package/dist/styles/variables-jdt.scss +0 -1
- package/dist/styles/variables.scss +0 -1
- package/dist/types/__VUE/backtop/backtop.vue.d.ts +87 -0
- package/dist/types/__VUE/backtop/index.d.ts +5 -0
- package/dist/types/__VUE/calendaritem/index.vue.d.ts +2 -12
- package/dist/types/__VUE/circleprogress/circle-progress.vue.d.ts +88 -0
- package/dist/types/__VUE/circleprogress/index.d.ts +6 -0
- package/dist/types/__VUE/empty/empty.vue.d.ts +62 -0
- package/dist/types/__VUE/empty/index.d.ts +6 -0
- package/dist/types/__VUE/indicator/index.d.ts +6 -0
- package/dist/types/__VUE/indicator/indicator.vue.d.ts +65 -0
- package/dist/types/__VUE/inputnumber/index.d.ts +5 -0
- package/dist/types/__VUE/inputnumber/input-number.vue.d.ts +112 -0
- package/dist/types/__VUE/invoice/index.d.ts +6 -0
- package/dist/types/__VUE/invoice/invoice.vue.d.ts +59 -0
- package/dist/types/__VUE/invoice/types.d.ts +12 -0
- package/dist/types/__VUE/navbar/index.d.ts +5 -0
- package/dist/types/__VUE/navbar/navbar.vue.d.ts +125 -0
- package/dist/types/__VUE/progress/index.d.ts +6 -0
- package/dist/types/__VUE/progress/progress.vue.d.ts +91 -0
- package/dist/types/__VUE/rate/index.d.ts +5 -0
- package/dist/types/__VUE/rate/rate.vue.d.ts +208 -0
- package/dist/types/__VUE/swipe/index.d.ts +6 -0
- package/dist/types/__VUE/swipe/swipe.vue.d.ts +79 -0
- package/dist/types/__VUE/swipe/types.d.ts +1 -0
- package/dist/types/__VUE/swipegroup/index.d.ts +5 -0
- package/dist/types/__VUE/swipegroup/swipe-group.vue.d.ts +47 -0
- package/dist/types/__VUE/switch/index.d.ts +5 -0
- package/dist/types/__VUE/switch/switch.vue.d.ts +109 -0
- package/dist/types/__VUE/tabbar/index.d.ts +5 -0
- package/dist/types/__VUE/tabbar/tabbar.vue.d.ts +83 -0
- package/dist/types/__VUE/tabbaritem/index.d.ts +5 -0
- package/dist/types/__VUE/tabbaritem/tabbar-item.vue.d.ts +65 -0
- package/dist/types/__VUE/tabs/index.vue.d.ts +12 -12
- package/dist/types/__VUE/tag/index.d.ts +6 -0
- package/dist/types/__VUE/tag/tag.vue.d.ts +90 -0
- package/dist/types/__VUE/tag/types.d.ts +1 -1
- package/dist/types/__VUE/textarea/index.d.ts +5 -0
- package/dist/types/__VUE/textarea/textarea.vue.d.ts +104 -0
- package/dist/types/__VUE/trendarrow/index.d.ts +5 -0
- package/dist/types/__VUE/trendarrow/trend-arrow.vue.d.ts +96 -0
- package/dist/types/index.d.ts +36 -20
- package/dist/types/utils/throttle.d.ts +1 -1
- package/dist/types/utils/useRelation/useParent.d.ts +1 -0
- package/package.json +1 -1
- package/dist/packages/calendaritem/CalendarItem.js +0 -819
- package/dist/packages/calendaritem/index.css +0 -0
- package/dist/packages/calendaritem/index.mjs +0 -2
- package/dist/packages/calendaritem/index.scss +0 -0
- package/dist/packages/calendaritem/style/css.mjs +0 -2
- package/dist/packages/calendaritem/style/index.mjs +0 -2
- package/dist/packages/useParent-KIxqkovs.js +0 -16
- package/dist/types/__VUE/backtop/index.vue.d.ts +0 -98
- package/dist/types/__VUE/circleprogress/index.vue.d.ts +0 -95
- package/dist/types/__VUE/empty/index.vue.d.ts +0 -53
- package/dist/types/__VUE/indicator/index.vue.d.ts +0 -69
- package/dist/types/__VUE/inputnumber/index.vue.d.ts +0 -117
- package/dist/types/__VUE/invoice/index.vue.d.ts +0 -53
- package/dist/types/__VUE/navbar/index.vue.d.ts +0 -129
- package/dist/types/__VUE/progress/index.vue.d.ts +0 -120
- package/dist/types/__VUE/rate/index.vue.d.ts +0 -240
- package/dist/types/__VUE/swipe/index.vue.d.ts +0 -70
- package/dist/types/__VUE/swipegroup/index.vue.d.ts +0 -26
- package/dist/types/__VUE/switch/index.vue.d.ts +0 -118
- package/dist/types/__VUE/tabbar/index.vue.d.ts +0 -85
- package/dist/types/__VUE/tabbaritem/index.vue.d.ts +0 -60
- package/dist/types/__VUE/tag/index.vue.d.ts +0 -94
- package/dist/types/__VUE/textarea/index.vue.d.ts +0 -127
- package/dist/types/__VUE/trendarrow/index.vue.d.ts +0 -102
- /package/dist/packages/{_plugin-vue_export-helper-yVxbj29m.js → _plugin-vue_export-helper-1tPrXgE0.js} +0 -0
- /package/dist/packages/{component-TCzwHGVq.js → component-DQf3CENX.js} +0 -0
- /package/dist/packages/{index-cp6Ms_Qe.js → index-B1qsj2XR.js} +0 -0
- /package/dist/packages/{index-xDfQLRen.js → index-BvmDLUYP.js} +0 -0
- /package/dist/packages/{index-084nl_oE.js → index-I8tfW3Kf.js} +0 -0
- /package/dist/packages/{index-Ii9XdkPy.js → index-aiGQ-EiA.js} +0 -0
- /package/dist/packages/locale/lang/{baseLang-7uiEiO-2.js → baseLang-Bnfy6fTl.js} +0 -0
- /package/dist/packages/{pxCheck-OnXlN1NC.js → pxCheck-DN6FYV6q.js} +0 -0
- /package/dist/packages/{raf-MQjoO-Ag.js → raf-c01wDYCo.js} +0 -0
- /package/dist/packages/{renderIcon--EgZu5_5.js → renderIcon-BfOvhG7i.js} +0 -0
- /package/dist/packages/{types-RCVUm7Nb.js → types-1HzUV14W.js} +0 -0
- /package/dist/packages/{types-zeKkNDAq.js → types-48N1bMrT.js} +0 -0
- /package/dist/packages/{types-Ww4ErYJT.js → types-BKDaJvHp.js} +0 -0
- /package/dist/packages/{types-odSRziQJ.js → types-BODurTjN.js} +0 -0
- /package/dist/packages/{types-qOrhXtA_.js → types-BWhKcf4T.js} +0 -0
- /package/dist/packages/{types-4IflWeQO.js → types-BomhFk3T.js} +0 -0
- /package/dist/packages/{types-j71K23JP.js → types-CkPfROfI.js} +0 -0
- /package/dist/packages/{types-9wCQwtH3.js → types-DUkJysbi.js} +0 -0
- /package/dist/packages/{types-Cq2YypZn.js → types-MuhxzCWc.js} +0 -0
- /package/dist/packages/{with-install-p59gYYU_.js → with-install-Ch3FF0uS.js} +0 -0
|
@@ -1,9 +1,820 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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, resolveComponent, createBlock, mergeProps, withCtx, createVNode, createSlots } from "vue";
|
|
21
|
+
import { c as createComponent } from "../component-DQf3CENX.js";
|
|
22
|
+
import { U as Utils } from "../date-DHXcwF1m.js";
|
|
23
|
+
import { r as requestAniFrame } from "../raf-c01wDYCo.js";
|
|
24
|
+
import { u as useLocale } from "../index-CFigyH92.js";
|
|
25
|
+
import { _ as _export_sfc } from "../_plugin-vue_export-helper-1tPrXgE0.js";
|
|
26
|
+
import { N as NutPopup } from "../index-uHBD4dfS.js";
|
|
27
|
+
const { create: create$1 } = createComponent("calendar-item");
|
|
28
|
+
const cN = "NutCalendarItem";
|
|
29
|
+
const _sfc_main$1 = create$1({
|
|
30
|
+
props: {
|
|
31
|
+
type: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "one"
|
|
34
|
+
},
|
|
35
|
+
isAutoBackFill: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: false
|
|
38
|
+
},
|
|
39
|
+
toDateAnimation: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: true
|
|
42
|
+
},
|
|
43
|
+
poppable: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: true
|
|
46
|
+
},
|
|
47
|
+
showTitle: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: true
|
|
50
|
+
},
|
|
51
|
+
showSubTitle: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: true
|
|
54
|
+
},
|
|
55
|
+
showToday: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true
|
|
58
|
+
},
|
|
59
|
+
title: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: ""
|
|
62
|
+
},
|
|
63
|
+
confirmText: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: ""
|
|
66
|
+
},
|
|
67
|
+
startText: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: ""
|
|
70
|
+
},
|
|
71
|
+
endText: {
|
|
72
|
+
type: String,
|
|
73
|
+
default: ""
|
|
74
|
+
},
|
|
75
|
+
defaultValue: {
|
|
76
|
+
type: [String, Array],
|
|
77
|
+
default: ""
|
|
78
|
+
},
|
|
79
|
+
startDate: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: Utils.getDay(0)
|
|
82
|
+
},
|
|
83
|
+
endDate: {
|
|
84
|
+
type: String,
|
|
85
|
+
default: Utils.getDay(365)
|
|
86
|
+
},
|
|
87
|
+
firstDayOfWeek: {
|
|
88
|
+
type: Number,
|
|
89
|
+
default: 0
|
|
90
|
+
},
|
|
91
|
+
disabledDate: Function
|
|
92
|
+
},
|
|
93
|
+
emits: ["choose", "update", "close", "select"],
|
|
94
|
+
setup(props, { emit, slots, expose }) {
|
|
95
|
+
const translate = useLocale(cN);
|
|
96
|
+
const weekdays = translate("weekdays").map((day, index2) => ({
|
|
97
|
+
day,
|
|
98
|
+
weekend: index2 === 0 || index2 === 6
|
|
99
|
+
}));
|
|
100
|
+
const weeks = ref([...weekdays.slice(props.firstDayOfWeek, 7), ...weekdays.slice(0, props.firstDayOfWeek)]);
|
|
101
|
+
const months = ref(null);
|
|
102
|
+
const monthsPanel = ref(null);
|
|
103
|
+
const weeksPanel = ref(null);
|
|
104
|
+
const viewArea = ref(null);
|
|
105
|
+
const viewHeight = ref(0);
|
|
106
|
+
const compConthsData = computed(() => {
|
|
107
|
+
return state.monthsData.slice(state.defaultRange[0], state.defaultRange[1]);
|
|
108
|
+
});
|
|
109
|
+
const showTopBtn = computed(() => {
|
|
110
|
+
return slots.btn;
|
|
111
|
+
});
|
|
112
|
+
const topInfo = computed(() => {
|
|
113
|
+
return slots["top-info"];
|
|
114
|
+
});
|
|
115
|
+
const bottomInfo = computed(() => {
|
|
116
|
+
return slots["bottom-info"];
|
|
117
|
+
});
|
|
118
|
+
const state = reactive({
|
|
119
|
+
yearMonthTitle: "",
|
|
120
|
+
defaultRange: [],
|
|
121
|
+
currDate: "",
|
|
122
|
+
propStartDate: "",
|
|
123
|
+
propEndDate: "",
|
|
124
|
+
unLoadPrev: false,
|
|
125
|
+
touchParams: {
|
|
126
|
+
startY: 0,
|
|
127
|
+
endY: 0,
|
|
128
|
+
startTime: 0,
|
|
129
|
+
endTime: 0,
|
|
130
|
+
lastY: 0,
|
|
131
|
+
lastTime: 0
|
|
132
|
+
},
|
|
133
|
+
transformY: 0,
|
|
134
|
+
translateY: 0,
|
|
135
|
+
scrollDistance: 0,
|
|
136
|
+
defaultData: [],
|
|
137
|
+
chooseData: [],
|
|
138
|
+
monthsData: [],
|
|
139
|
+
dayPrefix: "nut-calendar__day",
|
|
140
|
+
startData: "",
|
|
141
|
+
endData: "",
|
|
142
|
+
isRange: props.type === "range",
|
|
143
|
+
timer: 0,
|
|
144
|
+
currentIndex: 0,
|
|
145
|
+
avgHeight: 0,
|
|
146
|
+
monthsNum: 0
|
|
147
|
+
});
|
|
148
|
+
const splitDate = (date) => {
|
|
149
|
+
return date.split("-");
|
|
150
|
+
};
|
|
151
|
+
const isStart = (currDate) => {
|
|
152
|
+
return Utils.isEqual(state.currDate[0], currDate);
|
|
153
|
+
};
|
|
154
|
+
const isEnd = (currDate) => {
|
|
155
|
+
return Utils.isEqual(state.currDate[1], currDate);
|
|
156
|
+
};
|
|
157
|
+
const isMultiple = (currDate) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
if (((_a = state.currDate) == null ? void 0 : _a.length) > 0) {
|
|
160
|
+
return (_b = state.currDate) == null ? void 0 : _b.some((item) => {
|
|
161
|
+
return Utils.isEqual(item, currDate);
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const getCurrDate = (day, month) => {
|
|
168
|
+
return month.curData[0] + "-" + month.curData[1] + "-" + Utils.getNumTwoBit(+day.day);
|
|
169
|
+
};
|
|
170
|
+
const getClass = (day, month, index2) => {
|
|
171
|
+
const res = [];
|
|
172
|
+
if (typeof index2 === "number" && ((index2 + 1 + props.firstDayOfWeek) % 7 === 0 || (index2 + props.firstDayOfWeek) % 7 === 0)) {
|
|
173
|
+
res.push("weekend");
|
|
174
|
+
}
|
|
175
|
+
const currDate = getCurrDate(day, month);
|
|
176
|
+
const { type } = props;
|
|
177
|
+
if (day.type == "curr") {
|
|
178
|
+
if (Utils.isEqual(state.currDate, currDate) || (type == "range" || type == "week") && (isStart(currDate) || isEnd(currDate)) || type == "multiple" && isMultiple(currDate)) {
|
|
179
|
+
res.push(`${state.dayPrefix}--active`);
|
|
180
|
+
} else if (state.propStartDate && Utils.compareDate(currDate, state.propStartDate) || state.propEndDate && Utils.compareDate(state.propEndDate, currDate) || props.disabledDate && props.disabledDate(currDate)) {
|
|
181
|
+
res.push(`${state.dayPrefix}--disabled`);
|
|
182
|
+
} 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])) {
|
|
183
|
+
res.push(`${state.dayPrefix}--choose`);
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
res.push(`${state.dayPrefix}--disabled`);
|
|
187
|
+
}
|
|
188
|
+
return res;
|
|
189
|
+
};
|
|
190
|
+
const confirm = () => {
|
|
191
|
+
const { type } = props;
|
|
192
|
+
if (type == "range" && state.chooseData.length == 2 || type != "range") {
|
|
193
|
+
let selectData = state.chooseData.slice(0);
|
|
194
|
+
if (type == "week") {
|
|
195
|
+
if (state.chooseData.length !== 2) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
selectData = {
|
|
199
|
+
weekDate: [handleWeekDate(state.chooseData[0]), handleWeekDate(state.chooseData[1])]
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
emit("choose", selectData);
|
|
203
|
+
if (props.poppable) {
|
|
204
|
+
emit("update");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const chooseDay = (day, month, isFirst = false) => {
|
|
209
|
+
var _a, _b;
|
|
210
|
+
if (!getClass(day, month).includes(`${state.dayPrefix}--disabled`)) {
|
|
211
|
+
const { type } = props;
|
|
212
|
+
let [y, m] = month.curData;
|
|
213
|
+
let days = [...month.curData];
|
|
214
|
+
days[2] = Utils.getNumTwoBit(Number(day.day));
|
|
215
|
+
days[3] = `${days[0]}-${days[1]}-${days[2]}`;
|
|
216
|
+
days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
|
|
217
|
+
if (type == "multiple") {
|
|
218
|
+
if (((_a = state.currDate) == null ? void 0 : _a.length) > 0) {
|
|
219
|
+
let hasIndex = void 0;
|
|
220
|
+
(_b = state.currDate) == null ? void 0 : _b.forEach((item, index2) => {
|
|
221
|
+
if (item == days[3]) {
|
|
222
|
+
hasIndex = index2;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
if (isFirst) {
|
|
226
|
+
state.chooseData.push([...days]);
|
|
227
|
+
} else {
|
|
228
|
+
if (hasIndex !== void 0) {
|
|
229
|
+
state.currDate.splice(hasIndex, 1);
|
|
230
|
+
state.chooseData.splice(hasIndex, 1);
|
|
231
|
+
} else {
|
|
232
|
+
state.currDate.push(days[3]);
|
|
233
|
+
state.chooseData.push([...days]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
state.currDate = [days[3]];
|
|
238
|
+
state.chooseData = [[...days]];
|
|
239
|
+
}
|
|
240
|
+
} else if (type == "range") {
|
|
241
|
+
let curDataLength = Object.values(state.currDate).length;
|
|
242
|
+
if (curDataLength == 2 || curDataLength == 0) {
|
|
243
|
+
state.currDate = [days[3]];
|
|
244
|
+
} else {
|
|
245
|
+
if (Utils.compareDate(state.currDate[0], days[3])) {
|
|
246
|
+
Array.isArray(state.currDate) && state.currDate.push(days[3]);
|
|
247
|
+
} else {
|
|
248
|
+
Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (state.chooseData.length == 2 || !state.chooseData.length) {
|
|
252
|
+
state.chooseData = [[...days]];
|
|
253
|
+
} else {
|
|
254
|
+
if (Utils.compareDate(state.chooseData[0][3], days[3])) {
|
|
255
|
+
state.chooseData = [...state.chooseData, [...days]];
|
|
256
|
+
} else {
|
|
257
|
+
state.chooseData = [[...days], ...state.chooseData];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
} else if (type == "week") {
|
|
261
|
+
let weekArr = Utils.getWeekDate(y, m, day.day, props.firstDayOfWeek);
|
|
262
|
+
if (state.propStartDate && Utils.compareDate(weekArr[0], state.propStartDate)) {
|
|
263
|
+
weekArr.splice(0, 1, state.propStartDate);
|
|
264
|
+
}
|
|
265
|
+
if (state.propEndDate && Utils.compareDate(state.propEndDate, weekArr[1])) {
|
|
266
|
+
weekArr.splice(1, 1, state.propEndDate);
|
|
267
|
+
}
|
|
268
|
+
state.currDate = weekArr;
|
|
269
|
+
state.chooseData = [Utils.formatResultDate(weekArr[0]), Utils.formatResultDate(weekArr[1])];
|
|
270
|
+
} else {
|
|
271
|
+
state.currDate = days[3];
|
|
272
|
+
state.chooseData = [...days];
|
|
273
|
+
}
|
|
274
|
+
if (!isFirst) {
|
|
275
|
+
let selectData = state.chooseData;
|
|
276
|
+
if (type == "week") {
|
|
277
|
+
selectData = {
|
|
278
|
+
weekDate: [
|
|
279
|
+
handleWeekDate(state.chooseData[0]),
|
|
280
|
+
handleWeekDate(state.chooseData[1])
|
|
281
|
+
]
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
emit("select", selectData);
|
|
285
|
+
if (props.isAutoBackFill || !props.poppable) {
|
|
286
|
+
confirm();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const handleWeekDate = (weekDate) => {
|
|
292
|
+
let [y, m, d] = weekDate;
|
|
293
|
+
let obj = {
|
|
294
|
+
date: weekDate,
|
|
295
|
+
monthWeekNum: Utils.getMonthWeek(y, m, d, props.firstDayOfWeek),
|
|
296
|
+
yearWeekNum: Utils.getYearWeek(y, m, d, props.firstDayOfWeek)
|
|
297
|
+
};
|
|
298
|
+
return obj;
|
|
299
|
+
};
|
|
300
|
+
const getCurrData = (type) => {
|
|
301
|
+
const monthData = type == "prev" ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
|
|
302
|
+
let year = parseInt(monthData.curData[0]);
|
|
303
|
+
let month = parseInt(monthData.curData[1].toString().replace(/^0/, ""));
|
|
304
|
+
switch (type) {
|
|
305
|
+
case "prev":
|
|
306
|
+
month == 1 && (year -= 1);
|
|
307
|
+
month = month == 1 ? 12 : --month;
|
|
308
|
+
break;
|
|
309
|
+
case "next":
|
|
310
|
+
month == 12 && (year += 1);
|
|
311
|
+
month = month == 12 ? 1 : ++month;
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
return [year + "", Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month)) + ""];
|
|
315
|
+
};
|
|
316
|
+
const getDaysStatus = (days, type, dateInfo) => {
|
|
317
|
+
let { year, month } = dateInfo;
|
|
318
|
+
if (type == "prev" && days >= 7) {
|
|
319
|
+
days -= 7;
|
|
320
|
+
}
|
|
321
|
+
return Array.from(Array(days), (v, k) => {
|
|
322
|
+
return {
|
|
323
|
+
day: String(k + 1),
|
|
324
|
+
type,
|
|
325
|
+
year,
|
|
326
|
+
month
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
const getPreDaysStatus = (days, type, dateInfo, preCurrMonthDays) => {
|
|
331
|
+
days = days - props.firstDayOfWeek;
|
|
332
|
+
let { year, month } = dateInfo;
|
|
333
|
+
if (type == "prev" && days >= 7) {
|
|
334
|
+
days -= 7;
|
|
335
|
+
}
|
|
336
|
+
let months2 = Array.from(Array(preCurrMonthDays), (v, k) => {
|
|
337
|
+
return {
|
|
338
|
+
day: String(k + 1),
|
|
339
|
+
type,
|
|
340
|
+
year,
|
|
341
|
+
month
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
return months2.slice(preCurrMonthDays - days);
|
|
345
|
+
};
|
|
346
|
+
const getMonth = (curData, type) => {
|
|
347
|
+
const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
|
|
348
|
+
let preMonth = Number(curData[1]) - 1;
|
|
349
|
+
let preYear = Number(curData[0]);
|
|
350
|
+
if (preMonth <= 0) {
|
|
351
|
+
preMonth = 12;
|
|
352
|
+
preYear += 1;
|
|
353
|
+
}
|
|
354
|
+
const currMonthDays = Utils.getMonthDays(String(curData[0]), String(curData[1]));
|
|
355
|
+
const preCurrMonthDays = Utils.getMonthDays(preYear + "", preMonth + "");
|
|
356
|
+
const title = {
|
|
357
|
+
year: curData[0],
|
|
358
|
+
month: curData[1]
|
|
359
|
+
};
|
|
360
|
+
const monthInfo = {
|
|
361
|
+
curData,
|
|
362
|
+
title: translate("monthTitle", title.year, title.month),
|
|
363
|
+
monthData: [
|
|
364
|
+
...getPreDaysStatus(
|
|
365
|
+
preMonthDays,
|
|
366
|
+
"prev",
|
|
367
|
+
{ month: String(preMonth), year: String(preYear) },
|
|
368
|
+
preCurrMonthDays
|
|
369
|
+
),
|
|
370
|
+
...getDaysStatus(currMonthDays, "curr", title)
|
|
371
|
+
],
|
|
372
|
+
cssHeight: 0,
|
|
373
|
+
cssScrollHeight: 0
|
|
374
|
+
};
|
|
375
|
+
monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
|
|
376
|
+
let cssScrollHeight = 0;
|
|
377
|
+
if (state.monthsData.length > 0) {
|
|
378
|
+
cssScrollHeight = state.monthsData[state.monthsData.length - 1].cssScrollHeight + state.monthsData[state.monthsData.length - 1].cssHeight;
|
|
379
|
+
}
|
|
380
|
+
monthInfo.cssScrollHeight = cssScrollHeight;
|
|
381
|
+
if (type == "next") {
|
|
382
|
+
if (!state.endData || !Utils.compareDate(
|
|
383
|
+
`${state.endData[0]}-${state.endData[1]}-${Utils.getMonthDays(state.endData[0], state.endData[1])}`,
|
|
384
|
+
`${curData[0]}-${curData[1]}-${curData[2]}`
|
|
385
|
+
)) {
|
|
386
|
+
state.monthsData.push(monthInfo);
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
if (!state.startData || !Utils.compareDate(
|
|
390
|
+
`${curData[0]}-${curData[1]}-${curData[2]}`,
|
|
391
|
+
`${state.startData[0]}-${state.startData[1]}-01`
|
|
392
|
+
)) {
|
|
393
|
+
state.monthsData.unshift(monthInfo);
|
|
394
|
+
} else {
|
|
395
|
+
state.unLoadPrev = true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const initData = () => {
|
|
400
|
+
let propStartDate = props.startDate ? props.startDate : Utils.getDay(0);
|
|
401
|
+
let propEndDate = props.endDate ? props.endDate : Utils.getDay(365);
|
|
402
|
+
state.propStartDate = propStartDate;
|
|
403
|
+
state.propEndDate = propEndDate;
|
|
404
|
+
state.startData = splitDate(propStartDate);
|
|
405
|
+
state.endData = splitDate(propEndDate);
|
|
406
|
+
if (props.defaultValue || Array.isArray(props.defaultValue) && props.defaultValue.length > 0) {
|
|
407
|
+
state.currDate = props.type !== "one" ? [...props.defaultValue] : props.defaultValue;
|
|
408
|
+
}
|
|
409
|
+
const startDate = {
|
|
410
|
+
year: Number(state.startData[0]),
|
|
411
|
+
month: Number(state.startData[1])
|
|
412
|
+
};
|
|
413
|
+
const endDate = {
|
|
414
|
+
year: Number(state.endData[0]),
|
|
415
|
+
month: Number(state.endData[1])
|
|
416
|
+
};
|
|
417
|
+
let monthsNum = endDate.month - startDate.month;
|
|
418
|
+
if (endDate.year - startDate.year > 0) {
|
|
419
|
+
monthsNum = monthsNum + 12 * (endDate.year - startDate.year);
|
|
420
|
+
}
|
|
421
|
+
if (monthsNum <= 0) {
|
|
422
|
+
monthsNum = 1;
|
|
423
|
+
}
|
|
424
|
+
getMonth(state.startData, "next");
|
|
425
|
+
let i = 1;
|
|
426
|
+
do {
|
|
427
|
+
getMonth(getCurrData("next"), "next");
|
|
428
|
+
} while (i++ < monthsNum);
|
|
429
|
+
state.monthsNum = monthsNum;
|
|
430
|
+
if (props.type == "range" && Array.isArray(state.currDate)) {
|
|
431
|
+
if (state.currDate.length > 0) {
|
|
432
|
+
if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
|
|
433
|
+
state.currDate.splice(0, 1, propStartDate);
|
|
434
|
+
}
|
|
435
|
+
if (propEndDate && Utils.compareDate(propEndDate, state.currDate[1])) {
|
|
436
|
+
state.currDate.splice(1, 1, propEndDate);
|
|
437
|
+
}
|
|
438
|
+
state.defaultData = [...splitDate(state.currDate[0]), ...splitDate(state.currDate[1])];
|
|
439
|
+
}
|
|
440
|
+
} else if (props.type == "multiple" && Array.isArray(state.currDate)) {
|
|
441
|
+
if (state.currDate.length > 0) {
|
|
442
|
+
let defaultArr = [];
|
|
443
|
+
let obj = {};
|
|
444
|
+
state.currDate.forEach((item) => {
|
|
445
|
+
if (propStartDate && !Utils.compareDate(item, propStartDate) && propEndDate && !Utils.compareDate(propEndDate, item)) {
|
|
446
|
+
if (!Object.hasOwnProperty.call(obj, item)) {
|
|
447
|
+
defaultArr.push(item);
|
|
448
|
+
obj[item] = item;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
state.currDate = [...defaultArr];
|
|
453
|
+
state.defaultData = [...splitDate(defaultArr[0])];
|
|
454
|
+
}
|
|
455
|
+
} else if (props.type == "week" && Array.isArray(state.currDate)) {
|
|
456
|
+
if (state.currDate.length > 0) {
|
|
457
|
+
let [y, m, d] = splitDate(state.currDate[0]);
|
|
458
|
+
let weekArr = Utils.getWeekDate(y, m, d, props.firstDayOfWeek);
|
|
459
|
+
state.currDate = weekArr;
|
|
460
|
+
if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
|
|
461
|
+
state.currDate.splice(0, 1, propStartDate);
|
|
462
|
+
}
|
|
463
|
+
if (propEndDate && Utils.compareDate(propEndDate, state.currDate[1])) {
|
|
464
|
+
state.currDate.splice(1, 1, propEndDate);
|
|
465
|
+
}
|
|
466
|
+
state.defaultData = [...splitDate(state.currDate[0]), ...splitDate(state.currDate[1])];
|
|
467
|
+
}
|
|
468
|
+
} else {
|
|
469
|
+
if (state.currDate) {
|
|
470
|
+
if (propStartDate && Utils.compareDate(state.currDate, propStartDate)) {
|
|
471
|
+
state.currDate = propStartDate;
|
|
472
|
+
} else if (propEndDate && !Utils.compareDate(state.currDate, propEndDate)) {
|
|
473
|
+
state.currDate = propEndDate;
|
|
474
|
+
}
|
|
475
|
+
state.defaultData = [...splitDate(state.currDate)];
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
let current = 0;
|
|
479
|
+
let lastCurrent = 0;
|
|
480
|
+
if (state.defaultData.length > 0) {
|
|
481
|
+
state.monthsData.forEach((item, index2) => {
|
|
482
|
+
if (item.title == translate("monthTitle", state.defaultData[0], state.defaultData[1])) {
|
|
483
|
+
current = index2;
|
|
484
|
+
}
|
|
485
|
+
if (props.type == "range" || props.type == "week") {
|
|
486
|
+
if (item.title == translate("monthTitle", state.defaultData[3], state.defaultData[4])) {
|
|
487
|
+
lastCurrent = index2;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
setDefaultRange(monthsNum, current);
|
|
493
|
+
state.currentIndex = current;
|
|
494
|
+
state.yearMonthTitle = state.monthsData[state.currentIndex].title;
|
|
495
|
+
if (state.defaultData.length > 0) {
|
|
496
|
+
if (state.isRange) {
|
|
497
|
+
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
498
|
+
chooseDay({ day: state.defaultData[5], type: "curr" }, state.monthsData[lastCurrent], true);
|
|
499
|
+
} else if (props.type == "week") {
|
|
500
|
+
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
501
|
+
} else if (props.type == "multiple") {
|
|
502
|
+
[...state.currDate].forEach((item) => {
|
|
503
|
+
let dateArr = splitDate(item);
|
|
504
|
+
let current2 = state.currentIndex;
|
|
505
|
+
state.monthsData.forEach((item2, index2) => {
|
|
506
|
+
if (item2.title == translate("monthTitle", dateArr[0], dateArr[1])) {
|
|
507
|
+
current2 = index2;
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
chooseDay({ day: dateArr[2], type: "curr" }, state.monthsData[current2], true);
|
|
511
|
+
});
|
|
512
|
+
} else {
|
|
513
|
+
chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
let lastItem = state.monthsData[state.monthsData.length - 1];
|
|
517
|
+
let containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
|
|
518
|
+
requestAniFrame(() => {
|
|
519
|
+
if ((months == null ? void 0 : months.value) && (monthsPanel == null ? void 0 : monthsPanel.value) && (viewArea == null ? void 0 : viewArea.value)) {
|
|
520
|
+
viewHeight.value = months.value.clientHeight;
|
|
521
|
+
monthsPanel.value.style.height = `${containerHeight}px`;
|
|
522
|
+
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
|
|
526
|
+
};
|
|
527
|
+
const scrollToDate = (date) => {
|
|
528
|
+
if (Utils.compareDate(date, state.propStartDate)) {
|
|
529
|
+
date = state.propStartDate;
|
|
530
|
+
} else if (!Utils.compareDate(date, state.propEndDate)) {
|
|
531
|
+
date = state.propEndDate;
|
|
532
|
+
}
|
|
533
|
+
let dateArr = splitDate(date);
|
|
534
|
+
state.monthsData.forEach((item, index2) => {
|
|
535
|
+
if (item.title == translate("monthTitle", dateArr[0], dateArr[1])) {
|
|
536
|
+
if (months.value) {
|
|
537
|
+
let distance = state.monthsData[index2].cssScrollHeight - months.value.scrollTop;
|
|
538
|
+
if (props.toDateAnimation) {
|
|
539
|
+
let flag = 0;
|
|
540
|
+
let interval = setInterval(() => {
|
|
541
|
+
flag++;
|
|
542
|
+
if (months.value) {
|
|
543
|
+
let offset = distance / 10;
|
|
544
|
+
months.value.scrollTop = months.value.scrollTop + offset;
|
|
545
|
+
}
|
|
546
|
+
if (flag >= 10) {
|
|
547
|
+
clearInterval(interval);
|
|
548
|
+
if (months.value) {
|
|
549
|
+
months.value.scrollTop = state.monthsData[index2].cssScrollHeight;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}, 40);
|
|
553
|
+
} else {
|
|
554
|
+
months.value.scrollTop = state.monthsData[index2].cssScrollHeight;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
const initPosition = () => {
|
|
561
|
+
if (months == null ? void 0 : months.value) {
|
|
562
|
+
months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
expose({
|
|
566
|
+
scrollToDate,
|
|
567
|
+
initPosition
|
|
568
|
+
});
|
|
569
|
+
const setDefaultRange = (monthsNum, current) => {
|
|
570
|
+
if (monthsNum >= 3) {
|
|
571
|
+
if (current > 0 && current < monthsNum) {
|
|
572
|
+
state.defaultRange = [current - 1, current + 3];
|
|
573
|
+
} else if (current == 0) {
|
|
574
|
+
state.defaultRange = [current, current + 4];
|
|
575
|
+
} else if (current == monthsNum) {
|
|
576
|
+
state.defaultRange = [current - 2, current + 2];
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
state.defaultRange = [0, monthsNum + 2];
|
|
580
|
+
}
|
|
581
|
+
let defaultScrollTop = state.monthsData[state.defaultRange[0]].cssScrollHeight;
|
|
582
|
+
state.translateY = defaultScrollTop;
|
|
583
|
+
};
|
|
584
|
+
const isActive = (day, month) => {
|
|
585
|
+
return (props.type == "range" || props.type == "week") && day.type == "curr" && getClass(day, month).includes("nut-calendar__day--active");
|
|
586
|
+
};
|
|
587
|
+
const isStartTip = (day, month) => {
|
|
588
|
+
return isActive(day, month) && isStart(getCurrDate(day, month));
|
|
589
|
+
};
|
|
590
|
+
const isEndTip = (day, month) => {
|
|
591
|
+
if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
|
|
592
|
+
return isActive(day, month);
|
|
593
|
+
}
|
|
594
|
+
return false;
|
|
595
|
+
};
|
|
596
|
+
const rangeTip = () => {
|
|
597
|
+
if (state.currDate.length >= 2) {
|
|
598
|
+
return Utils.isEqual(state.currDate[0], state.currDate[1]);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
const isCurrDay = (dateInfo) => {
|
|
602
|
+
const date = `${dateInfo.year}-${dateInfo.month}-${Number(dateInfo.day) < 10 ? "0" + dateInfo.day : dateInfo.day}`;
|
|
603
|
+
return Utils.isEqual(date, Utils.date2Str(/* @__PURE__ */ new Date()));
|
|
604
|
+
};
|
|
605
|
+
const mothsViewScroll = (e) => {
|
|
606
|
+
if (state.monthsData.length <= 1) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const currentScrollTop = e.target.scrollTop;
|
|
610
|
+
let current = Math.floor(currentScrollTop / state.avgHeight);
|
|
611
|
+
if (current == 0) {
|
|
612
|
+
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
613
|
+
current += 1;
|
|
614
|
+
}
|
|
615
|
+
} else if (current > 0 && current < state.monthsNum - 1) {
|
|
616
|
+
if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
|
|
617
|
+
current += 1;
|
|
618
|
+
}
|
|
619
|
+
if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
|
|
620
|
+
current -= 1;
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
const viewPosition = Math.round(currentScrollTop + viewHeight.value);
|
|
624
|
+
if (viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight && currentScrollTop > state.monthsData[current - 1].cssScrollHeight) {
|
|
625
|
+
current -= 1;
|
|
626
|
+
}
|
|
627
|
+
if (current + 1 <= state.monthsNum && viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight) {
|
|
628
|
+
current += 1;
|
|
629
|
+
}
|
|
630
|
+
if (current >= 1 && currentScrollTop < state.monthsData[current - 1].cssScrollHeight) {
|
|
631
|
+
current -= 1;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
if (state.currentIndex !== current) {
|
|
635
|
+
state.currentIndex = current;
|
|
636
|
+
setDefaultRange(state.monthsNum, current);
|
|
637
|
+
}
|
|
638
|
+
state.yearMonthTitle = state.monthsData[current].title;
|
|
639
|
+
};
|
|
640
|
+
const resetRender = () => {
|
|
641
|
+
state.chooseData.splice(0);
|
|
642
|
+
state.monthsData.splice(0);
|
|
643
|
+
initData();
|
|
644
|
+
};
|
|
645
|
+
onMounted(() => {
|
|
646
|
+
initData();
|
|
647
|
+
});
|
|
648
|
+
watch(
|
|
649
|
+
() => props.defaultValue,
|
|
650
|
+
(val) => {
|
|
651
|
+
if (val) {
|
|
652
|
+
if (props.poppable) {
|
|
653
|
+
resetRender();
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
);
|
|
658
|
+
return __spreadProps(__spreadValues(__spreadValues({
|
|
659
|
+
weeks,
|
|
660
|
+
compConthsData,
|
|
661
|
+
showTopBtn,
|
|
662
|
+
topInfo,
|
|
663
|
+
bottomInfo,
|
|
664
|
+
rangeTip,
|
|
665
|
+
mothsViewScroll,
|
|
666
|
+
getClass,
|
|
667
|
+
isStartTip,
|
|
668
|
+
isEndTip,
|
|
669
|
+
chooseDay,
|
|
670
|
+
isCurrDay,
|
|
671
|
+
confirm,
|
|
672
|
+
months
|
|
673
|
+
}, toRefs(state)), toRefs(props)), {
|
|
674
|
+
translate,
|
|
675
|
+
monthsPanel,
|
|
676
|
+
weeksPanel,
|
|
677
|
+
viewArea
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
const _hoisted_1 = { class: "nut-calendar__header" };
|
|
682
|
+
const _hoisted_2 = {
|
|
683
|
+
key: 0,
|
|
684
|
+
class: "nut-calendar__header-title"
|
|
685
|
+
};
|
|
686
|
+
const _hoisted_3 = {
|
|
687
|
+
key: 1,
|
|
688
|
+
class: "nut-calendar__header-slot"
|
|
689
|
+
};
|
|
690
|
+
const _hoisted_4 = {
|
|
691
|
+
key: 2,
|
|
692
|
+
class: "nut-calendar__header-subtitle"
|
|
693
|
+
};
|
|
694
|
+
const _hoisted_5 = {
|
|
695
|
+
ref: "weeksPanel",
|
|
696
|
+
class: "nut-calendar__weekdays"
|
|
697
|
+
};
|
|
698
|
+
const _hoisted_6 = {
|
|
699
|
+
ref: "monthsPanel",
|
|
700
|
+
class: "nut-calendar__panel"
|
|
701
|
+
};
|
|
702
|
+
const _hoisted_7 = { class: "nut-calendar__month-title" };
|
|
703
|
+
const _hoisted_8 = { class: "nut-calendar__days" };
|
|
704
|
+
const _hoisted_9 = ["onClick"];
|
|
705
|
+
const _hoisted_10 = { class: "nut-calendar__day-value" };
|
|
706
|
+
const _hoisted_11 = {
|
|
707
|
+
key: 0,
|
|
708
|
+
class: "nut-calendar__day-tips nut-calendar__day-tips--top"
|
|
709
|
+
};
|
|
710
|
+
const _hoisted_12 = {
|
|
711
|
+
key: 1,
|
|
712
|
+
class: "nut-calendar__day-tips nut-calendar__day-tips--bottom"
|
|
713
|
+
};
|
|
714
|
+
const _hoisted_13 = {
|
|
715
|
+
key: 2,
|
|
716
|
+
class: "nut-calendar__day-tips--curr"
|
|
717
|
+
};
|
|
718
|
+
const _hoisted_14 = {
|
|
719
|
+
key: 4,
|
|
720
|
+
class: "nut-calendar__day-tip"
|
|
721
|
+
};
|
|
722
|
+
const _hoisted_15 = {
|
|
723
|
+
key: 0,
|
|
724
|
+
class: "nut-calendar__footer"
|
|
725
|
+
};
|
|
726
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
727
|
+
return openBlock(), createElementBlock("view", {
|
|
728
|
+
class: normalizeClass(["nut-calendar", {
|
|
729
|
+
"nut-calendar--nopop": !_ctx.poppable,
|
|
730
|
+
"nut-calendar--nofooter": _ctx.isAutoBackFill
|
|
731
|
+
}])
|
|
732
|
+
}, [
|
|
733
|
+
createElementVNode("view", _hoisted_1, [
|
|
734
|
+
_ctx.showTitle ? (openBlock(), createElementBlock("view", _hoisted_2, toDisplayString(_ctx.title || _ctx.translate("title")), 1)) : createCommentVNode("", true),
|
|
735
|
+
_ctx.showTopBtn ? (openBlock(), createElementBlock("view", _hoisted_3, [
|
|
736
|
+
renderSlot(_ctx.$slots, "btn")
|
|
737
|
+
])) : createCommentVNode("", true),
|
|
738
|
+
_ctx.showSubTitle ? (openBlock(), createElementBlock("view", _hoisted_4, toDisplayString(_ctx.yearMonthTitle), 1)) : createCommentVNode("", true),
|
|
739
|
+
createElementVNode("view", _hoisted_5, [
|
|
740
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (item, index2) => {
|
|
741
|
+
return openBlock(), createElementBlock("view", {
|
|
742
|
+
key: index2,
|
|
743
|
+
class: normalizeClass(["nut-calendar__weekday", { weekend: item.weekend }])
|
|
744
|
+
}, toDisplayString(item.day), 3);
|
|
745
|
+
}), 128))
|
|
746
|
+
], 512)
|
|
747
|
+
]),
|
|
748
|
+
createElementVNode("view", {
|
|
749
|
+
ref: "months",
|
|
750
|
+
class: "nut-calendar__content",
|
|
751
|
+
onScroll: _cache[0] || (_cache[0] = (...args) => _ctx.mothsViewScroll && _ctx.mothsViewScroll(...args))
|
|
752
|
+
}, [
|
|
753
|
+
createElementVNode("view", _hoisted_6, [
|
|
754
|
+
createElementVNode("view", {
|
|
755
|
+
ref: "viewArea",
|
|
756
|
+
class: "nut-calendar__body",
|
|
757
|
+
style: normalizeStyle({ transform: `translateY(${_ctx.translateY}px)` })
|
|
758
|
+
}, [
|
|
759
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.compConthsData, (month, index2) => {
|
|
760
|
+
return openBlock(), createElementBlock("view", {
|
|
761
|
+
key: index2,
|
|
762
|
+
class: "nut-calendar__month"
|
|
763
|
+
}, [
|
|
764
|
+
createElementVNode("view", _hoisted_7, toDisplayString(month.title), 1),
|
|
765
|
+
createElementVNode("view", _hoisted_8, [
|
|
766
|
+
createElementVNode("view", {
|
|
767
|
+
class: normalizeClass(["nut-calendar__days-item", _ctx.type === "range" ? "nut-calendar__days-item--range" : ""])
|
|
768
|
+
}, [
|
|
769
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(month.monthData, (day, i) => {
|
|
770
|
+
return openBlock(), createElementBlock("view", {
|
|
771
|
+
key: i,
|
|
772
|
+
class: normalizeClass(["nut-calendar__day", _ctx.getClass(day, month, i)]),
|
|
773
|
+
onClick: ($event) => _ctx.chooseDay(day, month)
|
|
774
|
+
}, [
|
|
775
|
+
createElementVNode("view", _hoisted_10, [
|
|
776
|
+
renderSlot(_ctx.$slots, "day", {
|
|
777
|
+
date: day.type == "curr" ? day : ""
|
|
778
|
+
}, () => [
|
|
779
|
+
createTextVNode(toDisplayString(day.type == "curr" ? day.day : ""), 1)
|
|
780
|
+
])
|
|
781
|
+
]),
|
|
782
|
+
_ctx.topInfo ? (openBlock(), createElementBlock("view", _hoisted_11, [
|
|
783
|
+
renderSlot(_ctx.$slots, "top-info", {
|
|
784
|
+
date: day.type == "curr" ? day : ""
|
|
785
|
+
})
|
|
786
|
+
])) : createCommentVNode("", true),
|
|
787
|
+
_ctx.bottomInfo ? (openBlock(), createElementBlock("view", _hoisted_12, [
|
|
788
|
+
renderSlot(_ctx.$slots, "bottom-info", {
|
|
789
|
+
date: day.type == "curr" ? day : ""
|
|
790
|
+
})
|
|
791
|
+
])) : createCommentVNode("", true),
|
|
792
|
+
!_ctx.bottomInfo && _ctx.showToday && _ctx.isCurrDay(day) ? (openBlock(), createElementBlock("view", _hoisted_13, toDisplayString(_ctx.translate("today")), 1)) : createCommentVNode("", true),
|
|
793
|
+
_ctx.isStartTip(day, month) ? (openBlock(), createElementBlock("view", {
|
|
794
|
+
key: 3,
|
|
795
|
+
class: normalizeClass(["nut-calendar__day-tip", { "nut-calendar__day-tips--top": _ctx.rangeTip() }])
|
|
796
|
+
}, toDisplayString(_ctx.startText || _ctx.translate("start")), 3)) : createCommentVNode("", true),
|
|
797
|
+
_ctx.isEndTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_14, toDisplayString(_ctx.endText || _ctx.translate("end")), 1)) : createCommentVNode("", true)
|
|
798
|
+
], 10, _hoisted_9);
|
|
799
|
+
}), 128))
|
|
800
|
+
], 2)
|
|
801
|
+
])
|
|
802
|
+
]);
|
|
803
|
+
}), 128))
|
|
804
|
+
], 4)
|
|
805
|
+
], 512)
|
|
806
|
+
], 544),
|
|
807
|
+
_ctx.poppable && !_ctx.isAutoBackFill ? (openBlock(), createElementBlock("view", _hoisted_15, [
|
|
808
|
+
renderSlot(_ctx.$slots, "footer-info", { date: _ctx.chooseData }, () => [
|
|
809
|
+
createElementVNode("view", {
|
|
810
|
+
class: "nut-calendar__confirm",
|
|
811
|
+
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.confirm && _ctx.confirm(...args))
|
|
812
|
+
}, toDisplayString(_ctx.confirmText || _ctx.translate("confirm")), 1)
|
|
813
|
+
])
|
|
814
|
+
])) : createCommentVNode("", true)
|
|
815
|
+
], 2);
|
|
816
|
+
}
|
|
817
|
+
const NutCalendarItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
7
818
|
const { create } = createComponent("calendar");
|
|
8
819
|
const _sfc_main = create({
|
|
9
820
|
components: {
|