@nutui/nutui-react-taro 3.0.15 → 3.0.17-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +22 -15
  2. package/dist/cjs/packages/calendaritem/calendaritem.d.ts +1 -1
  3. package/dist/cjs/packages/calendaritem/calendaritem.js +4 -4
  4. package/dist/cjs/packages/imagepreview/imagepreview.js +25 -4
  5. package/dist/cjs/packages/noticebar/noticebar.js +65 -41
  6. package/dist/cjs/packages/pulltorefresh/pulltorefresh.js +1 -1
  7. package/dist/cjs/packages/swiper/index.d.ts +1 -1
  8. package/dist/cjs/packages/swiper/swiper.js +6 -0
  9. package/dist/cjs/types/spec/calendar/base.d.ts +3 -1
  10. package/dist/cjs/types/spec/imagepreview/h5.d.ts +4 -1
  11. package/dist/cjs/types/spec/imagepreview/taro.d.ts +4 -1
  12. package/dist/cjs/types/spec/pulltorefresh/taro.d.ts +1 -0
  13. package/dist/cjs/utils/date.d.ts +2 -2
  14. package/dist/cjs/utils/date.js +2 -2
  15. package/dist/es/packages/calendaritem/calendaritem.d.ts +1 -1
  16. package/dist/es/packages/calendaritem/calendaritem.js +4 -4
  17. package/dist/es/packages/imagepreview/imagepreview.js +25 -4
  18. package/dist/es/packages/noticebar/noticebar.js +66 -42
  19. package/dist/es/packages/pulltorefresh/pulltorefresh.js +1 -1
  20. package/dist/es/packages/swiper/index.d.ts +1 -1
  21. package/dist/es/packages/swiper/swiper.js +7 -1
  22. package/dist/es/types/spec/calendar/base.d.ts +3 -1
  23. package/dist/es/types/spec/imagepreview/h5.d.ts +4 -1
  24. package/dist/es/types/spec/imagepreview/taro.d.ts +4 -1
  25. package/dist/es/types/spec/pulltorefresh/taro.d.ts +1 -0
  26. package/dist/es/utils/date.d.ts +2 -2
  27. package/dist/es/utils/date.js +2 -2
  28. package/dist/nutui.react.umd.js +101 -52
  29. package/dist/style-jmapp.css +1 -1
  30. package/dist/style-jmapp.scss +35 -35
  31. package/dist/style-jrkf.css +1 -1
  32. package/dist/style-jrkf.scss +31 -31
  33. package/dist/style.css +1 -1
  34. package/dist/style.scss +23 -23
  35. package/package.json +1 -1
@@ -4565,8 +4565,8 @@
4565
4565
  return {
4566
4566
  day: k + 1,
4567
4567
  type: type2,
4568
- preYear,
4569
- preMonth
4568
+ year: preYear,
4569
+ month: preMonth
4570
4570
  };
4571
4571
  });
4572
4572
  return months.slice(preDates - days);
@@ -7290,13 +7290,13 @@
7290
7290
  renderDay: void 0,
7291
7291
  renderDayTop: void 0,
7292
7292
  renderDayBottom: void 0,
7293
- onConfirm: function(data2) {
7293
+ onConfirm: function() {
7294
7294
  },
7295
7295
  onUpdate: function() {
7296
7296
  },
7297
- onDayClick: function(data2) {
7297
+ onDayClick: function() {
7298
7298
  },
7299
- onPageChange: function(data2) {
7299
+ onPageChange: function() {
7300
7300
  }
7301
7301
  });
7302
7302
  var CalendarItem = /* @__PURE__ */ React.forwardRef(function(props, ref) {
@@ -7418,7 +7418,7 @@
7418
7418
  if (yearNum > 0) {
7419
7419
  monthNum += 12 * yearNum;
7420
7420
  }
7421
- if (monthNum <= 0) {
7421
+ if (monthNum < 0) {
7422
7422
  monthNum = 1;
7423
7423
  }
7424
7424
  setMonthsNum(monthNum);
@@ -15727,9 +15727,10 @@
15727
15727
  var _useState8 = _sliced_to_array(React.useState(null), 2), isCanScroll = _useState8[0], SetIsCanScroll = _useState8[1];
15728
15728
  var isVertical = direction === "vertical";
15729
15729
  var _useState9 = _sliced_to_array(React.useState(null), 2), rect = _useState9[0], setRect = _useState9[1];
15730
- var active2 = 0;
15730
+ var activeRef = React.useRef(0);
15731
15731
  var _useState10 = _sliced_to_array(React.useState(false), 2), ready = _useState10[0], setReady = _useState10[1];
15732
15732
  var container = React.useRef(null);
15733
+ var _useState11 = _sliced_to_array(React.useState(false), 2), isContainerReady = _useState11[0], setIsContainerReady = _useState11[1];
15733
15734
  var innerRef = React.useRef(null);
15734
15735
  var swiperRef = React.useRef({
15735
15736
  moving: false,
@@ -15739,8 +15740,8 @@
15739
15740
  offset: 0,
15740
15741
  size: 0
15741
15742
  });
15742
- var _useState11 = _sliced_to_array(React.useState([]), 2), childOffset = _useState11[0], setChildOffset = _useState11[1];
15743
- var _useState12 = _sliced_to_array(React.useState(0), 2), offset = _useState12[0], setOffset = _useState12[1];
15743
+ var _useState12 = _sliced_to_array(React.useState([]), 2), childOffset = _useState12[0], setChildOffset = _useState12[1];
15744
+ var _useState13 = _sliced_to_array(React.useState(0), 2), offset = _useState13[0], setOffset = _useState13[1];
15744
15745
  var _useMemo = React.useMemo(function() {
15745
15746
  var childCount2 = 0;
15746
15747
  var childs2 = React.Children.map(children, function(child) {
@@ -15777,7 +15778,9 @@
15777
15778
  return function() {
15778
15779
  clearInterval(timer);
15779
15780
  };
15780
- }, []);
15781
+ }, [
15782
+ childs
15783
+ ]);
15781
15784
  React.useEffect(function() {
15782
15785
  initScrollWrap();
15783
15786
  }, [
@@ -15894,7 +15897,7 @@
15894
15897
  marginTop: animate ? "-".concat(height2, "px") : ""
15895
15898
  };
15896
15899
  var init = function() {
15897
- var active3 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
15900
+ var activeIndex = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
15898
15901
  if (!(container === null || container === void 0 ? void 0 : container.current)) return;
15899
15902
  setTimeout(/* @__PURE__ */ _async_to_generator(function() {
15900
15903
  var rects, _active, _height, targetOffset;
@@ -15907,17 +15910,17 @@
15907
15910
  ];
15908
15911
  case 1:
15909
15912
  rects = _state.sent();
15910
- _active = Math.max(Math.min(childCount - 1, active3), 0);
15913
+ _active = Math.max(Math.min(childCount - 1, activeIndex), 0);
15911
15914
  _height = rects === null || rects === void 0 ? void 0 : rects.height;
15912
15915
  trackSize = childCount * Number(_height);
15913
15916
  targetOffset = getOffset(_active);
15914
- swiperRef.current.moving = true;
15915
- if (ready) {
15916
- swiperRef.current.moving = false;
15917
- }
15918
- active3 = _active;
15917
+ activeRef.current = _active;
15919
15918
  setRect(rects);
15920
15919
  setOffset(targetOffset);
15920
+ setChildOffset(new Array(childCount).fill(0));
15921
+ swiperRef.current.moving = true;
15922
+ setStyle(targetOffset, rects);
15923
+ swiperRef.current.moving = false;
15921
15924
  setReady(true);
15922
15925
  return [
15923
15926
  2
@@ -15928,7 +15931,6 @@
15928
15931
  };
15929
15932
  React.useEffect(function() {
15930
15933
  if (ready) {
15931
- stopAutoPlay();
15932
15934
  autoplay();
15933
15935
  }
15934
15936
  return function() {
@@ -15938,17 +15940,18 @@
15938
15940
  ready
15939
15941
  ]);
15940
15942
  React.useEffect(function() {
15941
- if (isVertical && children) {
15942
- init();
15943
+ if (isVertical && children && isContainerReady) {
15943
15944
  stopAutoPlay();
15944
- autoplay();
15945
+ setReady(false);
15946
+ init();
15945
15947
  }
15946
15948
  }, [
15947
15949
  children,
15948
- container === null || container === void 0 ? void 0 : container.current
15950
+ isContainerReady
15949
15951
  ]);
15950
15952
  var stopAutoPlay = function() {
15951
15953
  clearTimeout(swiperRef.current.autoplayTimer);
15954
+ swiperRef.current.moving = false;
15952
15955
  swiperRef.current.autoplayTimer = null;
15953
15956
  };
15954
15957
  var autoplay = function() {
@@ -15964,21 +15967,24 @@
15964
15967
  if (childCount <= 1) return;
15965
15968
  var targetActive = getActive(pace);
15966
15969
  var targetOffset = getOffset(targetActive, offset2);
15967
- if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
15968
- var rightBound = targetOffset < minOffset;
15969
- childOffset[0] = rightBound ? trackSize : 0;
15970
- }
15971
- if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
15972
- var leftBound = targetOffset > 0;
15973
- childOffset[childCount - 1] = leftBound ? -trackSize : 0;
15974
- }
15975
- setChildOffset(childOffset);
15976
- active2 = targetActive;
15970
+ setChildOffset(function(prevChildOffset) {
15971
+ var newChildOffset = _to_consumable_array(prevChildOffset);
15972
+ if (Array.isArray(children) && children[0] && targetOffset !== minOffset) {
15973
+ var rightBound = targetOffset < minOffset;
15974
+ newChildOffset[0] = rightBound ? trackSize : 0;
15975
+ }
15976
+ if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
15977
+ var leftBound = targetOffset > 0;
15978
+ newChildOffset[childCount - 1] = leftBound ? -trackSize : 0;
15979
+ }
15980
+ return newChildOffset;
15981
+ });
15982
+ activeRef.current = targetActive;
15977
15983
  setOffset(targetOffset);
15978
- getStyle(targetOffset);
15984
+ setStyle(targetOffset);
15979
15985
  };
15980
15986
  var next = function() {
15981
- resettPosition();
15987
+ resetPosition();
15982
15988
  requestFrame(function() {
15983
15989
  requestFrame(function() {
15984
15990
  swiperRef.current.moving = false;
@@ -15991,15 +15997,16 @@
15991
15997
  var handleItemClick = function(event, value2) {
15992
15998
  onItemClick && onItemClick(event, value2);
15993
15999
  };
15994
- var getStyle = function() {
15995
- var moveOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : offset;
16000
+ var setStyle = function() {
16001
+ var moveOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : offset, currentRect = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : rect;
15996
16002
  var target = innerRef.current;
15997
16003
  if (!target) {
15998
16004
  return;
15999
16005
  }
16000
16006
  var _offset = 0;
16001
- var val2 = ((rect === null || rect === void 0 ? void 0 : rect.height) || 0) - height2;
16002
- _offset = moveOffset + Number(active2 === childCount - 1 && val2 / 2);
16007
+ var containerHeight = (currentRect === null || currentRect === void 0 ? void 0 : currentRect.height) || height2;
16008
+ var val2 = containerHeight - Number(height2);
16009
+ _offset = moveOffset + Number(activeRef.current === childCount - 1 && val2 / 2);
16003
16010
  target.style.transitionDuration = "".concat(swiperRef.current.moving ? 0 : duration, "ms");
16004
16011
  target.style.height = "".concat(Number(height2) * (childCount + 1), "px");
16005
16012
  target.style.transform = "translate3D(0,".concat(_offset, "px,0)");
@@ -16017,15 +16024,16 @@
16017
16024
  return style2;
16018
16025
  };
16019
16026
  var getActive = function(pace) {
16027
+ var currentActive = activeRef.current;
16020
16028
  if (pace) {
16021
- var _active = active2 + pace;
16029
+ var _active = currentActive + pace;
16022
16030
  return range2(_active, -1, childCount);
16023
16031
  }
16024
- return active2;
16032
+ return currentActive;
16025
16033
  };
16026
- var getOffset = function(active3) {
16034
+ var getOffset = function(active2) {
16027
16035
  var offset2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
16028
- var currentPosition = active3 * Number(height2);
16036
+ var currentPosition = active2 * Number(height2);
16029
16037
  var targetOffset = offset2 - currentPosition;
16030
16038
  return targetOffset;
16031
16039
  };
@@ -16035,14 +16043,15 @@
16035
16043
  var range2 = function(num, min, max) {
16036
16044
  return Math.min(Math.max(num, min), max);
16037
16045
  };
16038
- var resettPosition = function() {
16046
+ var resetPosition = function() {
16047
+ var currentActive = activeRef.current;
16039
16048
  swiperRef.current.moving = true;
16040
- if (active2 <= -1) {
16049
+ if (currentActive <= -1) {
16041
16050
  move({
16042
16051
  pace: childCount
16043
16052
  });
16044
16053
  }
16045
- if (active2 >= childCount) {
16054
+ if (currentActive >= childCount) {
16046
16055
  move({
16047
16056
  pace: -childCount
16048
16057
  });
@@ -16056,6 +16065,20 @@
16056
16065
  stopAutoPlay();
16057
16066
  };
16058
16067
  }, []);
16068
+ var hasVerticalContent = React.useMemo(function() {
16069
+ if (!isVertical) return false;
16070
+ if (children) return (childs === null || childs === void 0 ? void 0 : childs.length) > 0;
16071
+ return (list === null || list === void 0 ? void 0 : list.length) > 0;
16072
+ }, [
16073
+ isVertical,
16074
+ childs,
16075
+ list,
16076
+ children
16077
+ ]);
16078
+ var containerRefCallback = React.useCallback(function(ref) {
16079
+ container.current = ref;
16080
+ setIsContainerReady(true);
16081
+ }, []);
16059
16082
  return /* @__PURE__ */ React.createElement(components.View, {
16060
16083
  className: cls,
16061
16084
  style
@@ -16080,10 +16103,10 @@
16080
16103
  onClick: onClickIcon
16081
16104
  }, rightIcon || /* @__PURE__ */ React.createElement(IconSVG$p, {
16082
16105
  size: 12
16083
- })) : null) : null, showNoticeBar && scrollList.current.length > 0 && isVertical ? /* @__PURE__ */ React.createElement(components.View, {
16106
+ })) : null) : null, showNoticeBar && hasVerticalContent && isVertical ? /* @__PURE__ */ React.createElement(components.View, {
16084
16107
  className: "nut-noticebar-vertical",
16085
16108
  style: barStyle,
16086
- ref: container,
16109
+ ref: containerRefCallback,
16087
16110
  onClick: handleClick
16088
16111
  }, leftIcon ? /* @__PURE__ */ React.createElement(components.View, {
16089
16112
  className: "nut-noticebar-box-left-icon"
@@ -16701,7 +16724,7 @@
16701
16724
  return /* @__PURE__ */ React.createElement(components.View, {
16702
16725
  className: classes,
16703
16726
  style: props.style,
16704
- catchMove: true,
16727
+ catchMove: props.catchMove,
16705
16728
  onTouchStart: handleTouchStart,
16706
16729
  onTouchMove: handleTouchMove,
16707
16730
  onTouchEnd: handleTouchEnd
@@ -18778,6 +18801,12 @@
18778
18801
  }, [
18779
18802
  children
18780
18803
  ]);
18804
+ React.useEffect(function() {
18805
+ setInnerValue(current || defaultValue);
18806
+ }, [
18807
+ defaultValue,
18808
+ current
18809
+ ]);
18781
18810
  var renderIndicator = function() {
18782
18811
  if (/* @__PURE__ */ React.isValidElement(indicator)) return indicator;
18783
18812
  if (indicator || indicatorDots) {
@@ -18886,7 +18915,27 @@
18886
18915
  }
18887
18916
  });
18888
18917
  var ImagePreview = function(props) {
18889
- var _$_object_spread = _object_spread({}, defaultProps$h, props), value2 = _$_object_spread.value, className = _$_object_spread.className, style = _$_object_spread.style, images = _$_object_spread.images, videos = _$_object_spread.videos, visible = _$_object_spread.visible, defaultValue = _$_object_spread.defaultValue, indicatorColor = _$_object_spread.indicatorColor, pagination = _$_object_spread.pagination, indicator = _$_object_spread.indicator, autoPlay = _$_object_spread.autoPlay, closeOnContentClick = _$_object_spread.closeOnContentClick, closeIcon = _$_object_spread.closeIcon, closeIconPosition = _$_object_spread.closeIconPosition, showMenuByLongpress = _$_object_spread.showMenuByLongpress, onClose = _$_object_spread.onClose, onChange = _$_object_spread.onChange;
18918
+ var _mergeProps = mergeProps(defaultProps$h, props), value2 = _mergeProps.value, className = _mergeProps.className, style = _mergeProps.style, images = _mergeProps.images, videos = _mergeProps.videos, visible = _mergeProps.visible, defaultValue = _mergeProps.defaultValue, indicatorColor = _mergeProps.indicatorColor, pagination = _mergeProps.pagination, indicator = _mergeProps.indicator, autoPlay = _mergeProps.autoPlay, loop = _mergeProps.loop, closeOnContentClick = _mergeProps.closeOnContentClick, closeIcon = _mergeProps.closeIcon, closeIconPosition = _mergeProps.closeIconPosition, showMenuByLongpress = _mergeProps.showMenuByLongpress, onClose = _mergeProps.onClose, onChange = _mergeProps.onChange;
18919
+ _object_without_properties(_mergeProps, [
18920
+ "value",
18921
+ "className",
18922
+ "style",
18923
+ "images",
18924
+ "videos",
18925
+ "visible",
18926
+ "defaultValue",
18927
+ "indicatorColor",
18928
+ "pagination",
18929
+ "indicator",
18930
+ "autoPlay",
18931
+ "loop",
18932
+ "closeOnContentClick",
18933
+ "closeIcon",
18934
+ "closeIconPosition",
18935
+ "showMenuByLongpress",
18936
+ "onClose",
18937
+ "onChange"
18938
+ ]);
18890
18939
  var classPrefix2 = "nut-imagepreview";
18891
18940
  var ref = React.useRef(null);
18892
18941
  var _usePropsValue = _sliced_to_array(usePropsValue({
@@ -19017,9 +19066,10 @@
19017
19066
  onTouchEnd,
19018
19067
  onTouchCancel: onTouchEnd
19019
19068
  }, /* @__PURE__ */ React.createElement(InnerSwiper, {
19020
- autoPlay,
19069
+ autoplay: autoPlay,
19070
+ loop,
19071
+ direction: "horizontal",
19021
19072
  className: "".concat(classPrefix2, "-swiper"),
19022
- loop: true,
19023
19073
  height: "100%",
19024
19074
  style: {
19025
19075
  display: showPop ? "block" : "none",
@@ -19027,7 +19077,6 @@
19027
19077
  width: "100%",
19028
19078
  height: "100%"
19029
19079
  },
19030
- direction: "horizontal",
19031
19080
  onChange: function(e) {
19032
19081
  return slideChangeEnd(e.detail.current);
19033
19082
  },