@nutui/nutui 3.1.22-beta.3 → 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 (207) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -4
  3. package/dist/nutui.es.js +20426 -4050
  4. package/dist/nutui.umd.js +20529 -4049
  5. package/dist/packages/_es/ActionSheet.js +149 -36
  6. package/dist/packages/_es/Address.js +535 -129
  7. package/dist/packages/_es/AddressList.js +615 -113
  8. package/dist/packages/_es/Animate.js +64 -0
  9. package/dist/packages/_es/Audio.js +257 -72
  10. package/dist/packages/_es/AudioOperate.js +100 -32
  11. package/dist/packages/_es/Avatar.js +162 -54
  12. package/dist/packages/_es/AvatarGroup.js +73 -14
  13. package/dist/packages/_es/BackTop.js +156 -43
  14. package/dist/packages/_es/Badge.js +86 -14
  15. package/dist/packages/_es/Barrage.js +120 -41
  16. package/dist/packages/_es/Button.js +128 -23
  17. package/dist/packages/_es/Calendar.js +246 -24
  18. package/dist/packages/_es/CalendarItem.js +2 -1
  19. package/dist/packages/_es/Card.js +107 -10
  20. package/dist/packages/_es/Cascader.js +496 -179
  21. package/dist/packages/_es/Category.js +58 -15
  22. package/dist/packages/_es/CategoryPane.js +111 -11
  23. package/dist/packages/_es/Cell.js +108 -21
  24. package/dist/packages/_es/CellGroup.js +44 -9
  25. package/dist/packages/_es/Checkbox.js +134 -29
  26. package/dist/packages/_es/CheckboxGroup.js +79 -29
  27. package/dist/packages/_es/CircleProgress.js +150 -28
  28. package/dist/packages/_es/Col.js +56 -14
  29. package/dist/packages/_es/Collapse.js +110 -24
  30. package/dist/packages/_es/CollapseItem.js +252 -80
  31. package/dist/packages/_es/Comment.js +434 -64
  32. package/dist/packages/_es/ConfigProvider.js +25 -0
  33. package/dist/packages/_es/CountDown.js +238 -75
  34. package/dist/packages/_es/CountUp.js +539 -159
  35. package/dist/packages/_es/DatePicker.js +315 -117
  36. package/dist/packages/_es/Dialog.js +289 -79
  37. package/dist/packages/_es/Divider.js +65 -32
  38. package/dist/packages/_es/Drag.js +197 -56
  39. package/dist/packages/_es/Ecard.js +159 -24
  40. package/dist/packages/_es/Elevator.js +255 -77
  41. package/dist/packages/_es/Ellipsis.js +206 -0
  42. package/dist/packages/_es/Empty.js +71 -12
  43. package/dist/packages/_es/FixedNav.js +122 -15
  44. package/dist/packages/_es/Form.js +151 -64
  45. package/dist/packages/_es/FormItem.js +114 -15
  46. package/dist/packages/_es/Grid.js +6 -5
  47. package/dist/packages/_es/GridItem.js +144 -33
  48. package/dist/packages/_es/Icon.js +40 -15
  49. package/dist/packages/_es/Image.js +142 -0
  50. package/dist/packages/_es/ImagePreview.js +547 -84
  51. package/dist/packages/_es/Indicator.js +62 -15
  52. package/dist/packages/_es/InfiniteLoading.js +249 -76
  53. package/dist/packages/_es/Input.js +433 -51
  54. package/dist/packages/_es/InputNumber.js +160 -41
  55. package/dist/packages/_es/Layout.js +5 -4
  56. package/dist/packages/_es/List.js +106 -37
  57. package/dist/packages/_es/Menu.js +168 -29
  58. package/dist/packages/_es/MenuItem.js +173 -34
  59. package/dist/packages/_es/Navbar.js +192 -30
  60. package/dist/packages/_es/NoticeBar.js +380 -93
  61. package/dist/packages/_es/Notify.js +227 -91
  62. package/dist/packages/_es/NumberKeyboard.js +272 -41
  63. package/dist/packages/_es/OldPicker.js +457 -149
  64. package/dist/packages/_es/OverLay.js +98 -40
  65. package/dist/packages/_es/Pagination.js +157 -39
  66. package/dist/packages/_es/Picker.js +460 -148
  67. package/dist/packages/_es/Popover.js +957 -337
  68. package/dist/packages/_es/Popup.js +299 -74
  69. package/dist/packages/_es/Price.js +118 -16
  70. package/dist/packages/_es/Progress.js +146 -14
  71. package/dist/packages/_es/PullRefresh.js +339 -100
  72. package/dist/packages/_es/Radio.js +90 -22
  73. package/dist/packages/_es/RadioGroup.js +37 -8
  74. package/dist/packages/_es/Range.js +408 -102
  75. package/dist/packages/_es/Rate.js +193 -16
  76. package/dist/packages/_es/Row.js +64 -22
  77. package/dist/packages/_es/SearchBar.js +238 -56
  78. package/dist/packages/_es/ShortPassword.js +225 -35
  79. package/dist/packages/_es/SideNavBar.js +81 -43
  80. package/dist/packages/_es/SideNavBarItem.js +46 -11
  81. package/dist/packages/_es/Signature.js +160 -60
  82. package/dist/packages/_es/Skeleton.js +136 -20
  83. package/dist/packages/_es/Sku.js +491 -103
  84. package/dist/packages/_es/Step.js +115 -39
  85. package/dist/packages/_es/Steps.js +53 -18
  86. package/dist/packages/_es/Sticky.js +138 -53
  87. package/dist/packages/_es/SubSideNavBar.js +82 -36
  88. package/dist/packages/_es/Swipe.js +178 -60
  89. package/dist/packages/_es/Swiper.js +433 -121
  90. package/dist/packages/_es/SwiperItem.js +53 -22
  91. package/dist/packages/_es/Switch.js +116 -21
  92. package/dist/packages/_es/TabPane.js +39 -12
  93. package/dist/packages/_es/Tabbar.js +72 -17
  94. package/dist/packages/_es/TabbarItem.js +151 -29
  95. package/dist/packages/_es/Table.js +178 -37
  96. package/dist/packages/_es/Tabs.js +202 -59
  97. package/dist/packages/_es/Tag.js +97 -20
  98. package/dist/packages/_es/TextArea.js +160 -42
  99. package/dist/packages/_es/TimeDetail.js +79 -37
  100. package/dist/packages/_es/TimePannel.js +48 -33
  101. package/dist/packages/_es/TimeSelect.js +112 -15
  102. package/dist/packages/_es/Toast.js +310 -90
  103. package/dist/packages/_es/Uploader.js +455 -120
  104. package/dist/packages/_es/Video.js +332 -93
  105. package/dist/packages/_es/common.js +128 -38
  106. package/dist/packages/_es/component.js +76 -35
  107. package/dist/packages/_es/index.js +6 -5
  108. package/dist/packages/_es/index2.js +30 -9
  109. package/dist/packages/_es/index3.js +8 -6
  110. package/dist/packages/_es/index4.js +64 -13
  111. package/dist/packages/_es/index5.js +783 -130
  112. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  113. package/dist/packages/_es/pxCheck.js +5 -3
  114. package/dist/packages/_es/raf.js +15 -8
  115. package/dist/packages/animate/index.scss +299 -0
  116. package/dist/packages/cell/index.scss +7 -1
  117. package/dist/packages/checkbox/index.scss +10 -0
  118. package/dist/packages/configprovider/index.scss +2 -0
  119. package/dist/packages/ellipsis/index.scss +12 -0
  120. package/dist/packages/formitem/index.scss +12 -0
  121. package/dist/packages/griditem/index.scss +11 -0
  122. package/dist/packages/image/index.scss +39 -0
  123. package/dist/packages/imagepreview/index.scss +26 -2
  124. package/dist/packages/input/index.scss +13 -0
  125. package/dist/packages/inputnumber/index.scss +21 -0
  126. package/dist/packages/locale/lang/baseLang.js +3 -3
  127. package/dist/packages/locale/lang/en-US.js +105 -5
  128. package/dist/packages/locale/lang/id-ID.js +105 -5
  129. package/dist/packages/locale/lang/index.js +38 -16
  130. package/dist/packages/locale/lang/zh-CN.js +105 -5
  131. package/dist/packages/locale/lang/zh-TW.js +105 -5
  132. package/dist/packages/menu/index.scss +45 -36
  133. package/dist/packages/menuitem/index.scss +4 -0
  134. package/dist/packages/navbar/index.scss +9 -0
  135. package/dist/packages/pagination/index.scss +19 -0
  136. package/dist/packages/radio/index.scss +18 -0
  137. package/dist/packages/range/index.scss +19 -0
  138. package/dist/packages/rate/index.scss +1 -1
  139. package/dist/packages/searchbar/index.scss +21 -0
  140. package/dist/packages/switch/index.scss +1 -0
  141. package/dist/packages/tabbar/index.scss +5 -0
  142. package/dist/packages/tabbaritem/index.scss +7 -0
  143. package/dist/packages/tabpane/index.scss +5 -0
  144. package/dist/packages/tabs/index.scss +22 -0
  145. package/dist/packages/textarea/index.scss +8 -0
  146. package/dist/smartips/attributes.json +140 -4
  147. package/dist/smartips/tags.json +55 -6
  148. package/dist/smartips/web-types.json +6963 -0
  149. package/dist/style.css +1 -1
  150. package/dist/style.es.js +1 -1
  151. package/dist/styles/font/config.json +3 -1
  152. package/dist/styles/font/demo_index.html +49 -3
  153. package/dist/styles/font/iconfont.css +11 -3
  154. package/dist/styles/font/iconfont.js +15 -15
  155. package/dist/styles/font/iconfont.json +14 -0
  156. package/dist/styles/font/iconfont.ttf +0 -0
  157. package/dist/styles/font/iconfont.woff +0 -0
  158. package/dist/styles/font/iconfont.woff2 +0 -0
  159. package/dist/styles/themes/default.scss +54 -50
  160. package/dist/styles/themes/jdb.scss +54 -50
  161. package/dist/styles/themes/jdt.scss +54 -50
  162. package/dist/styles/variables-jdb.scss +12 -0
  163. package/dist/styles/variables-jdt.scss +12 -0
  164. package/dist/styles/variables.scss +12 -0
  165. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  166. package/dist/types/__VUE/address/index.vue.d.ts +7 -7
  167. package/dist/types/__VUE/animate/index.vue.d.ts +48 -0
  168. package/dist/types/__VUE/animate/type.d.ts +6 -0
  169. package/dist/types/__VUE/avatar/index.vue.d.ts +3 -3
  170. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  171. package/dist/types/__VUE/calendaritem/index.vue.d.ts +10 -2
  172. package/dist/types/__VUE/cascader/index.vue.d.ts +2 -2
  173. package/dist/types/__VUE/circleprogress/index.vue.d.ts +2 -2
  174. package/dist/types/__VUE/collapse/index.vue.d.ts +3 -1
  175. package/dist/types/__VUE/configprovider/common.d.ts +20 -0
  176. package/dist/types/__VUE/configprovider/index.vue.d.ts +33 -0
  177. package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
  178. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  179. package/dist/types/__VUE/ellipsis/index.vue.d.ts +72 -0
  180. package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
  181. package/dist/types/__VUE/grid/index.vue.d.ts +2 -2
  182. package/dist/types/__VUE/image/index.vue.d.ts +105 -0
  183. package/dist/types/__VUE/image/type.d.ts +6 -0
  184. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  185. package/dist/types/__VUE/imagepreview/index.vue.d.ts +56 -24
  186. package/dist/types/__VUE/menu/index.vue.d.ts +31 -4
  187. package/dist/types/__VUE/menuitem/index.vue.d.ts +12 -3
  188. package/dist/types/__VUE/noticebar/index.vue.d.ts +1 -1
  189. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  190. package/dist/types/__VUE/oldpicker/index.vue.d.ts +4 -4
  191. package/dist/types/__VUE/picker/index.vue.d.ts +4 -4
  192. package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
  193. package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
  194. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  195. package/dist/types/__VUE/rate/common.d.ts +149 -0
  196. package/dist/types/__VUE/rate/index.vue.d.ts +17 -7
  197. package/dist/types/__VUE/row/index.vue.d.ts +2 -2
  198. package/dist/types/__VUE/shortpassword/index.vue.d.ts +2 -2
  199. package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
  200. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  201. package/dist/types/__VUE/swiper/index.vue.d.ts +2 -2
  202. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  203. package/dist/types/__VUE/timeselect/index.vue.d.ts +3 -2
  204. package/dist/types/__VUE/uploader/uploader.d.ts +1 -0
  205. package/dist/types/index.d.ts +1 -1
  206. package/dist/types/nutui.d.ts +5 -1
  207. package/package.json +5 -4
@@ -1,137 +1,790 @@
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 = (a2, b2) => {
9
- for (var prop in b2 || (b2 = {}))
10
- if (__hasOwnProp.call(b2, prop))
11
- __defNormalProp(a2, prop, b2[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b2)) {
14
- if (__propIsEnum.call(b2, prop))
15
- __defNormalProp(a2, prop, b2[prop]);
16
- }
17
- return a2;
18
- };
19
- var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
20
1
  /*!
21
- * @nutui/nutui v3.1.22-beta.3 Wed Jun 15 2022 20:12:30 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
22
3
  * (c) 2022 @jdf2e.
23
4
  * Released under the MIT License.
24
5
  */
25
- import { ref as t, computed as e, reactive as a, watch as r, toRefs as n, openBlock as s, createElementBlock as o, normalizeClass as l, createElementVNode as c, toDisplayString as i, createCommentVNode as u, renderSlot as D, Fragment as h, renderList as d, normalizeStyle as m, createTextVNode as p } from "vue";
26
- import { c as y } from "./component.js";
27
- import { r as g } from "./raf.js";
28
- import { _ as f } from "./plugin-vue_export-helper.js";
29
- const w = { isLeapYear: function(t2) {
30
- return t2 % 4 == 0 && t2 % 100 != 0 || t2 % 400 == 0;
31
- }, getWhatDay: function(t2, e2, a2) {
32
- 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()];
33
- }, getMonthPreDay: function(t2, e2) {
34
- let a2 = new Date(t2 + "/" + e2 + "/01").getDay();
35
- return a2 == 0 && (a2 = 7), a2;
36
- }, getMonthDays: function(t2, e2) {
37
- 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];
38
- }, getNumTwoBit: function(t2) {
39
- return ((t2 = Number(t2)) > 9 ? "" : "0") + t2;
40
- }, date2Str: function(t2, e2) {
41
- e2 = e2 || "-";
42
- return [t2.getFullYear(), this.getNumTwoBit(t2.getMonth() + 1), this.getNumTwoBit(t2.getDate())].join(e2);
43
- }, getDay: function(t2) {
44
- t2 = t2 || 0;
45
- let e2 = new Date();
46
- const a2 = 864e5 * t2;
47
- return e2 = new Date(e2.getTime() + a2), this.date2Str(e2);
48
- }, compareDate: function(t2, e2) {
49
- return !(new Date(t2.replace("-", "/").replace("-", "/")) >= new Date(e2.replace("-", "/").replace("-", "/")));
50
- }, isEqual: function(t2, e2) {
51
- return new Date(t2).getTime() == new Date(e2).getTime();
52
- } }, { create: v, translate: T } = y("calendar-item"), S = v({ props: { type: { type: String, default: "one" }, isAutoBackFill: { type: Boolean, default: false }, 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: w.getDay(0) }, endDate: { type: String, default: w.getDay(365) } }, emits: ["choose", "update", "close", "select"], setup(s2, { emit: o2, slots: l2 }) {
53
- const c2 = t(T("weekdays")), i2 = t(null), u2 = t(null), D2 = t(null), h2 = t(null), d2 = t(0), m2 = e(() => v2.monthsData.slice(v2.defaultRange[0], v2.defaultRange[1])), p2 = e(() => l2.btn), y2 = e(() => l2.topInfo), f2 = e(() => l2.bottomInfo), v2 = 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: s2.type === "range", timer: 0, currentIndex: 0, avgHeight: 0, monthsNum: 0 }), S2 = (t2) => t2.split("-"), b2 = (t2) => w.isEqual(v2.currDate[0], t2), x2 = (t2) => w.isEqual(v2.currDate[1], t2), $2 = (t2, e2, a2) => e2.curData[0] + "-" + e2.curData[1] + "-" + w.getNumTwoBit(+t2.day), k2 = (t2, e2, a2) => {
54
- const r2 = $2(t2, e2);
55
- return t2.type == "curr" ? !v2.isRange && w.isEqual(v2.currDate, r2) || v2.isRange && (b2(r2) || x2(r2)) ? `${v2.dayPrefix}-active` : v2.propStartDate && w.compareDate(r2, v2.propStartDate) || v2.propEndDate && w.compareDate(v2.propEndDate, r2) ? `${v2.dayPrefix}-disabled` : v2.isRange && Array.isArray(v2.currDate) && Object.values(v2.currDate).length == 2 && w.compareDate(v2.currDate[0], r2) && w.compareDate(r2, v2.currDate[1]) ? `${v2.dayPrefix}-choose` : null : `${v2.dayPrefix}-disabled`;
56
- }, A2 = () => {
57
- (v2.isRange && v2.chooseData.length == 2 || !v2.isRange) && (o2("choose", v2.chooseData), s2.poppable && o2("update"));
58
- }, H2 = (t2, e2, a2, r2) => {
59
- if (k2(t2, e2) != `${v2.dayPrefix}-disabled`) {
60
- let r3 = [...e2.curData];
61
- r3[2] = typeof t2.day == "number" ? w.getNumTwoBit(t2.day) : t2.day, r3[3] = `${r3[0]}-${r3[1]}-${r3[2]}`, r3[4] = w.getWhatDay(+r3[0], +r3[1], +r3[2]), v2.isRange ? (Object.values(v2.currDate).length == 2 ? v2.currDate = [r3[3]] : w.compareDate(v2.currDate[0], r3[3]) ? Array.isArray(v2.currDate) && v2.currDate.push(r3[3]) : Array.isArray(v2.currDate) && v2.currDate.unshift(r3[3]), v2.chooseData.length != 2 && v2.chooseData.length ? w.compareDate(v2.chooseData[3], r3[3]) ? v2.chooseData = [[...v2.chooseData], [...r3]] : v2.chooseData = [[...r3], [...v2.chooseData]] : v2.chooseData = [...r3]) : (v2.currDate = r3[3], v2.chooseData = [...r3]), a2 || (o2("select", v2.chooseData), s2.isAutoBackFill && A2());
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;
34
+ }
35
+ return day;
36
+ },
37
+ getMonthDays: function(year, month) {
38
+ if (/^0/.test(month)) {
39
+ month = month.split("")[1];
40
+ }
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;
62
80
  }
63
- }, R2 = (t2) => {
64
- const e2 = t2 == "prev" ? v2.monthsData[0] : v2.monthsData[v2.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;
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;
72
88
  }
73
- return [a2, w.getNumTwoBit(r2), w.getMonthDays(String(a2), String(r2))];
74
- }, I2 = (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
- }, B2 = (t2, e2, a2, r2) => {
78
- let { year: n2, month: s3 } = a2;
79
- return e2 == "prev" && t2 >= 7 && (t2 -= 7), Array.from(Array(r2), (t3, a3) => ({ day: a3 + 1, type: e2, year: n2, month: s3 })).slice(r2 - t2);
80
- }, N2 = (t2, e2) => {
81
- const a2 = w.getMonthPreDay(+t2[0], +t2[1]);
82
- let r2 = t2[1] - 1, n2 = t2[0];
83
- r2 <= 0 && (r2 = 12, n2 += 1);
84
- const s3 = w.getMonthDays(t2[0], t2[1]), o3 = w.getMonthDays(n2 + "", r2 + ""), l3 = { year: t2[0], month: t2[1] }, c3 = { curData: t2, title: T("monthTitle", l3.year, l3.month), monthData: [...B2(a2, "prev", { month: r2, year: n2 }, o3), ...I2(s3, "curr", l3)] };
85
- c3.cssHeight = 39 + (c3.monthData.length > 35 ? 384 : 320);
86
- let i3 = 0;
87
- v2.monthsData.length > 0 && (i3 = v2.monthsData[v2.monthsData.length - 1].cssScrollHeight + v2.monthsData[v2.monthsData.length - 1].cssHeight), c3.cssScrollHeight = i3, e2 == "next" ? v2.endData && w.compareDate(`${v2.endData[0]}-${v2.endData[1]}-${w.getMonthDays(v2.endData[0], v2.endData[1])}`, `${t2[0]}-${t2[1]}-${t2[2]}`) || v2.monthsData.push(c3) : v2.startData && w.compareDate(`${t2[0]}-${t2[1]}-${t2[2]}`, `${v2.startData[0]}-${v2.startData[1]}-01`) ? v2.unLoadPrev = true : v2.monthsData.unshift(c3);
88
- }, M2 = () => {
89
- let t2 = s2.startDate ? s2.startDate : w.getDay(0), e2 = s2.endDate ? s2.endDate : w.getDay(365);
90
- v2.propStartDate = t2, v2.propEndDate = e2, v2.startData = S2(t2), v2.endData = S2(e2), !s2.defaultValue || Array.isArray(s2.defaultValue) && s2.defaultValue.length <= 0 ? v2.currDate = v2.isRange ? [w.date2Str(new Date()), w.getDay(1)] : w.date2Str(new Date()) : v2.currDate = v2.isRange ? [...s2.defaultValue] : s2.defaultValue;
91
- const a2 = Number(v2.startData[0]), r2 = Number(v2.startData[1]), n2 = Number(v2.endData[0]);
92
- let o3 = Number(v2.endData[1]) - r2;
93
- n2 - a2 > 0 && (o3 += 12 * (n2 - a2)), N2(v2.startData, "next");
94
- let l3 = 1;
95
- do {
96
- N2(R2("next"), "next");
97
- } while (l3++ < o3);
98
- v2.monthsNum = o3, v2.isRange && Array.isArray(v2.currDate) ? (t2 && w.compareDate(v2.currDate[0], t2) && v2.currDate.splice(0, 1, t2), e2 && w.compareDate(e2, v2.currDate[1]) && v2.currDate.splice(1, 1, e2), v2.defaultData = [...S2(v2.currDate[0]), ...S2(v2.currDate[1])]) : (t2 && w.compareDate(v2.currDate, t2) ? v2.currDate = t2 : e2 && !w.compareDate(v2.currDate, e2) && (v2.currDate = e2), v2.defaultData = [...S2(v2.currDate)]);
99
- let c3 = 0, D3 = 0;
100
- v2.monthsData.forEach((t3, e3) => {
101
- t3.title == T("monthTitle", v2.defaultData[0], v2.defaultData[1]) && (c3 = e3), v2.isRange && t3.title == T("monthTitle", v2.defaultData[3], v2.defaultData[4]) && (D3 = e3);
102
- }), P2(o3, c3), v2.currentIndex = c3, v2.yearMonthTitle = v2.monthsData[v2.currentIndex].title, v2.isRange ? (H2({ day: v2.defaultData[2], type: "curr" }, v2.monthsData[v2.currentIndex], true), H2({ day: v2.defaultData[5], type: "curr" }, v2.monthsData[D3], true)) : H2({ day: v2.defaultData[2], type: "curr" }, v2.monthsData[v2.currentIndex], true);
103
- let m3 = v2.monthsData[v2.monthsData.length - 1], p3 = m3.cssHeight + m3.cssScrollHeight;
104
- g(() => {
105
- (i2 == null ? void 0 : i2.value) && (u2 == null ? void 0 : u2.value) && (h2 == null ? void 0 : h2.value) && (d2.value = i2.value.clientHeight, u2.value.style.height = `${p3}px`, i2.value.scrollTop = v2.monthsData[v2.currentIndex].cssScrollHeight);
106
- }), v2.avgHeight = Math.floor(p3 / (o3 + 1));
107
- }, P2 = (t2, e2) => {
108
- t2 >= 3 ? e2 > 0 && e2 < t2 ? v2.defaultRange = [e2 - 1, e2 + 3] : e2 == 0 ? v2.defaultRange = [e2, e2 + 4] : e2 == t2 && (v2.defaultRange = [e2 - 2, e2 + 2]) : v2.defaultRange = [0, t2 + 2];
109
- let a2 = v2.monthsData[v2.defaultRange[0]].cssScrollHeight;
110
- v2.translateY = a2;
111
- }, E2 = (t2, e2) => v2.isRange && t2.type == "curr" && k2(t2, e2) == "calendar-month-day-active";
112
- return M2(), r(() => s2.defaultValue, (t2) => {
113
- t2 && s2.poppable && (v2.chooseData.splice(0), v2.monthsData.splice(0), M2());
114
- }), __spreadProps(__spreadValues(__spreadValues({ weeks: c2, compConthsData: m2, showTopBtn: p2, topInfo: y2, bottomInfo: f2, rangeTip: (t2, e2) => {
115
- if (v2.currDate.length >= 2)
116
- return w.isEqual(v2.currDate[0], v2.currDate[1]);
117
- }, mothsViewScroll: (t2) => {
118
- const e2 = t2.target.scrollTop;
119
- let a2 = Math.floor(e2 / v2.avgHeight);
120
- if (a2 == 0)
121
- e2 >= v2.monthsData[a2 + 1].cssScrollHeight && (a2 += 1);
122
- else if (a2 > 0 && a2 < v2.monthsNum - 1)
123
- e2 >= v2.monthsData[a2 + 1].cssScrollHeight && (a2 += 1), e2 < v2.monthsData[a2].cssScrollHeight && (a2 -= 1);
124
- else {
125
- const t3 = Math.round(e2 + d2.value);
126
- t3 < v2.monthsData[a2].cssScrollHeight + v2.monthsData[a2].cssHeight && e2 > v2.monthsData[a2 - 1].cssScrollHeight && (a2 -= 1), a2 + 1 <= v2.monthsNum && t3 >= v2.monthsData[a2 + 1].cssScrollHeight + v2.monthsData[a2 + 1].cssHeight && (a2 += 1), e2 < v2.monthsData[a2 - 1].cssScrollHeight && (a2 -= 1);
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)
127
150
  }
128
- v2.currentIndex !== a2 && (v2.currentIndex = a2, P2(v2.monthsNum, a2)), v2.yearMonthTitle = v2.monthsData[a2].title;
129
- }, getClass: k2, isStartTip: (t2, e2) => E2(t2, e2) && b2($2(t2, e2)), isEndTip: (t2, e2) => !!(v2.currDate.length >= 2 && x2($2(t2, e2))) && E2(t2, e2), chooseDay: H2, isCurrDay: (t2) => {
130
- const e2 = `${t2.year}-${t2.month}-${t2.day < 10 ? "0" + t2.day : t2.day}`;
131
- return w.isEqual(e2, w.date2Str(new Date()));
132
- }, confirm: A2, monthsPanel: u2, months: i2, weeksPanel: D2, viewArea: h2 }, n(v2)), n(s2)), { translate: T });
133
- } }), b = { key: 0, class: "calendar-title" }, x = { key: 1, class: "calendar-top-slot" }, $ = { key: 2, class: "calendar-curr-month" }, k = { class: "calendar-weeks", ref: "weeksPanel" }, A = { class: "calendar-months-panel", ref: "monthsPanel" }, H = { class: "calendar-month-title" }, R = { class: "calendar-month-con" }, I = ["onClick"], B = { class: "calendar-day" }, N = { key: 0, class: "calendar-curr-tips calendar-curr-tips-top" }, M = { key: 1, class: "calendar-curr-tips calendar-curr-tips-bottom" }, P = { key: 2, class: "calendar-curr-tip-curr" }, E = { key: 4, class: "calendar-day-tip" }, Y = { key: 0, class: "nut-calendar-footer" };
134
- var C = f(S, [["render", function(t2, e2, a2, r2, n2, y2) {
135
- return s(), o("view", { class: l(["nut-calendar nut-calendar-taro", { "nut-calendar-tile": !t2.poppable, "nut-calendar-nofooter": t2.isAutoBackFill }]) }, [c("view", { class: l(["nut-calendar-header", { "nut-calendar-header-tile": !t2.poppable }]) }, [t2.showTitle ? (s(), o("view", b, i(t2.title || t2.translate("title")), 1)) : u("", true), t2.showTopBtn ? (s(), o("view", x, [D(t2.$slots, "btn")])) : u("", true), t2.showSubTitle ? (s(), o("view", $, i(t2.yearMonthTitle), 1)) : u("", true), c("view", k, [(s(true), o(h, null, d(t2.weeks, (t3, e3) => (s(), o("view", { class: "calendar-week-item", key: e3 }, i(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", A, [c("view", { class: "viewArea", ref: "viewArea", style: m({ transform: `translateY(${t2.translateY}px)` }) }, [(s(true), o(h, null, d(t2.compConthsData, (e3, a3) => (s(), o("view", { class: "calendar-month", key: a3 }, [c("view", H, i(e3.title), 1), c("view", R, [c("view", { class: l(["calendar-month-item", t2.type === "range" ? "month-item-range" : ""]) }, [(s(true), o(h, null, d(e3.monthData, (a4, r3) => (s(), o("view", { key: r3, class: l(["calendar-month-day", t2.getClass(a4, e3)]), onClick: (r4) => t2.chooseDay(a4, e3) }, [c("view", B, [D(t2.$slots, "day", { date: a4.type == "curr" ? a4 : "" }, () => [p(i(a4.type == "curr" ? a4.day : ""), 1)])]), t2.topInfo ? (s(), o("view", N, [D(t2.$slots, "topInfo", { date: a4.type == "curr" ? a4 : "" })])) : u("", true), t2.bottomInfo ? (s(), o("view", M, [D(t2.$slots, "bottomInfo", { date: a4.type == "curr" ? a4 : "" })])) : u("", true), !t2.bottomInfo && t2.showToday && t2.isCurrDay(a4) ? (s(), o("view", P, i(t2.translate("today")), 1)) : u("", true), t2.isStartTip(a4, e3) ? (s(), o("view", { key: 3, class: l(["calendar-day-tip", { "calendar-curr-tips-top": t2.rangeTip(a4, e3) }]) }, i(t2.startText || t2.translate("start")), 3)) : u("", true), t2.isEndTip(a4, e3) ? (s(), o("view", E, i(t2.endText || t2.translate("end")), 1)) : u("", true)], 10, I))), 128))], 2)])]))), 128))], 4)], 512)], 544), t2.poppable && !t2.isAutoBackFill ? (s(), o("view", Y, [c("view", { class: "calendar-confirm-btn", onClick: e2[1] || (e2[1] = (...e3) => t2.confirm && t2.confirm(...e3)) }, i(t2.confirmText || t2.translate("confirm")), 1)])) : u("", true)], 2);
136
- }]]);
137
- export { C, w as U };
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
+ }
275
+ }
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;
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
545
+ });
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 };