@nutui/nutui-react-taro 2.6.14 → 2.6.15

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 (56) hide show
  1. package/CHANGELOG.md +914 -909
  2. package/README.md +21 -28
  3. package/dist/esm/Audio.js +1 -1
  4. package/dist/esm/Calendar.js +1 -1
  5. package/dist/esm/CalendarItem.js +1 -1
  6. package/dist/esm/Checkbox.js +1 -1
  7. package/dist/esm/CheckboxGroup.js +1 -1
  8. package/dist/esm/DatePicker.js +1 -1
  9. package/dist/esm/ImagePreview.js +1 -1
  10. package/dist/esm/InfiniteLoading.js +1 -1
  11. package/dist/esm/Menu.js +1 -1
  12. package/dist/esm/PullToRefresh.js +1 -1
  13. package/dist/esm/Radio.js +1 -1
  14. package/dist/esm/RadioGroup.js +1 -1
  15. package/dist/esm/Sticky.js +1 -1
  16. package/dist/esm/Swipe.js +1 -1
  17. package/dist/esm/Swiper.js +1 -2
  18. package/dist/esm/SwiperItem.js +1 -1
  19. package/dist/esm/Table.js +1 -1
  20. package/dist/esm/Uploader/style/style.css +1 -1
  21. package/dist/esm/Uploader.js +1 -1
  22. package/dist/esm/WaterMark.js +1 -1
  23. package/dist/esm/{audio.taro-DzSc40G9.js → audio.taro-CD-vP_u0.js} +7 -8
  24. package/dist/esm/{calendar.taro-Bf5owfGd.js → calendar.taro-BXrHr8bg.js} +1 -1
  25. package/dist/esm/{calendaritem.taro-PLHReAvU.js → calendaritem.taro-CRultyrO.js} +3 -1
  26. package/dist/esm/{checkbox.taro-Dc054oRo.js → checkbox.taro-CgqJyhrh.js} +4 -5
  27. package/dist/esm/{datepicker.taro-DTyJrlhD.js → datepicker.taro-BxaZ3Fjv.js} +3 -4
  28. package/dist/esm/{imagepreview.taro-DtgQJEQ_.js → imagepreview.taro-CF-CCJ1Q.js} +1 -1
  29. package/dist/esm/{infiniteloading.taro-DmDQKk_d.js → infiniteloading.taro-TbcBB0Qr.js} +1 -1
  30. package/dist/esm/{menu.taro-CrPdDbYM.js → menu.taro-BeuoJcj7.js} +2 -2
  31. package/dist/esm/nutui-react.es.js +16 -16
  32. package/dist/esm/{pulltorefresh.taro-CZReoWwU.js → pulltorefresh.taro-BScP6uPx.js} +0 -1
  33. package/dist/esm/{radio.taro-BNSceequ.js → radio.taro-CzOHqD3O.js} +0 -2
  34. package/dist/esm/{sticky.taro-DZzgkigZ.js → sticky.taro-Zbz7wQH8.js} +29 -31
  35. package/dist/esm/{swipe.taro-yUhne9XU.js → swipe.taro-Bsk2fnEl.js} +0 -1
  36. package/dist/esm/{swiperitem.taro-DeiNSrJV.js → swiperitem.taro-BleF1EOs.js} +0 -5
  37. package/dist/esm/{table.taro-D2M3D2Vj.js → table.taro-B6WCKTkO.js} +6 -5
  38. package/dist/esm/{uploader.taro-CiamsRGo.js → uploader.taro-DfO2HWvy.js} +13 -11
  39. package/dist/esm/{watermark.taro-BR12yZQt.js → watermark.taro-CZ6R5FlJ.js} +3 -3
  40. package/dist/locales/base.js +1 -1
  41. package/dist/locales/en-US.js +1 -1
  42. package/dist/locales/id-ID.js +1 -1
  43. package/dist/locales/tr-TR.js +1 -1
  44. package/dist/locales/zh-CN.js +1 -1
  45. package/dist/locales/zh-TW.js +1 -1
  46. package/dist/locales/zh-UG.js +1 -1
  47. package/dist/nutui.react.es.js +236 -247
  48. package/dist/nutui.react.umd.js +236 -247
  49. package/dist/packages/uploader/uploader.scss +3 -1
  50. package/dist/style.css +1 -1
  51. package/dist/types/packages/swiperitem/swiperitem.d.ts +0 -1
  52. package/dist/types/packages/watermark/watermark.d.ts +2 -0
  53. package/dist/types/packages/watermark/watermark.taro.d.ts +10 -0
  54. package/dist/types/utils/get-scroll-parent.d.ts +1 -1
  55. package/dist/types/utils/use-client-rect.d.ts +1 -1
  56. package/package.json +2 -2
@@ -41,22 +41,21 @@ const Sticky = (props) => {
41
41
  onChange && onChange(fixed);
42
42
  });
43
43
  const rootStyle = useMemo(() => {
44
+ var _a2, _b;
44
45
  if (!fixed) {
45
46
  return {
46
47
  height: "",
47
48
  width: ""
48
49
  };
49
50
  }
50
- const style2 = {};
51
- if (rootRect.height) {
52
- style2.height = rootRect.height;
53
- }
54
- if (rootRect.width) {
55
- style2.width = rootRect.width;
56
- }
51
+ const style2 = {
52
+ height: (_a2 = rootRect.height) !== null && _a2 !== void 0 ? _a2 : "",
53
+ width: (_b = rootRect.width) !== null && _b !== void 0 ? _b : ""
54
+ };
57
55
  return style2;
58
56
  }, [fixed, rootRect.height, rootRect.width]);
59
57
  const stickyStyle = useMemo(() => {
58
+ var _a2, _b;
60
59
  if (!fixed) {
61
60
  return {
62
61
  height: "",
@@ -64,38 +63,37 @@ const Sticky = (props) => {
64
63
  [position]: ""
65
64
  };
66
65
  }
67
- const style2 = {};
68
- if (rootRect.height)
69
- style2.height = rootRect.height;
70
- if (rootRect.width)
71
- style2.width = rootRect.width;
72
- style2.transform = `translate3d(0, ${transform}px, 0)`;
73
- style2[position] = threshold;
74
- style2.zIndex = zIndex;
66
+ const style2 = {
67
+ height: (_a2 = rootRect.height) !== null && _a2 !== void 0 ? _a2 : "",
68
+ width: (_b = rootRect.width) !== null && _b !== void 0 ? _b : "",
69
+ transform: `translate3d(0, ${transform}px, 0)`,
70
+ [position]: threshold,
71
+ zIndex
72
+ };
75
73
  return style2;
76
74
  }, [fixed, rootRect.height, rootRect.width, transform, position]);
77
75
  const handleScroll = (scrollTop) => __awaiter(void 0, void 0, void 0, function* () {
78
76
  const curRootRect = yield getRectByTaro(rootRef.current);
79
77
  const stickyRect = yield getRectByTaro(stickyRef.current);
80
- if (curRootRect && stickyRect) {
81
- setRootRect(curRootRect);
82
- if (position === "top") {
83
- if (container) {
84
- const containerRect = yield getRectByTaro(container.current);
85
- const difference = containerRect.bottom - threshold - curRootRect.height;
86
- const curTransform = difference < 0 ? difference : 0;
87
- setTransform(curTransform);
88
- const curFixed = threshold > curRootRect.top && containerRect.bottom > 0;
89
- setFixed(curFixed);
90
- } else {
91
- setFixed(threshold > curRootRect.top);
92
- }
78
+ if (!curRootRect || !stickyRect) {
79
+ console.warn("getRectByTaro获取失败", { stickyRect, curRootRect });
80
+ return;
81
+ }
82
+ setRootRect(curRootRect);
83
+ if (position === "top") {
84
+ if (container) {
85
+ const containerRect = yield getRectByTaro(container.current);
86
+ const difference = containerRect.bottom - threshold - curRootRect.height;
87
+ const curTransform = difference < 0 ? difference : 0;
88
+ setTransform(curTransform);
89
+ const curFixed = threshold > curRootRect.top && containerRect.bottom > 0;
90
+ setFixed(curFixed);
93
91
  } else {
94
- const windowHeight = getSystemInfoSync().windowHeight;
95
- setFixed(windowHeight - threshold < curRootRect.bottom);
92
+ setFixed(threshold > curRootRect.top);
96
93
  }
97
94
  } else {
98
- console.warn("getRectByTaro获取失败", { stickyRect, curRootRect });
95
+ const windowHeight = getSystemInfoSync().windowHeight;
96
+ setFixed(windowHeight - threshold < curRootRect.bottom);
99
97
  }
100
98
  });
101
99
  const getElement = useCallback(() => {
@@ -178,7 +178,6 @@ const Swipe = forwardRef((props, instanceRef) => {
178
178
  )
179
179
  );
180
180
  });
181
- Swipe.defaultProps = defaultProps;
182
181
  Swipe.displayName = "NutSwipe";
183
182
  export {
184
183
  Swipe as S
@@ -1,15 +1,10 @@
1
1
  import { _ as __rest } from "./tslib.es6-iWu3F_1J.js";
2
2
  import React__default from "react";
3
- const defaultProps = {
4
- itemId: "",
5
- skipHiddenItemLayout: false
6
- };
7
3
  const SwiperItem = (props) => {
8
4
  const { children } = props;
9
5
  __rest(props, ["children"]);
10
6
  return React__default.createElement(React__default.Fragment, null, children);
11
7
  };
12
- SwiperItem.defaultProps = defaultProps;
13
8
  SwiperItem.displayName = "NutSwiperItem";
14
9
  export {
15
10
  SwiperItem as S
@@ -130,17 +130,18 @@ const Table = (props) => {
130
130
  });
131
131
  };
132
132
  const renderBodyTds = (item, rowIndex) => {
133
- const { rowRender } = item;
134
- if (rowRender && typeof rowRender === "function") {
135
- return rowRender(item, rowIndex);
136
- }
137
133
  return sortDataItem().map(([value, render]) => {
138
134
  return React__default.createElement("div", { className: classNames(`${bodyClassPrefix}-td`, cellClasses(getColumnItem(value)), getStickyClass(value)), key: value, style: getStickyStyle(value) }, typeof item[value] === "function" || typeof render === "function" ? React__default.createElement("div", null, render ? render(item, rowIndex) : item[value](item)) : item[value]);
139
135
  });
140
136
  };
141
137
  const renderBodyTrs = () => {
142
138
  return innerValue.map((item, index) => {
143
- return React__default.createElement("div", { className: bodyClassPrefix, key: index }, renderBodyTds(item, index));
139
+ const inner = renderBodyTds(item, index);
140
+ const { rowRender } = item;
141
+ if (rowRender && typeof rowRender === "function") {
142
+ return rowRender(item, index, { inner });
143
+ }
144
+ return React__default.createElement("div", { className: bodyClassPrefix, key: index }, inner);
144
145
  });
145
146
  };
146
147
  return React__default.createElement(
@@ -1,5 +1,5 @@
1
1
  import { _ as __rest } from "./tslib.es6-iWu3F_1J.js";
2
- import React__default, { useState, useImperativeHandle } from "react";
2
+ import React__default, { useState, useImperativeHandle, useRef, useEffect } from "react";
3
3
  import classNames from "classnames";
4
4
  import Taro, { uploadFile, getEnv, chooseMedia, chooseImage } from "@tarojs/taro";
5
5
  import { Failure, Link, Del, Loading, Photograph } from "@nutui/icons-react-taro";
@@ -225,6 +225,10 @@ const InternalUploader = (props, ref) => {
225
225
  clearUploadQueue();
226
226
  }
227
227
  }));
228
+ const fileListRef = useRef([]);
229
+ useEffect(() => {
230
+ fileListRef.current = fileList;
231
+ }, [fileList]);
228
232
  const clearUploadQueue = (index = -1) => {
229
233
  if (index > -1) {
230
234
  uploadQueue.splice(index, 1);
@@ -300,28 +304,28 @@ const InternalUploader = (props, ref) => {
300
304
  uploadOption.beforeXhrUpload = beforeXhrUpload;
301
305
  uploadOption.onStart = (option) => {
302
306
  clearUploadQueue(index);
303
- setFileList(fileList.map((item) => {
307
+ setFileList(fileListRef.current.map((item) => {
304
308
  if (item.uid === fileItem.uid) {
305
309
  item.status = "ready";
306
310
  item.message = locale.uploader.readyUpload;
307
311
  }
308
312
  return item;
309
313
  }));
310
- onStart && onStart(option);
314
+ onStart === null || onStart === void 0 ? void 0 : onStart(option);
311
315
  };
312
316
  uploadOption.onProgress = (e, option) => {
313
- setFileList(fileList.map((item) => {
317
+ setFileList(fileListRef.current.map((item) => {
314
318
  if (item.uid === fileItem.uid) {
315
319
  item.status = UPLOADING;
316
320
  item.message = locale.uploader.uploading;
317
321
  item.percentage = e.progress;
318
- onProgress && onProgress({ e, option, percentage: item.percentage });
322
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({ e, option, percentage: item.percentage });
319
323
  }
320
324
  return item;
321
325
  }));
322
326
  };
323
327
  uploadOption.onSuccess = (responseText, option) => {
324
- const list = fileList.map((item) => {
328
+ const list = fileListRef.current.map((item) => {
325
329
  if (item.uid === fileItem.uid) {
326
330
  item.status = SUCCESS;
327
331
  item.message = locale.uploader.success;
@@ -337,7 +341,7 @@ const InternalUploader = (props, ref) => {
337
341
  });
338
342
  };
339
343
  uploadOption.onFailure = (responseText, option) => {
340
- const list = fileList.map((item) => {
344
+ const list = fileListRef.current.map((item) => {
341
345
  if (item.uid === fileItem.uid) {
342
346
  item.status = ERROR;
343
347
  item.message = locale.uploader.error;
@@ -397,8 +401,8 @@ const InternalUploader = (props, ref) => {
397
401
  if (preview) {
398
402
  fileItem.url = fileType === "video" ? file.thumbTempFilePath : filepath;
399
403
  }
400
- setFileList([...fileList, fileItem]);
401
404
  executeUpload(fileItem, index);
405
+ setFileList([...fileList, fileItem]);
402
406
  });
403
407
  };
404
408
  const filterFiles = (files) => {
@@ -412,9 +416,7 @@ const InternalUploader = (props, ref) => {
412
416
  }
413
417
  return true;
414
418
  });
415
- if (oversizes.length) {
416
- onOversize && onOversize(files);
417
- }
419
+ oversizes.length && (onOversize === null || onOversize === void 0 ? void 0 : onOversize(files));
418
420
  const currentFileLength = filterFile.length + fileList.length;
419
421
  if (currentFileLength > maximum) {
420
422
  filterFile.splice(filterFile.length - (currentFileLength - maximum));
@@ -3,10 +3,10 @@ import { getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
3
3
  import classNames from "classnames";
4
4
  import { u as useConfig } from "./configprovider.taro-DA4GDDFu.js";
5
5
  import { C as ComponentDefaults } from "./typings-DV9RBfhj.js";
6
- const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { content: "", fullPage: true, zIndex: 2e3, gapX: 24, gapY: 48, width: 120, height: 64, image: "", imageWidth: 120, imageHeight: 64, rotate: -22, color: "rgba(0,0,0,.15)", fontStyle: "normal", fontWeight: "normal", fontSize: 14 });
6
+ const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { content: "", fullPage: true, zIndex: 2e3, gapX: 24, gapY: 48, width: 120, height: 64, startX: 0, startY: 0, image: "", imageWidth: 120, imageHeight: 64, rotate: -22, color: "rgba(0,0,0,.15)", fontStyle: "normal", fontWeight: "normal", fontSize: 14 });
7
7
  const WaterMark = (props) => {
8
8
  const { locale } = useConfig();
9
- const { content, fullPage, zIndex, className, gapX, gapY, width, height, image, imageWidth, imageHeight, rotate, color, fontStyle, fontFamily, fontWeight, fontSize, style } = Object.assign(Object.assign({}, defaultProps), props);
9
+ const { content, fullPage, zIndex, className, gapX, gapY, startX, startY, width, height, image, imageWidth, imageHeight, rotate, color, fontStyle, fontFamily, fontWeight, fontSize, style } = Object.assign(Object.assign({}, defaultProps), props);
10
10
  const [base64Url, setBase64Url] = useState("");
11
11
  const classPrefix = "nut-watermark";
12
12
  const classes = classNames(classPrefix, {
@@ -65,7 +65,7 @@ const WaterMark = (props) => {
65
65
  const markSize = Number(fontSize) * ratio;
66
66
  ctx.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
67
67
  ctx.fillStyle = color;
68
- ctx.fillText(content, 0, 0);
68
+ ctx.fillText(content, startX, startY);
69
69
  ctx.restore();
70
70
  setBase64Url(canvas.toDataURL());
71
71
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.14 Fri Jul 19 2024 16:24:05 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.15 Fri Jul 26 2024 15:19:03 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.14 Fri Jul 19 2024 16:24:05 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.15 Fri Jul 26 2024 15:19:03 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.14 Fri Jul 19 2024 16:24:05 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.15 Fri Jul 26 2024 15:19:03 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.14 Fri Jul 19 2024 16:24:05 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.15 Fri Jul 26 2024 15:19:03 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.14 Fri Jul 19 2024 16:24:05 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.15 Fri Jul 26 2024 15:19:03 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.14 Fri Jul 19 2024 16:24:05 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.15 Fri Jul 26 2024 15:19:03 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.14 Fri Jul 19 2024 16:24:05 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.15 Fri Jul 26 2024 15:19:03 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */