@nutui/nutui-react-taro 2.7.7 → 2.7.9

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 (48) hide show
  1. package/CHANGELOG.md +26 -10
  2. package/dist/esm/Animate/style/style.css +1 -1
  3. package/dist/esm/Animate.js +1 -1
  4. package/dist/esm/AvatarCropper.js +1 -1
  5. package/dist/esm/Calendar/style/style.css +1 -1
  6. package/dist/esm/Calendar.js +1 -1
  7. package/dist/esm/CalendarCard.js +1 -1
  8. package/dist/esm/CalendarItem.js +1 -1
  9. package/dist/esm/Drag.js +1 -1
  10. package/dist/esm/ImagePreview/style/style.css +1 -1
  11. package/dist/esm/Menu.js +1 -1
  12. package/dist/esm/MenuItem.js +1 -1
  13. package/dist/esm/PullToRefresh.js +1 -1
  14. package/dist/esm/Sticky.js +1 -1
  15. package/dist/esm/Swiper/style/style.css +1 -1
  16. package/dist/esm/VirtualList.js +1 -1
  17. package/dist/esm/{animate.taro-CQVEyDKL.js → animate.taro-BHDZMzJF.js} +9 -12
  18. package/dist/esm/{avatarcropper.taro-meD2sizv.js → avatarcropper.taro-5JSFH7Q9.js} +2 -1
  19. package/dist/esm/{calendar.taro-CM4yWFlF.js → calendar.taro-CUDVpJBa.js} +3 -3
  20. package/dist/esm/{calendarcard.taro-CvWyBqnr.js → calendarcard.taro-BiOnui_b.js} +4 -4
  21. package/dist/esm/{calendaritem.taro-BGbbuJOS.js → calendaritem.taro-DveeC4_t.js} +237 -219
  22. package/dist/esm/date-BmUWlDuN.js +147 -0
  23. package/dist/esm/{drag.taro-r5Lmncrq.js → drag.taro-CHPSfySz.js} +2 -2
  24. package/dist/esm/get-system-info-D27xNglo.js +11 -0
  25. package/dist/esm/{menu.taro-2APk--BX.js → menu.taro-9N8A5UoN.js} +1 -1
  26. package/dist/esm/{menuitem.taro-BMlSqBSc.js → menuitem.taro-CnsORm5-.js} +5 -4
  27. package/dist/esm/nutui-react.es.js +11 -11
  28. package/dist/esm/{pulltorefresh.taro-BiSDwLpA.js → pulltorefresh.taro-DAFv7upo.js} +2 -1
  29. package/dist/esm/{sticky.taro-DtUAawu_.js → sticky.taro-l66r7WFn.js} +3 -2
  30. package/dist/esm/{virtuallist.taro-BlPW8ibd.js → virtuallist.taro-CQDtOwWn.js} +2 -2
  31. package/dist/locales/base.js +1 -1
  32. package/dist/locales/en-US.js +1 -1
  33. package/dist/locales/id-ID.js +1 -1
  34. package/dist/locales/tr-TR.js +1 -1
  35. package/dist/locales/zh-CN.js +1 -1
  36. package/dist/locales/zh-TW.js +1 -1
  37. package/dist/locales/zh-UG.js +1 -1
  38. package/dist/nutui.react.es.js +384 -465
  39. package/dist/nutui.react.umd.js +383 -464
  40. package/dist/packages/animate/animate.scss +63 -105
  41. package/dist/packages/calendar/calendar.scss +9 -9
  42. package/dist/packages/swiper/swiper.scss +11 -0
  43. package/dist/style.css +1 -1
  44. package/dist/types/packages/animate/animate.taro.d.ts +2 -1
  45. package/dist/types/utils/date.d.ts +54 -52
  46. package/dist/types/utils/get-system-info.d.ts +19 -0
  47. package/package.json +1 -1
  48. package/dist/esm/date-CYwRNlGq.js +0 -219
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.7.7 Fri Jan 24 2025 13:57:13 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.7.9 Fri Feb 21 2025 17:12:27 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
6
6
  import * as React from "react";
7
7
  import React__default, { useCallback, createContext, useContext, useState, useRef, useEffect, useMemo as useMemo$1, useImperativeHandle, isValidElement, forwardRef, Component, Children } from "react";
8
- import Taro, { getEnv, createSelectorQuery, usePageScroll, getSystemInfoSync, pageScrollTo, nextTick, ENV_TYPE, useReady, canvasToTempFilePath, uploadFile, chooseMedia, chooseImage, Events, getCurrentInstance, createInnerAudioContext, getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
8
+ import Taro, { getEnv, createSelectorQuery, usePageScroll, pageScrollTo, nextTick, ENV_TYPE, useReady, canvasToTempFilePath, uploadFile, chooseMedia, chooseImage, Events, getCurrentInstance, createInnerAudioContext, getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
9
9
  import { Image as Image$2, View, ScrollView, PickerView, PickerViewColumn, Form as Form$1, Text, Input as Input$1, Textarea, Swiper as Swiper$1, SwiperItem as SwiperItem$1, Video as Video$1, Canvas } from "@tarojs/components";
10
10
  import ReactDOM, { createPortal } from "react-dom";
11
11
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -1349,7 +1349,7 @@ lodash_isequal.exports;
1349
1349
  return value != null && isLength(value.length) && !isFunction2(value);
1350
1350
  }
1351
1351
  var isBuffer = nativeIsBuffer || stubFalse;
1352
- function isEqual(value, other) {
1352
+ function isEqual2(value, other) {
1353
1353
  return baseIsEqual(value, other);
1354
1354
  }
1355
1355
  function isFunction2(value) {
@@ -1379,7 +1379,7 @@ lodash_isequal.exports;
1379
1379
  function stubFalse() {
1380
1380
  return false;
1381
1381
  }
1382
- module.exports = isEqual;
1382
+ module.exports = isEqual2;
1383
1383
  })(lodash_isequal, lodash_isequal.exports);
1384
1384
  var lodash_isequalExports = lodash_isequal.exports;
1385
1385
  const isequal = /* @__PURE__ */ getDefaultExportFromCjs(lodash_isequalExports);
@@ -3922,6 +3922,12 @@ const Space = (props) => {
3922
3922
  }));
3923
3923
  };
3924
3924
  Space.displayName = "NutSpace";
3925
+ const getDeviceInfo = () => {
3926
+ return Taro.canIUse("getDeviceInfo") ? Taro.getDeviceInfo() : Taro.getSystemInfoSync();
3927
+ };
3928
+ const getWindowInfo = () => {
3929
+ return Taro.canIUse("getWindowInfo") ? Taro.getWindowInfo() : Taro.getSystemInfoSync();
3930
+ };
3925
3931
  function useWatch$1(dep, callback, config2 = { immediate: false }) {
3926
3932
  const { immediate } = config2;
3927
3933
  const prev = useRef();
@@ -4119,7 +4125,7 @@ const Sticky = (props) => {
4119
4125
  setFixed(threshold > curRootRect.top);
4120
4126
  }
4121
4127
  } else {
4122
- const windowHeight = getSystemInfoSync().windowHeight;
4128
+ const windowHeight = getWindowInfo().windowHeight;
4123
4129
  setFixed(windowHeight - threshold < curRootRect.bottom);
4124
4130
  }
4125
4131
  };
@@ -6212,189 +6218,106 @@ const InternalAddress = (props, ref) => {
6212
6218
  };
6213
6219
  const Address = forwardRef(InternalAddress);
6214
6220
  Address.displayName = "NutAddress";
6215
- const Utils = {
6216
- /**
6217
- * 是否为闫年
6218
- * @return {Boolse} true|false
6219
- */
6220
- isLeapYear(y2) {
6221
- return y2 % 4 === 0 && y2 % 100 !== 0 || y2 % 400 === 0;
6222
- },
6223
- /**
6224
- * 返回星期数
6225
- * @return {String}
6226
- */
6227
- getWhatDay(year, month, day) {
6228
- const date4 = /* @__PURE__ */ new Date(`${year}/${month}/${day}`);
6229
- const index = date4.getDay();
6230
- const dayNames = [
6231
- "星期日",
6232
- "星期一",
6233
- "星期二",
6234
- "星期三",
6235
- "星期四",
6236
- "星期五",
6237
- "星期六"
6238
- ];
6239
- return dayNames[index];
6240
- },
6241
- /**
6242
- * 返回上一个月在当前面板中的天数
6243
- * @return {Number}
6244
- */
6245
- getMonthPreDay(year, month) {
6246
- const date4 = /* @__PURE__ */ new Date(`${year}/${month}/01`);
6247
- let day = date4.getDay();
6248
- if (day === 0) {
6249
- day = 7;
6250
- }
6251
- return day;
6252
- },
6253
- /**
6254
- * 返回月份天数
6255
- * @return {Number}
6256
- */
6257
- getMonthDays(year, month) {
6258
- if (/^0/.test(month)) {
6259
- month = month.split("")[1];
6260
- }
6261
- return [
6262
- 0,
6263
- 31,
6264
- this.isLeapYear(Number(year)) ? 29 : 28,
6265
- 31,
6266
- 30,
6267
- 31,
6268
- 30,
6269
- 31,
6270
- 31,
6271
- 30,
6272
- 31,
6273
- 30,
6274
- 31
6275
- ][month];
6276
- },
6277
- /**
6278
- * 补齐数字位数
6279
- * @return {string}
6280
- */
6281
- getNumTwoBit(n2) {
6282
- n2 = Number(n2);
6283
- return (n2 > 9 ? "" : "0") + n2;
6284
- },
6285
- /**
6286
- * 日期对象转成字符串
6287
- * @return {string}
6288
- */
6289
- date2Str(date4, split) {
6290
- split = split || "-";
6291
- const y2 = date4.getFullYear();
6292
- const m2 = this.getNumTwoBit(date4.getMonth() + 1);
6293
- const d = this.getNumTwoBit(date4.getDate());
6294
- return [y2, m2, d].join(split);
6295
- },
6296
- /**
6297
- * 返回日期格式字符串
6298
- * @param {Number} 0返回今天的日期、1返回明天的日期,2返回后天得日期,依次类推
6299
- * @return {string} '2014-12-31'
6300
- */
6301
- getDay(i2) {
6302
- i2 = i2 || 0;
6303
- let date4 = /* @__PURE__ */ new Date();
6304
- const diff = i2 * (1e3 * 60 * 60 * 24);
6305
- date4 = new Date(date4.getTime() + diff);
6306
- return this.date2Str(date4);
6307
- },
6308
- /**
6309
- * 时间比较
6310
- * @return {Boolean}
6311
- */
6312
- compareDate(date1, date22) {
6313
- const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
6314
- const endTime = new Date(date22.replace("-", "/").replace("-", "/"));
6315
- if (startTime >= endTime) {
6316
- return false;
6317
- }
6318
- return true;
6319
- },
6320
- /**
6321
- * 时间是否相等
6322
- * @return {Boolean}
6323
- */
6324
- isEqual(date1, date22) {
6325
- const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
6326
- const endTime = new Date(date22.replace(/-/g, "/")).getTime();
6327
- if (startTime === endTime) {
6328
- return true;
6329
- }
6330
- return false;
6331
- },
6332
- getMonthWeek(year, month, date4, firstDayOfWeek = 0) {
6333
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6334
- let w = dateNow.getDay();
6335
- const d = dateNow.getDate();
6336
- let remainder = 6 - w;
6337
- if (firstDayOfWeek !== 0) {
6338
- w = w === 0 ? 7 : w;
6339
- remainder = 7 - w;
6340
- }
6341
- return Math.ceil((d + remainder) / 7);
6342
- },
6343
- getYearWeek(year, month, date4, firstDayOfWeek = 0) {
6344
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6345
- const dateFirst = new Date(Number(year), 0, 1);
6346
- const dataNumber = Math.round(
6347
- (dateNow.valueOf() - dateFirst.valueOf()) / 864e5
6348
- );
6349
- return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7);
6350
- },
6351
- getWeekDate(year, month, date4, firstDayOfWeek = 0) {
6352
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6353
- const nowTime = dateNow.getTime();
6354
- let day = dateNow.getDay();
6355
- if (firstDayOfWeek === 0) {
6356
- const oneDayTime2 = 24 * 60 * 60 * 1e3;
6357
- const SundayTime2 = nowTime - day * oneDayTime2;
6358
- const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
6359
- const sunday2 = this.date2Str(new Date(SundayTime2));
6360
- const saturday = this.date2Str(new Date(SaturdayTime));
6361
- return [sunday2, saturday];
6362
- }
6363
- day = day === 0 ? 7 : day;
6364
- const oneDayTime = 24 * 60 * 60 * 1e3;
6365
- const MondayTime = nowTime - (day - 1) * oneDayTime;
6366
- const SundayTime = nowTime + (7 - day) * oneDayTime;
6367
- const monday = this.date2Str(new Date(MondayTime));
6368
- const sunday = this.date2Str(new Date(SundayTime));
6369
- return [monday, sunday];
6370
- },
6371
- formatResultDate(date4) {
6372
- const days = [...date4.split("-")];
6373
- days[2] = Utils.getNumTwoBit(Number(days[2]));
6374
- days[3] = `${days[0]}-${days[1]}-${days[2]}`;
6375
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
6376
- return days;
6221
+ const isLeapYear = (y2) => {
6222
+ return y2 % 4 === 0 && y2 % 100 !== 0 || y2 % 400 === 0;
6223
+ };
6224
+ const getWhatDay = (year, month, day) => {
6225
+ const date4 = new Date(year, month - 1, day);
6226
+ const dayNames = [
6227
+ "星期日",
6228
+ "星期一",
6229
+ "星期二",
6230
+ "星期三",
6231
+ "星期四",
6232
+ "星期五",
6233
+ "星期六"
6234
+ ];
6235
+ return dayNames[date4.getDay()];
6236
+ };
6237
+ const getMonthPreDay = (year, month) => {
6238
+ const day = new Date(year, month - 1, 1).getDay();
6239
+ return day === 0 ? 7 : day;
6240
+ };
6241
+ const getMonthDays = (year, month) => {
6242
+ if (/^0/.test(month)) {
6243
+ month = month.split("")[1];
6244
+ }
6245
+ return [
6246
+ 0,
6247
+ 31,
6248
+ isLeapYear(Number(year)) ? 29 : 28,
6249
+ 31,
6250
+ 30,
6251
+ 31,
6252
+ 30,
6253
+ 31,
6254
+ 31,
6255
+ 30,
6256
+ 31,
6257
+ 30,
6258
+ 31
6259
+ ][month];
6260
+ };
6261
+ const getNumTwoBit = (n2) => {
6262
+ return n2 > 9 ? `${n2}` : `0${n2}`;
6263
+ };
6264
+ const date2Str = (date4, split = "-") => {
6265
+ const y2 = date4.getFullYear();
6266
+ const m2 = getNumTwoBit(date4.getMonth() + 1);
6267
+ const d = getNumTwoBit(date4.getDate());
6268
+ return [y2, m2, d].join(split);
6269
+ };
6270
+ const getDateString = (offset = 0) => {
6271
+ const date4 = /* @__PURE__ */ new Date();
6272
+ date4.setDate(date4.getDate() + offset);
6273
+ return date2Str(date4, "-");
6274
+ };
6275
+ const compareDate = (date1, date22) => {
6276
+ const startTime = new Date(date1.replace("-", "/").replace("-", "/"));
6277
+ const endTime = new Date(date22.replace("-", "/").replace("-", "/"));
6278
+ return startTime < endTime;
6279
+ };
6280
+ const isEqual = (date1, date22) => {
6281
+ const startTime = new Date((date1 || "").replace(/-/g, "/")).getTime();
6282
+ const endTime = new Date(date22.replace(/-/g, "/")).getTime();
6283
+ return startTime === endTime;
6284
+ };
6285
+ const getWeekDate = (year, month, date4, firstDayOfWeek = 0) => {
6286
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
6287
+ const nowTime = dateNow.getTime();
6288
+ let day = dateNow.getDay();
6289
+ if (firstDayOfWeek === 0) {
6290
+ const oneDayTime2 = 24 * 60 * 60 * 1e3;
6291
+ const SundayTime2 = nowTime - day * oneDayTime2;
6292
+ const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
6293
+ const sunday2 = date2Str(new Date(SundayTime2));
6294
+ const saturday = date2Str(new Date(SaturdayTime));
6295
+ return [sunday2, saturday];
6377
6296
  }
6297
+ day = day === 0 ? 7 : day;
6298
+ const oneDayTime = 24 * 60 * 60 * 1e3;
6299
+ const MondayTime = nowTime - (day - 1) * oneDayTime;
6300
+ const SundayTime = nowTime + (7 - day) * oneDayTime;
6301
+ const monday = date2Str(new Date(MondayTime));
6302
+ const sunday = date2Str(new Date(SundayTime));
6303
+ return [monday, sunday];
6304
+ };
6305
+ const formatResultDate = (date4) => {
6306
+ const [year, month, day] = [...date4.split("-")];
6307
+ const formatterDay = getNumTwoBit(Number(day));
6308
+ const formatterDate = `${year}-${month}-${day}`;
6309
+ const dayOfWeek = getWhatDay(Number(year), Number(month), Number(day));
6310
+ return [year, month, formatterDay, formatterDate, dayOfWeek];
6378
6311
  };
6379
6312
  const getCurrMonthData = (type4, year, month) => {
6380
- switch (type4) {
6381
- case "prev":
6382
- month === 1 && (year -= 1);
6383
- month = month === 1 ? 12 : --month;
6384
- break;
6385
- case "next":
6386
- month === 12 && (year += 1);
6387
- month = month === 12 ? 1 : ++month;
6388
- break;
6313
+ {
6314
+ month === 12 && (year += 1);
6315
+ month = month === 12 ? 1 : ++month;
6389
6316
  }
6390
- return [
6391
- year,
6392
- Utils.getNumTwoBit(month),
6393
- Utils.getMonthDays(String(year), String(month))
6394
- ];
6317
+ return [year, getNumTwoBit(month), getMonthDays(String(year), String(month))];
6395
6318
  };
6396
6319
  const getDaysStatus = (type4, year, month) => {
6397
- let days = Utils.getMonthDays(`${year}`, `${month}`);
6320
+ let days = getMonthDays(`${year}`, `${month}`);
6398
6321
  return Array.from(Array(days), (v, k) => {
6399
6322
  return {
6400
6323
  day: k + 1,
@@ -6411,12 +6334,12 @@ const getPreMonthDates = (type4, year, month, firstDayOfWeek) => {
6411
6334
  preMonth = 12;
6412
6335
  preYear += 1;
6413
6336
  }
6414
- let days = Utils.getMonthPreDay(+year, +month);
6337
+ let days = getMonthPreDay(+year, +month);
6415
6338
  days -= firstDayOfWeek;
6416
6339
  if (days >= 7) {
6417
6340
  days -= 7;
6418
6341
  }
6419
- const preDates = Utils.getMonthDays(`${preYear}`, `${preMonth}`);
6342
+ const preDates = getMonthDays(`${preYear}`, `${preMonth}`);
6420
6343
  const months = Array.from(Array(preDates), (v, k) => {
6421
6344
  return {
6422
6345
  day: k + 1,
@@ -6434,28 +6357,26 @@ const splitDate = (date4) => {
6434
6357
  const isMultiple = (day, days) => {
6435
6358
  if (days.length > 0) {
6436
6359
  return days.some((item) => {
6437
- return Utils.isEqual(item, day);
6360
+ return isEqual(item, day);
6438
6361
  });
6439
6362
  }
6440
6363
  return false;
6441
6364
  };
6442
6365
  const isCurrDay = (month, day) => {
6443
6366
  const date4 = `${month.curData[0]}/${month.curData[1]}/${day}`;
6444
- return Utils.isEqual(date4, Utils.date2Str(/* @__PURE__ */ new Date(), "/"));
6367
+ return isEqual(date4, date2Str(/* @__PURE__ */ new Date(), "/"));
6445
6368
  };
6446
6369
  const getCurrDate = (day, month) => {
6447
- return `${month.curData[0]}/${month.curData[1]}/${Utils.getNumTwoBit(
6448
- +day.day
6449
- )}`;
6370
+ return `${month.curData[0]}/${month.curData[1]}/${getNumTwoBit(+day.day)}`;
6450
6371
  };
6451
6372
  const isStart = (day, days) => {
6452
- return Utils.isEqual(days[0], day);
6373
+ return isEqual(days[0], day);
6453
6374
  };
6454
6375
  const isEnd = (day, days) => {
6455
- return Utils.isEqual(days[1], day);
6376
+ return isEqual(days[1], day);
6456
6377
  };
6457
6378
  const isStartAndEnd = (days) => {
6458
- return days.length >= 2 && Utils.isEqual(days[0], days[1]);
6379
+ return days.length >= 2 && isEqual(days[0], days[1]);
6459
6380
  };
6460
6381
  const defaultProps$13 = {
6461
6382
  ...ComponentDefaults,
@@ -6463,8 +6384,8 @@ const defaultProps$13 = {
6463
6384
  autoBackfill: false,
6464
6385
  popup: true,
6465
6386
  title: "",
6466
- startDate: Utils.getDay(0),
6467
- endDate: Utils.getDay(365),
6387
+ startDate: getDateString(0),
6388
+ endDate: getDateString(365),
6468
6389
  showToday: true,
6469
6390
  startText: "",
6470
6391
  endText: "",
@@ -6497,6 +6418,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6497
6418
  type: type4,
6498
6419
  autoBackfill,
6499
6420
  title,
6421
+ value,
6500
6422
  defaultValue,
6501
6423
  startDate,
6502
6424
  endDate,
@@ -6514,12 +6436,13 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6514
6436
  renderDayTop,
6515
6437
  renderDayBottom,
6516
6438
  renderBottomButton,
6517
- value,
6518
6439
  onConfirm,
6519
6440
  onUpdate,
6520
6441
  onDayClick,
6521
6442
  onPageChange
6522
6443
  } = { ...defaultProps$13, ...props };
6444
+ const classPrefix2 = "nut-calendar";
6445
+ const dayPrefix = "nut-calendar-day";
6523
6446
  const weekdays = locale.calendaritem.weekdays;
6524
6447
  const weeks = [
6525
6448
  ...weekdays.slice(firstDayOfWeek, 7),
@@ -6533,19 +6456,13 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6533
6456
  const [monthDefaultRange, setMonthDefaultRange] = useState([]);
6534
6457
  const [scrollTop, setScrollTop] = useState(0);
6535
6458
  const [scrollWithAnimation, setScrollWithAnimation] = useState(false);
6536
- const propStartDate = startDate || Utils.getDay(0);
6537
- const propEndDate = endDate || Utils.getDay(365);
6459
+ const propStartDate = startDate || getDateString(0);
6460
+ const propEndDate = endDate || getDateString(365);
6538
6461
  const startDates = splitDate(propStartDate);
6539
6462
  const endDates = splitDate(propEndDate);
6540
6463
  const [state] = useState({
6541
6464
  currDateArray: []
6542
6465
  });
6543
- const getMonthsPanel = () => {
6544
- return monthsPanel.current;
6545
- };
6546
- const getMonthsRef = () => {
6547
- return monthsRef.current;
6548
- };
6549
6466
  const resetDefaultValue = () => {
6550
6467
  if (defaultValue || Array.isArray(defaultValue) && defaultValue.length > 0) {
6551
6468
  return type4 !== "single" ? [...defaultValue] : defaultValue;
@@ -6565,9 +6482,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6565
6482
  const viewAreaRef = useRef(null);
6566
6483
  const [avgHeight, setAvgHeight] = useState(0);
6567
6484
  let viewHeight = 0;
6568
- const classPrefix2 = "nut-calendar";
6569
- const dayPrefix = "nut-calendar-day";
6570
- const getMonthData = (curData, monthNum, type22) => {
6485
+ const getMonthData = (curData, monthNum) => {
6571
6486
  let i2 = 0;
6572
6487
  let date4 = curData;
6573
6488
  const monthData = monthsData;
@@ -6578,12 +6493,12 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6578
6493
  ...getPreMonthDates("prev", y2, m2, firstDayOfWeek),
6579
6494
  ...getDaysStatus("active", y2, m2)
6580
6495
  ];
6581
- const cssHeight = 39 + (days.length > 35 ? 384 : 320);
6582
6496
  let scrollTop2 = 0;
6583
6497
  if (monthData.length > 0) {
6584
6498
  const monthEle = monthData[monthData.length - 1];
6585
6499
  scrollTop2 = monthEle.scrollTop + monthEle.cssHeight;
6586
6500
  }
6501
+ const cssHeight = 39 + (days.length > 35 ? 384 : 320);
6587
6502
  const monthInfo = {
6588
6503
  curData: date4,
6589
6504
  title: monthTitle(y2, m2),
@@ -6591,16 +6506,14 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6591
6506
  cssHeight,
6592
6507
  scrollTop: scrollTop2
6593
6508
  };
6594
- {
6595
- if (!endDates || !Utils.compareDate(
6596
- `${endDates[0]}/${endDates[1]}/${Utils.getMonthDays(
6597
- endDates[0],
6598
- endDates[1]
6599
- )}`,
6600
- `${curData[0]}/${curData[1]}/${curData[2]}`
6601
- )) {
6602
- monthData.push(monthInfo);
6603
- }
6509
+ if (!endDates || !compareDate(
6510
+ `${endDates[0]}/${endDates[1]}/${getMonthDays(
6511
+ endDates[0],
6512
+ endDates[1]
6513
+ )}`,
6514
+ `${curData[0]}/${curData[1]}/${curData[2]}`
6515
+ )) {
6516
+ monthData.push(monthInfo);
6604
6517
  }
6605
6518
  date4 = getCurrMonthData("next", y2, m2);
6606
6519
  } while (i2++ < monthNum);
@@ -6608,8 +6521,8 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6608
6521
  };
6609
6522
  const setReachedYearMonthInfo = (current) => {
6610
6523
  const currentMonthsData = monthsData[current];
6611
- const [year, month] = currentMonthsData.curData;
6612
6524
  if (currentMonthsData.title === yearMonthTitle) return;
6525
+ const [year, month] = currentMonthsData.curData;
6613
6526
  onPageChange && onPageChange([year, month, `${year}-${month}`]);
6614
6527
  setYearMonthTitle(currentMonthsData.title);
6615
6528
  };
@@ -6635,75 +6548,67 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6635
6548
  setTranslateY(monthsData[start].scrollTop);
6636
6549
  setReachedYearMonthInfo(current);
6637
6550
  };
6638
- const getMonthNum = () => {
6639
- let monthNum = Number(endDates[1]) - Number(startDates[1]);
6640
- const yearNum = Number(endDates[0]) - Number(startDates[0]);
6641
- if (yearNum > 0) {
6642
- monthNum += 12 * yearNum;
6643
- }
6644
- if (monthNum <= 0) {
6645
- monthNum = 1;
6646
- }
6647
- setMonthsNum(monthNum);
6648
- return monthNum;
6649
- };
6650
6551
  const setDefaultDate = () => {
6651
6552
  let defaultData = [];
6652
- if (type4 === "range" && Array.isArray(currentDate)) {
6653
- if (currentDate.length > 0) {
6654
- if (propStartDate && Utils.compareDate(currentDate[0], propStartDate)) {
6655
- currentDate.splice(0, 1, propStartDate);
6656
- }
6657
- if (propEndDate && Utils.compareDate(propEndDate, currentDate[1])) {
6658
- currentDate.splice(1, 1, propEndDate);
6659
- }
6660
- defaultData = [
6661
- ...splitDate(currentDate[0]),
6662
- ...splitDate(currentDate[1])
6663
- ];
6553
+ if (type4 === "single" && typeof currentDate === "string") {
6554
+ if (!currentDate.length) {
6555
+ return defaultData;
6556
+ }
6557
+ if (compareDate(currentDate, propStartDate)) {
6558
+ defaultData = [...splitDate(propStartDate)];
6559
+ } else if (!compareDate(currentDate, propEndDate)) {
6560
+ defaultData = [...splitDate(propEndDate)];
6561
+ } else {
6562
+ defaultData = [...splitDate(currentDate)];
6664
6563
  }
6665
- } else if (type4 === "multiple" && Array.isArray(currentDate)) {
6666
- if (currentDate.length > 0) {
6667
- const defaultArr = [];
6668
- const obj = {};
6669
- currentDate.forEach((item) => {
6670
- if (propStartDate && !Utils.compareDate(item, propStartDate) && propEndDate && !Utils.compareDate(propEndDate, item)) {
6671
- if (!Object.hasOwnProperty.call(obj, item)) {
6672
- defaultArr.push(item);
6673
- obj[item] = item;
6674
- }
6564
+ return defaultData;
6565
+ }
6566
+ if (Array.isArray(currentDate) && currentDate.length) {
6567
+ switch (type4) {
6568
+ case "range": {
6569
+ if (compareDate(currentDate[0], propStartDate)) {
6570
+ currentDate[0] = propStartDate;
6675
6571
  }
6676
- });
6677
- currentDate.splice(0) && currentDate.push(...defaultArr);
6678
- defaultData = [...splitDate(defaultArr[0])];
6679
- }
6680
- } else if (type4 === "week" && Array.isArray(currentDate)) {
6681
- if (currentDate.length > 0) {
6682
- const [y2, m2, d] = splitDate(currentDate[0]);
6683
- const weekArr = Utils.getWeekDate(y2, m2, d, firstDayOfWeek);
6684
- currentDate.splice(0) && currentDate.push(...weekArr);
6685
- if (propStartDate && Utils.compareDate(currentDate[0], propStartDate)) {
6686
- currentDate.splice(0, 1, propStartDate);
6572
+ if (compareDate(propEndDate, currentDate[1])) {
6573
+ currentDate[1] = propEndDate;
6574
+ }
6575
+ defaultData = [
6576
+ ...splitDate(currentDate[0]),
6577
+ ...splitDate(currentDate[1])
6578
+ ];
6579
+ break;
6687
6580
  }
6688
- if (propEndDate && Utils.compareDate(propEndDate, currentDate[1])) {
6689
- currentDate.splice(1, 1, propEndDate);
6581
+ case "multiple": {
6582
+ const defaultArr = [];
6583
+ const obj = {};
6584
+ currentDate.forEach((item) => {
6585
+ if (!compareDate(item, propStartDate) && !compareDate(propEndDate, item)) {
6586
+ if (!Object.hasOwnProperty.call(obj, item)) {
6587
+ defaultArr.push(item);
6588
+ obj[item] = item;
6589
+ }
6590
+ }
6591
+ });
6592
+ currentDate.splice(0, currentDate.length, ...defaultArr);
6593
+ defaultData = [...splitDate(defaultArr[0])];
6594
+ break;
6690
6595
  }
6691
- defaultData = [
6692
- ...splitDate(currentDate[0]),
6693
- ...splitDate(currentDate[1])
6694
- ];
6695
- }
6696
- } else if (currentDate) {
6697
- if (currentDate.length > 0) {
6698
- if (propStartDate && Utils.compareDate(currentDate, propStartDate)) {
6699
- defaultData = [...splitDate(propStartDate)];
6700
- } else if (propEndDate && !Utils.compareDate(currentDate, propEndDate)) {
6701
- defaultData = [...splitDate(propEndDate)];
6702
- } else {
6703
- defaultData = [...splitDate(currentDate)];
6596
+ case "week": {
6597
+ const [y2, m2, d] = splitDate(currentDate[0]);
6598
+ const weekArr = getWeekDate(y2, m2, d, firstDayOfWeek);
6599
+ currentDate.splice(0, currentDate.length, ...weekArr);
6600
+ if (compareDate(currentDate[0], propStartDate)) {
6601
+ currentDate.splice(0, 1, propStartDate);
6602
+ }
6603
+ if (compareDate(propEndDate, currentDate[1])) {
6604
+ currentDate.splice(1, 1, propEndDate);
6605
+ }
6606
+ defaultData = [
6607
+ ...splitDate(currentDate[0]),
6608
+ ...splitDate(currentDate[1])
6609
+ ];
6610
+ break;
6704
6611
  }
6705
- } else {
6706
- defaultData = [];
6707
6612
  }
6708
6613
  }
6709
6614
  return defaultData;
@@ -6726,63 +6631,57 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6726
6631
  const date4 = /* @__PURE__ */ new Date();
6727
6632
  const year = date4.getFullYear();
6728
6633
  const month = date4.getMonth() + 1;
6729
- const index = monthsData.findIndex((item) => {
6730
- return +item.curData[0] === year && +item.curData[1] === month;
6731
- });
6732
- if (index > -1) {
6733
- current = index;
6734
- }
6634
+ const index = monthsData.findIndex(
6635
+ (item) => +item.curData[0] === year && +item.curData[1] === month
6636
+ );
6637
+ if (index > -1) current = index;
6735
6638
  }
6736
6639
  return {
6737
6640
  current,
6738
6641
  lastCurrent
6739
6642
  };
6740
6643
  };
6741
- const renderCurrentDate = () => {
6742
- const defaultData = setDefaultDate();
6743
- const current = getCurrentIndex(defaultData);
6744
- if (defaultData.length > 0) {
6745
- if (type4 === "range") {
6746
- chooseDay(
6747
- { day: defaultData[2], type: "active" },
6748
- monthsData[current.current],
6749
- true
6750
- );
6751
- chooseDay(
6644
+ const renderCurrentDate = (defaultData, current) => {
6645
+ if (!defaultData.length) return;
6646
+ const date4 = monthsData[current.current];
6647
+ switch (type4) {
6648
+ case "range": {
6649
+ handleDayClick({ day: defaultData[2], type: "active" }, date4);
6650
+ handleDayClick(
6752
6651
  { day: defaultData[5], type: "active" },
6753
- monthsData[current.lastCurrent],
6754
- true
6652
+ monthsData[current.lastCurrent]
6755
6653
  );
6756
- } else if (type4 === "week") {
6757
- chooseDay(
6758
- { day: defaultData[2], type: "curr" },
6759
- monthsData[current.current],
6760
- true
6761
- );
6762
- } else if (type4 === "multiple") {
6654
+ break;
6655
+ }
6656
+ case "week": {
6657
+ handleDayClick({ day: defaultData[2], type: "curr" }, date4);
6658
+ break;
6659
+ }
6660
+ case "multiple": {
6763
6661
  [...currentDate].forEach((item) => {
6764
6662
  const dateArr = splitDate(item);
6765
6663
  let currentIndex = current.current;
6766
- monthsData.forEach((item2, index) => {
6767
- if (item2.title === monthTitle(dateArr[0], dateArr[1])) {
6768
- currentIndex = index;
6769
- }
6770
- });
6771
- chooseDay(
6664
+ currentIndex = monthsData.findIndex(
6665
+ (item2) => item2.title === monthTitle(dateArr[0], dateArr[1])
6666
+ );
6667
+ handleDayClick(
6772
6668
  { day: dateArr[2], type: "active" },
6773
- monthsData[currentIndex],
6774
- true
6669
+ monthsData[currentIndex]
6775
6670
  );
6776
6671
  });
6777
- } else {
6778
- chooseDay(
6779
- { day: defaultData[2], type: "active" },
6780
- monthsData[current.current],
6781
- true
6782
- );
6672
+ break;
6673
+ }
6674
+ default: {
6675
+ handleDayClick({ day: defaultData[2], type: "active" }, date4);
6676
+ break;
6783
6677
  }
6784
6678
  }
6785
- return current.current;
6679
+ };
6680
+ const getMonthsPanel = () => {
6681
+ return monthsPanel.current;
6682
+ };
6683
+ const getMonthsRef = () => {
6684
+ return monthsRef.current;
6786
6685
  };
6787
6686
  const requestAniFrameFunc = (current, monthNum) => {
6788
6687
  const lastItem = monthsData[monthsData.length - 1];
@@ -6791,19 +6690,31 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6791
6690
  if (monthsRef && monthsPanel && viewAreaRef) {
6792
6691
  viewHeight = getMonthsRef().clientHeight;
6793
6692
  getMonthsPanel().style.height = `${containerHeight}px`;
6794
- getMonthsRef().scrollTop = monthsData[current].scrollTop;
6795
- setScrollTop(monthsData[current].scrollTop);
6693
+ const currTop = monthsData[current].scrollTop;
6694
+ getMonthsRef().scrollTop = currTop;
6695
+ setScrollTop(currTop);
6796
6696
  nextTick(() => setScrollWithAnimation(true));
6797
6697
  }
6798
6698
  });
6799
6699
  setAvgHeight(Math.floor(containerHeight / (monthNum + 1)));
6800
6700
  };
6701
+ const getMonthNum = () => {
6702
+ let monthNum = Number(endDates[1]) - Number(startDates[1]);
6703
+ const yearNum = Number(endDates[0]) - Number(startDates[0]);
6704
+ if (yearNum > 0) monthNum += 12 * yearNum;
6705
+ if (monthNum <= 0) monthNum = 1;
6706
+ setMonthsNum(monthNum);
6707
+ return monthNum;
6708
+ };
6801
6709
  const initData = () => {
6802
6710
  const monthNum = getMonthNum();
6803
6711
  getMonthData(startDates, monthNum);
6804
- const current = renderCurrentDate();
6805
- setDefaultRange(monthNum, current);
6806
- requestAniFrameFunc(current, monthNum);
6712
+ const defaultData = setDefaultDate();
6713
+ const current = getCurrentIndex(defaultData);
6714
+ const currentIndex = current.current;
6715
+ renderCurrentDate(defaultData, current);
6716
+ setDefaultRange(monthNum, currentIndex);
6717
+ requestAniFrameFunc(currentIndex, monthNum);
6807
6718
  };
6808
6719
  useEffect(() => {
6809
6720
  initData();
@@ -6820,9 +6731,9 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6820
6731
  popup && resetRender();
6821
6732
  }, [currentDate]);
6822
6733
  const scrollToDate = (date4) => {
6823
- if (Utils.compareDate(date4, propStartDate)) {
6734
+ if (compareDate(date4, propStartDate)) {
6824
6735
  date4 = propStartDate;
6825
- } else if (!Utils.compareDate(date4, propEndDate)) {
6736
+ } else if (!compareDate(date4, propEndDate)) {
6826
6737
  date4 = propEndDate;
6827
6738
  }
6828
6739
  const dateArr = splitDate(date4);
@@ -6843,22 +6754,20 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6843
6754
  clearInterval(interval);
6844
6755
  if (monthsRef.current) {
6845
6756
  monthsRef.current.scrollTop = currTop;
6846
- setScrollTop(monthsRef.current.scrollTop);
6757
+ setScrollTop(currTop);
6847
6758
  }
6848
6759
  }
6849
6760
  }, 40);
6850
6761
  } else {
6851
6762
  monthsRef.current.scrollTop = currTop;
6852
- setScrollTop(monthsRef.current.scrollTop);
6763
+ setScrollTop(currTop);
6853
6764
  }
6854
6765
  }
6855
6766
  }
6856
6767
  });
6857
6768
  };
6858
6769
  const monthsViewScroll = (e2) => {
6859
- if (monthsData.length <= 1) {
6860
- return;
6861
- }
6770
+ if (monthsData.length <= 1) return;
6862
6771
  const scrollTop2 = e2.target.scrollTop;
6863
6772
  Taro.getEnv() === "WEB" && setScrollTop(scrollTop2);
6864
6773
  let current = Math.floor(scrollTop2 / avgHeight);
@@ -6867,16 +6776,10 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6867
6776
  const nextTop = monthsData[current + 1].scrollTop;
6868
6777
  const nextHeight = monthsData[current + 1].cssHeight;
6869
6778
  if (current === 0) {
6870
- if (scrollTop2 >= nextTop) {
6871
- current += 1;
6872
- }
6779
+ if (scrollTop2 >= nextTop) current += 1;
6873
6780
  } else if (current > 0 && current < monthsNum - 1) {
6874
- if (scrollTop2 >= nextTop) {
6875
- current += 1;
6876
- }
6877
- if (scrollTop2 < monthsData[current].scrollTop) {
6878
- current -= 1;
6879
- }
6781
+ if (scrollTop2 >= nextTop) current += 1;
6782
+ if (scrollTop2 < monthsData[current].scrollTop) current -= 1;
6880
6783
  } else {
6881
6784
  const viewPosition = Math.round(scrollTop2 + viewHeight);
6882
6785
  if (current + 1 <= monthsNum && viewPosition >= nextTop + nextHeight) {
@@ -6891,90 +6794,96 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6891
6794
  React__default.useImperativeHandle(ref, () => ({
6892
6795
  scrollToDate
6893
6796
  }));
6797
+ const isDisable = (day, month) => {
6798
+ if (day.type !== "active") return true;
6799
+ const dateStr = getCurrDate(day, month);
6800
+ if (compareDate(dateStr, propStartDate)) return true;
6801
+ if (compareDate(propEndDate, dateStr)) return true;
6802
+ return false;
6803
+ };
6894
6804
  const getClasses = (day, month) => {
6895
6805
  const dateStr = getCurrDate(day, month);
6896
- if (day.type === "active") {
6897
- if (propStartDate && Utils.compareDate(dateStr, propStartDate) || propEndDate && Utils.compareDate(propEndDate, dateStr)) {
6898
- return `${dayPrefix}-disabled`;
6899
- }
6900
- if (type4 === "range" || type4 === "week") {
6901
- if (isStart(dateStr, currentDate) || isEnd(dateStr, currentDate)) {
6902
- return `${dayPrefix}-active ${isStart(dateStr, currentDate) ? "active-start" : ""} ${isEnd(dateStr, currentDate) ? "active-end" : ""}`;
6903
- }
6904
- if (Array.isArray(currentDate) && Object.values(currentDate).length === 2 && Utils.compareDate(currentDate[0], dateStr) && Utils.compareDate(dateStr, currentDate[1])) {
6905
- if (disableDate(day)) {
6906
- return `${dayPrefix}-choose-disabled`;
6907
- }
6908
- return `${dayPrefix}-choose`;
6909
- }
6910
- } else if (type4 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && Utils.isEqual(currentDate, dateStr)) {
6911
- return `${dayPrefix}-active`;
6806
+ if (isDisable(day, month)) return `${dayPrefix}-disabled`;
6807
+ const activeCls = `${dayPrefix}-active`;
6808
+ if (type4 === "range" || type4 === "week") {
6809
+ if (isStart(dateStr, currentDate))
6810
+ return `${activeCls} active-start`;
6811
+ if (isEnd(dateStr, currentDate)) {
6812
+ return `${activeCls} active-end`;
6912
6813
  }
6913
- if (disableDate(day)) {
6914
- return `${dayPrefix}-disabled`;
6814
+ if (currentDate.length === 2 && compareDate(currentDate[0], dateStr) && compareDate(dateStr, currentDate[1])) {
6815
+ return disableDate(day) ? `${dayPrefix}-choose-disabled` : `${dayPrefix}-choose`;
6915
6816
  }
6916
- return null;
6817
+ } else if (type4 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && isEqual(currentDate, dateStr)) {
6818
+ return activeCls;
6917
6819
  }
6918
- return `${dayPrefix}-disabled`;
6820
+ if (disableDate(day)) return `${dayPrefix}-disabled`;
6821
+ return null;
6919
6822
  };
6920
- const chooseDay = (day, month, isFirst) => {
6921
- if (getClasses(day, month) === `${dayPrefix}-disabled`) {
6922
- return;
6923
- }
6823
+ const handleDayClick = (day, month, isFirst = true) => {
6824
+ if (isDisable(day, month) || disableDate(day)) return;
6924
6825
  const days = [...month.curData];
6925
6826
  const [y2, m2] = month.curData;
6926
- days[2] = typeof day.day === "number" ? Utils.getNumTwoBit(day.day) : day.day;
6827
+ days[2] = typeof day.day === "number" ? getNumTwoBit(day.day) : day.day;
6927
6828
  days[3] = `${days[0]}/${days[1]}/${days[2]}`;
6928
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
6929
- if (type4 === "multiple") {
6930
- if (currentDate.length > 0) {
6931
- let hasIndex = "";
6932
- currentDate.forEach((item, index) => {
6933
- if (item === days[3]) {
6934
- hasIndex = index;
6829
+ days[4] = getWhatDay(+days[0], +days[1], +days[2]);
6830
+ const newDate = days[3];
6831
+ switch (type4) {
6832
+ case "multiple": {
6833
+ if (Array.isArray(currentDate)) {
6834
+ if (currentDate.length > 0) {
6835
+ const hasIndex = currentDate.findIndex((item) => item === newDate);
6836
+ if (isFirst) {
6837
+ state.currDateArray.push([...days]);
6838
+ } else if (hasIndex > -1) {
6839
+ currentDate.splice(hasIndex, 1);
6840
+ state.currDateArray.splice(hasIndex, 1);
6841
+ } else {
6842
+ currentDate.push(newDate);
6843
+ state.currDateArray.push([...days]);
6844
+ }
6845
+ } else {
6846
+ currentDate.push(newDate);
6847
+ state.currDateArray = [[...days]];
6935
6848
  }
6936
- });
6937
- if (isFirst) {
6938
- state.currDateArray.push([...days]);
6939
- } else if (hasIndex !== "") {
6940
- currentDate.splice(hasIndex, 1);
6941
- state.currDateArray.splice(hasIndex, 1);
6942
- } else {
6943
- currentDate.push(days[3]);
6944
- state.currDateArray.push([...days]);
6945
6849
  }
6946
- } else {
6947
- currentDate.push(days[3]);
6948
- state.currDateArray = [[...days]];
6949
- }
6950
- } else if (type4 === "range") {
6951
- const curDataLength = Object.values(currentDate).length;
6952
- if (curDataLength === 2 || curDataLength === 0) {
6953
- Array.isArray(currentDate) && currentDate.splice(0) && currentDate.push(days[3]);
6954
- state.currDateArray = [[...days]];
6955
- } else if (Utils.compareDate(currentDate[0], days[3])) {
6956
- Array.isArray(currentDate) && currentDate.push(days[3]);
6957
- state.currDateArray = [...state.currDateArray, [...days]];
6958
- } else {
6959
- Array.isArray(currentDate) && currentDate.unshift(days[3]);
6960
- state.currDateArray = [[...days], ...state.currDateArray];
6850
+ break;
6851
+ }
6852
+ case "range": {
6853
+ if (Array.isArray(currentDate)) {
6854
+ if (currentDate.length === 2 || currentDate.length === 0) {
6855
+ currentDate.splice(0, currentDate.length, newDate);
6856
+ state.currDateArray = [[...days]];
6857
+ } else if (compareDate(currentDate[0], newDate)) {
6858
+ currentDate.push(newDate);
6859
+ state.currDateArray = [...state.currDateArray, [...days]];
6860
+ } else {
6861
+ currentDate.unshift(newDate);
6862
+ state.currDateArray = [[...days], ...state.currDateArray];
6863
+ }
6864
+ }
6865
+ break;
6961
6866
  }
6962
- } else if (type4 === "week") {
6963
- const weekArr = Utils.getWeekDate(y2, m2, `${day.day}`, firstDayOfWeek);
6964
- if (propStartDate && Utils.compareDate(weekArr[0], propStartDate)) {
6965
- weekArr.splice(0, 1, propStartDate);
6867
+ case "week": {
6868
+ const weekArr = getWeekDate(y2, m2, `${day.day}`, firstDayOfWeek);
6869
+ if (compareDate(weekArr[0], propStartDate)) {
6870
+ weekArr[0] = propStartDate;
6871
+ }
6872
+ if (compareDate(propEndDate, weekArr[1])) {
6873
+ weekArr[1] = propEndDate;
6874
+ }
6875
+ currentDate.splice(0, currentDate.length, ...weekArr);
6876
+ state.currDateArray = [
6877
+ formatResultDate(weekArr[0]),
6878
+ formatResultDate(weekArr[1])
6879
+ ];
6880
+ break;
6966
6881
  }
6967
- if (propEndDate && Utils.compareDate(propEndDate, weekArr[1])) {
6968
- weekArr.splice(1, 1, propEndDate);
6882
+ default: {
6883
+ setCurrentDate(newDate);
6884
+ state.currDateArray = [...days];
6885
+ break;
6969
6886
  }
6970
- Array.isArray(currentDate) && currentDate.splice(0) && currentDate.push(...weekArr);
6971
- state.currDateArray = [
6972
- Utils.formatResultDate(weekArr[0]),
6973
- Utils.formatResultDate(weekArr[1])
6974
- ];
6975
- } else {
6976
- setCurrentDate(days[3]);
6977
- state.currDateArray = [...days];
6978
6887
  }
6979
6888
  if (!isFirst) {
6980
6889
  onDayClick && onDayClick(state.currDateArray);
@@ -6994,11 +6903,11 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6994
6903
  }
6995
6904
  };
6996
6905
  const classes = classNames(
6906
+ classPrefix2,
6997
6907
  {
6998
6908
  [`${classPrefix2}-title`]: !popup,
6999
6909
  [`${classPrefix2}-nofooter`]: !!autoBackfill
7000
6910
  },
7001
- classPrefix2,
7002
6911
  className
7003
6912
  );
7004
6913
  const headerClasses = classNames({
@@ -7014,6 +6923,40 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
7014
6923
  const renderHeader = () => {
7015
6924
  return /* @__PURE__ */ React__default.createElement("div", { className: headerClasses }, showTitle && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-title` }, title || locale.calendaritem.title), renderHeaderButtons && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-header-buttons` }, renderHeaderButtons()), showSubTitle && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-sub-title` }, yearMonthTitle), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-weeks`, ref: weeksPanel }, weeks.map((item) => /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-week-item`, key: item }, item))));
7016
6925
  };
6926
+ const renderItem = (month, day, index) => {
6927
+ const startTip = isStartTip(day, month);
6928
+ const endTip = isEndTip(day, month);
6929
+ const noStartNorEnd = !startTip && !endTip;
6930
+ return /* @__PURE__ */ React__default.createElement(
6931
+ "div",
6932
+ {
6933
+ className: classNames("nut-calendar-day", getClasses(day, month)),
6934
+ onClick: () => handleDayClick(day, month, false),
6935
+ key: index
6936
+ },
6937
+ /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
6938
+ !startTip && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
6939
+ noStartNorEnd && renderDayBottom && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
6940
+ noStartNorEnd && isCurrDay(month, day.day) && !renderDayBottom && showToday && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-curr` }, locale.calendaritem.today),
6941
+ startTip && /* @__PURE__ */ React__default.createElement(
6942
+ "div",
6943
+ {
6944
+ className: classNames("nut-calendar-day-info", {
6945
+ "nut-calendar-day-info-top": isStartAndEnd(
6946
+ currentDate
6947
+ )
6948
+ })
6949
+ },
6950
+ startText || locale.calendaritem.start
6951
+ ),
6952
+ endTip && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
6953
+ );
6954
+ };
6955
+ const renderPanel = (month, key) => {
6956
+ return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month`, key }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month-title` }, month.title), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-days` }, month.monthData.map(
6957
+ (day, i2) => renderItem(month, day, i2)
6958
+ )));
6959
+ };
7017
6960
  const renderContent = () => {
7018
6961
  return /* @__PURE__ */ React__default.createElement(
7019
6962
  ScrollView,
@@ -7034,31 +6977,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
7034
6977
  style: { transform: `translateY(${translateY}px)` }
7035
6978
  },
7036
6979
  monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map((month, key) => {
7037
- return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month`, key }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-month-title` }, month.title), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-days` }, month.monthData.map((day, i2) => /* @__PURE__ */ React__default.createElement(
7038
- "div",
7039
- {
7040
- className: [
7041
- `${classPrefix2}-day`,
7042
- getClasses(day, month)
7043
- ].join(" "),
7044
- onClick: () => {
7045
- chooseDay(day, month);
7046
- },
7047
- key: i2
7048
- },
7049
- /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
7050
- !isStartTip(day, month) && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
7051
- !isStartTip(day, month) && !isEndTip(day, month) && renderDayBottom && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
7052
- !isStartTip(day, month) && !isEndTip(day, month) && !renderDayBottom && showToday && isCurrDay(month, day.day) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-curr` }, locale.calendaritem.today),
7053
- isStartTip(day, month) && /* @__PURE__ */ React__default.createElement(
7054
- "div",
7055
- {
7056
- className: `${classPrefix2}-day-info ${isStartAndEnd(currentDate) ? `${classPrefix2}-day-info-top` : ""}`
7057
- },
7058
- startText || locale.calendaritem.start
7059
- ),
7060
- isEndTip(day, month) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
7061
- ))));
6980
+ return renderPanel(month, key);
7062
6981
  })
7063
6982
  ))
7064
6983
  );
@@ -7077,8 +6996,8 @@ const defaultProps$12 = {
7077
6996
  visible: false,
7078
6997
  title: "",
7079
6998
  defaultValue: "",
7080
- startDate: Utils.getDay(0),
7081
- endDate: Utils.getDay(365),
6999
+ startDate: getDateString(0),
7000
+ endDate: getDateString(365),
7082
7001
  showToday: true,
7083
7002
  startText: "",
7084
7003
  endText: "",
@@ -7246,12 +7165,12 @@ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
7246
7165
  prevMonth = 12;
7247
7166
  prevYear -= 1;
7248
7167
  }
7249
- let days = Utils.getMonthPreDay(year, month);
7168
+ let days = getMonthPreDay(year, month);
7250
7169
  days -= firstDayOfWeek;
7251
7170
  if (days >= 7) {
7252
7171
  days -= 7;
7253
7172
  }
7254
- const preDates = Utils.getMonthDays(`${prevYear}`, `${prevMonth}`);
7173
+ const preDates = getMonthDays(`${prevYear}`, `${prevMonth}`);
7255
7174
  const months = Array.from(Array(preDates), (_, k) => {
7256
7175
  return {
7257
7176
  type: "prev",
@@ -7263,7 +7182,7 @@ const getPrevMonthDays = (year, month, firstDayOfWeek) => {
7263
7182
  return months.slice(preDates - days);
7264
7183
  };
7265
7184
  const getCurrentMonthDays = (year, month) => {
7266
- const days = Utils.getMonthDays(`${year}`, `${month}`);
7185
+ const days = getMonthDays(`${year}`, `${month}`);
7267
7186
  return Array.from(Array(days), (_, k) => {
7268
7187
  return {
7269
7188
  type: "current",
@@ -8626,9 +8545,9 @@ const DatePicker = (props) => {
8626
8545
  };
8627
8546
  const compareDateChange = (currentDate, newDate, selectedOptions, index) => {
8628
8547
  var _a;
8629
- const isEqual = ((_a = new Date(currentDate)) == null ? void 0 : _a.getTime()) === (newDate == null ? void 0 : newDate.getTime());
8548
+ const isEqual2 = ((_a = new Date(currentDate)) == null ? void 0 : _a.getTime()) === (newDate == null ? void 0 : newDate.getTime());
8630
8549
  if (newDate && isDate(newDate)) {
8631
- if (!isEqual) {
8550
+ if (!isEqual2) {
8632
8551
  setSelectedDate(formatValue(newDate));
8633
8552
  }
8634
8553
  onChange == null ? void 0 : onChange(
@@ -10953,7 +10872,7 @@ const MenuItem = forwardRef((props, ref) => {
10953
10872
  useEffect(() => {
10954
10873
  getParentOffset();
10955
10874
  }, [showPopup, getParentOffset]);
10956
- const windowHeight = useMemo$1(() => getSystemInfoSync().windowHeight, []);
10875
+ const windowHeight = useMemo$1(() => getWindowInfo().windowHeight, []);
10957
10876
  const updateItemOffset = useCallback(() => {
10958
10877
  if (!parent.lockScroll) return;
10959
10878
  const p = parent.menuRef.current;
@@ -11003,7 +10922,7 @@ const MenuItem = forwardRef((props, ref) => {
11003
10922
  bottom: "0",
11004
10923
  height: "initial"
11005
10924
  } : {
11006
- bottom: `${getSystemInfoSync().windowHeight - position.top}px`,
10925
+ bottom: `${getWindowInfo().windowHeight - position.top}px`,
11007
10926
  top: "0",
11008
10927
  height: "initial"
11009
10928
  };
@@ -11016,7 +10935,7 @@ const MenuItem = forwardRef((props, ref) => {
11016
10935
  };
11017
10936
  }
11018
10937
  return {
11019
- height: `${getSystemInfoSync().windowHeight - position.top}px`,
10938
+ height: `${getWindowInfo().windowHeight - position.top}px`,
11020
10939
  top: "auto",
11021
10940
  ...isShow()
11022
10941
  };
@@ -13881,7 +13800,7 @@ const Drag = (props) => {
13881
13800
  const el = myDrag.current;
13882
13801
  if (el) {
13883
13802
  const { top, left: left2, bottom, right: right2 } = boundary;
13884
- const { screenWidth, windowHeight } = getSystemInfoSync();
13803
+ const { screenWidth, windowHeight } = getWindowInfo();
13885
13804
  const {
13886
13805
  width,
13887
13806
  height,
@@ -15158,7 +15077,7 @@ const PullToRefresh = (p) => {
15158
15077
  setStatus("pulling");
15159
15078
  }
15160
15079
  };
15161
- const isAndroidWeApp = Taro.getSystemInfoSync().platform === "android" && Taro.getEnv() === "WEAPP";
15080
+ const isAndroidWeApp = getDeviceInfo().platform === "android" && Taro.getEnv() === "WEAPP";
15162
15081
  const springStyles = {
15163
15082
  height: `${height}px`,
15164
15083
  ...!pullingRef.current || isAndroidWeApp ? { transition: "height .3s ease" } : {}
@@ -15746,29 +15665,29 @@ const defaultProps$r = {
15746
15665
  onClick: (event) => {
15747
15666
  }
15748
15667
  };
15749
- const classPrefix$8 = `nut-animate`;
15668
+ const classPrefix$8 = "nut-animate";
15750
15669
  const Animate = (props) => {
15751
- const { className, type: type4, action, loop, onClick, children, ...rest } = {
15670
+ const { className, type: type4, action, loop, onClick, children, style } = {
15752
15671
  ...defaultProps$r,
15753
15672
  ...props
15754
15673
  };
15755
15674
  const [clicked, setClicked] = useState(false);
15756
- const classes = classNames({
15757
- "nut-ani-container": true,
15758
- [`${classPrefix$8}-${type4}`]: action === "initial" || clicked ? type4 : false,
15759
- loop
15760
- });
15761
- const cls = classNames(classes, className);
15675
+ const classes = classNames(
15676
+ {
15677
+ "nut-ani-container": true,
15678
+ [`${classPrefix$8}-${type4}`]: action === "initial" || clicked,
15679
+ loop
15680
+ },
15681
+ className
15682
+ );
15762
15683
  const handleClick = (event) => {
15763
15684
  setClicked(true);
15764
15685
  if (!loop) {
15765
- setTimeout(() => {
15766
- setClicked(false);
15767
- }, 1e3);
15686
+ setTimeout(() => setClicked(false), 1e3);
15768
15687
  }
15769
- onClick && onClick(event);
15688
+ onClick(event);
15770
15689
  };
15771
- return /* @__PURE__ */ React__default.createElement("div", { className: "nut-animate" }, /* @__PURE__ */ React__default.createElement("div", { className: cls, onClick: handleClick, ...rest }, children));
15690
+ return /* @__PURE__ */ React__default.createElement(View, { className: "nut-animate" }, /* @__PURE__ */ React__default.createElement(View, { className: classes, onClick: handleClick, style }, children));
15772
15691
  };
15773
15692
  Animate.displayName = "NutAnimate";
15774
15693
  const defaultProps$q = {
@@ -18362,7 +18281,7 @@ const VirtualList = (props) => {
18362
18281
  ...props
18363
18282
  };
18364
18283
  const clientHeight = useMemo$1(
18365
- () => getSystemInfoSync().windowHeight - 5 || 667,
18284
+ () => getWindowInfo().windowHeight - 5 || 667,
18366
18285
  []
18367
18286
  );
18368
18287
  const containerHeight = useMemo$1(
@@ -19136,7 +19055,7 @@ const AvatarCropper = (props) => {
19136
19055
  const [visible, setVisible] = useState(false);
19137
19056
  const [moving, setMoving] = useState(false);
19138
19057
  const [zooming, setZooming] = useState(false);
19139
- const systemInfo = Taro.getSystemInfoSync();
19058
+ const systemInfo = getWindowInfo();
19140
19059
  const showAlipayCanvas2D = useMemo$1(() => {
19141
19060
  return Taro.getEnv() === "ALIPAY" && parseInt(Taro.SDKVersion.replace(/\./g, "")) >= 270;
19142
19061
  }, []);