@nutui/nutui-react 2.6.20 → 2.6.22

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.19 Fri Sep 20 2024 13:46:38 GMT+0800 (China Standard Time)
5
+ * @nutui/nutui-react v2.6.22 Sat Oct 12 2024 14:58:54 GMT+0800 (China Standard Time)
6
6
  * (c) 2023 @jdf2e.
7
7
  * Released under the MIT License.
8
8
  */
@@ -653,7 +653,7 @@
653
653
  };
654
654
  const getStyle = React.useCallback(() => {
655
655
  const style2 = {};
656
- if (props.color) {
656
+ if (color) {
657
657
  if (props.fill === "outline" || props.fill === "dashed") {
658
658
  style2.color = color;
659
659
  if (!(color == null ? void 0 : color.includes("gradient"))) {
@@ -666,7 +666,7 @@
666
666
  }
667
667
  }
668
668
  return style2;
669
- }, [color]);
669
+ }, [color, props.fill]);
670
670
  const handleClick2 = (e) => {
671
671
  if (!loading && !disabled && onClick) {
672
672
  onClick(e);
@@ -1872,7 +1872,7 @@
1872
1872
  };
1873
1873
  const inBrowser = typeof window !== "undefined";
1874
1874
  function requestAniFrame() {
1875
- if (typeof window !== "undefined") {
1875
+ if (inBrowser) {
1876
1876
  const _window = window;
1877
1877
  return _window.requestAnimationFrame || _window.webkitRequestAnimationFrame || function(callback) {
1878
1878
  _window.setTimeout(callback, 1e3 / 60);
@@ -1882,6 +1882,14 @@
1882
1882
  setTimeout(callback, 1e3 / 60);
1883
1883
  };
1884
1884
  }
1885
+ function cancelRaf(id) {
1886
+ if (inBrowser) {
1887
+ const _window = window;
1888
+ (_window.cancelAnimationFrame || _window.webkitCancelAnimationFrame)(id);
1889
+ } else {
1890
+ clearTimeout(id);
1891
+ }
1892
+ }
1885
1893
  const requestAniFrame$1 = requestAniFrame();
1886
1894
  const classPrefix$p = "nut-configprovider";
1887
1895
  const defaultConfigRef$1 = {
@@ -2800,7 +2808,8 @@
2800
2808
  setInnerVisible(false);
2801
2809
  }
2802
2810
  }, [visible]);
2803
- useLockScroll(nodeRef, !!lockScroll && innerVisible);
2811
+ const shouldLockScroll = !innerVisible ? false : lockScroll;
2812
+ useLockScroll(nodeRef, shouldLockScroll);
2804
2813
  const classes = classNames(classPrefix2, className);
2805
2814
  const styles = {
2806
2815
  ...style
@@ -3354,31 +3363,36 @@
3354
3363
  const [scrollTop, SetScrollTop] = React.useState(0);
3355
3364
  let startTime = 0;
3356
3365
  const scrollEl = React.useRef(null);
3357
- React.useEffect(() => {
3358
- init();
3359
- return () => removeEventListener();
3360
- }, []);
3361
- const init = () => {
3366
+ const cls = classNames(classPrefix2, { show: backTop }, className);
3367
+ const scrollListener = React.useCallback(() => {
3368
+ var _a;
3369
+ let top = null;
3370
+ if (scrollEl.current instanceof Window) {
3371
+ top = scrollEl.current.scrollY;
3372
+ } else {
3373
+ top = (_a = scrollEl.current) == null ? void 0 : _a.scrollTop;
3374
+ }
3375
+ SetScrollTop(top);
3376
+ SetBackTop(top >= threshold);
3377
+ }, [threshold]);
3378
+ const init = React.useCallback(() => {
3379
+ var _a, _b;
3362
3380
  if (target && document.getElementById(target)) {
3363
3381
  scrollEl.current = document.getElementById(target);
3364
3382
  } else {
3365
3383
  scrollEl.current = window;
3366
3384
  }
3367
- addEventListener();
3368
- initCancelAniFrame();
3369
- };
3370
- const scrollListener = () => {
3371
- let top = null;
3372
- if (scrollEl.current instanceof Window) {
3373
- top = scrollEl.current.pageYOffset;
3374
- SetScrollTop(top);
3375
- } else {
3376
- top = scrollEl.current.scrollTop;
3377
- SetScrollTop(top);
3378
- }
3379
- const showBtn = top >= threshold;
3380
- SetBackTop(showBtn);
3381
- };
3385
+ (_a = scrollEl.current) == null ? void 0 : _a.addEventListener("scroll", scrollListener, false);
3386
+ (_b = scrollEl.current) == null ? void 0 : _b.addEventListener("resize", scrollListener, false);
3387
+ }, [target, scrollListener]);
3388
+ React.useEffect(() => {
3389
+ init();
3390
+ return () => {
3391
+ var _a, _b;
3392
+ (_a = scrollEl.current) == null ? void 0 : _a.removeEventListener("scroll", scrollListener, false);
3393
+ (_b = scrollEl.current) == null ? void 0 : _b.removeEventListener("resize", scrollListener, false);
3394
+ };
3395
+ }, [init, scrollListener]);
3382
3396
  const scroll = (y = 0) => {
3383
3397
  if (scrollEl.current instanceof Window) {
3384
3398
  window.scrollTo(0, y);
@@ -3394,27 +3408,13 @@
3394
3408
  scroll(y);
3395
3409
  cid = requestAniFrame$1(fn);
3396
3410
  if (t === duration || y === 0) {
3397
- window.cancelAnimationFrame(cid);
3411
+ cancelRaf(cid);
3398
3412
  }
3399
3413
  });
3400
3414
  };
3401
- const initCancelAniFrame = () => {
3402
- window.cancelAnimationFrame = window.webkitCancelAnimationFrame;
3403
- };
3404
- function addEventListener() {
3405
- var _a, _b;
3406
- (_a = scrollEl.current) == null ? void 0 : _a.addEventListener("scroll", scrollListener, false);
3407
- (_b = scrollEl.current) == null ? void 0 : _b.addEventListener("resize", scrollListener, false);
3408
- }
3409
- function removeEventListener() {
3410
- var _a, _b;
3411
- (_a = scrollEl.current) == null ? void 0 : _a.removeEventListener("scroll", scrollListener, false);
3412
- (_b = scrollEl.current) == null ? void 0 : _b.removeEventListener("resize", scrollListener, false);
3413
- }
3414
3415
  const goTop = (e) => {
3415
3416
  onClick && onClick(e);
3416
- const otime = +/* @__PURE__ */ new Date();
3417
- startTime = otime;
3417
+ startTime = +/* @__PURE__ */ new Date();
3418
3418
  duration > 0 ? scrollAnimation() : scroll();
3419
3419
  };
3420
3420
  const styles = Object.keys(style || {}).length !== 0 ? {
@@ -3425,23 +3425,7 @@
3425
3425
  bottom: "20px",
3426
3426
  zIndex
3427
3427
  };
3428
- return /* @__PURE__ */ React.createElement(
3429
- "div",
3430
- {
3431
- className: classNames(
3432
- classPrefix2,
3433
- {
3434
- show: backTop
3435
- },
3436
- className
3437
- ),
3438
- style: styles,
3439
- onClick: (e) => {
3440
- goTop(e);
3441
- }
3442
- },
3443
- children || /* @__PURE__ */ React.createElement(s$1, { width: 19, height: 19, className: "nut-backtop-main" })
3444
- );
3428
+ return /* @__PURE__ */ React.createElement("div", { className: cls, style: styles, onClick: (e) => goTop(e) }, children || /* @__PURE__ */ React.createElement(s$1, { width: 19, height: 19, className: "nut-backtop-main" }));
3445
3429
  };
3446
3430
  BackTop.displayName = "NutBackTop";
3447
3431
  function clamp$2(v, min, max) {
@@ -8644,11 +8628,10 @@
8644
8628
  };
8645
8629
  const classes = classNames({
8646
8630
  [`${classPrefix2}-fixed`]: fixed,
8647
- [`${classPrefix2}-safe-area-inset-top`]: safeAreaInsetTop,
8648
8631
  [`${classPrefix2}-title-align-${titleAlign}`]: true
8649
8632
  });
8650
8633
  const cls = classNames(classPrefix2, classes, className);
8651
- return /* @__PURE__ */ React.createElement(React.Fragment, null, fixed && placeholder ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-placeholder` }, renderWrapper()) : renderWrapper());
8634
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, safeAreaInsetTop && /* @__PURE__ */ React.createElement(SafeArea, { position: "top" }), fixed && placeholder ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-placeholder` }, renderWrapper()) : renderWrapper());
8652
8635
  };
8653
8636
  NavBar.displayName = "NutNavBar";
8654
8637
  const defaultProps$1e = {
@@ -8711,7 +8694,8 @@
8711
8694
  const [innerVisible, setInnerVisible] = React.useState(visible);
8712
8695
  const [showChildren, setShowChildren] = React.useState(true);
8713
8696
  const [transitionName, setTransitionName] = React.useState("");
8714
- useLockScroll(nodeRef, innerVisible && lockScroll);
8697
+ const shouldLockScroll = !innerVisible ? false : lockScroll;
8698
+ useLockScroll(nodeRef, shouldLockScroll);
8715
8699
  const classPrefix2 = "nut-popup";
8716
8700
  const baseStyle = {
8717
8701
  zIndex: index
@@ -14697,9 +14681,21 @@
14697
14681
  React.useEffect(() => {
14698
14682
  setShowPopup(show2);
14699
14683
  }, [show2]);
14684
+ const getParentOffset = React.useCallback(() => {
14685
+ setTimeout(() => {
14686
+ const p2 = parent.menuRef.current;
14687
+ if (p2) {
14688
+ const rect = p2.getBoundingClientRect();
14689
+ setPosition({
14690
+ height: rect.height,
14691
+ top: rect.top
14692
+ });
14693
+ }
14694
+ });
14695
+ }, [parent.menuRef]);
14700
14696
  React.useEffect(() => {
14701
14697
  getParentOffset();
14702
- }, [showPopup]);
14698
+ }, [showPopup, getParentOffset]);
14703
14699
  React.useImperativeHandle(ref, () => ({
14704
14700
  toggle: (s2) => {
14705
14701
  const from = "REF";
@@ -14733,18 +14729,6 @@
14733
14729
  const scrollParent = React.useMemo(() => {
14734
14730
  return getScrollParent(parent.menuRef, window);
14735
14731
  }, [parent.menuRef]);
14736
- const getParentOffset = () => {
14737
- setTimeout(() => {
14738
- const p2 = parent.menuRef.current;
14739
- if (p2) {
14740
- const rect = p2.getBoundingClientRect();
14741
- setPosition({
14742
- height: rect.height,
14743
- top: rect.top
14744
- });
14745
- }
14746
- });
14747
- };
14748
14732
  React.useEffect(() => {
14749
14733
  if (!parent.lockScroll) {
14750
14734
  scrollParent == null ? void 0 : scrollParent.addEventListener("scroll", getParentOffset, false);
@@ -14752,7 +14736,7 @@
14752
14736
  scrollParent == null ? void 0 : scrollParent.removeEventListener("scroll", getParentOffset, false);
14753
14737
  };
14754
14738
  }
14755
- }, []);
14739
+ }, [parent.lockScroll, scrollParent, getParentOffset]);
14756
14740
  const getPosition = () => {
14757
14741
  return direction === "down" ? {
14758
14742
  top: `${position.top + position.height}px`,
@@ -14883,24 +14867,29 @@
14883
14867
  ...props
14884
14868
  };
14885
14869
  const menuRef = React.useRef(null);
14870
+ const [showMenuItem, setShowMenuItem] = React.useState([]);
14871
+ const [menuItemTitle, setMenuItemTitle] = React.useState([]);
14886
14872
  const [isScrollFixed, setIsScrollFixed] = React.useState(false);
14873
+ const cls = classNames(`nut-menu`, className, {
14874
+ "scroll-fixed": isScrollFixed
14875
+ });
14887
14876
  const getScrollTop = (el) => {
14888
- return Math.max(0, "scrollTop" in el ? el.scrollTop : el.pageYOffset);
14877
+ return Math.max(
14878
+ 0,
14879
+ el === window ? window.scrollY : el.scrollTop
14880
+ );
14889
14881
  };
14890
- const onScroll = () => {
14891
- const { scrollFixed: scrollFixed2 } = props;
14882
+ const onScroll = React.useCallback(() => {
14892
14883
  const scrollTop = getScrollTop(window);
14893
- const isFixed = scrollTop > (typeof scrollFixed2 === "boolean" ? 30 : Number(scrollFixed2));
14884
+ const isFixed = scrollTop > (typeof scrollFixed === "boolean" ? 30 : Number(scrollFixed));
14894
14885
  setIsScrollFixed(isFixed);
14895
- };
14886
+ }, [scrollFixed]);
14896
14887
  React.useEffect(() => {
14897
14888
  if (scrollFixed) {
14898
14889
  window.addEventListener("scroll", onScroll);
14899
14890
  }
14900
14891
  return () => window.removeEventListener("scroll", onScroll);
14901
- }, []);
14902
- const [showMenuItem, setShowMenuItem] = React.useState([]);
14903
- const [menuItemTitle, setMenuItemTitle] = React.useState([]);
14892
+ }, [scrollFixed, onScroll]);
14904
14893
  const toggleMenuItem = (index, from = "NORMAL") => {
14905
14894
  showMenuItem[index] = !showMenuItem[index];
14906
14895
  if (showMenuItem[index]) {
@@ -15004,26 +14993,15 @@
15004
14993
  return null;
15005
14994
  });
15006
14995
  };
15007
- return /* @__PURE__ */ React.createElement(
14996
+ return /* @__PURE__ */ React.createElement("div", { ...rest, className: cls, ref: menuRef }, /* @__PURE__ */ React.createElement(
15008
14997
  "div",
15009
14998
  {
15010
- ...rest,
15011
- className: classNames(`nut-menu`, className, {
15012
- "scroll-fixed": isScrollFixed
15013
- }),
15014
- ref: menuRef
14999
+ className: classNames("nut-menu-bar", {
15000
+ opened: showMenuItem.includes(true)
15001
+ })
15015
15002
  },
15016
- /* @__PURE__ */ React.createElement(
15017
- "div",
15018
- {
15019
- className: classNames("nut-menu-bar", {
15020
- opened: showMenuItem.includes(true)
15021
- })
15022
- },
15023
- menuTitle()
15024
- ),
15025
- cloneChildren()
15026
- );
15003
+ menuTitle()
15004
+ ), cloneChildren());
15027
15005
  };
15028
15006
  Menu.displayName = "NutMenu";
15029
15007
  Menu.Item = MenuItem;
@@ -15220,6 +15198,13 @@
15220
15198
  disabled,
15221
15199
  ...rest
15222
15200
  } = { ...defaultProps$Q, ...props };
15201
+ const cls = classNames(
15202
+ classPrefix$f,
15203
+ {
15204
+ [`${classPrefix$f}-${props.direction}`]: props.direction
15205
+ },
15206
+ className
15207
+ );
15223
15208
  const [val2State, setVal2State] = usePropsValue({
15224
15209
  defaultValue: props.defaultValue,
15225
15210
  value: props.value,
@@ -15242,7 +15227,7 @@
15242
15227
  }
15243
15228
  );
15244
15229
  });
15245
- }, [options2]);
15230
+ }, [options2, labelPosition, val2State]);
15246
15231
  return /* @__PURE__ */ React.createElement(
15247
15232
  RadioContext.Provider,
15248
15233
  {
@@ -15259,20 +15244,7 @@
15259
15244
  }
15260
15245
  }
15261
15246
  },
15262
- /* @__PURE__ */ React.createElement(
15263
- "div",
15264
- {
15265
- className: classNames(
15266
- classPrefix$f,
15267
- {
15268
- [`${classPrefix$f}-${props.direction}`]: props.direction
15269
- },
15270
- className
15271
- ),
15272
- ...rest
15273
- },
15274
- (options2 == null ? void 0 : options2.length) ? renderOptionsChildren() : children
15275
- )
15247
+ /* @__PURE__ */ React.createElement("div", { className: cls, ...rest }, (options2 == null ? void 0 : options2.length) ? renderOptionsChildren() : children)
15276
15248
  );
15277
15249
  }
15278
15250
  );
@@ -15330,29 +15302,6 @@
15330
15302
  }
15331
15303
  };
15332
15304
  }
15333
- const renderLabel = () => {
15334
- return /* @__PURE__ */ React.createElement(
15335
- "div",
15336
- {
15337
- className: classNames(`${classPrefix2}-label`, {
15338
- [`${classPrefix2}-label-disabled`]: disabled
15339
- })
15340
- },
15341
- children
15342
- );
15343
- };
15344
- const renderButton = () => {
15345
- return /* @__PURE__ */ React.createElement(
15346
- "div",
15347
- {
15348
- className: classNames(`${classPrefix2}-button`, {
15349
- [`${classPrefix2}-button-active`]: checkedStatement,
15350
- [`${classPrefix2}-button-disabled`]: disabled
15351
- })
15352
- },
15353
- children
15354
- );
15355
- };
15356
15305
  const color = () => {
15357
15306
  return {
15358
15307
  [`${classPrefix2}-icon-disabled`]: disabled,
@@ -15376,8 +15325,21 @@
15376
15325
  className: classNames(color())
15377
15326
  }) : /* @__PURE__ */ React.createElement(i$6, { className: classNames(color()) });
15378
15327
  };
15328
+ const renderLabel = () => {
15329
+ const labelcls = classNames(`${classPrefix2}-label`, {
15330
+ [`${classPrefix2}-label-disabled`]: disabled
15331
+ });
15332
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, renderIcon(), /* @__PURE__ */ React.createElement("div", { className: labelcls }, children));
15333
+ };
15334
+ const renderButton = () => {
15335
+ const buttoncls = classNames(`${classPrefix2}-button`, {
15336
+ [`${classPrefix2}-button-active`]: checkedStatement,
15337
+ [`${classPrefix2}-button-disabled`]: disabled
15338
+ });
15339
+ return /* @__PURE__ */ React.createElement("div", { className: buttoncls }, children);
15340
+ };
15379
15341
  const renderByShape = (shape2) => {
15380
- return shape2 === "button" ? renderButton() : /* @__PURE__ */ React.createElement(React.Fragment, null, renderIcon(), renderLabel());
15342
+ return shape2 === "button" ? renderButton() : renderLabel();
15381
15343
  };
15382
15344
  const renderRadioItem = () => {
15383
15345
  return renderByShape(context && context.shape ? context.shape : shape);
@@ -15386,22 +15348,14 @@
15386
15348
  if (disabled || checkedStatement) return;
15387
15349
  setCheckedStatement(!checkedStatement);
15388
15350
  };
15389
- return /* @__PURE__ */ React.createElement(
15390
- "div",
15351
+ const cls = classNames(
15352
+ classPrefix2,
15391
15353
  {
15392
- className: classNames(
15393
- classPrefix2,
15394
- {
15395
- [`${classPrefix2}-reverse`]: labelPosition === "left"
15396
- },
15397
- className
15398
- ),
15399
- style,
15400
- onClick: handleClick2,
15401
- ...rest
15354
+ [`${classPrefix2}-reverse`]: labelPosition === "left"
15402
15355
  },
15403
- renderRadioItem()
15356
+ className
15404
15357
  );
15358
+ return /* @__PURE__ */ React.createElement("div", { className: cls, style, onClick: handleClick2, ...rest }, renderRadioItem());
15405
15359
  };
15406
15360
  Radio.displayName = "NutRadio";
15407
15361
  Radio.Group = RadioGroup;
@@ -15423,9 +15377,6 @@
15423
15377
  button,
15424
15378
  vertical,
15425
15379
  marks,
15426
- onChange,
15427
- onStart,
15428
- onEnd,
15429
15380
  minDescription,
15430
15381
  maxDescription,
15431
15382
  currentDescription,
@@ -15433,7 +15384,10 @@
15433
15384
  max,
15434
15385
  step,
15435
15386
  value,
15436
- defaultValue
15387
+ defaultValue,
15388
+ onChange,
15389
+ onStart,
15390
+ onEnd
15437
15391
  } = { ...defaultProps$O, ...props };
15438
15392
  const classPrefix2 = "nut-range";
15439
15393
  const [buttonIndex, setButtonIndex] = React.useState(0);
@@ -15451,7 +15405,7 @@
15451
15405
  finalValue: 0,
15452
15406
  onChange: handleChange
15453
15407
  });
15454
- const [exactValue, setEaxctValue] = React.useState(
15408
+ const [exactValue, setExactValue] = React.useState(
15455
15409
  () => value || defaultValue || 0
15456
15410
  );
15457
15411
  const marksRef = React.useRef({});
@@ -15469,10 +15423,7 @@
15469
15423
  setMarksList(list);
15470
15424
  }
15471
15425
  }
15472
- }, [marks]);
15473
- const scope = () => {
15474
- return max - min;
15475
- };
15426
+ }, [marks, max, min]);
15476
15427
  const classes = classNames(classPrefix2, {
15477
15428
  [`${classPrefix2}-disabled`]: disabled,
15478
15429
  [`${classPrefix2}-vertical`]: vertical
@@ -15484,41 +15435,38 @@
15484
15435
  },
15485
15436
  className
15486
15437
  );
15487
- const markClassName = React.useCallback(
15488
- (mark) => {
15489
- const classPrefix22 = "nut-range-mark";
15490
- let lowerBound = min;
15491
- let upperBound = max;
15492
- if (range2 && Array.isArray(current)) {
15493
- lowerBound = current[0];
15494
- upperBound = current[1];
15495
- } else {
15496
- upperBound = current;
15497
- }
15498
- const isActive = mark <= upperBound && mark >= lowerBound;
15499
- return [
15500
- `${classPrefix22}-text`,
15501
- `${isActive ? `${classPrefix22}-text-active` : ""}`
15502
- ].join(" ");
15503
- },
15504
- [range2, current, min, max]
15505
- );
15438
+ const markClassName = (mark) => {
15439
+ const classPrefix22 = "nut-range-mark";
15440
+ let lowerBound = min;
15441
+ let upperBound = max;
15442
+ if (range2 && Array.isArray(current)) {
15443
+ lowerBound = current[0];
15444
+ upperBound = current[1];
15445
+ } else {
15446
+ upperBound = current;
15447
+ }
15448
+ const isActive = mark <= upperBound && mark >= lowerBound;
15449
+ return [
15450
+ `${classPrefix22}-text`,
15451
+ `${isActive ? `${classPrefix22}-text-active` : ""}`
15452
+ ].join(" ");
15453
+ };
15506
15454
  const isRange = (val) => {
15507
15455
  return !!range2 && Array.isArray(val);
15508
15456
  };
15457
+ const scope = React.useMemo(() => {
15458
+ if (max < min || max === min) {
15459
+ console.log("max 的值需要大于 min的值");
15460
+ }
15461
+ return max - min;
15462
+ }, [max, min]);
15509
15463
  const calcMainAxis = () => {
15510
15464
  const modelVal = current;
15511
- if (isRange(modelVal)) {
15512
- return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
15513
- }
15514
- return `${(modelVal - min) * 100 / scope()}%`;
15465
+ return isRange(modelVal) ? `${(modelVal[1] - modelVal[0]) * 100 / scope}%` : `${(modelVal - min) * 100 / scope}%`;
15515
15466
  };
15516
15467
  const calcOffset = () => {
15517
15468
  const modelVal = current;
15518
- if (isRange(modelVal)) {
15519
- return `${(modelVal[0] - min) * 100 / scope()}%`;
15520
- }
15521
- return `0%`;
15469
+ return isRange(modelVal) ? `${(modelVal[0] - min) * 100 / scope}%` : `0%`;
15522
15470
  };
15523
15471
  const barStyle = () => {
15524
15472
  if (vertical) {
@@ -15538,11 +15486,11 @@
15538
15486
  const marksStyle = (mark) => {
15539
15487
  const dir = rtl ? "right" : "left";
15540
15488
  let style = {
15541
- [dir]: `${(mark - min) / scope() * 100}%`
15489
+ [dir]: `${(mark - min) / scope * 100}%`
15542
15490
  };
15543
15491
  if (vertical) {
15544
15492
  style = {
15545
- top: `${(mark - min) / scope() * 100}%`
15493
+ top: `${(mark - min) / scope * 100}%`
15546
15494
  };
15547
15495
  }
15548
15496
  return style;
@@ -15589,8 +15537,8 @@
15589
15537
  delta = event.clientY - rect.top;
15590
15538
  total = rect.height;
15591
15539
  }
15592
- const value2 = min + delta / total * scope();
15593
- setEaxctValue(current);
15540
+ const value2 = min + delta / total * scope;
15541
+ setExactValue(current);
15594
15542
  if (isRange(current)) {
15595
15543
  const [left, right] = current;
15596
15544
  const middle = (left + right) / 2;
@@ -15608,7 +15556,7 @@
15608
15556
  return;
15609
15557
  }
15610
15558
  touch.start(event);
15611
- setEaxctValue(current);
15559
+ setExactValue(current);
15612
15560
  if (isRange(current)) {
15613
15561
  setStartValue(current.map(format2));
15614
15562
  } else {
@@ -15629,12 +15577,12 @@
15629
15577
  const rect = getRect(root2.current);
15630
15578
  let delta = touch.deltaX.current;
15631
15579
  let total = rect.width;
15632
- let diff = delta / total * scope();
15580
+ let diff = delta / total * scope;
15633
15581
  diff = rtl ? -diff : diff;
15634
15582
  if (vertical) {
15635
15583
  delta = touch.deltaY.current;
15636
15584
  total = rect.height;
15637
- diff = delta / total * scope();
15585
+ diff = delta / total * scope;
15638
15586
  }
15639
15587
  let newValue;
15640
15588
  if (isRange(startValue)) {
@@ -15643,7 +15591,7 @@
15643
15591
  } else {
15644
15592
  newValue = startValue + diff;
15645
15593
  }
15646
- setEaxctValue(newValue);
15594
+ setExactValue(newValue);
15647
15595
  updateValue(newValue);
15648
15596
  };
15649
15597
  const onTouchEnd = () => {
@@ -15663,56 +15611,64 @@
15663
15611
  const renderButton = (index) => {
15664
15612
  return /* @__PURE__ */ React.createElement(React.Fragment, null, button || /* @__PURE__ */ React.createElement("div", { className: "nut-range-button" }, currentDescription !== null && /* @__PURE__ */ React.createElement("div", { className: "number" }, currentDescription ? currentDescription(curValue(index)) : curValue(index))));
15665
15613
  };
15666
- return /* @__PURE__ */ React.createElement("div", { className: containerClasses }, minDescription !== null && /* @__PURE__ */ React.createElement("div", { className: "min" }, minDescription || min), /* @__PURE__ */ React.createElement("div", { ref: root2, className: classes, onClick: (e) => click(e) }, marksList.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "nut-range-mark" }, marksList.map((mark) => {
15667
- return /* @__PURE__ */ React.createElement(
15668
- "span",
15669
- {
15670
- key: mark,
15671
- className: markClassName(mark),
15672
- style: marksStyle(mark)
15673
- },
15674
- Array.isArray(marks) ? marksRef.current[mark] : marks[mark],
15675
- /* @__PURE__ */ React.createElement(
15676
- "span",
15614
+ const renderRangeButton = () => {
15615
+ return [0, 1].map((item, index) => {
15616
+ const cls = `${index === 0 ? "nut-range-button-wrapper-left" : ""}
15617
+ ${index === 1 ? "nut-range-button-wrapper-right" : ""}`;
15618
+ return /* @__PURE__ */ React.createElement(
15619
+ "div",
15677
15620
  {
15678
- className: classNames("nut-range-tick", {
15679
- active: tickClass(mark)
15680
- })
15681
- }
15682
- )
15683
- );
15684
- })), /* @__PURE__ */ React.createElement("div", { className: "nut-range-bar", style: barStyle() }, range2 ? [0, 1].map((item, index) => {
15621
+ key: index,
15622
+ className: cls,
15623
+ onTouchStart: (e) => {
15624
+ setButtonIndex(index);
15625
+ onTouchStart(e);
15626
+ },
15627
+ onTouchMove,
15628
+ onTouchEnd,
15629
+ onTouchCancel: onTouchEnd,
15630
+ onClick: (e) => e.stopPropagation()
15631
+ },
15632
+ renderButton(index)
15633
+ );
15634
+ });
15635
+ };
15636
+ const renderSingleButton = () => {
15685
15637
  return /* @__PURE__ */ React.createElement(
15686
15638
  "div",
15687
15639
  {
15688
- key: index,
15689
- className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
15690
- ${index === 1 ? "nut-range-button-wrapper-right" : ""}`,
15691
- onTouchStart: (e) => {
15692
- if (typeof index === "number") {
15693
- setButtonIndex(index);
15694
- }
15695
- onTouchStart(e);
15696
- },
15697
- onTouchMove: (e) => onTouchMove(e),
15640
+ className: "nut-range-button-wrapper",
15641
+ onTouchStart,
15642
+ onTouchMove,
15698
15643
  onTouchEnd,
15699
15644
  onTouchCancel: onTouchEnd,
15700
15645
  onClick: (e) => e.stopPropagation()
15701
15646
  },
15702
- renderButton(index)
15647
+ renderButton()
15703
15648
  );
15704
- }) : /* @__PURE__ */ React.createElement(
15705
- "div",
15706
- {
15707
- className: "nut-range-button-wrapper",
15708
- onTouchStart: (e) => onTouchStart(e),
15709
- onTouchMove: (e) => onTouchMove(e),
15710
- onTouchEnd,
15711
- onTouchCancel: onTouchEnd,
15712
- onClick: (e) => e.stopPropagation()
15713
- },
15714
- renderButton()
15715
- ))), maxDescription !== null && /* @__PURE__ */ React.createElement("div", { className: "max" }, maxDescription || max));
15649
+ };
15650
+ const renderMark = () => {
15651
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, marksList.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "nut-range-mark" }, marksList.map((mark) => {
15652
+ return /* @__PURE__ */ React.createElement(
15653
+ "span",
15654
+ {
15655
+ key: mark,
15656
+ className: markClassName(mark),
15657
+ style: marksStyle(mark)
15658
+ },
15659
+ Array.isArray(marks) ? marksRef.current[mark] : marks[mark],
15660
+ /* @__PURE__ */ React.createElement(
15661
+ "span",
15662
+ {
15663
+ className: classNames("nut-range-tick", {
15664
+ active: tickClass(mark)
15665
+ })
15666
+ }
15667
+ )
15668
+ );
15669
+ })));
15670
+ };
15671
+ return /* @__PURE__ */ React.createElement("div", { className: containerClasses }, minDescription !== null && /* @__PURE__ */ React.createElement("div", { className: "min" }, minDescription || min), /* @__PURE__ */ React.createElement("div", { ref: root2, className: classes, onClick: (e) => click(e) }, renderMark(), /* @__PURE__ */ React.createElement("div", { className: "nut-range-bar", style: barStyle() }, range2 ? renderRangeButton() : renderSingleButton())), maxDescription !== null && /* @__PURE__ */ React.createElement("div", { className: "max" }, maxDescription || max));
15716
15672
  };
15717
15673
  Range.displayName = "NutRange";
15718
15674
  const defaultProps$N = {
@@ -16667,6 +16623,7 @@
16667
16623
  onDeleteItem,
16668
16624
  handleItemClick,
16669
16625
  previewUrl,
16626
+ deleteIcon,
16670
16627
  children
16671
16628
  }) => {
16672
16629
  const renderIcon = (item) => {
@@ -16684,12 +16641,12 @@
16684
16641
  key: item.uid
16685
16642
  },
16686
16643
  previewType === "picture" && !children && deletable && /* @__PURE__ */ React.createElement(
16687
- p$3,
16644
+ "div",
16688
16645
  {
16689
- color: "rgba(0,0,0,0.6)",
16690
- className: "close",
16691
- onClick: () => onDeleteItem(item, index)
16692
- }
16646
+ onClick: () => onDeleteItem(item, index),
16647
+ className: "close"
16648
+ },
16649
+ deleteIcon
16693
16650
  ),
16694
16651
  previewType === "picture" && !children && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader-preview-img" }, item.status === "ready" ? /* @__PURE__ */ React.createElement("div", { className: "nut-uploader-preview-progress" }, /* @__PURE__ */ React.createElement("div", { className: "nut-uploader-preview-progress-msg" }, item.message)) : item.status !== "success" && /* @__PURE__ */ React.createElement("div", { className: "nut-uploader-preview-progress" }, renderIcon(item), /* @__PURE__ */ React.createElement("div", { className: "nut-uploader-preview-progress-msg" }, item.message)), ((_a = item.type) == null ? void 0 : _a.includes("image")) ? /* @__PURE__ */ React.createElement(React.Fragment, null, item.url && /* @__PURE__ */ React.createElement(
16695
16652
  Image$1,
@@ -16775,6 +16732,7 @@
16775
16732
  deletable: true,
16776
16733
  capture: false,
16777
16734
  uploadIcon: /* @__PURE__ */ React.createElement(c$1, { width: "20px", height: "20px", color: "#808080" }),
16735
+ deleteIcon: /* @__PURE__ */ React.createElement(p$3, { color: "rgba(0,0,0,0.6)" }),
16778
16736
  beforeDelete: (file, files) => {
16779
16737
  return true;
16780
16738
  }
@@ -16785,6 +16743,7 @@
16785
16743
  const {
16786
16744
  children,
16787
16745
  uploadIcon,
16746
+ deleteIcon,
16788
16747
  uploadLabel,
16789
16748
  name,
16790
16749
  accept,
@@ -17051,7 +17010,8 @@
17051
17010
  onDeleteItem,
17052
17011
  handleItemClick,
17053
17012
  previewUrl,
17054
- children
17013
+ children,
17014
+ deleteIcon
17055
17015
  }
17056
17016
  }
17057
17017
  ), Number(maxCount) > fileList.length && previewType === "picture" && !children && /* @__PURE__ */ React.createElement(
@@ -17359,6 +17319,18 @@
17359
17319
  );
17360
17320
  };
17361
17321
  Content.displayName = "NutContent";
17322
+ const defaultDialogProps = {
17323
+ ...ComponentDefaults,
17324
+ overlay: true,
17325
+ overlayStyle: {},
17326
+ overlayClassName: "",
17327
+ onCancel: () => {
17328
+ },
17329
+ onClose: () => {
17330
+ },
17331
+ onOverlayClick: (e) => true,
17332
+ ...defaultOverlayProps
17333
+ };
17362
17334
  const DialogWrap = (props) => {
17363
17335
  const {
17364
17336
  visible,
@@ -17400,6 +17372,7 @@
17400
17372
  /* @__PURE__ */ React.createElement(Content, { ...props, visible })
17401
17373
  ));
17402
17374
  };
17375
+ DialogWrap.defaultProps = defaultDialogProps;
17403
17376
  DialogWrap.displayName = "NutDialogWrap";
17404
17377
  const defaultProps$E = {
17405
17378
  ...ComponentDefaults,
@@ -18966,7 +18939,6 @@
18966
18939
  };
18967
18940
  const classPrefix$9 = `nut-avatar`;
18968
18941
  const Avatar = (props) => {
18969
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
18970
18942
  const {
18971
18943
  children,
18972
18944
  size,
@@ -18992,9 +18964,10 @@
18992
18964
  const avatarRef = React.useRef(null);
18993
18965
  const parent = React.useContext(AvatarContext);
18994
18966
  const sizeValue = ["large", "normal", "small"];
18967
+ const { propAvatarGroup, avatarGroupRef } = parent;
18995
18968
  const classes = classNames({
18996
- [`nut-avatar-${((_a = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _a.size) || size || "normal"}`]: true,
18997
- [`nut-avatar-${((_b = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _b.shape) || shape}`]: true
18969
+ [`nut-avatar-${(propAvatarGroup == null ? void 0 : propAvatarGroup.size) || size || "normal"}`]: true,
18970
+ [`nut-avatar-${(propAvatarGroup == null ? void 0 : propAvatarGroup.shape) || shape}`]: true
18998
18971
  });
18999
18972
  const cls = classNames(classPrefix$9, classes, className);
19000
18973
  const styles = {
@@ -19002,45 +18975,45 @@
19002
18975
  height: sizeValue.indexOf(size) > -1 ? "" : `${size}px`,
19003
18976
  backgroundColor: `${background}`,
19004
18977
  color,
19005
- marginLeft: avatarIndex !== 1 && ((_c = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _c.gap) ? `${(_d = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _d.gap}px` : "",
19006
- zIndex: ((_e = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _e.level) === "right" ? `${Math.abs(maxSum - avatarIndex)}` : "",
18978
+ marginLeft: avatarIndex !== 1 && (propAvatarGroup == null ? void 0 : propAvatarGroup.gap) ? `${propAvatarGroup == null ? void 0 : propAvatarGroup.gap}px` : "",
18979
+ zIndex: (propAvatarGroup == null ? void 0 : propAvatarGroup.level) === "right" ? `${Math.abs(maxSum - avatarIndex)}` : "",
19007
18980
  ...style
19008
18981
  };
19009
18982
  const maxStyles = {
19010
- backgroundColor: `${(_f = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _f.maxBackground}`,
19011
- color: `${(_g = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _g.maxColor}`
19012
- };
18983
+ backgroundColor: `${propAvatarGroup == null ? void 0 : propAvatarGroup.maxBackground}`,
18984
+ color: `${propAvatarGroup == null ? void 0 : propAvatarGroup.maxColor}`
18985
+ };
18986
+ const avatarLength = React.useCallback(
18987
+ (children2) => {
18988
+ var _a, _b;
18989
+ for (let i2 = 0; i2 < children2.length; i2++) {
18990
+ if (children2[i2] && children2[i2].classList && children2[i2].classList[0] === "nut-avatar") {
18991
+ children2[i2].setAttribute("data-index", i2 + 1);
18992
+ }
18993
+ }
18994
+ const index = Number((_b = (_a = avatarRef.current) == null ? void 0 : _a.dataset) == null ? void 0 : _b.index);
18995
+ const maxCount = propAvatarGroup == null ? void 0 : propAvatarGroup.max;
18996
+ setMaxSum(children2.length);
18997
+ setAvatarIndex(index);
18998
+ if (index === children2.length && index !== maxCount && children2.length > maxCount) {
18999
+ setShowMax(true);
19000
+ }
19001
+ },
19002
+ [propAvatarGroup == null ? void 0 : propAvatarGroup.max]
19003
+ );
19013
19004
  React.useEffect(() => {
19014
- var _a2;
19015
- const avatarChildren = (_a2 = parent == null ? void 0 : parent.avatarGroupRef) == null ? void 0 : _a2.current.children;
19005
+ const avatarChildren = avatarGroupRef == null ? void 0 : avatarGroupRef.current.children;
19016
19006
  if (avatarChildren) {
19017
19007
  avatarLength(avatarChildren);
19018
19008
  }
19019
- }, []);
19020
- const avatarLength = (children2) => {
19021
- var _a2, _b2, _c2;
19022
- for (let i2 = 0; i2 < children2.length; i2++) {
19023
- if (children2[i2] && children2[i2].classList && children2[i2].classList[0] === "nut-avatar") {
19024
- children2[i2].setAttribute("data-index", i2 + 1);
19025
- }
19026
- }
19027
- const index = Number((_b2 = (_a2 = avatarRef == null ? void 0 : avatarRef.current) == null ? void 0 : _a2.dataset) == null ? void 0 : _b2.index);
19028
- const maxCount = (_c2 = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _c2.max;
19029
- setMaxSum(children2.length);
19030
- setAvatarIndex(index);
19031
- if (index === children2.length && index !== maxCount && children2.length > maxCount) {
19032
- setShowMax(true);
19033
- }
19034
- };
19009
+ }, [avatarLength, avatarGroupRef]);
19035
19010
  const errorEvent = () => {
19036
- if (onError) {
19037
- onError();
19038
- }
19011
+ onError && onError();
19039
19012
  };
19040
19013
  const clickAvatar = (e) => {
19041
19014
  onClick && onClick(e);
19042
19015
  };
19043
- return /* @__PURE__ */ React.createElement(React.Fragment, null, (showMax || !((_h = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _h.max) || avatarIndex <= ((_i = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _i.max)) && /* @__PURE__ */ React.createElement(
19016
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, (showMax || !(propAvatarGroup == null ? void 0 : propAvatarGroup.max) || avatarIndex <= (propAvatarGroup == null ? void 0 : propAvatarGroup.max)) && /* @__PURE__ */ React.createElement(
19044
19017
  "div",
19045
19018
  {
19046
19019
  className: cls,
@@ -19049,7 +19022,7 @@
19049
19022
  onClick: clickAvatar,
19050
19023
  ref: avatarRef
19051
19024
  },
19052
- (!((_j = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _j.max) || avatarIndex <= ((_k = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _k.max)) && /* @__PURE__ */ React.createElement(React.Fragment, null, src && /* @__PURE__ */ React.createElement(
19025
+ (!(propAvatarGroup == null ? void 0 : propAvatarGroup.max) || avatarIndex <= (propAvatarGroup == null ? void 0 : propAvatarGroup.max)) && /* @__PURE__ */ React.createElement(React.Fragment, null, src && /* @__PURE__ */ React.createElement(
19053
19026
  Image$1,
19054
19027
  {
19055
19028
  className: "avatar-img",
@@ -19062,7 +19035,7 @@
19062
19035
  ...icon.props,
19063
19036
  className: `${icon.props.className || ""} icon`
19064
19037
  }) : null, children && /* @__PURE__ */ React.createElement("span", { className: "text" }, children), !src && !icon && !children && /* @__PURE__ */ React.createElement(i, { className: "icon" })),
19065
- showMax && /* @__PURE__ */ React.createElement("div", { className: "text" }, ((_l = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _l.maxContent) ? (_m = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _m.maxContent : `+ ${avatarIndex - Number(((_n = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _n.max) || 0)}`)
19038
+ showMax && /* @__PURE__ */ React.createElement("div", { className: "text" }, (propAvatarGroup == null ? void 0 : propAvatarGroup.maxContent) ? propAvatarGroup == null ? void 0 : propAvatarGroup.maxContent : `+ ${avatarIndex - Number((propAvatarGroup == null ? void 0 : propAvatarGroup.max) || 0)}`)
19066
19039
  ));
19067
19040
  };
19068
19041
  Avatar.displayName = "NutAvatar";
@@ -19571,7 +19544,7 @@
19571
19544
  className,
19572
19545
  thousands,
19573
19546
  style,
19574
- ...reset
19547
+ ...rest
19575
19548
  } = mergeProps(defaultProps$r, props);
19576
19549
  const classPrefix2 = "nut-countup";
19577
19550
  const countupRef = React.useRef(null);
@@ -19584,7 +19557,7 @@
19584
19557
  return currNumber.split("");
19585
19558
  };
19586
19559
  const numerArr = React.useMemo(getShowNumber, [value, length, thousands]);
19587
- const setNumberTransform = () => {
19560
+ const setNumberTransform = React.useCallback(() => {
19588
19561
  if (countupRef.current) {
19589
19562
  const numberItems = countupRef.current.querySelectorAll(
19590
19563
  ".nut-countup-number"
@@ -19602,7 +19575,7 @@
19602
19575
  }
19603
19576
  });
19604
19577
  }
19605
- };
19578
+ }, [numerArr]);
19606
19579
  const numberEaseStyle = {
19607
19580
  transition: `transform ${duration}s ease-in-out`
19608
19581
  };
@@ -19613,7 +19586,7 @@
19613
19586
  return () => {
19614
19587
  window.clearTimeout(timerRef.current);
19615
19588
  };
19616
- }, [numerArr]);
19589
+ }, [numerArr, delay, setNumberTransform]);
19617
19590
  return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2} ${className}`, ref: countupRef }, /* @__PURE__ */ React.createElement("ul", { className: `${classPrefix2}-list` }, numerArr.map((item, idx) => {
19618
19591
  return /* @__PURE__ */ React.createElement(
19619
19592
  "li",