@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
@@ -1,692 +1,13 @@
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
1
  /*!
18
- * @nutui/nutui v3.1.18-beta.0 Tue Mar 08 2022 10:41:31 GMT+0800 (中国标准时间)
19
- * (c) 2021 @jdf2e.
2
+ * @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
3
+ * (c) 2022 @jdf2e.
20
4
  * Released under the MIT License.
21
5
  */
22
- import { ref, computed, reactive, watch, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, renderSlot, Fragment, renderList, normalizeStyle, createTextVNode, resolveComponent, createBlock, withCtx, createSlots } from "vue";
6
+ import { computed, ref, watch, resolveComponent, openBlock, createBlock, withCtx, createSlots, renderSlot, createCommentVNode } from "vue";
23
7
  import { c as createComponent } from "./component.js";
24
- import { r as requestAniFrame } from "./raf.js";
8
+ import { C as CalendarItem, U as Utils } from "./index.taro.js";
25
9
  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
- showTitle: {
123
- type: Boolean,
124
- default: true
125
- },
126
- showSubTitle: {
127
- type: Boolean,
128
- default: true
129
- },
130
- showToday: {
131
- type: Boolean,
132
- default: true
133
- },
134
- title: {
135
- type: String,
136
- default: "\u65E5\u5386\u9009\u62E9"
137
- },
138
- confirmText: {
139
- type: String,
140
- default: "\u786E\u8BA4"
141
- },
142
- startText: {
143
- type: String,
144
- default: "\u5F00\u59CB"
145
- },
146
- endText: {
147
- type: String,
148
- default: "\u7ED3\u675F"
149
- },
150
- defaultValue: {
151
- type: [String, Array],
152
- default: null
153
- },
154
- startDate: {
155
- type: String,
156
- default: Utils.getDay(0)
157
- },
158
- endDate: {
159
- type: String,
160
- default: Utils.getDay(365)
161
- }
162
- },
163
- emits: ["choose", "update", "close", "select"],
164
- setup(props, { emit, slots }) {
165
- const weeks = ref(["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"]);
166
- const months = ref(null);
167
- const monthsPanel = ref(null);
168
- const weeksPanel = ref(null);
169
- const viewArea = ref(null);
170
- const viewHeight = ref(0);
171
- const compConthsData = computed(() => {
172
- return state.monthsData.slice(state.defaultRange[0], state.defaultRange[1]);
173
- });
174
- const showTopBtn = computed(() => {
175
- return slots.btn;
176
- });
177
- const topInfo = computed(() => {
178
- return slots.topInfo;
179
- });
180
- const bottomInfo = computed(() => {
181
- return slots.bottomInfo;
182
- });
183
- const state = reactive({
184
- yearMonthTitle: "",
185
- defaultRange: [],
186
- currDate: "",
187
- propStartDate: "",
188
- propEndDate: "",
189
- unLoadPrev: false,
190
- touchParams: {
191
- startY: 0,
192
- endY: 0,
193
- startTime: 0,
194
- endTime: 0,
195
- lastY: 0,
196
- lastTime: 0
197
- },
198
- transformY: 0,
199
- translateY: 0,
200
- scrollDistance: 0,
201
- defaultData: [],
202
- chooseData: [],
203
- monthsData: [],
204
- dayPrefix: "calendar-month-day",
205
- startData: "",
206
- endData: "",
207
- isRange: props.type === "range",
208
- timer: 0,
209
- currentIndex: 0,
210
- avgHeight: 0,
211
- monthsNum: 0
212
- });
213
- const splitDate = (date) => {
214
- return date.split("-");
215
- };
216
- const isStart = (currDate) => {
217
- return Utils.isEqual(state.currDate[0], currDate);
218
- };
219
- const isEnd = (currDate) => {
220
- return Utils.isEqual(state.currDate[1], currDate);
221
- };
222
- const getCurrDate = (day, month, isRange) => {
223
- return month.curData[0] + "-" + month.curData[1] + "-" + Utils.getNumTwoBit(+day.day);
224
- };
225
- const getClass = (day, month, isRange) => {
226
- const currDate = getCurrDate(day, month);
227
- if (day.type == "curr") {
228
- if (!state.isRange && Utils.isEqual(state.currDate, currDate) || state.isRange && (isStart(currDate) || isEnd(currDate))) {
229
- return `${state.dayPrefix}-active`;
230
- } else if (state.propStartDate && Utils.compareDate(currDate, state.propStartDate) || state.propEndDate && Utils.compareDate(state.propEndDate, currDate)) {
231
- return `${state.dayPrefix}-disabled`;
232
- } 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])) {
233
- return `${state.dayPrefix}-choose`;
234
- } else {
235
- return null;
236
- }
237
- } else {
238
- return `${state.dayPrefix}-disabled`;
239
- }
240
- };
241
- const confirm = () => {
242
- if (state.isRange && state.chooseData.length == 2 || !state.isRange) {
243
- emit("choose", state.chooseData);
244
- if (props.poppable) {
245
- emit("update");
246
- }
247
- }
248
- };
249
- const chooseDay = (day, month, isFirst, isRange) => {
250
- if (getClass(day, month) != `${state.dayPrefix}-disabled`) {
251
- let days = [...month.curData];
252
- days[2] = typeof day.day == "number" ? Utils.getNumTwoBit(day.day) : day.day;
253
- days[3] = `${days[0]}-${days[1]}-${days[2]}`;
254
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
255
- if (!state.isRange) {
256
- state.currDate = days[3];
257
- state.chooseData = [...days];
258
- } else {
259
- if (Object.values(state.currDate).length == 2) {
260
- state.currDate = [days[3]];
261
- } else {
262
- if (Utils.compareDate(state.currDate[0], days[3])) {
263
- Array.isArray(state.currDate) && state.currDate.push(days[3]);
264
- } else {
265
- Array.isArray(state.currDate) && state.currDate.unshift(days[3]);
266
- }
267
- }
268
- if (state.chooseData.length == 2 || !state.chooseData.length) {
269
- state.chooseData = [...days];
270
- } else {
271
- if (Utils.compareDate(state.chooseData[3], days[3])) {
272
- state.chooseData = [[...state.chooseData], [...days]];
273
- } else {
274
- state.chooseData = [[...days], [...state.chooseData]];
275
- }
276
- }
277
- }
278
- if (!isFirst) {
279
- emit("select", state.chooseData);
280
- if (props.isAutoBackFill) {
281
- confirm();
282
- }
283
- }
284
- }
285
- };
286
- const getCurrData = (type) => {
287
- const monthData = type == "prev" ? state.monthsData[0] : state.monthsData[state.monthsData.length - 1];
288
- let year = parseInt(monthData.curData[0]);
289
- let month = parseInt(monthData.curData[1].toString().replace(/^0/, ""));
290
- switch (type) {
291
- case "prev":
292
- month == 1 && (year -= 1);
293
- month = month == 1 ? 12 : --month;
294
- break;
295
- case "next":
296
- month == 12 && (year += 1);
297
- month = month == 12 ? 1 : ++month;
298
- break;
299
- }
300
- return [year, Utils.getNumTwoBit(month), Utils.getMonthDays(String(year), String(month))];
301
- };
302
- const getDaysStatus = (days, type, dateInfo) => {
303
- let { year, month } = dateInfo;
304
- if (type == "prev" && days >= 7) {
305
- days -= 7;
306
- }
307
- return Array.from(Array(days), (v, k) => {
308
- return {
309
- day: k + 1,
310
- type,
311
- year,
312
- month
313
- };
314
- });
315
- };
316
- const getPreDaysStatus = (days, type, dateInfo, preCurrMonthDays) => {
317
- let { year, month } = dateInfo;
318
- if (type == "prev" && days >= 7) {
319
- days -= 7;
320
- }
321
- let months2 = Array.from(Array(preCurrMonthDays), (v, k) => {
322
- return {
323
- day: k + 1,
324
- type,
325
- year,
326
- month
327
- };
328
- });
329
- return months2.slice(preCurrMonthDays - days);
330
- };
331
- const getMonth = (curData, type) => {
332
- const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
333
- let preMonth = curData[1] - 1;
334
- let preYear = curData[0];
335
- if (preMonth <= 0) {
336
- preMonth = 12;
337
- preYear += 1;
338
- }
339
- const currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
340
- const preCurrMonthDays = Utils.getMonthDays(preYear + "", preMonth + "");
341
- const title = {
342
- year: curData[0],
343
- month: curData[1]
344
- };
345
- const monthInfo = {
346
- curData,
347
- title: `${title.year}\u5E74${title.month}\u6708`,
348
- monthData: [
349
- ...getPreDaysStatus(preMonthDays, "prev", { month: preMonth, year: preYear }, preCurrMonthDays),
350
- ...getDaysStatus(currMonthDays, "curr", title)
351
- ]
352
- };
353
- monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
354
- let cssScrollHeight = 0;
355
- if (state.monthsData.length > 0) {
356
- cssScrollHeight = state.monthsData[state.monthsData.length - 1].cssScrollHeight + state.monthsData[state.monthsData.length - 1].cssHeight;
357
- }
358
- monthInfo.cssScrollHeight = cssScrollHeight;
359
- if (type == "next") {
360
- 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]}`)) {
361
- state.monthsData.push(monthInfo);
362
- }
363
- } else {
364
- if (!state.startData || !Utils.compareDate(`${curData[0]}-${curData[1]}-${curData[2]}`, `${state.startData[0]}-${state.startData[1]}-01`)) {
365
- state.monthsData.unshift(monthInfo);
366
- } else {
367
- state.unLoadPrev = true;
368
- }
369
- }
370
- };
371
- const initData = () => {
372
- let propStartDate = props.startDate ? props.startDate : Utils.getDay(0);
373
- let propEndDate = props.endDate ? props.endDate : Utils.getDay(365);
374
- state.propStartDate = propStartDate;
375
- state.propEndDate = propEndDate;
376
- state.startData = splitDate(propStartDate);
377
- state.endData = splitDate(propEndDate);
378
- if (!props.defaultValue || Array.isArray(props.defaultValue) && props.defaultValue.length <= 0) {
379
- state.currDate = state.isRange ? [Utils.date2Str(new Date()), Utils.getDay(1)] : Utils.date2Str(new Date());
380
- } else {
381
- state.currDate = state.isRange ? [...props.defaultValue] : props.defaultValue;
382
- }
383
- const startDate = {
384
- year: Number(state.startData[0]),
385
- month: Number(state.startData[1])
386
- };
387
- const endDate = {
388
- year: Number(state.endData[0]),
389
- month: Number(state.endData[1])
390
- };
391
- let monthsNum = endDate.month - startDate.month;
392
- if (endDate.year - startDate.year > 0) {
393
- monthsNum = monthsNum + 12 * (endDate.year - startDate.year);
394
- }
395
- getMonth(state.startData, "next");
396
- let i = 1;
397
- do {
398
- getMonth(getCurrData("next"), "next");
399
- } while (i++ < monthsNum);
400
- state.monthsNum = monthsNum;
401
- if (state.isRange && Array.isArray(state.currDate)) {
402
- if (propStartDate && Utils.compareDate(state.currDate[0], propStartDate)) {
403
- state.currDate.splice(0, 1, propStartDate);
404
- }
405
- if (propEndDate && Utils.compareDate(propEndDate, state.currDate[1])) {
406
- state.currDate.splice(1, 1, propEndDate);
407
- }
408
- state.defaultData = [...splitDate(state.currDate[0]), ...splitDate(state.currDate[1])];
409
- } else {
410
- if (propStartDate && Utils.compareDate(state.currDate, propStartDate)) {
411
- state.currDate = propStartDate;
412
- } else if (propEndDate && !Utils.compareDate(state.currDate, propEndDate)) {
413
- state.currDate = propEndDate;
414
- }
415
- state.defaultData = [...splitDate(state.currDate)];
416
- }
417
- let current = 0;
418
- let lastCurrent = 0;
419
- state.monthsData.forEach((item, index2) => {
420
- if (item.title == `${state.defaultData[0]}\u5E74${state.defaultData[1]}\u6708`) {
421
- current = index2;
422
- }
423
- if (state.isRange) {
424
- if (item.title == `${state.defaultData[3]}\u5E74${state.defaultData[4]}\u6708`) {
425
- lastCurrent = index2;
426
- }
427
- }
428
- });
429
- setDefaultRange(monthsNum, current);
430
- state.currentIndex = current;
431
- state.yearMonthTitle = state.monthsData[state.currentIndex].title;
432
- if (state.isRange) {
433
- chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
434
- chooseDay({ day: state.defaultData[5], type: "curr" }, state.monthsData[lastCurrent], true);
435
- } else {
436
- chooseDay({ day: state.defaultData[2], type: "curr" }, state.monthsData[state.currentIndex], true);
437
- }
438
- let lastItem = state.monthsData[state.monthsData.length - 1];
439
- let containerHeight = lastItem.cssHeight + lastItem.cssScrollHeight;
440
- requestAniFrame(() => {
441
- if ((months == null ? void 0 : months.value) && (monthsPanel == null ? void 0 : monthsPanel.value) && (viewArea == null ? void 0 : viewArea.value)) {
442
- viewHeight.value = months.value.clientHeight;
443
- monthsPanel.value.style.height = `${containerHeight}px`;
444
- months.value.scrollTop = state.monthsData[state.currentIndex].cssScrollHeight;
445
- }
446
- });
447
- state.avgHeight = Math.floor(containerHeight / (monthsNum + 1));
448
- };
449
- const setDefaultRange = (monthsNum, current) => {
450
- if (monthsNum >= 3) {
451
- if (current > 0 && current < monthsNum) {
452
- state.defaultRange = [current - 1, current + 3];
453
- } else if (current == 0) {
454
- state.defaultRange = [current, current + 4];
455
- } else if (current == monthsNum) {
456
- state.defaultRange = [current - 2, current + 2];
457
- }
458
- } else {
459
- state.defaultRange = [0, monthsNum + 2];
460
- }
461
- let defaultScrollTop = state.monthsData[state.defaultRange[0]].cssScrollHeight;
462
- state.translateY = defaultScrollTop;
463
- };
464
- const isActive = (day, month) => {
465
- return state.isRange && day.type == "curr" && getClass(day, month) == "calendar-month-day-active";
466
- };
467
- const isStartTip = (day, month) => {
468
- if (isActive(day, month)) {
469
- return isStart(getCurrDate(day, month));
470
- } else {
471
- return false;
472
- }
473
- };
474
- const isEndTip = (day, month) => {
475
- if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
476
- return isActive(day, month);
477
- }
478
- return false;
479
- };
480
- const rangeTip = (day, month) => {
481
- if (state.currDate.length >= 2) {
482
- return Utils.isEqual(state.currDate[0], state.currDate[1]);
483
- }
484
- };
485
- const isCurrDay = (month, day) => {
486
- const date = `${month.curData[0]}-${month.curData[1]}-${day}`;
487
- return Utils.isEqual(date, Utils.date2Str(new Date()));
488
- };
489
- const mothsViewScroll = (e) => {
490
- var currentScrollTop = e.target.scrollTop;
491
- let current = Math.floor(currentScrollTop / state.avgHeight);
492
- if (current == 0) {
493
- if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
494
- current += 1;
495
- }
496
- } else if (current > 0 && current < state.monthsNum - 1) {
497
- if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
498
- current += 1;
499
- }
500
- if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
501
- current -= 1;
502
- }
503
- } else {
504
- if (currentScrollTop + viewHeight.value < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight) {
505
- current -= 1;
506
- }
507
- if (current + 1 <= state.monthsNum && currentScrollTop + viewHeight.value >= 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 __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
- }
553
- });
554
- const _hoisted_1 = {
555
- key: 0,
556
- class: "calendar-title"
557
- };
558
- const _hoisted_2 = {
559
- key: 1,
560
- class: "calendar-top-slot"
561
- };
562
- const _hoisted_3 = {
563
- key: 2,
564
- class: "calendar-curr-month"
565
- };
566
- const _hoisted_4 = {
567
- class: "calendar-weeks",
568
- ref: "weeksPanel"
569
- };
570
- const _hoisted_5 = {
571
- class: "calendar-months-panel",
572
- ref: "monthsPanel"
573
- };
574
- const _hoisted_6 = { class: "calendar-month-title" };
575
- const _hoisted_7 = { class: "calendar-month-con" };
576
- const _hoisted_8 = ["onClick"];
577
- const _hoisted_9 = { class: "calendar-day" };
578
- const _hoisted_10 = {
579
- key: 0,
580
- class: "calendar-curr-tips calendar-curr-tips-top"
581
- };
582
- const _hoisted_11 = {
583
- key: 1,
584
- class: "calendar-curr-tips calendar-curr-tips-bottom"
585
- };
586
- const _hoisted_12 = {
587
- key: 2,
588
- class: "calendar-curr-tip-curr"
589
- };
590
- const _hoisted_13 = {
591
- key: 4,
592
- class: "calendar-day-tip"
593
- };
594
- const _hoisted_14 = {
595
- key: 0,
596
- class: "nut-calendar-footer"
597
- };
598
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
599
- return openBlock(), createElementBlock("view", {
600
- class: normalizeClass(["nut-calendar nut-calendar-taro", {
601
- "nut-calendar-tile": !_ctx.poppable,
602
- "nut-calendar-nofooter": _ctx.isAutoBackFill
603
- }])
604
- }, [
605
- createElementVNode("view", {
606
- class: normalizeClass(["nut-calendar-header", { "nut-calendar-header-tile": !_ctx.poppable }])
607
- }, [
608
- _ctx.showTitle ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
609
- _ctx.showTopBtn ? (openBlock(), createElementBlock("view", _hoisted_2, [
610
- renderSlot(_ctx.$slots, "btn")
611
- ])) : createCommentVNode("", true),
612
- _ctx.showSubTitle ? (openBlock(), createElementBlock("view", _hoisted_3, toDisplayString(_ctx.yearMonthTitle), 1)) : createCommentVNode("", true),
613
- createElementVNode("view", _hoisted_4, [
614
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (item, index2) => {
615
- return openBlock(), createElementBlock("view", {
616
- class: "calendar-week-item",
617
- key: index2
618
- }, toDisplayString(item), 1);
619
- }), 128))
620
- ], 512)
621
- ], 2),
622
- createElementVNode("view", {
623
- class: "nut-calendar-content",
624
- ref: "months",
625
- onScroll: _cache[0] || (_cache[0] = (...args) => _ctx.mothsViewScroll && _ctx.mothsViewScroll(...args))
626
- }, [
627
- createElementVNode("view", _hoisted_5, [
628
- createElementVNode("view", {
629
- class: "viewArea",
630
- ref: "viewArea",
631
- style: normalizeStyle({ transform: `translateY(${_ctx.translateY}px)` })
632
- }, [
633
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.compConthsData, (month, index2) => {
634
- return openBlock(), createElementBlock("view", {
635
- class: "calendar-month",
636
- key: index2
637
- }, [
638
- createElementVNode("view", _hoisted_6, toDisplayString(month.title), 1),
639
- createElementVNode("view", _hoisted_7, [
640
- createElementVNode("view", {
641
- class: normalizeClass(["calendar-month-item", _ctx.type === "range" ? "month-item-range" : ""])
642
- }, [
643
- (openBlock(true), createElementBlock(Fragment, null, renderList(month.monthData, (day, i) => {
644
- return openBlock(), createElementBlock("view", {
645
- key: i,
646
- class: normalizeClass(["calendar-month-day", _ctx.getClass(day, month)]),
647
- onClick: ($event) => _ctx.chooseDay(day, month)
648
- }, [
649
- createElementVNode("view", _hoisted_9, [
650
- renderSlot(_ctx.$slots, "day", {
651
- date: day.type == "curr" ? day : ""
652
- }, () => [
653
- createTextVNode(toDisplayString(day.type == "curr" ? day.day : ""), 1)
654
- ])
655
- ]),
656
- _ctx.topInfo ? (openBlock(), createElementBlock("view", _hoisted_10, [
657
- renderSlot(_ctx.$slots, "topInfo", {
658
- date: day.type == "curr" ? day : ""
659
- })
660
- ])) : createCommentVNode("", true),
661
- _ctx.bottomInfo ? (openBlock(), createElementBlock("view", _hoisted_11, [
662
- renderSlot(_ctx.$slots, "bottomInfo", {
663
- date: day.type == "curr" ? day : ""
664
- })
665
- ])) : createCommentVNode("", true),
666
- !_ctx.bottomInfo && _ctx.showToday && _ctx.isCurrDay(month, day.day) ? (openBlock(), createElementBlock("view", _hoisted_12, " \u4ECA\u5929 ")) : createCommentVNode("", true),
667
- _ctx.isStartTip(day, month) ? (openBlock(), createElementBlock("view", {
668
- key: 3,
669
- class: normalizeClass(["calendar-day-tip", { "calendar-curr-tips-top": _ctx.rangeTip(day, month) }])
670
- }, toDisplayString(_ctx.startText), 3)) : createCommentVNode("", true),
671
- _ctx.isEndTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_13, toDisplayString(_ctx.endText), 1)) : createCommentVNode("", true)
672
- ], 10, _hoisted_8);
673
- }), 128))
674
- ], 2)
675
- ])
676
- ]);
677
- }), 128))
678
- ], 4)
679
- ], 512)
680
- ], 544),
681
- _ctx.poppable && !_ctx.isAutoBackFill ? (openBlock(), createElementBlock("view", _hoisted_14, [
682
- createElementVNode("view", {
683
- class: "calendar-confirm-btn",
684
- onClick: _cache[1] || (_cache[1] = (...args) => _ctx.confirm && _ctx.confirm(...args))
685
- }, toDisplayString(_ctx.confirmText), 1)
686
- ])) : createCommentVNode("", true)
687
- ], 2);
688
- }
689
- var CalendarItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
10
+ import "@tarojs/taro";
690
11
  const { create } = createComponent("calendar");
691
12
  const _sfc_main = create({
692
13
  components: {
@@ -763,11 +84,14 @@ const _sfc_main = create({
763
84
  const bottomInfo = computed(() => {
764
85
  return slots.bottomInfo;
765
86
  });
87
+ let show = ref(props.visible);
766
88
  const calendarRef = ref(null);
767
89
  const update = () => {
90
+ show.value = false;
768
91
  emit("update:visible", false);
769
92
  };
770
93
  const close = () => {
94
+ show.value = false;
771
95
  emit("close");
772
96
  emit("update:visible", false);
773
97
  };
@@ -775,18 +99,22 @@ const _sfc_main = create({
775
99
  close();
776
100
  emit("choose", param);
777
101
  };
778
- const select = (param) => {
779
- emit("select", param);
780
- };
781
102
  const closePopup = () => {
782
103
  close();
783
104
  };
105
+ const select = (param) => {
106
+ emit("select", param);
107
+ };
108
+ watch(() => props.visible, (value) => {
109
+ show.value = value;
110
+ });
784
111
  return {
112
+ show,
785
113
  closePopup,
786
114
  update,
787
115
  close,
788
- choose,
789
116
  select,
117
+ choose,
790
118
  calendarRef,
791
119
  showTopBtn,
792
120
  topInfo,
@@ -800,35 +128,34 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
800
128
  const _component_nut_popup = resolveComponent("nut-popup");
801
129
  return _ctx.poppable ? (openBlock(), createBlock(_component_nut_popup, {
802
130
  key: 0,
803
- visible: _ctx.visible,
131
+ visible: _ctx.show,
132
+ "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => _ctx.show = $event),
804
133
  position: "bottom",
805
134
  round: "",
806
- closeable: true,
135
+ closeable: "",
807
136
  onClickOverlay: _ctx.closePopup,
808
137
  onClickCloseIcon: _ctx.closePopup,
809
- "destroy-on-close": true,
810
138
  style: { height: "85vh" }
811
139
  }, {
812
140
  default: withCtx(() => [
813
- _ctx.visible ? (openBlock(), createBlock(_component_nut_calendar_item, {
141
+ _ctx.show ? (openBlock(), createBlock(_component_nut_calendar_item, {
814
142
  key: 0,
815
- props: "",
816
143
  ref: "calendarRef",
817
144
  type: _ctx.type,
818
145
  "is-auto-back-fill": _ctx.isAutoBackFill,
819
146
  poppable: _ctx.poppable,
820
147
  title: _ctx.title,
821
- "confirm-text": _ctx.confirmText,
822
- "start-text": _ctx.startText,
823
- "end-text": _ctx.endText,
824
148
  "default-value": _ctx.defaultValue,
825
- "show-today": _ctx.showToday,
826
149
  "start-date": _ctx.startDate,
827
150
  "end-date": _ctx.endDate,
828
151
  onUpdate: _ctx.update,
829
152
  onClose: _ctx.close,
830
153
  onChoose: _ctx.choose,
831
154
  onSelect: _ctx.select,
155
+ "confirm-text": _ctx.confirmText,
156
+ "start-text": _ctx.startText,
157
+ "end-text": _ctx.endText,
158
+ "show-today": _ctx.showToday,
832
159
  "show-title": _ctx.showTitle,
833
160
  "show-sub-title": _ctx.showSubTitle
834
161
  }, createSlots({ _: 2 }, [
@@ -862,7 +189,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
862
189
  })
863
190
  ])
864
191
  } : void 0
865
- ]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "confirm-text", "start-text", "end-text", "default-value", "show-today", "start-date", "end-date", "onUpdate", "onClose", "onChoose", "onSelect", "show-title", "show-sub-title"])) : createCommentVNode("", true)
192
+ ]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "default-value", "start-date", "end-date", "onUpdate", "onClose", "onChoose", "onSelect", "confirm-text", "start-text", "end-text", "show-today", "show-title", "show-sub-title"])) : createCommentVNode("", true)
866
193
  ]),
867
194
  _: 3
868
195
  }, 8, ["visible", "onClickOverlay", "onClickCloseIcon"])) : (openBlock(), createBlock(_component_nut_calendar_item, {
@@ -881,7 +208,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
881
208
  onChoose: _ctx.choose,
882
209
  onSelect: _ctx.select,
883
210
  "show-title": _ctx.showTitle,
884
- "show-sub-title": _ctx.showSubTitle
211
+ "show-sub-title": _ctx.showSubTitle,
212
+ "show-today": _ctx.showToday
885
213
  }, createSlots({ _: 2 }, [
886
214
  _ctx.showTopBtn ? {
887
215
  name: "btn",
@@ -913,7 +241,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
913
241
  })
914
242
  ])
915
243
  } : void 0
916
- ]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "confirm-text", "start-text", "end-text", "default-value", "start-date", "end-date", "onClose", "onChoose", "onSelect", "show-title", "show-sub-title"]));
244
+ ]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "confirm-text", "start-text", "end-text", "default-value", "start-date", "end-date", "onClose", "onChoose", "onSelect", "show-title", "show-sub-title", "show-today"]));
917
245
  }
918
- var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
919
- export { index as default };
246
+ var index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
247
+ export { index_taro as default };