@nutui/nutui 3.1.18 → 3.1.19-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +9 -8
  2. package/dist/nutui.es.js +12360 -12238
  3. package/dist/nutui.umd.js +12367 -12245
  4. package/dist/packages/_es/ActionSheet.js +1 -1
  5. package/dist/packages/_es/Address.js +1 -1
  6. package/dist/packages/_es/Audio.js +1 -1
  7. package/dist/packages/_es/AudioOperate.js +125 -0
  8. package/dist/packages/_es/Avatar.js +1 -1
  9. package/dist/packages/_es/BackTop.js +1 -1
  10. package/dist/packages/_es/Badge.js +1 -1
  11. package/dist/packages/_es/Barrage.js +1 -1
  12. package/dist/packages/_es/Button.js +1 -1
  13. package/dist/packages/_es/Calendar.js +8 -684
  14. package/dist/packages/_es/CalendarItem.js +10 -0
  15. package/dist/packages/_es/Card.js +1 -1
  16. package/dist/packages/_es/Cascader.js +1 -1
  17. package/dist/packages/_es/Cell.js +1 -1
  18. package/dist/packages/_es/CellGroup.js +1 -1
  19. package/dist/packages/_es/Checkbox.js +13 -3
  20. package/dist/packages/_es/CheckboxGroup.js +2 -2
  21. package/dist/packages/_es/CircleProgress.js +1 -1
  22. package/dist/packages/_es/Col.js +1 -1
  23. package/dist/packages/_es/Collapse.js +1 -1
  24. package/dist/packages/_es/CollapseItem.js +1 -1
  25. package/dist/packages/_es/CountDown.js +1 -1
  26. package/dist/packages/_es/CountUp.js +1 -1
  27. package/dist/packages/_es/DatePicker.js +1 -1
  28. package/dist/packages/_es/Dialog.js +10 -9
  29. package/dist/packages/_es/Divider.js +1 -1
  30. package/dist/packages/_es/Drag.js +1 -1
  31. package/dist/packages/_es/Elevator.js +2 -2
  32. package/dist/packages/_es/Empty.js +1 -1
  33. package/dist/packages/_es/FixedNav.js +6 -7
  34. package/dist/packages/_es/Form.js +2 -6
  35. package/dist/packages/_es/FormItem.js +1 -1
  36. package/dist/packages/_es/Grid.js +1 -1
  37. package/dist/packages/_es/GridItem.js +1 -1
  38. package/dist/packages/_es/Icon.js +1 -1
  39. package/dist/packages/_es/ImagePreview.js +2 -2
  40. package/dist/packages/_es/Indicator.js +1 -1
  41. package/dist/packages/_es/InfiniteLoading.js +1 -1
  42. package/dist/packages/_es/Input.js +1 -1
  43. package/dist/packages/_es/InputNumber.js +1 -1
  44. package/dist/packages/_es/Layout.js +1 -1
  45. package/dist/packages/_es/List.js +1 -1
  46. package/dist/packages/_es/Menu.js +2 -2
  47. package/dist/packages/_es/MenuItem.js +1 -1
  48. package/dist/packages/_es/Navbar.js +1 -1
  49. package/dist/packages/_es/NoticeBar.js +1 -1
  50. package/dist/packages/_es/Notify.js +1 -1
  51. package/dist/packages/_es/NumberKeyboard.js +9 -4
  52. package/dist/packages/_es/OldPicker.js +484 -0
  53. package/dist/packages/_es/OverLay.js +1 -1
  54. package/dist/packages/_es/Pagination.js +8 -7
  55. package/dist/packages/_es/Picker.js +1 -1
  56. package/dist/packages/_es/Popover.js +1 -1
  57. package/dist/packages/_es/Popup.js +1 -1
  58. package/dist/packages/_es/Price.js +1 -1
  59. package/dist/packages/_es/Progress.js +1 -1
  60. package/dist/packages/_es/PullRefresh.js +363 -0
  61. package/dist/packages/_es/Radio.js +13 -3
  62. package/dist/packages/_es/RadioGroup.js +1 -1
  63. package/dist/packages/_es/Range.js +2 -2
  64. package/dist/packages/_es/Rate.js +1 -1
  65. package/dist/packages/_es/Row.js +1 -1
  66. package/dist/packages/_es/SearchBar.js +6 -5
  67. package/dist/packages/_es/ShortPassword.js +1 -1
  68. package/dist/packages/_es/SideNavBar.js +1 -1
  69. package/dist/packages/_es/SideNavBarItem.js +1 -1
  70. package/dist/packages/_es/Signature.js +1 -1
  71. package/dist/packages/_es/Skeleton.js +1 -1
  72. package/dist/packages/_es/Sku.js +2 -3
  73. package/dist/packages/_es/Step.js +1 -1
  74. package/dist/packages/_es/Steps.js +1 -1
  75. package/dist/packages/_es/Sticky.js +2 -2
  76. package/dist/packages/_es/SubSideNavBar.js +1 -1
  77. package/dist/packages/_es/Swipe.js +1 -1
  78. package/dist/packages/_es/Swiper.js +2 -2
  79. package/dist/packages/_es/SwiperItem.js +2 -2
  80. package/dist/packages/_es/Switch.js +1 -1
  81. package/dist/packages/_es/TabPane.js +1 -1
  82. package/dist/packages/_es/Tabbar.js +1 -1
  83. package/dist/packages/_es/TabbarItem.js +7 -3
  84. package/dist/packages/_es/Table.js +1 -1
  85. package/dist/packages/_es/Tabs.js +1 -1
  86. package/dist/packages/_es/Tag.js +1 -1
  87. package/dist/packages/_es/TextArea.js +1 -1
  88. package/dist/packages/_es/TimeDetail.js +1 -1
  89. package/dist/packages/_es/TimePannel.js +1 -1
  90. package/dist/packages/_es/TimeSelect.js +1 -1
  91. package/dist/packages/_es/Toast.js +1 -1
  92. package/dist/packages/_es/Uploader.js +1 -1
  93. package/dist/packages/_es/Video.js +7 -6
  94. package/dist/packages/_es/common.js +1 -1
  95. package/dist/packages/_es/component.js +135 -3
  96. package/dist/packages/_es/index.js +1 -1
  97. package/dist/packages/_es/index2.js +31 -8
  98. package/dist/packages/_es/index3.js +8 -31
  99. package/dist/packages/_es/index4.js +1 -1
  100. package/dist/packages/_es/index5.js +692 -0
  101. package/dist/packages/_es/plugin-vue_export-helper.js +1 -1
  102. package/dist/packages/_es/pxCheck.js +1 -1
  103. package/dist/packages/_es/raf.js +1 -1
  104. package/dist/packages/uploader/index.scss +2 -2
  105. package/dist/style.css +1 -1
  106. package/dist/styles/themes/default.scss +65 -65
  107. package/dist/styles/themes/jdt.scss +65 -65
  108. package/dist/styles/variables-jdt.scss +2 -1
  109. package/dist/styles/variables.scss +1 -1
  110. package/dist/types/__VUE/actionsheet/index.d.ts +269 -0
  111. package/dist/types/__VUE/address/index.d.ts +386 -0
  112. package/dist/types/__VUE/audio/index.d.ts +92 -0
  113. package/dist/types/__VUE/audiooperate/index.d.ts +68 -0
  114. package/dist/types/__VUE/avatar/index.d.ts +66 -0
  115. package/dist/types/__VUE/backtop/index.d.ts +105 -0
  116. package/dist/types/__VUE/badge/index.d.ts +94 -0
  117. package/dist/types/__VUE/barrage/index.d.ts +80 -0
  118. package/dist/types/__VUE/button/index.d.ts +116 -0
  119. package/dist/types/__VUE/calendar/index.d.ts +155 -0
  120. package/dist/types/__VUE/calendaritem/index.d.ts +195 -0
  121. package/dist/types/__VUE/card/index.d.ts +81 -0
  122. package/dist/types/__VUE/cascader/cascader-item.d.ts +76 -0
  123. package/dist/types/__VUE/cascader/helper.d.ts +8 -0
  124. package/dist/types/__VUE/cascader/index.d.ts +76 -0
  125. package/dist/types/__VUE/cascader/tree.d.ts +17 -0
  126. package/dist/types/__VUE/cascader/types.d.ts +30 -0
  127. package/dist/types/__VUE/cell/index.d.ts +109 -0
  128. package/dist/types/__VUE/cellgroup/index.d.ts +38 -0
  129. package/dist/types/__VUE/checkbox/index.d.ts +102 -0
  130. package/dist/types/__VUE/checkboxgroup/index.d.ts +39 -0
  131. package/dist/types/__VUE/circleprogress/index.d.ts +66 -0
  132. package/dist/types/__VUE/col/index.d.ts +42 -0
  133. package/dist/types/__VUE/collapse/index.d.ts +104 -0
  134. package/dist/types/__VUE/collapseitem/index.d.ts +83 -0
  135. package/dist/types/__VUE/countdown/index.d.ts +90 -0
  136. package/dist/types/__VUE/countup/index.d.ts +216 -0
  137. package/dist/types/__VUE/datepicker/index.d.ts +347 -0
  138. package/dist/types/__VUE/datepicker/utils.d.ts +5 -0
  139. package/dist/types/__VUE/dialog/index.d.ts +306 -0
  140. package/dist/types/__VUE/divider/index.d.ts +47 -0
  141. package/dist/types/__VUE/drag/index.d.ts +61 -0
  142. package/dist/types/__VUE/elevator/index.d.ts +71 -0
  143. package/dist/types/__VUE/empty/index.d.ts +46 -0
  144. package/dist/types/__VUE/fixednav/index.d.ts +96 -0
  145. package/dist/types/__VUE/form/common.d.ts +20 -0
  146. package/dist/types/__VUE/form/index.d.ts +32 -0
  147. package/dist/types/__VUE/form/types.d.ts +13 -0
  148. package/dist/types/__VUE/formitem/index.d.ts +120 -0
  149. package/dist/types/__VUE/formitem/types.d.ts +10 -0
  150. package/dist/types/__VUE/grid/common.d.ts +91 -0
  151. package/dist/types/__VUE/grid/index.d.ts +100 -0
  152. package/dist/types/__VUE/griditem/index.d.ts +80 -0
  153. package/dist/types/__VUE/icon/index.d.ts +74 -0
  154. package/dist/types/__VUE/imagepreview/index.d.ts +125 -0
  155. package/dist/types/__VUE/indicator/index.d.ts +70 -0
  156. package/dist/types/__VUE/infiniteloading/index.d.ts +140 -0
  157. package/dist/types/__VUE/input/index.d.ts +336 -0
  158. package/dist/types/__VUE/input/util.d.ts +5 -0
  159. package/dist/types/__VUE/inputnumber/index.d.ts +117 -0
  160. package/dist/types/__VUE/layout/index.d.ts +13 -0
  161. package/dist/types/__VUE/list/index.d.ts +48 -0
  162. package/dist/types/__VUE/menu/index.d.ts +51 -0
  163. package/dist/types/__VUE/menuitem/index.d.ts +77 -0
  164. package/dist/types/__VUE/navbar/index.d.ts +84 -0
  165. package/dist/types/__VUE/noticebar/index.d.ts +209 -0
  166. package/dist/types/__VUE/notify/index.d.ts +103 -0
  167. package/dist/types/__VUE/numberkeyboard/index.d.ts +123 -0
  168. package/dist/types/__VUE/oldpicker/Column.d.ts +96 -0
  169. package/dist/types/__VUE/oldpicker/commonProps.d.ts +22 -0
  170. package/dist/types/__VUE/oldpicker/index.d.ts +360 -0
  171. package/dist/types/__VUE/oldpicker/types.d.ts +24 -0
  172. package/dist/types/__VUE/overlay/index.d.ts +1614 -0
  173. package/dist/types/__VUE/pagination/index.d.ts +112 -0
  174. package/dist/types/__VUE/picker/Column.d.ts +90 -0
  175. package/dist/types/__VUE/picker/index.d.ts +342 -0
  176. package/dist/types/__VUE/picker/types.d.ts +26 -0
  177. package/dist/types/__VUE/popover/index.d.ts +233 -0
  178. package/dist/types/__VUE/popup/index.d.ts +1734 -0
  179. package/dist/types/__VUE/popup/use-lock-scroll.d.ts +5 -0
  180. package/dist/types/__VUE/price/index.d.ts +87 -0
  181. package/dist/types/__VUE/progress/index.d.ts +137 -0
  182. package/dist/types/__VUE/pullrefresh/index.d.ts +128 -0
  183. package/dist/types/__VUE/pullrefresh/use-touch.d.ts +20 -0
  184. package/dist/types/__VUE/pullrefresh/util.d.ts +6 -0
  185. package/dist/types/__VUE/radio/index.d.ts +90 -0
  186. package/dist/types/__VUE/radiogroup/index.d.ts +48 -0
  187. package/dist/types/__VUE/range/index.d.ts +156 -0
  188. package/dist/types/__VUE/rate/index.d.ts +142 -0
  189. package/dist/types/__VUE/row/index.d.ts +63 -0
  190. package/dist/types/__VUE/searchbar/index.d.ts +100 -0
  191. package/dist/types/__VUE/shortpassword/index.d.ts +136 -0
  192. package/dist/types/__VUE/sidenavbar/index.d.ts +36 -0
  193. package/dist/types/__VUE/sidenavbaritem/index.d.ts +41 -0
  194. package/dist/types/__VUE/signature/index.d.ts +73 -0
  195. package/dist/types/__VUE/skeleton/common.d.ts +63 -0
  196. package/dist/types/__VUE/skeleton/index.d.ts +117 -0
  197. package/dist/types/__VUE/sku/components/SkuHeader.d.ts +27 -0
  198. package/dist/types/__VUE/sku/components/SkuOperate.d.ts +70 -0
  199. package/dist/types/__VUE/sku/components/SkuSelect.d.ts +30 -0
  200. package/dist/types/__VUE/sku/components/SkuStepper.d.ts +67 -0
  201. package/dist/types/__VUE/sku/index.d.ts +300 -0
  202. package/dist/types/__VUE/step/index.d.ts +70 -0
  203. package/dist/types/__VUE/steps/index.d.ts +47 -0
  204. package/dist/types/__VUE/sticky/index.d.ts +63 -0
  205. package/dist/types/__VUE/subsidenavbar/index.d.ts +54 -0
  206. package/dist/types/__VUE/swipe/index.d.ts +69 -0
  207. package/dist/types/__VUE/swiper/index.d.ts +163 -0
  208. package/dist/types/__VUE/swiper/use-touch.d.ts +20 -0
  209. package/dist/types/__VUE/swiperitem/index.d.ts +24 -0
  210. package/dist/types/__VUE/switch/index.d.ts +136 -0
  211. package/dist/types/__VUE/tabbar/index.d.ts +84 -0
  212. package/dist/types/__VUE/tabbaritem/index.d.ts +108 -0
  213. package/dist/types/__VUE/table/common.d.ts +54 -0
  214. package/dist/types/__VUE/table/index.d.ts +75 -0
  215. package/dist/types/__VUE/table/renderColumn.d.ts +20 -0
  216. package/dist/types/__VUE/table/types.d.ts +19 -0
  217. package/dist/types/__VUE/tabpane/index.d.ts +47 -0
  218. package/dist/types/__VUE/tabs/index.d.ts +128 -0
  219. package/dist/types/__VUE/tag/index.d.ts +89 -0
  220. package/dist/types/__VUE/textarea/index.d.ts +120 -0
  221. package/dist/types/__VUE/timedetail/index.d.ts +48 -0
  222. package/dist/types/__VUE/timepannel/index.d.ts +43 -0
  223. package/dist/types/__VUE/timeselect/index.d.ts +82 -0
  224. package/dist/types/__VUE/toast/index.d.ts +149 -0
  225. package/dist/types/__VUE/uploader/index.d.ts +258 -0
  226. package/dist/types/__VUE/uploader/uploader.d.ts +25 -0
  227. package/dist/types/__VUE/video/index.d.ts +123 -0
  228. package/dist/{index.d.ts → types/index.d.ts} +0 -0
  229. package/dist/types/nutui.d.ts +92 -0
  230. package/package.json +14 -5
  231. package/dist/nutui.d.ts +0 -103
  232. package/dist/packages/_es/util.js +0 -47
@@ -0,0 +1,692 @@
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
+ /*!
21
+ * @nutui/nutui v3.1.19-beta.2 Thu Apr 07 2022 17:52:31 GMT+0800 (中国标准时间)
22
+ * (c) 2022 @jdf2e.
23
+ * Released under the MIT License.
24
+ */
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];
58
+ }
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;
98
+ }
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;
106
+ }
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]);
269
+ }
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;
341
+ }
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
+ });
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 };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.18 Fri Mar 25 2022 15:02:08 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.19-beta.2 Thu Apr 07 2022 17:52:31 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.18 Fri Mar 25 2022 15:02:08 GMT+0800 (中国标准时间)
2
+ * @nutui/nutui v3.1.19-beta.2 Thu Apr 07 2022 17:52:31 GMT+0800 (中国标准时间)
3
3
  * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */