@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
@@ -0,0 +1,687 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ /*!
18
+ * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
19
+ * (c) 2022 @jdf2e.
20
+ * Released under the MIT License.
21
+ */
22
+ import { ref, computed, reactive, watch, toRefs, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createCommentVNode, renderSlot, Fragment, renderList, normalizeStyle, createTextVNode } 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 index = date.getDay();
33
+ const dayNames = [
34
+ "\u661F\u671F\u65E5",
35
+ "\u661F\u671F\u4E00",
36
+ "\u661F\u671F\u4E8C",
37
+ "\u661F\u671F\u4E09",
38
+ "\u661F\u671F\u56DB",
39
+ "\u661F\u671F\u4E94",
40
+ "\u661F\u671F\u516D"
41
+ ];
42
+ return dayNames[index];
43
+ },
44
+ getMonthPreDay: function(year, month) {
45
+ const date = new Date(year + "/" + month + "/01");
46
+ let day = date.getDay();
47
+ if (day == 0) {
48
+ day = 7;
49
+ }
50
+ return day;
51
+ },
52
+ getMonthDays: function(year, month) {
53
+ if (/^0/.test(month)) {
54
+ month = month.split("")[1];
55
+ }
56
+ return [
57
+ 0,
58
+ 31,
59
+ this.isLeapYear(Number(year)) ? 29 : 28,
60
+ 31,
61
+ 30,
62
+ 31,
63
+ 30,
64
+ 31,
65
+ 31,
66
+ 30,
67
+ 31,
68
+ 30,
69
+ 31
70
+ ][month];
71
+ },
72
+ getNumTwoBit: function(n) {
73
+ n = Number(n);
74
+ return (n > 9 ? "" : "0") + n;
75
+ },
76
+ date2Str: function(date, split) {
77
+ split = split || "-";
78
+ const y = date.getFullYear();
79
+ const m = this.getNumTwoBit(date.getMonth() + 1);
80
+ const d = this.getNumTwoBit(date.getDate());
81
+ return [y, m, d].join(split);
82
+ },
83
+ getDay: function(i) {
84
+ i = i || 0;
85
+ let date = new Date();
86
+ const diff = i * (1e3 * 60 * 60 * 24);
87
+ date = new Date(date.getTime() + diff);
88
+ return this.date2Str(date);
89
+ },
90
+ compareDate: function(date1, date2) {
91
+ const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
92
+ const endTime = new Date(date2.replace("-", "/").replace("-", "/"));
93
+ if (startTime >= endTime) {
94
+ return false;
95
+ }
96
+ return true;
97
+ },
98
+ isEqual: function(date1, date2) {
99
+ const startTime = new Date(date1).getTime();
100
+ const endTime = new Date(date2).getTime();
101
+ if (startTime == endTime) {
102
+ return true;
103
+ }
104
+ return false;
105
+ }
106
+ };
107
+ const { create } = createComponent("calendar-item");
108
+ const _sfc_main = create({
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, index) => {
420
+ if (item.title == `${state.defaultData[0]}\u5E74${state.defaultData[1]}\u6708`) {
421
+ current = index;
422
+ }
423
+ if (state.isRange) {
424
+ if (item.title == `${state.defaultData[3]}\u5E74${state.defaultData[4]}\u6708`) {
425
+ lastCurrent = index;
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
+ return isActive(day, month) && isStart(getCurrDate(day, month));
469
+ };
470
+ const isEndTip = (day, month) => {
471
+ if (state.currDate.length >= 2 && isEnd(getCurrDate(day, month))) {
472
+ return isActive(day, month);
473
+ }
474
+ return false;
475
+ };
476
+ const rangeTip = (day, month) => {
477
+ if (state.currDate.length >= 2) {
478
+ return Utils.isEqual(state.currDate[0], state.currDate[1]);
479
+ }
480
+ };
481
+ const isCurrDay = (dateInfo) => {
482
+ const date = `${dateInfo.year}-${dateInfo.month}-${dateInfo.day < 10 ? "0" + dateInfo.day : dateInfo.day}`;
483
+ return Utils.isEqual(date, Utils.date2Str(new Date()));
484
+ };
485
+ const mothsViewScroll = (e) => {
486
+ const currentScrollTop = e.target.scrollTop;
487
+ let current = Math.floor(currentScrollTop / state.avgHeight);
488
+ if (current == 0) {
489
+ if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
490
+ current += 1;
491
+ }
492
+ } else if (current > 0 && current < state.monthsNum - 1) {
493
+ if (currentScrollTop >= state.monthsData[current + 1].cssScrollHeight) {
494
+ current += 1;
495
+ }
496
+ if (currentScrollTop < state.monthsData[current].cssScrollHeight) {
497
+ current -= 1;
498
+ }
499
+ } else {
500
+ const viewPosition = Math.round(currentScrollTop + viewHeight.value);
501
+ if (viewPosition < state.monthsData[current].cssScrollHeight + state.monthsData[current].cssHeight && currentScrollTop > state.monthsData[current - 1].cssScrollHeight) {
502
+ current -= 1;
503
+ }
504
+ if (current + 1 <= state.monthsNum && viewPosition >= state.monthsData[current + 1].cssScrollHeight + state.monthsData[current + 1].cssHeight) {
505
+ current += 1;
506
+ }
507
+ if (currentScrollTop < state.monthsData[current - 1].cssScrollHeight) {
508
+ current -= 1;
509
+ }
510
+ }
511
+ if (state.currentIndex !== current) {
512
+ state.currentIndex = current;
513
+ setDefaultRange(state.monthsNum, current);
514
+ }
515
+ state.yearMonthTitle = state.monthsData[current].title;
516
+ };
517
+ const resetRender = () => {
518
+ state.chooseData.splice(0);
519
+ state.monthsData.splice(0);
520
+ initData();
521
+ };
522
+ initData();
523
+ watch(() => props.defaultValue, (val) => {
524
+ if (val) {
525
+ if (props.poppable) {
526
+ resetRender();
527
+ }
528
+ }
529
+ });
530
+ return __spreadValues(__spreadValues({
531
+ weeks,
532
+ compConthsData,
533
+ showTopBtn,
534
+ topInfo,
535
+ bottomInfo,
536
+ rangeTip,
537
+ mothsViewScroll,
538
+ getClass,
539
+ isStartTip,
540
+ isEndTip,
541
+ chooseDay,
542
+ isCurrDay,
543
+ confirm,
544
+ monthsPanel,
545
+ months,
546
+ weeksPanel,
547
+ viewArea
548
+ }, toRefs(state)), toRefs(props));
549
+ }
550
+ });
551
+ const _hoisted_1 = {
552
+ key: 0,
553
+ class: "calendar-title"
554
+ };
555
+ const _hoisted_2 = {
556
+ key: 1,
557
+ class: "calendar-top-slot"
558
+ };
559
+ const _hoisted_3 = {
560
+ key: 2,
561
+ class: "calendar-curr-month"
562
+ };
563
+ const _hoisted_4 = {
564
+ class: "calendar-weeks",
565
+ ref: "weeksPanel"
566
+ };
567
+ const _hoisted_5 = {
568
+ class: "calendar-months-panel",
569
+ ref: "monthsPanel"
570
+ };
571
+ const _hoisted_6 = { class: "calendar-month-title" };
572
+ const _hoisted_7 = { class: "calendar-month-con" };
573
+ const _hoisted_8 = ["onClick"];
574
+ const _hoisted_9 = { class: "calendar-day" };
575
+ const _hoisted_10 = {
576
+ key: 0,
577
+ class: "calendar-curr-tips calendar-curr-tips-top"
578
+ };
579
+ const _hoisted_11 = {
580
+ key: 1,
581
+ class: "calendar-curr-tips calendar-curr-tips-bottom"
582
+ };
583
+ const _hoisted_12 = {
584
+ key: 2,
585
+ class: "calendar-curr-tip-curr"
586
+ };
587
+ const _hoisted_13 = {
588
+ key: 4,
589
+ class: "calendar-day-tip"
590
+ };
591
+ const _hoisted_14 = {
592
+ key: 0,
593
+ class: "nut-calendar-footer"
594
+ };
595
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
596
+ return openBlock(), createElementBlock("view", {
597
+ class: normalizeClass(["nut-calendar nut-calendar-taro", {
598
+ "nut-calendar-tile": !_ctx.poppable,
599
+ "nut-calendar-nofooter": _ctx.isAutoBackFill
600
+ }])
601
+ }, [
602
+ createElementVNode("view", {
603
+ class: normalizeClass(["nut-calendar-header", { "nut-calendar-header-tile": !_ctx.poppable }])
604
+ }, [
605
+ _ctx.showTitle ? (openBlock(), createElementBlock("view", _hoisted_1, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
606
+ _ctx.showTopBtn ? (openBlock(), createElementBlock("view", _hoisted_2, [
607
+ renderSlot(_ctx.$slots, "btn")
608
+ ])) : createCommentVNode("", true),
609
+ _ctx.showSubTitle ? (openBlock(), createElementBlock("view", _hoisted_3, toDisplayString(_ctx.yearMonthTitle), 1)) : createCommentVNode("", true),
610
+ createElementVNode("view", _hoisted_4, [
611
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.weeks, (item, index) => {
612
+ return openBlock(), createElementBlock("view", {
613
+ class: "calendar-week-item",
614
+ key: index
615
+ }, toDisplayString(item), 1);
616
+ }), 128))
617
+ ], 512)
618
+ ], 2),
619
+ createElementVNode("view", {
620
+ class: "nut-calendar-content",
621
+ ref: "months",
622
+ onScroll: _cache[0] || (_cache[0] = (...args) => _ctx.mothsViewScroll && _ctx.mothsViewScroll(...args))
623
+ }, [
624
+ createElementVNode("view", _hoisted_5, [
625
+ createElementVNode("view", {
626
+ class: "viewArea",
627
+ ref: "viewArea",
628
+ style: normalizeStyle({ transform: `translateY(${_ctx.translateY}px)` })
629
+ }, [
630
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.compConthsData, (month, index) => {
631
+ return openBlock(), createElementBlock("view", {
632
+ class: "calendar-month",
633
+ key: index
634
+ }, [
635
+ createElementVNode("view", _hoisted_6, toDisplayString(month.title), 1),
636
+ createElementVNode("view", _hoisted_7, [
637
+ createElementVNode("view", {
638
+ class: normalizeClass(["calendar-month-item", _ctx.type === "range" ? "month-item-range" : ""])
639
+ }, [
640
+ (openBlock(true), createElementBlock(Fragment, null, renderList(month.monthData, (day, i) => {
641
+ return openBlock(), createElementBlock("view", {
642
+ key: i,
643
+ class: normalizeClass(["calendar-month-day", _ctx.getClass(day, month)]),
644
+ onClick: ($event) => _ctx.chooseDay(day, month)
645
+ }, [
646
+ createElementVNode("view", _hoisted_9, [
647
+ renderSlot(_ctx.$slots, "day", {
648
+ date: day.type == "curr" ? day : ""
649
+ }, () => [
650
+ createTextVNode(toDisplayString(day.type == "curr" ? day.day : ""), 1)
651
+ ])
652
+ ]),
653
+ _ctx.topInfo ? (openBlock(), createElementBlock("view", _hoisted_10, [
654
+ renderSlot(_ctx.$slots, "topInfo", {
655
+ date: day.type == "curr" ? day : ""
656
+ })
657
+ ])) : createCommentVNode("", true),
658
+ _ctx.bottomInfo ? (openBlock(), createElementBlock("view", _hoisted_11, [
659
+ renderSlot(_ctx.$slots, "bottomInfo", {
660
+ date: day.type == "curr" ? day : ""
661
+ })
662
+ ])) : createCommentVNode("", true),
663
+ !_ctx.bottomInfo && _ctx.showToday && _ctx.isCurrDay(day) ? (openBlock(), createElementBlock("view", _hoisted_12, " \u4ECA\u5929 ")) : createCommentVNode("", true),
664
+ _ctx.isStartTip(day, month) ? (openBlock(), createElementBlock("view", {
665
+ key: 3,
666
+ class: normalizeClass(["calendar-day-tip", { "calendar-curr-tips-top": _ctx.rangeTip(day, month) }])
667
+ }, toDisplayString(_ctx.startText), 3)) : createCommentVNode("", true),
668
+ _ctx.isEndTip(day, month) ? (openBlock(), createElementBlock("view", _hoisted_13, toDisplayString(_ctx.endText), 1)) : createCommentVNode("", true)
669
+ ], 10, _hoisted_8);
670
+ }), 128))
671
+ ], 2)
672
+ ])
673
+ ]);
674
+ }), 128))
675
+ ], 4)
676
+ ], 512)
677
+ ], 544),
678
+ _ctx.poppable && !_ctx.isAutoBackFill ? (openBlock(), createElementBlock("view", _hoisted_14, [
679
+ createElementVNode("view", {
680
+ class: "calendar-confirm-btn",
681
+ onClick: _cache[1] || (_cache[1] = (...args) => _ctx.confirm && _ctx.confirm(...args))
682
+ }, toDisplayString(_ctx.confirmText), 1)
683
+ ])) : createCommentVNode("", true)
684
+ ], 2);
685
+ }
686
+ var CalendarItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
687
+ export { CalendarItem as C, Utils as U };
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.16 Fri Feb 25 2022 18:32:15 GMT+0800 (中国标准时间)
3
- * (c) 2021 @jdf2e.
2
+ * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
3
+ * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  var _export_sfc = (sfc, props) => {
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.16 Fri Feb 25 2022 18:32:15 GMT+0800 (中国标准时间)
3
- * (c) 2021 @jdf2e.
2
+ * @nutui/nutui v3.1.19-beta.0 Mon Mar 28 2022 17:50:21 GMT+0800 (中国标准时间)
3
+ * (c) 2022 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  const pxCheck = (value) => {