@nutui/nutui-react 2.7.9 → 2.7.11

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 (40) hide show
  1. package/CHANGELOG.md +23 -4
  2. package/dist/esm/Calendar/style/index.js +3 -1
  3. package/dist/esm/Calendar/style/style.css +1 -1
  4. package/dist/esm/Calendar.js +267 -10
  5. package/dist/esm/CalendarCard.js +1 -1
  6. package/dist/esm/CalendarItem.js +119 -42
  7. package/dist/esm/SearchBar/style/style.css +1 -1
  8. package/dist/esm/configprovider2.js +4 -0
  9. package/dist/esm/date.js +7 -80
  10. package/dist/esm/utils.js +125 -0
  11. package/dist/locales/base.d.ts +4 -0
  12. package/dist/locales/base.js +1 -1
  13. package/dist/locales/en-US.js +5 -1
  14. package/dist/locales/id-ID.js +5 -1
  15. package/dist/locales/tr-TR.js +5 -1
  16. package/dist/locales/zh-CN.js +5 -1
  17. package/dist/locales/zh-TW.js +5 -1
  18. package/dist/locales/zh-UG.js +5 -1
  19. package/dist/nutui.react.es.js +553 -114
  20. package/dist/nutui.react.umd.js +553 -114
  21. package/dist/packages/calendar/calendar.scss +24 -0
  22. package/dist/packages/calendar/calendarviewmode.scss +181 -0
  23. package/dist/packages/searchbar/searchbar.scss +2 -0
  24. package/dist/style.css +1 -1
  25. package/dist/styles/variables-jmapp.scss +4 -0
  26. package/dist/styles/variables.scss +4 -0
  27. package/dist/types/locales/base.d.ts +4 -0
  28. package/dist/types/packages/calendar/calendar.d.ts +4 -0
  29. package/dist/types/packages/calendar/calendar.taro.d.ts +4 -0
  30. package/dist/types/packages/calendar/calendarviewmodeitem.d.ts +20 -0
  31. package/dist/types/packages/calendar/calendarviewmodeitem.taro.d.ts +20 -0
  32. package/dist/types/packages/calendar/types.d.ts +27 -0
  33. package/dist/types/packages/calendar/utils.d.ts +40 -0
  34. package/dist/types/packages/calendaritem/calendaritem.d.ts +1 -0
  35. package/dist/types/packages/calendaritem/calendaritem.taro.d.ts +1 -0
  36. package/dist/types/packages/calendaritem/utils.d.ts +17 -0
  37. package/dist/types/packages/configprovider/types.d.ts +1 -1
  38. package/dist/types/packages/searchbar/searchbar.taro.d.ts +11 -5
  39. package/dist/types/utils/date.d.ts +0 -17
  40. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react", "react-dom"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.nutui = {}, global2.React, global2.ReactDOM));
3
3
  })(this, function(exports2, React, ReactDOM) {
4
4
  "use strict";/*!
5
- * @nutui/nutui-react v2.7.9 Fri Feb 21 2025 17:10:51 GMT+0800 (China Standard Time)
5
+ * @nutui/nutui-react v2.7.11 Fri Mar 28 2025 13:38:10 GMT+0800 (China Standard Time)
6
6
  * (c) 2023 @jdf2e.
7
7
  * Released under the MIT License.
8
8
  */
@@ -612,7 +612,7 @@
612
612
  style: {}
613
613
  };
614
614
  const prefixCls$2 = "nut-button";
615
- const defaultProps$1t = {
615
+ const defaultProps$1u = {
616
616
  ...ComponentDefaults,
617
617
  color: "",
618
618
  type: "default",
@@ -648,7 +648,7 @@
648
648
  onClick,
649
649
  ...rest
650
650
  } = {
651
- ...defaultProps$1t,
651
+ ...defaultProps$1u,
652
652
  ...props
653
653
  };
654
654
  const getStyle = React.useCallback(() => {
@@ -707,7 +707,7 @@
707
707
  );
708
708
  Button.displayName = "NutButton";
709
709
  const CellGroupContext = React.createContext(null);
710
- const defaultProps$1s = {
710
+ const defaultProps$1t = {
711
711
  ...ComponentDefaults,
712
712
  title: "",
713
713
  description: "",
@@ -716,7 +716,7 @@
716
716
  const classPrefix$r = "nut-cell-group";
717
717
  const CellGroup = (props) => {
718
718
  const { children, className, title, description, divider, ...rest } = {
719
- ...defaultProps$1s,
719
+ ...defaultProps$1t,
720
720
  ...props
721
721
  };
722
722
  return /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix$r, className), ...rest }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$r}-title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$r}-description` }, description) : null, /* @__PURE__ */ React.createElement(
@@ -728,7 +728,7 @@
728
728
  ));
729
729
  };
730
730
  CellGroup.displayName = "NutCellGroup";
731
- const defaultProps$1r = {
731
+ const defaultProps$1s = {
732
732
  ...ComponentDefaults,
733
733
  title: null,
734
734
  description: null,
@@ -755,7 +755,7 @@
755
755
  style,
756
756
  ...rest
757
757
  } = {
758
- ...defaultProps$1r,
758
+ ...defaultProps$1s,
759
759
  ...props
760
760
  };
761
761
  const handleClick2 = (event) => {
@@ -1768,6 +1768,10 @@
1768
1768
  start: "开始",
1769
1769
  confirm: "确认",
1770
1770
  title: "日历选择",
1771
+ week: "周",
1772
+ month: "月",
1773
+ year: "年",
1774
+ quarter: "季度",
1771
1775
  monthTitle: (year, month) => `${year}年${Number(month) < 10 ? `0${Number(month)}` : month}月`,
1772
1776
  today: "今天",
1773
1777
  loadPreviousMonth: "加载上一个月",
@@ -1958,7 +1962,7 @@
1958
1962
  const pxCheck = (value) => {
1959
1963
  return Number.isNaN(Number(value)) ? String(value) : `${value}px`;
1960
1964
  };
1961
- const defaultProps$1q = {
1965
+ const defaultProps$1r = {
1962
1966
  ...ComponentDefaults,
1963
1967
  fit: "fill",
1964
1968
  position: "center",
@@ -1988,7 +1992,7 @@
1988
1992
  onClick,
1989
1993
  onLoad,
1990
1994
  onError
1991
- } = { ...defaultProps$1q, ...props };
1995
+ } = { ...defaultProps$1r, ...props };
1992
1996
  const [innerLoading, setInnerLoading] = React.useState(false);
1993
1997
  const [isError, setIsError] = React.useState(false);
1994
1998
  const [complete, setComplete] = React.useState(false);
@@ -2851,7 +2855,7 @@
2851
2855
  };
2852
2856
  Overlay.displayName = "NutOverlay";
2853
2857
  const DataContext$1 = React.createContext({});
2854
- const defaultProps$1p = {
2858
+ const defaultProps$1q = {
2855
2859
  ...ComponentDefaults,
2856
2860
  span: "24",
2857
2861
  offset: "0",
@@ -2859,7 +2863,7 @@
2859
2863
  };
2860
2864
  const Col = (props) => {
2861
2865
  const { className, style, span, offset, children, onClick } = {
2862
- ...defaultProps$1p,
2866
+ ...defaultProps$1q,
2863
2867
  ...props
2864
2868
  };
2865
2869
  const [colName, setColName] = React.useState("");
@@ -2892,7 +2896,7 @@
2892
2896
  );
2893
2897
  };
2894
2898
  Col.displayName = "NutCol";
2895
- const defaultProps$1o = {
2899
+ const defaultProps$1p = {
2896
2900
  ...ComponentDefaults,
2897
2901
  contentPosition: "center",
2898
2902
  direction: "horizontal"
@@ -2900,7 +2904,7 @@
2900
2904
  const classPrefix$n = `nut-divider`;
2901
2905
  const Divider = (props) => {
2902
2906
  const { children, contentPosition, style, className, direction, ...rest } = {
2903
- ...defaultProps$1o,
2907
+ ...defaultProps$1p,
2904
2908
  ...props
2905
2909
  };
2906
2910
  const classes = direction === "horizontal" ? classNames({
@@ -2921,7 +2925,7 @@
2921
2925
  }
2922
2926
  };
2923
2927
  const GridContext = React.createContext(gridContext);
2924
- const defaultProps$1n = {
2928
+ const defaultProps$1o = {
2925
2929
  text: "",
2926
2930
  columns: 4,
2927
2931
  gap: 0,
@@ -2946,7 +2950,7 @@
2946
2950
  onClick,
2947
2951
  ...rest
2948
2952
  } = {
2949
- ...defaultProps$1n,
2953
+ ...defaultProps$1o,
2950
2954
  ...props
2951
2955
  };
2952
2956
  const classPrefix2 = "nut-grid-item";
@@ -3005,7 +3009,7 @@
3005
3009
  );
3006
3010
  };
3007
3011
  GridItem.displayName = "NutGridItem";
3008
- const defaultProps$1m = {
3012
+ const defaultProps$1n = {
3009
3013
  columns: 4,
3010
3014
  gap: 0,
3011
3015
  center: true,
@@ -3026,7 +3030,7 @@
3026
3030
  className,
3027
3031
  onClick,
3028
3032
  ...rest
3029
- } = { ...defaultProps$1m, ...props };
3033
+ } = { ...defaultProps$1n, ...props };
3030
3034
  const childrenDom = React.Children.toArray(children);
3031
3035
  const classPrefix2 = "nut-grid";
3032
3036
  const rootClass = () => {
@@ -3067,7 +3071,7 @@
3067
3071
  };
3068
3072
  Layout.displayName = "NutLayout";
3069
3073
  const classPrefix$m = "nut-row";
3070
- const defaultProps$1l = {
3074
+ const defaultProps$1m = {
3071
3075
  ...ComponentDefaults,
3072
3076
  type: "",
3073
3077
  justify: "start",
@@ -3087,7 +3091,7 @@
3087
3091
  gutter,
3088
3092
  onClick
3089
3093
  } = {
3090
- ...defaultProps$1l,
3094
+ ...defaultProps$1m,
3091
3095
  ...props
3092
3096
  };
3093
3097
  const getClass = (prefix2, type22) => {
@@ -3121,12 +3125,12 @@
3121
3125
  };
3122
3126
  Row.displayName = "NutRow";
3123
3127
  const prefixCls$1 = "nut-space";
3124
- const defaultProps$1k = {
3128
+ const defaultProps$1l = {
3125
3129
  direction: "horizontal"
3126
3130
  };
3127
3131
  const Space = (props) => {
3128
3132
  const { className, style, children, wrap, align, direction, justify } = {
3129
- ...defaultProps$1k,
3133
+ ...defaultProps$1l,
3130
3134
  ...props
3131
3135
  };
3132
3136
  const cls = classNames(
@@ -3194,7 +3198,7 @@
3194
3198
  stop2.current = true;
3195
3199
  };
3196
3200
  }
3197
- const defaultProps$1j = {
3201
+ const defaultProps$1k = {
3198
3202
  ...ComponentDefaults,
3199
3203
  position: "top",
3200
3204
  threshold: 0,
@@ -3212,7 +3216,7 @@
3212
3216
  threshold,
3213
3217
  onChange,
3214
3218
  ...rest
3215
- } = { ...defaultProps$1j, ...props };
3219
+ } = { ...defaultProps$1k, ...props };
3216
3220
  const stickyRef = React.useRef(null);
3217
3221
  const rootRef = React.useRef(null);
3218
3222
  const [isFixed, setIsFixed] = React.useState(false);
@@ -3336,7 +3340,7 @@
3336
3340
  );
3337
3341
  };
3338
3342
  SafeArea.displayName = "NutSafeArea";
3339
- const defaultProps$1i = {
3343
+ const defaultProps$1j = {
3340
3344
  ...ComponentDefaults,
3341
3345
  target: "",
3342
3346
  threshold: 200,
@@ -3355,7 +3359,7 @@
3355
3359
  style,
3356
3360
  onClick
3357
3361
  } = {
3358
- ...defaultProps$1i,
3362
+ ...defaultProps$1j,
3359
3363
  ...props
3360
3364
  };
3361
3365
  const classPrefix2 = "nut-backtop";
@@ -8248,7 +8252,7 @@
8248
8252
  });
8249
8253
  const animated = host.animated;
8250
8254
  const elevatorContext = React.createContext({});
8251
- const defaultProps$1h = {
8255
+ const defaultProps$1i = {
8252
8256
  ...ComponentDefaults,
8253
8257
  height: "200px",
8254
8258
  floorKey: "title",
@@ -8274,7 +8278,7 @@
8274
8278
  children,
8275
8279
  ...rest
8276
8280
  } = {
8277
- ...defaultProps$1h,
8281
+ ...defaultProps$1i,
8278
8282
  ...props
8279
8283
  };
8280
8284
  const classPrefix2 = "nut-elevator";
@@ -8452,7 +8456,7 @@
8452
8456
  };
8453
8457
  Elevator.displayName = "NutElevator";
8454
8458
  Elevator.Context = elevatorContext;
8455
- const defaultProps$1g = {
8459
+ const defaultProps$1h = {
8456
8460
  ...ComponentDefaults,
8457
8461
  activeText: "",
8458
8462
  inactiveText: "",
@@ -8480,7 +8484,7 @@
8480
8484
  content,
8481
8485
  ...rest
8482
8486
  } = {
8483
- ...defaultProps$1g,
8487
+ ...defaultProps$1h,
8484
8488
  ...props
8485
8489
  };
8486
8490
  const classPrefix2 = "nut-fixednav";
@@ -8533,7 +8537,7 @@
8533
8537
  );
8534
8538
  };
8535
8539
  FixedNav.displayName = "NutFixedNav";
8536
- const defaultProps$1f = {
8540
+ const defaultProps$1g = {
8537
8541
  ...ComponentDefaults,
8538
8542
  left: "",
8539
8543
  right: "",
@@ -8558,7 +8562,7 @@
8558
8562
  zIndex,
8559
8563
  onBackClick
8560
8564
  } = {
8561
- ...defaultProps$1f,
8565
+ ...defaultProps$1g,
8562
8566
  ...props
8563
8567
  };
8564
8568
  const classPrefix2 = "nut-navbar";
@@ -8634,7 +8638,7 @@
8634
8638
  return /* @__PURE__ */ React.createElement(React.Fragment, null, safeAreaInsetTop && /* @__PURE__ */ React.createElement(SafeArea, { position: "top" }), fixed && placeholder ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-placeholder` }, renderWrapper()) : renderWrapper());
8635
8639
  };
8636
8640
  NavBar.displayName = "NutNavBar";
8637
- const defaultProps$1e = {
8641
+ const defaultProps$1f = {
8638
8642
  ...ComponentDefaults,
8639
8643
  position: "center",
8640
8644
  transition: "",
@@ -8687,7 +8691,7 @@
8687
8691
  afterShow,
8688
8692
  afterClose,
8689
8693
  onClick
8690
- } = { ...defaultProps$1e, ...props };
8694
+ } = { ...defaultProps$1f, ...props };
8691
8695
  const nodeRef = React.useRef(null);
8692
8696
  let innerIndex = zIndex || _zIndex;
8693
8697
  const [index, setIndex] = React.useState(innerIndex);
@@ -8844,7 +8848,7 @@
8844
8848
  }
8845
8849
  };
8846
8850
  const OffsetContext = React.createContext(20);
8847
- const defaultProps$1d = {
8851
+ const defaultProps$1e = {
8848
8852
  ...ComponentDefaults,
8849
8853
  position: "left",
8850
8854
  width: "80%"
@@ -8862,7 +8866,7 @@
8862
8866
  indent,
8863
8867
  ...rest
8864
8868
  } = {
8865
- ...defaultProps$1d,
8869
+ ...defaultProps$1e,
8866
8870
  ...props
8867
8871
  };
8868
8872
  const innerIndent = indent ? Number(indent) : 20;
@@ -8912,13 +8916,13 @@
8912
8916
  title
8913
8917
  );
8914
8918
  };
8915
- const defaultProps$1c = {
8919
+ const defaultProps$1d = {
8916
8920
  open: true
8917
8921
  };
8918
8922
  const SubSideNavBar = (props) => {
8919
8923
  const classPrefix2 = "nut-subsidenavbar";
8920
8924
  const { title, value, children, onClick, open, ...rest } = {
8921
- ...defaultProps$1c,
8925
+ ...defaultProps$1d,
8922
8926
  ...props
8923
8927
  };
8924
8928
  const offset = React.useContext(OffsetContext);
@@ -8995,7 +8999,7 @@
8995
8999
  );
8996
9000
  return [stateRef.current, setState];
8997
9001
  }
8998
- const defaultProps$1b = {
9002
+ const defaultProps$1c = {
8999
9003
  ...ComponentDefaults,
9000
9004
  value: "",
9001
9005
  dot: false,
@@ -9020,7 +9024,7 @@
9020
9024
  color,
9021
9025
  fill
9022
9026
  } = {
9023
- ...defaultProps$1b,
9027
+ ...defaultProps$1c,
9024
9028
  ...props
9025
9029
  };
9026
9030
  const classPrefix2 = "nut-badge";
@@ -9074,7 +9078,7 @@
9074
9078
  };
9075
9079
  Badge.displayName = "NutBadge";
9076
9080
  const TabbarContext = React.createContext(null);
9077
- const defaultProps$1a = {
9081
+ const defaultProps$1b = {
9078
9082
  ...ComponentDefaults,
9079
9083
  title: "",
9080
9084
  icon: null,
@@ -9100,7 +9104,7 @@
9100
9104
  index,
9101
9105
  ...rest
9102
9106
  } = {
9103
- ...defaultProps$1a,
9107
+ ...defaultProps$1b,
9104
9108
  ...props
9105
9109
  };
9106
9110
  const active = index === (ctx2 == null ? void 0 : ctx2.selectIndex);
@@ -9138,7 +9142,7 @@
9138
9142
  icon ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Badge, { ...badgeProps }, /* @__PURE__ */ React.createElement("div", { className: boxPrefix }, icon)), /* @__PURE__ */ React.createElement("div", { className: titleClass }, title)) : /* @__PURE__ */ React.createElement(Badge, { ...badgeProps }, /* @__PURE__ */ React.createElement("div", { className: titleClass }, title))
9139
9143
  );
9140
9144
  };
9141
- const defaultProps$19 = {
9145
+ const defaultProps$1a = {
9142
9146
  ...ComponentDefaults,
9143
9147
  defaultValue: 0,
9144
9148
  fixed: false,
@@ -9161,7 +9165,7 @@
9161
9165
  style,
9162
9166
  onSwitch
9163
9167
  } = {
9164
- ...defaultProps$19,
9168
+ ...defaultProps$1a,
9165
9169
  ...props
9166
9170
  };
9167
9171
  const classPrefix2 = "nut-tabbar";
@@ -9203,14 +9207,14 @@
9203
9207
  };
9204
9208
  Tabbar.displayName = "NutTabbar";
9205
9209
  Tabbar.Item = TabbarItem;
9206
- const defaultProps$18 = {
9210
+ const defaultProps$19 = {
9207
9211
  title: "",
9208
9212
  value: "",
9209
9213
  disabled: false
9210
9214
  };
9211
9215
  const TabPane = (props) => {
9212
9216
  const { children, autoHeightClassName, className, disabled } = {
9213
- ...defaultProps$18,
9217
+ ...defaultProps$19,
9214
9218
  ...props
9215
9219
  };
9216
9220
  const classPrefix2 = "nut-tabpane";
@@ -9224,7 +9228,7 @@
9224
9228
  );
9225
9229
  return children && /* @__PURE__ */ React.createElement("div", { className: classes }, !disabled && children);
9226
9230
  };
9227
- const defaultProps$17 = {
9231
+ const defaultProps$18 = {
9228
9232
  ...ComponentDefaults,
9229
9233
  tabStyle: {},
9230
9234
  activeColor: "",
@@ -9252,7 +9256,7 @@
9252
9256
  value: outerValue,
9253
9257
  defaultValue: outerDefaultValue,
9254
9258
  ...rest
9255
- } = { ...defaultProps$17, ...props };
9259
+ } = { ...defaultProps$18, ...props };
9256
9260
  const [value, setValue] = usePropsValue({
9257
9261
  value: outerValue,
9258
9262
  defaultValue: outerDefaultValue,
@@ -9533,7 +9537,7 @@
9533
9537
  return pathNodes;
9534
9538
  }
9535
9539
  }
9536
- const defaultProps$16 = {
9540
+ const defaultProps$17 = {
9537
9541
  ...ComponentDefaults,
9538
9542
  activeColor: "",
9539
9543
  activeIcon: "checklist",
@@ -9579,7 +9583,7 @@
9579
9583
  onClose,
9580
9584
  onChange,
9581
9585
  onPathChange
9582
- } = { ...defaultProps$16, ...props };
9586
+ } = { ...defaultProps$17, ...props };
9583
9587
  const [tabvalue, setTabvalue] = React.useState("c1");
9584
9588
  const [optionsData, setOptionsData] = React.useState([]);
9585
9589
  const isLazy = () => state.configs.lazy && Boolean(state.configs.onLoad);
@@ -9889,7 +9893,7 @@
9889
9893
  };
9890
9894
  const Cascader = React.forwardRef(InternalCascader);
9891
9895
  Cascader.displayName = "NutCascader";
9892
- const defaultProps$15 = {
9896
+ const defaultProps$16 = {
9893
9897
  ...ComponentDefaults,
9894
9898
  visible: false,
9895
9899
  type: "custom",
@@ -9916,7 +9920,7 @@
9916
9920
  onPathChange,
9917
9921
  ...rest
9918
9922
  } = {
9919
- ...defaultProps$15,
9923
+ ...defaultProps$16,
9920
9924
  ...props
9921
9925
  };
9922
9926
  return /* @__PURE__ */ React.createElement(React.Fragment, null, type === "custom" && /* @__PURE__ */ React.createElement(
@@ -9941,7 +9945,7 @@
9941
9945
  }
9942
9946
  ));
9943
9947
  };
9944
- const defaultProps$14 = {
9948
+ const defaultProps$15 = {
9945
9949
  type: "custom",
9946
9950
  existList: [],
9947
9951
  defaultIcon: null,
@@ -9960,7 +9964,7 @@
9960
9964
  onSelect,
9961
9965
  onSwitch,
9962
9966
  ...rest
9963
- } = { ...defaultProps$14, ...props };
9967
+ } = { ...defaultProps$15, ...props };
9964
9968
  const classPrefix2 = "nut-address";
9965
9969
  const selectedExist = (item) => {
9966
9970
  existList.forEach((list, index) => {
@@ -9989,7 +9993,7 @@
9989
9993
  );
9990
9994
  })), (custom || custom && locale.address.chooseAnotherAddress) && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer`, onClick }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-footer-btn` }, custom)));
9991
9995
  };
9992
- const defaultProps$13 = {
9996
+ const defaultProps$14 = {
9993
9997
  ...ComponentDefaults,
9994
9998
  defaultValue: [],
9995
9999
  type: "custom",
@@ -10031,7 +10035,7 @@
10031
10035
  onSwitch,
10032
10036
  ...rest
10033
10037
  } = {
10034
- ...defaultProps$13,
10038
+ ...defaultProps$14,
10035
10039
  ...props
10036
10040
  };
10037
10041
  const classPrefix2 = "nut-address";
@@ -10188,33 +10192,6 @@
10188
10192
  const endTime = new Date(date22.replace(/-/g, "/")).getTime();
10189
10193
  return startTime === endTime;
10190
10194
  };
10191
- const getWeekDate = (year, month, date, firstDayOfWeek = 0) => {
10192
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
10193
- const nowTime = dateNow.getTime();
10194
- let day = dateNow.getDay();
10195
- if (firstDayOfWeek === 0) {
10196
- const oneDayTime2 = 24 * 60 * 60 * 1e3;
10197
- const SundayTime2 = nowTime - day * oneDayTime2;
10198
- const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
10199
- const sunday2 = date2Str(new Date(SundayTime2));
10200
- const saturday = date2Str(new Date(SaturdayTime));
10201
- return [sunday2, saturday];
10202
- }
10203
- day = day === 0 ? 7 : day;
10204
- const oneDayTime = 24 * 60 * 60 * 1e3;
10205
- const MondayTime = nowTime - (day - 1) * oneDayTime;
10206
- const SundayTime = nowTime + (7 - day) * oneDayTime;
10207
- const monday = date2Str(new Date(MondayTime));
10208
- const sunday = date2Str(new Date(SundayTime));
10209
- return [monday, sunday];
10210
- };
10211
- const formatResultDate = (date) => {
10212
- const [year, month, day] = [...date.split("-")];
10213
- const formatterDay = getNumTwoBit(Number(day));
10214
- const formatterDate = `${year}-${month}-${day}`;
10215
- const dayOfWeek = getWhatDay(Number(year), Number(month), Number(day));
10216
- return [year, month, formatterDay, formatterDate, dayOfWeek];
10217
- };
10218
10195
  const getCurrMonthData = (type, year, month) => {
10219
10196
  {
10220
10197
  month === 12 && (year += 1);
@@ -10256,6 +10233,74 @@
10256
10233
  });
10257
10234
  return months.slice(preDates - days);
10258
10235
  };
10236
+ const getWeekDate = (year, month, date, firstDayOfWeek = 0) => {
10237
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
10238
+ const nowTime = dateNow.getTime();
10239
+ let day = dateNow.getDay();
10240
+ if (firstDayOfWeek === 0) {
10241
+ const oneDayTime2 = 24 * 60 * 60 * 1e3;
10242
+ const SundayTime2 = nowTime - day * oneDayTime2;
10243
+ const SaturdayTime = nowTime + (6 - day) * oneDayTime2;
10244
+ const sunday2 = date2Str(new Date(SundayTime2));
10245
+ const saturday = date2Str(new Date(SaturdayTime));
10246
+ return [sunday2, saturday];
10247
+ }
10248
+ day = day === 0 ? 7 : day;
10249
+ const oneDayTime = 24 * 60 * 60 * 1e3;
10250
+ const MondayTime = nowTime - (day - 1) * oneDayTime;
10251
+ const SundayTime = nowTime + (7 - day) * oneDayTime;
10252
+ const monday = date2Str(new Date(MondayTime));
10253
+ const sunday = date2Str(new Date(SundayTime));
10254
+ return [monday, sunday];
10255
+ };
10256
+ const formatResultDate = (date) => {
10257
+ const [year, month, day] = [...date.split("-")];
10258
+ const formatterDay = getNumTwoBit(Number(day));
10259
+ const formatterDate = `${year}-${month}-${day}`;
10260
+ const dayOfWeek = getWhatDay(Number(year), Number(month), Number(day));
10261
+ return [year, month, formatterDay, formatterDate, dayOfWeek];
10262
+ };
10263
+ const getWeekOfYearByYMD = (year, month, date, firstDayOfWeek = 0) => {
10264
+ const MILLISECONDS_PER_DAY = 864e5;
10265
+ const dateNow = new Date(year, month - 1, date);
10266
+ const dateFirst = new Date(year, 0, 1);
10267
+ const dayOfYear = Math.round(
10268
+ (dateNow.valueOf() - dateFirst.valueOf()) / MILLISECONDS_PER_DAY
10269
+ );
10270
+ const DAYS_OF_FIRST_WEEK = 3;
10271
+ let dayOfWeek = dateNow.getDay();
10272
+ let remainder = 6 - dayOfWeek - DAYS_OF_FIRST_WEEK;
10273
+ if (firstDayOfWeek !== 0) {
10274
+ dayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
10275
+ remainder = 7 - dayOfWeek - DAYS_OF_FIRST_WEEK;
10276
+ }
10277
+ let weekNo = Math.ceil((dayOfYear + remainder + 1) / 7);
10278
+ if (weekNo === 0) {
10279
+ weekNo = getWeekOfYearByYMD(year - 1, 12, 31, firstDayOfWeek);
10280
+ } else if (weekNo === 53) {
10281
+ const remainder2 = 7 - dayOfWeek - DAYS_OF_FIRST_WEEK;
10282
+ weekNo = remainder2 > 0 ? 1 : weekNo;
10283
+ }
10284
+ return weekNo;
10285
+ };
10286
+ const getWeekNosOfYear = (year, month, firstDayOfWeek) => {
10287
+ const startWeekNo = getWeekOfYearByYMD(year, month, 1, firstDayOfWeek);
10288
+ const endWeekNo = getWeekOfYearByYMD(
10289
+ year,
10290
+ month,
10291
+ getMonthDays(`${year}`, `${month}`),
10292
+ firstDayOfWeek
10293
+ );
10294
+ return Array.from(
10295
+ {
10296
+ length: (endWeekNo === 1 ? 53 : endWeekNo) - (startWeekNo === 53 || startWeekNo === 52 ? 0 : startWeekNo) + 1
10297
+ },
10298
+ (_, i2) => {
10299
+ const lastIndex = (endWeekNo === 1 ? 53 : endWeekNo) - startWeekNo;
10300
+ return `${endWeekNo === 1 && i2 === lastIndex ? 1 : ((startWeekNo === 53 || startWeekNo === 52) && i2 !== 0 ? 0 : startWeekNo) + i2}`;
10301
+ }
10302
+ );
10303
+ };
10259
10304
  const splitDate = (date) => {
10260
10305
  const split = date.indexOf("-") !== -1 ? "-" : "/";
10261
10306
  return date.split(split);
@@ -10284,7 +10329,89 @@
10284
10329
  const isStartAndEnd = (days) => {
10285
10330
  return days.length >= 2 && isEqual(days[0], days[1]);
10286
10331
  };
10287
- const defaultProps$12 = {
10332
+ const getPreMonths = (type, year, month) => {
10333
+ const preMonth = +month - 1;
10334
+ const months = Array.from(Array(preMonth), (v, k) => {
10335
+ return {
10336
+ year,
10337
+ month: k + 1,
10338
+ yearAndMonth: formatMonth(year, k + 1),
10339
+ type
10340
+ };
10341
+ });
10342
+ return months;
10343
+ };
10344
+ const getMonths = (type, year, month, endMonth = 12) => {
10345
+ const nextMonth = endMonth - month + 1;
10346
+ const months = Array.from(Array(nextMonth), (v, k) => {
10347
+ return {
10348
+ year,
10349
+ month: k + month,
10350
+ yearAndMonth: formatMonth(year, k + month),
10351
+ type
10352
+ };
10353
+ });
10354
+ return months;
10355
+ };
10356
+ const formatMonth = (year, month) => {
10357
+ return `${year}-${String(month).padStart(2, "0")}`;
10358
+ };
10359
+ const formatQuarter = (year, quarter) => {
10360
+ return `${year}-Q${quarter}`;
10361
+ };
10362
+ const getQuarter = (month) => {
10363
+ if (month < 1 || month > 12) {
10364
+ throw new Error("月份必须在 1 到 12 之间");
10365
+ }
10366
+ const quarter = Math.floor((month - 1) / 3) + 1;
10367
+ return quarter;
10368
+ };
10369
+ const getQuarters = (type, year, month, endMonth = 12) => {
10370
+ const quarters = [];
10371
+ const startIndex = month;
10372
+ const endIndex = endMonth;
10373
+ for (let index = startIndex; index <= endIndex; index += 3) {
10374
+ const quarter = getQuarter(index);
10375
+ quarters.push({
10376
+ year,
10377
+ quarter,
10378
+ yearAndQuarter: formatQuarter(year, quarter),
10379
+ type
10380
+ });
10381
+ }
10382
+ return quarters;
10383
+ };
10384
+ const getPreQuarters = (type, year, month) => {
10385
+ const quarters = [];
10386
+ const startIndex = 1;
10387
+ const endIndex = month - 3;
10388
+ for (let index = startIndex; index <= endIndex; index += 3) {
10389
+ const quarter = getQuarter(index);
10390
+ quarters.push({
10391
+ year,
10392
+ quarter,
10393
+ yearAndQuarter: formatQuarter(year, quarter),
10394
+ type
10395
+ });
10396
+ }
10397
+ return quarters;
10398
+ };
10399
+ const getNextQuarters = (type, year, month, endMonth = 12) => {
10400
+ const quarters = [];
10401
+ const startIndex = month + 3;
10402
+ const endIndex = endMonth;
10403
+ for (let index = startIndex; index <= endIndex; index += 3) {
10404
+ const quarter = getQuarter(index);
10405
+ quarters.push({
10406
+ year,
10407
+ quarter,
10408
+ yearAndQuarter: formatQuarter(year, quarter),
10409
+ type
10410
+ });
10411
+ }
10412
+ return quarters;
10413
+ };
10414
+ const defaultProps$13 = {
10288
10415
  ...ComponentDefaults,
10289
10416
  type: "single",
10290
10417
  autoBackfill: false,
@@ -10298,6 +10425,7 @@
10298
10425
  confirmText: "",
10299
10426
  showTitle: true,
10300
10427
  showSubTitle: true,
10428
+ showMonthNumber: false,
10301
10429
  scrollAnimation: true,
10302
10430
  firstDayOfWeek: 0,
10303
10431
  disableDate: (date) => false,
@@ -10324,6 +10452,7 @@
10324
10452
  type,
10325
10453
  autoBackfill,
10326
10454
  title,
10455
+ value,
10327
10456
  defaultValue,
10328
10457
  startDate,
10329
10458
  endDate,
@@ -10333,6 +10462,7 @@
10333
10462
  confirmText,
10334
10463
  showTitle,
10335
10464
  showSubTitle,
10465
+ showMonthNumber,
10336
10466
  scrollAnimation,
10337
10467
  firstDayOfWeek,
10338
10468
  disableDate,
@@ -10341,12 +10471,11 @@
10341
10471
  renderDay,
10342
10472
  renderDayTop,
10343
10473
  renderDayBottom,
10344
- value,
10345
10474
  onConfirm,
10346
10475
  onUpdate,
10347
10476
  onDayClick,
10348
10477
  onPageChange
10349
- } = { ...defaultProps$12, ...props };
10478
+ } = { ...defaultProps$13, ...props };
10350
10479
  const classPrefix2 = "nut-calendar";
10351
10480
  const dayPrefix = "nut-calendar-day";
10352
10481
  const weekdays = locale.calendaritem.weekdays;
@@ -10371,7 +10500,7 @@
10371
10500
  if (defaultValue || Array.isArray(defaultValue) && defaultValue.length > 0) {
10372
10501
  return type !== "single" ? [...defaultValue] : defaultValue;
10373
10502
  }
10374
- return void 0;
10503
+ return type === "single" ? "" : [];
10375
10504
  };
10376
10505
  const [currentDate, setCurrentDate] = usePropsValue({
10377
10506
  value,
@@ -10397,15 +10526,16 @@
10397
10526
  ...getPreMonthDates("prev", y, m2, firstDayOfWeek),
10398
10527
  ...getDaysStatus("active", y, m2)
10399
10528
  ];
10400
- const cssHeight = 39 + (days.length > 35 ? 384 : 320);
10401
10529
  let scrollTop = 0;
10402
10530
  if (monthData.length > 0) {
10403
10531
  const monthEle = monthData[monthData.length - 1];
10404
10532
  scrollTop = monthEle.scrollTop + monthEle.cssHeight;
10405
10533
  }
10534
+ const cssHeight = 39 + (days.length > 35 ? 384 : 320);
10406
10535
  const monthInfo = {
10407
10536
  curData: date,
10408
10537
  title: monthTitle(y, m2),
10538
+ weekNo: getWeekNosOfYear(y, m2, firstDayOfWeek),
10409
10539
  monthData: days,
10410
10540
  cssHeight,
10411
10541
  scrollTop
@@ -10427,7 +10557,7 @@
10427
10557
  const currentMonthsData = monthsData[current];
10428
10558
  if (currentMonthsData.title === yearMonthTitle) return;
10429
10559
  const [year, month] = currentMonthsData.curData;
10430
- onPageChange && onPageChange([year, month, `${year}-${month}`]);
10560
+ onPageChange == null ? void 0 : onPageChange([year, month, `${year}-${month}`]);
10431
10561
  setYearMonthTitle(currentMonthsData.title);
10432
10562
  };
10433
10563
  const setDefaultRange = (monthNum, current) => {
@@ -10531,9 +10661,7 @@
10531
10661
  const index = monthsData.findIndex((item) => {
10532
10662
  return +item.curData[0] === year && +item.curData[1] === month;
10533
10663
  });
10534
- if (index > -1) {
10535
- current = index;
10536
- }
10664
+ if (index > -1) current = index;
10537
10665
  }
10538
10666
  return {
10539
10667
  current,
@@ -10588,12 +10716,8 @@
10588
10716
  const getMonthNum = () => {
10589
10717
  let monthNum = Number(endDates[1]) - Number(startDates[1]);
10590
10718
  const yearNum = Number(endDates[0]) - Number(startDates[0]);
10591
- if (yearNum > 0) {
10592
- monthNum += 12 * yearNum;
10593
- }
10594
- if (monthNum <= 0) {
10595
- monthNum = 1;
10596
- }
10719
+ if (yearNum > 0) monthNum += 12 * yearNum;
10720
+ if (monthNum <= 0) monthNum = 1;
10597
10721
  setMonthsNum(monthNum);
10598
10722
  return monthNum;
10599
10723
  };
@@ -10616,7 +10740,7 @@
10616
10740
  initData();
10617
10741
  };
10618
10742
  React.useEffect(() => {
10619
- setCurrentDate(resetDefaultValue() || []);
10743
+ setCurrentDate(resetDefaultValue());
10620
10744
  }, [defaultValue]);
10621
10745
  React.useEffect(() => {
10622
10746
  popup && resetRender();
@@ -10769,7 +10893,7 @@
10769
10893
  state.currDateArray = [...days];
10770
10894
  }
10771
10895
  if (!isFirst) {
10772
- onDayClick && onDayClick(state.currDateArray);
10896
+ onDayClick == null ? void 0 : onDayClick(state.currDateArray);
10773
10897
  if (autoBackfill || !popup) {
10774
10898
  confirm2();
10775
10899
  }
@@ -10779,9 +10903,9 @@
10779
10903
  const confirm2 = () => {
10780
10904
  if (type === "range" && state.currDateArray.length === 2 || type !== "range") {
10781
10905
  const chooseData = state.currDateArray.slice(0);
10782
- onConfirm && onConfirm(chooseData);
10906
+ onConfirm == null ? void 0 : onConfirm(chooseData);
10783
10907
  if (popup) {
10784
- onUpdate && onUpdate();
10908
+ onUpdate == null ? void 0 : onUpdate();
10785
10909
  }
10786
10910
  }
10787
10911
  };
@@ -10804,7 +10928,14 @@
10804
10928
  return currentDate.length >= 2 && (type === "range" || type === "week") && day.type === "active" && isEnd(getCurrDate(day, month), currentDate);
10805
10929
  };
10806
10930
  const renderHeader = () => {
10807
- return /* @__PURE__ */ React.createElement("div", { className: headerClasses }, showTitle && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-title` }, title || locale.calendaritem.title), renderHeaderButtons && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-header-buttons` }, renderHeaderButtons()), showSubTitle && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-sub-title` }, yearMonthTitle), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-weeks`, ref: weeksPanel }, weeks.map((item) => /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-week-item`, key: item }, item))));
10931
+ return /* @__PURE__ */ React.createElement("div", { className: headerClasses }, showTitle && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-title` }, title || locale.calendaritem.title), renderHeaderButtons && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-header-buttons` }, renderHeaderButtons()), showSubTitle && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-sub-title` }, yearMonthTitle), /* @__PURE__ */ React.createElement(
10932
+ "div",
10933
+ {
10934
+ className: `${classPrefix2}-weeks ${showMonthNumber ? `${classPrefix2}-weeks-shrink` : ""}`,
10935
+ ref: weeksPanel
10936
+ },
10937
+ weeks.map((item) => /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-week-item`, key: item }, item))
10938
+ ));
10808
10939
  };
10809
10940
  const renderItem = (month, day, index) => {
10810
10941
  const startTip = isStartTip(day, month);
@@ -10813,7 +10944,7 @@
10813
10944
  return /* @__PURE__ */ React.createElement(
10814
10945
  "div",
10815
10946
  {
10816
- className: [`${classPrefix2}-day`, getClasses(day, month)].join(" "),
10947
+ className: classNames("nut-calendar-day", getClasses(day, month)),
10817
10948
  onClick: () => handleDayClick(day, month, false),
10818
10949
  key: index
10819
10950
  },
@@ -10824,7 +10955,11 @@
10824
10955
  startTip && /* @__PURE__ */ React.createElement(
10825
10956
  "div",
10826
10957
  {
10827
- className: `${classPrefix2}-day-info ${isStartAndEnd(currentDate) ? `${classPrefix2}-day-info-top` : ""}`
10958
+ className: classNames("nut-calendar-day-info", {
10959
+ "nut-calendar-day-info-top": isStartAndEnd(
10960
+ currentDate
10961
+ )
10962
+ })
10828
10963
  },
10829
10964
  startText || locale.calendaritem.start
10830
10965
  ),
@@ -10832,9 +10967,9 @@
10832
10967
  );
10833
10968
  };
10834
10969
  const renderPanel = (month, key) => {
10835
- return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-month`, key }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-month-title` }, month.title), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-days` }, month.monthData.map(
10970
+ return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-month`, key }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-month-title` }, month.title), /* @__PURE__ */ React.createElement("div", { className: `${showMonthNumber ? "shrink" : ""}` }, showMonthNumber && /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-weeknumber` }, month.weekNo.map((item, index) => /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-weeknumber-index`, key: index }, item))), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-days` }, month.monthData.map(
10836
10971
  (day, i2) => renderItem(month, day, i2)
10837
- )));
10972
+ ))));
10838
10973
  };
10839
10974
  const renderContent = () => {
10840
10975
  return /* @__PURE__ */ React.createElement(
@@ -10847,7 +10982,6 @@
10847
10982
  /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-pannel`, ref: monthsPanel }, /* @__PURE__ */ React.createElement(
10848
10983
  "div",
10849
10984
  {
10850
- className: "viewArea",
10851
10985
  ref: viewAreaRef,
10852
10986
  style: { transform: `translateY(${translateY}px)` }
10853
10987
  },
@@ -10863,13 +10997,295 @@
10863
10997
  return /* @__PURE__ */ React.createElement("div", { className: classes, style }, renderHeader(), renderContent(), popup && !autoBackfill ? renderFooter() : "");
10864
10998
  });
10865
10999
  CalendarItem.displayName = "NutCalendarItem";
11000
+ const YearMonthPanelHeight = 231;
11001
+ const YearQuarterPanelHeight = 103;
11002
+ const defaultProps$12 = {
11003
+ ...ComponentDefaults,
11004
+ type: "single",
11005
+ viewMode: "month",
11006
+ title: "",
11007
+ startDate: getDateString(0),
11008
+ endDate: getDateString(365),
11009
+ showToday: true,
11010
+ showTitle: true,
11011
+ scrollAnimation: true,
11012
+ renderDay: void 0,
11013
+ onItemClick: () => {
11014
+ }
11015
+ };
11016
+ const CalendarViewModeItem = React.forwardRef((props) => {
11017
+ const { locale } = useConfig();
11018
+ const {
11019
+ style,
11020
+ className,
11021
+ viewMode,
11022
+ title,
11023
+ value,
11024
+ defaultValue,
11025
+ startDate,
11026
+ endDate,
11027
+ showTitle,
11028
+ renderDay,
11029
+ onItemClick
11030
+ } = { ...defaultProps$12, ...props };
11031
+ const classPrefix2 = "nut-calendar-viewmode";
11032
+ const [panelDate, setPanelDate] = React.useState({
11033
+ months: [
11034
+ {
11035
+ year: (/* @__PURE__ */ new Date()).getFullYear(),
11036
+ months: [],
11037
+ cssHeight: 0,
11038
+ scrollTop: 0,
11039
+ currYear: false
11040
+ }
11041
+ ],
11042
+ quarters: [
11043
+ {
11044
+ year: (/* @__PURE__ */ new Date()).getFullYear(),
11045
+ quarters: [],
11046
+ cssHeight: 0,
11047
+ scrollTop: 0,
11048
+ currYear: false
11049
+ }
11050
+ ]
11051
+ });
11052
+ const propStartDate = startDate || getDateString(0);
11053
+ const propEndDate = endDate || getDateString(365);
11054
+ const startDates = splitDate(propStartDate);
11055
+ const endDates = splitDate(propEndDate);
11056
+ const [innerValue, setInnerValue] = usePropsValue({
11057
+ value,
11058
+ defaultValue,
11059
+ finalValue: [],
11060
+ onChange: (val) => {
11061
+ }
11062
+ });
11063
+ const monthsRef = React.useRef(null);
11064
+ const monthsPanel = React.useRef(null);
11065
+ const viewAreaRef = React.useRef(null);
11066
+ const getMonthsPanel = () => {
11067
+ return monthsPanel.current;
11068
+ };
11069
+ const getMonthsRef = () => {
11070
+ return monthsRef.current;
11071
+ };
11072
+ const requestAniFrameFunc = (viewMode2) => {
11073
+ switch (viewMode2) {
11074
+ case "month":
11075
+ {
11076
+ const lastItem = panelDate.months[panelDate.months.length - 1];
11077
+ const containerHeight = lastItem.cssHeight + lastItem.scrollTop;
11078
+ const currentIndex = panelDate.months.findIndex(
11079
+ (item) => item.currYear === true
11080
+ );
11081
+ requestAniFrame$1(() => {
11082
+ if (monthsRef && monthsPanel && viewAreaRef) {
11083
+ getMonthsRef().clientHeight;
11084
+ getMonthsPanel().style.height = `${containerHeight}px`;
11085
+ getMonthsRef().scrollTop = panelDate.months[currentIndex].scrollTop;
11086
+ }
11087
+ });
11088
+ }
11089
+ break;
11090
+ case "quarter":
11091
+ {
11092
+ const lastItem = panelDate.quarters[panelDate.quarters.length - 1];
11093
+ const containerHeight = lastItem.cssHeight + lastItem.scrollTop;
11094
+ const currentIndex = panelDate.quarters.findIndex(
11095
+ (item) => item.currYear === true
11096
+ );
11097
+ requestAniFrame$1(() => {
11098
+ if (monthsRef && monthsPanel && viewAreaRef) {
11099
+ getMonthsRef().clientHeight;
11100
+ getMonthsPanel().style.height = `${containerHeight}px`;
11101
+ getMonthsRef().scrollTop = panelDate.quarters[currentIndex].scrollTop;
11102
+ }
11103
+ });
11104
+ }
11105
+ break;
11106
+ }
11107
+ };
11108
+ const isCurrYear = (year) => {
11109
+ return innerValue.split("-")[0] === `${year}`;
11110
+ };
11111
+ const getMonthsData = () => {
11112
+ const startYear = Number(startDates[0]);
11113
+ const startMonth = Number(startDates[1]);
11114
+ const endYear = Number(endDates[0]);
11115
+ const endMonth = Number(endDates[1]);
11116
+ const panelData = [];
11117
+ const addPanelData = (year, months, scrollTop) => {
11118
+ panelData.push({
11119
+ year,
11120
+ months,
11121
+ scrollTop,
11122
+ cssHeight: YearMonthPanelHeight,
11123
+ currYear: isCurrYear(year)
11124
+ });
11125
+ };
11126
+ if (startYear === endYear) {
11127
+ addPanelData(
11128
+ startYear,
11129
+ [
11130
+ ...getPreMonths("prev", startYear, startMonth),
11131
+ ...getMonths("curr", startYear, startMonth, endMonth),
11132
+ ...getMonths("next", endYear, endMonth + 1)
11133
+ ],
11134
+ 0
11135
+ );
11136
+ } else {
11137
+ let scrollTop = panelData.length * YearMonthPanelHeight;
11138
+ const startMonths = [
11139
+ ...getPreMonths("prev", startYear, startMonth),
11140
+ ...getMonths("curr", startYear, startMonth)
11141
+ ];
11142
+ addPanelData(startYear, startMonths, scrollTop);
11143
+ for (let i2 = startYear + 1; i2 < endYear; i2++) {
11144
+ scrollTop = panelData.length * YearMonthPanelHeight;
11145
+ const midMonths = [...getMonths("curr", i2, 1)];
11146
+ addPanelData(i2, midMonths, scrollTop);
11147
+ }
11148
+ const lastMonths = [
11149
+ ...getPreMonths("curr", endYear, endMonth + 1),
11150
+ ...getMonths("next", endYear, endMonth + 1)
11151
+ ];
11152
+ scrollTop = panelData.length * YearMonthPanelHeight;
11153
+ addPanelData(endYear, lastMonths, scrollTop);
11154
+ }
11155
+ return panelData;
11156
+ };
11157
+ const getQuartersData = () => {
11158
+ const startYear = Number(startDates[0]);
11159
+ const startMonth = Number(startDates[1]);
11160
+ const endYear = Number(endDates[0]);
11161
+ const endMonth = Number(endDates[1]);
11162
+ const panelData = [];
11163
+ const addPanelData = (year, quarters, scrollTop) => {
11164
+ panelData.push({
11165
+ year,
11166
+ quarters,
11167
+ scrollTop,
11168
+ cssHeight: YearQuarterPanelHeight,
11169
+ currYear: isCurrYear(year)
11170
+ });
11171
+ };
11172
+ if (startYear === endYear) {
11173
+ const quarters = [
11174
+ ...getPreQuarters("prev", startYear, startMonth),
11175
+ ...getQuarters("curr", startYear, startMonth, endMonth),
11176
+ ...getNextQuarters("next", endYear, endMonth)
11177
+ ];
11178
+ addPanelData(startYear, quarters, 0);
11179
+ } else {
11180
+ let scrollTop = panelData.length * YearQuarterPanelHeight;
11181
+ const startQuarters = [
11182
+ ...getPreQuarters("prev", startYear, startMonth),
11183
+ ...getQuarters("curr", startYear, startMonth)
11184
+ ];
11185
+ addPanelData(startYear, startQuarters, scrollTop);
11186
+ for (let i2 = startYear + 1; i2 < endYear; i2++) {
11187
+ scrollTop = panelData.length * YearQuarterPanelHeight;
11188
+ const midQuarters = [...getQuarters("curr", i2, 1)];
11189
+ addPanelData(i2, midQuarters, scrollTop);
11190
+ }
11191
+ const lastQuarters = [
11192
+ ...getQuarters("curr", endYear, 1, endMonth),
11193
+ ...getNextQuarters("next", endYear, endMonth)
11194
+ ];
11195
+ scrollTop = panelData.length * YearQuarterPanelHeight;
11196
+ addPanelData(endYear, lastQuarters, scrollTop);
11197
+ }
11198
+ return panelData;
11199
+ };
11200
+ const initData = () => {
11201
+ const data = (
11202
+ // eslint-disable-next-line no-nested-ternary
11203
+ viewMode === "month" ? getMonthsData() : viewMode === "quarter" ? getQuartersData() : null
11204
+ );
11205
+ setPanelDate({ ...panelDate, [`${viewMode}s`]: data });
11206
+ };
11207
+ React.useEffect(() => {
11208
+ requestAniFrameFunc(viewMode);
11209
+ }, [panelDate]);
11210
+ React.useEffect(() => {
11211
+ initData();
11212
+ }, []);
11213
+ const handleItemClick = (item) => {
11214
+ if (item.type !== "curr") return;
11215
+ const val = viewMode === "month" ? item.yearAndMonth : item.yearAndQuarter;
11216
+ setInnerValue(val);
11217
+ onItemClick == null ? void 0 : onItemClick(val);
11218
+ };
11219
+ const isDisable = (item) => {
11220
+ return item.type === "prev" || item.type === "next";
11221
+ };
11222
+ const isActive = (item) => {
11223
+ const val = viewMode === "month" ? item.yearAndMonth : item.yearAndQuarter;
11224
+ return val === innerValue;
11225
+ };
11226
+ const getClasses = (item) => {
11227
+ if (isDisable(item)) {
11228
+ return ["disabled"];
11229
+ }
11230
+ const res = [];
11231
+ if (item.type === "curr") {
11232
+ if (isActive(item)) {
11233
+ res.push("active");
11234
+ }
11235
+ }
11236
+ return res;
11237
+ };
11238
+ const classes = classNames(classPrefix2, className);
11239
+ const renderHeader = () => {
11240
+ return showTitle && /* @__PURE__ */ React.createElement(
11241
+ "div",
11242
+ {
11243
+ className: classNames({
11244
+ [`${classPrefix2}-header`]: true
11245
+ })
11246
+ },
11247
+ /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-title` }, title)
11248
+ );
11249
+ };
11250
+ const renderItem = (item, index) => {
11251
+ const units = {
11252
+ month: locale.calendaritem.month,
11253
+ quarter: locale.calendaritem.quarter
11254
+ };
11255
+ return /* @__PURE__ */ React.createElement(
11256
+ "div",
11257
+ {
11258
+ className: classNames(
11259
+ `${classPrefix2}-item`,
11260
+ item.type,
11261
+ getClasses(item)
11262
+ ),
11263
+ onClick: () => handleItemClick(item),
11264
+ key: index
11265
+ },
11266
+ /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-item-${item.type}` }, renderDay ? renderDay(item) : `${item[viewMode]}${units[viewMode]}`)
11267
+ );
11268
+ };
11269
+ const renderPanel = () => {
11270
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, panelDate[`${viewMode}s`].map((item, key) => /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-panel`, key }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-panel-title` }, item.year), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-content` }, item[`${viewMode}s`].map(
11271
+ (item2, i2) => renderItem(item2, i2)
11272
+ )))));
11273
+ };
11274
+ const renderContent = () => {
11275
+ return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-content`, ref: monthsRef }, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-pannel`, ref: monthsPanel }, /* @__PURE__ */ React.createElement("div", { ref: viewAreaRef }, renderPanel())));
11276
+ };
11277
+ return /* @__PURE__ */ React.createElement("div", { className: classes, style }, renderHeader(), renderContent());
11278
+ });
11279
+ CalendarViewModeItem.displayName = "NutCalendarViewModeItem";
10866
11280
  const defaultProps$11 = {
10867
11281
  ...ComponentDefaults,
10868
11282
  type: "single",
11283
+ viewMode: "day",
10869
11284
  autoBackfill: false,
10870
11285
  popup: true,
10871
11286
  visible: false,
10872
11287
  title: "",
11288
+ value: "",
10873
11289
  defaultValue: "",
10874
11290
  startDate: getDateString(0),
10875
11291
  endDate: getDateString(365),
@@ -10879,6 +11295,7 @@
10879
11295
  confirmText: "",
10880
11296
  showTitle: true,
10881
11297
  showSubTitle: true,
11298
+ showMonthNumber: false,
10882
11299
  scrollAnimation: true,
10883
11300
  firstDayOfWeek: 0,
10884
11301
  disableDate: (date) => false,
@@ -10892,6 +11309,8 @@
10892
11309
  },
10893
11310
  onDayClick: (data) => {
10894
11311
  },
11312
+ onItemClick: () => {
11313
+ },
10895
11314
  onPageChange: (param) => {
10896
11315
  }
10897
11316
  };
@@ -10904,8 +11323,10 @@
10904
11323
  popup,
10905
11324
  visible,
10906
11325
  type,
11326
+ viewMode,
10907
11327
  autoBackfill,
10908
11328
  title,
11329
+ value,
10909
11330
  defaultValue,
10910
11331
  startDate,
10911
11332
  endDate,
@@ -10915,6 +11336,7 @@
10915
11336
  confirmText,
10916
11337
  showTitle,
10917
11338
  showSubTitle,
11339
+ showMonthNumber,
10918
11340
  scrollAnimation,
10919
11341
  firstDayOfWeek,
10920
11342
  closeIcon,
@@ -10927,6 +11349,7 @@
10927
11349
  onClose,
10928
11350
  onConfirm,
10929
11351
  onDayClick,
11352
+ onItemClick,
10930
11353
  onPageChange
10931
11354
  } = { ...defaultProps$11, ...props };
10932
11355
  const calendarRef = React.useRef(null);
@@ -10940,9 +11363,6 @@
10940
11363
  const closePopup = () => {
10941
11364
  close();
10942
11365
  };
10943
- const select = (param) => {
10944
- onDayClick && onDayClick(param);
10945
- };
10946
11366
  const scrollToDate = (date) => {
10947
11367
  var _a;
10948
11368
  (_a = calendarRef.current) == null ? void 0 : _a.scrollToDate(date);
@@ -10954,7 +11374,25 @@
10954
11374
  scrollToDate
10955
11375
  }));
10956
11376
  const renderItem = () => {
10957
- return /* @__PURE__ */ React.createElement(
11377
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, viewMode !== "day" ? /* @__PURE__ */ React.createElement(
11378
+ CalendarViewModeItem,
11379
+ {
11380
+ ref: calendarRef,
11381
+ style,
11382
+ className,
11383
+ type,
11384
+ viewMode,
11385
+ title: title || locale.calendaritem.title,
11386
+ value,
11387
+ defaultValue,
11388
+ startDate,
11389
+ endDate,
11390
+ showTitle,
11391
+ scrollAnimation,
11392
+ renderDay,
11393
+ onItemClick
11394
+ }
11395
+ ) : /* @__PURE__ */ React.createElement(
10958
11396
  CalendarItem,
10959
11397
  {
10960
11398
  ref: calendarRef,
@@ -10975,6 +11413,7 @@
10975
11413
  confirmText: confirmText || locale.calendaritem.confirm,
10976
11414
  showTitle,
10977
11415
  showSubTitle,
11416
+ showMonthNumber,
10978
11417
  scrollAnimation,
10979
11418
  firstDayOfWeek,
10980
11419
  disableDate,
@@ -10983,12 +11422,12 @@
10983
11422
  renderDayTop,
10984
11423
  renderDayBottom,
10985
11424
  onConfirm: choose,
10986
- onDayClick: select,
11425
+ onDayClick: (param) => onDayClick && onDayClick(param),
10987
11426
  onPageChange: yearMonthChange
10988
11427
  }
10989
- );
11428
+ ));
10990
11429
  };
10991
- return /* @__PURE__ */ React.createElement(React.Fragment, null, popup ? /* @__PURE__ */ React.createElement(
11430
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, popup && viewMode === "day" ? /* @__PURE__ */ React.createElement(
10992
11431
  Popup,
10993
11432
  {
10994
11433
  className: "nut-calendar-popup",