@nutui/nutui 3.1.17 → 3.1.19-beta.0

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 (155) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +1 -1
  3. package/README.md +7 -1
  4. package/dist/nutui.d.ts +3 -1
  5. package/dist/nutui.es.js +2335 -1280
  6. package/dist/nutui.umd.js +2350 -1293
  7. package/dist/packages/_es/ActionSheet.js +8 -3
  8. package/dist/packages/_es/Address.js +17 -11
  9. package/dist/packages/_es/Audio.js +2 -2
  10. package/dist/packages/_es/AudioOperate.js +125 -0
  11. package/dist/packages/_es/Avatar.js +2 -2
  12. package/dist/packages/_es/BackTop.js +7 -4
  13. package/dist/packages/_es/Badge.js +2 -2
  14. package/dist/packages/_es/Barrage.js +2 -2
  15. package/dist/packages/_es/Button.js +2 -2
  16. package/dist/packages/_es/Calendar.js +10 -687
  17. package/dist/packages/_es/CalendarItem.js +10 -0
  18. package/dist/packages/_es/Card.js +2 -2
  19. package/dist/packages/_es/Cascader.js +2 -2
  20. package/dist/packages/_es/Cell.js +25 -18
  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 +4 -4
  24. package/dist/packages/_es/CircleProgress.js +2 -2
  25. package/dist/packages/_es/Col.js +2 -2
  26. package/dist/packages/_es/Collapse.js +2 -2
  27. package/dist/packages/_es/CollapseItem.js +31 -19
  28. package/dist/packages/_es/CountDown.js +4 -2
  29. package/dist/packages/_es/CountUp.js +25 -16
  30. package/dist/packages/_es/DatePicker.js +83 -47
  31. package/dist/packages/_es/Dialog.js +7 -5
  32. package/dist/packages/_es/Divider.js +2 -2
  33. package/dist/packages/_es/Drag.js +4 -4
  34. package/dist/packages/_es/Elevator.js +3 -3
  35. package/dist/packages/_es/Empty.js +2 -2
  36. package/dist/packages/_es/FixedNav.js +2 -2
  37. package/dist/packages/_es/Form.js +8 -6
  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 +3 -3
  41. package/dist/packages/_es/Icon.js +2 -2
  42. package/dist/packages/_es/ImagePreview.js +11 -6
  43. package/dist/packages/_es/Indicator.js +2 -2
  44. package/dist/packages/_es/InfiniteLoading.js +2 -2
  45. package/dist/packages/_es/Input.js +290 -66
  46. package/dist/packages/_es/InputNumber.js +2 -2
  47. package/dist/packages/_es/Layout.js +2 -2
  48. package/dist/packages/_es/List.js +124 -0
  49. package/dist/packages/_es/Menu.js +3 -3
  50. package/dist/packages/_es/MenuItem.js +4 -4
  51. package/dist/packages/_es/Navbar.js +31 -66
  52. package/dist/packages/_es/NoticeBar.js +41 -22
  53. package/dist/packages/_es/Notify.js +9 -5
  54. package/dist/packages/_es/NumberKeyboard.js +9 -4
  55. package/dist/packages/_es/OldPicker.js +484 -0
  56. package/dist/packages/_es/OverLay.js +2 -2
  57. package/dist/packages/_es/Pagination.js +2 -2
  58. package/dist/packages/_es/Picker.js +164 -157
  59. package/dist/packages/_es/Popover.js +7 -4
  60. package/dist/packages/_es/Popup.js +4 -4
  61. package/dist/packages/_es/Price.js +2 -2
  62. package/dist/packages/_es/Progress.js +14 -22
  63. package/dist/packages/_es/PullRefresh.js +363 -0
  64. package/dist/packages/_es/Radio.js +3 -3
  65. package/dist/packages/_es/RadioGroup.js +2 -2
  66. package/dist/packages/_es/Range.js +131 -21
  67. package/dist/packages/_es/Rate.js +2 -2
  68. package/dist/packages/_es/Row.js +2 -2
  69. package/dist/packages/_es/SearchBar.js +2 -2
  70. package/dist/packages/_es/ShortPassword.js +9 -4
  71. package/dist/packages/_es/SideNavBar.js +2 -2
  72. package/dist/packages/_es/SideNavBarItem.js +2 -2
  73. package/dist/packages/_es/Signature.js +25 -6
  74. package/dist/packages/_es/Skeleton.js +2 -2
  75. package/dist/packages/_es/Sku.js +31 -13
  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 +3 -3
  79. package/dist/packages/_es/SubSideNavBar.js +2 -2
  80. package/dist/packages/_es/Swipe.js +3 -3
  81. package/dist/packages/_es/Swiper.js +3 -3
  82. package/dist/packages/_es/SwiperItem.js +3 -3
  83. package/dist/packages/_es/Switch.js +2 -2
  84. package/dist/packages/_es/TabPane.js +2 -2
  85. package/dist/packages/_es/Tabbar.js +2 -2
  86. package/dist/packages/_es/TabbarItem.js +23 -8
  87. package/dist/packages/_es/Table.js +2 -2
  88. package/dist/packages/_es/Tabs.js +8 -5
  89. package/dist/packages/_es/Tag.js +11 -5
  90. package/dist/packages/_es/TextArea.js +38 -6
  91. package/dist/packages/_es/TimeDetail.js +2 -2
  92. package/dist/packages/_es/TimePannel.js +2 -2
  93. package/dist/packages/_es/TimeSelect.js +8 -3
  94. package/dist/packages/_es/Toast.js +16 -9
  95. package/dist/packages/_es/Uploader.js +2 -4
  96. package/dist/packages/_es/Video.js +12 -8
  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 +6 -8
  100. package/dist/packages/_es/index2.js +9 -32
  101. package/dist/packages/_es/index3.js +29 -57
  102. package/dist/packages/_es/index4.js +64 -0
  103. package/dist/packages/_es/index5.js +687 -0
  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/raf.js +2 -2
  107. package/dist/packages/_es/util.js +2 -2
  108. package/dist/packages/actionsheet/index.scss +7 -6
  109. package/dist/packages/badge/index.scss +11 -13
  110. package/dist/packages/button/index.scss +6 -5
  111. package/dist/packages/calendar/index.scss +9 -4
  112. package/dist/packages/calendaritem/index.scss +0 -207
  113. package/dist/packages/cell/index.scss +9 -9
  114. package/dist/packages/cellgroup/index.scss +1 -1
  115. package/dist/packages/checkbox/index.scss +4 -3
  116. package/dist/packages/collapseitem/index.scss +21 -11
  117. package/dist/packages/countdown/index.scss +3 -1
  118. package/dist/packages/divider/index.scss +8 -8
  119. package/dist/packages/elevator/index.scss +36 -36
  120. package/dist/packages/formitem/index.scss +15 -8
  121. package/dist/packages/indicator/index.scss +1 -1
  122. package/dist/packages/input/index.scss +70 -24
  123. package/dist/packages/inputnumber/index.scss +4 -2
  124. package/dist/packages/list/index.scss +24 -0
  125. package/dist/packages/menu/index.scss +3 -3
  126. package/dist/packages/navbar/index.scss +30 -8
  127. package/dist/packages/noticebar/index.scss +10 -5
  128. package/dist/packages/notify/index.scss +10 -0
  129. package/dist/packages/numberkeyboard/index.scss +22 -21
  130. package/dist/packages/oldpicker/index.scss +131 -0
  131. package/dist/packages/picker/index.scss +38 -32
  132. package/dist/packages/progress/index.scss +24 -19
  133. package/dist/packages/radio/index.scss +7 -6
  134. package/dist/packages/range/index.scss +113 -6
  135. package/dist/packages/searchbar/index.scss +7 -7
  136. package/dist/packages/sidenavbaritem/index.scss +5 -5
  137. package/dist/packages/step/index.scss +29 -29
  138. package/dist/packages/subsidenavbar/index.scss +10 -8
  139. package/dist/packages/swiper/index.scss +4 -4
  140. package/dist/packages/switch/index.scss +8 -8
  141. package/dist/packages/tabbar/index.scss +3 -2
  142. package/dist/packages/tabbaritem/index.scss +19 -3
  143. package/dist/packages/tabs/index.scss +1 -0
  144. package/dist/packages/timedetail/index.scss +13 -13
  145. package/dist/packages/timepannel/index.scss +7 -7
  146. package/dist/packages/timeselect/index.scss +3 -3
  147. package/dist/packages/toast/index.scss +8 -7
  148. package/dist/packages/uploader/index.scss +4 -4
  149. package/dist/style.css +1 -1
  150. package/dist/styles/themes/default.scss +43 -41
  151. package/dist/styles/themes/jdt.scss +91 -0
  152. package/dist/styles/variables-jdt.scss +728 -0
  153. package/dist/styles/variables.scss +322 -38
  154. package/package.json +3 -2
  155. 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.16 Fri Feb 25 2022 18:32:15 GMT+0800 (中国标准时间)
19
- * (c) 2021 @jdf2e.
2
+ * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 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, 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 "./index5.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 "./raf.js";
690
11
  const { create } = createComponent("calendar");
691
12
  const _sfc_main = create({
692
13
  components: {
@@ -822,13 +143,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
822
143
  "start-text": _ctx.startText,
823
144
  "end-text": _ctx.endText,
824
145
  "default-value": _ctx.defaultValue,
825
- "show-today": _ctx.showToday,
826
146
  "start-date": _ctx.startDate,
827
147
  "end-date": _ctx.endDate,
828
148
  onUpdate: _ctx.update,
829
149
  onClose: _ctx.close,
830
150
  onChoose: _ctx.choose,
831
151
  onSelect: _ctx.select,
152
+ "show-today": _ctx.showToday,
832
153
  "show-title": _ctx.showTitle,
833
154
  "show-sub-title": _ctx.showSubTitle
834
155
  }, createSlots({ _: 2 }, [
@@ -862,7 +183,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
862
183
  })
863
184
  ])
864
185
  } : 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)
186
+ ]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "confirm-text", "start-text", "end-text", "default-value", "start-date", "end-date", "onUpdate", "onClose", "onChoose", "onSelect", "show-today", "show-title", "show-sub-title"])) : createCommentVNode("", true)
866
187
  ]),
867
188
  _: 3
868
189
  }, 8, ["visible", "onClickOverlay", "onClickCloseIcon"])) : (openBlock(), createBlock(_component_nut_calendar_item, {
@@ -877,9 +198,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
877
198
  "default-value": _ctx.defaultValue,
878
199
  "start-date": _ctx.startDate,
879
200
  "end-date": _ctx.endDate,
201
+ onUpdate: _ctx.update,
880
202
  onClose: _ctx.close,
881
203
  onChoose: _ctx.choose,
882
204
  onSelect: _ctx.select,
205
+ "show-today": _ctx.showToday,
883
206
  "show-title": _ctx.showTitle,
884
207
  "show-sub-title": _ctx.showSubTitle
885
208
  }, createSlots({ _: 2 }, [
@@ -913,7 +236,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
913
236
  })
914
237
  ])
915
238
  } : 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"]));
239
+ ]), 1032, ["type", "is-auto-back-fill", "poppable", "title", "confirm-text", "start-text", "end-text", "default-value", "start-date", "end-date", "onUpdate", "onClose", "onChoose", "onSelect", "show-today", "show-title", "show-sub-title"]));
917
240
  }
918
241
  var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
919
242
  export { index as default };