@nutui/nutui 3.1.6 → 3.1.7

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 (92) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/nutui.d.ts +7 -1
  3. package/dist/nutui.es.js +1097 -517
  4. package/dist/nutui.umd.js +1158 -571
  5. package/dist/packages/_es/ActionSheet.js +158 -0
  6. package/dist/packages/_es/Address.js +525 -0
  7. package/dist/packages/_es/Avatar.js +87 -0
  8. package/dist/packages/_es/BackTop.js +159 -0
  9. package/dist/packages/_es/Badge.js +90 -0
  10. package/dist/packages/_es/Barrage.js +118 -0
  11. package/dist/packages/_es/Button.js +124 -0
  12. package/dist/packages/_es/Calendar.js +700 -0
  13. package/dist/packages/_es/Cell.js +95 -0
  14. package/dist/packages/_es/CellGroup.js +42 -0
  15. package/dist/packages/_es/Checkbox.js +109 -0
  16. package/dist/packages/_es/CheckboxGroup.js +62 -0
  17. package/dist/packages/_es/CircleProgress.js +109 -0
  18. package/dist/packages/_es/Col.js +53 -0
  19. package/dist/packages/_es/Collapse.js +89 -0
  20. package/dist/packages/_es/CollapseItem.js +257 -0
  21. package/dist/packages/_es/CountDown.js +224 -0
  22. package/dist/packages/_es/CountUp.js +547 -0
  23. package/dist/packages/_es/DatePicker.js +282 -0
  24. package/dist/packages/_es/Dialog.js +313 -0
  25. package/dist/packages/_es/Divider.js +49 -0
  26. package/dist/packages/_es/Drag.js +198 -0
  27. package/dist/packages/_es/Elevator.js +207 -0
  28. package/dist/packages/_es/FixedNav.js +127 -0
  29. package/dist/packages/_es/Icon.js +44 -0
  30. package/dist/packages/_es/ImagePreview.js +109 -0
  31. package/dist/packages/_es/InfiniteLoading.js +265 -0
  32. package/dist/packages/_es/Input.js +183 -0
  33. package/dist/packages/_es/InputNumber.js +172 -0
  34. package/dist/packages/_es/Layout.js +10 -0
  35. package/dist/packages/_es/MenuItem.js +180 -0
  36. package/dist/packages/_es/Navbar.js +160 -0
  37. package/dist/packages/_es/NoticeBar.js +389 -0
  38. package/dist/packages/_es/Notify.js +233 -0
  39. package/dist/packages/_es/NumberKeyboard.js +248 -0
  40. package/dist/packages/_es/OverLay.js +118 -0
  41. package/dist/packages/_es/Pagination.js +163 -0
  42. package/dist/packages/_es/Picker.js +485 -0
  43. package/dist/packages/_es/Popover.js +157 -0
  44. package/dist/packages/_es/Popup.js +268 -0
  45. package/dist/packages/_es/Price.js +104 -0
  46. package/dist/packages/_es/Progress.js +131 -0
  47. package/dist/packages/_es/Radio.js +72 -0
  48. package/dist/packages/_es/RadioGroup.js +37 -0
  49. package/dist/packages/_es/Range.js +350 -0
  50. package/dist/packages/_es/Rate.js +129 -0
  51. package/dist/packages/_es/Row.js +61 -0
  52. package/dist/packages/_es/ShortPassword.js +221 -0
  53. package/dist/packages/_es/Signature.js +167 -0
  54. package/dist/packages/_es/Step.js +116 -0
  55. package/dist/packages/_es/Steps.js +52 -0
  56. package/dist/packages/_es/Swipe.js +193 -0
  57. package/dist/packages/_es/Swiper.js +429 -0
  58. package/dist/packages/_es/SwiperItem.js +60 -0
  59. package/dist/packages/_es/Switch.js +90 -0
  60. package/dist/packages/_es/Tab.js +179 -0
  61. package/dist/packages/_es/TabPane.js +42 -0
  62. package/dist/packages/_es/TabPanel.js +30 -0
  63. package/dist/packages/_es/Tabbar.js +73 -0
  64. package/dist/packages/_es/TabbarItem.js +142 -0
  65. package/dist/packages/_es/Tag.js +98 -0
  66. package/dist/packages/_es/TextArea.js +127 -0
  67. package/dist/packages/_es/Toast.js +317 -0
  68. package/dist/packages/_es/Uploader.js +400 -0
  69. package/dist/packages/_es/Video.js +405 -0
  70. package/dist/packages/_es/component.js +26 -0
  71. package/dist/packages/_es/index.js +64 -0
  72. package/dist/packages/_es/index2.js +13 -0
  73. package/dist/packages/_es/plugin-vue_export-helper.js +12 -0
  74. package/dist/packages/_es/pxCheck.js +9 -0
  75. package/dist/packages/_es/raf.js +19 -0
  76. package/dist/packages/avatar/index.scss +0 -1
  77. package/dist/packages/badge/index.scss +35 -0
  78. package/dist/packages/calendar/index.scss +13 -0
  79. package/dist/packages/imagepreview/index.scss +48 -0
  80. package/dist/packages/input/index.scss +14 -7
  81. package/dist/packages/pagination/index.scss +51 -0
  82. package/dist/packages/popover/index.scss +159 -0
  83. package/dist/packages/shortpassword/index.scss +19 -7
  84. package/dist/packages/tabpane/index.scss +1 -0
  85. package/dist/packages/tabs/index.scss +1 -0
  86. package/dist/packages/tag/index.scss +47 -0
  87. package/dist/packages/uploader/index.scss +0 -1
  88. package/dist/style.css +1 -1
  89. package/dist/style.es.js +2 -1
  90. package/dist/styles/themes/default.scss +35 -28
  91. package/dist/styles/variables.scss +55 -32
  92. package/package.json +7 -7
@@ -0,0 +1,700 @@
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.7 Thu Sep 30 2021 20:17:02 GMT+0800 (中国标准时间)
19
+ * (c) 2021 @jdf2e.
20
+ * Released under the MIT License.
21
+ */
22
+ import { ref, reactive, watch, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, Fragment, toDisplayString, createCommentVNode, renderList, withModifiers, resolveComponent, createBlock, withCtx, createVNode } from "vue";
23
+ import { c as createComponent } from "./component.js";
24
+ import { r as requestAniFrame } from "./raf.js";
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 index2 = 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[index2];
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: create$1 } = createComponent("calendar-item");
108
+ const _sfc_main$1 = create$1({
109
+ props: {
110
+ type: {
111
+ type: String,
112
+ default: "one"
113
+ },
114
+ isAutoBackFill: {
115
+ type: Boolean,
116
+ default: false
117
+ },
118
+ poppable: {
119
+ type: Boolean,
120
+ default: true
121
+ },
122
+ title: {
123
+ type: String,
124
+ default: "\u65E5\u5386\u9009\u62E9"
125
+ },
126
+ defaultValue: {
127
+ type: String,
128
+ default: null
129
+ },
130
+ startDate: {
131
+ type: String,
132
+ default: Utils.getDay(0)
133
+ },
134
+ endDate: {
135
+ type: String,
136
+ default: Utils.getDay(365)
137
+ }
138
+ },
139
+ emits: ["choose", "update", "close"],
140
+ setup(props, { emit }) {
141
+ const weeks = ref(["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"]);
142
+ const months = ref(null);
143
+ const monthsPanel = ref(null);
144
+ const weeksPanel = ref(null);
145
+ const state = reactive({
146
+ yearMonthTitle: "",
147
+ currDate: "",
148
+ unLoadPrev: false,
149
+ touchParams: {
150
+ startY: 0,
151
+ endY: 0,
152
+ startTime: 0,
153
+ endTime: 0,
154
+ lastY: 0,
155
+ lastTime: 0
156
+ },
157
+ transformY: 0,
158
+ translateY: 0,
159
+ scrollDistance: 0,
160
+ defaultData: [],
161
+ chooseData: [],
162
+ monthsData: [],
163
+ dayPrefix: "calendar-month-day",
164
+ startData: "",
165
+ endData: "",
166
+ isRange: props.type === "range",
167
+ timer: 0
168
+ });
169
+ const splitDate = (date) => {
170
+ return date.split("-");
171
+ };
172
+ const isStart = (currDate) => {
173
+ return Utils.isEqual(state.currDate[0], currDate);
174
+ };
175
+ const isEnd = (currDate) => {
176
+ return Utils.isEqual(state.currDate[1], currDate);
177
+ };
178
+ const getCurrDate = (day, month, isRange) => {
179
+ return isRange ? month.curData[3] + "-" + month.curData[4] + "-" + Utils.getNumTwoBit(+day.day) : month.curData[0] + "-" + month.curData[1] + "-" + Utils.getNumTwoBit(+day.day);
180
+ };
181
+ const getClass = (day, month, isRange) => {
182
+ const currDate = getCurrDate(day, month, isRange);
183
+ if (day.type == "curr") {
184
+ if (!state.isRange && Utils.isEqual(state.currDate, currDate) || state.isRange && (isStart(currDate) || isEnd(currDate))) {
185
+ return `${state.dayPrefix}-active`;
186
+ } else if (props.startDate && Utils.compareDate(currDate, props.startDate) || props.endDate && Utils.compareDate(props.endDate, currDate)) {
187
+ return `${state.dayPrefix}-disabled`;
188
+ } 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])) {
189
+ return `${state.dayPrefix}-choose`;
190
+ } else {
191
+ return null;
192
+ }
193
+ } else {
194
+ return `${state.dayPrefix}-disabled`;
195
+ }
196
+ };
197
+ const confirm = () => {
198
+ if (state.isRange && state.chooseData.length == 2 || !state.isRange) {
199
+ emit("choose", state.chooseData);
200
+ if (props.poppable) {
201
+ emit("update");
202
+ }
203
+ }
204
+ };
205
+ const chooseDay = (day, month, isFirst, isRange) => {
206
+ if (getClass(day, month, isRange) != `${state.dayPrefix}-disabled`) {
207
+ let days = [...month.curData];
208
+ days = isRange ? days.splice(3) : days.splice(0, 3);
209
+ days[2] = typeof day.day == "number" ? Utils.getNumTwoBit(day.day) : day.day;
210
+ days[3] = `${days[0]}-${days[1]}-${days[2]}`;
211
+ days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
212
+ if (!state.isRange) {
213
+ state.currDate = days[3];
214
+ state.chooseData = [...days];
215
+ } else {
216
+ if (Object.values(state.currDate).length == 2) {
217
+ state.currDate = [days[3]];
218
+ } else {
219
+ if (Utils.compareDate(state.currDate[0], days[3])) {
220
+ Array.isArray(state.currDate) && state.currDate.push(days[3]);
221
+ } else {
222
+ Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
223
+ }
224
+ }
225
+ if (state.chooseData.length == 2 || !state.chooseData.length) {
226
+ state.chooseData = [...days];
227
+ } else {
228
+ if (Utils.compareDate(state.chooseData[3], days[3])) {
229
+ state.chooseData = [[...state.chooseData], [...days]];
230
+ } else {
231
+ state.chooseData = [[...days], [...state.chooseData]];
232
+ }
233
+ }
234
+ }
235
+ if (props.isAutoBackFill && !isFirst) {
236
+ confirm();
237
+ }
238
+ }
239
+ };
240
+ const getCurrData = (type) => {
241
+ const monthData = type == "prev" ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
242
+ let year = parseInt(monthData.curData[0]);
243
+ let month = parseInt(monthData.curData[1].toString().replace(/^0/, ""));
244
+ switch (type) {
245
+ case "prev":
246
+ month == 1 && (year -= 1);
247
+ month = month == 1 ? 12 : --month;
248
+ break;
249
+ case "next":
250
+ month == 12 && (year += 1);
251
+ month = month == 12 ? 1 : ++month;
252
+ break;
253
+ }
254
+ return [
255
+ year,
256
+ Utils.getNumTwoBit(month),
257
+ Utils.getMonthDays(String(year), String(month))
258
+ ];
259
+ };
260
+ const getDaysStatus = (days, type) => {
261
+ if (type == "prev" && days >= 7) {
262
+ days -= 7;
263
+ }
264
+ return Array.from(Array(days), (v, k) => {
265
+ return {
266
+ day: k + 1,
267
+ type
268
+ };
269
+ });
270
+ };
271
+ const getMonth = (curData, type) => {
272
+ const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
273
+ const currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
274
+ const title = {
275
+ year: curData[0],
276
+ month: curData[1]
277
+ };
278
+ const monthInfo = {
279
+ curData,
280
+ title: `${title.year}\u5E74${title.month}\u6708`,
281
+ monthData: [
282
+ ...getDaysStatus(preMonthDays, "prev"),
283
+ ...getDaysStatus(currMonthDays, "curr")
284
+ ]
285
+ };
286
+ if (type == "next") {
287
+ 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]}`)) {
288
+ state.monthsData.push(monthInfo);
289
+ }
290
+ } else {
291
+ if (!state.startData || !Utils.compareDate(`${curData[0]}-${curData[1]}-${curData[2]}`, `${state.startData[0]}-${state.startData[1]}-01`)) {
292
+ state.monthsData.unshift(monthInfo);
293
+ } else {
294
+ state.unLoadPrev = true;
295
+ }
296
+ }
297
+ };
298
+ const initData = () => {
299
+ state.startData = props.startDate ? splitDate(props.startDate) : "";
300
+ state.endData = props.endDate ? splitDate(props.endDate) : "";
301
+ if (!props.defaultValue) {
302
+ state.currDate = state.isRange ? [Utils.date2Str(new Date()), Utils.getDay(1)] : Utils.date2Str(new Date());
303
+ } else {
304
+ state.currDate = state.isRange ? [...props.defaultValue] : props.defaultValue;
305
+ }
306
+ if (state.isRange && Array.isArray(state.currDate)) {
307
+ if (props.startDate && Utils.compareDate(state.currDate[0], props.startDate)) {
308
+ state.currDate.splice(0, 1, props.startDate);
309
+ }
310
+ if (props.endDate && Utils.compareDate(props.endDate, state.currDate[1])) {
311
+ state.currDate.splice(1, 1, props.endDate);
312
+ }
313
+ state.defaultData = [
314
+ ...splitDate(state.currDate[0]),
315
+ ...splitDate(state.currDate[1])
316
+ ];
317
+ } else {
318
+ if (props.startDate && Utils.compareDate(state.currDate, props.startDate)) {
319
+ state.currDate = props.startDate;
320
+ } else if (props.endDate && !Utils.compareDate(state.currDate, props.endDate)) {
321
+ state.currDate = props.endDate;
322
+ }
323
+ state.defaultData = [...splitDate(state.currDate)];
324
+ }
325
+ getMonth(state.defaultData, "next");
326
+ state.yearMonthTitle = state.monthsData[0].title;
327
+ let i = 1;
328
+ do {
329
+ getMonth(getCurrData("next"), "next");
330
+ } while (i++ < 4);
331
+ if (state.isRange) {
332
+ chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[0], true);
333
+ chooseDay({ day: state.defaultData[5], type: "curr" }, state.monthsData[0], true, true);
334
+ } else {
335
+ chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[0], true);
336
+ }
337
+ };
338
+ const isActive = (day, month) => {
339
+ return state.isRange && day.type == "curr" && getClass(day, month) == "calendar-month-day-active";
340
+ };
341
+ const isStartTip = (day, month) => {
342
+ if (isActive(day, month)) {
343
+ return isStart(getCurrDate(day, month));
344
+ } else {
345
+ return false;
346
+ }
347
+ };
348
+ const isEndTip = (day, month) => {
349
+ return isActive(day, month);
350
+ };
351
+ const isCurrDay = (month, day) => {
352
+ const date = `${month.curData[0]}-${month.curData[1]}-${day}`;
353
+ return Utils.isEqual(date, Utils.date2Str(new Date()));
354
+ };
355
+ const loadScroll = () => {
356
+ if (!props.poppable) {
357
+ return false;
358
+ }
359
+ requestAniFrame(() => {
360
+ if ((weeksPanel == null ? void 0 : weeksPanel.value) && (monthsPanel == null ? void 0 : monthsPanel.value)) {
361
+ const top = weeksPanel == null ? void 0 : weeksPanel.value.getBoundingClientRect().bottom;
362
+ const monthsDoms = monthsPanel.value.getElementsByClassName("calendar-month");
363
+ for (let i = 0; i < monthsDoms.length; i++) {
364
+ if (monthsDoms[i].getBoundingClientRect().top <= top && monthsDoms[i].getBoundingClientRect().bottom >= top) {
365
+ state.yearMonthTitle = state.monthsData[i].title;
366
+ } else if (state.scrollDistance === 0) {
367
+ state.yearMonthTitle = state.monthsData[0].title;
368
+ }
369
+ }
370
+ }
371
+ });
372
+ };
373
+ const setTransform = (translateY = 0, type, time = 1e3) => {
374
+ if (monthsPanel == null ? void 0 : monthsPanel.value) {
375
+ if (type === "end") {
376
+ monthsPanel.value.style.webkitTransition = `transform ${time}ms cubic-bezier(0.19, 1, 0.22, 1)`;
377
+ clearTimeout(state.timer);
378
+ state.timer = setTimeout(() => {
379
+ loadScroll();
380
+ }, time);
381
+ } else {
382
+ monthsPanel.value.style.webkitTransition = "";
383
+ loadScroll();
384
+ }
385
+ monthsPanel.value.style.webkitTransform = `translateY(${translateY}px)`;
386
+ state.scrollDistance = translateY;
387
+ }
388
+ };
389
+ const setMove = (move, type, time) => {
390
+ var _a, _b;
391
+ let updateMove = move + state.transformY;
392
+ const h = ((_a = months.value) == null ? void 0 : _a.offsetHeight) || 0;
393
+ const offsetHeight = ((_b = monthsPanel.value) == null ? void 0 : _b.offsetHeight) || 0;
394
+ if (type === "end") {
395
+ if (updateMove > 0) {
396
+ updateMove = 0;
397
+ }
398
+ if (updateMove < 0 && updateMove < -offsetHeight + h) {
399
+ updateMove = -offsetHeight + h;
400
+ }
401
+ if (offsetHeight <= h && state.monthsData.length == 1) {
402
+ updateMove = 0;
403
+ }
404
+ setTransform(updateMove, type, time);
405
+ } else {
406
+ if (updateMove > 0 && updateMove > 100) {
407
+ updateMove = 100;
408
+ }
409
+ if (updateMove < -offsetHeight + h - 100 && state.monthsData.length > 1) {
410
+ updateMove = -offsetHeight + h - 100;
411
+ }
412
+ if (updateMove < 0 && updateMove < -100 && state.monthsData.length == 1) {
413
+ updateMove = -100;
414
+ }
415
+ setTransform(updateMove);
416
+ }
417
+ };
418
+ const touchStart = (event) => {
419
+ const changedTouches = event.changedTouches[0];
420
+ state.touchParams.startY = changedTouches.pageY;
421
+ state.touchParams.startTime = event.timeStamp || Date.now();
422
+ state.transformY = state.scrollDistance;
423
+ };
424
+ const touchMove = (event) => {
425
+ const changedTouches = event.changedTouches[0];
426
+ state.touchParams.lastY = changedTouches.pageY;
427
+ state.touchParams.lastTime = event.timeStamp || Date.now();
428
+ const move = state.touchParams.lastY - state.touchParams.startY;
429
+ if (Math.abs(move) < 5) {
430
+ return false;
431
+ }
432
+ setMove(move);
433
+ };
434
+ const touchEnd = (event) => {
435
+ var _a, _b;
436
+ const changedTouches = event.changedTouches[0];
437
+ state.touchParams.lastY = changedTouches.pageY;
438
+ state.touchParams.lastTime = event.timeStamp || Date.now();
439
+ let move = state.touchParams.lastY - state.touchParams.startY;
440
+ if (Math.abs(move) < 5) {
441
+ return false;
442
+ }
443
+ const updateMove = move + state.transformY;
444
+ const h = ((_a = months.value) == null ? void 0 : _a.offsetHeight) || 0;
445
+ const offsetHeight = ((_b = monthsPanel.value) == null ? void 0 : _b.offsetHeight) || 0;
446
+ if (updateMove > 0) {
447
+ getMonth(getCurrData("prev"), "prev");
448
+ } else if (updateMove < 0 && updateMove < -offsetHeight + (Math.abs(move) > h ? Math.abs(move) : h) * 5) {
449
+ getMonth(getCurrData("next"), "next");
450
+ if (Math.abs(move) >= 300) {
451
+ getMonth(getCurrData("next"), "next");
452
+ }
453
+ }
454
+ let moveTime = state.touchParams.lastTime - state.touchParams.startTime;
455
+ if (moveTime <= 300) {
456
+ move = move * 2;
457
+ moveTime = moveTime + 1e3;
458
+ setMove(move, "end", moveTime);
459
+ } else {
460
+ setMove(move, "end");
461
+ }
462
+ };
463
+ const resetRender = () => {
464
+ state.chooseData.splice(0);
465
+ state.monthsData.splice(0);
466
+ state.scrollDistance = 0;
467
+ state.translateY = 0;
468
+ setTransform(state.scrollDistance);
469
+ initData();
470
+ };
471
+ initData();
472
+ watch(() => props.defaultValue, (val) => {
473
+ if (val) {
474
+ resetRender();
475
+ }
476
+ });
477
+ return __spreadValues(__spreadValues({
478
+ weeks,
479
+ touchStart,
480
+ touchMove,
481
+ touchEnd,
482
+ getClass,
483
+ isStartTip,
484
+ isEndTip,
485
+ chooseDay,
486
+ isCurrDay,
487
+ confirm,
488
+ monthsPanel,
489
+ months,
490
+ weeksPanel
491
+ }, toRefs(state)), toRefs(props));
492
+ }
493
+ });
494
+ const _hoisted_1 = { class: "calendar-title" };
495
+ const _hoisted_2 = { class: "calendar-curr-month" };
496
+ const _hoisted_3 = {
497
+ class: "calendar-weeks",
498
+ ref: "weeksPanel"
499
+ };
500
+ const _hoisted_4 = {
501
+ class: "calendar-months-panel",
502
+ ref: "monthsPanel"
503
+ };
504
+ const _hoisted_5 = { class: "calendar-loading-tip" };
505
+ const _hoisted_6 = { class: "calendar-month-title" };
506
+ const _hoisted_7 = { class: "calendar-month-con" };
507
+ const _hoisted_8 = ["onClick"];
508
+ const _hoisted_9 = { class: "calendar-day" };
509
+ const _hoisted_10 = {
510
+ key: 0,
511
+ class: "calendar-curr-tips"
512
+ };
513
+ const _hoisted_11 = {
514
+ key: 1,
515
+ class: "calendar-day-tip"
516
+ };
517
+ const _hoisted_12 = {
518
+ key: 2,
519
+ class: "calendar-day-tip"
520
+ };
521
+ const _hoisted_13 = {
522
+ key: 0,
523
+ class: "nut-calendar-footer"
524
+ };
525
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
526
+ return openBlock(), createElementBlock("view", {
527
+ class: normalizeClass(["nut-calendar nut-calendar-taro", {
528
+ "nut-calendar-tile": !_ctx.poppable,
529
+ "nut-calendar-nofooter": _ctx.isAutoBackFill
530
+ }])
531
+ }, [
532
+ createElementVNode("view", {
533
+ class: normalizeClass(["nut-calendar-header", { "nut-calendar-header-tile": !_ctx.poppable }])
534
+ }, [
535
+ _ctx.poppable ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
536
+ createElementVNode("view", _hoisted_1, toDisplayString(_ctx.title), 1),
537
+ createElementVNode("view", _hoisted_2, toDisplayString(_ctx.yearMonthTitle), 1)
538
+ ], 64)) : createCommentVNode("", true),
539
+ createElementVNode("view", _hoisted_3, [
540
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (item, index2) => {
541
+ return openBlock(), createElementBlock("view", {
542
+ class: "calendar-week-item",
543
+ key: index2
544
+ }, toDisplayString(item), 1);
545
+ }), 128))
546
+ ], 512)
547
+ ], 2),
548
+ createElementVNode("view", {
549
+ class: "nut-calendar-content",
550
+ ref: "months",
551
+ onTouchstart: _cache[0] || (_cache[0] = withModifiers((...args) => _ctx.touchStart && _ctx.touchStart(...args), ["stop"])),
552
+ onTouchmove: _cache[1] || (_cache[1] = withModifiers((...args) => _ctx.touchMove && _ctx.touchMove(...args), ["stop", "prevent"])),
553
+ onTouchend: _cache[2] || (_cache[2] = withModifiers((...args) => _ctx.touchEnd && _ctx.touchEnd(...args), ["stop"]))
554
+ }, [
555
+ createElementVNode("view", _hoisted_4, [
556
+ createElementVNode("view", _hoisted_5, toDisplayString(!_ctx.unLoadPrev ? "\u52A0\u8F7D\u4E0A\u4E00\u4E2A\u6708" : "\u6CA1\u6709\u66F4\u65E9\u6708\u4EFD"), 1),
557
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.monthsData, (month, index2) => {
558
+ return openBlock(), createElementBlock("view", {
559
+ class: "calendar-month",
560
+ key: index2
561
+ }, [
562
+ createElementVNode("view", _hoisted_6, toDisplayString(month.title), 1),
563
+ createElementVNode("view", _hoisted_7, [
564
+ createElementVNode("view", {
565
+ class: normalizeClass(["calendar-month-item", _ctx.type === "range" ? "month-item-range" : ""])
566
+ }, [
567
+ (openBlock(true), createElementBlock(Fragment, null, renderList(month.monthData, (day, i) => {
568
+ return openBlock(), createElementBlock("view", {
569
+ key: i,
570
+ class: normalizeClass(["calendar-month-day", _ctx.getClass(day, month)]),
571
+ onClick: ($event) => _ctx.chooseDay(day, month)
572
+ }, [
573
+ createElementVNode("view", _hoisted_9, toDisplayString(day.type == "curr" ? day.day : ""), 1),
574
+ _ctx.isCurrDay(month, day.day) ? (openBlock(), createElementBlock("view", _hoisted_10, "\u4ECA\u5929")) : createCommentVNode("", true),
575
+ _ctx.isStartTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_11, toDisplayString("\u5F00\u59CB"))) : _ctx.isEndTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_12, toDisplayString("\u7ED3\u675F"))) : createCommentVNode("", true)
576
+ ], 10, _hoisted_8);
577
+ }), 128))
578
+ ], 2)
579
+ ])
580
+ ]);
581
+ }), 128))
582
+ ], 512)
583
+ ], 544),
584
+ _ctx.poppable && !_ctx.isAutoBackFill ? (openBlock(), createElementBlock("view", _hoisted_13, [
585
+ createElementVNode("view", {
586
+ class: "calendar-confirm-btn",
587
+ onClick: _cache[3] || (_cache[3] = (...args) => _ctx.confirm && _ctx.confirm(...args))
588
+ }, "\u786E\u5B9A")
589
+ ])) : createCommentVNode("", true)
590
+ ], 2);
591
+ }
592
+ var CalendarItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
593
+ const { create } = createComponent("calendar");
594
+ const _sfc_main = create({
595
+ components: {
596
+ [CalendarItem.name]: CalendarItem
597
+ },
598
+ props: {
599
+ type: {
600
+ type: String,
601
+ default: "one"
602
+ },
603
+ isAutoBackFill: {
604
+ type: Boolean,
605
+ default: false
606
+ },
607
+ poppable: {
608
+ type: Boolean,
609
+ default: true
610
+ },
611
+ visible: {
612
+ type: Boolean,
613
+ default: false
614
+ },
615
+ title: {
616
+ type: String,
617
+ default: "\u65E5\u5386\u9009\u62E9"
618
+ },
619
+ defaultValue: {
620
+ type: String
621
+ },
622
+ startDate: {
623
+ type: String,
624
+ default: Utils.getDay(0)
625
+ },
626
+ endDate: {
627
+ type: String,
628
+ default: Utils.getDay(365)
629
+ }
630
+ },
631
+ emits: ["choose", "close", "update:visible"],
632
+ setup(props, { emit }) {
633
+ const calendarRef = ref(null);
634
+ const update = () => {
635
+ emit("update:visible", false);
636
+ };
637
+ const close = () => {
638
+ emit("close");
639
+ emit("update:visible", false);
640
+ };
641
+ const choose = (param) => {
642
+ close();
643
+ emit("choose", param);
644
+ };
645
+ const closePopup = () => {
646
+ close();
647
+ };
648
+ return {
649
+ closePopup,
650
+ update,
651
+ close,
652
+ choose,
653
+ calendarRef
654
+ };
655
+ }
656
+ });
657
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
658
+ const _component_nut_calendar_item = resolveComponent("nut-calendar-item");
659
+ const _component_nut_popup = resolveComponent("nut-popup");
660
+ return _ctx.poppable ? (openBlock(), createBlock(_component_nut_popup, {
661
+ key: 0,
662
+ visible: _ctx.visible,
663
+ position: "bottom",
664
+ round: "",
665
+ closeable: true,
666
+ onClickOverlay: _ctx.closePopup,
667
+ onClickCloseIcon: _ctx.closePopup
668
+ }, {
669
+ default: withCtx(() => [
670
+ createVNode(_component_nut_calendar_item, {
671
+ props: "",
672
+ ref: "calendarRef",
673
+ type: _ctx.type,
674
+ "is-auto-back-fill": _ctx.isAutoBackFill,
675
+ poppable: _ctx.poppable,
676
+ title: _ctx.title,
677
+ "default-value": _ctx.defaultValue,
678
+ "start-date": _ctx.startDate,
679
+ "end-date": _ctx.endDate,
680
+ onUpdate: _ctx.update,
681
+ onClose: _ctx.close,
682
+ onChoose: _ctx.choose
683
+ }, null, 8, ["type", "is-auto-back-fill", "poppable", "title", "default-value", "start-date", "end-date", "onUpdate", "onClose", "onChoose"])
684
+ ]),
685
+ _: 1
686
+ }, 8, ["visible", "onClickOverlay", "onClickCloseIcon"])) : (openBlock(), createBlock(_component_nut_calendar_item, {
687
+ key: 1,
688
+ type: _ctx.type,
689
+ "is-auto-back-fill": _ctx.isAutoBackFill,
690
+ poppable: _ctx.poppable,
691
+ title: _ctx.title,
692
+ "default-value": _ctx.defaultValue,
693
+ "start-date": _ctx.startDate,
694
+ "end-date": _ctx.endDate,
695
+ onClose: _ctx.close,
696
+ onChoose: _ctx.choose
697
+ }, null, 8, ["type", "is-auto-back-fill", "poppable", "title", "default-value", "start-date", "end-date", "onClose", "onChoose"]));
698
+ }
699
+ var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
700
+ export { index as default };