@nutui/nutui-react 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.
@@ -2,7 +2,7 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react-dom")) : typeof define === "function" && define.amd ? define(["exports", "react", "react-dom"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.nutui = {}, global2.React, global2.ReactDOM));
3
3
  })(this, function(exports2, React, ReactDOM) {
4
4
  "use strict";/*!
5
- * @nutui/nutui-react v2.6.14 Fri Jul 19 2024 16:21:28 GMT+0800 (China Standard Time)
5
+ * @nutui/nutui-react v2.6.15 Fri Jul 26 2024 15:20:57 GMT+0800 (China Standard Time)
6
6
  * (c) 2023 @jdf2e.
7
7
  * Released under the MIT License.
8
8
  */
@@ -3150,13 +3150,14 @@
3150
3150
  }, []);
3151
3151
  React.useEffect(() => {
3152
3152
  if (position === "top") return;
3153
- const containerEle = container == null ? void 0 : container.current;
3154
- if (!rootRef.current && !containerEle) return;
3155
- const rootRect = getRect(rootRef.current);
3153
+ const containerEle = container && container.current;
3154
+ const rootEle = rootRef.current;
3155
+ const stickyEle = stickyRef.current;
3156
+ if (!rootEle && !containerEle) return;
3157
+ const rootRect = getRect(rootEle);
3156
3158
  const containerRect = getRect(containerEle);
3157
3159
  const clientHeight = document.documentElement.clientHeight;
3158
- const stCurrent = stickyRef.current;
3159
- const stickyRect = getRect(stCurrent);
3160
+ const stickyRect = getRect(stickyEle);
3160
3161
  let fixed = clientHeight - threshold < rootRect.bottom;
3161
3162
  if (containerEle) {
3162
3163
  fixed = containerRect.bottom > clientHeight - threshold - stickyRect.height && clientHeight - threshold - stickyRect.height > containerRect.top;
@@ -3171,19 +3172,18 @@
3171
3172
  setIsFixed(fixed);
3172
3173
  }, [position, container, threshold]);
3173
3174
  const handleScroll = React.useCallback(() => {
3174
- const containerEle = container == null ? void 0 : container.current;
3175
- if (!rootRef.current && !containerEle) return;
3176
- const rootRect = getRect(rootRef.current);
3177
- const stCurrent = stickyRef.current;
3178
- const stickyRect = getRect(stCurrent);
3175
+ const containerEle = container && container.current;
3176
+ const rootEle = rootRef.current;
3177
+ const stickyEle = stickyRef.current;
3178
+ if (!rootEle && !containerEle) return;
3179
+ const rootRect = getRect(rootEle);
3180
+ const stickyRect = getRect(stickyEle);
3179
3181
  const containerRect = getRect(containerEle);
3180
3182
  if (rootRect.height) {
3181
- setRootStyle((prev) => {
3182
- return {
3183
- ...prev,
3184
- height: rootRect.height
3185
- };
3186
- });
3183
+ setRootStyle((prev) => ({
3184
+ ...prev,
3185
+ height: rootRect.height
3186
+ }));
3187
3187
  }
3188
3188
  const getFixed = () => {
3189
3189
  let fixed2 = false;
@@ -3199,22 +3199,16 @@
3199
3199
  };
3200
3200
  };
3201
3201
  const getTransform = () => {
3202
- if (position === "top") {
3203
- if (containerEle) {
3204
- const diff = containerRect.bottom - threshold - stickyRect.height;
3205
- const transform = diff < 0 ? diff : 0;
3206
- return { transform: `translate3d(0, ${transform}px, 0)` };
3207
- }
3208
- return {};
3202
+ if (position === "top" && containerEle) {
3203
+ const diff = containerRect.bottom - threshold - stickyRect.height;
3204
+ const transform = diff < 0 ? diff : 0;
3205
+ return { transform: `translate3d(0, ${transform}px, 0)` };
3209
3206
  }
3210
- if (position === "bottom") {
3211
- if (containerEle) {
3212
- const clientHeight = document.documentElement.clientHeight;
3213
- const diff = containerRect.bottom - (clientHeight - threshold);
3214
- const transform = diff < 0 ? diff : 0;
3215
- return { transform: `translate3d(0, ${transform}px, 0)` };
3216
- }
3217
- return {};
3207
+ if (position === "bottom" && containerEle) {
3208
+ const clientHeight = document.documentElement.clientHeight;
3209
+ const diff = containerRect.bottom - (clientHeight - threshold);
3210
+ const transform = diff < 0 ? diff : 0;
3211
+ return { transform: `translate3d(0, ${transform}px, 0)` };
3218
3212
  }
3219
3213
  return {};
3220
3214
  };
@@ -3233,9 +3227,9 @@
3233
3227
  });
3234
3228
  React.useEffect(() => {
3235
3229
  const el = getElement();
3236
- el.addEventListener("scroll", handleScroll, false);
3230
+ el == null ? void 0 : el.addEventListener("scroll", handleScroll, false);
3237
3231
  return () => {
3238
- el.removeEventListener("scroll", handleScroll);
3232
+ el == null ? void 0 : el.removeEventListener("scroll", handleScroll);
3239
3233
  };
3240
3234
  }, [getElement, handleScroll]);
3241
3235
  return /* @__PURE__ */ React.createElement(
@@ -10698,8 +10692,10 @@
10698
10692
  };
10699
10693
  React.useEffect(() => {
10700
10694
  setCurrentDate(resetDefaultValue() || []);
10701
- popup && resetRender();
10702
10695
  }, [defaultValue]);
10696
+ React.useEffect(() => {
10697
+ popup && resetRender();
10698
+ }, [currentDate]);
10703
10699
  const scrollToDate = (date) => {
10704
10700
  if (Utils.compareDate(date, propStartDate)) {
10705
10701
  date = propStartDate;
@@ -11534,15 +11530,15 @@
11534
11530
  className,
11535
11531
  disabled,
11536
11532
  list,
11537
- onChange,
11538
11533
  value,
11539
11534
  defaultValue,
11540
11535
  max,
11541
11536
  min,
11542
- onLimit,
11543
11537
  labelPosition,
11544
11538
  direction,
11545
11539
  options: options2,
11540
+ onChange,
11541
+ onLimit,
11546
11542
  ...rest
11547
11543
  } = { ...defaultProps$_, ...props };
11548
11544
  React.useImperativeHandle(ref, () => ({
@@ -11571,8 +11567,8 @@
11571
11567
  }
11572
11568
  }));
11573
11569
  const [_value, setValue] = usePropsValue({
11574
- value: props.value,
11575
- defaultValue: props.defaultValue,
11570
+ value,
11571
+ defaultValue,
11576
11572
  finalValue: [],
11577
11573
  onChange
11578
11574
  });
@@ -11624,7 +11620,7 @@
11624
11620
  className: classNames(
11625
11621
  classPrefix$i,
11626
11622
  {
11627
- [`nut-checkboxgroup-${props.direction}`]: props.direction,
11623
+ [`nut-checkboxgroup-${direction}`]: direction,
11628
11624
  [`nut-checkboxgroup-list`]: list
11629
11625
  },
11630
11626
  className
@@ -11636,7 +11632,6 @@
11636
11632
  );
11637
11633
  }
11638
11634
  );
11639
- CheckboxGroup.defaultProps = defaultProps$_;
11640
11635
  CheckboxGroup.displayName = "NutCheckboxGroup";
11641
11636
  const defaultProps$Z = {
11642
11637
  ...ComponentDefaults,
@@ -12457,7 +12452,7 @@
12457
12452
  if (!isEqual2) {
12458
12453
  setSelectedDate(formatValue(newDate));
12459
12454
  }
12460
- props.onChange && props.onChange(
12455
+ onChange == null ? void 0 : onChange(
12461
12456
  selectedOptions,
12462
12457
  [
12463
12458
  String(newDate.getFullYear()),
@@ -12554,8 +12549,8 @@
12554
12549
  }
12555
12550
  pickerValue[columnIndex] = (_a = arr[index]) == null ? void 0 : _a.value;
12556
12551
  setPickerValue([...pickerValue]);
12557
- if (props.filter && props.filter(type22, arr)) {
12558
- return props.filter(type22, arr);
12552
+ if (filter == null ? void 0 : filter(type22, arr)) {
12553
+ return filter == null ? void 0 : filter(type22, arr);
12559
12554
  }
12560
12555
  return arr;
12561
12556
  };
@@ -12613,7 +12608,6 @@
12613
12608
  }
12614
12609
  ));
12615
12610
  };
12616
- DatePicker.defaultProps = defaultProps$X;
12617
12611
  DatePicker.displayName = "NutDatePicker";
12618
12612
  const Context = React.createContext({});
12619
12613
  function _extends() {
@@ -14856,14 +14850,10 @@
14856
14850
  return /* @__PURE__ */ React.createElement(
14857
14851
  "div",
14858
14852
  {
14859
- className: classNames(
14860
- "nut-menu-title ",
14861
- {
14862
- active: showMenuItem[index],
14863
- disabled
14864
- },
14865
- className
14866
- ),
14853
+ className: classNames("nut-menu-title", `nut-menu-title-${index}`, {
14854
+ active: showMenuItem[index],
14855
+ disabled
14856
+ }),
14867
14857
  style: { color: showMenuItem[index] ? activeColor : "" },
14868
14858
  key: index,
14869
14859
  onClick: (e2) => {
@@ -15140,7 +15130,6 @@
15140
15130
  );
15141
15131
  }
15142
15132
  );
15143
- RadioGroup.defaultProps = defaultProps$Q;
15144
15133
  RadioGroup.displayName = "NutRadioGroup";
15145
15134
  const defaultProps$P = {
15146
15135
  ...ComponentDefaults,
@@ -15268,7 +15257,6 @@
15268
15257
  renderRadioItem()
15269
15258
  );
15270
15259
  };
15271
- Radio.defaultProps = defaultProps$P;
15272
15260
  Radio.displayName = "NutRadio";
15273
15261
  Radio.Group = RadioGroup;
15274
15262
  const defaultProps$O = {
@@ -16647,6 +16635,7 @@
16647
16635
  };
16648
16636
  const InternalUploader = (props, ref) => {
16649
16637
  const { locale } = useConfig();
16638
+ const fileListRef = React.useRef([]);
16650
16639
  const {
16651
16640
  children,
16652
16641
  uploadIcon,
@@ -16699,6 +16688,9 @@
16699
16688
  });
16700
16689
  const [uploadQueue, setUploadQueue] = React.useState([]);
16701
16690
  const classes = classNames(className, "nut-uploader");
16691
+ React.useEffect(() => {
16692
+ fileListRef.current = fileList;
16693
+ }, [fileList]);
16702
16694
  React.useImperativeHandle(ref, () => ({
16703
16695
  submit: () => {
16704
16696
  Promise.all(uploadQueue).then((res) => {
@@ -16743,7 +16735,7 @@
16743
16735
  uploadOption.onStart = (option) => {
16744
16736
  clearUploadQueue(index);
16745
16737
  setFileList(
16746
- fileList.map((item) => {
16738
+ fileListRef.current.map((item) => {
16747
16739
  if (item.uid === fileItem.uid) {
16748
16740
  item.status = "ready";
16749
16741
  item.message = locale.uploader.readyUpload;
@@ -16751,23 +16743,23 @@
16751
16743
  return item;
16752
16744
  })
16753
16745
  );
16754
- onStart && onStart(option);
16746
+ onStart == null ? void 0 : onStart(option);
16755
16747
  };
16756
16748
  uploadOption.onProgress = (e2, option) => {
16757
16749
  setFileList(
16758
- fileList.map((item) => {
16750
+ fileListRef.current.map((item) => {
16759
16751
  if (item.uid === fileItem.uid) {
16760
16752
  item.status = UPLOADING;
16761
16753
  item.message = locale.uploader.uploading;
16762
16754
  item.percentage = (e2.loaded / e2.total * 100).toFixed(0);
16763
- onProgress && onProgress({ e: e2, option, percentage: item.percentage });
16755
+ onProgress == null ? void 0 : onProgress({ e: e2, option, percentage: item.percentage });
16764
16756
  }
16765
16757
  return item;
16766
16758
  })
16767
16759
  );
16768
16760
  };
16769
16761
  uploadOption.onSuccess = (responseText, option) => {
16770
- const list = fileList.map((item) => {
16762
+ const list = fileListRef.current.map((item) => {
16771
16763
  if (item.uid === fileItem.uid) {
16772
16764
  item.status = SUCCESS;
16773
16765
  item.message = locale.uploader.success;
@@ -16784,7 +16776,7 @@
16784
16776
  });
16785
16777
  };
16786
16778
  uploadOption.onFailure = (responseText, option) => {
16787
- const list = fileList.map((item) => {
16779
+ const list = fileListRef.current.map((item) => {
16788
16780
  if (item.uid === fileItem.uid) {
16789
16781
  item.status = ERROR;
16790
16782
  item.message = locale.uploader.error;
@@ -16846,9 +16838,7 @@
16846
16838
  }
16847
16839
  return true;
16848
16840
  });
16849
- if (oversizes.length) {
16850
- onOversize && onOversize(files);
16851
- }
16841
+ oversizes.length && (onOversize == null ? void 0 : onOversize(files));
16852
16842
  if (filterFile.length > maximum) {
16853
16843
  filterFile.splice(maximum, filterFile.length - maximum);
16854
16844
  }
@@ -16887,7 +16877,6 @@
16887
16877
  const _files = filterFiles(new Array().slice.call(files));
16888
16878
  readFile(_files);
16889
16879
  }
16890
- setFileList(fileList);
16891
16880
  if (clearInput) {
16892
16881
  clearInputValue($el);
16893
16882
  }
@@ -17212,18 +17201,6 @@
17212
17201
  );
17213
17202
  };
17214
17203
  Content.displayName = "NutContent";
17215
- const defaultDialogProps = {
17216
- ...ComponentDefaults,
17217
- overlay: true,
17218
- overlayStyle: {},
17219
- overlayClassName: "",
17220
- onCancel: () => {
17221
- },
17222
- onClose: () => {
17223
- },
17224
- onOverlayClick: (e2) => true,
17225
- ...defaultOverlayProps
17226
- };
17227
17204
  const DialogWrap = (props) => {
17228
17205
  const {
17229
17206
  visible,
@@ -17265,7 +17242,6 @@
17265
17242
  /* @__PURE__ */ React.createElement(Content, { ...props, visible })
17266
17243
  ));
17267
17244
  };
17268
- DialogWrap.defaultProps = defaultDialogProps;
17269
17245
  DialogWrap.displayName = "NutDialogWrap";
17270
17246
  const defaultProps$E = {
17271
17247
  ...ComponentDefaults,
@@ -18798,7 +18774,6 @@
18798
18774
  /* @__PURE__ */ React.createElement("div", null, renderStatusText())
18799
18775
  )), /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-content` }, props.children));
18800
18776
  };
18801
- PullToRefresh.defaultProps = defaultProps$x;
18802
18777
  PullToRefresh.displayName = "NutPullToRefresh";
18803
18778
  const AvatarContext = React.createContext({});
18804
18779
  const defaultProps$w = {
@@ -19182,7 +19157,6 @@
19182
19157
  /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-wrapper`, style: wrapperStyle }, renderActionContent("left", leftRef), children, renderActionContent("right", rightRef))
19183
19158
  );
19184
19159
  });
19185
- Swipe.defaultProps = defaultProps$t;
19186
19160
  Swipe.displayName = "NutSwipe";
19187
19161
  const classPrefix$8 = "nut-toast";
19188
19162
  class Notification extends React__namespace.PureComponent {
@@ -19582,16 +19556,16 @@
19582
19556
  percent: 0,
19583
19557
  duration: "00:00:00",
19584
19558
  second: 0,
19585
- hanMuted: props.muted,
19586
- playing: props.autoPlay,
19559
+ hanMuted: muted,
19560
+ playing: autoPlay,
19587
19561
  handPlaying: false
19588
19562
  });
19589
19563
  const classPrefix2 = "nut-audio";
19590
19564
  const handleEnded = (e2) => {
19591
- if (props.loop) {
19565
+ if (loop2) {
19592
19566
  console.warn(locale.audio.tips || "onPlayEnd事件在loop=false时才会触发");
19593
19567
  } else {
19594
- props.onEnd && props.onEnd(e2);
19568
+ onEnd == null ? void 0 : onEnd(e2);
19595
19569
  }
19596
19570
  };
19597
19571
  function watch() {
@@ -19632,25 +19606,25 @@
19632
19606
  if (statusRef.current.currentTime > 0 && AudioRef.current) {
19633
19607
  statusRef.current.currentTime--;
19634
19608
  AudioRef.current.currentTime = statusRef.current.currentTime;
19635
- props.onBack && props.onBack(AudioRef.current);
19609
+ onBack == null ? void 0 : onBack(AudioRef.current);
19636
19610
  }
19637
19611
  };
19638
19612
  const handleForward = () => {
19639
19613
  if (AudioRef.current) {
19640
19614
  statusRef.current.currentTime++;
19641
19615
  AudioRef.current.currentTime = statusRef.current.currentTime;
19642
- props.onForward && props.onForward(AudioRef.current);
19616
+ onForward == null ? void 0 : onForward(AudioRef.current);
19643
19617
  }
19644
19618
  };
19645
19619
  const handleMute = () => {
19646
19620
  if (AudioRef.current) {
19647
19621
  AudioRef.current.muted = !AudioRef.current.muted;
19648
- props.onMute && props.onMute(AudioRef.current);
19622
+ onMute == null ? void 0 : onMute(AudioRef.current);
19649
19623
  }
19650
19624
  };
19651
19625
  const handlePause = (e2) => {
19652
19626
  setPlaying(false);
19653
- props.onPause && props.onPause(e2);
19627
+ onPause == null ? void 0 : onPause(e2);
19654
19628
  };
19655
19629
  const formatSeconds = (value) => {
19656
19630
  if (!value) {
@@ -19739,12 +19713,12 @@
19739
19713
  };
19740
19714
  const handleCanplay = (e2) => {
19741
19715
  setIsCanPlay(true);
19742
- if (props.autoPlay && !playing) {
19716
+ if (autoPlay && !playing) {
19743
19717
  AudioRef && AudioRef.current && AudioRef.current.play();
19744
19718
  }
19745
19719
  if (AudioRef.current) {
19746
19720
  statusRef.current.second = AudioRef.current.duration || 0;
19747
- props.onCanPlay && props.onCanPlay(e2);
19721
+ onCanPlay == null ? void 0 : onCanPlay(e2);
19748
19722
  }
19749
19723
  };
19750
19724
  const onTimeupdate = (e2) => {
@@ -19773,7 +19747,6 @@
19773
19747
  /* @__PURE__ */ React.createElement("track", { kind: "captions" })
19774
19748
  ));
19775
19749
  };
19776
- Audio.defaultProps = defaultProps$p;
19777
19750
  Audio.displayName = "NutAudio";
19778
19751
  const defaultProps$o = {
19779
19752
  ...ComponentDefaults,
@@ -20969,7 +20942,6 @@
20969
20942
  );
20970
20943
  }
20971
20944
  );
20972
- Swiper.defaultProps = defaultProps$h;
20973
20945
  Swiper.displayName = "NutSwiper";
20974
20946
  const defaultProps$g = {
20975
20947
  onClick: (e2) => void 0
@@ -20980,7 +20952,6 @@
20980
20952
  const classes = classNames(classPrefix2, className);
20981
20953
  return /* @__PURE__ */ React.createElement("div", { className: classes, onClick: props.onClick, style }, children);
20982
20954
  };
20983
- SwiperItem.defaultProps = defaultProps$g;
20984
20955
  SwiperItem.displayName = "NutSwiperItem";
20985
20956
  const InnerSwiper = Swiper;
20986
20957
  InnerSwiper.Item = SwiperItem;
@@ -21676,10 +21647,6 @@
21676
21647
  });
21677
21648
  };
21678
21649
  const renderBodyTds = (item, rowIndex) => {
21679
- const { rowRender } = item;
21680
- if (rowRender && typeof rowRender === "function") {
21681
- return rowRender(item, rowIndex);
21682
- }
21683
21650
  return sortDataItem().map(([value, render2]) => {
21684
21651
  return /* @__PURE__ */ React.createElement(
21685
21652
  "div",
@@ -21698,7 +21665,12 @@
21698
21665
  };
21699
21666
  const renderBodyTrs = () => {
21700
21667
  return innerValue.map((item, index) => {
21701
- return /* @__PURE__ */ React.createElement("div", { className: bodyClassPrefix, key: index }, renderBodyTds(item, index));
21668
+ const inner = renderBodyTds(item, index);
21669
+ const { rowRender } = item;
21670
+ if (rowRender && typeof rowRender === "function") {
21671
+ return rowRender(item, index, { inner });
21672
+ }
21673
+ return /* @__PURE__ */ React.createElement("div", { className: bodyClassPrefix, key: index }, inner);
21702
21674
  });
21703
21675
  };
21704
21676
  return /* @__PURE__ */ React.createElement("div", { className: cls, ...rest }, /* @__PURE__ */ React.createElement(
@@ -22722,6 +22694,8 @@
22722
22694
  gapY: 48,
22723
22695
  width: 120,
22724
22696
  height: 64,
22697
+ startX: 0,
22698
+ startY: 0,
22725
22699
  image: "",
22726
22700
  imageWidth: 120,
22727
22701
  imageHeight: 64,
@@ -22740,6 +22714,8 @@
22740
22714
  className,
22741
22715
  gapX,
22742
22716
  gapY,
22717
+ startX,
22718
+ startY,
22743
22719
  width,
22744
22720
  height,
22745
22721
  image,
@@ -22802,7 +22778,7 @@
22802
22778
  const markSize = Number(fontSize) * ratio;
22803
22779
  ctx2.font = `${fontStyle} normal ${fontWeight} ${markSize}px/${markHeight}px ${fontFamily}`;
22804
22780
  ctx2.fillStyle = color;
22805
- ctx2.fillText(content, 0, 0);
22781
+ ctx2.fillText(content, startX, startY);
22806
22782
  ctx2.restore();
22807
22783
  setBase64Url(canvas.toDataURL());
22808
22784
  }
@@ -174,7 +174,9 @@
174
174
  }
175
175
 
176
176
  &-c {
177
- width: 100%;
177
+ display: flex;
178
+ justify-content: center;
179
+ align-items: center;
178
180
  height: 100%;
179
181
  position: initial;
180
182
  border-radius: $uploader-image-border-radius;