@nutui/nutui 3.1.22-beta.0 → 3.1.22

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