@nutui/nutui-react 2.3.1 → 2.3.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 (149) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/ActionSheet/style/style.css +1 -1
  3. package/dist/esm/Address/style/style.css +1 -1
  4. package/dist/esm/Audio/style/style.css +1 -1
  5. package/dist/esm/Button/style/style.css +1 -1
  6. package/dist/esm/Calendar/style/style.css +1 -1
  7. package/dist/esm/CalendarItem.js +9 -3
  8. package/dist/esm/Cascader/style/style.css +1 -1
  9. package/dist/esm/Checkbox/style/style.css +1 -1
  10. package/dist/esm/CountDown.js +1 -8
  11. package/dist/esm/DatePicker/style/style.css +1 -1
  12. package/dist/esm/DatePicker.js +60 -81
  13. package/dist/esm/Dialog/style/style.css +1 -1
  14. package/dist/esm/FixedNav.js +1 -1
  15. package/dist/esm/ImagePreview/style/style.css +1 -1
  16. package/dist/esm/InfiniteLoading.js +9 -6
  17. package/dist/esm/Menu/style/style.css +1 -1
  18. package/dist/esm/MenuItem/style/style.css +1 -1
  19. package/dist/esm/NumberKeyboard/style/style.css +1 -1
  20. package/dist/esm/Picker/style/style.css +1 -1
  21. package/dist/esm/Picker.js +1 -1
  22. package/dist/esm/Popover/style/style.css +1 -1
  23. package/dist/esm/Popup/style/style.css +1 -1
  24. package/dist/esm/PullToRefresh.js +11 -33
  25. package/dist/esm/Radio/style/style.css +1 -1
  26. package/dist/esm/ShortPassword/style/style.css +1 -1
  27. package/dist/esm/SideNavBar/style/style.css +1 -1
  28. package/dist/esm/Swiper.js +120 -167
  29. package/dist/esm/Tabbar.js +13 -12
  30. package/dist/esm/Table/style/style.css +1 -1
  31. package/dist/esm/Table.js +97 -12
  32. package/dist/esm/TimeSelect/style/style.css +1 -1
  33. package/dist/esm/Tour/style/style.css +1 -1
  34. package/dist/esm/cascader2.js +19 -3
  35. package/dist/esm/formitem2.js +1 -0
  36. package/dist/esm/pad-zero.js +11 -0
  37. package/dist/esm/tabbaritem2.js +11 -9
  38. package/dist/esm/types/src/packages/address/address.d.ts +1 -1
  39. package/dist/esm/types/src/packages/address/address.taro.d.ts +1 -1
  40. package/dist/esm/types/src/packages/address/existRender.d.ts +1 -1
  41. package/dist/esm/types/src/packages/address/existRender.taro.d.ts +1 -1
  42. package/dist/esm/types/src/packages/animate/animate.d.ts +1 -1
  43. package/dist/esm/types/src/packages/animate/animate.taro.d.ts +1 -1
  44. package/dist/esm/types/src/packages/animate/index.d.ts +1 -1
  45. package/dist/esm/types/src/packages/animate/index.taro.d.ts +1 -1
  46. package/dist/esm/types/src/packages/calendar/calendar.d.ts +1 -1
  47. package/dist/esm/types/src/packages/calendar/calendar.taro.d.ts +1 -1
  48. package/dist/esm/types/src/packages/calendar/utils.d.ts +1 -1
  49. package/dist/esm/types/src/packages/calendaritem/calendaritem.d.ts +1 -1
  50. package/dist/esm/types/src/packages/calendaritem/calendaritem.taro.d.ts +1 -1
  51. package/dist/esm/types/src/packages/cascader/cascader.d.ts +4 -0
  52. package/dist/esm/types/src/packages/cascader/cascader.taro.d.ts +4 -0
  53. package/dist/esm/types/src/packages/checkboxgroup/checkboxgroup.d.ts +1 -1
  54. package/dist/esm/types/src/packages/checkboxgroup/checkboxgroup.taro.d.ts +1 -1
  55. package/dist/esm/types/src/packages/configprovider/types.d.ts +1 -1
  56. package/dist/esm/types/src/packages/fixednav/fixednav.d.ts +2 -6
  57. package/dist/esm/types/src/packages/fixednav/fixednav.taro.d.ts +2 -6
  58. package/dist/esm/types/src/packages/fixednav/index.d.ts +2 -1
  59. package/dist/esm/types/src/packages/fixednav/index.taro.d.ts +2 -1
  60. package/dist/esm/types/src/packages/fixednav/types.d.ts +12 -0
  61. package/dist/esm/types/src/packages/pulltorefresh/pulltorefresh.d.ts +1 -0
  62. package/dist/esm/types/src/packages/pulltorefresh/pulltorefresh.taro.d.ts +1 -0
  63. package/dist/esm/types/src/packages/radiogroup/radiogroup.d.ts +1 -1
  64. package/dist/esm/types/src/packages/radiogroup/radiogroup.taro.d.ts +1 -1
  65. package/dist/esm/types/src/packages/tabbar/context.d.ts +9 -0
  66. package/dist/esm/types/src/packages/tabbar/index.d.ts +1 -0
  67. package/dist/esm/types/src/packages/tabbar/index.taro.d.ts +1 -0
  68. package/dist/esm/types/src/packages/tabbaritem/tabbaritem.d.ts +0 -5
  69. package/dist/esm/types/src/packages/tabbaritem/tabbaritem.taro.d.ts +0 -5
  70. package/dist/esm/types/src/packages/table/types.d.ts +2 -0
  71. package/dist/esm/types/src/packages/table/useTableSticky.d.ts +8 -0
  72. package/dist/esm/types/src/packages/virtuallist/utils.d.ts +1 -1
  73. package/dist/esm/types/src/packages/virtuallist/virtuallist.d.ts +1 -1
  74. package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +1 -1
  75. package/dist/esm/types/src/utils/is-date.d.ts +1 -0
  76. package/dist/esm/types/src/utils/pad-zero.d.ts +1 -0
  77. package/dist/esm/types/src/utils/use-touch.d.ts +2 -0
  78. package/dist/esm/use-touch.js +7 -0
  79. package/dist/locales/base.js +1 -1
  80. package/dist/locales/en-US.js +1 -1
  81. package/dist/locales/id-ID.js +1 -1
  82. package/dist/locales/tr-TR.js +1 -1
  83. package/dist/locales/zh-CN.js +1 -1
  84. package/dist/locales/zh-TW.js +1 -1
  85. package/dist/locales/zh-UG.js +1 -1
  86. package/dist/nutui.react.es.js +713 -672
  87. package/dist/nutui.react.umd.js +712 -671
  88. package/dist/packages/cascader/cascader.scss +1 -6
  89. package/dist/packages/checkbox/checkbox.scss +3 -0
  90. package/dist/packages/menuitem/menuitem.scss +1 -1
  91. package/dist/packages/popup/popup.scss +2 -2
  92. package/dist/packages/table/table.scss +82 -9
  93. package/dist/style.css +1 -1
  94. package/dist/style.mjs +1 -1
  95. package/dist/styles/variables-jmapp.scss +9 -2
  96. package/dist/styles/variables.scss +10 -3
  97. package/dist/types/packages/address/address.d.ts +1 -1
  98. package/dist/types/packages/address/address.taro.d.ts +1 -1
  99. package/dist/types/packages/address/existRender.d.ts +1 -1
  100. package/dist/types/packages/address/existRender.taro.d.ts +1 -1
  101. package/dist/types/packages/animate/animate.d.ts +1 -1
  102. package/dist/types/packages/animate/animate.taro.d.ts +1 -1
  103. package/dist/types/packages/animate/index.d.ts +1 -1
  104. package/dist/types/packages/animate/index.taro.d.ts +1 -1
  105. package/dist/types/packages/calendar/calendar.d.ts +1 -1
  106. package/dist/types/packages/calendar/calendar.taro.d.ts +1 -1
  107. package/dist/types/packages/calendar/utils.d.ts +1 -1
  108. package/dist/types/packages/calendaritem/calendaritem.d.ts +1 -1
  109. package/dist/types/packages/calendaritem/calendaritem.taro.d.ts +1 -1
  110. package/dist/types/packages/cascader/cascader.d.ts +4 -0
  111. package/dist/types/packages/cascader/cascader.taro.d.ts +4 -0
  112. package/dist/types/packages/checkboxgroup/checkboxgroup.d.ts +1 -1
  113. package/dist/types/packages/checkboxgroup/checkboxgroup.taro.d.ts +1 -1
  114. package/dist/types/packages/configprovider/types.d.ts +1 -1
  115. package/dist/types/packages/fixednav/fixednav.d.ts +2 -6
  116. package/dist/types/packages/fixednav/fixednav.taro.d.ts +2 -6
  117. package/dist/types/packages/fixednav/index.d.ts +2 -1
  118. package/dist/types/packages/fixednav/index.taro.d.ts +2 -1
  119. package/dist/types/packages/fixednav/types.d.ts +12 -0
  120. package/dist/types/packages/pulltorefresh/pulltorefresh.d.ts +7 -2
  121. package/dist/types/packages/pulltorefresh/pulltorefresh.taro.d.ts +1 -0
  122. package/dist/types/packages/radiogroup/radiogroup.d.ts +1 -1
  123. package/dist/types/packages/radiogroup/radiogroup.taro.d.ts +1 -1
  124. package/dist/types/packages/tabbar/context.d.ts +9 -0
  125. package/dist/types/packages/tabbar/index.d.ts +1 -0
  126. package/dist/types/packages/tabbar/index.taro.d.ts +1 -0
  127. package/dist/types/packages/tabbaritem/tabbaritem.d.ts +0 -5
  128. package/dist/types/packages/tabbaritem/tabbaritem.taro.d.ts +0 -5
  129. package/dist/types/packages/table/types.d.ts +2 -0
  130. package/dist/types/packages/table/useTableSticky.d.ts +8 -0
  131. package/dist/types/packages/virtuallist/utils.d.ts +1 -1
  132. package/dist/types/packages/virtuallist/virtuallist.d.ts +1 -1
  133. package/dist/types/packages/virtuallist/virtuallist.taro.d.ts +1 -1
  134. package/dist/types/utils/is-date.d.ts +1 -0
  135. package/dist/types/utils/pad-zero.d.ts +1 -0
  136. package/dist/types/utils/use-touch.d.ts +2 -0
  137. package/package.json +2 -2
  138. /package/dist/esm/types/src/packages/address/{type.d.ts → types.d.ts} +0 -0
  139. /package/dist/esm/types/src/packages/animate/{type.d.ts → types.d.ts} +0 -0
  140. /package/dist/esm/types/src/packages/calendar/{type.d.ts → types.d.ts} +0 -0
  141. /package/dist/esm/types/src/packages/checkboxgroup/{type.d.ts → types.d.ts} +0 -0
  142. /package/dist/esm/types/src/packages/radiogroup/{type.d.ts → types.d.ts} +0 -0
  143. /package/dist/esm/types/src/packages/virtuallist/{type.d.ts → types.d.ts} +0 -0
  144. /package/dist/types/packages/address/{type.d.ts → types.d.ts} +0 -0
  145. /package/dist/types/packages/animate/{type.d.ts → types.d.ts} +0 -0
  146. /package/dist/types/packages/calendar/{type.d.ts → types.d.ts} +0 -0
  147. /package/dist/types/packages/checkboxgroup/{type.d.ts → types.d.ts} +0 -0
  148. /package/dist/types/packages/radiogroup/{type.d.ts → types.d.ts} +0 -0
  149. /package/dist/types/packages/virtuallist/{type.d.ts → types.d.ts} +0 -0
@@ -28,6 +28,8 @@ import classNames from "classnames";
28
28
  import { D as DataContext } from "./context4.js";
29
29
  import { g as getRect } from "./use-client-rect.js";
30
30
  import { I as Indicator } from "./indicator2.js";
31
+ import { u as useTouch } from "./use-touch.js";
32
+ import { r as requestAniFrame } from "./raf.js";
31
33
  import SwiperItem from "./SwiperItem.js";
32
34
  var defaultProps = {
33
35
  duration: 500,
@@ -42,10 +44,9 @@ var defaultProps = {
42
44
  center: false,
43
45
  className: ""
44
46
  };
45
- var DISTANCE = 5;
46
47
  var Swiper = React__default.forwardRef(function(props, ref) {
47
- var propSwiper = _objectSpread(_objectSpread({}, defaultProps), props);
48
- var children = propSwiper.children, direction = propSwiper.direction, className = propSwiper.className, onChange = propSwiper.onChange, defaultValue = propSwiper.defaultValue, indicator = propSwiper.indicator, touchable = propSwiper.touchable, preventDefault = propSwiper.preventDefault, stopPropagation = propSwiper.stopPropagation, autoPlay = propSwiper.autoPlay, center = propSwiper.center, rest = _objectWithoutProperties(propSwiper, _excluded);
48
+ var mergedProps = _objectSpread(_objectSpread({}, defaultProps), props);
49
+ var children = mergedProps.children, direction = mergedProps.direction, className = mergedProps.className, onChange = mergedProps.onChange, defaultValue = mergedProps.defaultValue, indicator = mergedProps.indicator, touchable = mergedProps.touchable, preventDefault = mergedProps.preventDefault, stopPropagation = mergedProps.stopPropagation, autoPlay = mergedProps.autoPlay, center = mergedProps.center, rest = _objectWithoutProperties(mergedProps, _excluded);
49
50
  var container = useRef(null);
50
51
  var innerRef = useRef(null);
51
52
  var swiperRef = useRef({
@@ -56,6 +57,7 @@ var Swiper = React__default.forwardRef(function(props, ref) {
56
57
  offset: 0,
57
58
  size: 0
58
59
  });
60
+ var touch = useTouch();
59
61
  var isVertical = direction === "vertical";
60
62
  var _useState = useState(null), _useState2 = _slicedToArray(_useState, 2), rect = _useState2[0], setRect = _useState2[1];
61
63
  var _useState3 = useState(0), _useState4 = _slicedToArray(_useState3, 2), active = _useState4[0], setActive = _useState4[1];
@@ -65,39 +67,28 @@ var Swiper = React__default.forwardRef(function(props, ref) {
65
67
  var _useState11 = useState([]), _useState12 = _slicedToArray(_useState11, 2), childOffset = _useState12[0], setChildOffset = _useState12[1];
66
68
  var _useState13 = useState(false), _useState14 = _slicedToArray(_useState13, 2), ready = _useState14[0], setReady = _useState14[1];
67
69
  var size = isVertical ? height : width;
68
- var _useState15 = useState({
69
- startX: 0,
70
- startY: 0,
71
- deltaX: 0,
72
- deltaY: 0,
73
- offsetX: 0,
74
- offsetY: 0,
75
- stateDirection: "",
76
- delta: 0,
77
- touchTime: 0
78
- }), _useState16 = _slicedToArray(_useState15, 1), touch = _useState16[0];
79
70
  var _useMemo = useMemo(function() {
80
- var childCount2 = 0;
81
- var childs2 = React__default.Children.map(props.children, function(child) {
71
+ var count = 0;
72
+ var swiperItems2 = React__default.Children.map(props.children, function(child) {
82
73
  if (!React__default.isValidElement(child))
83
74
  return null;
84
- childCount2++;
75
+ count++;
85
76
  return child;
86
77
  });
87
78
  return {
88
- childs: childs2,
89
- childCount: childCount2
79
+ swiperItems: swiperItems2,
80
+ swiperItemCount: count
90
81
  };
91
- }, [props.children]), childs = _useMemo.childs, childCount = _useMemo.childCount;
92
- var trackSize = childCount * Number(size);
82
+ }, [props.children]), swiperItems = _useMemo.swiperItems, swiperItemCount = _useMemo.swiperItemCount;
83
+ var trackSize = swiperItemCount * Number(size);
93
84
  var parent = {
94
- propSwiper,
85
+ propSwiper: mergedProps,
95
86
  size
96
87
  };
97
88
  var minOffset = function() {
98
89
  if (rect) {
99
90
  var base = isVertical ? rect.height : rect.width;
100
- return base - Number(size) * childCount;
91
+ return base - Number(size) * swiperItemCount;
101
92
  }
102
93
  return 0;
103
94
  }();
@@ -106,69 +97,63 @@ var Swiper = React__default.forwardRef(function(props, ref) {
106
97
  swiperRef.current.autoplayTimer = null;
107
98
  };
108
99
  var startPlay = function startPlay2() {
109
- if (propSwiper.autoPlay <= 0 || childCount <= 1)
100
+ if (mergedProps.autoPlay <= 0 || swiperItemCount <= 1)
110
101
  return;
111
102
  stopAutoPlay();
112
103
  swiperRef.current.autoplayTimer = setTimeout(function() {
113
104
  next();
114
105
  startPlay2();
115
- }, Number(propSwiper.autoPlay));
106
+ }, Number(mergedProps.autoPlay));
116
107
  };
117
108
  var resetPosition = function resetPosition2() {
118
109
  swiperRef.current.moving = true;
119
110
  if (active <= -1) {
120
111
  move({
121
- pace: childCount
112
+ pace: swiperItemCount
122
113
  });
123
114
  }
124
- if (active >= childCount) {
115
+ if (active >= swiperItemCount) {
125
116
  move({
126
- pace: -childCount
117
+ pace: -swiperItemCount
127
118
  });
128
119
  }
129
120
  };
130
121
  var prev = function prev2() {
131
122
  resetPosition();
132
- resetTouchDetails();
133
- requestFrame(function() {
134
- requestFrame(function() {
135
- swiperRef.current.moving = false;
136
- move({
137
- pace: -1,
138
- isEmit: true
139
- });
123
+ touch.reset();
124
+ requestAniFrame(function() {
125
+ swiperRef.current.moving = false;
126
+ move({
127
+ pace: -1,
128
+ isEmit: true
140
129
  });
141
130
  });
142
131
  };
143
132
  var next = function next2() {
144
133
  resetPosition();
145
- resetTouchDetails();
146
- requestFrame(function() {
147
- requestFrame(function() {
148
- swiperRef.current.moving = false;
149
- move({
150
- pace: 1,
151
- isEmit: true
152
- });
134
+ touch.reset();
135
+ requestAniFrame(function() {
136
+ swiperRef.current.moving = false;
137
+ move({
138
+ pace: 1,
139
+ isEmit: true
153
140
  });
154
141
  });
155
142
  };
156
143
  var to = function to2(index) {
157
144
  resetPosition();
158
- resetTouchDetails();
159
- requestFrame(function() {
160
- requestFrame(function() {
161
- swiperRef.current.moving = false;
162
- var targetIndex;
163
- if (props.loop && childCount === index) {
164
- targetIndex = active === 0 ? 0 : index;
165
- } else {
166
- targetIndex = index % childCount;
167
- }
168
- move({
169
- pace: targetIndex - active,
170
- isEmit: true
171
- });
145
+ touch.reset();
146
+ requestAniFrame(function() {
147
+ swiperRef.current.moving = false;
148
+ var targetIndex;
149
+ if (props.loop && swiperItemCount === index) {
150
+ targetIndex = active === 0 ? 0 : index;
151
+ } else {
152
+ targetIndex = index % swiperItemCount;
153
+ }
154
+ move({
155
+ pace: targetIndex - active,
156
+ isEmit: true
172
157
  });
173
158
  });
174
159
  };
@@ -177,7 +162,7 @@ var Swiper = React__default.forwardRef(function(props, ref) {
177
162
  };
178
163
  var move = function move2(_ref) {
179
164
  var _ref$pace = _ref.pace, pace = _ref$pace === void 0 ? 0 : _ref$pace, _ref$offset = _ref.offset, offset2 = _ref$offset === void 0 ? 0 : _ref$offset, _ref$isEmit = _ref.isEmit, isEmit = _ref$isEmit === void 0 ? false : _ref$isEmit, _ref$movingStatus = _ref.movingStatus, movingStatus = _ref$movingStatus === void 0 ? false : _ref$movingStatus;
180
- if (childCount <= 1)
165
+ if (swiperItemCount <= 1)
181
166
  return;
182
167
  var targetActive = getActive(pace);
183
168
  var targetOffset = getOffset(targetActive, offset2);
@@ -186,27 +171,36 @@ var Swiper = React__default.forwardRef(function(props, ref) {
186
171
  var rightBound = targetOffset < minOffset;
187
172
  childOffset[0] = rightBound ? trackSize : 0;
188
173
  }
189
- if (Array.isArray(children) && children[childCount - 1] && targetOffset !== 0) {
174
+ if (Array.isArray(children) && children[swiperItemCount - 1] && targetOffset !== 0) {
190
175
  var leftBound = targetOffset > 0;
191
- childOffset[childCount - 1] = leftBound ? -trackSize : 0;
176
+ childOffset[swiperItemCount - 1] = leftBound ? -trackSize : 0;
192
177
  }
193
178
  setChildOffset(childOffset);
194
179
  }
195
180
  if (isEmit && active !== targetActive) {
196
- props.onChange && props.onChange((targetActive + childCount) % childCount);
181
+ var _props$onChange;
182
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, (targetActive + swiperItemCount) % swiperItemCount);
197
183
  }
198
184
  active = targetActive;
199
185
  setActive(targetActive);
200
186
  setOffset(targetOffset);
201
187
  getStyle(targetOffset);
202
188
  };
189
+ React__default.useImperativeHandle(ref, function() {
190
+ return {
191
+ to,
192
+ next,
193
+ prev,
194
+ resize
195
+ };
196
+ });
203
197
  var getActive = function getActive2(pace) {
204
198
  if (pace) {
205
199
  var _active = active + pace;
206
200
  if (props.loop) {
207
- return range(_active, -1, childCount);
201
+ return range(_active, -1, swiperItemCount);
208
202
  }
209
- return range(_active, 0, childCount - 1);
203
+ return range(_active, 0, swiperItemCount - 1);
210
204
  }
211
205
  return active;
212
206
  };
@@ -222,45 +216,9 @@ var Swiper = React__default.forwardRef(function(props, ref) {
222
216
  }
223
217
  return targetOffset;
224
218
  };
225
- var requestFrame = function requestFrame2(fn) {
226
- window.requestAnimationFrame.call(window, fn);
227
- };
228
219
  var range = function range2(num, min, max) {
229
220
  return Math.min(Math.max(num, min), max);
230
221
  };
231
- var getDirection = function getDirection2(x, y) {
232
- if (x > y && x > DISTANCE)
233
- return "horizontal";
234
- if (y > x && y > DISTANCE)
235
- return "vertical";
236
- return "";
237
- };
238
- var resetTouchDetails = function resetTouchDetails2() {
239
- touch.startX = 0;
240
- touch.startY = 0;
241
- touch.deltaX = 0;
242
- touch.deltaY = 0;
243
- touch.offsetX = 0;
244
- touch.offsetY = 0;
245
- touch.delta = 0;
246
- touch.stateDirection = "";
247
- touch.touchTime = 0;
248
- };
249
- var touchStart = function touchStart2(e) {
250
- resetTouchDetails();
251
- touch.startX = e.touches[0].clientX;
252
- touch.startY = e.touches[0].clientY;
253
- };
254
- var handleTouchMove = function handleTouchMove2(e) {
255
- touch.deltaX = e.touches[0].clientX - touch.startX;
256
- touch.deltaY = e.touches[0].clientY - touch.startY;
257
- touch.offsetX = Math.abs(touch.deltaX);
258
- touch.offsetY = Math.abs(touch.deltaY);
259
- touch.delta = isVertical ? touch.deltaY : touch.deltaX;
260
- if (!touch.stateDirection) {
261
- touch.stateDirection = getDirection(touch.offsetX, touch.offsetY);
262
- }
263
- };
264
222
  var classPrefix = "nut-swiper";
265
223
  var contentClass = classNames(_defineProperty(_defineProperty({}, "".concat(classPrefix, "-inner"), true), "".concat(classPrefix, "-vertical"), isVertical));
266
224
  var getStyle = function getStyle2() {
@@ -272,18 +230,17 @@ var Swiper = React__default.forwardRef(function(props, ref) {
272
230
  } else {
273
231
  var _size = isVertical ? height : width;
274
232
  var val = isVertical ? rect.height - _size : rect.width - _size;
275
- _offset = moveOffset + (active === childCount - 1 && !props.loop ? -val / 2 : val / 2);
233
+ _offset = moveOffset + (active === swiperItemCount - 1 && !props.loop ? -val / 2 : val / 2);
276
234
  }
277
235
  target.style.transitionDuration = "".concat(swiperRef.current.moving ? 0 : props.duration, "ms");
278
- target.style[isVertical ? "height" : "width"] = "".concat(Number(size) * childCount, "px");
236
+ target.style[isVertical ? "height" : "width"] = "".concat(Number(size) * swiperItemCount, "px");
279
237
  target.style[isVertical ? "width" : "height"] = "".concat(isVertical ? width : height, "px");
280
238
  target.style.transform = "translate3D".concat(!isVertical ? "(".concat(_offset, "px,0,0)") : "(0,".concat(_offset, "px,0)"));
281
239
  };
282
240
  var onTouchStart = function onTouchStart2(e) {
283
241
  if (!props.touchable)
284
242
  return;
285
- touchStart(e);
286
- touch.touchTime = Date.now();
243
+ touch.start(e);
287
244
  stopAutoPlay();
288
245
  resetPosition();
289
246
  };
@@ -293,10 +250,10 @@ var Swiper = React__default.forwardRef(function(props, ref) {
293
250
  if (props.stopPropagation)
294
251
  e.stopPropagation();
295
252
  if (props.touchable && swiperRef.current.moving) {
296
- handleTouchMove(e);
297
- if (touch.stateDirection === props.direction) {
253
+ touch.move(e);
254
+ if (touch.direction.current === props.direction) {
298
255
  move({
299
- offset: touch.delta
256
+ offset: touch.delta.current
300
257
  });
301
258
  }
302
259
  }
@@ -304,26 +261,24 @@ var Swiper = React__default.forwardRef(function(props, ref) {
304
261
  var onTouchEnd = function onTouchEnd2(e) {
305
262
  if (!props.touchable || !swiperRef.current.moving)
306
263
  return;
307
- var speed = touch.delta / (Date.now() - touch.touchTime);
308
- var isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta) > Number((size / 2).toFixed(2));
309
- var pace = 0;
264
+ var speed = touch.delta.current / (Date.now() - touch.touchTime.current);
265
+ var isShouldMove = Math.abs(speed) > 0.3 || Math.abs(touch.delta.current) > Number((size / 2).toFixed(2));
310
266
  swiperRef.current.moving = false;
311
- if (isShouldMove && touch.stateDirection === props.direction) {
312
- var offset2 = isVertical ? touch.offsetY : touch.offsetX;
267
+ if (isShouldMove && touch.direction.current === props.direction) {
268
+ var pace = 0;
269
+ var offset2 = touch.isVertical() ? touch.offsetY : touch.offsetX;
313
270
  if (props.loop) {
314
- if (offset2 > 0) {
315
- pace = touch.delta > 0 ? -1 : 1;
316
- } else {
317
- pace = 0;
271
+ if (offset2.current > 0) {
272
+ pace = touch.delta.current > 0 ? -1 : 1;
318
273
  }
319
274
  } else {
320
- pace = -Math[touch.delta > 0 ? "ceil" : "floor"](touch.delta / size);
275
+ pace = -Math[touch.delta.current > 0 ? "ceil" : "floor"](touch.delta.current / size);
321
276
  }
322
277
  move({
323
278
  pace,
324
279
  isEmit: true
325
280
  });
326
- } else if (touch.delta) {
281
+ } else if (touch.delta.current) {
327
282
  move({
328
283
  pace: 0
329
284
  });
@@ -332,17 +287,24 @@ var Swiper = React__default.forwardRef(function(props, ref) {
332
287
  }
333
288
  startPlay();
334
289
  };
335
- useEffect(function() {
336
- swiperRef.current.activeIndicator = (active + childCount) % childCount;
337
- }, [active]);
338
- var init = function init2() {
339
- var active2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : +propSwiper.defaultValue;
290
+ var getItemStyle = function getItemStyle2(index) {
291
+ var style = {};
292
+ if (size) {
293
+ style[direction === "horizontal" ? "width" : "height"] = "".concat(size, "px");
294
+ }
295
+ var offset2 = childOffset[index];
296
+ if (offset2) {
297
+ style.transform = "translate3D".concat(direction === "horizontal" ? "(".concat(offset2, "px,0,0)") : "(0,".concat(offset2, "px,0)"));
298
+ }
299
+ return style;
300
+ };
301
+ var init = function init2(index) {
340
302
  var rect2 = getRect(container === null || container === void 0 ? void 0 : container.current);
341
- var currentIndex = Math.max(Math.min(childCount - 1, active2), 0);
342
- var width2 = +propSwiper.width || rect2.width;
343
- var height2 = +propSwiper.height || rect2.height;
303
+ var currentIndex = Math.max(Math.min(swiperItemCount - 1, index || Number(mergedProps.defaultValue)), 0);
304
+ var width2 = Number(mergedProps.width) || rect2.width;
305
+ var height2 = Number(mergedProps.height) || rect2.height;
344
306
  size = isVertical ? height2 : width2;
345
- trackSize = childCount * Number(size);
307
+ trackSize = swiperItemCount * Number(size);
346
308
  var targetOffset = getOffset(currentIndex);
347
309
  swiperRef.current.moving = true;
348
310
  if (ready) {
@@ -374,56 +336,47 @@ var Swiper = React__default.forwardRef(function(props, ref) {
374
336
  startPlay();
375
337
  }, [children]);
376
338
  useEffect(function() {
377
- return init();
378
- }, [propSwiper.defaultValue]);
379
- useEffect(function() {
380
- var target = container.current;
381
- target.addEventListener("touchstart", onTouchStart, false);
382
- target.addEventListener("touchmove", onTouchMove, false);
383
- target.addEventListener("touchend", onTouchEnd, false);
339
+ var events = [{
340
+ name: "touchstart",
341
+ e: onTouchStart
342
+ }, {
343
+ name: "touchmove",
344
+ e: onTouchMove
345
+ }, {
346
+ name: "touchend",
347
+ e: onTouchEnd
348
+ }];
349
+ events.forEach(function(item) {
350
+ var _container$current;
351
+ (_container$current = container.current) === null || _container$current === void 0 || _container$current.addEventListener(item.name, item.e, false);
352
+ });
384
353
  return function() {
385
- target.removeEventListener("touchstart", onTouchStart, false);
386
- target.removeEventListener("touchmove", onTouchMove, false);
387
- target.removeEventListener("touchend", onTouchEnd, false);
354
+ events.forEach(function(item) {
355
+ var _container$current2;
356
+ (_container$current2 = container.current) === null || _container$current2 === void 0 || _container$current2.removeEventListener(item.name, item.e, false);
357
+ });
388
358
  };
389
359
  });
360
+ useEffect(function() {
361
+ return init();
362
+ }, [props.defaultValue]);
390
363
  useEffect(function() {
391
364
  return function() {
392
365
  return stopAutoPlay();
393
366
  };
394
367
  }, []);
395
- var getItemStyle = function getItemStyle2(index) {
396
- var style = {};
397
- if (size) {
398
- style[direction === "horizontal" ? "width" : "height"] = "".concat(size, "px");
399
- }
400
- var offset2 = childOffset[index];
401
- if (offset2) {
402
- style.transform = "translate3D".concat(direction === "horizontal" ? "(".concat(offset2, "px,0,0)") : "(0,".concat(offset2, "px,0)"));
403
- }
404
- return style;
405
- };
406
- React__default.useImperativeHandle(ref, function() {
407
- return {
408
- to,
409
- next,
410
- prev,
411
- resize
412
- };
413
- });
414
368
  var renderIndicator = function renderIndicator2() {
415
369
  if (React__default.isValidElement(indicator))
416
370
  return indicator;
417
- if (indicator === true) {
418
- return React__default.createElement("div", {
419
- className: classNames(_defineProperty(_defineProperty({}, "".concat(classPrefix, "-indicator"), true), "".concat(classPrefix, "-indicator-vertical"), isVertical))
420
- }, React__default.createElement(Indicator, {
421
- current: (active + childCount) % childCount,
422
- total: childs === null || childs === void 0 ? void 0 : childs.length,
423
- direction
424
- }));
425
- }
426
- return null;
371
+ if (!indicator)
372
+ return null;
373
+ return React__default.createElement("div", {
374
+ className: classNames(_defineProperty(_defineProperty({}, "".concat(classPrefix, "-indicator"), true), "".concat(classPrefix, "-indicator-vertical"), isVertical))
375
+ }, React__default.createElement(Indicator, {
376
+ current: (active + swiperItemCount) % swiperItemCount,
377
+ total: swiperItems === null || swiperItems === void 0 ? void 0 : swiperItems.length,
378
+ direction
379
+ }));
427
380
  };
428
381
  return React__default.createElement(DataContext.Provider, {
429
382
  value: parent
@@ -433,7 +386,7 @@ var Swiper = React__default.forwardRef(function(props, ref) {
433
386
  }, rest), React__default.createElement("div", {
434
387
  className: contentClass,
435
388
  ref: innerRef
436
- }, React__default.Children.map(childs, function(child, index) {
389
+ }, React__default.Children.map(swiperItems, function(child, index) {
437
390
  return React__default.createElement("div", {
438
391
  className: "".concat(classPrefix, "-item-wrapper"),
439
392
  style: getItemStyle(index),
@@ -25,7 +25,7 @@ import React__default from "react";
25
25
  import classNames from "classnames";
26
26
  import { C as ComponentDefaults } from "./typings.js";
27
27
  import { u as usePropsValue } from "./use-props-value.js";
28
- import { T as TabbarItem } from "./tabbaritem2.js";
28
+ import { a as TabbarContext, T as TabbarItem } from "./tabbaritem2.js";
29
29
  import "./badge2.js";
30
30
  var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
31
31
  defaultValue: 0,
@@ -50,19 +50,20 @@ var Tabbar = function Tabbar2(props) {
50
50
  style
51
51
  }, React__default.createElement("div", {
52
52
  className: "".concat(classPrefix, "-wrap")
53
- }, React__default.Children.map(children, function(child, idx) {
54
- if (!React__default.isValidElement(child)) {
55
- return null;
56
- }
57
- var childProps = _objectSpread(_objectSpread({}, child.props), {}, {
58
- active: idx === selectIndex,
59
- index: idx,
60
- inactiveColor,
53
+ }, React__default.createElement(TabbarContext.Provider, {
54
+ value: {
55
+ selectIndex,
61
56
  activeColor,
57
+ inactiveColor,
62
58
  handleClick: setSelectIndex
63
- });
64
- return React__default.cloneElement(child, childProps);
65
- })), (fixed || safeArea) && React__default.createElement("div", {
59
+ }
60
+ }, React__default.Children.map(children, function(child, index) {
61
+ if (!React__default.isValidElement(child))
62
+ return null;
63
+ return React__default.cloneElement(child, _objectSpread(_objectSpread({}, child.props), {}, {
64
+ index
65
+ }));
66
+ }))), (fixed || safeArea) && React__default.createElement("div", {
66
67
  className: "".concat(classPrefix, "-safe-area")
67
68
  }));
68
69
  };
@@ -1 +1 @@
1
- .nut-table{display:flex;width:100%;flex-direction:column;font-size:var(--nutui-font-size-3, 14px);color:var(--nutui-gray-7, #1a1a1a)}.nut-table-main{display:table;width:100%;border-collapse:collapse;overflow-x:hidden;color:var(--nutui-gray-7, #1a1a1a);background-color:var(--nutui-gray-1, #ffffff)}.nut-table-main-striped .nut-table-main-head-tr{background-color:var(--nutui-table-tr-even-bg-color, var(--nutui-gray-3, #f6f6f6))}.nut-table-main-striped .nut-table-main-body-tr:nth-child(odd){background-color:var(--nutui-table-tr-odd-bg-color, #ffffff)}.nut-table-main-striped .nut-table-main-body-tr:nth-child(2n){background-color:var(--nutui-table-tr-even-bg-color, var(--nutui-gray-3, #f6f6f6))}.nut-table-main-head-tr,.nut-table-main-body-tr{display:table-row}.nut-table-main-head-tr-th,.nut-table-main-body-tr-th,.nut-table-main-head-tr-td,.nut-table-main-body-tr-td{display:table-cell;padding:var(--nutui-table-cols-padding, 10px)}.nut-table-main-head-tr-td-nodata,.nut-table-main-body-tr-td-nodata{display:flex;height:50px;align-items:center;justify-content:center}.nut-table-main-head-tr-border,.nut-table-main-body-tr-border{border:1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, .06)))}.nut-table-main-head-tr-alignleft,.nut-table-main-head-tr-align,.nut-table-main-body-tr-alignleft,.nut-table-main-body-tr-align{text-align:left}.nut-table-main-head-tr-aligncenter,.nut-table-main-body-tr-aligncenter{text-align:center}.nut-table-main-head-tr-alignright,.nut-table-main-body-tr-alignright{text-align:right}.nut-table-main-head{display:table-header-group}.nut-table-main-body{display:table-row-group}.nut-table-summary{color:var(--nutui-gray-7, #1a1a1a);background-color:var(--nutui-gray-1, #ffffff);display:flex;align-items:center;justify-content:center;height:30px;padding:var(--nutui-table-cols-padding, 10px)}
1
+ .nut-table{overflow:hidden;position:relative}.nut-table-wrapper{display:flex;width:100%;flex-direction:column;font-size:var(--nutui-font-size-3, 14px);color:var(--nutui-gray-7, #1a1a1a);overflow:auto;position:relative;border:1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, .06)))}.nut-table-main{display:table;overflow-x:auto;color:var(--nutui-gray-7, #1a1a1a);background-color:var(--nutui-gray-1, #ffffff);table-layout:fixed;width:max-content;min-width:100%;position:relative}.nut-table-main-striped .nut-table-main-head-tr{background-color:var(--nutui-table-tr-even-bg-color, var(--nutui-gray-3, #f6f6f6))}.nut-table-main-striped .nut-table-main-body-tr:nth-child(odd){background-color:var(--nutui-table-tr-odd-bg-color, #ffffff)}.nut-table-main-striped .nut-table-main-body-tr:nth-child(2n){background-color:var(--nutui-table-tr-even-bg-color, var(--nutui-gray-3, #f6f6f6))}.nut-table-main-head,.nut-table-main-body{background:inherit}.nut-table-main-head-tr,.nut-table-main-body-tr{display:table-row;background:inherit}.nut-table-main-head-tr:last-child .nut-table-main-body-tr-td,.nut-table-main-body-tr:last-child .nut-table-main-body-tr-td{border-bottom:none}.nut-table-main-head-tr-th,.nut-table-main-body-tr-th{display:table-cell;padding:var(--nutui-table-cols-padding, 10px);background:inherit;position:sticky;top:0}.nut-table-main-head-tr-th.nut-table-fixed-left,.nut-table-main-head-tr-th.nut-table-fixed-right,.nut-table-main-body-tr-th.nut-table-fixed-left,.nut-table-main-body-tr-th.nut-table-fixed-right{z-index:4}.nut-table-main-head-tr-th:last-child,.nut-table-main-body-tr-th:last-child{border-right:none}.nut-table-main-head-tr-td,.nut-table-main-body-tr-td{display:table-cell;padding:var(--nutui-table-cols-padding, 10px);background:inherit}.nut-table-main-head-tr-td:last-child,.nut-table-main-body-tr-td:last-child{border-right:none}.nut-table-main-head-tr-td-nodata,.nut-table-main-body-tr-td-nodata{display:flex;height:50px;align-items:center;justify-content:center}.nut-table-main-head-tr-border,.nut-table-main-body-tr-border{border-right:1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, .06)));border-bottom:1px solid var(--nutui-table-border-color, var(--nutui-black-3, rgba(0, 0, 0, .06)))}.nut-table-main-head-tr-alignleft,.nut-table-main-head-tr-align,.nut-table-main-body-tr-alignleft,.nut-table-main-body-tr-align{text-align:left}.nut-table-main-head-tr-aligncenter,.nut-table-main-body-tr-aligncenter{text-align:center}.nut-table-main-head-tr-alignright,.nut-table-main-body-tr-alignright{text-align:right}.nut-table-main-head{display:table-header-group}.nut-table-main-body{display:table-row-group}.nut-table-sticky-left,.nut-table-sticky-right{position:absolute;top:0;width:8px;bottom:-1px;overflow-x:hidden;overflow-y:hidden;box-shadow:none;touch-action:none;pointer-events:none;z-index:3;background:transparent}.nut-table-sticky-left{left:1px;box-shadow:var(--nutui-table-sticky-left-shadow, 4px 0 8px 0 rgba(0, 0, 0, .1))}.nut-table-sticky-right{right:1px;box-shadow:var(--nutui-table-sticky-right-shadow, -4px 0 8px 0 rgba(0, 0, 0, .1))}.nut-table-fixed-left,.nut-table-fixed-right{position:sticky;z-index:2}.nut-table-fixed-left-last{border-right:none}.nut-table-summary{color:var(--nutui-gray-7, #1a1a1a);background-color:var(--nutui-gray-1, #ffffff);display:flex;align-items:center;justify-content:center;height:30px;padding:var(--nutui-table-cols-padding, 10px);position:relative;z-index:5}