@nutui/nutui-react 2.6.21 → 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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.6.21 Fri Sep 27 2024 14:09:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.6.22 Sat Oct 12 2024 14:58:54 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -635,7 +635,7 @@ const Button = React__default.forwardRef(
635
635
  };
636
636
  const getStyle = useCallback(() => {
637
637
  const style2 = {};
638
- if (props.color) {
638
+ if (color) {
639
639
  if (props.fill === "outline" || props.fill === "dashed") {
640
640
  style2.color = color;
641
641
  if (!(color == null ? void 0 : color.includes("gradient"))) {
@@ -648,7 +648,7 @@ const Button = React__default.forwardRef(
648
648
  }
649
649
  }
650
650
  return style2;
651
- }, [color]);
651
+ }, [color, props.fill]);
652
652
  const handleClick2 = (e) => {
653
653
  if (!loading && !disabled && onClick) {
654
654
  onClick(e);
@@ -1854,7 +1854,7 @@ const zhCN = {
1854
1854
  };
1855
1855
  const inBrowser = typeof window !== "undefined";
1856
1856
  function requestAniFrame() {
1857
- if (typeof window !== "undefined") {
1857
+ if (inBrowser) {
1858
1858
  const _window = window;
1859
1859
  return _window.requestAnimationFrame || _window.webkitRequestAnimationFrame || function(callback) {
1860
1860
  _window.setTimeout(callback, 1e3 / 60);
@@ -1864,6 +1864,14 @@ function requestAniFrame() {
1864
1864
  setTimeout(callback, 1e3 / 60);
1865
1865
  };
1866
1866
  }
1867
+ function cancelRaf(id) {
1868
+ if (inBrowser) {
1869
+ const _window = window;
1870
+ (_window.cancelAnimationFrame || _window.webkitCancelAnimationFrame)(id);
1871
+ } else {
1872
+ clearTimeout(id);
1873
+ }
1874
+ }
1867
1875
  const requestAniFrame$1 = requestAniFrame();
1868
1876
  const classPrefix$p = "nut-configprovider";
1869
1877
  const defaultConfigRef$1 = {
@@ -2782,7 +2790,8 @@ const Overlay = (props) => {
2782
2790
  setInnerVisible(false);
2783
2791
  }
2784
2792
  }, [visible]);
2785
- useLockScroll(nodeRef, !!lockScroll && innerVisible);
2793
+ const shouldLockScroll = !innerVisible ? false : lockScroll;
2794
+ useLockScroll(nodeRef, shouldLockScroll);
2786
2795
  const classes = classNames(classPrefix2, className);
2787
2796
  const styles = {
2788
2797
  ...style
@@ -3336,31 +3345,36 @@ const BackTop = (props) => {
3336
3345
  const [scrollTop, SetScrollTop] = useState(0);
3337
3346
  let startTime = 0;
3338
3347
  const scrollEl = useRef(null);
3339
- useEffect(() => {
3340
- init();
3341
- return () => removeEventListener();
3342
- }, []);
3343
- const init = () => {
3348
+ const cls = classNames(classPrefix2, { show: backTop }, className);
3349
+ const scrollListener = useCallback(() => {
3350
+ var _a;
3351
+ let top = null;
3352
+ if (scrollEl.current instanceof Window) {
3353
+ top = scrollEl.current.scrollY;
3354
+ } else {
3355
+ top = (_a = scrollEl.current) == null ? void 0 : _a.scrollTop;
3356
+ }
3357
+ SetScrollTop(top);
3358
+ SetBackTop(top >= threshold);
3359
+ }, [threshold]);
3360
+ const init = useCallback(() => {
3361
+ var _a, _b;
3344
3362
  if (target && document.getElementById(target)) {
3345
3363
  scrollEl.current = document.getElementById(target);
3346
3364
  } else {
3347
3365
  scrollEl.current = window;
3348
3366
  }
3349
- addEventListener();
3350
- initCancelAniFrame();
3351
- };
3352
- const scrollListener = () => {
3353
- let top = null;
3354
- if (scrollEl.current instanceof Window) {
3355
- top = scrollEl.current.pageYOffset;
3356
- SetScrollTop(top);
3357
- } else {
3358
- top = scrollEl.current.scrollTop;
3359
- SetScrollTop(top);
3360
- }
3361
- const showBtn = top >= threshold;
3362
- SetBackTop(showBtn);
3363
- };
3367
+ (_a = scrollEl.current) == null ? void 0 : _a.addEventListener("scroll", scrollListener, false);
3368
+ (_b = scrollEl.current) == null ? void 0 : _b.addEventListener("resize", scrollListener, false);
3369
+ }, [target, scrollListener]);
3370
+ useEffect(() => {
3371
+ init();
3372
+ return () => {
3373
+ var _a, _b;
3374
+ (_a = scrollEl.current) == null ? void 0 : _a.removeEventListener("scroll", scrollListener, false);
3375
+ (_b = scrollEl.current) == null ? void 0 : _b.removeEventListener("resize", scrollListener, false);
3376
+ };
3377
+ }, [init, scrollListener]);
3364
3378
  const scroll = (y = 0) => {
3365
3379
  if (scrollEl.current instanceof Window) {
3366
3380
  window.scrollTo(0, y);
@@ -3376,27 +3390,13 @@ const BackTop = (props) => {
3376
3390
  scroll(y);
3377
3391
  cid = requestAniFrame$1(fn);
3378
3392
  if (t === duration || y === 0) {
3379
- window.cancelAnimationFrame(cid);
3393
+ cancelRaf(cid);
3380
3394
  }
3381
3395
  });
3382
3396
  };
3383
- const initCancelAniFrame = () => {
3384
- window.cancelAnimationFrame = window.webkitCancelAnimationFrame;
3385
- };
3386
- function addEventListener() {
3387
- var _a, _b;
3388
- (_a = scrollEl.current) == null ? void 0 : _a.addEventListener("scroll", scrollListener, false);
3389
- (_b = scrollEl.current) == null ? void 0 : _b.addEventListener("resize", scrollListener, false);
3390
- }
3391
- function removeEventListener() {
3392
- var _a, _b;
3393
- (_a = scrollEl.current) == null ? void 0 : _a.removeEventListener("scroll", scrollListener, false);
3394
- (_b = scrollEl.current) == null ? void 0 : _b.removeEventListener("resize", scrollListener, false);
3395
- }
3396
3397
  const goTop = (e) => {
3397
3398
  onClick && onClick(e);
3398
- const otime = +/* @__PURE__ */ new Date();
3399
- startTime = otime;
3399
+ startTime = +/* @__PURE__ */ new Date();
3400
3400
  duration > 0 ? scrollAnimation() : scroll();
3401
3401
  };
3402
3402
  const styles = Object.keys(style || {}).length !== 0 ? {
@@ -3407,23 +3407,7 @@ const BackTop = (props) => {
3407
3407
  bottom: "20px",
3408
3408
  zIndex
3409
3409
  };
3410
- return /* @__PURE__ */ React__default.createElement(
3411
- "div",
3412
- {
3413
- className: classNames(
3414
- classPrefix2,
3415
- {
3416
- show: backTop
3417
- },
3418
- className
3419
- ),
3420
- style: styles,
3421
- onClick: (e) => {
3422
- goTop(e);
3423
- }
3424
- },
3425
- children || /* @__PURE__ */ React__default.createElement(s$1, { width: 19, height: 19, className: "nut-backtop-main" })
3426
- );
3410
+ return /* @__PURE__ */ React__default.createElement("div", { className: cls, style: styles, onClick: (e) => goTop(e) }, children || /* @__PURE__ */ React__default.createElement(s$1, { width: 19, height: 19, className: "nut-backtop-main" }));
3427
3411
  };
3428
3412
  BackTop.displayName = "NutBackTop";
3429
3413
  function clamp$2(v, min, max) {
@@ -8626,11 +8610,10 @@ const NavBar = (props) => {
8626
8610
  };
8627
8611
  const classes = classNames({
8628
8612
  [`${classPrefix2}-fixed`]: fixed,
8629
- [`${classPrefix2}-safe-area-inset-top`]: safeAreaInsetTop,
8630
8613
  [`${classPrefix2}-title-align-${titleAlign}`]: true
8631
8614
  });
8632
8615
  const cls = classNames(classPrefix2, classes, className);
8633
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, fixed && placeholder ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-placeholder` }, renderWrapper()) : renderWrapper());
8616
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, safeAreaInsetTop && /* @__PURE__ */ React__default.createElement(SafeArea, { position: "top" }), fixed && placeholder ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-placeholder` }, renderWrapper()) : renderWrapper());
8634
8617
  };
8635
8618
  NavBar.displayName = "NutNavBar";
8636
8619
  const defaultProps$1e = {
@@ -8693,7 +8676,8 @@ const Popup = (props) => {
8693
8676
  const [innerVisible, setInnerVisible] = useState(visible);
8694
8677
  const [showChildren, setShowChildren] = useState(true);
8695
8678
  const [transitionName, setTransitionName] = useState("");
8696
- useLockScroll(nodeRef, innerVisible && lockScroll);
8679
+ const shouldLockScroll = !innerVisible ? false : lockScroll;
8680
+ useLockScroll(nodeRef, shouldLockScroll);
8697
8681
  const classPrefix2 = "nut-popup";
8698
8682
  const baseStyle = {
8699
8683
  zIndex: index
@@ -14679,9 +14663,21 @@ const MenuItem = forwardRef((props, ref) => {
14679
14663
  useEffect(() => {
14680
14664
  setShowPopup(show2);
14681
14665
  }, [show2]);
14666
+ const getParentOffset = useCallback(() => {
14667
+ setTimeout(() => {
14668
+ const p2 = parent.menuRef.current;
14669
+ if (p2) {
14670
+ const rect = p2.getBoundingClientRect();
14671
+ setPosition({
14672
+ height: rect.height,
14673
+ top: rect.top
14674
+ });
14675
+ }
14676
+ });
14677
+ }, [parent.menuRef]);
14682
14678
  useEffect(() => {
14683
14679
  getParentOffset();
14684
- }, [showPopup]);
14680
+ }, [showPopup, getParentOffset]);
14685
14681
  useImperativeHandle(ref, () => ({
14686
14682
  toggle: (s2) => {
14687
14683
  const from = "REF";
@@ -14715,18 +14711,6 @@ const MenuItem = forwardRef((props, ref) => {
14715
14711
  const scrollParent = useMemo$1(() => {
14716
14712
  return getScrollParent(parent.menuRef, window);
14717
14713
  }, [parent.menuRef]);
14718
- const getParentOffset = () => {
14719
- setTimeout(() => {
14720
- const p2 = parent.menuRef.current;
14721
- if (p2) {
14722
- const rect = p2.getBoundingClientRect();
14723
- setPosition({
14724
- height: rect.height,
14725
- top: rect.top
14726
- });
14727
- }
14728
- });
14729
- };
14730
14714
  useEffect(() => {
14731
14715
  if (!parent.lockScroll) {
14732
14716
  scrollParent == null ? void 0 : scrollParent.addEventListener("scroll", getParentOffset, false);
@@ -14734,7 +14718,7 @@ const MenuItem = forwardRef((props, ref) => {
14734
14718
  scrollParent == null ? void 0 : scrollParent.removeEventListener("scroll", getParentOffset, false);
14735
14719
  };
14736
14720
  }
14737
- }, []);
14721
+ }, [parent.lockScroll, scrollParent, getParentOffset]);
14738
14722
  const getPosition = () => {
14739
14723
  return direction === "down" ? {
14740
14724
  top: `${position.top + position.height}px`,
@@ -14865,24 +14849,29 @@ const Menu = (props) => {
14865
14849
  ...props
14866
14850
  };
14867
14851
  const menuRef = useRef(null);
14852
+ const [showMenuItem, setShowMenuItem] = useState([]);
14853
+ const [menuItemTitle, setMenuItemTitle] = useState([]);
14868
14854
  const [isScrollFixed, setIsScrollFixed] = useState(false);
14855
+ const cls = classNames(`nut-menu`, className, {
14856
+ "scroll-fixed": isScrollFixed
14857
+ });
14869
14858
  const getScrollTop = (el) => {
14870
- return Math.max(0, "scrollTop" in el ? el.scrollTop : el.pageYOffset);
14859
+ return Math.max(
14860
+ 0,
14861
+ el === window ? window.scrollY : el.scrollTop
14862
+ );
14871
14863
  };
14872
- const onScroll = () => {
14873
- const { scrollFixed: scrollFixed2 } = props;
14864
+ const onScroll = useCallback(() => {
14874
14865
  const scrollTop = getScrollTop(window);
14875
- const isFixed = scrollTop > (typeof scrollFixed2 === "boolean" ? 30 : Number(scrollFixed2));
14866
+ const isFixed = scrollTop > (typeof scrollFixed === "boolean" ? 30 : Number(scrollFixed));
14876
14867
  setIsScrollFixed(isFixed);
14877
- };
14868
+ }, [scrollFixed]);
14878
14869
  useEffect(() => {
14879
14870
  if (scrollFixed) {
14880
14871
  window.addEventListener("scroll", onScroll);
14881
14872
  }
14882
14873
  return () => window.removeEventListener("scroll", onScroll);
14883
- }, []);
14884
- const [showMenuItem, setShowMenuItem] = useState([]);
14885
- const [menuItemTitle, setMenuItemTitle] = useState([]);
14874
+ }, [scrollFixed, onScroll]);
14886
14875
  const toggleMenuItem = (index, from = "NORMAL") => {
14887
14876
  showMenuItem[index] = !showMenuItem[index];
14888
14877
  if (showMenuItem[index]) {
@@ -14986,26 +14975,15 @@ const Menu = (props) => {
14986
14975
  return null;
14987
14976
  });
14988
14977
  };
14989
- return /* @__PURE__ */ React__default.createElement(
14978
+ return /* @__PURE__ */ React__default.createElement("div", { ...rest, className: cls, ref: menuRef }, /* @__PURE__ */ React__default.createElement(
14990
14979
  "div",
14991
14980
  {
14992
- ...rest,
14993
- className: classNames(`nut-menu`, className, {
14994
- "scroll-fixed": isScrollFixed
14995
- }),
14996
- ref: menuRef
14981
+ className: classNames("nut-menu-bar", {
14982
+ opened: showMenuItem.includes(true)
14983
+ })
14997
14984
  },
14998
- /* @__PURE__ */ React__default.createElement(
14999
- "div",
15000
- {
15001
- className: classNames("nut-menu-bar", {
15002
- opened: showMenuItem.includes(true)
15003
- })
15004
- },
15005
- menuTitle()
15006
- ),
15007
- cloneChildren()
15008
- );
14985
+ menuTitle()
14986
+ ), cloneChildren());
15009
14987
  };
15010
14988
  Menu.displayName = "NutMenu";
15011
14989
  Menu.Item = MenuItem;
@@ -15202,6 +15180,13 @@ const RadioGroup = React__default.forwardRef(
15202
15180
  disabled,
15203
15181
  ...rest
15204
15182
  } = { ...defaultProps$Q, ...props };
15183
+ const cls = classNames(
15184
+ classPrefix$f,
15185
+ {
15186
+ [`${classPrefix$f}-${props.direction}`]: props.direction
15187
+ },
15188
+ className
15189
+ );
15205
15190
  const [val2State, setVal2State] = usePropsValue({
15206
15191
  defaultValue: props.defaultValue,
15207
15192
  value: props.value,
@@ -15224,7 +15209,7 @@ const RadioGroup = React__default.forwardRef(
15224
15209
  }
15225
15210
  );
15226
15211
  });
15227
- }, [options2]);
15212
+ }, [options2, labelPosition, val2State]);
15228
15213
  return /* @__PURE__ */ React__default.createElement(
15229
15214
  RadioContext.Provider,
15230
15215
  {
@@ -15241,20 +15226,7 @@ const RadioGroup = React__default.forwardRef(
15241
15226
  }
15242
15227
  }
15243
15228
  },
15244
- /* @__PURE__ */ React__default.createElement(
15245
- "div",
15246
- {
15247
- className: classNames(
15248
- classPrefix$f,
15249
- {
15250
- [`${classPrefix$f}-${props.direction}`]: props.direction
15251
- },
15252
- className
15253
- ),
15254
- ...rest
15255
- },
15256
- (options2 == null ? void 0 : options2.length) ? renderOptionsChildren() : children
15257
- )
15229
+ /* @__PURE__ */ React__default.createElement("div", { className: cls, ...rest }, (options2 == null ? void 0 : options2.length) ? renderOptionsChildren() : children)
15258
15230
  );
15259
15231
  }
15260
15232
  );
@@ -15312,29 +15284,6 @@ const Radio = (props) => {
15312
15284
  }
15313
15285
  };
15314
15286
  }
15315
- const renderLabel = () => {
15316
- return /* @__PURE__ */ React__default.createElement(
15317
- "div",
15318
- {
15319
- className: classNames(`${classPrefix2}-label`, {
15320
- [`${classPrefix2}-label-disabled`]: disabled
15321
- })
15322
- },
15323
- children
15324
- );
15325
- };
15326
- const renderButton = () => {
15327
- return /* @__PURE__ */ React__default.createElement(
15328
- "div",
15329
- {
15330
- className: classNames(`${classPrefix2}-button`, {
15331
- [`${classPrefix2}-button-active`]: checkedStatement,
15332
- [`${classPrefix2}-button-disabled`]: disabled
15333
- })
15334
- },
15335
- children
15336
- );
15337
- };
15338
15287
  const color = () => {
15339
15288
  return {
15340
15289
  [`${classPrefix2}-icon-disabled`]: disabled,
@@ -15358,8 +15307,21 @@ const Radio = (props) => {
15358
15307
  className: classNames(color())
15359
15308
  }) : /* @__PURE__ */ React__default.createElement(i$6, { className: classNames(color()) });
15360
15309
  };
15310
+ const renderLabel = () => {
15311
+ const labelcls = classNames(`${classPrefix2}-label`, {
15312
+ [`${classPrefix2}-label-disabled`]: disabled
15313
+ });
15314
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderIcon(), /* @__PURE__ */ React__default.createElement("div", { className: labelcls }, children));
15315
+ };
15316
+ const renderButton = () => {
15317
+ const buttoncls = classNames(`${classPrefix2}-button`, {
15318
+ [`${classPrefix2}-button-active`]: checkedStatement,
15319
+ [`${classPrefix2}-button-disabled`]: disabled
15320
+ });
15321
+ return /* @__PURE__ */ React__default.createElement("div", { className: buttoncls }, children);
15322
+ };
15361
15323
  const renderByShape = (shape2) => {
15362
- return shape2 === "button" ? renderButton() : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderIcon(), renderLabel());
15324
+ return shape2 === "button" ? renderButton() : renderLabel();
15363
15325
  };
15364
15326
  const renderRadioItem = () => {
15365
15327
  return renderByShape(context && context.shape ? context.shape : shape);
@@ -15368,22 +15330,14 @@ const Radio = (props) => {
15368
15330
  if (disabled || checkedStatement) return;
15369
15331
  setCheckedStatement(!checkedStatement);
15370
15332
  };
15371
- return /* @__PURE__ */ React__default.createElement(
15372
- "div",
15333
+ const cls = classNames(
15334
+ classPrefix2,
15373
15335
  {
15374
- className: classNames(
15375
- classPrefix2,
15376
- {
15377
- [`${classPrefix2}-reverse`]: labelPosition === "left"
15378
- },
15379
- className
15380
- ),
15381
- style,
15382
- onClick: handleClick2,
15383
- ...rest
15336
+ [`${classPrefix2}-reverse`]: labelPosition === "left"
15384
15337
  },
15385
- renderRadioItem()
15338
+ className
15386
15339
  );
15340
+ return /* @__PURE__ */ React__default.createElement("div", { className: cls, style, onClick: handleClick2, ...rest }, renderRadioItem());
15387
15341
  };
15388
15342
  Radio.displayName = "NutRadio";
15389
15343
  Radio.Group = RadioGroup;
@@ -15405,9 +15359,6 @@ const Range = (props) => {
15405
15359
  button,
15406
15360
  vertical,
15407
15361
  marks,
15408
- onChange,
15409
- onStart,
15410
- onEnd,
15411
15362
  minDescription,
15412
15363
  maxDescription,
15413
15364
  currentDescription,
@@ -15415,7 +15366,10 @@ const Range = (props) => {
15415
15366
  max,
15416
15367
  step,
15417
15368
  value,
15418
- defaultValue
15369
+ defaultValue,
15370
+ onChange,
15371
+ onStart,
15372
+ onEnd
15419
15373
  } = { ...defaultProps$O, ...props };
15420
15374
  const classPrefix2 = "nut-range";
15421
15375
  const [buttonIndex, setButtonIndex] = useState(0);
@@ -15433,7 +15387,7 @@ const Range = (props) => {
15433
15387
  finalValue: 0,
15434
15388
  onChange: handleChange
15435
15389
  });
15436
- const [exactValue, setEaxctValue] = useState(
15390
+ const [exactValue, setExactValue] = useState(
15437
15391
  () => value || defaultValue || 0
15438
15392
  );
15439
15393
  const marksRef = useRef({});
@@ -15451,10 +15405,7 @@ const Range = (props) => {
15451
15405
  setMarksList(list);
15452
15406
  }
15453
15407
  }
15454
- }, [marks]);
15455
- const scope = () => {
15456
- return max - min;
15457
- };
15408
+ }, [marks, max, min]);
15458
15409
  const classes = classNames(classPrefix2, {
15459
15410
  [`${classPrefix2}-disabled`]: disabled,
15460
15411
  [`${classPrefix2}-vertical`]: vertical
@@ -15466,41 +15417,38 @@ const Range = (props) => {
15466
15417
  },
15467
15418
  className
15468
15419
  );
15469
- const markClassName = useCallback(
15470
- (mark) => {
15471
- const classPrefix22 = "nut-range-mark";
15472
- let lowerBound = min;
15473
- let upperBound = max;
15474
- if (range3 && Array.isArray(current)) {
15475
- lowerBound = current[0];
15476
- upperBound = current[1];
15477
- } else {
15478
- upperBound = current;
15479
- }
15480
- const isActive = mark <= upperBound && mark >= lowerBound;
15481
- return [
15482
- `${classPrefix22}-text`,
15483
- `${isActive ? `${classPrefix22}-text-active` : ""}`
15484
- ].join(" ");
15485
- },
15486
- [range3, current, min, max]
15487
- );
15420
+ const markClassName = (mark) => {
15421
+ const classPrefix22 = "nut-range-mark";
15422
+ let lowerBound = min;
15423
+ let upperBound = max;
15424
+ if (range3 && Array.isArray(current)) {
15425
+ lowerBound = current[0];
15426
+ upperBound = current[1];
15427
+ } else {
15428
+ upperBound = current;
15429
+ }
15430
+ const isActive = mark <= upperBound && mark >= lowerBound;
15431
+ return [
15432
+ `${classPrefix22}-text`,
15433
+ `${isActive ? `${classPrefix22}-text-active` : ""}`
15434
+ ].join(" ");
15435
+ };
15488
15436
  const isRange = (val) => {
15489
15437
  return !!range3 && Array.isArray(val);
15490
15438
  };
15439
+ const scope = useMemo$1(() => {
15440
+ if (max < min || max === min) {
15441
+ console.log("max 的值需要大于 min的值");
15442
+ }
15443
+ return max - min;
15444
+ }, [max, min]);
15491
15445
  const calcMainAxis = () => {
15492
15446
  const modelVal = current;
15493
- if (isRange(modelVal)) {
15494
- return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
15495
- }
15496
- return `${(modelVal - min) * 100 / scope()}%`;
15447
+ return isRange(modelVal) ? `${(modelVal[1] - modelVal[0]) * 100 / scope}%` : `${(modelVal - min) * 100 / scope}%`;
15497
15448
  };
15498
15449
  const calcOffset = () => {
15499
15450
  const modelVal = current;
15500
- if (isRange(modelVal)) {
15501
- return `${(modelVal[0] - min) * 100 / scope()}%`;
15502
- }
15503
- return `0%`;
15451
+ return isRange(modelVal) ? `${(modelVal[0] - min) * 100 / scope}%` : `0%`;
15504
15452
  };
15505
15453
  const barStyle = () => {
15506
15454
  if (vertical) {
@@ -15520,11 +15468,11 @@ const Range = (props) => {
15520
15468
  const marksStyle = (mark) => {
15521
15469
  const dir = rtl ? "right" : "left";
15522
15470
  let style = {
15523
- [dir]: `${(mark - min) / scope() * 100}%`
15471
+ [dir]: `${(mark - min) / scope * 100}%`
15524
15472
  };
15525
15473
  if (vertical) {
15526
15474
  style = {
15527
- top: `${(mark - min) / scope() * 100}%`
15475
+ top: `${(mark - min) / scope * 100}%`
15528
15476
  };
15529
15477
  }
15530
15478
  return style;
@@ -15571,8 +15519,8 @@ const Range = (props) => {
15571
15519
  delta = event.clientY - rect.top;
15572
15520
  total = rect.height;
15573
15521
  }
15574
- const value2 = min + delta / total * scope();
15575
- setEaxctValue(current);
15522
+ const value2 = min + delta / total * scope;
15523
+ setExactValue(current);
15576
15524
  if (isRange(current)) {
15577
15525
  const [left, right] = current;
15578
15526
  const middle = (left + right) / 2;
@@ -15590,7 +15538,7 @@ const Range = (props) => {
15590
15538
  return;
15591
15539
  }
15592
15540
  touch.start(event);
15593
- setEaxctValue(current);
15541
+ setExactValue(current);
15594
15542
  if (isRange(current)) {
15595
15543
  setStartValue(current.map(format2));
15596
15544
  } else {
@@ -15611,12 +15559,12 @@ const Range = (props) => {
15611
15559
  const rect = getRect(root2.current);
15612
15560
  let delta = touch.deltaX.current;
15613
15561
  let total = rect.width;
15614
- let diff = delta / total * scope();
15562
+ let diff = delta / total * scope;
15615
15563
  diff = rtl ? -diff : diff;
15616
15564
  if (vertical) {
15617
15565
  delta = touch.deltaY.current;
15618
15566
  total = rect.height;
15619
- diff = delta / total * scope();
15567
+ diff = delta / total * scope;
15620
15568
  }
15621
15569
  let newValue;
15622
15570
  if (isRange(startValue)) {
@@ -15625,7 +15573,7 @@ const Range = (props) => {
15625
15573
  } else {
15626
15574
  newValue = startValue + diff;
15627
15575
  }
15628
- setEaxctValue(newValue);
15576
+ setExactValue(newValue);
15629
15577
  updateValue(newValue);
15630
15578
  };
15631
15579
  const onTouchEnd = () => {
@@ -15645,56 +15593,64 @@ const Range = (props) => {
15645
15593
  const renderButton = (index) => {
15646
15594
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, button || /* @__PURE__ */ React__default.createElement("div", { className: "nut-range-button" }, currentDescription !== null && /* @__PURE__ */ React__default.createElement("div", { className: "number" }, currentDescription ? currentDescription(curValue(index)) : curValue(index))));
15647
15595
  };
15648
- return /* @__PURE__ */ React__default.createElement("div", { className: containerClasses }, minDescription !== null && /* @__PURE__ */ React__default.createElement("div", { className: "min" }, minDescription || min), /* @__PURE__ */ React__default.createElement("div", { ref: root2, className: classes, onClick: (e) => click(e) }, marksList.length > 0 && /* @__PURE__ */ React__default.createElement("div", { className: "nut-range-mark" }, marksList.map((mark) => {
15649
- return /* @__PURE__ */ React__default.createElement(
15650
- "span",
15651
- {
15652
- key: mark,
15653
- className: markClassName(mark),
15654
- style: marksStyle(mark)
15655
- },
15656
- Array.isArray(marks) ? marksRef.current[mark] : marks[mark],
15657
- /* @__PURE__ */ React__default.createElement(
15658
- "span",
15596
+ const renderRangeButton = () => {
15597
+ return [0, 1].map((item, index) => {
15598
+ const cls = `${index === 0 ? "nut-range-button-wrapper-left" : ""}
15599
+ ${index === 1 ? "nut-range-button-wrapper-right" : ""}`;
15600
+ return /* @__PURE__ */ React__default.createElement(
15601
+ "div",
15659
15602
  {
15660
- className: classNames("nut-range-tick", {
15661
- active: tickClass(mark)
15662
- })
15663
- }
15664
- )
15665
- );
15666
- })), /* @__PURE__ */ React__default.createElement("div", { className: "nut-range-bar", style: barStyle() }, range3 ? [0, 1].map((item, index) => {
15603
+ key: index,
15604
+ className: cls,
15605
+ onTouchStart: (e) => {
15606
+ setButtonIndex(index);
15607
+ onTouchStart(e);
15608
+ },
15609
+ onTouchMove,
15610
+ onTouchEnd,
15611
+ onTouchCancel: onTouchEnd,
15612
+ onClick: (e) => e.stopPropagation()
15613
+ },
15614
+ renderButton(index)
15615
+ );
15616
+ });
15617
+ };
15618
+ const renderSingleButton = () => {
15667
15619
  return /* @__PURE__ */ React__default.createElement(
15668
15620
  "div",
15669
15621
  {
15670
- key: index,
15671
- className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
15672
- ${index === 1 ? "nut-range-button-wrapper-right" : ""}`,
15673
- onTouchStart: (e) => {
15674
- if (typeof index === "number") {
15675
- setButtonIndex(index);
15676
- }
15677
- onTouchStart(e);
15678
- },
15679
- onTouchMove: (e) => onTouchMove(e),
15622
+ className: "nut-range-button-wrapper",
15623
+ onTouchStart,
15624
+ onTouchMove,
15680
15625
  onTouchEnd,
15681
15626
  onTouchCancel: onTouchEnd,
15682
15627
  onClick: (e) => e.stopPropagation()
15683
15628
  },
15684
- renderButton(index)
15629
+ renderButton()
15685
15630
  );
15686
- }) : /* @__PURE__ */ React__default.createElement(
15687
- "div",
15688
- {
15689
- className: "nut-range-button-wrapper",
15690
- onTouchStart: (e) => onTouchStart(e),
15691
- onTouchMove: (e) => onTouchMove(e),
15692
- onTouchEnd,
15693
- onTouchCancel: onTouchEnd,
15694
- onClick: (e) => e.stopPropagation()
15695
- },
15696
- renderButton()
15697
- ))), maxDescription !== null && /* @__PURE__ */ React__default.createElement("div", { className: "max" }, maxDescription || max));
15631
+ };
15632
+ const renderMark = () => {
15633
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, marksList.length > 0 && /* @__PURE__ */ React__default.createElement("div", { className: "nut-range-mark" }, marksList.map((mark) => {
15634
+ return /* @__PURE__ */ React__default.createElement(
15635
+ "span",
15636
+ {
15637
+ key: mark,
15638
+ className: markClassName(mark),
15639
+ style: marksStyle(mark)
15640
+ },
15641
+ Array.isArray(marks) ? marksRef.current[mark] : marks[mark],
15642
+ /* @__PURE__ */ React__default.createElement(
15643
+ "span",
15644
+ {
15645
+ className: classNames("nut-range-tick", {
15646
+ active: tickClass(mark)
15647
+ })
15648
+ }
15649
+ )
15650
+ );
15651
+ })));
15652
+ };
15653
+ return /* @__PURE__ */ React__default.createElement("div", { className: containerClasses }, minDescription !== null && /* @__PURE__ */ React__default.createElement("div", { className: "min" }, minDescription || min), /* @__PURE__ */ React__default.createElement("div", { ref: root2, className: classes, onClick: (e) => click(e) }, renderMark(), /* @__PURE__ */ React__default.createElement("div", { className: "nut-range-bar", style: barStyle() }, range3 ? renderRangeButton() : renderSingleButton())), maxDescription !== null && /* @__PURE__ */ React__default.createElement("div", { className: "max" }, maxDescription || max));
15698
15654
  };
15699
15655
  Range.displayName = "NutRange";
15700
15656
  const defaultProps$N = {
@@ -17345,6 +17301,18 @@ const Content = (props) => {
17345
17301
  );
17346
17302
  };
17347
17303
  Content.displayName = "NutContent";
17304
+ const defaultDialogProps = {
17305
+ ...ComponentDefaults,
17306
+ overlay: true,
17307
+ overlayStyle: {},
17308
+ overlayClassName: "",
17309
+ onCancel: () => {
17310
+ },
17311
+ onClose: () => {
17312
+ },
17313
+ onOverlayClick: (e) => true,
17314
+ ...defaultOverlayProps
17315
+ };
17348
17316
  const DialogWrap = (props) => {
17349
17317
  const {
17350
17318
  visible,
@@ -17386,6 +17354,7 @@ const DialogWrap = (props) => {
17386
17354
  /* @__PURE__ */ React__default.createElement(Content, { ...props, visible })
17387
17355
  ));
17388
17356
  };
17357
+ DialogWrap.defaultProps = defaultDialogProps;
17389
17358
  DialogWrap.displayName = "NutDialogWrap";
17390
17359
  const defaultProps$E = {
17391
17360
  ...ComponentDefaults,
@@ -18952,7 +18921,6 @@ const defaultProps$v = {
18952
18921
  };
18953
18922
  const classPrefix$9 = `nut-avatar`;
18954
18923
  const Avatar = (props) => {
18955
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
18956
18924
  const {
18957
18925
  children,
18958
18926
  size,
@@ -18978,9 +18946,10 @@ const Avatar = (props) => {
18978
18946
  const avatarRef = useRef(null);
18979
18947
  const parent = useContext(AvatarContext);
18980
18948
  const sizeValue = ["large", "normal", "small"];
18949
+ const { propAvatarGroup, avatarGroupRef } = parent;
18981
18950
  const classes = classNames({
18982
- [`nut-avatar-${((_a = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _a.size) || size || "normal"}`]: true,
18983
- [`nut-avatar-${((_b = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _b.shape) || shape}`]: true
18951
+ [`nut-avatar-${(propAvatarGroup == null ? void 0 : propAvatarGroup.size) || size || "normal"}`]: true,
18952
+ [`nut-avatar-${(propAvatarGroup == null ? void 0 : propAvatarGroup.shape) || shape}`]: true
18984
18953
  });
18985
18954
  const cls = classNames(classPrefix$9, classes, className);
18986
18955
  const styles = {
@@ -18988,45 +18957,45 @@ const Avatar = (props) => {
18988
18957
  height: sizeValue.indexOf(size) > -1 ? "" : `${size}px`,
18989
18958
  backgroundColor: `${background}`,
18990
18959
  color,
18991
- 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` : "",
18992
- zIndex: ((_e = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _e.level) === "right" ? `${Math.abs(maxSum - avatarIndex)}` : "",
18960
+ marginLeft: avatarIndex !== 1 && (propAvatarGroup == null ? void 0 : propAvatarGroup.gap) ? `${propAvatarGroup == null ? void 0 : propAvatarGroup.gap}px` : "",
18961
+ zIndex: (propAvatarGroup == null ? void 0 : propAvatarGroup.level) === "right" ? `${Math.abs(maxSum - avatarIndex)}` : "",
18993
18962
  ...style
18994
18963
  };
18995
18964
  const maxStyles = {
18996
- backgroundColor: `${(_f = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _f.maxBackground}`,
18997
- color: `${(_g = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _g.maxColor}`
18998
- };
18965
+ backgroundColor: `${propAvatarGroup == null ? void 0 : propAvatarGroup.maxBackground}`,
18966
+ color: `${propAvatarGroup == null ? void 0 : propAvatarGroup.maxColor}`
18967
+ };
18968
+ const avatarLength = useCallback(
18969
+ (children2) => {
18970
+ var _a, _b;
18971
+ for (let i2 = 0; i2 < children2.length; i2++) {
18972
+ if (children2[i2] && children2[i2].classList && children2[i2].classList[0] === "nut-avatar") {
18973
+ children2[i2].setAttribute("data-index", i2 + 1);
18974
+ }
18975
+ }
18976
+ const index = Number((_b = (_a = avatarRef.current) == null ? void 0 : _a.dataset) == null ? void 0 : _b.index);
18977
+ const maxCount = propAvatarGroup == null ? void 0 : propAvatarGroup.max;
18978
+ setMaxSum(children2.length);
18979
+ setAvatarIndex(index);
18980
+ if (index === children2.length && index !== maxCount && children2.length > maxCount) {
18981
+ setShowMax(true);
18982
+ }
18983
+ },
18984
+ [propAvatarGroup == null ? void 0 : propAvatarGroup.max]
18985
+ );
18999
18986
  useEffect(() => {
19000
- var _a2;
19001
- const avatarChildren = (_a2 = parent == null ? void 0 : parent.avatarGroupRef) == null ? void 0 : _a2.current.children;
18987
+ const avatarChildren = avatarGroupRef == null ? void 0 : avatarGroupRef.current.children;
19002
18988
  if (avatarChildren) {
19003
18989
  avatarLength(avatarChildren);
19004
18990
  }
19005
- }, []);
19006
- const avatarLength = (children2) => {
19007
- var _a2, _b2, _c2;
19008
- for (let i2 = 0; i2 < children2.length; i2++) {
19009
- if (children2[i2] && children2[i2].classList && children2[i2].classList[0] === "nut-avatar") {
19010
- children2[i2].setAttribute("data-index", i2 + 1);
19011
- }
19012
- }
19013
- const index = Number((_b2 = (_a2 = avatarRef == null ? void 0 : avatarRef.current) == null ? void 0 : _a2.dataset) == null ? void 0 : _b2.index);
19014
- const maxCount = (_c2 = parent == null ? void 0 : parent.propAvatarGroup) == null ? void 0 : _c2.max;
19015
- setMaxSum(children2.length);
19016
- setAvatarIndex(index);
19017
- if (index === children2.length && index !== maxCount && children2.length > maxCount) {
19018
- setShowMax(true);
19019
- }
19020
- };
18991
+ }, [avatarLength, avatarGroupRef]);
19021
18992
  const errorEvent = () => {
19022
- if (onError) {
19023
- onError();
19024
- }
18993
+ onError && onError();
19025
18994
  };
19026
18995
  const clickAvatar = (e) => {
19027
18996
  onClick && onClick(e);
19028
18997
  };
19029
- return /* @__PURE__ */ React__default.createElement(React__default.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__default.createElement(
18998
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, (showMax || !(propAvatarGroup == null ? void 0 : propAvatarGroup.max) || avatarIndex <= (propAvatarGroup == null ? void 0 : propAvatarGroup.max)) && /* @__PURE__ */ React__default.createElement(
19030
18999
  "div",
19031
19000
  {
19032
19001
  className: cls,
@@ -19035,7 +19004,7 @@ const Avatar = (props) => {
19035
19004
  onClick: clickAvatar,
19036
19005
  ref: avatarRef
19037
19006
  },
19038
- (!((_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__default.createElement(React__default.Fragment, null, src && /* @__PURE__ */ React__default.createElement(
19007
+ (!(propAvatarGroup == null ? void 0 : propAvatarGroup.max) || avatarIndex <= (propAvatarGroup == null ? void 0 : propAvatarGroup.max)) && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, src && /* @__PURE__ */ React__default.createElement(
19039
19008
  Image$1,
19040
19009
  {
19041
19010
  className: "avatar-img",
@@ -19048,7 +19017,7 @@ const Avatar = (props) => {
19048
19017
  ...icon.props,
19049
19018
  className: `${icon.props.className || ""} icon`
19050
19019
  }) : null, children && /* @__PURE__ */ React__default.createElement("span", { className: "text" }, children), !src && !icon && !children && /* @__PURE__ */ React__default.createElement(i, { className: "icon" })),
19051
- showMax && /* @__PURE__ */ React__default.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)}`)
19020
+ showMax && /* @__PURE__ */ React__default.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)}`)
19052
19021
  ));
19053
19022
  };
19054
19023
  Avatar.displayName = "NutAvatar";
@@ -19557,7 +19526,7 @@ const CountUp = (props) => {
19557
19526
  className,
19558
19527
  thousands,
19559
19528
  style,
19560
- ...reset
19529
+ ...rest
19561
19530
  } = mergeProps(defaultProps$r, props);
19562
19531
  const classPrefix2 = "nut-countup";
19563
19532
  const countupRef = useRef(null);
@@ -19570,7 +19539,7 @@ const CountUp = (props) => {
19570
19539
  return currNumber.split("");
19571
19540
  };
19572
19541
  const numerArr = useMemo$1(getShowNumber, [value, length, thousands]);
19573
- const setNumberTransform = () => {
19542
+ const setNumberTransform = useCallback(() => {
19574
19543
  if (countupRef.current) {
19575
19544
  const numberItems = countupRef.current.querySelectorAll(
19576
19545
  ".nut-countup-number"
@@ -19588,7 +19557,7 @@ const CountUp = (props) => {
19588
19557
  }
19589
19558
  });
19590
19559
  }
19591
- };
19560
+ }, [numerArr]);
19592
19561
  const numberEaseStyle = {
19593
19562
  transition: `transform ${duration}s ease-in-out`
19594
19563
  };
@@ -19599,7 +19568,7 @@ const CountUp = (props) => {
19599
19568
  return () => {
19600
19569
  window.clearTimeout(timerRef.current);
19601
19570
  };
19602
- }, [numerArr]);
19571
+ }, [numerArr, delay, setNumberTransform]);
19603
19572
  return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2} ${className}`, ref: countupRef }, /* @__PURE__ */ React__default.createElement("ul", { className: `${classPrefix2}-list` }, numerArr.map((item, idx) => {
19604
19573
  return /* @__PURE__ */ React__default.createElement(
19605
19574
  "li",