@nutui/nutui-react 2.0.0-beta.1 → 2.0.0-beta.3

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 (114) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/esm/ActionSheet.js +2 -2
  3. package/dist/esm/Avatar.js +2 -0
  4. package/dist/esm/Calendar/style/style.css +1 -1
  5. package/dist/esm/Calendar.js +8 -6
  6. package/dist/esm/CalendarItem.js +288 -291
  7. package/dist/esm/Cell/style/index.js +1 -1
  8. package/dist/esm/Cell/style/style.css +1 -1
  9. package/dist/esm/Cell.js +2 -0
  10. package/dist/esm/CellGroup.js +47 -4
  11. package/dist/esm/ConfigProvider.js +6 -483
  12. package/dist/esm/Dialog/style/style.css +1 -1
  13. package/dist/esm/Elevator.js +4 -4
  14. package/dist/esm/Form.js +1 -2
  15. package/dist/esm/Menu.js +6 -1
  16. package/dist/esm/MenuItem.js +8 -153
  17. package/dist/esm/NavBar.js +2 -2
  18. package/dist/esm/NoticeBar.js +2 -2
  19. package/dist/esm/NumberKeyboard.js +2 -2
  20. package/dist/esm/Popover.js +6 -7
  21. package/dist/esm/SearchBar.js +2 -2
  22. package/dist/esm/ShortPassword.js +4 -4
  23. package/dist/esm/Swiper.js +4 -1
  24. package/dist/esm/TrendArrow.js +11 -11
  25. package/dist/esm/Uploader.js +4 -4
  26. package/dist/esm/VirtualList.js +3 -8
  27. package/dist/esm/cascader2.js +2 -2
  28. package/dist/esm/configprovider2.js +486 -0
  29. package/dist/esm/date.js +103 -2
  30. package/dist/esm/menuitem2.js +156 -0
  31. package/dist/esm/nutui-react.es.js +30 -30
  32. package/dist/esm/popup2.js +5 -5
  33. package/dist/esm/types/src/packages/avatar/avatar.d.ts +4 -1
  34. package/dist/esm/types/src/packages/avatar/avatar.taro.d.ts +4 -1
  35. package/dist/esm/types/src/packages/calendar/calendar.d.ts +4 -6
  36. package/dist/esm/types/src/packages/calendar/calendar.taro.d.ts +4 -6
  37. package/dist/esm/types/src/packages/calendar/type.d.ts +13 -0
  38. package/dist/esm/types/src/packages/calendar/utils.d.ts +8 -0
  39. package/dist/esm/types/src/packages/calendaritem/calendaritem.d.ts +25 -27
  40. package/dist/esm/types/src/packages/calendaritem/calendaritem.taro.d.ts +26 -28
  41. package/dist/esm/types/src/packages/cell/cell.d.ts +4 -1
  42. package/dist/esm/types/src/packages/cell/cell.taro.d.ts +4 -1
  43. package/dist/esm/types/src/packages/configprovider/types.d.ts +1 -1
  44. package/dist/esm/types/src/packages/elevator/elevator.d.ts +2 -2
  45. package/dist/esm/types/src/packages/elevator/elevator.taro.d.ts +2 -2
  46. package/dist/esm/types/src/packages/menu/menu.d.ts +4 -1
  47. package/dist/esm/types/src/packages/menu/menu.taro.d.ts +4 -1
  48. package/dist/esm/types/src/packages/navbar/demo.d.ts +1 -0
  49. package/dist/esm/types/src/packages/navbar/demo.taro.d.ts +1 -0
  50. package/dist/esm/types/src/packages/navbar/navbar.d.ts +1 -1
  51. package/dist/esm/types/src/packages/navbar/navbar.taro.d.ts +1 -1
  52. package/dist/esm/types/src/packages/noticebar/noticebar.d.ts +1 -1
  53. package/dist/esm/types/src/packages/noticebar/noticebar.taro.d.ts +1 -1
  54. package/dist/esm/types/src/packages/nutui.react.build.d.ts +3 -3
  55. package/dist/esm/types/src/packages/nutui.react.d.ts +5 -5
  56. package/dist/esm/types/src/packages/nutui.react.scss.d.ts +2 -2
  57. package/dist/esm/types/src/packages/nutui.react.taro.d.ts +5 -5
  58. package/dist/esm/types/src/packages/nutui.react.taro.scss.d.ts +2 -2
  59. package/dist/esm/types/src/packages/nutui.taro.react.build.d.ts +3 -3
  60. package/dist/esm/types/src/packages/popover/popover.d.ts +2 -2
  61. package/dist/esm/types/src/packages/popover/popover.taro.d.ts +2 -2
  62. package/dist/esm/types/src/packages/popup/popup.d.ts +2 -2
  63. package/dist/esm/types/src/packages/popup/popup.taro.d.ts +2 -2
  64. package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +1 -1
  65. package/dist/esm/types/src/packages/searchbar/searchbar.taro.d.ts +1 -1
  66. package/dist/esm/types/src/packages/swiper/index.d.ts +8 -2
  67. package/dist/esm/types/src/packages/swiper/index.taro.d.ts +8 -2
  68. package/dist/esm/types/src/packages/trendarrow/trendarrow.d.ts +3 -3
  69. package/dist/esm/types/src/packages/trendarrow/trendarrow.taro.d.ts +3 -3
  70. package/dist/esm/types/src/packages/uploader/uploader.d.ts +1 -1
  71. package/dist/esm/types/src/packages/uploader/uploader.taro.d.ts +1 -1
  72. package/dist/esm/types/src/packages/virtuallist/virtuallist.d.ts +2 -2
  73. package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +2 -2
  74. package/dist/esm/types/src/utils/date.d.ts +19 -3
  75. package/dist/locales/base.js +1 -1
  76. package/dist/locales/en-US.js +1 -1
  77. package/dist/locales/id-ID.js +1 -1
  78. package/dist/locales/tr-TR.js +1 -1
  79. package/dist/locales/zh-CN.js +1 -1
  80. package/dist/locales/zh-TW.js +1 -1
  81. package/dist/locales/zh-UG.js +1 -1
  82. package/dist/nutui.react.es.js +1104 -1011
  83. package/dist/nutui.react.umd.js +1104 -1011
  84. package/dist/packages/calendar/calendar.scss +4 -0
  85. package/dist/packages/cell/cell.scss +2 -0
  86. package/dist/packages/dialog/dialog.scss +1 -1
  87. package/dist/style.css +1 -1
  88. package/dist/style.mjs +1 -1
  89. package/dist/styles/themes/default.scss +2 -2
  90. package/dist/styles/variables-jmapp.scss +2 -2
  91. package/dist/styles/variables.scss +2 -2
  92. package/dist/types/index.d.ts +3 -3
  93. package/dist/types/packages/avatar/avatar.d.ts +4 -1
  94. package/dist/types/packages/calendar/calendar.d.ts +8 -6
  95. package/dist/types/packages/calendar/type.d.ts +13 -0
  96. package/dist/types/packages/calendar/utils.d.ts +8 -0
  97. package/dist/types/packages/calendaritem/calendaritem.d.ts +25 -27
  98. package/dist/types/packages/cell/cell.d.ts +4 -1
  99. package/dist/types/packages/configprovider/types.d.ts +1 -1
  100. package/dist/types/packages/elevator/elevator.d.ts +2 -2
  101. package/dist/types/packages/menu/menu.d.ts +4 -1
  102. package/dist/types/packages/navbar/navbar.d.ts +1 -1
  103. package/dist/types/packages/noticebar/noticebar.d.ts +1 -1
  104. package/dist/types/packages/popover/popover.d.ts +2 -2
  105. package/dist/types/packages/popup/popup.d.ts +2 -2
  106. package/dist/types/packages/searchbar/searchbar.d.ts +1 -1
  107. package/dist/types/packages/swiper/index.d.ts +8 -2
  108. package/dist/types/packages/trendarrow/trendarrow.d.ts +3 -3
  109. package/dist/types/packages/uploader/uploader.d.ts +1 -1
  110. package/dist/types/packages/virtuallist/utils.d.ts +1 -1
  111. package/dist/types/packages/virtuallist/virtuallist.d.ts +2 -2
  112. package/dist/types/utils/date.d.ts +19 -3
  113. package/package.json +1 -1
  114. package/dist/esm/cellgroup2.js +0 -50
@@ -6,7 +6,7 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  var _a;
8
8
  /*!
9
- * @nutui/nutui-react v2.0.0-beta.1 Wed Jun 21 2023 15:03:52 GMT+0800 (China Standard Time)
9
+ * @nutui/nutui-react v2.0.0-beta.3 Fri Jun 30 2023 14:20:38 GMT+0800 (China Standard Time)
10
10
  * (c) 2023 @jdf2e.
11
11
  * Released under the MIT License.
12
12
  */
@@ -2480,6 +2480,28 @@ const Button = React__default.forwardRef(
2480
2480
  );
2481
2481
  Button.displayName = "NutButton";
2482
2482
  const defaultProps$1p = {
2483
+ ...ComponentDefaults,
2484
+ title: "",
2485
+ description: "",
2486
+ divider: true
2487
+ };
2488
+ const classPrefix$n = "nut-cell-group";
2489
+ const CellGroup = (props) => {
2490
+ const { children, className, style, title, description, divider, ...rest } = {
2491
+ ...defaultProps$1p,
2492
+ ...props
2493
+ };
2494
+ return /* @__PURE__ */ React__default.createElement("div", { className: classNames(classPrefix$n, className), ...rest }, title ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$n}__title` }, title) : null, description ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$n}__description` }, description) : null, /* @__PURE__ */ React__default.createElement(
2495
+ "div",
2496
+ {
2497
+ className: `${classPrefix$n}__wrap ${divider ? `${classPrefix$n}__wrap--divider` : ""}`
2498
+ },
2499
+ children
2500
+ ));
2501
+ };
2502
+ CellGroup.defaultProps = defaultProps$1p;
2503
+ CellGroup.displayName = "NutCellGroup";
2504
+ const defaultProps$1o = {
2483
2505
  ...ComponentDefaults,
2484
2506
  title: null,
2485
2507
  description: null,
@@ -2489,7 +2511,7 @@ const defaultProps$1p = {
2489
2511
  onClick: (event) => {
2490
2512
  }
2491
2513
  };
2492
- const classPrefix$n = "nut-cell";
2514
+ const classPrefix$m = "nut-cell";
2493
2515
  const Cell = (props) => {
2494
2516
  const {
2495
2517
  children,
@@ -2503,7 +2525,7 @@ const Cell = (props) => {
2503
2525
  style,
2504
2526
  ...rest
2505
2527
  } = {
2506
- ...defaultProps$1p,
2528
+ ...defaultProps$1o,
2507
2529
  ...props
2508
2530
  };
2509
2531
  const handleClick2 = (event) => {
@@ -2520,45 +2542,24 @@ const Cell = (props) => {
2520
2542
  return /* @__PURE__ */ React__default.createElement(
2521
2543
  "div",
2522
2544
  {
2523
- className: classNames(classPrefix$n, className),
2545
+ className: classNames(classPrefix$m, className),
2524
2546
  onClick: (event) => handleClick2(event),
2525
2547
  style: baseStyle,
2526
2548
  ...rest
2527
2549
  },
2528
- children || /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, title || description ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$n}__left` }, title ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$n}__title` }, title) : null, description ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$n}__description` }, description) : null) : null, extra ? /* @__PURE__ */ React__default.createElement(
2550
+ children || /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, title || description ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$m}__left` }, title ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$m}__title` }, title) : null, description ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$m}__description` }, description) : null) : null, extra ? /* @__PURE__ */ React__default.createElement(
2529
2551
  "div",
2530
2552
  {
2531
- className: `${classPrefix$n}__extra`,
2553
+ className: `${classPrefix$m}__extra`,
2532
2554
  style: styles
2533
2555
  },
2534
2556
  extra
2535
- ) : null, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$n}__divider` }))
2557
+ ) : null, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$m}__divider` }))
2536
2558
  );
2537
2559
  };
2538
- Cell.defaultProps = defaultProps$1p;
2560
+ Cell.defaultProps = defaultProps$1o;
2539
2561
  Cell.displayName = "NutCell";
2540
- const defaultProps$1o = {
2541
- ...ComponentDefaults,
2542
- title: "",
2543
- description: "",
2544
- divider: true
2545
- };
2546
- const classPrefix$m = "nut-cell-group";
2547
- const CellGroup = (props) => {
2548
- const { children, className, style, title, description, divider, ...rest } = {
2549
- ...defaultProps$1o,
2550
- ...props
2551
- };
2552
- return /* @__PURE__ */ React__default.createElement("div", { className: classNames(classPrefix$m, className), ...rest }, title ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$m}__title` }, title) : null, description ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix$m}__description` }, description) : null, /* @__PURE__ */ React__default.createElement(
2553
- "div",
2554
- {
2555
- className: `${classPrefix$m}__wrap ${divider ? `${classPrefix$m}__wrap--divider` : ""}`
2556
- },
2557
- children
2558
- ));
2559
- };
2560
- CellGroup.defaultProps = defaultProps$1o;
2561
- CellGroup.displayName = "NutCellGroup";
2562
+ Cell.Group = CellGroup;
2562
2563
  var INFINITY = 1 / 0;
2563
2564
  var symbolTag = "[object Symbol]";
2564
2565
  var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
@@ -8997,8 +8998,8 @@ const Elevator = (props) => {
8997
8998
  showKeys,
8998
8999
  className,
8999
9000
  style,
9000
- onClickItem,
9001
- onClickIndex,
9001
+ onItemClick,
9002
+ onIndexClick,
9002
9003
  children,
9003
9004
  ...rest
9004
9005
  } = {
@@ -9080,12 +9081,12 @@ const Elevator = (props) => {
9080
9081
  }
9081
9082
  });
9082
9083
  const handleClickItem = (key, item) => {
9083
- onClickItem && onClickItem(key, item);
9084
+ onItemClick && onItemClick(key, item);
9084
9085
  setCurrentData(item);
9085
9086
  setCurrentKey(key);
9086
9087
  };
9087
9088
  const handleClickIndex = (key) => {
9088
- onClickIndex && onClickIndex(key);
9089
+ onIndexClick && onIndexClick(key);
9089
9090
  };
9090
9091
  const setListGroup = () => {
9091
9092
  if (listview.current) {
@@ -9283,7 +9284,7 @@ const NavBar = (props) => {
9283
9284
  safeAreaInsetTop,
9284
9285
  placeholder,
9285
9286
  zIndex,
9286
- onClickBack
9287
+ onBackClick
9287
9288
  } = {
9288
9289
  ...defaultProps$1b,
9289
9290
  ...props
@@ -9301,7 +9302,7 @@ const NavBar = (props) => {
9301
9302
  "div",
9302
9303
  {
9303
9304
  className: `${classPrefix2}__left__back`,
9304
- onClick: (e) => onClickBack(e)
9305
+ onClick: (e) => onBackClick(e)
9305
9306
  },
9306
9307
  back
9307
9308
  ), left);
@@ -11082,8 +11083,8 @@ const defaultProps$1a = {
11082
11083
  },
11083
11084
  onClose: () => {
11084
11085
  },
11085
- onClickOverlay: (e) => true,
11086
- onClickCloseIcon: (e) => true,
11086
+ onOverlayClick: (e) => true,
11087
+ onCloseIconClick: (e) => true,
11087
11088
  ...defaultOverlayProps
11088
11089
  };
11089
11090
  let _zIndex = 1e3;
@@ -11112,8 +11113,8 @@ const Popup = (props) => {
11112
11113
  portal,
11113
11114
  onOpen,
11114
11115
  onClose,
11115
- onClickOverlay,
11116
- onClickCloseIcon,
11116
+ onOverlayClick,
11117
+ onCloseIconClick,
11117
11118
  afterShow,
11118
11119
  afterClose,
11119
11120
  onClick
@@ -11169,7 +11170,7 @@ const Popup = (props) => {
11169
11170
  const onHandleClickOverlay = (e) => {
11170
11171
  e.stopPropagation();
11171
11172
  if (closeOnOverlayClick) {
11172
- const closed = onClickOverlay && onClickOverlay(e);
11173
+ const closed = onOverlayClick && onOverlayClick(e);
11173
11174
  closed && close();
11174
11175
  }
11175
11176
  };
@@ -11177,7 +11178,7 @@ const Popup = (props) => {
11177
11178
  onClick && onClick(e);
11178
11179
  };
11179
11180
  const onHandleClickCloseIcon = (e) => {
11180
- const closed = onClickCloseIcon && onClickCloseIcon(e);
11181
+ const closed = onCloseIconClick && onCloseIconClick(e);
11181
11182
  closed && close();
11182
11183
  };
11183
11184
  const onHandleOpened = (e) => {
@@ -12272,8 +12273,8 @@ const InternalCascader = (props, ref) => {
12272
12273
  closeIconPosition,
12273
12274
  title: popup && props.title,
12274
12275
  left: props.left,
12275
- onClickOverlay: closePopup,
12276
- onClickCloseIcon: closePopup
12276
+ onOverlayClick: closePopup,
12277
+ onCloseIconClick: closePopup
12277
12278
  },
12278
12279
  renderTabs()
12279
12280
  ) : renderTabs());
@@ -12525,7 +12526,7 @@ const Utils = {
12525
12526
  return dayNames[index];
12526
12527
  },
12527
12528
  /**
12528
- * 返回星期数
12529
+ * 返回上一个月在当前面板中的天数
12529
12530
  * @return {Number}
12530
12531
  */
12531
12532
  getMonthPreDay(year, month) {
@@ -12614,9 +12615,140 @@ const Utils = {
12614
12615
  return true;
12615
12616
  }
12616
12617
  return false;
12618
+ },
12619
+ getMonthWeek(year, month, date4, firstDayOfWeek = 0) {
12620
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
12621
+ let w = dateNow.getDay();
12622
+ const d = dateNow.getDate();
12623
+ let remainder = 6 - w;
12624
+ if (firstDayOfWeek !== 0) {
12625
+ w = w === 0 ? 7 : w;
12626
+ remainder = 7 - w;
12627
+ }
12628
+ return Math.ceil((d + remainder) / 7);
12629
+ },
12630
+ getYearWeek(year, month, date4, firstDayOfWeek = 0) {
12631
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
12632
+ const dateFirst = new Date(Number(year), 0, 1);
12633
+ const dataNumber = Math.round(
12634
+ (dateNow.valueOf() - dateFirst.valueOf()) / 864e5
12635
+ );
12636
+ return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7);
12637
+ },
12638
+ getWeekDate(year, month, date4, firstDayOfWeek = 0) {
12639
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date4));
12640
+ const nowTime = dateNow.getTime();
12641
+ let day = dateNow.getDay();
12642
+ if (firstDayOfWeek === 0) {
12643
+ const oneDayTime2 = 24 * 60 * 60 * 1e3;
12644
+ const SundayTime2 = nowTime - day * oneDayTime2;
12645
+ const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
12646
+ const sunday2 = this.date2Str(new Date(SundayTime2));
12647
+ const saturday = this.date2Str(new Date(SaturdayTime));
12648
+ return [sunday2, saturday];
12649
+ }
12650
+ day = day === 0 ? 7 : day;
12651
+ const oneDayTime = 24 * 60 * 60 * 1e3;
12652
+ const MondayTime = nowTime - (day - 1) * oneDayTime;
12653
+ const SundayTime = nowTime + (7 - day) * oneDayTime;
12654
+ const monday = this.date2Str(new Date(MondayTime));
12655
+ const sunday = this.date2Str(new Date(SundayTime));
12656
+ return [monday, sunday];
12657
+ },
12658
+ formatResultDate(date4) {
12659
+ const days = [...date4.split("-")];
12660
+ days[2] = Utils.getNumTwoBit(Number(days[2]));
12661
+ days[3] = `${days[0]}-${days[1]}-${days[2]}`;
12662
+ days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
12663
+ return days;
12664
+ }
12665
+ };
12666
+ const getCurrMonthData = (type4, year, month) => {
12667
+ switch (type4) {
12668
+ case "prev":
12669
+ month === 1 && (year -= 1);
12670
+ month = month === 1 ? 12 : --month;
12671
+ break;
12672
+ case "next":
12673
+ month === 12 && (year += 1);
12674
+ month = month === 12 ? 1 : ++month;
12675
+ break;
12676
+ }
12677
+ return [
12678
+ year,
12679
+ Utils.getNumTwoBit(month),
12680
+ Utils.getMonthDays(String(year), String(month))
12681
+ ];
12682
+ };
12683
+ const getDaysStatus = (type4, year, month) => {
12684
+ let days = Utils.getMonthDays(`${year}`, `${month}`);
12685
+ if (type4 === "prev" && days >= 7) {
12686
+ days -= 7;
12687
+ }
12688
+ return Array.from(Array(days), (v, k2) => {
12689
+ return {
12690
+ day: k2 + 1,
12691
+ type: type4,
12692
+ year,
12693
+ month
12694
+ };
12695
+ });
12696
+ };
12697
+ const getPreMonthDates = (type4, year, month, firstDayOfWeek) => {
12698
+ let preMonth = +month - 1;
12699
+ let preYear = year;
12700
+ if (preMonth <= 0) {
12701
+ preMonth = 12;
12702
+ preYear += 1;
12703
+ }
12704
+ let days = Utils.getMonthPreDay(+year, +month);
12705
+ days -= firstDayOfWeek;
12706
+ if (type4 === "prev" && days >= 7) {
12707
+ days -= 7;
12708
+ }
12709
+ const preDates = Utils.getMonthDays(`${preYear}`, `${preMonth}`);
12710
+ const months = Array.from(Array(preDates), (v, k2) => {
12711
+ return {
12712
+ day: k2 + 1,
12713
+ type: type4,
12714
+ preYear,
12715
+ preMonth
12716
+ };
12717
+ });
12718
+ return months.slice(preDates - days);
12719
+ };
12720
+ const splitDate = (date4) => {
12721
+ const split = date4.indexOf("-") !== -1 ? "-" : "/";
12722
+ return date4.split(split);
12723
+ };
12724
+ const isMultiple = (day, days) => {
12725
+ if (days.length > 0) {
12726
+ return days.some((item) => {
12727
+ return Utils.isEqual(item, day);
12728
+ });
12617
12729
  }
12730
+ return false;
12731
+ };
12732
+ const isCurrDay = (month, day) => {
12733
+ const date4 = `${month.curData[0]}/${month.curData[1]}/${day}`;
12734
+ return Utils.isEqual(date4, Utils.date2Str(/* @__PURE__ */ new Date(), "/"));
12735
+ };
12736
+ const getCurrDate = (day, month) => {
12737
+ return `${month.curData[0]}/${month.curData[1]}/${Utils.getNumTwoBit(
12738
+ +day.day
12739
+ )}`;
12740
+ };
12741
+ const isStart = (day, days) => {
12742
+ return Utils.isEqual(days[0], day);
12743
+ };
12744
+ const isEnd = (day, days) => {
12745
+ return Utils.isEqual(days[1], day);
12746
+ };
12747
+ const isStartAndEnd = (days) => {
12748
+ return days.length >= 2 && Utils.isEqual(days[0], days[1]);
12618
12749
  };
12619
12750
  const defaultProps$_ = {
12751
+ ...ComponentDefaults,
12620
12752
  type: "single",
12621
12753
  autoBackfill: false,
12622
12754
  popup: true,
@@ -12630,6 +12762,7 @@ const defaultProps$_ = {
12630
12762
  showTitle: true,
12631
12763
  showSubTitle: true,
12632
12764
  scrollAnimation: true,
12765
+ firstDayOfWeek: 0,
12633
12766
  renderHeaderButtons: void 0,
12634
12767
  renderDay: void 0,
12635
12768
  renderDayTop: void 0,
@@ -12638,7 +12771,7 @@ const defaultProps$_ = {
12638
12771
  },
12639
12772
  onUpdate: () => {
12640
12773
  },
12641
- onClickDay: (data) => {
12774
+ onDayClick: (data) => {
12642
12775
  },
12643
12776
  onPageChange: (data) => {
12644
12777
  }
@@ -12646,11 +12779,13 @@ const defaultProps$_ = {
12646
12779
  const CalendarItem = React__default.forwardRef((props, ref) => {
12647
12780
  const { locale } = useConfig();
12648
12781
  const {
12782
+ popup,
12649
12783
  type: type4,
12650
12784
  autoBackfill,
12651
- popup,
12652
12785
  title,
12653
12786
  defaultValue,
12787
+ startDate,
12788
+ endDate,
12654
12789
  showToday,
12655
12790
  startText,
12656
12791
  endText,
@@ -12658,28 +12793,29 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
12658
12793
  showTitle,
12659
12794
  showSubTitle,
12660
12795
  scrollAnimation,
12796
+ firstDayOfWeek,
12661
12797
  renderHeaderButtons,
12662
12798
  renderDay,
12663
12799
  renderDayTop,
12664
12800
  renderDayBottom,
12665
12801
  onConfirm,
12666
12802
  onUpdate,
12667
- onClickDay,
12803
+ onDayClick,
12668
12804
  onPageChange
12669
12805
  } = { ...defaultProps$_, ...props };
12670
- const weeks = locale.calendaritem.weekdays;
12806
+ const weekdays = locale.calendaritem.weekdays;
12807
+ const weeks = [
12808
+ ...weekdays.slice(firstDayOfWeek, 7),
12809
+ ...weekdays.slice(0, firstDayOfWeek)
12810
+ ];
12671
12811
  const monthTitle = locale.calendaritem.monthTitle;
12672
12812
  const [yearMonthTitle, setYearMonthTitle] = useState("");
12673
12813
  const [monthsData, setMonthsData] = useState([]);
12674
12814
  const [monthsNum, setMonthsNum] = useState(0);
12675
12815
  const [translateY, setTranslateY] = useState(0);
12676
12816
  const [monthDefaultRange, setMonthDefaultRange] = useState([]);
12677
- const propStartDate = props.startDate || Utils.getDay(0);
12678
- const propEndDate = props.endDate || Utils.getDay(365);
12679
- const splitDate = (date4) => {
12680
- const split = date4.indexOf("-") !== -1 ? "-" : "/";
12681
- return date4.split(split);
12682
- };
12817
+ const propStartDate = startDate || Utils.getDay(0);
12818
+ const propEndDate = endDate || Utils.getDay(365);
12683
12819
  const startDates = splitDate(propStartDate);
12684
12820
  const endDates = splitDate(propEndDate);
12685
12821
  const [state] = useState({
@@ -12706,171 +12842,49 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
12706
12842
  let viewHeight = 0;
12707
12843
  const classPrefix2 = "nut-calendar";
12708
12844
  const dayPrefix = "nut-calendar-day";
12709
- const classes = classNames(
12710
- {
12711
- [`${classPrefix2}-title`]: !popup,
12712
- [`${classPrefix2}-nofooter`]: !!autoBackfill
12713
- },
12714
- classPrefix2
12715
- );
12716
- const headerClasses = classNames({
12717
- [`${classPrefix2}-header`]: true,
12718
- [`${classPrefix2}-header-title`]: !popup
12719
- });
12720
- const isMultiple = (d) => {
12721
- if (currentDate.length > 0) {
12722
- return currentDate.some((item) => {
12723
- return Utils.isEqual(item, d);
12724
- });
12725
- }
12726
- return false;
12727
- };
12728
- const getCurrDate = (day, month) => {
12729
- return `${month.curData[0]}/${month.curData[1]}/${Utils.getNumTwoBit(
12730
- +day.day
12731
- )}`;
12732
- };
12733
- const getClasses = (day, month) => {
12734
- const dateStr = getCurrDate(day, month);
12735
- if (day.type === "active") {
12736
- if (propStartDate && Utils.compareDate(dateStr, propStartDate) || propEndDate && Utils.compareDate(propEndDate, dateStr)) {
12737
- return `${dayPrefix}-disabled`;
12738
- }
12739
- if (type4 === "range") {
12740
- if (isStart(dateStr) || isEnd(dateStr)) {
12741
- return `${dayPrefix}-active ${isStart(dateStr) ? "active-start" : ""} ${isEnd(dateStr) ? "active-end" : ""}`;
12742
- }
12743
- if (Array.isArray(currentDate) && Object.values(currentDate).length === 2 && Utils.compareDate(currentDate[0], dateStr) && Utils.compareDate(dateStr, currentDate[1])) {
12744
- return `${dayPrefix}-choose`;
12745
- }
12746
- return null;
12747
- }
12748
- if (type4 === "multiple" && isMultiple(dateStr) || !Array.isArray(currentDate) && Utils.isEqual(currentDate, dateStr)) {
12749
- return `${dayPrefix}-active`;
12750
- }
12751
- return null;
12752
- }
12753
- return `${dayPrefix}-disabled`;
12754
- };
12755
- const isCurrDay = (month, day) => {
12756
- const date4 = `${month.curData[0]}/${month.curData[1]}/${day}`;
12757
- return Utils.isEqual(date4, Utils.date2Str(/* @__PURE__ */ new Date(), "/"));
12758
- };
12759
- const isStart = (d) => {
12760
- return Utils.isEqual(currentDate[0], d);
12761
- };
12762
- const isEnd = (d) => {
12763
- return Utils.isEqual(currentDate[1], d);
12764
- };
12765
- const isStartTip = (day, month) => {
12766
- return type4 === "range" && day.type === "active" && isStart(getCurrDate(day, month));
12767
- };
12768
- const isEndTip = (day, month) => {
12769
- return currentDate.length >= 2 && type4 === "range" && day.type === "active" && isEnd(getCurrDate(day, month));
12770
- };
12771
- const isStartAndEnd = () => {
12772
- return currentDate.length >= 2 && Utils.isEqual(currentDate[0], currentDate[1]);
12773
- };
12774
- const getCurrMonthData = (type22) => {
12775
- const monthData = type22 === "prev" ? monthsData[0] : monthsData[monthsData.length - 1];
12776
- let year = parseInt(monthData.curData[0]);
12777
- let month = parseInt(monthData.curData[1].toString().replace(/^0/, ""));
12778
- switch (type22) {
12779
- case "prev":
12780
- month === 1 && (year -= 1);
12781
- month = month === 1 ? 12 : --month;
12782
- break;
12783
- case "next":
12784
- month === 12 && (year += 1);
12785
- month = month === 12 ? 1 : ++month;
12786
- break;
12787
- }
12788
- return [
12789
- year,
12790
- Utils.getNumTwoBit(month),
12791
- Utils.getMonthDays(String(year), String(month))
12792
- ];
12793
- };
12794
- const getDaysStatus = (days, type22, year, month) => {
12795
- if (type22 === "prev" && days >= 7) {
12796
- days -= 7;
12797
- }
12798
- return Array.from(Array(days), (v, k2) => {
12799
- return {
12800
- day: k2 + 1,
12801
- type: type22,
12802
- year,
12803
- month
12804
- };
12805
- });
12806
- };
12807
- const getPreDaysStatus = (days, type22, year, month, preCurrMonthDays) => {
12808
- if (type22 === "prev" && days >= 7) {
12809
- days -= 7;
12810
- }
12811
- const months = Array.from(Array(preCurrMonthDays), (v, k2) => {
12812
- return {
12813
- day: k2 + 1,
12814
- type: type22,
12815
- year,
12816
- month
12845
+ const getMonthData = (curData, monthNum, type22) => {
12846
+ let i = 0;
12847
+ let date4 = curData;
12848
+ const monthData = monthsData;
12849
+ do {
12850
+ const y2 = parseInt(date4[0], 10);
12851
+ const m = parseInt(date4[1], 10);
12852
+ const days = [
12853
+ ...getPreMonthDates("prev", y2, m, firstDayOfWeek),
12854
+ ...getDaysStatus("active", y2, m)
12855
+ ];
12856
+ const cssHeight = 39 + (days.length > 35 ? 384 : 320);
12857
+ let scrollTop = 0;
12858
+ if (monthData.length > 0) {
12859
+ const monthEle = monthData[monthData.length - 1];
12860
+ scrollTop = monthEle.scrollTop + monthEle.cssHeight;
12861
+ }
12862
+ const monthInfo = {
12863
+ curData: date4,
12864
+ title: monthTitle(y2, m),
12865
+ monthData: days,
12866
+ cssHeight,
12867
+ scrollTop
12817
12868
  };
12818
- });
12819
- return months.slice(preCurrMonthDays - days);
12820
- };
12821
- const getMonthData = (curData, type22) => {
12822
- let preMonth = +curData[1] - 1;
12823
- let preYear = curData[0];
12824
- if (preMonth <= 0) {
12825
- preMonth = 12;
12826
- preYear += 1;
12827
- }
12828
- const preMonthDays = Utils.getMonthPreDay(+curData[0], +curData[1]);
12829
- const currMonthDays = Utils.getMonthDays(curData[0], curData[1]);
12830
- const preCurrMonthDays = Utils.getMonthDays(`${preYear}`, `${preMonth}`);
12831
- const monthInfo = {
12832
- curData,
12833
- title: monthTitle(curData[0], curData[1]),
12834
- monthData: [
12835
- ...getPreDaysStatus(
12836
- preMonthDays,
12837
- "prev",
12838
- `${preMonth}`,
12839
- preYear,
12840
- preCurrMonthDays
12841
- ),
12842
- ...getDaysStatus(
12843
- currMonthDays,
12844
- "active",
12845
- curData[0],
12846
- curData[1]
12847
- )
12848
- ]
12849
- };
12850
- monthInfo.cssHeight = 39 + (monthInfo.monthData.length > 35 ? 384 : 320);
12851
- let scrollTop = 0;
12852
- if (monthsData.length > 0) {
12853
- const monthEle = monthsData[monthsData.length - 1];
12854
- scrollTop = monthEle.scrollTop + monthEle.cssHeight;
12855
- }
12856
- monthInfo.scrollTop = scrollTop;
12857
- if (type22 === "next") {
12858
- if (!endDates || !Utils.compareDate(
12859
- `${endDates[0]}/${endDates[1]}/${Utils.getMonthDays(
12860
- endDates[0],
12861
- endDates[1]
12862
- )}`,
12863
- `${curData[0]}/${curData[1]}/${curData[2]}`
12869
+ if (type22 === "next") {
12870
+ if (!endDates || !Utils.compareDate(
12871
+ `${endDates[0]}/${endDates[1]}/${Utils.getMonthDays(
12872
+ endDates[0],
12873
+ endDates[1]
12874
+ )}`,
12875
+ `${curData[0]}/${curData[1]}/${curData[2]}`
12876
+ )) {
12877
+ monthData.push(monthInfo);
12878
+ }
12879
+ } else if (!startDates || !Utils.compareDate(
12880
+ `${curData[0]}/${curData[1]}/${curData[2]}`,
12881
+ `${startDates[0]}/${startDates[1]}/01`
12864
12882
  )) {
12865
- monthsData.push(monthInfo);
12883
+ monthData.unshift(monthInfo);
12866
12884
  }
12867
- } else if (!startDates || !Utils.compareDate(
12868
- `${curData[0]}/${curData[1]}/${curData[2]}`,
12869
- `${startDates[0]}/${startDates[1]}/01`
12870
- )) {
12871
- monthsData.unshift(monthInfo);
12872
- }
12873
- setMonthsData(monthsData);
12885
+ date4 = getCurrMonthData("next", y2, m);
12886
+ } while (i++ < monthNum);
12887
+ setMonthsData(monthData);
12874
12888
  };
12875
12889
  const setReachedYearMonthInfo = (current) => {
12876
12890
  const currentMonthsData = monthsData[current];
@@ -12902,48 +12916,11 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
12902
12916
  setTranslateY(monthsData[start2].scrollTop);
12903
12917
  setReachedYearMonthInfo(current);
12904
12918
  };
12905
- const monthsViewScroll = (e) => {
12906
- if (monthsData.length <= 1) {
12907
- return;
12908
- }
12909
- const scrollTop = e.target.scrollTop;
12910
- let current = Math.floor(scrollTop / avgHeight);
12911
- const nextTop = monthsData[current + 1].scrollTop;
12912
- const nextHeight = monthsData[current + 1].cssHeight;
12913
- if (current === 0) {
12914
- if (scrollTop >= nextTop) {
12915
- current += 1;
12916
- }
12917
- } else if (current > 0 && current < monthsNum - 1) {
12918
- if (scrollTop >= nextTop) {
12919
- current += 1;
12920
- }
12921
- if (scrollTop < monthsData[current].scrollTop) {
12922
- current -= 1;
12923
- }
12924
- } else {
12925
- const viewPosition = Math.round(scrollTop + viewHeight);
12926
- if (current + 1 <= monthsNum && viewPosition >= nextTop + nextHeight) {
12927
- current += 1;
12928
- }
12929
- if (current >= 1 && scrollTop < monthsData[current - 1].scrollTop) {
12930
- current -= 1;
12931
- }
12932
- }
12933
- setDefaultRange(monthsNum, current);
12934
- };
12935
12919
  const getMonthNum = () => {
12936
- const startDate = {
12937
- year: Number(startDates[0]),
12938
- month: Number(startDates[1])
12939
- };
12940
- const endDate = {
12941
- year: Number(endDates[0]),
12942
- month: Number(endDates[1])
12943
- };
12944
- let monthNum = endDate.month - startDate.month;
12945
- if (endDate.year - startDate.year > 0) {
12946
- monthNum += 12 * (endDate.year - startDate.year);
12920
+ let monthNum = Number(endDates[1]) - Number(startDates[1]);
12921
+ const yearNum = Number(endDates[0]) - Number(startDates[0]);
12922
+ if (yearNum > 0) {
12923
+ monthNum += 12 * yearNum;
12947
12924
  }
12948
12925
  if (monthNum <= 0) {
12949
12926
  monthNum = 1;
@@ -12951,26 +12928,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
12951
12928
  setMonthsNum(monthNum);
12952
12929
  return monthNum;
12953
12930
  };
12954
- const getMonthsData = (monthNum) => {
12955
- getMonthData(startDates, "next");
12956
- let i = 1;
12957
- do {
12958
- getMonthData(getCurrMonthData("next"), "next");
12959
- } while (i++ < monthNum);
12960
- };
12961
- const requestAniFrameFunc = (current, monthNum) => {
12962
- const lastItem = monthsData[monthsData.length - 1];
12963
- const containerHeight = lastItem.cssHeight + lastItem.scrollTop;
12964
- requestAniFrame$1(() => {
12965
- if (monthsRef && monthsPanel && viewAreaRef) {
12966
- viewHeight = monthsRef.current.clientHeight;
12967
- monthsPanel.current.style.height = `${containerHeight}px`;
12968
- monthsRef.current.scrollTop = monthsData[current].scrollTop;
12969
- }
12970
- });
12971
- setAvgHeight(Math.floor(containerHeight / (monthNum + 1)));
12972
- };
12973
- const renderCurrentDate = () => {
12931
+ const setDefaultDate = () => {
12974
12932
  let defaultData = [];
12975
12933
  if (type4 === "range" && Array.isArray(currentDate)) {
12976
12934
  if (currentDate.length > 0) {
@@ -12985,7 +12943,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
12985
12943
  ...splitDate(currentDate[1])
12986
12944
  ];
12987
12945
  }
12988
- } else if (props.type === "multiple" && Array.isArray(currentDate)) {
12946
+ } else if (type4 === "multiple" && Array.isArray(currentDate)) {
12989
12947
  if (currentDate.length > 0) {
12990
12948
  const defaultArr = [];
12991
12949
  const obj = {};
@@ -13000,6 +12958,22 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
13000
12958
  currentDate.splice(0) && currentDate.push(...defaultArr);
13001
12959
  defaultData = [...splitDate(defaultArr[0])];
13002
12960
  }
12961
+ } else if (type4 === "week" && Array.isArray(currentDate)) {
12962
+ if (currentDate.length > 0) {
12963
+ const [y2, m, d] = splitDate(currentDate[0]);
12964
+ const weekArr = Utils.getWeekDate(y2, m, d, firstDayOfWeek);
12965
+ currentDate.splice(0) && currentDate.push(...weekArr);
12966
+ if (propStartDate && Utils.compareDate(currentDate[0], propStartDate)) {
12967
+ currentDate.splice(0, 1, propStartDate);
12968
+ }
12969
+ if (propEndDate && Utils.compareDate(propEndDate, currentDate[1])) {
12970
+ currentDate.splice(1, 1, propEndDate);
12971
+ }
12972
+ defaultData = [
12973
+ ...splitDate(currentDate[0]),
12974
+ ...splitDate(currentDate[1])
12975
+ ];
12976
+ }
13003
12977
  } else if (currentDate) {
13004
12978
  if (currentDate.length > 0) {
13005
12979
  if (propStartDate && Utils.compareDate(currentDate, propStartDate)) {
@@ -13013,6 +12987,9 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
13013
12987
  defaultData = [];
13014
12988
  }
13015
12989
  }
12990
+ return defaultData;
12991
+ };
12992
+ const getCurrentIndex = (defaultData) => {
13016
12993
  let current = 0;
13017
12994
  let lastCurrent = 0;
13018
12995
  if (defaultData.length > 0) {
@@ -13020,38 +12997,53 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
13020
12997
  if (item.title === monthTitle(defaultData[0], defaultData[1])) {
13021
12998
  current = index;
13022
12999
  }
13023
- if (props.type === "range") {
13000
+ if (type4 === "range" || type4 === "week") {
13024
13001
  if (item.title === monthTitle(defaultData[3], defaultData[4])) {
13025
13002
  lastCurrent = index;
13026
13003
  }
13027
13004
  }
13028
13005
  });
13029
13006
  } else {
13030
- const currentYear2 = (/* @__PURE__ */ new Date()).getFullYear();
13031
- const currentMonth = (/* @__PURE__ */ new Date()).getMonth() + 1;
13032
- const currentYearMonthIndex = monthsData.findIndex((item) => {
13033
- return +item.curData[0] === currentYear2 && +item.curData[1] === currentMonth;
13007
+ const date4 = /* @__PURE__ */ new Date();
13008
+ const year = date4.getFullYear();
13009
+ const month = date4.getMonth() + 1;
13010
+ const index = monthsData.findIndex((item) => {
13011
+ return +item.curData[0] === year && +item.curData[1] === month;
13034
13012
  });
13035
- if (currentYearMonthIndex > -1) {
13036
- current = currentYearMonthIndex;
13013
+ if (index > -1) {
13014
+ current = index;
13037
13015
  }
13038
13016
  }
13017
+ return {
13018
+ current,
13019
+ lastCurrent
13020
+ };
13021
+ };
13022
+ const renderCurrentDate = () => {
13023
+ const defaultData = setDefaultDate();
13024
+ const current = getCurrentIndex(defaultData);
13039
13025
  if (defaultData.length > 0) {
13040
13026
  if (type4 === "range") {
13041
13027
  chooseDay(
13042
13028
  { day: defaultData[2], type: "active" },
13043
- monthsData[current],
13029
+ monthsData[current.current],
13044
13030
  true
13045
13031
  );
13046
13032
  chooseDay(
13047
13033
  { day: defaultData[5], type: "active" },
13048
- monthsData[lastCurrent],
13034
+ monthsData[current.lastCurrent],
13035
+ true
13036
+ );
13037
+ } else if (props.type === "week") {
13038
+ chooseDay(
13039
+ { day: defaultData[2], type: "curr" },
13040
+ monthsData[current.current],
13049
13041
  true
13050
13042
  );
13051
13043
  } else if (type4 === "multiple") {
13052
13044
  [...currentDate].forEach((item) => {
13053
13045
  const dateArr = splitDate(item);
13054
- let currentIndex = current;
13046
+ let currentIndex = current.current;
13055
13047
  monthsData.forEach((item2, index) => {
13056
13048
  if (item2.title === monthTitle(dateArr[0], dateArr[1])) {
13057
13049
  currentIndex = index;
@@ -13066,25 +13058,44 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
13066
13058
  } else {
13067
13059
  chooseDay(
13068
13060
  { day: defaultData[2], type: "active" },
13069
- monthsData[current],
13061
+ monthsData[current.current],
13070
13062
  true
13071
13063
  );
13072
13064
  }
13073
13065
  }
13074
- return current;
13066
+ return current.current;
13067
+ };
13068
+ const requestAniFrameFunc = (current, monthNum) => {
13069
+ const lastItem = monthsData[monthsData.length - 1];
13070
+ const containerHeight = lastItem.cssHeight + lastItem.scrollTop;
13071
+ requestAniFrame$1(() => {
13072
+ if (monthsRef && monthsPanel && viewAreaRef) {
13073
+ viewHeight = monthsRef.current.clientHeight;
13074
+ monthsPanel.current.style.height = `${containerHeight}px`;
13075
+ monthsRef.current.scrollTop = monthsData[current].scrollTop;
13076
+ }
13077
+ });
13078
+ setAvgHeight(Math.floor(containerHeight / (monthNum + 1)));
13075
13079
  };
13076
13080
  const initData = () => {
13077
13081
  const monthNum = getMonthNum();
13078
- getMonthsData(monthNum);
13082
+ getMonthData(startDates, monthNum, "next");
13079
13083
  const current = renderCurrentDate();
13080
13084
  setDefaultRange(monthNum, current);
13081
13085
  requestAniFrameFunc(current, monthNum);
13082
13086
  };
13087
+ useEffect(() => {
13088
+ initData();
13089
+ }, []);
13083
13090
  const resetRender = () => {
13084
13091
  state.currDateArray.splice(0);
13085
13092
  monthsData.splice(0);
13086
13093
  initData();
13087
13094
  };
13095
+ useEffect(() => {
13096
+ setCurrentDate(resetDefaultValue() || []);
13097
+ popup && resetRender();
13098
+ }, [defaultValue]);
13088
13099
  const scrollToDate = (date4) => {
13089
13100
  if (Utils.compareDate(date4, propStartDate)) {
13090
13101
  date4 = propStartDate;
@@ -13119,30 +13130,67 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
13119
13130
  }
13120
13131
  });
13121
13132
  };
13122
- useEffect(() => {
13123
- initData();
13124
- }, []);
13125
- useEffect(() => {
13126
- setCurrentDate(resetDefaultValue() || []);
13127
- popup && resetRender();
13128
- }, [defaultValue]);
13129
- React__default.useImperativeHandle(ref, () => ({
13130
- scrollToDate
13131
- }));
13132
- const confirm2 = () => {
13133
- if (type4 === "range" && state.currDateArray.length === 2 || type4 !== "range") {
13134
- const chooseData = state.currDateArray.slice(0);
13135
- onConfirm && onConfirm(chooseData);
13136
- if (popup) {
13137
- onUpdate && onUpdate();
13138
- }
13139
- }
13140
- };
13133
+ const monthsViewScroll = (e) => {
13134
+ if (monthsData.length <= 1) {
13135
+ return;
13136
+ }
13137
+ const scrollTop = e.target.scrollTop;
13138
+ let current = Math.floor(scrollTop / avgHeight);
13139
+ const nextTop = monthsData[current + 1].scrollTop;
13140
+ const nextHeight = monthsData[current + 1].cssHeight;
13141
+ if (current === 0) {
13142
+ if (scrollTop >= nextTop) {
13143
+ current += 1;
13144
+ }
13145
+ } else if (current > 0 && current < monthsNum - 1) {
13146
+ if (scrollTop >= nextTop) {
13147
+ current += 1;
13148
+ }
13149
+ if (scrollTop < monthsData[current].scrollTop) {
13150
+ current -= 1;
13151
+ }
13152
+ } else {
13153
+ const viewPosition = Math.round(scrollTop + viewHeight);
13154
+ if (current + 1 <= monthsNum && viewPosition >= nextTop + nextHeight) {
13155
+ current += 1;
13156
+ }
13157
+ if (current >= 1 && scrollTop < monthsData[current - 1].scrollTop) {
13158
+ current -= 1;
13159
+ }
13160
+ }
13161
+ setDefaultRange(monthsNum, current);
13162
+ };
13163
+ React__default.useImperativeHandle(ref, () => ({
13164
+ scrollToDate
13165
+ }));
13166
+ const getClasses = (day, month) => {
13167
+ const dateStr = getCurrDate(day, month);
13168
+ if (day.type === "active") {
13169
+ if (propStartDate && Utils.compareDate(dateStr, propStartDate) || propEndDate && Utils.compareDate(propEndDate, dateStr)) {
13170
+ return `${dayPrefix}-disabled`;
13171
+ }
13172
+ if (type4 === "range" || type4 === "week") {
13173
+ if (isStart(dateStr, currentDate) || isEnd(dateStr, currentDate)) {
13174
+ return `${dayPrefix}-active ${isStart(dateStr, currentDate) ? "active-start" : ""} ${isEnd(dateStr, currentDate) ? "active-end" : ""}`;
13175
+ }
13176
+ if (Array.isArray(currentDate) && Object.values(currentDate).length === 2 && Utils.compareDate(currentDate[0], dateStr) && Utils.compareDate(dateStr, currentDate[1])) {
13177
+ return `${dayPrefix}-choose`;
13178
+ }
13179
+ return null;
13180
+ }
13181
+ if (type4 === "multiple" && isMultiple(dateStr, currentDate) || !Array.isArray(currentDate) && Utils.isEqual(currentDate, dateStr)) {
13182
+ return `${dayPrefix}-active`;
13183
+ }
13184
+ return null;
13185
+ }
13186
+ return `${dayPrefix}-disabled`;
13187
+ };
13141
13188
  const chooseDay = (day, month, isFirst) => {
13142
13189
  if (getClasses(day, month) === `${dayPrefix}-disabled`) {
13143
13190
  return;
13144
13191
  }
13145
13192
  const days = [...month.curData];
13193
+ const [y2, m] = month.curData;
13146
13194
  days[2] = typeof day.day === "number" ? Utils.getNumTwoBit(day.day) : day.day;
13147
13195
  days[3] = `${days[0]}/${days[1]}/${days[2]}`;
13148
13196
  days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
@@ -13179,67 +13227,109 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
13179
13227
  Array.isArray(currentDate) && currentDate.unshift(days[3]);
13180
13228
  state.currDateArray = [[...days], ...state.currDateArray];
13181
13229
  }
13230
+ } else if (type4 === "week") {
13231
+ const weekArr = Utils.getWeekDate(y2, m, `${day.day}`, firstDayOfWeek);
13232
+ if (propStartDate && Utils.compareDate(weekArr[0], propStartDate)) {
13233
+ weekArr.splice(0, 1, propStartDate);
13234
+ }
13235
+ if (propEndDate && Utils.compareDate(propEndDate, weekArr[1])) {
13236
+ weekArr.splice(1, 1, propEndDate);
13237
+ }
13238
+ Array.isArray(currentDate) && currentDate.splice(0) && currentDate.push(...weekArr);
13239
+ state.currDateArray = [
13240
+ Utils.formatResultDate(weekArr[0]),
13241
+ Utils.formatResultDate(weekArr[1])
13242
+ ];
13182
13243
  } else {
13183
13244
  setCurrentDate(days[3]);
13184
13245
  state.currDateArray = [...days];
13185
13246
  }
13186
13247
  if (!isFirst) {
13187
- onClickDay && onClickDay(state.currDateArray);
13248
+ onDayClick && onDayClick(state.currDateArray);
13188
13249
  if (autoBackfill || !popup) {
13189
13250
  confirm2();
13190
13251
  }
13191
13252
  }
13192
13253
  setMonthsData(monthsData.slice());
13193
13254
  };
13194
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: classes }, /* @__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)))), /* @__PURE__ */ React__default.createElement(
13195
- "div",
13255
+ const confirm2 = () => {
13256
+ if (type4 === "range" && state.currDateArray.length === 2 || type4 !== "range") {
13257
+ const chooseData = state.currDateArray.slice(0);
13258
+ onConfirm && onConfirm(chooseData);
13259
+ if (popup) {
13260
+ onUpdate && onUpdate();
13261
+ }
13262
+ }
13263
+ };
13264
+ const classes = classNames(
13196
13265
  {
13197
- className: `${classPrefix2}-content`,
13198
- onScroll: monthsViewScroll,
13199
- ref: monthsRef
13266
+ [`${classPrefix2}-title`]: !popup,
13267
+ [`${classPrefix2}-nofooter`]: !!autoBackfill
13200
13268
  },
13201
- /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-pannel`, ref: monthsPanel }, /* @__PURE__ */ React__default.createElement(
13269
+ classPrefix2
13270
+ );
13271
+ const headerClasses = classNames({
13272
+ [`${classPrefix2}-header`]: true,
13273
+ [`${classPrefix2}-header-title`]: !popup
13274
+ });
13275
+ const isStartTip = (day, month) => {
13276
+ return (type4 === "range" || type4 === "week") && day.type === "active" && isStart(getCurrDate(day, month), currentDate);
13277
+ };
13278
+ const isEndTip = (day, month) => {
13279
+ return currentDate.length >= 2 && (type4 === "range" || type4 === "week") && day.type === "active" && isEnd(getCurrDate(day, month), currentDate);
13280
+ };
13281
+ const renderHeader = () => {
13282
+ 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))));
13283
+ };
13284
+ const renderContent = () => {
13285
+ return /* @__PURE__ */ React__default.createElement(
13202
13286
  "div",
13203
13287
  {
13204
- className: "viewArea",
13205
- ref: viewAreaRef,
13206
- style: { transform: `translateY(${translateY}px)` }
13288
+ className: `${classPrefix2}-content`,
13289
+ onScroll: monthsViewScroll,
13290
+ ref: monthsRef
13207
13291
  },
13208
- monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map((month, key) => {
13209
- 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, i) => /* @__PURE__ */ React__default.createElement(
13210
- "div",
13211
- {
13212
- className: [
13213
- `${classPrefix2}-day`,
13214
- getClasses(day, month)
13215
- ].join(" "),
13216
- onClick: () => {
13217
- chooseDay(day, month);
13218
- },
13219
- key: i
13220
- },
13221
- /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
13222
- !isStartTip(day, month) && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
13223
- !isStartTip(day, month) && !isEndTip(day, month) && renderDayBottom && /* @__PURE__ */ React__default.createElement(
13224
- "div",
13225
- {
13226
- className: `${classPrefix2}-day-info-bottom`
13227
- },
13228
- renderDayBottom(day)
13229
- ),
13230
- !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),
13231
- isStartTip(day, month) && /* @__PURE__ */ React__default.createElement(
13292
+ /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-pannel`, ref: monthsPanel }, /* @__PURE__ */ React__default.createElement(
13293
+ "div",
13294
+ {
13295
+ className: "viewArea",
13296
+ ref: viewAreaRef,
13297
+ style: { transform: `translateY(${translateY}px)` }
13298
+ },
13299
+ monthsData.slice(monthDefaultRange[0], monthDefaultRange[1]).map((month, key) => {
13300
+ 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, i) => /* @__PURE__ */ React__default.createElement(
13232
13301
  "div",
13233
13302
  {
13234
- className: `${classPrefix2}-day-info ${isStartAndEnd() ? `${classPrefix2}-day-info-top` : ""}`
13303
+ className: [
13304
+ `${classPrefix2}-day`,
13305
+ getClasses(day, month)
13306
+ ].join(" "),
13307
+ onClick: () => {
13308
+ chooseDay(day, month);
13309
+ },
13310
+ key: i
13235
13311
  },
13236
- startText || locale.calendaritem.start
13237
- ),
13238
- isEndTip(day, month) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
13239
- ))));
13240
- })
13241
- ))
13242
- ), popup && !autoBackfill ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-calendar-footer" }, /* @__PURE__ */ React__default.createElement("div", { className: "calendar-confirm-btn", onClick: confirm2 }, confirmText || locale.confirm)) : ""));
13312
+ /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-day` }, renderDay ? renderDay(day) : day.day),
13313
+ !isStartTip(day, month) && renderDayTop && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-top` }, renderDayTop(day)),
13314
+ !isStartTip(day, month) && !isEndTip(day, month) && renderDayBottom && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info-bottom` }, renderDayBottom(day)),
13315
+ !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),
13316
+ isStartTip(day, month) && /* @__PURE__ */ React__default.createElement(
13317
+ "div",
13318
+ {
13319
+ className: `${classPrefix2}-day-info ${isStartAndEnd(currentDate) ? `${classPrefix2}-day-info-top` : ""}`
13320
+ },
13321
+ startText || locale.calendaritem.start
13322
+ ),
13323
+ isEndTip(day, month) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-day-info` }, endText || locale.calendaritem.end)
13324
+ ))));
13325
+ })
13326
+ ))
13327
+ );
13328
+ };
13329
+ const renderFooter = () => {
13330
+ return /* @__PURE__ */ React__default.createElement("div", { className: "nut-calendar-footer" }, /* @__PURE__ */ React__default.createElement("div", { className: "calendar-confirm-btn", onClick: confirm2 }, confirmText || locale.confirm));
13331
+ };
13332
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: classes }, renderHeader(), renderContent(), popup && !autoBackfill ? renderFooter() : ""));
13243
13333
  });
13244
13334
  CalendarItem.defaultProps = defaultProps$_;
13245
13335
  CalendarItem.displayName = "NutCalendarItem";
@@ -13259,6 +13349,7 @@ const defaultProps$Z = {
13259
13349
  showTitle: true,
13260
13350
  showSubTitle: true,
13261
13351
  scrollAnimation: true,
13352
+ firstDayOfWeek: 0,
13262
13353
  renderHeaderButtons: void 0,
13263
13354
  renderDay: void 0,
13264
13355
  renderDayTop: void 0,
@@ -13267,7 +13358,7 @@ const defaultProps$Z = {
13267
13358
  },
13268
13359
  onConfirm: (param) => {
13269
13360
  },
13270
- onClickDay: (data) => {
13361
+ onDayClick: (data) => {
13271
13362
  },
13272
13363
  onPageChange: (param) => {
13273
13364
  }
@@ -13290,13 +13381,14 @@ const Calendar = React__default.forwardRef((props, ref) => {
13290
13381
  showTitle,
13291
13382
  showSubTitle,
13292
13383
  scrollAnimation,
13384
+ firstDayOfWeek,
13293
13385
  renderHeaderButtons,
13294
13386
  renderDay,
13295
13387
  renderDayTop,
13296
13388
  renderDayBottom,
13297
13389
  onClose,
13298
13390
  onConfirm,
13299
- onClickDay,
13391
+ onDayClick,
13300
13392
  onPageChange
13301
13393
  } = { ...defaultProps$Z, ...props };
13302
13394
  const calendarRef = useRef(null);
@@ -13311,7 +13403,7 @@ const Calendar = React__default.forwardRef((props, ref) => {
13311
13403
  close();
13312
13404
  };
13313
13405
  const select = (param) => {
13314
- onClickDay && onClickDay(param);
13406
+ onDayClick && onDayClick(param);
13315
13407
  };
13316
13408
  const scrollToDate = (date4) => {
13317
13409
  var _a2;
@@ -13342,12 +13434,13 @@ const Calendar = React__default.forwardRef((props, ref) => {
13342
13434
  showTitle,
13343
13435
  showSubTitle,
13344
13436
  scrollAnimation,
13437
+ firstDayOfWeek,
13345
13438
  renderHeaderButtons,
13346
13439
  renderDay,
13347
13440
  renderDayTop,
13348
13441
  renderDayBottom,
13349
13442
  onConfirm: choose,
13350
- onClickDay: select,
13443
+ onDayClick: select,
13351
13444
  onPageChange: yearMonthChange
13352
13445
  }
13353
13446
  );
@@ -13361,8 +13454,8 @@ const Calendar = React__default.forwardRef((props, ref) => {
13361
13454
  duration: 0.5,
13362
13455
  closeable: true,
13363
13456
  destroyOnClose: true,
13364
- onClickOverlay: closePopup,
13365
- onClickCloseIcon: closePopup,
13457
+ onOverlayClick: closePopup,
13458
+ onCloseIconClick: closePopup,
13366
13459
  style: { height: "85vh" }
13367
13460
  },
13368
13461
  renderItem()
@@ -15832,7 +15925,7 @@ const Form = (props) => {
15832
15925
  resetFields();
15833
15926
  }
15834
15927
  },
15835
- /* @__PURE__ */ React__default.createElement(CellGroup, null, /* @__PURE__ */ React__default.createElement(Context.Provider, { value: formInstance }, children), footer ? /* @__PURE__ */ React__default.createElement(Cell, null, footer) : null)
15928
+ /* @__PURE__ */ React__default.createElement(Cell.Group, null, /* @__PURE__ */ React__default.createElement(Context.Provider, { value: formInstance }, children), footer ? /* @__PURE__ */ React__default.createElement(Cell, null, footer) : null)
15836
15929
  );
15837
15930
  };
15838
15931
  Form.defaultProps = defaultProps$T;
@@ -16279,149 +16372,6 @@ const InputNumber = (props) => {
16279
16372
  };
16280
16373
  InputNumber.defaultProps = defaultProps$R;
16281
16374
  InputNumber.displayName = "NutInputNumber";
16282
- const defaultProps$Q = {
16283
- ...ComponentDefaults,
16284
- activeColor: "",
16285
- closeOnOverlayClick: true,
16286
- scrollFixed: false,
16287
- lockScroll: true,
16288
- icon: null
16289
- };
16290
- const Menu = (props) => {
16291
- const {
16292
- className,
16293
- icon,
16294
- scrollFixed,
16295
- lockScroll,
16296
- closeOnOverlayClick,
16297
- children,
16298
- activeColor,
16299
- ...rest
16300
- } = {
16301
- ...defaultProps$Q,
16302
- ...props
16303
- };
16304
- const menuRef = useRef(null);
16305
- const [isScrollFixed, setIsScrollFixed] = useState(false);
16306
- const getScrollTop = (el) => {
16307
- return Math.max(0, "scrollTop" in el ? el.scrollTop : el.pageYOffset);
16308
- };
16309
- const onScroll = () => {
16310
- const { scrollFixed: scrollFixed2 } = props;
16311
- const scrollTop = getScrollTop(window);
16312
- const isFixed = scrollTop > (typeof scrollFixed2 === "boolean" ? 30 : Number(scrollFixed2));
16313
- setIsScrollFixed(isFixed);
16314
- };
16315
- useEffect(() => {
16316
- if (scrollFixed) {
16317
- window.addEventListener("scroll", onScroll);
16318
- }
16319
- return () => window.removeEventListener("scroll", onScroll);
16320
- }, []);
16321
- const [showMenuItem, setShowMenuItem] = useState([]);
16322
- const [menuItemTitle, setMenuItemTitle] = useState([]);
16323
- const toggleMenuItem = (index) => {
16324
- showMenuItem[index] = !showMenuItem[index];
16325
- const temp = showMenuItem.map(
16326
- (i, idx) => idx === index ? i : false
16327
- );
16328
- setShowMenuItem([...temp]);
16329
- };
16330
- const hideMenuItem = (index) => {
16331
- showMenuItem[index] = false;
16332
- console.log([...showMenuItem]);
16333
- setShowMenuItem([...showMenuItem]);
16334
- };
16335
- const updateTitle = (text, index) => {
16336
- menuItemTitle[index] = text;
16337
- setMenuItemTitle([...menuItemTitle]);
16338
- };
16339
- const cloneChildren = () => {
16340
- return React__default.Children.map(children, (child, index) => {
16341
- return React__default.cloneElement(child, {
16342
- ...child.props,
16343
- show: showMenuItem[index],
16344
- index,
16345
- activeColor,
16346
- parent: {
16347
- closeOnOverlayClick,
16348
- lockScroll,
16349
- toggleMenuItem,
16350
- updateTitle,
16351
- hideMenuItem,
16352
- menuRef
16353
- }
16354
- });
16355
- });
16356
- };
16357
- const menuTitle = () => {
16358
- return React__default.Children.map(children, (child, index) => {
16359
- if (React__default.isValidElement(child)) {
16360
- const { title, options: options2, value, disabled, direction } = child.props;
16361
- const selected = options2 == null ? void 0 : options2.filter(
16362
- (option) => option.value === value
16363
- );
16364
- const finallyTitle = () => {
16365
- if (title)
16366
- return title;
16367
- if (menuItemTitle && menuItemTitle[index])
16368
- return menuItemTitle[index];
16369
- if (selected && selected.length && selected[0].text)
16370
- return selected[0].text;
16371
- return "";
16372
- };
16373
- return /* @__PURE__ */ React__default.createElement(
16374
- "div",
16375
- {
16376
- className: classNames("nut-menu__item ", className, {
16377
- active: showMenuItem[index],
16378
- disabled
16379
- }),
16380
- style: { color: showMenuItem[index] ? activeColor : "" },
16381
- key: index,
16382
- onClick: (e) => {
16383
- e.stopPropagation();
16384
- !disabled && toggleMenuItem(index);
16385
- }
16386
- },
16387
- /* @__PURE__ */ React__default.createElement(
16388
- "div",
16389
- {
16390
- className: classNames("nut-menu__title ", {
16391
- active: showMenuItem[index],
16392
- disabled
16393
- })
16394
- },
16395
- /* @__PURE__ */ React__default.createElement("div", { className: "nut-menu__title-text" }, finallyTitle()),
16396
- icon || (direction === "up" ? /* @__PURE__ */ React__default.createElement(x$h, { className: "nut-menu__title-icon" }) : /* @__PURE__ */ React__default.createElement(y$9, { className: "nut-menu__title-icon" }))
16397
- )
16398
- );
16399
- }
16400
- return null;
16401
- });
16402
- };
16403
- return /* @__PURE__ */ React__default.createElement(
16404
- "div",
16405
- {
16406
- ...rest,
16407
- className: classNames(`nut-menu`, className, {
16408
- "scroll-fixed": isScrollFixed
16409
- }),
16410
- ref: menuRef
16411
- },
16412
- /* @__PURE__ */ React__default.createElement("div", { className: "nut-menu-relative" }, /* @__PURE__ */ React__default.createElement(
16413
- "div",
16414
- {
16415
- className: classNames("nut-menu__bar", {
16416
- opened: showMenuItem.includes(true)
16417
- })
16418
- },
16419
- menuTitle()
16420
- ), cloneChildren())
16421
- );
16422
- };
16423
- Menu.defaultProps = defaultProps$Q;
16424
- Menu.displayName = "NutMenu";
16425
16375
  const isObject = (val) => val !== null && typeof val === "object";
16426
16376
  const isFunction = (val) => typeof val === "function";
16427
16377
  const isPromise = (val) => {
@@ -16462,7 +16412,7 @@ function useClickAway(onClickAway, target, eventName = "click", useCapture, isLi
16462
16412
  };
16463
16413
  }, [target]);
16464
16414
  }
16465
- const defaultProps$P = {
16415
+ const defaultProps$Q = {
16466
16416
  ...ComponentDefaults,
16467
16417
  columns: 1,
16468
16418
  direction: "down",
@@ -16491,7 +16441,7 @@ const MenuItem = forwardRef((props, ref) => {
16491
16441
  parent,
16492
16442
  index
16493
16443
  } = {
16494
- ...defaultProps$P,
16444
+ ...defaultProps$Q,
16495
16445
  ...props
16496
16446
  };
16497
16447
  const [_showPopup, setShowPopup] = useState(show2);
@@ -16623,12 +16573,155 @@ const MenuItem = forwardRef((props, ref) => {
16623
16573
  )
16624
16574
  );
16625
16575
  });
16626
- MenuItem.defaultProps = defaultProps$P;
16576
+ MenuItem.defaultProps = defaultProps$Q;
16627
16577
  MenuItem.displayName = "NutMenuItem";
16628
- const defaultProps$O = {
16578
+ const defaultProps$P = {
16629
16579
  ...ComponentDefaults,
16630
- visible: false,
16631
- type: "default",
16580
+ activeColor: "",
16581
+ closeOnOverlayClick: true,
16582
+ scrollFixed: false,
16583
+ lockScroll: true,
16584
+ icon: null
16585
+ };
16586
+ const Menu = (props) => {
16587
+ const {
16588
+ className,
16589
+ icon,
16590
+ scrollFixed,
16591
+ lockScroll,
16592
+ closeOnOverlayClick,
16593
+ children,
16594
+ activeColor,
16595
+ ...rest
16596
+ } = {
16597
+ ...defaultProps$P,
16598
+ ...props
16599
+ };
16600
+ const menuRef = useRef(null);
16601
+ const [isScrollFixed, setIsScrollFixed] = useState(false);
16602
+ const getScrollTop = (el) => {
16603
+ return Math.max(0, "scrollTop" in el ? el.scrollTop : el.pageYOffset);
16604
+ };
16605
+ const onScroll = () => {
16606
+ const { scrollFixed: scrollFixed2 } = props;
16607
+ const scrollTop = getScrollTop(window);
16608
+ const isFixed = scrollTop > (typeof scrollFixed2 === "boolean" ? 30 : Number(scrollFixed2));
16609
+ setIsScrollFixed(isFixed);
16610
+ };
16611
+ useEffect(() => {
16612
+ if (scrollFixed) {
16613
+ window.addEventListener("scroll", onScroll);
16614
+ }
16615
+ return () => window.removeEventListener("scroll", onScroll);
16616
+ }, []);
16617
+ const [showMenuItem, setShowMenuItem] = useState([]);
16618
+ const [menuItemTitle, setMenuItemTitle] = useState([]);
16619
+ const toggleMenuItem = (index) => {
16620
+ showMenuItem[index] = !showMenuItem[index];
16621
+ const temp = showMenuItem.map(
16622
+ (i, idx) => idx === index ? i : false
16623
+ );
16624
+ setShowMenuItem([...temp]);
16625
+ };
16626
+ const hideMenuItem = (index) => {
16627
+ showMenuItem[index] = false;
16628
+ setShowMenuItem([...showMenuItem]);
16629
+ };
16630
+ const updateTitle = (text, index) => {
16631
+ menuItemTitle[index] = text;
16632
+ setMenuItemTitle([...menuItemTitle]);
16633
+ };
16634
+ const cloneChildren = () => {
16635
+ return React__default.Children.map(children, (child, index) => {
16636
+ return React__default.cloneElement(child, {
16637
+ ...child.props,
16638
+ show: showMenuItem[index],
16639
+ index,
16640
+ activeColor,
16641
+ parent: {
16642
+ closeOnOverlayClick,
16643
+ lockScroll,
16644
+ toggleMenuItem,
16645
+ updateTitle,
16646
+ hideMenuItem,
16647
+ menuRef
16648
+ }
16649
+ });
16650
+ });
16651
+ };
16652
+ const menuTitle = () => {
16653
+ return React__default.Children.map(children, (child, index) => {
16654
+ if (React__default.isValidElement(child)) {
16655
+ const { title, options: options2, value, disabled, direction } = child.props;
16656
+ const selected = options2 == null ? void 0 : options2.filter(
16657
+ (option) => option.value === value
16658
+ );
16659
+ const finallyTitle = () => {
16660
+ if (title)
16661
+ return title;
16662
+ if (menuItemTitle && menuItemTitle[index])
16663
+ return menuItemTitle[index];
16664
+ if (selected && selected.length && selected[0].text)
16665
+ return selected[0].text;
16666
+ return "";
16667
+ };
16668
+ return /* @__PURE__ */ React__default.createElement(
16669
+ "div",
16670
+ {
16671
+ className: classNames("nut-menu__item ", className, {
16672
+ active: showMenuItem[index],
16673
+ disabled
16674
+ }),
16675
+ style: { color: showMenuItem[index] ? activeColor : "" },
16676
+ key: index,
16677
+ onClick: (e) => {
16678
+ e.stopPropagation();
16679
+ !disabled && toggleMenuItem(index);
16680
+ }
16681
+ },
16682
+ /* @__PURE__ */ React__default.createElement(
16683
+ "div",
16684
+ {
16685
+ className: classNames("nut-menu__title ", {
16686
+ active: showMenuItem[index],
16687
+ disabled
16688
+ })
16689
+ },
16690
+ /* @__PURE__ */ React__default.createElement("div", { className: "nut-menu__title-text" }, finallyTitle()),
16691
+ icon || (direction === "up" ? /* @__PURE__ */ React__default.createElement(x$h, { className: "nut-menu__title-icon" }) : /* @__PURE__ */ React__default.createElement(y$9, { className: "nut-menu__title-icon" }))
16692
+ )
16693
+ );
16694
+ }
16695
+ return null;
16696
+ });
16697
+ };
16698
+ return /* @__PURE__ */ React__default.createElement(
16699
+ "div",
16700
+ {
16701
+ ...rest,
16702
+ className: classNames(`nut-menu`, className, {
16703
+ "scroll-fixed": isScrollFixed
16704
+ }),
16705
+ ref: menuRef
16706
+ },
16707
+ /* @__PURE__ */ React__default.createElement("div", { className: "nut-menu-relative" }, /* @__PURE__ */ React__default.createElement(
16708
+ "div",
16709
+ {
16710
+ className: classNames("nut-menu__bar", {
16711
+ opened: showMenuItem.includes(true)
16712
+ })
16713
+ },
16714
+ menuTitle()
16715
+ ), cloneChildren())
16716
+ );
16717
+ };
16718
+ Menu.defaultProps = defaultProps$P;
16719
+ Menu.displayName = "NutMenu";
16720
+ Menu.Item = MenuItem;
16721
+ const defaultProps$O = {
16722
+ ...ComponentDefaults,
16723
+ visible: false,
16724
+ type: "default",
16632
16725
  custom: [],
16633
16726
  random: false,
16634
16727
  onClose: () => {
@@ -16741,8 +16834,8 @@ const NumberKeyboard = (props) => {
16741
16834
  {
16742
16835
  visible,
16743
16836
  position: "bottom",
16744
- onClickOverlay: onClose,
16745
- onClickCloseIcon: onClose,
16837
+ onOverlayClick: onClose,
16838
+ onCloseIconClick: onClose,
16746
16839
  overlayStyle: { backgroundColor: "rgba(0, 0, 0, 0)" },
16747
16840
  ...rest
16748
16841
  },
@@ -17420,7 +17513,7 @@ const SearchBar = (props) => {
17420
17513
  onBlur,
17421
17514
  onClear,
17422
17515
  onSearch,
17423
- onClickInput
17516
+ onInputClick
17424
17517
  } = {
17425
17518
  ...defaultProps$J,
17426
17519
  ...props
@@ -17471,7 +17564,7 @@ const SearchBar = (props) => {
17471
17564
  );
17472
17565
  };
17473
17566
  const clickInput = (e) => {
17474
- onClickInput && onClickInput(e);
17567
+ onInputClick && onInputClick(e);
17475
17568
  };
17476
17569
  const renderLeftIn = () => {
17477
17570
  if (!leftIn)
@@ -17575,8 +17668,8 @@ const ShortPassword = (props) => {
17575
17668
  onCancel,
17576
17669
  onClose,
17577
17670
  onComplete,
17578
- onClickOverlay,
17579
- onClickCloseIcon,
17671
+ onOverlayClick,
17672
+ onCloseIconClick,
17580
17673
  ...rest
17581
17674
  } = {
17582
17675
  ...defaultProps$I,
@@ -17615,8 +17708,8 @@ const ShortPassword = (props) => {
17615
17708
  },
17616
17709
  visible,
17617
17710
  closeable: true,
17618
- onClickOverlay: onClose,
17619
- onClickCloseIcon: onClose,
17711
+ onOverlayClick: onClose,
17712
+ onCloseIconClick: onClose,
17620
17713
  ...rest
17621
17714
  },
17622
17715
  /* @__PURE__ */ React__default.createElement("div", { className: classNames(className, classPrefix2), style }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__title` }, title || locale.shortpassword.title), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__description` }, description || locale.shortpassword.description), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__input`, onClick: onFocus }, /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__input-site` }), /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__input-fake` }, [...new Array(comLen).keys()].map((item, index) => {
@@ -18126,7 +18219,7 @@ const defaultProps$D = {
18126
18219
  url: "",
18127
18220
  maxCount: 1,
18128
18221
  previewType: "picture",
18129
- imageFit: "cover",
18222
+ fit: "cover",
18130
18223
  name: "file",
18131
18224
  accept: "*",
18132
18225
  disabled: false,
@@ -18171,7 +18264,7 @@ const InternalUploader = (props, ref) => {
18171
18264
  defaultValue,
18172
18265
  value,
18173
18266
  previewType,
18174
- imageFit,
18267
+ fit,
18175
18268
  disabled,
18176
18269
  multiple,
18177
18270
  url: url2,
@@ -18463,7 +18556,7 @@ const InternalUploader = (props, ref) => {
18463
18556
  "img",
18464
18557
  {
18465
18558
  className: "nut-uploader__preview-img__c",
18466
- style: { objectFit: imageFit },
18559
+ style: { objectFit: fit },
18467
18560
  src: item.url,
18468
18561
  alt: "",
18469
18562
  onClick: () => handleItemClick(item)
@@ -18578,7 +18671,7 @@ const ActionSheet = (props) => {
18578
18671
  onCancel && onCancel();
18579
18672
  };
18580
18673
  const chooseItem = (item, index) => {
18581
- if (!item.disable) {
18674
+ if (!item.disabled) {
18582
18675
  onSelect && onSelect(item, index);
18583
18676
  }
18584
18677
  };
@@ -18598,7 +18691,7 @@ const ActionSheet = (props) => {
18598
18691
  return /* @__PURE__ */ React__default.createElement(
18599
18692
  "div",
18600
18693
  {
18601
- className: `${classPrefix2}__item ${item.disable ? "disabled" : ""} ${item.danger ? "danger" : ""}`,
18694
+ className: `${classPrefix2}__item ${item.disabled ? "disabled" : ""} ${item.danger ? "danger" : ""}`,
18602
18695
  key: index,
18603
18696
  onClick: () => chooseItem(item, index)
18604
18697
  },
@@ -19280,7 +19373,7 @@ const NoticeBar = (props) => {
19280
19373
  click,
19281
19374
  onClose,
19282
19375
  onClick,
19283
- onClickItem
19376
+ onItemClick
19284
19377
  } = {
19285
19378
  ...defaultProps$x,
19286
19379
  ...props
@@ -19511,7 +19604,7 @@ const NoticeBar = (props) => {
19511
19604
  });
19512
19605
  };
19513
19606
  const handleItemClick = (event, value) => {
19514
- onClickItem && onClickItem(event, value);
19607
+ onItemClick && onItemClick(event, value);
19515
19608
  };
19516
19609
  const getStyle = (moveOffset = offset) => {
19517
19610
  const target = innerRef.current;
@@ -19805,10 +19898,9 @@ const defaultProps$w = {
19805
19898
  visible: false,
19806
19899
  offset: [0, 12],
19807
19900
  targetId: "",
19808
- className: "",
19809
19901
  showArrow: true,
19810
- closeOnClickOutside: true,
19811
- closeOnClickAction: true,
19902
+ closeOnOutsideClick: true,
19903
+ closeOnActionClick: true,
19812
19904
  overlay: false,
19813
19905
  onClick: () => {
19814
19906
  },
@@ -19827,8 +19919,8 @@ const Popover = (props) => {
19827
19919
  offset,
19828
19920
  targetId,
19829
19921
  overlay,
19830
- closeOnClickOutside,
19831
- closeOnClickAction,
19922
+ closeOnOutsideClick,
19923
+ closeOnActionClick,
19832
19924
  className,
19833
19925
  showArrow,
19834
19926
  style,
@@ -19868,7 +19960,7 @@ const Popover = (props) => {
19868
19960
  "touchstart",
19869
19961
  true,
19870
19962
  visible,
19871
- closeOnClickOutside
19963
+ closeOnOutsideClick
19872
19964
  );
19873
19965
  const getContentWidth = () => {
19874
19966
  let rect = getRect(popoverRef.current);
@@ -19962,7 +20054,7 @@ const Popover = (props) => {
19962
20054
  if (!item.disabled) {
19963
20055
  onSelect && onSelect(item, index);
19964
20056
  }
19965
- if (closeOnClickAction) {
20057
+ if (closeOnActionClick) {
19966
20058
  props.onClick && props.onClick();
19967
20059
  onClose && onClose();
19968
20060
  }
@@ -20214,6 +20306,29 @@ PullToRefresh.defaultProps = defaultProps$v;
20214
20306
  PullToRefresh.displayName = "NutPullToRefresh";
20215
20307
  const AvatarContext = createContext({});
20216
20308
  const defaultProps$u = {
20309
+ ...ComponentDefaults,
20310
+ maxContent: "",
20311
+ max: "",
20312
+ maxBackground: "#eee",
20313
+ maxColor: "#666",
20314
+ gap: "-8",
20315
+ level: "left"
20316
+ };
20317
+ const classPrefix$8 = `nut-avatar-group`;
20318
+ const AvatarGroup = (props) => {
20319
+ const propAvatarGroup = { ...defaultProps$u, ...props };
20320
+ const { className, style, children } = propAvatarGroup;
20321
+ const avatarGroupRef = useRef(null);
20322
+ const cls = classNames(classPrefix$8, className);
20323
+ const parentAvatar = {
20324
+ propAvatarGroup,
20325
+ avatarGroupRef
20326
+ };
20327
+ return /* @__PURE__ */ React__default.createElement(AvatarContext.Provider, { value: parentAvatar }, /* @__PURE__ */ React__default.createElement("div", { className: cls, style, ref: avatarGroupRef }, children));
20328
+ };
20329
+ AvatarGroup.defaultProps = defaultProps$u;
20330
+ AvatarGroup.displayName = "NutAvatarGroup";
20331
+ const defaultProps$t = {
20217
20332
  ...ComponentDefaults,
20218
20333
  size: "",
20219
20334
  shape: "round",
@@ -20224,7 +20339,7 @@ const defaultProps$u = {
20224
20339
  src: "",
20225
20340
  alt: ""
20226
20341
  };
20227
- const classPrefix$8 = `nut-avatar`;
20342
+ const classPrefix$7 = `nut-avatar`;
20228
20343
  const Avatar = (props) => {
20229
20344
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
20230
20345
  const {
@@ -20243,7 +20358,7 @@ const Avatar = (props) => {
20243
20358
  onError,
20244
20359
  ...rest
20245
20360
  } = {
20246
- ...defaultProps$u,
20361
+ ...defaultProps$t,
20247
20362
  ...props
20248
20363
  };
20249
20364
  const [maxSum, setMaxSum] = useState(0);
@@ -20256,7 +20371,7 @@ const Avatar = (props) => {
20256
20371
  [`nut-avatar-${((_a2 = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _a2.size) || size || "normal"}`]: true,
20257
20372
  [`nut-avatar-${((_b = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _b.shape) || shape}`]: true
20258
20373
  });
20259
- const cls = classNames(classPrefix$8, classes, className);
20374
+ const cls = classNames(classPrefix$7, classes, className);
20260
20375
  const styles = {
20261
20376
  width: sizeValue.indexOf(size) > -1 ? "" : `${size}px`,
20262
20377
  height: sizeValue.indexOf(size) > -1 ? "" : `${size}px`,
@@ -20325,9 +20440,10 @@ const Avatar = (props) => {
20325
20440
  showMax && /* @__PURE__ */ React__default.createElement("div", { className: "text" }, ((_l = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _l.maxContent) ? (_m = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _m.maxContent : `+ ${avatarIndex - ((_n = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _n.max)}`)
20326
20441
  ));
20327
20442
  };
20328
- Avatar.defaultProps = defaultProps$u;
20443
+ Avatar.defaultProps = defaultProps$t;
20329
20444
  Avatar.displayName = "NutAvatar";
20330
- const defaultProps$t = {
20445
+ Avatar.Group = AvatarGroup;
20446
+ const defaultProps$s = {
20331
20447
  ...ComponentDefaults,
20332
20448
  rows: 1,
20333
20449
  animated: false,
@@ -20350,7 +20466,7 @@ const Skeleton = (props) => {
20350
20466
  avatarShape,
20351
20467
  ...rest
20352
20468
  } = {
20353
- ...defaultProps$t,
20469
+ ...defaultProps$s,
20354
20470
  ...props
20355
20471
  };
20356
20472
  const classPrefix2 = "nut-skeleton";
@@ -20386,7 +20502,7 @@ const Skeleton = (props) => {
20386
20502
  return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__block`, key: index });
20387
20503
  })))));
20388
20504
  };
20389
- Skeleton.defaultProps = defaultProps$t;
20505
+ Skeleton.defaultProps = defaultProps$s;
20390
20506
  Skeleton.displayName = "NutSkeleton";
20391
20507
  function preventDefault(event, isStopPropagation) {
20392
20508
  if (typeof event.cancelable !== "boolean" || event.cancelable) {
@@ -20396,13 +20512,13 @@ function preventDefault(event, isStopPropagation) {
20396
20512
  event.stopPropagation();
20397
20513
  }
20398
20514
  }
20399
- const defaultProps$s = {
20515
+ const defaultProps$r = {
20400
20516
  name: ""
20401
20517
  };
20402
20518
  const Swipe = forwardRef((props, instanceRef) => {
20403
20519
  const classPrefix2 = "nut-swipe";
20404
20520
  const touch = useTouch();
20405
- const { children, className, style } = { ...defaultProps$s, ...props };
20521
+ const { children, className, style } = { ...defaultProps$r, ...props };
20406
20522
  const root2 = useRef();
20407
20523
  const opened = useRef(false);
20408
20524
  const lockClick = useRef(false);
@@ -20570,9 +20686,9 @@ const Swipe = forwardRef((props, instanceRef) => {
20570
20686
  /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__wrapper`, style: wrapperStyle }, renderActionContent("left", leftRef), children, renderActionContent("right", rightRef))
20571
20687
  );
20572
20688
  });
20573
- Swipe.defaultProps = defaultProps$s;
20689
+ Swipe.defaultProps = defaultProps$r;
20574
20690
  Swipe.displayName = "NutSwipe";
20575
- const classPrefix$7 = "nut-toast";
20691
+ const classPrefix$6 = "nut-toast";
20576
20692
  class Notification extends React.PureComponent {
20577
20693
  constructor(props) {
20578
20694
  super(props);
@@ -20634,7 +20750,7 @@ class Notification extends React.PureComponent {
20634
20750
  iconNode = /* @__PURE__ */ React.createElement(x$8, null);
20635
20751
  break;
20636
20752
  }
20637
- return /* @__PURE__ */ React.createElement("p", { className: `${classPrefix$7}__icon-wrapper` }, iconNode);
20753
+ return /* @__PURE__ */ React.createElement("p", { className: `${classPrefix$6}__icon-wrapper` }, iconNode);
20638
20754
  }
20639
20755
  return icon;
20640
20756
  }
@@ -20669,22 +20785,22 @@ class Notification extends React.PureComponent {
20669
20785
  {
20670
20786
  visible: show2,
20671
20787
  style,
20672
- className: `${classPrefix$7}__overlay-default ${className}`,
20788
+ className: `${classPrefix$6}__overlay-default ${className}`,
20673
20789
  onClick: () => {
20674
20790
  this.clickCover();
20675
20791
  },
20676
20792
  closeOnOverlayClick,
20677
20793
  lockScroll
20678
20794
  },
20679
- /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$7} ${classes}`, id: `toast-${id}` }, /* @__PURE__ */ React.createElement(
20795
+ /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$6} ${classes}`, id: `toast-${id}` }, /* @__PURE__ */ React.createElement(
20680
20796
  "div",
20681
20797
  {
20682
- className: `${classPrefix$7}__inner ${classPrefix$7}-${position} ${contentClassName}`,
20798
+ className: `${classPrefix$6}__inner ${classPrefix$6}-${position} ${contentClassName}`,
20683
20799
  style: contentStyle
20684
20800
  },
20685
20801
  this.renderIcon(),
20686
- title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$7}-title` }, title) : null,
20687
- /* @__PURE__ */ React.createElement("span", { className: `${classPrefix$7}-text` }, content)
20802
+ title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$6}-title` }, title) : null,
20803
+ /* @__PURE__ */ React.createElement("span", { className: `${classPrefix$6}-text` }, content)
20688
20804
  ))
20689
20805
  ));
20690
20806
  }
@@ -20791,7 +20907,7 @@ const Toast = {
20791
20907
  }
20792
20908
  }
20793
20909
  };
20794
- const defaultProps$r = {
20910
+ const defaultProps$q = {
20795
20911
  ...ComponentDefaults,
20796
20912
  type: "shake",
20797
20913
  action: "initial",
@@ -20799,16 +20915,16 @@ const defaultProps$r = {
20799
20915
  onClick: (event) => {
20800
20916
  }
20801
20917
  };
20802
- const classPrefix$6 = `nut-animate`;
20918
+ const classPrefix$5 = `nut-animate`;
20803
20919
  const Animate = (props) => {
20804
20920
  const { className, type: type4, action, loop: loop2, onClick, children, ...rest } = {
20805
- ...defaultProps$r,
20921
+ ...defaultProps$q,
20806
20922
  ...props
20807
20923
  };
20808
20924
  const [clicked, setClicked] = useState(false);
20809
20925
  const classes = classNames({
20810
20926
  "nut-ani-container": true,
20811
- [`${classPrefix$6}-${type4}`]: action === "initial" || clicked ? type4 : false,
20927
+ [`${classPrefix$5}-${type4}`]: action === "initial" || clicked ? type4 : false,
20812
20928
  loop: loop2
20813
20929
  });
20814
20930
  const cls = classNames(classes, className);
@@ -20823,9 +20939,9 @@ const Animate = (props) => {
20823
20939
  };
20824
20940
  return /* @__PURE__ */ React__default.createElement("div", { className: "nut-animate" }, /* @__PURE__ */ React__default.createElement("div", { className: cls, onClick: handleClick2, ...rest }, children));
20825
20941
  };
20826
- Animate.defaultProps = defaultProps$r;
20942
+ Animate.defaultProps = defaultProps$q;
20827
20943
  Animate.displayName = "NutAnimate";
20828
- const defaultProps$q = {
20944
+ const defaultProps$p = {
20829
20945
  ...ComponentDefaults,
20830
20946
  length: 0,
20831
20947
  value: "",
@@ -20844,7 +20960,7 @@ const CountUp = (props) => {
20844
20960
  style,
20845
20961
  ...reset
20846
20962
  } = {
20847
- ...defaultProps$q,
20963
+ ...defaultProps$p,
20848
20964
  ...props
20849
20965
  };
20850
20966
  const classPrefix2 = "nut-countup";
@@ -20908,9 +21024,9 @@ const CountUp = (props) => {
20908
21024
  );
20909
21025
  })));
20910
21026
  };
20911
- CountUp.defaultProps = defaultProps$q;
21027
+ CountUp.defaultProps = defaultProps$p;
20912
21028
  CountUp.displayName = "NutCountUp";
20913
- const defaultProps$p = {};
21029
+ const defaultProps$o = {};
20914
21030
  class AnimatingNumbers extends Component {
20915
21031
  constructor(props) {
20916
21032
  super(props);
@@ -20920,11 +21036,11 @@ class AnimatingNumbers extends Component {
20920
21036
  return /* @__PURE__ */ React__default.createElement("div", { className: "nut-animatingnumbers" });
20921
21037
  }
20922
21038
  }
20923
- __publicField(AnimatingNumbers, "defaultProps", defaultProps$p);
21039
+ __publicField(AnimatingNumbers, "defaultProps", defaultProps$o);
20924
21040
  __publicField(AnimatingNumbers, "displayName", "NutAnimatingNumbers");
20925
21041
  __publicField(AnimatingNumbers, "CountUp", CountUp);
20926
21042
  AnimatingNumbers.CountUp = CountUp;
20927
- const defaultProps$o = {
21043
+ const defaultProps$n = {
20928
21044
  ...ComponentDefaults,
20929
21045
  src: "",
20930
21046
  muted: false,
@@ -20967,7 +21083,7 @@ const Audio = (props) => {
20967
21083
  children,
20968
21084
  ...rest
20969
21085
  } = {
20970
- ...defaultProps$o,
21086
+ ...defaultProps$n,
20971
21087
  ...props
20972
21088
  };
20973
21089
  const [playing, setPlaying] = useState(false);
@@ -21173,31 +21289,8 @@ const Audio = (props) => {
21173
21289
  /* @__PURE__ */ React__default.createElement("track", { kind: "captions" })
21174
21290
  ));
21175
21291
  };
21176
- Audio.defaultProps = defaultProps$o;
21292
+ Audio.defaultProps = defaultProps$n;
21177
21293
  Audio.displayName = "NutAudio";
21178
- const defaultProps$n = {
21179
- ...ComponentDefaults,
21180
- maxContent: "",
21181
- max: "",
21182
- maxBackground: "#eee",
21183
- maxColor: "#666",
21184
- gap: "-8",
21185
- level: "left"
21186
- };
21187
- const classPrefix$5 = `nut-avatar-group`;
21188
- const AvatarGroup = (props) => {
21189
- const propAvatarGroup = { ...defaultProps$n, ...props };
21190
- const { className, style, children } = propAvatarGroup;
21191
- const avatarGroupRef = useRef(null);
21192
- const cls = classNames(classPrefix$5, className);
21193
- const parentAvatar = {
21194
- propAvatarGroup,
21195
- avatarGroupRef
21196
- };
21197
- return /* @__PURE__ */ React__default.createElement(AvatarContext.Provider, { value: parentAvatar }, /* @__PURE__ */ React__default.createElement("div", { className: cls, style, ref: avatarGroupRef }, children));
21198
- };
21199
- AvatarGroup.defaultProps = defaultProps$n;
21200
- AvatarGroup.displayName = "NutAvatarGroup";
21201
21294
  const defaultProps$m = {
21202
21295
  ...ComponentDefaults,
21203
21296
  strokeWidth: 5,
@@ -22472,6 +22565,8 @@ const SwiperItem = React__default.forwardRef((props, ref) => {
22472
22565
  });
22473
22566
  SwiperItem.defaultProps = defaultProps$e;
22474
22567
  SwiperItem.displayName = "NutSwiperItem";
22568
+ const InnerSwiper = Swiper;
22569
+ InnerSwiper.Item = SwiperItem;
22475
22570
  const defaultProps$d = {
22476
22571
  ...ComponentDefaults,
22477
22572
  images: [],
@@ -22647,7 +22742,7 @@ const ImagePreview = (props) => {
22647
22742
  onTouchStart
22648
22743
  },
22649
22744
  /* @__PURE__ */ React__default.createElement(
22650
- Swiper,
22745
+ InnerSwiper,
22651
22746
  {
22652
22747
  autoPlay,
22653
22748
  className: `${classPrefix2}-swiper`,
@@ -22676,315 +22771,16 @@ const ImagePreview = (props) => {
22676
22771
  };
22677
22772
  ImagePreview.defaultProps = defaultProps$d;
22678
22773
  ImagePreview.displayName = "NutImagePreview";
22679
- const initPositinoCache = (reaItemSize, length = 0) => {
22680
- let index = 0;
22681
- const positions = Array(length);
22682
- while (index < length) {
22683
- positions[index] = {
22684
- index,
22685
- height: reaItemSize,
22686
- width: reaItemSize,
22687
- top: index * reaItemSize,
22688
- bottom: (index + 1) * reaItemSize,
22689
- left: index * reaItemSize,
22690
- right: (index + 1) * reaItemSize
22691
- };
22692
- index++;
22693
- }
22694
- return positions;
22695
- };
22696
- const getListTotalSize = (positions, horizontal) => {
22697
- const index = positions.length - 1;
22698
- let size = 0;
22699
- if (index < 0) {
22700
- size = 0;
22701
- } else {
22702
- size = horizontal ? positions[index].right : positions[index].bottom;
22703
- }
22704
- return size;
22705
- };
22706
- const binarySearch = (positionsList, value = 0, horizontal) => {
22707
- let start2 = 0;
22708
- let end = positionsList.length - 1;
22709
- let tempIndex = null;
22710
- const key = horizontal ? "right" : "bottom";
22711
- while (start2 <= end) {
22712
- const midIndex = Math.floor((start2 + end) / 2);
22713
- const midValue = positionsList[midIndex][key];
22714
- if (midValue === value) {
22715
- return midIndex + 1;
22716
- }
22717
- if (midValue < value) {
22718
- start2 = midIndex + 1;
22719
- } else if (midValue > value) {
22720
- if (tempIndex === null || tempIndex > midIndex) {
22721
- tempIndex = midIndex;
22722
- }
22723
- end = midIndex - 1;
22724
- }
22725
- }
22726
- tempIndex = tempIndex || 0;
22727
- return tempIndex;
22728
- };
22729
- const getEndIndex = ({
22730
- list,
22731
- startIndex,
22732
- visibleCount,
22733
- itemEqual = true,
22734
- positions,
22735
- offSetSize,
22736
- overscan,
22737
- sizeKey = "width"
22738
- }) => {
22739
- const dataLength = list.length;
22740
- let tempIndex = null;
22741
- if (itemEqual) {
22742
- const endIndex = startIndex + visibleCount;
22743
- tempIndex = dataLength > 0 ? Math.min(dataLength, endIndex) : endIndex;
22744
- } else {
22745
- let sizeNum = 0;
22746
- for (let i = startIndex; i < dataLength; i++) {
22747
- sizeNum += positions[i][sizeKey] || 0;
22748
- if (sizeNum > offSetSize) {
22749
- const endIndex = i + overscan;
22750
- tempIndex = dataLength > 0 ? Math.min(dataLength, endIndex) : endIndex;
22751
- break;
22752
- }
22753
- }
22754
- if (sizeNum < offSetSize) {
22755
- tempIndex = dataLength;
22756
- }
22757
- }
22758
- tempIndex = tempIndex || 0;
22759
- return tempIndex;
22760
- };
22761
- const updateItemSize = (positions, items, sizeKey) => {
22762
- const newPos = positions.concat();
22763
- Array.from(items).forEach((item) => {
22764
- const index = Number(item.getAttribute("data-index"));
22765
- const styleVal = item.getAttribute("style");
22766
- if (styleVal && styleVal.includes("none"))
22767
- return;
22768
- const nowSize = item.getBoundingClientRect()[sizeKey];
22769
- const oldSize = positions[index][sizeKey];
22770
- const dValue = oldSize - nowSize;
22771
- if (dValue) {
22772
- if (sizeKey === "width") {
22773
- newPos[index].right -= dValue;
22774
- newPos[index][sizeKey] = nowSize;
22775
- for (let k2 = index + 1; k2 < positions.length; k2++) {
22776
- newPos[k2].left = positions[k2 - 1].right;
22777
- newPos[k2].right -= dValue;
22778
- }
22779
- } else if (sizeKey === "height") {
22780
- newPos[index].bottom -= dValue;
22781
- newPos[index][sizeKey] = nowSize;
22782
- for (let k2 = index + 1; k2 < positions.length; k2++) {
22783
- newPos[k2].top = positions[k2 - 1].bottom;
22784
- newPos[k2].bottom -= dValue;
22785
- }
22786
- }
22787
- }
22788
- });
22789
- };
22790
- const defaultProps$c = {
22791
- ...ComponentDefaults,
22792
- list: [],
22793
- itemHeight: 66,
22794
- itemEqual: true,
22795
- direction: "vertical",
22796
- overscan: 2
22797
- };
22798
- const VirtualList = (props) => {
22799
- const {
22800
- list,
22801
- ItemRender,
22802
- itemEqual,
22803
- itemHeight,
22804
- direction,
22805
- overscan,
22806
- key,
22807
- onScroll,
22808
- className,
22809
- containerHeight,
22810
- ...rest
22811
- } = {
22812
- ...defaultProps$c,
22813
- ...props
22814
- };
22815
- const horizontal = direction === "horizontal";
22816
- const sizeKey = horizontal ? "width" : "height";
22817
- const scrollKey = horizontal ? "scrollLeft" : "scrollTop";
22818
- const offsetKey = horizontal ? "left" : "top";
22819
- const scrollRef = useRef(null);
22820
- const itemsRef = useRef(null);
22821
- const firstItemRef = useRef(null);
22822
- const [positions, setPositions] = useState([
22823
- {
22824
- index: 0,
22825
- left: 0,
22826
- top: 0,
22827
- bottom: 0,
22828
- width: 0,
22829
- height: 0,
22830
- right: 0
22831
- }
22832
- ]);
22833
- const [listTotalSize, setListTotalSize] = useState(99999999);
22834
- const [visibleCount, setVisibleCount] = useState(0);
22835
- const [offSetSize, setOffSetSize] = useState(containerHeight || 0);
22836
- const [options2, setOptions] = useState({
22837
- startOffset: 0,
22838
- // 可视区域距离顶部的偏移量
22839
- startIndex: 0,
22840
- // 可视区域开始索引
22841
- overStart: 0,
22842
- endIndex: 10
22843
- // 可视区域结束索引
22844
- });
22845
- useEffect(() => {
22846
- const pos = initPositinoCache(itemHeight, list.length);
22847
- setPositions(pos);
22848
- const totalSize = getListTotalSize(pos, horizontal);
22849
- setListTotalSize(totalSize);
22850
- }, [list, itemHeight, horizontal]);
22851
- const getElement = useCallback(() => {
22852
- var _a2;
22853
- return ((_a2 = scrollRef.current) == null ? void 0 : _a2.parentElement) || document.body;
22854
- }, []);
22855
- useEffect(() => {
22856
- if (containerHeight)
22857
- return;
22858
- const size = horizontal ? getElement().offsetWidth : getElement().offsetHeight;
22859
- setOffSetSize(size);
22860
- }, [getElement, horizontal, containerHeight]);
22861
- useEffect(() => {
22862
- if (offSetSize === 0)
22863
- return;
22864
- const count = Math.ceil(offSetSize / itemHeight) + overscan;
22865
- setVisibleCount(count);
22866
- setOptions((options22) => {
22867
- return { ...options22, endIndex: count };
22868
- });
22869
- }, [getElement, horizontal, itemHeight, overscan, offSetSize]);
22870
- const updateTotalSize = useCallback(() => {
22871
- if (!itemsRef.current)
22872
- return;
22873
- const items = itemsRef.current.children;
22874
- if (!items.length)
22875
- return;
22876
- updateItemSize(positions, items, sizeKey);
22877
- const totalSize = getListTotalSize(positions, horizontal);
22878
- setListTotalSize(totalSize);
22879
- }, [positions, sizeKey, horizontal]);
22880
- const scroll = useCallback(() => {
22881
- requestAnimationFrame((e) => {
22882
- const scrollSize = getElement()[scrollKey];
22883
- const startIndex = binarySearch(positions, scrollSize, horizontal);
22884
- const overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
22885
- if (!itemEqual) {
22886
- updateTotalSize();
22887
- }
22888
- const endIndex = getEndIndex({
22889
- list,
22890
- startIndex,
22891
- visibleCount,
22892
- itemEqual,
22893
- positions,
22894
- offSetSize,
22895
- sizeKey,
22896
- overscan
22897
- });
22898
- const startOffset = positions[startIndex][offsetKey];
22899
- setOptions({ startOffset, startIndex, overStart, endIndex });
22900
- if (endIndex > list.length - 1) {
22901
- if (onScroll) {
22902
- onScroll();
22903
- }
22904
- }
22905
- });
22906
- }, [
22907
- positions,
22908
- getElement,
22909
- list,
22910
- visibleCount,
22911
- itemEqual,
22912
- updateTotalSize,
22913
- offsetKey,
22914
- sizeKey,
22915
- scrollKey,
22916
- horizontal,
22917
- overscan,
22918
- offSetSize
22919
- ]);
22920
- useEffect(() => {
22921
- const element = getElement();
22922
- element.addEventListener("scroll", scroll, false);
22923
- return () => {
22924
- element.removeEventListener("scroll", scroll, false);
22925
- };
22926
- }, [getElement, scroll]);
22927
- return /* @__PURE__ */ React__default.createElement(
22928
- "div",
22929
- {
22930
- className: className ? `${className} nut-virtualList-box` : "nut-virtualList-box",
22931
- ...rest,
22932
- style: {
22933
- [sizeKey]: containerHeight ? `${offSetSize}px` : ""
22934
- }
22935
- },
22936
- /* @__PURE__ */ React__default.createElement(
22937
- "div",
22938
- {
22939
- ref: scrollRef,
22940
- className: horizontal ? "nut-horizontal-box" : "nut-vertical-box",
22941
- style: {
22942
- position: "relative",
22943
- [sizeKey]: `${listTotalSize}px`
22944
- }
22945
- },
22946
- /* @__PURE__ */ React__default.createElement(
22947
- "ul",
22948
- {
22949
- className: horizontal ? "nut-virtuallist-items nut-horizontal-items" : "nut-virtuallist-items nut-vertical-items",
22950
- ref: itemsRef,
22951
- style: {
22952
- transform: horizontal ? `translate3d(${options2.startOffset}px,0,0)` : `translate3d(0,${options2.startOffset}px,0)`
22953
- }
22954
- },
22955
- list.slice(options2.overStart, options2.endIndex).map((data, index) => {
22956
- const { startIndex, overStart } = options2;
22957
- const dataIndex = overStart + index;
22958
- const styleVal = dataIndex < startIndex ? "none" : "block";
22959
- const keyVal = key && data[key] ? data[key] : dataIndex;
22960
- return /* @__PURE__ */ React__default.createElement(
22961
- "li",
22962
- {
22963
- ref: dataIndex === 0 ? firstItemRef : null,
22964
- "data-index": `${dataIndex}`,
22965
- className: dataIndex % 2 === 0 ? "nut-virtuallist-item even" : "nut-virtuallist-item odd",
22966
- key: `${keyVal}`,
22967
- style: { display: styleVal }
22968
- },
22969
- ItemRender ? /* @__PURE__ */ React__default.createElement(ItemRender, { data, index: `${dataIndex}` }) : data
22970
- );
22971
- })
22972
- )
22973
- )
22974
- );
22975
- };
22976
- VirtualList.defaultProps = defaultProps$c;
22977
- VirtualList.displayName = "NutVirtualList";
22978
- const defaultProps$b = {
22979
- ...ComponentDefaults,
22980
- defaultValue: 1,
22981
- mode: "multi",
22982
- prev: null,
22983
- next: null,
22984
- total: 50,
22985
- pageSize: 10,
22986
- itemSize: 5,
22987
- ellipse: false
22774
+ const defaultProps$c = {
22775
+ ...ComponentDefaults,
22776
+ defaultValue: 1,
22777
+ mode: "multi",
22778
+ prev: null,
22779
+ next: null,
22780
+ total: 50,
22781
+ pageSize: 10,
22782
+ itemSize: 5,
22783
+ ellipse: false
22988
22784
  };
22989
22785
  const Pagination = (props) => {
22990
22786
  const { locale } = useConfig();
@@ -23003,7 +22799,7 @@ const Pagination = (props) => {
23003
22799
  className,
23004
22800
  ...rest
23005
22801
  } = {
23006
- ...defaultProps$b,
22802
+ ...defaultProps$c,
23007
22803
  ...props
23008
22804
  };
23009
22805
  const classPrefix2 = "nut-pagination";
@@ -23085,9 +22881,9 @@ const Pagination = (props) => {
23085
22881
  next || locale.pagination.next
23086
22882
  ));
23087
22883
  };
23088
- Pagination.defaultProps = defaultProps$b;
22884
+ Pagination.defaultProps = defaultProps$c;
23089
22885
  Pagination.displayName = "NutPagination";
23090
- const defaultProps$a = {
22886
+ const defaultProps$b = {
23091
22887
  ...ComponentDefaults,
23092
22888
  price: 0,
23093
22889
  symbol: "&yen;",
@@ -23110,7 +22906,7 @@ const Price = (props) => {
23110
22906
  style,
23111
22907
  ...rest
23112
22908
  } = {
23113
- ...defaultProps$a,
22909
+ ...defaultProps$b,
23114
22910
  ...props
23115
22911
  };
23116
22912
  const classPrefix2 = "nut-price";
@@ -23190,10 +22986,10 @@ const Price = (props) => {
23190
22986
  symbol && position === "after" ? renderSymbol() : null
23191
22987
  );
23192
22988
  };
23193
- Price.defaultProps = defaultProps$a;
22989
+ Price.defaultProps = defaultProps$b;
23194
22990
  Price.displayName = "NutPrice";
23195
22991
  const DataContext = createContext({});
23196
- const defaultProps$9 = {
22992
+ const defaultProps$a = {
23197
22993
  ...ComponentDefaults,
23198
22994
  title: "",
23199
22995
  description: "",
@@ -23202,7 +22998,7 @@ const defaultProps$9 = {
23202
22998
  };
23203
22999
  const Step = (props) => {
23204
23000
  const { children, title, description, value, icon, className, ...restProps } = {
23205
- ...defaultProps$9,
23001
+ ...defaultProps$a,
23206
23002
  ...props
23207
23003
  };
23208
23004
  const parent = useContext(DataContext);
@@ -23236,16 +23032,16 @@ const Step = (props) => {
23236
23032
  };
23237
23033
  return /* @__PURE__ */ React__default.createElement("div", { className: classes, ...restProps, onClick: handleClickStep }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-head" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-line" }), /* @__PURE__ */ React__default.createElement("div", { className: renderIconClass() }, icon || !dot && /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-inner" }, value))), /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-main" }, /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-title" }, title), description && /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-description" }, description)));
23238
23034
  };
23239
- Step.defaultProps = defaultProps$9;
23035
+ Step.defaultProps = defaultProps$a;
23240
23036
  Step.displayName = "NutStep";
23241
- const defaultProps$8 = {
23037
+ const defaultProps$9 = {
23242
23038
  ...ComponentDefaults,
23243
23039
  value: 0,
23244
23040
  direction: "horizontal",
23245
23041
  dot: false
23246
23042
  };
23247
23043
  const Steps = (props) => {
23248
- const propSteps = { ...defaultProps$8, ...props };
23044
+ const propSteps = { ...defaultProps$9, ...props };
23249
23045
  const {
23250
23046
  children,
23251
23047
  value,
@@ -23276,9 +23072,9 @@ const Steps = (props) => {
23276
23072
  children
23277
23073
  ));
23278
23074
  };
23279
- Steps.defaultProps = defaultProps$8;
23075
+ Steps.defaultProps = defaultProps$9;
23280
23076
  Steps.displayName = "NutSteps";
23281
- const defaultProps$7 = {
23077
+ const defaultProps$8 = {
23282
23078
  ...ComponentDefaults,
23283
23079
  columns: [],
23284
23080
  data: [],
@@ -23290,7 +23086,7 @@ const defaultProps$7 = {
23290
23086
  };
23291
23087
  const Table = (props) => {
23292
23088
  const { locale } = useConfig();
23293
- defaultProps$7.noData = locale.noData;
23089
+ defaultProps$8.noData = locale.noData;
23294
23090
  const {
23295
23091
  children,
23296
23092
  className,
@@ -23306,7 +23102,7 @@ const Table = (props) => {
23306
23102
  onSort,
23307
23103
  ...rest
23308
23104
  } = {
23309
- ...defaultProps$7,
23105
+ ...defaultProps$8,
23310
23106
  ...props
23311
23107
  };
23312
23108
  const [curData, setCurData] = useState(data);
@@ -23389,117 +23185,414 @@ const Table = (props) => {
23389
23185
  /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__main__body` }, renderBoyTrs())
23390
23186
  ), (summary || curData.length === 0) && /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}__summary` }, summary || noData));
23391
23187
  };
23392
- Table.defaultProps = defaultProps$7;
23393
- Table.displayName = "NutTable";
23188
+ Table.defaultProps = defaultProps$8;
23189
+ Table.displayName = "NutTable";
23190
+ const defaultProps$7 = {
23191
+ ...ComponentDefaults,
23192
+ type: "default",
23193
+ background: "",
23194
+ color: "",
23195
+ plain: false,
23196
+ round: false,
23197
+ mark: false,
23198
+ closeable: false,
23199
+ closeIcon: null,
23200
+ onClose: (e) => {
23201
+ },
23202
+ onClick: (e) => {
23203
+ }
23204
+ };
23205
+ const Tag = (props) => {
23206
+ const {
23207
+ className,
23208
+ style,
23209
+ background,
23210
+ plain,
23211
+ type: type4,
23212
+ round,
23213
+ children,
23214
+ mark,
23215
+ closeable,
23216
+ closeIcon,
23217
+ color,
23218
+ onClick,
23219
+ onClose
23220
+ } = {
23221
+ ...defaultProps$7,
23222
+ ...props
23223
+ };
23224
+ const [tagClass, setTagClass] = useState("");
23225
+ const [visible, setVisible] = useState(true);
23226
+ const classPrefix2 = "nut-tag";
23227
+ const classes = () => {
23228
+ return classNames({
23229
+ [classPrefix2]: true,
23230
+ [`${classPrefix2}--${type4}`]: type4,
23231
+ [`${classPrefix2}--plain`]: plain,
23232
+ [`${classPrefix2}--round`]: round,
23233
+ [`${classPrefix2}--mark`]: mark,
23234
+ [`${classPrefix2}--close`]: closeable,
23235
+ [`${className}`]: className
23236
+ });
23237
+ };
23238
+ useEffect(() => {
23239
+ setTagClass(classes());
23240
+ }, [type4, background, color, plain, round, mark, closeable, className]);
23241
+ const handleClick2 = (e) => {
23242
+ onClick && onClick(e);
23243
+ };
23244
+ const getStyle = () => {
23245
+ const style2 = {};
23246
+ if (color) {
23247
+ style2.color = color;
23248
+ } else if (background && plain) {
23249
+ style2.color = background;
23250
+ }
23251
+ if (plain) {
23252
+ style2.borderColor = background;
23253
+ } else if (background) {
23254
+ style2.background = background;
23255
+ }
23256
+ return style2;
23257
+ };
23258
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, closeable ? visible && /* @__PURE__ */ React__default.createElement(
23259
+ "div",
23260
+ {
23261
+ className: tagClass,
23262
+ style: { ...style, ...getStyle() },
23263
+ onClick: (e) => handleClick2(e)
23264
+ },
23265
+ children && /* @__PURE__ */ React__default.createElement("span", { className: `${classPrefix2}-text` }, children),
23266
+ React__default.isValidElement(closeIcon) ? /* @__PURE__ */ React__default.createElement(
23267
+ "i",
23268
+ {
23269
+ className: `${classPrefix2}-custom-icon`,
23270
+ onClick: (e) => {
23271
+ setVisible(false);
23272
+ onClose && onClose(e);
23273
+ }
23274
+ },
23275
+ closeIcon
23276
+ ) : /* @__PURE__ */ React__default.createElement(
23277
+ x$b,
23278
+ {
23279
+ width: 12,
23280
+ height: 12,
23281
+ onClick: (e) => {
23282
+ setVisible(false);
23283
+ onClose && onClose(e);
23284
+ }
23285
+ }
23286
+ )
23287
+ ) : /* @__PURE__ */ React__default.createElement(
23288
+ "div",
23289
+ {
23290
+ className: tagClass,
23291
+ style: { ...style, ...getStyle() },
23292
+ onClick: (e) => handleClick2(e)
23293
+ },
23294
+ children && /* @__PURE__ */ React__default.createElement("span", { className: `${classPrefix2}-text` }, children)
23295
+ ));
23296
+ };
23297
+ Tag.defaultProps = defaultProps$7;
23298
+ Tag.displayName = "NutTag";
23299
+ const initPositinoCache = (reaItemSize, length = 0) => {
23300
+ let index = 0;
23301
+ const positions = Array(length);
23302
+ while (index < length) {
23303
+ positions[index] = {
23304
+ index,
23305
+ height: reaItemSize,
23306
+ width: reaItemSize,
23307
+ top: index * reaItemSize,
23308
+ bottom: (index + 1) * reaItemSize,
23309
+ left: index * reaItemSize,
23310
+ right: (index + 1) * reaItemSize
23311
+ };
23312
+ index++;
23313
+ }
23314
+ return positions;
23315
+ };
23316
+ const getListTotalSize = (positions, horizontal) => {
23317
+ const index = positions.length - 1;
23318
+ let size = 0;
23319
+ if (index < 0) {
23320
+ size = 0;
23321
+ } else {
23322
+ size = horizontal ? positions[index].right : positions[index].bottom;
23323
+ }
23324
+ return size;
23325
+ };
23326
+ const binarySearch = (positionsList, value = 0, horizontal) => {
23327
+ let start2 = 0;
23328
+ let end = positionsList.length - 1;
23329
+ let tempIndex = null;
23330
+ const key = horizontal ? "right" : "bottom";
23331
+ while (start2 <= end) {
23332
+ const midIndex = Math.floor((start2 + end) / 2);
23333
+ const midValue = positionsList[midIndex][key];
23334
+ if (midValue === value) {
23335
+ return midIndex + 1;
23336
+ }
23337
+ if (midValue < value) {
23338
+ start2 = midIndex + 1;
23339
+ } else if (midValue > value) {
23340
+ if (tempIndex === null || tempIndex > midIndex) {
23341
+ tempIndex = midIndex;
23342
+ }
23343
+ end = midIndex - 1;
23344
+ }
23345
+ }
23346
+ tempIndex = tempIndex || 0;
23347
+ return tempIndex;
23348
+ };
23349
+ const getEndIndex = ({
23350
+ list,
23351
+ startIndex,
23352
+ visibleCount,
23353
+ itemEqual = true,
23354
+ positions,
23355
+ offSetSize,
23356
+ overscan,
23357
+ sizeKey = "width"
23358
+ }) => {
23359
+ const dataLength = list.length;
23360
+ let tempIndex = null;
23361
+ if (itemEqual) {
23362
+ const endIndex = startIndex + visibleCount;
23363
+ tempIndex = dataLength > 0 ? Math.min(dataLength, endIndex) : endIndex;
23364
+ } else {
23365
+ let sizeNum = 0;
23366
+ for (let i = startIndex; i < dataLength; i++) {
23367
+ sizeNum += positions[i][sizeKey] || 0;
23368
+ if (sizeNum > offSetSize) {
23369
+ const endIndex = i + overscan;
23370
+ tempIndex = dataLength > 0 ? Math.min(dataLength, endIndex) : endIndex;
23371
+ break;
23372
+ }
23373
+ }
23374
+ if (sizeNum < offSetSize) {
23375
+ tempIndex = dataLength;
23376
+ }
23377
+ }
23378
+ tempIndex = tempIndex || 0;
23379
+ return tempIndex;
23380
+ };
23381
+ const updateItemSize = (positions, items, sizeKey) => {
23382
+ const newPos = positions.concat();
23383
+ Array.from(items).forEach((item) => {
23384
+ const index = Number(item.getAttribute("data-index"));
23385
+ const styleVal = item.getAttribute("style");
23386
+ if (styleVal && styleVal.includes("none"))
23387
+ return;
23388
+ const nowSize = item.getBoundingClientRect()[sizeKey];
23389
+ const oldSize = positions[index][sizeKey];
23390
+ const dValue = oldSize - nowSize;
23391
+ if (dValue) {
23392
+ if (sizeKey === "width") {
23393
+ newPos[index].right -= dValue;
23394
+ newPos[index][sizeKey] = nowSize;
23395
+ for (let k2 = index + 1; k2 < positions.length; k2++) {
23396
+ newPos[k2].left = positions[k2 - 1].right;
23397
+ newPos[k2].right -= dValue;
23398
+ }
23399
+ } else if (sizeKey === "height") {
23400
+ newPos[index].bottom -= dValue;
23401
+ newPos[index][sizeKey] = nowSize;
23402
+ for (let k2 = index + 1; k2 < positions.length; k2++) {
23403
+ newPos[k2].top = positions[k2 - 1].bottom;
23404
+ newPos[k2].bottom -= dValue;
23405
+ }
23406
+ }
23407
+ }
23408
+ });
23409
+ };
23394
23410
  const defaultProps$6 = {
23395
23411
  ...ComponentDefaults,
23396
- type: "default",
23397
- background: "",
23398
- color: "",
23399
- plain: false,
23400
- round: false,
23401
- mark: false,
23402
- closeable: false,
23403
- closeIcon: null,
23404
- onClose: (e) => {
23405
- },
23406
- onClick: (e) => {
23407
- }
23412
+ list: [],
23413
+ itemHeight: 66,
23414
+ itemEqual: true,
23415
+ direction: "vertical",
23416
+ overscan: 2
23408
23417
  };
23409
- const Tag = (props) => {
23418
+ const VirtualList = (props) => {
23410
23419
  const {
23420
+ list,
23421
+ itemRender,
23422
+ itemEqual,
23423
+ itemHeight,
23424
+ direction,
23425
+ overscan,
23426
+ key,
23427
+ onScroll,
23411
23428
  className,
23412
- style,
23413
- background,
23414
- plain,
23415
- type: type4,
23416
- round,
23417
- children,
23418
- mark,
23419
- closeable,
23420
- closeIcon,
23421
- color,
23422
- onClick,
23423
- onClose
23429
+ containerHeight,
23430
+ ...rest
23424
23431
  } = {
23425
23432
  ...defaultProps$6,
23426
23433
  ...props
23427
23434
  };
23428
- const [tagClass, setTagClass] = useState("");
23429
- const [visible, setVisible] = useState(true);
23430
- const classPrefix2 = "nut-tag";
23431
- const classes = () => {
23432
- return classNames({
23433
- [classPrefix2]: true,
23434
- [`${classPrefix2}--${type4}`]: type4,
23435
- [`${classPrefix2}--plain`]: plain,
23436
- [`${classPrefix2}--round`]: round,
23437
- [`${classPrefix2}--mark`]: mark,
23438
- [`${classPrefix2}--close`]: closeable,
23439
- [`${className}`]: className
23435
+ const horizontal = direction === "horizontal";
23436
+ const sizeKey = horizontal ? "width" : "height";
23437
+ const scrollKey = horizontal ? "scrollLeft" : "scrollTop";
23438
+ const offsetKey = horizontal ? "left" : "top";
23439
+ const scrollRef = useRef(null);
23440
+ const itemsRef = useRef(null);
23441
+ const [positions, setPositions] = useState([
23442
+ {
23443
+ index: 0,
23444
+ left: 0,
23445
+ top: 0,
23446
+ bottom: 0,
23447
+ width: 0,
23448
+ height: 0,
23449
+ right: 0
23450
+ }
23451
+ ]);
23452
+ const [listTotalSize, setListTotalSize] = useState(99999999);
23453
+ const [visibleCount, setVisibleCount] = useState(0);
23454
+ const [offSetSize, setOffSetSize] = useState(containerHeight || 0);
23455
+ const [options2, setOptions] = useState({
23456
+ startOffset: 0,
23457
+ // 可视区域距离顶部的偏移量
23458
+ startIndex: 0,
23459
+ // 可视区域开始索引
23460
+ overStart: 0,
23461
+ endIndex: 10
23462
+ // 可视区域结束索引
23463
+ });
23464
+ useEffect(() => {
23465
+ const pos = initPositinoCache(itemHeight, list.length);
23466
+ setPositions(pos);
23467
+ const totalSize = getListTotalSize(pos, horizontal);
23468
+ setListTotalSize(totalSize);
23469
+ }, [list, itemHeight, horizontal]);
23470
+ const getElement = useCallback(() => {
23471
+ var _a2;
23472
+ return ((_a2 = scrollRef.current) == null ? void 0 : _a2.parentElement) || document.body;
23473
+ }, []);
23474
+ useEffect(() => {
23475
+ if (containerHeight)
23476
+ return;
23477
+ const size = horizontal ? getElement().offsetWidth : getElement().offsetHeight;
23478
+ setOffSetSize(size);
23479
+ }, [getElement, horizontal, containerHeight]);
23480
+ useEffect(() => {
23481
+ if (offSetSize === 0)
23482
+ return;
23483
+ const count = Math.ceil(offSetSize / itemHeight) + overscan;
23484
+ setVisibleCount(count);
23485
+ setOptions((options22) => {
23486
+ return { ...options22, endIndex: count };
23440
23487
  });
23441
- };
23488
+ }, [getElement, horizontal, itemHeight, overscan, offSetSize]);
23489
+ const updateTotalSize = useCallback(() => {
23490
+ if (!itemsRef.current)
23491
+ return;
23492
+ const items = itemsRef.current.children;
23493
+ if (!items.length)
23494
+ return;
23495
+ updateItemSize(positions, items, sizeKey);
23496
+ const totalSize = getListTotalSize(positions, horizontal);
23497
+ setListTotalSize(totalSize);
23498
+ }, [positions, sizeKey, horizontal]);
23499
+ const scroll = useCallback(() => {
23500
+ requestAnimationFrame((e) => {
23501
+ const scrollSize = getElement()[scrollKey];
23502
+ const startIndex = binarySearch(positions, scrollSize, horizontal);
23503
+ const overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
23504
+ if (!itemEqual) {
23505
+ updateTotalSize();
23506
+ }
23507
+ const endIndex = getEndIndex({
23508
+ list,
23509
+ startIndex,
23510
+ visibleCount,
23511
+ itemEqual,
23512
+ positions,
23513
+ offSetSize,
23514
+ sizeKey,
23515
+ overscan
23516
+ });
23517
+ const startOffset = positions[startIndex][offsetKey];
23518
+ setOptions({ startOffset, startIndex, overStart, endIndex });
23519
+ if (endIndex > list.length - 1) {
23520
+ if (onScroll) {
23521
+ onScroll();
23522
+ }
23523
+ }
23524
+ });
23525
+ }, [
23526
+ positions,
23527
+ getElement,
23528
+ list,
23529
+ visibleCount,
23530
+ itemEqual,
23531
+ updateTotalSize,
23532
+ offsetKey,
23533
+ sizeKey,
23534
+ scrollKey,
23535
+ horizontal,
23536
+ overscan,
23537
+ offSetSize
23538
+ ]);
23442
23539
  useEffect(() => {
23443
- setTagClass(classes());
23444
- }, [type4, background, color, plain, round, mark, closeable, className]);
23445
- const handleClick2 = (e) => {
23446
- onClick && onClick(e);
23447
- };
23448
- const getStyle = () => {
23449
- const style2 = {};
23450
- if (color) {
23451
- style2.color = color;
23452
- } else if (background && plain) {
23453
- style2.color = background;
23454
- }
23455
- if (plain) {
23456
- style2.borderColor = background;
23457
- } else if (background) {
23458
- style2.background = background;
23459
- }
23460
- return style2;
23461
- };
23462
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, closeable ? visible && /* @__PURE__ */ React__default.createElement(
23540
+ const element = getElement();
23541
+ element.addEventListener("scroll", scroll, false);
23542
+ return () => {
23543
+ element.removeEventListener("scroll", scroll, false);
23544
+ };
23545
+ }, [getElement, scroll]);
23546
+ return /* @__PURE__ */ React__default.createElement(
23463
23547
  "div",
23464
23548
  {
23465
- className: tagClass,
23466
- style: { ...style, ...getStyle() },
23467
- onClick: (e) => handleClick2(e)
23549
+ className: className ? `${className} nut-virtualList-box` : "nut-virtualList-box",
23550
+ ...rest,
23551
+ style: {
23552
+ [sizeKey]: containerHeight ? `${offSetSize}px` : ""
23553
+ }
23468
23554
  },
23469
- children && /* @__PURE__ */ React__default.createElement("span", { className: `${classPrefix2}-text` }, children),
23470
- React__default.isValidElement(closeIcon) ? /* @__PURE__ */ React__default.createElement(
23471
- "i",
23555
+ /* @__PURE__ */ React__default.createElement(
23556
+ "div",
23472
23557
  {
23473
- className: `${classPrefix2}-custom-icon`,
23474
- onClick: (e) => {
23475
- setVisible(false);
23476
- onClose && onClose(e);
23558
+ ref: scrollRef,
23559
+ className: horizontal ? "nut-horizontal-box" : "nut-vertical-box",
23560
+ style: {
23561
+ position: "relative",
23562
+ [sizeKey]: `${listTotalSize}px`
23477
23563
  }
23478
23564
  },
23479
- closeIcon
23480
- ) : /* @__PURE__ */ React__default.createElement(
23481
- x$b,
23482
- {
23483
- width: 12,
23484
- height: 12,
23485
- onClick: (e) => {
23486
- setVisible(false);
23487
- onClose && onClose(e);
23488
- }
23489
- }
23565
+ /* @__PURE__ */ React__default.createElement(
23566
+ "ul",
23567
+ {
23568
+ className: horizontal ? "nut-virtuallist-items nut-horizontal-items" : "nut-virtuallist-items nut-vertical-items",
23569
+ ref: itemsRef,
23570
+ style: {
23571
+ transform: horizontal ? `translate3d(${options2.startOffset}px,0,0)` : `translate3d(0,${options2.startOffset}px,0)`
23572
+ }
23573
+ },
23574
+ list.slice(options2.overStart, options2.endIndex).map((data, index) => {
23575
+ const { startIndex, overStart } = options2;
23576
+ const dataIndex = overStart + index;
23577
+ const styleVal = dataIndex < startIndex ? "none" : "block";
23578
+ const keyVal = key && data[key] ? data[key] : dataIndex;
23579
+ return /* @__PURE__ */ React__default.createElement(
23580
+ "li",
23581
+ {
23582
+ "data-index": `${dataIndex}`,
23583
+ className: dataIndex % 2 === 0 ? "nut-virtuallist-item even" : "nut-virtuallist-item odd",
23584
+ key: `${keyVal}`,
23585
+ style: { display: styleVal }
23586
+ },
23587
+ itemRender ? itemRender(data, dataIndex, index) : data
23588
+ );
23589
+ })
23590
+ )
23490
23591
  )
23491
- ) : /* @__PURE__ */ React__default.createElement(
23492
- "div",
23493
- {
23494
- className: tagClass,
23495
- style: { ...style, ...getStyle() },
23496
- onClick: (e) => handleClick2(e)
23497
- },
23498
- children && /* @__PURE__ */ React__default.createElement("span", { className: `${classPrefix2}-text` }, children)
23499
- ));
23592
+ );
23500
23593
  };
23501
- Tag.defaultProps = defaultProps$6;
23502
- Tag.displayName = "NutTag";
23594
+ VirtualList.defaultProps = defaultProps$6;
23595
+ VirtualList.displayName = "NutVirtualList";
23503
23596
  const defaultProps$5 = {
23504
23597
  ...ComponentDefaults,
23505
23598
  list: [],
@@ -23833,13 +23926,13 @@ const defaultProps$1 = {
23833
23926
  digits: 2,
23834
23927
  symbol: false,
23835
23928
  zero: false,
23836
- arrowLeft: false,
23837
- syncColor: true,
23929
+ left: false,
23930
+ sync: true,
23838
23931
  color: "#333",
23839
23932
  riseColor: "#fa2c19",
23840
23933
  dropColor: "#64b578",
23841
23934
  riseIcon: null,
23842
- downIcon: null
23935
+ dropIcon: null
23843
23936
  };
23844
23937
  const TrendArrow = (props) => {
23845
23938
  const {
@@ -23847,13 +23940,13 @@ const TrendArrow = (props) => {
23847
23940
  digits,
23848
23941
  symbol,
23849
23942
  zero,
23850
- arrowLeft,
23851
- syncColor,
23943
+ left,
23944
+ sync: sync2,
23852
23945
  color,
23853
23946
  riseColor,
23854
23947
  dropColor,
23855
23948
  riseIcon,
23856
- downIcon,
23949
+ dropIcon,
23857
23950
  className,
23858
23951
  style,
23859
23952
  children,
@@ -23871,7 +23964,7 @@ const TrendArrow = (props) => {
23871
23964
  };
23872
23965
  const calcStyle = (() => {
23873
23966
  const arrowColor = rateTrend.current ? riseColor : dropColor;
23874
- const textEquArrowColor = syncColor ? arrowColor : color;
23967
+ const textEquArrowColor = sync2 ? arrowColor : color;
23875
23968
  const style2 = {
23876
23969
  color: value === 0 ? color : textEquArrowColor
23877
23970
  };
@@ -23893,8 +23986,8 @@ const TrendArrow = (props) => {
23893
23986
  };
23894
23987
  return iconProps;
23895
23988
  })();
23896
- const renderContent = (arrowLeft2) => {
23897
- const classNameSuffix = !arrowLeft2 ? "icon-after" : "icon-before";
23989
+ const renderContent = (left2) => {
23990
+ const classNameSuffix = !left2 ? "icon-after" : "icon-before";
23898
23991
  return /* @__PURE__ */ React__default.createElement(
23899
23992
  "span",
23900
23993
  {
@@ -23904,7 +23997,7 @@ const TrendArrow = (props) => {
23904
23997
  calcRate
23905
23998
  );
23906
23999
  };
23907
- return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2} ${className}`, style, ...rest }, !arrowLeft && renderContent(!arrowLeft), Number(value) !== 0 && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, rateTrend.current ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, riseIcon || /* @__PURE__ */ React__default.createElement(y, { color: calcIconProps.color })) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, downIcon || /* @__PURE__ */ React__default.createElement(y$1, { color: calcIconProps.color }))), arrowLeft && renderContent(!arrowLeft));
24000
+ return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2} ${className}`, style, ...rest }, !left && renderContent(!left), Number(value) !== 0 && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, rateTrend.current ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, riseIcon || /* @__PURE__ */ React__default.createElement(y, { color: calcIconProps.color })) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, dropIcon || /* @__PURE__ */ React__default.createElement(y$1, { color: calcIconProps.color }))), left && renderContent(!left));
23908
24001
  };
23909
24002
  TrendArrow.defaultProps = defaultProps$1;
23910
24003
  TrendArrow.displayName = "NutTrendArrow";
@@ -24095,7 +24188,7 @@ export {
24095
24188
  Sticky,
24096
24189
  SubSideNavBar,
24097
24190
  Swipe,
24098
- Swiper,
24191
+ InnerSwiper as Swiper,
24099
24192
  SwiperItem,
24100
24193
  Switch,
24101
24194
  TabPane,