@nutui/nutui 3.1.22 → 3.1.23-beta.0

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