@nutui/nutui-react-taro 2.3.3 → 2.3.4

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 +15 -0
  2. package/dist/esm/DatePicker.js +1 -1
  3. package/dist/esm/InfiniteLoading/style/style.css +1 -1
  4. package/dist/esm/InfiniteLoading.js +1 -1
  5. package/dist/esm/Popover/style/style.css +1 -1
  6. package/dist/esm/Popover.js +1 -1
  7. package/dist/esm/Tabbar/style/style.css +1 -1
  8. package/dist/esm/TabbarItem/style/style.css +1 -1
  9. package/dist/esm/Tour/style/style.css +1 -1
  10. package/dist/esm/Tour.js +2 -2
  11. package/dist/esm/VirtualList.js +1 -1
  12. package/dist/esm/{datepicker.taro-7xNSgNRT.js → datepicker.taro-9VuzlCew.js} +1 -3
  13. package/dist/esm/{infiniteloading.taro-eSS7cIsT.js → infiniteloading.taro-sl41Ddeh.js} +8 -6
  14. package/dist/esm/nutui-react.es.js +5 -5
  15. package/dist/esm/{popover.taro-N1dZfUxf.js → popover.taro-ScQymuJC.js} +2 -2
  16. package/dist/esm/{tour.taro-_3C-szH1.js → tour.taro-GabSljal.js} +1 -1
  17. package/dist/esm/types/src/packages/infiniteloading/infiniteloading.d.ts +2 -2
  18. package/dist/esm/types/src/packages/infiniteloading/infiniteloading.taro.d.ts +2 -2
  19. package/dist/esm/types/src/packages/virtuallist/utils.d.ts +1 -1
  20. package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +1 -0
  21. package/dist/esm/{virtuallist.taro-vrNBr0zS.js → virtuallist.taro-AeTVtFFa.js} +34 -60
  22. package/dist/locales/base.js +1 -1
  23. package/dist/locales/en-US.js +1 -1
  24. package/dist/locales/id-ID.js +1 -1
  25. package/dist/locales/tr-TR.js +1 -1
  26. package/dist/locales/zh-CN.js +1 -1
  27. package/dist/locales/zh-TW.js +1 -1
  28. package/dist/locales/zh-UG.js +1 -1
  29. package/dist/nutui.react.es.js +45 -71
  30. package/dist/nutui.react.umd.js +45 -71
  31. package/dist/packages/infiniteloading/infiniteloading.scss +2 -6
  32. package/dist/packages/popover/popover.scss +21 -15
  33. package/dist/packages/tabbaritem/tabbaritem.scss +10 -4
  34. package/dist/style.css +1 -1
  35. package/dist/style.mjs +1 -1
  36. package/dist/types/packages/infiniteloading/infiniteloading.d.ts +2 -2
  37. package/dist/types/packages/infiniteloading/infiniteloading.taro.d.ts +2 -2
  38. package/dist/types/packages/virtuallist/utils.d.ts +1 -1
  39. package/dist/types/packages/virtuallist/virtuallist.taro.d.ts +1 -0
  40. package/package.json +1 -1
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  /*!
8
- * @nutui/nutui-react-taro v2.3.3 Fri Dec 22 2023 17:47:39 GMT+0800 (China Standard Time)
8
+ * @nutui/nutui-react-taro v2.3.4 Fri Dec 29 2023 14:38:58 GMT+0800 (China Standard Time)
9
9
  * (c) 2023 @jdf2e.
10
10
  * Released under the MIT License.
11
11
  */
@@ -9235,9 +9235,7 @@ const DatePicker = (props) => {
9235
9235
  return val || [];
9236
9236
  };
9237
9237
  useEffect(() => {
9238
- if (selectedDate) {
9239
- setPickerOptions(columns());
9240
- }
9238
+ setPickerOptions(columns());
9241
9239
  }, [selectedDate, startDate, endDate]);
9242
9240
  return /* @__PURE__ */ React__default.createElement(
9243
9241
  View,
@@ -14929,12 +14927,13 @@ const InfiniteLoading = (props) => {
14929
14927
  }
14930
14928
  onScroll && onScroll(e.target.scrollTop);
14931
14929
  };
14932
- const lower = () => {
14930
+ const lower = async () => {
14933
14931
  if (!hasMore || isInfiniting) {
14934
14932
  return false;
14935
14933
  }
14936
14934
  setIsInfiniting(true);
14937
- onLoadMore && onLoadMore(infiniteDone);
14935
+ await (onLoadMore == null ? void 0 : onLoadMore());
14936
+ infiniteDone();
14938
14937
  };
14939
14938
  const touchStart = (event) => {
14940
14939
  if (scrollTop.current === 0 && !isTouching.current && pullRefresh) {
@@ -14957,12 +14956,13 @@ const InfiniteLoading = (props) => {
14957
14956
  isTouching.current = false;
14958
14957
  }
14959
14958
  };
14960
- const touchEnd = () => {
14959
+ const touchEnd = async () => {
14961
14960
  if (distance.current < refreshMaxH.current) {
14962
14961
  distance.current = 0;
14963
14962
  setTopDisScoll(0);
14964
14963
  } else {
14965
- onRefresh && onRefresh(refreshDone);
14964
+ await (onRefresh == null ? void 0 : onRefresh());
14965
+ refreshDone();
14966
14966
  }
14967
14967
  };
14968
14968
  return /* @__PURE__ */ React__default.createElement(
@@ -14979,9 +14979,9 @@ const InfiniteLoading = (props) => {
14979
14979
  onTouchMove: touchMove,
14980
14980
  onTouchEnd: touchEnd
14981
14981
  },
14982
- /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-top", ref: refreshTop, style: getStyle() }, /* @__PURE__ */ React__default.createElement("div", { className: "top-box" }, pullingText || locale.infiniteloading.pullRefreshText)),
14982
+ /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-top", ref: refreshTop, style: getStyle() }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-top-tips" }, pullingText || locale.infiniteloading.pullRefreshText)),
14983
14983
  /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-container" }, children),
14984
- /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-bottom" }, isInfiniting ? /* @__PURE__ */ React__default.createElement("div", { className: "bottom-box" }, loadingText || locale.infiniteloading.loadText) : !hasMore && /* @__PURE__ */ React__default.createElement("div", { className: "bottom-box" }, loadMoreText || locale.infiniteloading.loadMoreText))
14984
+ /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-bottom" }, isInfiniting ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-bottom-tips" }, loadingText || locale.infiniteloading.loadText) : !hasMore && /* @__PURE__ */ React__default.createElement("div", { className: "nut-infinite-bottom-tips" }, loadMoreText || locale.infiniteloading.loadMoreText))
14985
14985
  );
14986
14986
  };
14987
14987
  InfiniteLoading.defaultProps = defaultProps$D;
@@ -15775,10 +15775,10 @@ const Popover = (props) => {
15775
15775
  key: item.key || index,
15776
15776
  onClick: () => handleSelect(item, index)
15777
15777
  },
15778
- item.icon ? /* @__PURE__ */ React__default.createElement("i", { className: "nut-popover-menu-item-icon" }, item.icon) : null,
15778
+ item.icon ? /* @__PURE__ */ React__default.createElement("div", { className: "nut-popover-menu-item-icon" }, item.icon) : null,
15779
15779
  /* @__PURE__ */ React__default.createElement("div", { className: "nut-popover-menu-item-name" }, item.name),
15780
15780
  item.action && item.action.icon ? /* @__PURE__ */ React__default.createElement(
15781
- "i",
15781
+ "div",
15782
15782
  {
15783
15783
  className: "nut-popover-menu-item-action-icon",
15784
15784
  onClick: (e) => {
@@ -19070,37 +19070,16 @@ const initPositinoCache = (reaItemSize, length = 0) => {
19070
19070
  }
19071
19071
  return positions;
19072
19072
  };
19073
- const binarySearch = (positionsList, horizontal, value = 0) => {
19074
- let start = 0;
19075
- let end = positionsList.length - 1;
19076
- let tempIndex = null;
19077
- const key = horizontal ? "right" : "bottom";
19078
- while (start <= end) {
19079
- const midIndex = Math.floor((start + end) / 2);
19080
- const midValue = positionsList[midIndex][key];
19081
- if (midValue === value) {
19082
- return midIndex + 1;
19083
- }
19084
- if (midValue < value) {
19085
- start = midIndex + 1;
19086
- } else if (midValue > value) {
19087
- if (tempIndex === null || tempIndex > midIndex) {
19088
- tempIndex = midIndex;
19089
- }
19090
- end = midIndex - 1;
19091
- }
19092
- }
19093
- tempIndex = tempIndex || 0;
19094
- return tempIndex;
19095
- };
19096
- const updateItemSize = (positions, items, sizeKey) => {
19073
+ const updateItemSize = (positions, items, sizeKey, margin) => {
19097
19074
  const newPos = positions.concat();
19098
19075
  Array.from(items).forEach((item) => {
19099
19076
  const index = Number(item.getAttribute("data-index"));
19100
19077
  const styleVal = item.getAttribute("style");
19101
19078
  if (styleVal && styleVal.includes("none"))
19102
19079
  return;
19103
- const nowSize = item.getBoundingClientRect()[sizeKey];
19080
+ let nowSize = item.getBoundingClientRect()[sizeKey];
19081
+ if (margin)
19082
+ nowSize += margin;
19104
19083
  const oldSize = positions[index][sizeKey];
19105
19084
  const dValue = oldSize - nowSize;
19106
19085
  if (dValue) {
@@ -19128,6 +19107,7 @@ const defaultProps$7 = {
19128
19107
  list: [],
19129
19108
  containerHeight: clientHeight,
19130
19109
  itemHeight: 66,
19110
+ margin: 10,
19131
19111
  itemEqual: true,
19132
19112
  overscan: 2
19133
19113
  };
@@ -19136,6 +19116,7 @@ const VirtualList = (props) => {
19136
19116
  list,
19137
19117
  itemRender,
19138
19118
  itemHeight,
19119
+ margin,
19139
19120
  itemEqual,
19140
19121
  overscan,
19141
19122
  key,
@@ -19148,7 +19129,7 @@ const VirtualList = (props) => {
19148
19129
  ...props
19149
19130
  };
19150
19131
  const [startOffset, setStartOffset] = useState(0);
19151
- const [start, setStart] = useState(0);
19132
+ const start = useRef(0);
19152
19133
  const scrollRef = useRef(null);
19153
19134
  const itemsRef = useRef(null);
19154
19135
  const [positions, setPositions] = useState([
@@ -19163,18 +19144,9 @@ const VirtualList = (props) => {
19163
19144
  }
19164
19145
  ]);
19165
19146
  const [offSetSize, setOffSetSize] = useState(containerHeight || 0);
19166
- const [options, setOptions] = useState({
19167
- startOffset: 0,
19168
- // 可视区域距离顶部的偏移量
19169
- startIndex: 0,
19170
- // 可视区域开始索引
19171
- overStart: 0,
19172
- endIndex: 10
19173
- // 可视区域结束索引
19174
- });
19175
19147
  useEffect(() => {
19176
- setPositions((options2) => {
19177
- return { ...options2, endIndex: visibleCount() };
19148
+ setPositions((options) => {
19149
+ return { ...options, endIndex: visibleCount() };
19178
19150
  });
19179
19151
  }, [itemHeight, overscan, offSetSize]);
19180
19152
  useEffect(() => {
@@ -19183,24 +19155,25 @@ const VirtualList = (props) => {
19183
19155
  setOffSetSize(getContainerHeight());
19184
19156
  }, [containerHeight]);
19185
19157
  useEffect(() => {
19186
- const pos = initPositinoCache(itemHeight, list.length);
19158
+ const pos = initPositinoCache(itemHeight + margin, list.length);
19187
19159
  setPositions(pos);
19188
19160
  }, [itemHeight, list]);
19161
+ const prevListLength = useRef(list.length);
19189
19162
  const getContainerHeight = () => {
19190
- const initH = itemHeight * list.length;
19191
- return initH < clientHeight ? initH + overscan * itemHeight - 5 : Math.min(containerHeight, clientHeight);
19163
+ const initH = (itemHeight + margin) * list.length;
19164
+ return initH < clientHeight ? initH + overscan * (itemHeight + margin) - 5 : Math.min(containerHeight, clientHeight);
19192
19165
  };
19193
19166
  const visibleCount = () => {
19194
- return Math.ceil(getContainerHeight() / itemHeight) + overscan;
19167
+ return Math.ceil(getContainerHeight() / (itemHeight + margin)) + overscan;
19195
19168
  };
19196
19169
  const end = () => {
19197
- return start + visibleCount();
19170
+ return start.current + visibleCount();
19198
19171
  };
19199
19172
  const listHeight = () => {
19200
- return list.length * itemHeight;
19173
+ return list.length * (itemHeight + margin);
19201
19174
  };
19202
19175
  const visibleData = () => {
19203
- return list.slice(start, Math.min(end(), list.length));
19176
+ return list.slice(start.current, Math.min(end(), list.length));
19204
19177
  };
19205
19178
  const updateTotalSize = useCallback(() => {
19206
19179
  if (!itemsRef.current)
@@ -19208,26 +19181,27 @@ const VirtualList = (props) => {
19208
19181
  const items = itemsRef.current.children;
19209
19182
  if (!items.length)
19210
19183
  return;
19211
- updateItemSize(positions, items, "height");
19184
+ updateItemSize(positions, items, "height", margin);
19212
19185
  }, [positions]);
19213
19186
  const listScroll = (e) => {
19214
19187
  const scrollTop = e.target.scrollTop;
19215
- const scrollSize = Math.floor(scrollTop);
19216
- const startIndex = binarySearch(positions, false, scrollSize);
19217
- const overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
19218
- const endIndex = end();
19188
+ if (scrollTop <= 0) {
19189
+ e.target.scrollTop = 0;
19190
+ return setStartOffset(0);
19191
+ }
19219
19192
  if (!itemEqual) {
19220
19193
  updateTotalSize();
19221
19194
  }
19222
- setStart(Math.floor(scrollTop / itemHeight));
19223
- setOptions({ startOffset, startIndex, overStart, endIndex });
19224
- if (end() > list.length - 1) {
19195
+ start.current = Math.floor(scrollTop / (itemHeight + margin));
19196
+ setStartOffset(scrollTop - scrollTop % (itemHeight + margin));
19197
+ const endIndex = end();
19198
+ if (endIndex > list.length - 1 && prevListLength.current < list.length) {
19225
19199
  onScroll && onScroll();
19200
+ prevListLength.current = list.length;
19226
19201
  }
19227
- setStartOffset(scrollTop - scrollTop % itemHeight);
19228
19202
  };
19229
19203
  return /* @__PURE__ */ React__default.createElement(
19230
- "div",
19204
+ View,
19231
19205
  {
19232
19206
  className: classNames("nut-virtualList-box", className),
19233
19207
  ...rest,
@@ -19239,6 +19213,7 @@ const VirtualList = (props) => {
19239
19213
  ScrollView,
19240
19214
  {
19241
19215
  scrollY: true,
19216
+ bounces: false,
19242
19217
  type: "list",
19243
19218
  ref: scrollRef,
19244
19219
  className: "nut-virtuallist",
@@ -19248,25 +19223,24 @@ const VirtualList = (props) => {
19248
19223
  onScroll: listScroll
19249
19224
  },
19250
19225
  /* @__PURE__ */ React__default.createElement(
19251
- "div",
19226
+ View,
19252
19227
  {
19253
19228
  className: "nut-virtuallist-phantom",
19254
19229
  style: { height: `${listHeight()}px` }
19255
19230
  }
19256
19231
  ),
19257
19232
  /* @__PURE__ */ React__default.createElement(
19258
- "div",
19233
+ View,
19259
19234
  {
19260
19235
  className: "nut-virtuallist-container",
19261
19236
  ref: itemsRef,
19262
19237
  style: { transform: `translate3d(0, ${startOffset}px, 0)` }
19263
19238
  },
19264
19239
  visibleData().map((data, index) => {
19265
- const { overStart } = options;
19266
- const dataIndex = overStart + index;
19240
+ const dataIndex = start.current + index;
19267
19241
  const keyVal = key && data[key] ? data[key] : dataIndex;
19268
19242
  return /* @__PURE__ */ React__default.createElement(
19269
- "div",
19243
+ View,
19270
19244
  {
19271
19245
  "data-index": `${dataIndex}`,
19272
19246
  className: "nut-virtuallist-item",
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
8
8
  return value;
9
9
  };
10
10
  /*!
11
- * @nutui/nutui-react-taro v2.3.3 Fri Dec 22 2023 17:47:39 GMT+0800 (China Standard Time)
11
+ * @nutui/nutui-react-taro v2.3.4 Fri Dec 29 2023 14:38:58 GMT+0800 (China Standard Time)
12
12
  * (c) 2023 @jdf2e.
13
13
  * Released under the MIT License.
14
14
  */
@@ -9251,9 +9251,7 @@ Check the top-level render call using <` + t2 + ">.");
9251
9251
  return val || [];
9252
9252
  };
9253
9253
  React.useEffect(() => {
9254
- if (selectedDate) {
9255
- setPickerOptions(columns());
9256
- }
9254
+ setPickerOptions(columns());
9257
9255
  }, [selectedDate, startDate, endDate]);
9258
9256
  return /* @__PURE__ */ React.createElement(
9259
9257
  components.View,
@@ -14945,12 +14943,13 @@ Check the top-level render call using <` + t2 + ">.");
14945
14943
  }
14946
14944
  onScroll && onScroll(e.target.scrollTop);
14947
14945
  };
14948
- const lower = () => {
14946
+ const lower = async () => {
14949
14947
  if (!hasMore || isInfiniting) {
14950
14948
  return false;
14951
14949
  }
14952
14950
  setIsInfiniting(true);
14953
- onLoadMore && onLoadMore(infiniteDone);
14951
+ await (onLoadMore == null ? void 0 : onLoadMore());
14952
+ infiniteDone();
14954
14953
  };
14955
14954
  const touchStart = (event) => {
14956
14955
  if (scrollTop.current === 0 && !isTouching.current && pullRefresh) {
@@ -14973,12 +14972,13 @@ Check the top-level render call using <` + t2 + ">.");
14973
14972
  isTouching.current = false;
14974
14973
  }
14975
14974
  };
14976
- const touchEnd = () => {
14975
+ const touchEnd = async () => {
14977
14976
  if (distance.current < refreshMaxH.current) {
14978
14977
  distance.current = 0;
14979
14978
  setTopDisScoll(0);
14980
14979
  } else {
14981
- onRefresh && onRefresh(refreshDone);
14980
+ await (onRefresh == null ? void 0 : onRefresh());
14981
+ refreshDone();
14982
14982
  }
14983
14983
  };
14984
14984
  return /* @__PURE__ */ React.createElement(
@@ -14995,9 +14995,9 @@ Check the top-level render call using <` + t2 + ">.");
14995
14995
  onTouchMove: touchMove,
14996
14996
  onTouchEnd: touchEnd
14997
14997
  },
14998
- /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-top", ref: refreshTop, style: getStyle() }, /* @__PURE__ */ React.createElement("div", { className: "top-box" }, pullingText || locale.infiniteloading.pullRefreshText)),
14998
+ /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-top", ref: refreshTop, style: getStyle() }, /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-top-tips" }, pullingText || locale.infiniteloading.pullRefreshText)),
14999
14999
  /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-container" }, children),
15000
- /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-bottom" }, isInfiniting ? /* @__PURE__ */ React.createElement("div", { className: "bottom-box" }, loadingText || locale.infiniteloading.loadText) : !hasMore && /* @__PURE__ */ React.createElement("div", { className: "bottom-box" }, loadMoreText || locale.infiniteloading.loadMoreText))
15000
+ /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-bottom" }, isInfiniting ? /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-bottom-tips" }, loadingText || locale.infiniteloading.loadText) : !hasMore && /* @__PURE__ */ React.createElement("div", { className: "nut-infinite-bottom-tips" }, loadMoreText || locale.infiniteloading.loadMoreText))
15001
15001
  );
15002
15002
  };
15003
15003
  InfiniteLoading.defaultProps = defaultProps$D;
@@ -15791,10 +15791,10 @@ Check the top-level render call using <` + t2 + ">.");
15791
15791
  key: item.key || index,
15792
15792
  onClick: () => handleSelect(item, index)
15793
15793
  },
15794
- item.icon ? /* @__PURE__ */ React.createElement("i", { className: "nut-popover-menu-item-icon" }, item.icon) : null,
15794
+ item.icon ? /* @__PURE__ */ React.createElement("div", { className: "nut-popover-menu-item-icon" }, item.icon) : null,
15795
15795
  /* @__PURE__ */ React.createElement("div", { className: "nut-popover-menu-item-name" }, item.name),
15796
15796
  item.action && item.action.icon ? /* @__PURE__ */ React.createElement(
15797
- "i",
15797
+ "div",
15798
15798
  {
15799
15799
  className: "nut-popover-menu-item-action-icon",
15800
15800
  onClick: (e) => {
@@ -19086,37 +19086,16 @@ Check the top-level render call using <` + t2 + ">.");
19086
19086
  }
19087
19087
  return positions;
19088
19088
  };
19089
- const binarySearch = (positionsList, horizontal, value = 0) => {
19090
- let start = 0;
19091
- let end = positionsList.length - 1;
19092
- let tempIndex = null;
19093
- const key = horizontal ? "right" : "bottom";
19094
- while (start <= end) {
19095
- const midIndex = Math.floor((start + end) / 2);
19096
- const midValue = positionsList[midIndex][key];
19097
- if (midValue === value) {
19098
- return midIndex + 1;
19099
- }
19100
- if (midValue < value) {
19101
- start = midIndex + 1;
19102
- } else if (midValue > value) {
19103
- if (tempIndex === null || tempIndex > midIndex) {
19104
- tempIndex = midIndex;
19105
- }
19106
- end = midIndex - 1;
19107
- }
19108
- }
19109
- tempIndex = tempIndex || 0;
19110
- return tempIndex;
19111
- };
19112
- const updateItemSize = (positions, items, sizeKey) => {
19089
+ const updateItemSize = (positions, items, sizeKey, margin) => {
19113
19090
  const newPos = positions.concat();
19114
19091
  Array.from(items).forEach((item) => {
19115
19092
  const index = Number(item.getAttribute("data-index"));
19116
19093
  const styleVal = item.getAttribute("style");
19117
19094
  if (styleVal && styleVal.includes("none"))
19118
19095
  return;
19119
- const nowSize = item.getBoundingClientRect()[sizeKey];
19096
+ let nowSize = item.getBoundingClientRect()[sizeKey];
19097
+ if (margin)
19098
+ nowSize += margin;
19120
19099
  const oldSize = positions[index][sizeKey];
19121
19100
  const dValue = oldSize - nowSize;
19122
19101
  if (dValue) {
@@ -19144,6 +19123,7 @@ Check the top-level render call using <` + t2 + ">.");
19144
19123
  list: [],
19145
19124
  containerHeight: clientHeight,
19146
19125
  itemHeight: 66,
19126
+ margin: 10,
19147
19127
  itemEqual: true,
19148
19128
  overscan: 2
19149
19129
  };
@@ -19152,6 +19132,7 @@ Check the top-level render call using <` + t2 + ">.");
19152
19132
  list,
19153
19133
  itemRender,
19154
19134
  itemHeight,
19135
+ margin,
19155
19136
  itemEqual,
19156
19137
  overscan,
19157
19138
  key,
@@ -19164,7 +19145,7 @@ Check the top-level render call using <` + t2 + ">.");
19164
19145
  ...props
19165
19146
  };
19166
19147
  const [startOffset, setStartOffset] = React.useState(0);
19167
- const [start, setStart] = React.useState(0);
19148
+ const start = React.useRef(0);
19168
19149
  const scrollRef = React.useRef(null);
19169
19150
  const itemsRef = React.useRef(null);
19170
19151
  const [positions, setPositions] = React.useState([
@@ -19179,18 +19160,9 @@ Check the top-level render call using <` + t2 + ">.");
19179
19160
  }
19180
19161
  ]);
19181
19162
  const [offSetSize, setOffSetSize] = React.useState(containerHeight || 0);
19182
- const [options, setOptions] = React.useState({
19183
- startOffset: 0,
19184
- // 可视区域距离顶部的偏移量
19185
- startIndex: 0,
19186
- // 可视区域开始索引
19187
- overStart: 0,
19188
- endIndex: 10
19189
- // 可视区域结束索引
19190
- });
19191
19163
  React.useEffect(() => {
19192
- setPositions((options2) => {
19193
- return { ...options2, endIndex: visibleCount() };
19164
+ setPositions((options) => {
19165
+ return { ...options, endIndex: visibleCount() };
19194
19166
  });
19195
19167
  }, [itemHeight, overscan, offSetSize]);
19196
19168
  React.useEffect(() => {
@@ -19199,24 +19171,25 @@ Check the top-level render call using <` + t2 + ">.");
19199
19171
  setOffSetSize(getContainerHeight());
19200
19172
  }, [containerHeight]);
19201
19173
  React.useEffect(() => {
19202
- const pos = initPositinoCache(itemHeight, list.length);
19174
+ const pos = initPositinoCache(itemHeight + margin, list.length);
19203
19175
  setPositions(pos);
19204
19176
  }, [itemHeight, list]);
19177
+ const prevListLength = React.useRef(list.length);
19205
19178
  const getContainerHeight = () => {
19206
- const initH = itemHeight * list.length;
19207
- return initH < clientHeight ? initH + overscan * itemHeight - 5 : Math.min(containerHeight, clientHeight);
19179
+ const initH = (itemHeight + margin) * list.length;
19180
+ return initH < clientHeight ? initH + overscan * (itemHeight + margin) - 5 : Math.min(containerHeight, clientHeight);
19208
19181
  };
19209
19182
  const visibleCount = () => {
19210
- return Math.ceil(getContainerHeight() / itemHeight) + overscan;
19183
+ return Math.ceil(getContainerHeight() / (itemHeight + margin)) + overscan;
19211
19184
  };
19212
19185
  const end = () => {
19213
- return start + visibleCount();
19186
+ return start.current + visibleCount();
19214
19187
  };
19215
19188
  const listHeight = () => {
19216
- return list.length * itemHeight;
19189
+ return list.length * (itemHeight + margin);
19217
19190
  };
19218
19191
  const visibleData = () => {
19219
- return list.slice(start, Math.min(end(), list.length));
19192
+ return list.slice(start.current, Math.min(end(), list.length));
19220
19193
  };
19221
19194
  const updateTotalSize = React.useCallback(() => {
19222
19195
  if (!itemsRef.current)
@@ -19224,26 +19197,27 @@ Check the top-level render call using <` + t2 + ">.");
19224
19197
  const items = itemsRef.current.children;
19225
19198
  if (!items.length)
19226
19199
  return;
19227
- updateItemSize(positions, items, "height");
19200
+ updateItemSize(positions, items, "height", margin);
19228
19201
  }, [positions]);
19229
19202
  const listScroll = (e) => {
19230
19203
  const scrollTop = e.target.scrollTop;
19231
- const scrollSize = Math.floor(scrollTop);
19232
- const startIndex = binarySearch(positions, false, scrollSize);
19233
- const overStart = startIndex - overscan > -1 ? startIndex - overscan : 0;
19234
- const endIndex = end();
19204
+ if (scrollTop <= 0) {
19205
+ e.target.scrollTop = 0;
19206
+ return setStartOffset(0);
19207
+ }
19235
19208
  if (!itemEqual) {
19236
19209
  updateTotalSize();
19237
19210
  }
19238
- setStart(Math.floor(scrollTop / itemHeight));
19239
- setOptions({ startOffset, startIndex, overStart, endIndex });
19240
- if (end() > list.length - 1) {
19211
+ start.current = Math.floor(scrollTop / (itemHeight + margin));
19212
+ setStartOffset(scrollTop - scrollTop % (itemHeight + margin));
19213
+ const endIndex = end();
19214
+ if (endIndex > list.length - 1 && prevListLength.current < list.length) {
19241
19215
  onScroll && onScroll();
19216
+ prevListLength.current = list.length;
19242
19217
  }
19243
- setStartOffset(scrollTop - scrollTop % itemHeight);
19244
19218
  };
19245
19219
  return /* @__PURE__ */ React.createElement(
19246
- "div",
19220
+ components.View,
19247
19221
  {
19248
19222
  className: classNames("nut-virtualList-box", className),
19249
19223
  ...rest,
@@ -19255,6 +19229,7 @@ Check the top-level render call using <` + t2 + ">.");
19255
19229
  components.ScrollView,
19256
19230
  {
19257
19231
  scrollY: true,
19232
+ bounces: false,
19258
19233
  type: "list",
19259
19234
  ref: scrollRef,
19260
19235
  className: "nut-virtuallist",
@@ -19264,25 +19239,24 @@ Check the top-level render call using <` + t2 + ">.");
19264
19239
  onScroll: listScroll
19265
19240
  },
19266
19241
  /* @__PURE__ */ React.createElement(
19267
- "div",
19242
+ components.View,
19268
19243
  {
19269
19244
  className: "nut-virtuallist-phantom",
19270
19245
  style: { height: `${listHeight()}px` }
19271
19246
  }
19272
19247
  ),
19273
19248
  /* @__PURE__ */ React.createElement(
19274
- "div",
19249
+ components.View,
19275
19250
  {
19276
19251
  className: "nut-virtuallist-container",
19277
19252
  ref: itemsRef,
19278
19253
  style: { transform: `translate3d(0, ${startOffset}px, 0)` }
19279
19254
  },
19280
19255
  visibleData().map((data, index) => {
19281
- const { overStart } = options;
19282
- const dataIndex = overStart + index;
19256
+ const dataIndex = start.current + index;
19283
19257
  const keyVal = key && data[key] ? data[key] : dataIndex;
19284
19258
  return /* @__PURE__ */ React.createElement(
19285
- "div",
19259
+ components.View,
19286
19260
  {
19287
19261
  "data-index": `${dataIndex}`,
19288
19262
  className: "nut-virtuallist-item",
@@ -11,7 +11,7 @@
11
11
  font-size: $font-size-small;
12
12
  color: $infiniteloading-color;
13
13
 
14
- .top-box {
14
+ &-tips {
15
15
  width: 100%;
16
16
  display: flex;
17
17
  flex-direction: column;
@@ -21,8 +21,6 @@
21
21
  display: flex;
22
22
  justify-content: center;
23
23
  align-items: center;
24
- width: $pulltorefresh-icon-width;
25
- height: $pulltorefresh-icon-height;
26
24
  margin-bottom: 4px;
27
25
  }
28
26
  }
@@ -38,14 +36,12 @@
38
36
  color: $infiniteloading-color;
39
37
  text-align: center;
40
38
 
41
- .bottom-box {
39
+ &-tips {
42
40
  display: flex;
43
41
  justify-content: center;
44
42
  align-items: center;
45
43
 
46
44
  &-icons {
47
- width: $infiniteloading-icon-size;
48
- height: $infiniteloading-icon-size;
49
45
  margin-right: 8px;
50
46
  }
51
47
  }
@@ -22,21 +22,6 @@
22
22
  border-bottom-color: $popover-border-color;
23
23
  border-top-width: 0;
24
24
  margin-top: -8px;
25
-
26
- &.nut-popover-arrow-bottom {
27
- left: 50%;
28
- transform: translateX(-50%);
29
- }
30
-
31
- &.nut-popover-arrow-bottom-start {
32
- left: 16px;
33
- transform: translateX(0%);
34
- }
35
-
36
- &.nut-popover-arrow-bottom-end {
37
- right: 16px;
38
- transform: translateX(0%);
39
- }
40
25
  }
41
26
 
42
27
  &-left {
@@ -189,10 +174,31 @@
189
174
  }
190
175
  }
191
176
 
177
+ &-bottom {
178
+ .nut-popover-arrow-bottom {
179
+ left: 50%;
180
+ transform: translateX(-50%);
181
+ }
182
+ }
183
+
192
184
  &-bottom-end {
185
+ .nut-popover-arrow-bottom-end {
186
+ right: 16px;
187
+ transform: translateX(0%);
188
+ }
189
+
193
190
  right: 0;
194
191
  }
195
192
 
193
+ &-bottom-start {
194
+ left: 0;
195
+
196
+ .nut-popover-arrow-bottom-start {
197
+ left: 16px;
198
+ transform: translateX(0%);
199
+ }
200
+ }
201
+
196
202
  &-left-end {
197
203
  bottom: 0;
198
204
  }
@@ -10,10 +10,6 @@
10
10
  color: $tabbar-inactive-color;
11
11
  height: 100%;
12
12
 
13
- &-active {
14
- color: $tabbar-active-color;
15
- }
16
-
17
13
  &-icon-box {
18
14
  padding: 0px;
19
15
  display: flex;
@@ -40,4 +36,14 @@
40
36
  font-weight: $tabbar-text-large-font-weight;
41
37
  }
42
38
  }
39
+
40
+ &-active {
41
+ color: $tabbar-active-color;
42
+ .nut-tabbar-item-icon-box {
43
+ color: inherit;
44
+ .nut-icon {
45
+ color: inherit;
46
+ }
47
+ }
48
+ }
43
49
  }