@nutui/nutui 3.1.18-beta.0 → 3.1.19-beta.1

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