@nutui/nutui-react-taro 2.6.11 → 2.6.13

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 +17 -4
  2. package/dist/esm/Address/style/style.css +1 -1
  3. package/dist/esm/AvatarCropper.js +1 -1
  4. package/dist/esm/Calendar.js +1 -1
  5. package/dist/esm/CalendarItem.js +1 -1
  6. package/dist/esm/Cascader/style/style.css +1 -1
  7. package/dist/esm/Drag.js +1 -1
  8. package/dist/esm/ImagePreview.js +1 -1
  9. package/dist/esm/Tabs/style/style.css +1 -1
  10. package/dist/esm/Uploader.js +1 -1
  11. package/dist/esm/{avatarcropper.taro-R3OfWq1H.js → avatarcropper.taro-CAVcFvKC.js} +2 -0
  12. package/dist/esm/{calendar.taro-DN6uEJw-.js → calendar.taro-Bf5owfGd.js} +1 -1
  13. package/dist/esm/{calendaritem.taro-CiGznRkW.js → calendaritem.taro-PLHReAvU.js} +2 -0
  14. package/dist/esm/{drag.taro-CI7ZFwaM.js → drag.taro-B_TO4Nnu.js} +8 -2
  15. package/dist/esm/{imagepreview.taro-B7eJN5Hn.js → imagepreview.taro-DtgQJEQ_.js} +16 -9
  16. package/dist/esm/nutui-react.es.js +6 -6
  17. package/dist/esm/{uploader.taro-E6R-Ow7M.js → uploader.taro-CiamsRGo.js} +3 -5
  18. package/dist/locales/base.js +1 -1
  19. package/dist/locales/en-US.js +1 -1
  20. package/dist/locales/id-ID.js +1 -1
  21. package/dist/locales/tr-TR.js +1 -1
  22. package/dist/locales/zh-CN.js +1 -1
  23. package/dist/locales/zh-TW.js +1 -1
  24. package/dist/locales/zh-UG.js +1 -1
  25. package/dist/nutui.react.es.js +55 -17
  26. package/dist/nutui.react.umd.js +55 -17
  27. package/dist/packages/tabs/tabs.scss +1 -0
  28. package/dist/style.css +1 -1
  29. package/dist/types/packages/drag/drag.d.ts +6 -0
  30. package/dist/types/packages/drag/drag.taro.d.ts +16 -0
  31. package/dist/types/packages/form/usewatch.d.ts +2 -0
  32. package/dist/types/packages/formitem/types.d.ts +1 -1
  33. package/dist/types/packages/imagepreview/imagepreview.d.ts +1 -0
  34. package/dist/types/packages/imagepreview/imagepreview.taro.d.ts +5 -0
  35. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react-taro v2.6.11 Fri Jun 28 2024 14:38:04 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react-taro v2.6.13 Fri Jul 12 2024 13:57:50 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -3385,6 +3385,19 @@ function getScrollParent(el, root2 = defaultRoot) {
3385
3385
  }
3386
3386
  return root2;
3387
3387
  }
3388
+ let passiveSupported = false;
3389
+ if (canUseDom) {
3390
+ try {
3391
+ const opts = Object.defineProperty({}, "passive", {
3392
+ get() {
3393
+ passiveSupported = true;
3394
+ }
3395
+ });
3396
+ window.addEventListener("test-passive-supported", null, opts);
3397
+ } catch (e2) {
3398
+ console.log(e2);
3399
+ }
3400
+ }
3388
3401
  let totalLockCount = 0;
3389
3402
  const BODY_LOCK_CLASS = "nut-overflow-hidden";
3390
3403
  function getScrollableElement(el) {
@@ -3432,7 +3445,7 @@ function useLockScroll(rootRef, shouldLock) {
3432
3445
  document.addEventListener(
3433
3446
  "touchmove",
3434
3447
  onTouchMove,
3435
- false
3448
+ passiveSupported ? { passive: false } : false
3436
3449
  );
3437
3450
  if (!totalLockCount) {
3438
3451
  document.body.classList.add(BODY_LOCK_CLASS);
@@ -6762,6 +6775,7 @@ const CalendarItem = React__default.forwardRef((props, ref) => {
6762
6775
  const scrollTop2 = e2.target.scrollTop;
6763
6776
  Taro.getEnv() === "WEB" && setScrollTop(scrollTop2);
6764
6777
  let current = Math.floor(scrollTop2 / avgHeight);
6778
+ if (current < 0) return;
6765
6779
  if (!monthsData[current + 1]) return;
6766
6780
  const nextTop = monthsData[current + 1].scrollTop;
6767
6781
  const nextHeight = monthsData[current + 1].cssHeight;
@@ -7963,7 +7977,7 @@ const InternalPickerPanel = (props, ref) => {
7963
7977
  moving: moving.current
7964
7978
  }));
7965
7979
  useEffect(() => {
7966
- const eventOptions = false;
7980
+ const eventOptions = passiveSupported ? { passive: false, once: true } : false;
7967
7981
  const element = pickerPanelRef.current;
7968
7982
  element.addEventListener("touchstart", touchStart, eventOptions);
7969
7983
  element.addEventListener("touchmove", touchMove, eventOptions);
@@ -12874,8 +12888,7 @@ const InternalUploader = (props, ref) => {
12874
12888
  setUploadQueue(uploadQueue);
12875
12889
  } else {
12876
12890
  setUploadQueue([]);
12877
- fileList.splice(0, fileList.length);
12878
- setFileList([...fileList]);
12891
+ setFileList([]);
12879
12892
  }
12880
12893
  };
12881
12894
  const _chooseImage = () => {
@@ -12898,7 +12911,7 @@ const InternalUploader = (props, ref) => {
12898
12911
  document.body.appendChild(obj);
12899
12912
  }
12900
12913
  }
12901
- if (getEnv() === "WEAPP" && chooseMedia) {
12914
+ if ((getEnv() === "WEAPP" || getEnv() === "JD") && chooseMedia) {
12902
12915
  chooseMedia({
12903
12916
  /** 最多可以选择的文件个数 */
12904
12917
  count: multiple ? maxCount * 1 - fileList.length : 1,
@@ -13050,8 +13063,7 @@ const InternalUploader = (props, ref) => {
13050
13063
  if (preview) {
13051
13064
  fileItem.url = fileType === "video" ? file.thumbTempFilePath : filepath;
13052
13065
  }
13053
- fileList.push(fileItem);
13054
- setFileList(fileList);
13066
+ setFileList([...fileList, fileItem]);
13055
13067
  executeUpload(fileItem, index);
13056
13068
  });
13057
13069
  };
@@ -13498,7 +13510,18 @@ const defaultProps$F = {
13498
13510
  className: "myDrag"
13499
13511
  };
13500
13512
  const Drag = (props) => {
13501
- const { attract, direction, boundary, children, className, style, ...reset } = {
13513
+ const {
13514
+ attract,
13515
+ direction,
13516
+ boundary,
13517
+ onDrag,
13518
+ onDragStart,
13519
+ onDragEnd,
13520
+ children,
13521
+ className,
13522
+ style,
13523
+ ...reset
13524
+ } = {
13502
13525
  ...defaultProps$F,
13503
13526
  ...props
13504
13527
  };
@@ -13533,7 +13556,7 @@ const Drag = (props) => {
13533
13556
  }
13534
13557
  };
13535
13558
  const touchStart = (e2) => {
13536
- e2.currentTarget;
13559
+ onDragStart == null ? void 0 : onDragStart();
13537
13560
  const touches = e2.touches[0];
13538
13561
  axisCache.current = { x: touches.clientX, y: touches.clientY };
13539
13562
  transformCache.current = { x: translateX.current, y: translateY.current };
@@ -13545,6 +13568,9 @@ const Drag = (props) => {
13545
13568
  const y = touch.clientY - axisCache.current.y;
13546
13569
  translateX.current = x + transformCache.current.x;
13547
13570
  translateY.current = y + transformCache.current.y;
13571
+ onDrag == null ? void 0 : onDrag({
13572
+ offset: [translateX.current, translateY.current]
13573
+ });
13548
13574
  if (translateX.current < boundaryState.left) {
13549
13575
  translateX.current = boundaryState.left;
13550
13576
  } else if (translateX.current > boundaryState.right) {
@@ -13560,6 +13586,9 @@ const Drag = (props) => {
13560
13586
  }
13561
13587
  };
13562
13588
  const touchEnd = (e2) => {
13589
+ onDragEnd == null ? void 0 : onDragEnd({
13590
+ offset: [translateX.current, translateY.current]
13591
+ });
13563
13592
  if (direction !== "y" && attract && dragRef.current) {
13564
13593
  if (translateX.current < middleLine.current) {
13565
13594
  translateX.current = boundaryState.left;
@@ -16794,6 +16823,7 @@ const defaultProps$g = {
16794
16823
  autoPlay: false,
16795
16824
  defaultValue: 1,
16796
16825
  closeOnContentClick: false,
16826
+ pagination: true,
16797
16827
  indicator: false,
16798
16828
  indicatorColor: "#fff",
16799
16829
  closeIcon: false,
@@ -16814,6 +16844,7 @@ const ImagePreview = (props) => {
16814
16844
  visible,
16815
16845
  defaultValue,
16816
16846
  indicatorColor,
16847
+ pagination,
16817
16848
  indicator,
16818
16849
  autoPlay,
16819
16850
  closeOnContentClick,
@@ -16975,7 +17006,6 @@ const ImagePreview = (props) => {
16975
17006
  className: classNames(classPrefix2, className),
16976
17007
  style,
16977
17008
  ref,
16978
- onClick: closeOnImg,
16979
17009
  onTouchStart
16980
17010
  },
16981
17011
  /* @__PURE__ */ React__default.createElement(
@@ -17007,6 +17037,7 @@ const ImagePreview = (props) => {
17007
17037
  Video$1,
17008
17038
  {
17009
17039
  src: item.source.src,
17040
+ onClick: closeOnImg,
17010
17041
  controls: item.options.controls,
17011
17042
  autoplay: false,
17012
17043
  loop: false,
@@ -17022,20 +17053,26 @@ const ImagePreview = (props) => {
17022
17053
  key: index,
17023
17054
  className: "nut-imagepreview-swiper-item"
17024
17055
  },
17025
- Taro.getEnv() === "WEB" ? /* @__PURE__ */ React__default.createElement(Image$1, { src: item.src, mode: "aspectFit" }) : /* @__PURE__ */ React__default.createElement(
17026
- Image$1,
17056
+ "(",
17057
+ /* @__PURE__ */ React__default.createElement(
17058
+ Image$2,
17027
17059
  {
17028
17060
  src: item.src,
17029
- mode: "aspectFit",
17030
- showMenuByLongpress: !!showMenuByLongpress
17061
+ mode: "widthFix",
17062
+ onClick: closeOnImg,
17063
+ style: { width: "100%" },
17064
+ ...Taro.getEnv() !== "WEB" && {
17065
+ showMenuByLongpress
17066
+ }
17031
17067
  }
17032
- )
17068
+ ),
17069
+ ")"
17033
17070
  );
17034
17071
  }) : []
17035
17072
  )
17036
17073
  )
17037
17074
  ),
17038
- /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-index` }, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)),
17075
+ pagination ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-index` }, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)) : null,
17039
17076
  closeIcon !== false ? /* @__PURE__ */ React__default.createElement(
17040
17077
  "div",
17041
17078
  {
@@ -18861,6 +18898,7 @@ const AvatarCropper = (props) => {
18861
18898
  if ((canvasDom == null ? void 0 : canvasDom.tagName) !== "CANVAS") {
18862
18899
  canvas = canvasDom == null ? void 0 : canvasDom.getElementsByTagName("canvas")[0];
18863
18900
  }
18901
+ if (!canvas) return;
18864
18902
  canvas.width = state.displayWidth;
18865
18903
  canvas.height = state.displayHeight;
18866
18904
  const ctx = canvas.getContext("2d");
@@ -2,7 +2,7 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@tarojs/taro"), require("@tarojs/components"), require("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react", "@tarojs/taro", "@tarojs/components", "react-dom"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory((global2.nutui = global2.nutui || {}, global2.nutui.react = {}), global2.React, global2.Taro, global2.components, global2.ReactDOM));
3
3
  })(this, function(exports2, React, Taro, components, ReactDOM) {
4
4
  "use strict";/*!
5
- * @nutui/nutui-react-taro v2.6.11 Fri Jun 28 2024 14:38:04 GMT+0800 (China Standard Time)
5
+ * @nutui/nutui-react-taro v2.6.13 Fri Jul 12 2024 13:57:50 GMT+0800 (China Standard Time)
6
6
  * (c) 2023 @jdf2e.
7
7
  * Released under the MIT License.
8
8
  */
@@ -3401,6 +3401,19 @@
3401
3401
  }
3402
3402
  return root2;
3403
3403
  }
3404
+ let passiveSupported = false;
3405
+ if (canUseDom) {
3406
+ try {
3407
+ const opts = Object.defineProperty({}, "passive", {
3408
+ get() {
3409
+ passiveSupported = true;
3410
+ }
3411
+ });
3412
+ window.addEventListener("test-passive-supported", null, opts);
3413
+ } catch (e2) {
3414
+ console.log(e2);
3415
+ }
3416
+ }
3404
3417
  let totalLockCount = 0;
3405
3418
  const BODY_LOCK_CLASS = "nut-overflow-hidden";
3406
3419
  function getScrollableElement(el) {
@@ -3448,7 +3461,7 @@
3448
3461
  document.addEventListener(
3449
3462
  "touchmove",
3450
3463
  onTouchMove,
3451
- false
3464
+ passiveSupported ? { passive: false } : false
3452
3465
  );
3453
3466
  if (!totalLockCount) {
3454
3467
  document.body.classList.add(BODY_LOCK_CLASS);
@@ -6778,6 +6791,7 @@
6778
6791
  const scrollTop2 = e2.target.scrollTop;
6779
6792
  Taro.getEnv() === "WEB" && setScrollTop(scrollTop2);
6780
6793
  let current = Math.floor(scrollTop2 / avgHeight);
6794
+ if (current < 0) return;
6781
6795
  if (!monthsData[current + 1]) return;
6782
6796
  const nextTop = monthsData[current + 1].scrollTop;
6783
6797
  const nextHeight = monthsData[current + 1].cssHeight;
@@ -7979,7 +7993,7 @@
7979
7993
  moving: moving.current
7980
7994
  }));
7981
7995
  React.useEffect(() => {
7982
- const eventOptions = false;
7996
+ const eventOptions = passiveSupported ? { passive: false, once: true } : false;
7983
7997
  const element = pickerPanelRef.current;
7984
7998
  element.addEventListener("touchstart", touchStart, eventOptions);
7985
7999
  element.addEventListener("touchmove", touchMove, eventOptions);
@@ -12890,8 +12904,7 @@
12890
12904
  setUploadQueue(uploadQueue);
12891
12905
  } else {
12892
12906
  setUploadQueue([]);
12893
- fileList.splice(0, fileList.length);
12894
- setFileList([...fileList]);
12907
+ setFileList([]);
12895
12908
  }
12896
12909
  };
12897
12910
  const _chooseImage = () => {
@@ -12914,7 +12927,7 @@
12914
12927
  document.body.appendChild(obj);
12915
12928
  }
12916
12929
  }
12917
- if (Taro.getEnv() === "WEAPP" && Taro.chooseMedia) {
12930
+ if ((Taro.getEnv() === "WEAPP" || Taro.getEnv() === "JD") && Taro.chooseMedia) {
12918
12931
  Taro.chooseMedia({
12919
12932
  /** 最多可以选择的文件个数 */
12920
12933
  count: multiple ? maxCount * 1 - fileList.length : 1,
@@ -13066,8 +13079,7 @@
13066
13079
  if (preview) {
13067
13080
  fileItem.url = fileType === "video" ? file.thumbTempFilePath : filepath;
13068
13081
  }
13069
- fileList.push(fileItem);
13070
- setFileList(fileList);
13082
+ setFileList([...fileList, fileItem]);
13071
13083
  executeUpload(fileItem, index);
13072
13084
  });
13073
13085
  };
@@ -13514,7 +13526,18 @@
13514
13526
  className: "myDrag"
13515
13527
  };
13516
13528
  const Drag = (props) => {
13517
- const { attract, direction, boundary, children, className, style, ...reset } = {
13529
+ const {
13530
+ attract,
13531
+ direction,
13532
+ boundary,
13533
+ onDrag,
13534
+ onDragStart,
13535
+ onDragEnd,
13536
+ children,
13537
+ className,
13538
+ style,
13539
+ ...reset
13540
+ } = {
13518
13541
  ...defaultProps$F,
13519
13542
  ...props
13520
13543
  };
@@ -13549,7 +13572,7 @@
13549
13572
  }
13550
13573
  };
13551
13574
  const touchStart = (e2) => {
13552
- e2.currentTarget;
13575
+ onDragStart == null ? void 0 : onDragStart();
13553
13576
  const touches = e2.touches[0];
13554
13577
  axisCache.current = { x: touches.clientX, y: touches.clientY };
13555
13578
  transformCache.current = { x: translateX.current, y: translateY.current };
@@ -13561,6 +13584,9 @@
13561
13584
  const y = touch.clientY - axisCache.current.y;
13562
13585
  translateX.current = x + transformCache.current.x;
13563
13586
  translateY.current = y + transformCache.current.y;
13587
+ onDrag == null ? void 0 : onDrag({
13588
+ offset: [translateX.current, translateY.current]
13589
+ });
13564
13590
  if (translateX.current < boundaryState.left) {
13565
13591
  translateX.current = boundaryState.left;
13566
13592
  } else if (translateX.current > boundaryState.right) {
@@ -13576,6 +13602,9 @@
13576
13602
  }
13577
13603
  };
13578
13604
  const touchEnd = (e2) => {
13605
+ onDragEnd == null ? void 0 : onDragEnd({
13606
+ offset: [translateX.current, translateY.current]
13607
+ });
13579
13608
  if (direction !== "y" && attract && dragRef.current) {
13580
13609
  if (translateX.current < middleLine.current) {
13581
13610
  translateX.current = boundaryState.left;
@@ -16810,6 +16839,7 @@
16810
16839
  autoPlay: false,
16811
16840
  defaultValue: 1,
16812
16841
  closeOnContentClick: false,
16842
+ pagination: true,
16813
16843
  indicator: false,
16814
16844
  indicatorColor: "#fff",
16815
16845
  closeIcon: false,
@@ -16830,6 +16860,7 @@
16830
16860
  visible,
16831
16861
  defaultValue,
16832
16862
  indicatorColor,
16863
+ pagination,
16833
16864
  indicator,
16834
16865
  autoPlay,
16835
16866
  closeOnContentClick,
@@ -16991,7 +17022,6 @@
16991
17022
  className: classNames(classPrefix2, className),
16992
17023
  style,
16993
17024
  ref,
16994
- onClick: closeOnImg,
16995
17025
  onTouchStart
16996
17026
  },
16997
17027
  /* @__PURE__ */ React.createElement(
@@ -17023,6 +17053,7 @@
17023
17053
  components.Video,
17024
17054
  {
17025
17055
  src: item.source.src,
17056
+ onClick: closeOnImg,
17026
17057
  controls: item.options.controls,
17027
17058
  autoplay: false,
17028
17059
  loop: false,
@@ -17038,20 +17069,26 @@
17038
17069
  key: index,
17039
17070
  className: "nut-imagepreview-swiper-item"
17040
17071
  },
17041
- Taro.getEnv() === "WEB" ? /* @__PURE__ */ React.createElement(Image$1, { src: item.src, mode: "aspectFit" }) : /* @__PURE__ */ React.createElement(
17042
- Image$1,
17072
+ "(",
17073
+ /* @__PURE__ */ React.createElement(
17074
+ components.Image,
17043
17075
  {
17044
17076
  src: item.src,
17045
- mode: "aspectFit",
17046
- showMenuByLongpress: !!showMenuByLongpress
17077
+ mode: "widthFix",
17078
+ onClick: closeOnImg,
17079
+ style: { width: "100%" },
17080
+ ...Taro.getEnv() !== "WEB" && {
17081
+ showMenuByLongpress
17082
+ }
17047
17083
  }
17048
- )
17084
+ ),
17085
+ ")"
17049
17086
  );
17050
17087
  }) : []
17051
17088
  )
17052
17089
  )
17053
17090
  ),
17054
- /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-index` }, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)),
17091
+ pagination ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-index` }, active, "/", (images ? images.length : 0) + (videos ? videos.length : 0)) : null,
17055
17092
  closeIcon !== false ? /* @__PURE__ */ React.createElement(
17056
17093
  "div",
17057
17094
  {
@@ -18877,6 +18914,7 @@
18877
18914
  if ((canvasDom == null ? void 0 : canvasDom.tagName) !== "CANVAS") {
18878
18915
  canvas = canvasDom == null ? void 0 : canvasDom.getElementsByTagName("canvas")[0];
18879
18916
  }
18917
+ if (!canvas) return;
18880
18918
  canvas.width = state.displayWidth;
18881
18919
  canvas.height = state.displayHeight;
18882
18920
  const ctx = canvas.getContext("2d");
@@ -11,6 +11,7 @@
11
11
  user-select: none;
12
12
  overflow: hidden;
13
13
  background: $tabs-titles-background-color;
14
+ scrollbar-width: none;
14
15
 
15
16
  &::-webkit-scrollbar {
16
17
  display: none;