@nutui/nutui-react 2.0.0-alpha.6 → 2.0.0-alpha.8

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.
@@ -6,7 +6,7 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  var _a;
8
8
  /*!
9
- * @nutui/nutui-react v2.0.0-alpha.6 Fri May 12 2023 15:13:32 GMT+0800 (China Standard Time)
9
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:07:24 GMT+0800 (China Standard Time)
10
10
  * (c) 2023 @jdf2e.
11
11
  * Released under the MIT License.
12
12
  */
@@ -7525,7 +7525,7 @@ const useIsMounted = () => {
7525
7525
  }, []);
7526
7526
  return isMounted;
7527
7527
  };
7528
- function useForceUpdate() {
7528
+ function useForceUpdate$1() {
7529
7529
  const update2 = useState()[1];
7530
7530
  const isMounted = useIsMounted();
7531
7531
  return () => {
@@ -7786,7 +7786,7 @@ const withAnimated = (Component2, host2) => {
7786
7786
  instanceRef.current = updateRef(givenRef, value);
7787
7787
  }, [givenRef]);
7788
7788
  const [props, deps] = getAnimatedState(givenProps, host2);
7789
- const forceUpdate = useForceUpdate();
7789
+ const forceUpdate = useForceUpdate$1();
7790
7790
  const callback = () => {
7791
7791
  const instance = instanceRef.current;
7792
7792
  if (hasInstance && !instance) {
@@ -9441,7 +9441,7 @@ function useSprings(length, props, deps) {
9441
9441
  deps = [];
9442
9442
  const ref = useMemo(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
9443
9443
  const layoutId = useRef(0);
9444
- const forceUpdate = useForceUpdate();
9444
+ const forceUpdate = useForceUpdate$1();
9445
9445
  const state = useMemo(() => ({
9446
9446
  ctrls: [],
9447
9447
  queue: [],
@@ -12482,6 +12482,10 @@ function requestAniFrame() {
12482
12482
  }
12483
12483
  }
12484
12484
  const requestAniFrame$1 = requestAniFrame();
12485
+ function useForceUpdate() {
12486
+ const [, updateState] = React__default.useState();
12487
+ return React__default.useCallback(() => updateState({}), []);
12488
+ }
12485
12489
  const defaultProps$15 = {
12486
12490
  ...ComponentDefaults,
12487
12491
  tabStyle: {},
@@ -12569,15 +12573,20 @@ const Tabs = (props) => {
12569
12573
  return titles2;
12570
12574
  };
12571
12575
  const titles = useRef(getTitles());
12576
+ const forceUpdate = useForceUpdate();
12572
12577
  useEffect(() => {
12573
12578
  titles.current = getTitles();
12574
12579
  let current = "";
12575
12580
  titles.current.forEach((title2) => {
12576
- if (title2.value === value) {
12581
+ if (title2.value == value) {
12577
12582
  current = value;
12578
12583
  }
12579
12584
  });
12580
- setValue(current);
12585
+ if (current !== "" && current !== value) {
12586
+ setValue(current);
12587
+ } else {
12588
+ forceUpdate();
12589
+ }
12581
12590
  }, [children]);
12582
12591
  const classes = classNames(
12583
12592
  classPrefix$a,
@@ -12594,14 +12603,16 @@ const Tabs = (props) => {
12594
12603
  background: activeType === "line" ? activeColor : ""
12595
12604
  };
12596
12605
  useEffect(() => {
12597
- const index = titles.current.findIndex((t) => t.value === value);
12606
+ const index = titles.current.findIndex((t) => t.value == value);
12598
12607
  setContentStyle({
12599
12608
  transform: direction === "horizontal" ? `translate3d(-${index * 100}%, 0, 0)` : `translate3d( 0,-${index * 100}%, 0)`,
12600
12609
  transitionDuration: `${duration}ms`
12601
12610
  });
12602
- scrollIntoView(index);
12611
+ setTimeout(() => {
12612
+ scrollIntoView(index);
12613
+ });
12603
12614
  }, [value]);
12604
- const tabChange = (item, index) => {
12615
+ const tabChange = (item) => {
12605
12616
  onClick && onClick(item.value);
12606
12617
  if (item.disabled) {
12607
12618
  return;
@@ -12609,11 +12620,11 @@ const Tabs = (props) => {
12609
12620
  setValue(item.value);
12610
12621
  };
12611
12622
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes, ...rest, children: [
12612
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classesTitle, style: { ...tabStyle }, ref: navRef, children: !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
12623
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classesTitle, style: { ...tabStyle }, ref: navRef, children: !!title && typeof title === "function" ? title() : titles.current.map((item) => {
12613
12624
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
12614
12625
  "div",
12615
12626
  {
12616
- onClick: (e) => {
12627
+ onClick: () => {
12617
12628
  tabChange(item);
12618
12629
  },
12619
12630
  className: classNames(`${classPrefix$a}__titles-item`, {
@@ -14462,7 +14473,6 @@ const defaultProps$_ = {
14462
14473
  popup: true,
14463
14474
  visible: false,
14464
14475
  options: [],
14465
- value: [],
14466
14476
  title: "",
14467
14477
  optionKey: { textKey: "text", valueKey: "value", childrenKey: "children" },
14468
14478
  format: {},
@@ -14477,8 +14487,7 @@ const defaultProps$_ = {
14477
14487
  onChange: () => {
14478
14488
  },
14479
14489
  onPathChange: () => {
14480
- },
14481
- ...Popup.defaultProps
14490
+ }
14482
14491
  };
14483
14492
  const InternalCascader = (props, ref) => {
14484
14493
  const {
@@ -14488,6 +14497,7 @@ const InternalCascader = (props, ref) => {
14488
14497
  visible,
14489
14498
  options: options2,
14490
14499
  value,
14500
+ defaultValue,
14491
14501
  title,
14492
14502
  optionKey: optionKey2,
14493
14503
  format: format2,
@@ -14503,6 +14513,15 @@ const InternalCascader = (props, ref) => {
14503
14513
  const [tabvalue, setTabvalue] = useState("c1");
14504
14514
  const [optionsData, setOptionsData] = useState([]);
14505
14515
  const isLazy = () => state.configs.lazy && Boolean(state.configs.onLoad);
14516
+ const [innerValue, setInnerValue] = usePropsValue({
14517
+ value,
14518
+ defaultValue,
14519
+ finalValue: defaultValue,
14520
+ onChange: (val) => {
14521
+ var _a2;
14522
+ (_a2 = props.onChange) == null ? void 0 : _a2.call(props, val);
14523
+ }
14524
+ });
14506
14525
  const [state] = useState({
14507
14526
  optionsData: [],
14508
14527
  panes: [
@@ -14512,7 +14531,6 @@ const InternalCascader = (props, ref) => {
14512
14531
  paneKey: ""
14513
14532
  }
14514
14533
  ],
14515
- innerValue: value,
14516
14534
  tree: new Tree$1([], {}),
14517
14535
  tabsCursor: 0,
14518
14536
  // 选中的tab项
@@ -14532,12 +14550,12 @@ const InternalCascader = (props, ref) => {
14532
14550
  });
14533
14551
  useEffect(() => {
14534
14552
  initData();
14535
- }, [options2]);
14553
+ }, [options2, format2]);
14536
14554
  useEffect(() => {
14537
- if (value !== state.innerValue) {
14538
- state.innerValue = value;
14555
+ if (defaultValue && defaultValue !== innerValue) {
14556
+ setInnerValue(defaultValue);
14539
14557
  }
14540
- }, [value]);
14558
+ }, [defaultValue]);
14541
14559
  const initData = async () => {
14542
14560
  state.lazyLoadMap.clear();
14543
14561
  if (format2 && Object.keys(format2).length > 0) {
@@ -14572,24 +14590,24 @@ const InternalCascader = (props, ref) => {
14572
14590
  setOptionsData(state.panes);
14573
14591
  };
14574
14592
  const syncValue = async () => {
14575
- const currentValue2 = state.innerValue;
14576
- if (currentValue2 === void 0 || !state.tree.nodes.length) {
14593
+ const currentValue = innerValue;
14594
+ if (currentValue === void 0 || currentValue !== defaultValue || !state.tree.nodes.length) {
14577
14595
  return;
14578
14596
  }
14579
- if (currentValue2.length === 0) {
14597
+ if (currentValue.length === 0) {
14580
14598
  state.tabsCursor = 0;
14581
14599
  return;
14582
14600
  }
14583
- let needToSync = currentValue2;
14584
- if (isLazy() && Array.isArray(currentValue2) && currentValue2.length) {
14601
+ let needToSync = currentValue;
14602
+ if (isLazy() && Array.isArray(currentValue) && currentValue.length) {
14585
14603
  needToSync = [];
14586
14604
  const parent = state.tree.nodes.find(
14587
- (node) => node.value === currentValue2[0]
14605
+ (node) => node.value === currentValue[0]
14588
14606
  );
14589
14607
  if (parent) {
14590
14608
  needToSync = [parent.value];
14591
14609
  state.initLoading = true;
14592
- const last = await currentValue2.slice(1).reduce(async (p, value2) => {
14610
+ const last = await currentValue.slice(1).reduce(async (p, value2) => {
14593
14611
  var _a2;
14594
14612
  const parent2 = await p;
14595
14613
  await invokeLazyLoad(parent2);
@@ -14605,7 +14623,7 @@ const InternalCascader = (props, ref) => {
14605
14623
  state.initLoading = false;
14606
14624
  }
14607
14625
  }
14608
- if (needToSync.length && currentValue2 === value) {
14626
+ if (needToSync.length && currentValue === defaultValue) {
14609
14627
  const pathNodes = state.tree.getPathNodesByValue(needToSync);
14610
14628
  pathNodes.forEach((node, index) => {
14611
14629
  state.tabsCursor = index;
@@ -14662,6 +14680,7 @@ const InternalCascader = (props, ref) => {
14662
14680
  const optionParams = pathNodes.map((item) => item.value);
14663
14681
  onChange(optionParams, pathNodes);
14664
14682
  onPathChange(optionParams, pathNodes);
14683
+ setInnerValue(optionParams);
14665
14684
  }
14666
14685
  setOptionsData(state.panes);
14667
14686
  close();
@@ -18433,475 +18452,167 @@ const Radio = (props) => {
18433
18452
  Radio.defaultProps = defaultProps$N;
18434
18453
  Radio.displayName = "NutRadio";
18435
18454
  Radio.RadioGroup = RadioGroup;
18436
- const fullClone = {
18437
- ...ReactDOM
18455
+ const defaultProps$M = {
18456
+ ...ComponentDefaults,
18457
+ range: false,
18458
+ min: 0,
18459
+ max: 100,
18460
+ step: 1,
18461
+ vertical: false,
18462
+ marks: {}
18438
18463
  };
18439
- const { version, render: reactRender, unmountComponentAtNode } = fullClone;
18440
- let createRoot;
18441
- try {
18442
- const mainVersion = Number((version || "").split(".")[0]);
18443
- if (mainVersion >= 18 && fullClone.createRoot) {
18444
- createRoot = fullClone.createRoot;
18445
- }
18446
- } catch (e) {
18447
- }
18448
- function toggleWarning(skip) {
18449
- const { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } = fullClone;
18450
- if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === "object") {
18451
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
18452
- }
18453
- }
18454
- const MARK = "__nutui_react_root__";
18455
- function legacyRender(node, container) {
18456
- reactRender(node, container);
18457
- }
18458
- function concurrentRender(node, container) {
18459
- toggleWarning(true);
18460
- const root2 = container[MARK] || createRoot(container);
18461
- toggleWarning(false);
18462
- root2.render(node);
18463
- container[MARK] = root2;
18464
- }
18465
- function render(node, container) {
18466
- if (createRoot) {
18467
- concurrentRender(node, container);
18468
- return;
18469
- }
18470
- legacyRender(node, container);
18471
- }
18472
- function legacyUnmount(container) {
18473
- return unmountComponentAtNode(container);
18474
- }
18475
- async function concurrentUnmount(container) {
18476
- return Promise.resolve().then(() => {
18477
- var _a2;
18478
- (_a2 = container[MARK]) == null ? void 0 : _a2.unmount();
18479
- delete container[MARK];
18464
+ const Range = (props) => {
18465
+ const {
18466
+ className,
18467
+ range: range3,
18468
+ disabled,
18469
+ button,
18470
+ vertical,
18471
+ marks,
18472
+ onChange,
18473
+ onStart,
18474
+ onEnd,
18475
+ minDescription,
18476
+ maxDescription,
18477
+ currentDescription,
18478
+ min,
18479
+ max,
18480
+ step,
18481
+ value,
18482
+ defaultValue
18483
+ } = { ...defaultProps$M, ...props };
18484
+ const classPrefix2 = "nut-range";
18485
+ const [buttonIndex, setButtonIndex] = useState(0);
18486
+ const [dragStatus, setDragStatus] = useState("start");
18487
+ const touch = useTouch();
18488
+ const root2 = useRef(null);
18489
+ const [marksList, setMarksList] = useState([]);
18490
+ const [startValue, setStartValue] = useState(0);
18491
+ const handleChange = (value2) => {
18492
+ onChange && onChange(value2);
18493
+ };
18494
+ const [current, setCurrent] = usePropsValue({
18495
+ value,
18496
+ defaultValue,
18497
+ finalValue: 0,
18498
+ onChange: handleChange
18480
18499
  });
18481
- }
18482
- function unmount(container) {
18483
- if (createRoot) {
18484
- return concurrentUnmount(container);
18485
- }
18486
- return legacyUnmount(container);
18487
- }
18488
- let Notification$1 = (_a = class extends React.PureComponent {
18489
- constructor(props) {
18490
- super(props);
18491
- __publicField(this, "closeTimer");
18492
- this.close = this.close.bind(this);
18493
- this.startCloseTimer = this.startCloseTimer.bind(this);
18494
- this.clearCloseTimer = this.clearCloseTimer.bind(this);
18495
- this.close = this.close.bind(this);
18496
- this.clickCover = this.clickCover.bind(this);
18497
- }
18498
- close() {
18499
- this.clearCloseTimer();
18500
- this.props.onClose();
18501
- }
18502
- startCloseTimer() {
18503
- const { duration } = this.props;
18504
- if (duration) {
18505
- this.closeTimer = window.setTimeout(() => {
18506
- this.close();
18507
- }, duration * 1e3);
18500
+ const [exactValue, setEaxctValue] = useState(
18501
+ () => value || defaultValue || 0
18502
+ );
18503
+ useEffect(() => {
18504
+ if (marks) {
18505
+ const marksKeys = Object.keys(marks);
18506
+ const list = marksKeys.map(parseFloat).sort((a2, b) => a2 - b).filter((point) => point >= min && point <= max);
18507
+ setMarksList(list);
18508
18508
  }
18509
- }
18510
- clearCloseTimer() {
18511
- if (this.closeTimer) {
18512
- clearTimeout(this.closeTimer);
18513
- this.closeTimer = -1;
18509
+ }, [marks]);
18510
+ const scope = () => {
18511
+ return max - min;
18512
+ };
18513
+ const classes = classNames(classPrefix2, {
18514
+ [`${classPrefix2}-disabled`]: disabled,
18515
+ [`${classPrefix2}-vertical`]: vertical
18516
+ });
18517
+ const containerClasses = classNames(`${classPrefix2}-container`, className, {
18518
+ [`${classPrefix2}-container-vertical`]: vertical
18519
+ });
18520
+ const markClassName = useCallback(
18521
+ (mark) => {
18522
+ const classPrefix22 = "nut-range-mark";
18523
+ let lowerBound = min;
18524
+ let upperBound = max;
18525
+ if (range3 && Array.isArray(current)) {
18526
+ lowerBound = current[0];
18527
+ upperBound = current[1];
18528
+ } else {
18529
+ upperBound = current;
18530
+ }
18531
+ const isActive = mark <= upperBound && mark >= lowerBound;
18532
+ return [
18533
+ `${classPrefix22}-text`,
18534
+ `${isActive ? `${classPrefix22}-text-active` : ""}`
18535
+ ].join(" ");
18536
+ },
18537
+ [range3, current, min, max]
18538
+ );
18539
+ const isRange = (val) => {
18540
+ return !!range3 && Array.isArray(val);
18541
+ };
18542
+ const calcMainAxis = () => {
18543
+ const modelVal = current;
18544
+ if (isRange(modelVal)) {
18545
+ return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
18514
18546
  }
18515
- }
18516
- clickCover() {
18517
- const { closeOnClickOverlay } = this.props;
18518
- if (closeOnClickOverlay) {
18519
- this.close();
18547
+ return `${(modelVal - min) * 100 / scope()}%`;
18548
+ };
18549
+ const calcOffset = () => {
18550
+ const modelVal = current;
18551
+ if (isRange(modelVal)) {
18552
+ return `${(modelVal[0] - min) * 100 / scope()}%`;
18520
18553
  }
18521
- }
18522
- componentDidMount() {
18523
- this.startCloseTimer();
18524
- }
18525
- componentWillUnmount() {
18526
- this.clearCloseTimer();
18527
- }
18528
- render() {
18529
- const {
18530
- id,
18531
- style,
18532
- icon,
18533
- title,
18534
- msg,
18535
- bottom,
18536
- center,
18537
- bgColor,
18538
- coverColor,
18539
- textAlignCenter,
18540
- size,
18541
- customClass,
18542
- cover,
18543
- type: type4
18544
- } = this.props;
18545
- const toastBem = cn("toast");
18546
- const classes = classNames({
18547
- "nut-toast-center": center,
18548
- "nut-toast-has-icon": icon,
18549
- "nut-toast-cover": cover,
18550
- "nut-toast-loading": type4 === "loading",
18551
- [`${customClass}`]: true,
18552
- [`nut-toast-${size}`]: true
18553
- });
18554
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
18555
- "div",
18556
- {
18557
- className: `${toastBem()} ${classes}`,
18558
- id: `toast-${id}`,
18559
- style: {
18560
- bottom: center ? "auto" : `${bottom}`,
18561
- backgroundColor: cover ? coverColor : "",
18562
- ...style
18563
- },
18564
- onClick: () => {
18565
- this.clickCover();
18566
- },
18567
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
18568
- "div",
18569
- {
18570
- className: toastBem("inner"),
18571
- style: {
18572
- textAlign: textAlignCenter ? "center" : "left",
18573
- backgroundColor: bgColor
18574
- },
18575
- children: [
18576
- icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: toastBem("icon-wrapper"), children: icon }) : null,
18577
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-toast-title", children: title }) : null,
18578
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: toastBem("text"), children: msg })
18579
- ]
18580
- }
18581
- )
18582
- }
18583
- ) });
18584
- }
18585
- }, __publicField(_a, "newInstance"), _a);
18586
- Notification$1.newInstance = (properties, callback) => {
18587
- const element = document.createElement("div");
18588
- if (properties.id) {
18589
- element.setAttribute("id", `${properties.id}`);
18590
- }
18591
- document.body.appendChild(element);
18592
- let called = false;
18593
- function ref(instance) {
18594
- if (called) {
18595
- return;
18596
- }
18597
- called = true;
18598
- callback({
18599
- component: instance,
18600
- destroy() {
18601
- unmount(element);
18602
- element && element.parentNode && element.parentNode.removeChild(element);
18603
- }
18604
- });
18605
- }
18606
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
18607
- };
18608
- let messageInstance$1 = null;
18609
- const options$1 = {
18610
- msg: "",
18611
- id: "",
18612
- style: {},
18613
- duration: 1.5,
18614
- // 时长,duration为0则一直展示
18615
- center: true,
18616
- // toast是否居中展示
18617
- type: "text",
18618
- title: "",
18619
- customClass: "",
18620
- // 自定义样式名
18621
- bottom: "30px",
18622
- // center为false时生效,距离底部位置
18623
- size: "base",
18624
- // 设置字体大小,默认base,可选large\small\base
18625
- icon: null,
18626
- iconSize: "20",
18627
- textAlignCenter: true,
18628
- // 文字是否居中显示,true为居中,false为left
18629
- loadingRotate: true,
18630
- // 未实现
18631
- bgColor: "rgba(0, 0, 0, .8)",
18632
- onClose: () => {
18633
- },
18634
- cover: false,
18635
- // 是否展示透明遮罩层
18636
- coverColor: "rgba(0, 0, 0, 0)",
18637
- // 遮罩颜色设定
18638
- closeOnClickOverlay: false
18639
- // 是否点击遮罩可关闭
18640
- };
18641
- function getInstance$1(props, callback) {
18642
- if (messageInstance$1) {
18643
- messageInstance$1.destroy();
18644
- messageInstance$1 = null;
18645
- }
18646
- Notification$1.newInstance(props, (notification) => {
18647
- return callback && callback(notification);
18648
- });
18649
- }
18650
- function notice$1(opts) {
18651
- function close() {
18652
- if (messageInstance$1) {
18653
- messageInstance$1.destroy();
18654
- messageInstance$1 = null;
18655
- }
18656
- }
18657
- const opts2 = { ...options$1, ...opts, onClose: close };
18658
- getInstance$1(opts2, (notification) => {
18659
- messageInstance$1 = notification;
18660
- });
18661
- }
18662
- const errorMsg$1 = (msg) => {
18663
- if (!msg) {
18664
- console.warn("[NutUI Toast]: msg cannot be null");
18665
- }
18666
- };
18667
- const Toast = {
18668
- text(msg, option = {}) {
18669
- errorMsg$1(msg);
18670
- return notice$1({ msg, type: "text", ...option });
18671
- },
18672
- success(msg, option = {}) {
18673
- errorMsg$1(msg);
18674
- return notice$1({ msg, icon: "success", type: "success", ...option });
18675
- },
18676
- fail(msg, option = {}) {
18677
- errorMsg$1(msg);
18678
- return notice$1({ msg, icon: "failure", type: "fail", ...option });
18679
- },
18680
- loading(msg, option = {}) {
18681
- errorMsg$1(msg);
18682
- return notice$1({ msg, icon: /* @__PURE__ */ jsxRuntimeExports.jsx(k$3, {}), type: "loading", ...option });
18683
- },
18684
- warn(msg, option = {}) {
18685
- errorMsg$1(msg);
18686
- return notice$1({ msg, icon: "tips", type: "warn", ...option });
18687
- },
18688
- customIcon(msg, option = {}) {
18689
- errorMsg$1(msg);
18690
- return notice$1({ msg, ...option });
18691
- },
18692
- hide() {
18693
- if (messageInstance$1) {
18694
- messageInstance$1.destroy();
18695
- messageInstance$1 = null;
18696
- }
18697
- }
18698
- };
18699
- const defaultProps$M = {
18700
- range: false,
18701
- hiddenRange: false,
18702
- hiddenTag: false,
18703
- min: 0,
18704
- max: 100,
18705
- step: 1,
18706
- modelValue: 0,
18707
- vertical: false,
18708
- marks: {}
18709
- };
18710
- let startValue;
18711
- let currentValue;
18712
- const Range = (props) => {
18713
- const { locale } = useConfig();
18714
- const {
18715
- className,
18716
- range: range3,
18717
- disabled,
18718
- activeColor,
18719
- inactiveColor,
18720
- buttonColor,
18721
- hiddenRange,
18722
- hiddenTag,
18723
- modelValue,
18724
- button,
18725
- vertical,
18726
- marks,
18727
- dragStart,
18728
- dragEnd,
18729
- onChange,
18730
- onDragStart,
18731
- onDragEnd,
18732
- minDesc,
18733
- maxDesc,
18734
- curValueDesc
18735
- } = { ...defaultProps$M, ...props };
18736
- let { min, max, step } = { ...defaultProps$M, ...props };
18737
- min = Number(min);
18738
- max = Number(max);
18739
- step = Number(step);
18740
- const [buttonIndex, SetButtonIndex] = useState(0);
18741
- const [initValue, SetInitValue] = useState();
18742
- const [dragStatus, SetDragStatus] = useState("start");
18743
- const touch = useTouch();
18744
- const root2 = useRef(null);
18745
- const [marksList, SetMarksList] = useState([]);
18746
- useEffect(() => {
18747
- if (typeof modelValue === "number") {
18748
- if (!range3 && (modelValue < min || modelValue > max)) {
18749
- SetInitValue(0);
18750
- Toast.text(`${modelValue} ${locale.range.rangeText}`);
18751
- return;
18752
- }
18753
- SetInitValue(modelValue);
18754
- }
18755
- }, [modelValue]);
18756
- useEffect(() => {
18757
- if (marks) {
18758
- const marksKeys = Object.keys(marks);
18759
- const list = marksKeys.map(parseFloat).sort((a2, b) => a2 - b).filter((point) => point >= min && point <= max);
18760
- SetMarksList(list);
18761
- }
18762
- }, [marks]);
18763
- const scope = () => {
18764
- return Number(max) - Number(min);
18765
- };
18766
- const classes = useCallback(() => {
18767
- const prefixCls2 = "nut-range";
18768
- return [
18769
- prefixCls2,
18770
- `${disabled ? `${prefixCls2}-disabled` : ""}`,
18771
- `${vertical ? `${prefixCls2}-vertical` : ""}`,
18772
- `${!hiddenRange ? `${prefixCls2}-show-number` : ""}`
18773
- ].filter(Boolean).join(" ");
18774
- }, [disabled, vertical, hiddenRange]);
18775
- const containerClasses = useCallback(() => {
18776
- const prefixCls2 = "nut-range-container";
18777
- return [prefixCls2, `${vertical ? `${prefixCls2}-vertical` : ""}`, className].filter(Boolean).join(" ");
18778
- }, [vertical, className]);
18779
- const markClassName = useCallback(
18780
- (mark) => {
18781
- const classPrefix2 = "nut-range-mark";
18782
- let lowerBound = Number(min);
18783
- let upperBound = Number(max);
18784
- if (range3) {
18785
- const [left, right] = modelValue;
18786
- lowerBound = left;
18787
- upperBound = right;
18788
- } else {
18789
- upperBound = modelValue;
18790
- }
18791
- const isActive = mark <= upperBound && mark >= lowerBound;
18792
- return [
18793
- `${classPrefix2}-text`,
18794
- `${isActive ? `${classPrefix2}-text-active` : ""}`
18795
- ].filter(Boolean).join(" ");
18796
- },
18797
- [range3, modelValue, min, max]
18798
- );
18799
- const [rangeName, setRangeName] = useState(classes());
18800
- const [containerName, setContainerName] = useState(containerClasses());
18801
- useEffect(() => {
18802
- setRangeName(classes());
18803
- setContainerName(containerClasses());
18804
- }, [classes, containerClasses]);
18805
- const wrapperStyle = () => {
18806
- return {
18807
- background: inactiveColor
18808
- };
18809
- };
18810
- const buttonStyle = () => {
18811
- return {
18812
- borderColor: buttonColor
18813
- };
18814
- };
18815
- const isRange = (val) => {
18816
- return !!range3 && Array.isArray(val);
18817
- };
18818
- const calcMainAxis = () => {
18819
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18820
- if (isRange(modelVal)) {
18821
- return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
18822
- }
18823
- return `${(modelVal - Number(min)) * 100 / scope()}%`;
18824
- };
18825
- const calcOffset = () => {
18826
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18827
- if (isRange(modelVal)) {
18828
- return `${(modelVal[0] - Number(min)) * 100 / scope()}%`;
18829
- }
18830
- return `0%`;
18831
- };
18832
- const barStyle = () => {
18833
- if (vertical) {
18834
- return {
18835
- height: calcMainAxis(),
18836
- top: calcOffset(),
18837
- background: activeColor,
18838
- transition: dragStatus ? "none" : void 0
18839
- };
18554
+ return `0%`;
18555
+ };
18556
+ const barStyle = () => {
18557
+ if (vertical) {
18558
+ return {
18559
+ height: calcMainAxis(),
18560
+ top: calcOffset(),
18561
+ transition: dragStatus ? "none" : void 0
18562
+ };
18840
18563
  }
18841
18564
  return {
18842
18565
  width: calcMainAxis(),
18843
18566
  left: calcOffset(),
18844
- background: activeColor,
18845
18567
  transition: dragStatus ? "none" : void 0
18846
18568
  };
18847
18569
  };
18848
18570
  const marksStyle = (mark) => {
18849
18571
  let style = {
18850
- left: `${(mark - Number(min)) / scope() * 100}%`
18572
+ left: `${(mark - min) / scope() * 100}%`
18851
18573
  };
18852
18574
  if (vertical) {
18853
18575
  style = {
18854
- top: `${(mark - Number(min)) / scope() * 100}%`
18576
+ top: `${(mark - min) / scope() * 100}%`
18855
18577
  };
18856
18578
  }
18857
18579
  return style;
18858
18580
  };
18859
- const tickStyle = (mark) => {
18860
- let lowerBound = Number(min);
18861
- let upperBound = Number(max);
18862
- if (range3) {
18863
- const [left, right] = modelValue;
18864
- lowerBound = left;
18865
- upperBound = right;
18581
+ const tickClass = (mark) => {
18582
+ if (range3 && Array.isArray(current)) {
18583
+ return mark <= current[1] && mark >= current[0];
18866
18584
  }
18867
- const isActive = mark <= upperBound && mark >= lowerBound;
18868
- const style = {
18869
- background: !isActive ? inactiveColor : activeColor
18870
- };
18871
- return style;
18585
+ return mark <= current;
18872
18586
  };
18873
- const format2 = (value) => {
18874
- value = Math.max(+min, Math.min(value, +max));
18875
- return Math.round(value / +step) * +step;
18587
+ const format2 = (value2) => {
18588
+ value2 = Math.max(+min, Math.min(value2, +max));
18589
+ return Math.round(value2 / +step) * +step;
18876
18590
  };
18877
18591
  const isSameValue = (newValue, oldValue) => {
18878
18592
  return JSON.stringify(newValue) === JSON.stringify(oldValue);
18879
18593
  };
18880
- const handleOverlap = (value) => {
18881
- if (value[0] > value[1]) {
18882
- return value.slice(0).reverse();
18594
+ const handleOverlap = (value2) => {
18595
+ if (value2[0] > value2[1]) {
18596
+ return value2.slice(0).reverse();
18883
18597
  }
18884
- return value;
18598
+ return value2;
18885
18599
  };
18886
- const updateValue = (value, end) => {
18887
- if (isRange(value)) {
18888
- value = handleOverlap(value).map(format2);
18600
+ const updateValue = (value2, end) => {
18601
+ if (isRange(value2)) {
18602
+ value2 = handleOverlap(value2).map(format2);
18889
18603
  } else {
18890
- value = format2(value);
18891
- }
18892
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18893
- if (!isSameValue(value, modelVal)) {
18894
- SetInitValue(value);
18604
+ value2 = format2(value2);
18895
18605
  }
18896
- if ((marks || end) && !isSameValue(value, startValue)) {
18897
- onChange && onChange(value);
18606
+ if (!isSameValue(value2, current)) {
18607
+ setCurrent(value2);
18898
18608
  }
18609
+ end && onEnd && onEnd(value2);
18899
18610
  };
18900
18611
  const click = (event) => {
18901
18612
  if (disabled || !root2.current) {
18902
18613
  return;
18903
18614
  }
18904
- SetDragStatus("");
18615
+ setDragStatus("");
18905
18616
  const rect = getRect(root2.current);
18906
18617
  let delta = event.clientX - rect.left;
18907
18618
  let total = rect.width;
@@ -18909,18 +18620,18 @@ const Range = (props) => {
18909
18620
  delta = event.clientY - rect.top;
18910
18621
  total = rect.height;
18911
18622
  }
18912
- const value = Number(min) + delta / total * scope();
18913
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18914
- if (isRange(currentValue)) {
18915
- const [left, right] = currentValue;
18623
+ const value2 = min + delta / total * scope();
18624
+ setEaxctValue(current);
18625
+ if (isRange(current)) {
18626
+ const [left, right] = current;
18916
18627
  const middle = (left + right) / 2;
18917
- if (value <= middle) {
18918
- updateValue([value, right], true);
18628
+ if (value2 <= middle) {
18629
+ updateValue([value2, right], true);
18919
18630
  } else {
18920
- updateValue([left, value], true);
18631
+ updateValue([left, value2], true);
18921
18632
  }
18922
18633
  } else {
18923
- updateValue(value, true);
18634
+ updateValue(value2, true);
18924
18635
  }
18925
18636
  };
18926
18637
  const onTouchStart = (event) => {
@@ -18928,24 +18639,24 @@ const Range = (props) => {
18928
18639
  return;
18929
18640
  }
18930
18641
  touch.start(event);
18931
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18932
- if (isRange(currentValue)) {
18933
- startValue = currentValue.map(format2);
18642
+ setEaxctValue(current);
18643
+ if (isRange(current)) {
18644
+ setStartValue(current.map(format2));
18934
18645
  } else {
18935
- startValue = format2(currentValue);
18646
+ setStartValue(format2(current));
18936
18647
  }
18937
- SetDragStatus("start");
18648
+ setDragStatus("start");
18938
18649
  };
18939
18650
  const onTouchMove = (event) => {
18651
+ event.stopPropagation();
18940
18652
  if (disabled || !root2.current) {
18941
18653
  return;
18942
18654
  }
18943
18655
  if (dragStatus === "start") {
18944
- dragStart && dragStart();
18945
- onDragStart && onDragStart();
18656
+ onStart && onStart();
18946
18657
  }
18947
18658
  touch.move(event);
18948
- SetDragStatus("draging");
18659
+ setDragStatus("draging");
18949
18660
  const rect = getRect(root2.current);
18950
18661
  let delta = touch.deltaX;
18951
18662
  let total = rect.width;
@@ -18955,121 +18666,91 @@ const Range = (props) => {
18955
18666
  total = rect.height;
18956
18667
  diff = delta / total * scope();
18957
18668
  }
18669
+ let newValue;
18958
18670
  if (isRange(startValue)) {
18959
- currentValue[buttonIndex] = startValue[buttonIndex] + diff;
18671
+ newValue = exactValue.slice();
18672
+ newValue[buttonIndex] = startValue[buttonIndex] + diff;
18960
18673
  } else {
18961
- currentValue = startValue + diff;
18674
+ newValue = startValue + diff;
18962
18675
  }
18963
- updateValue(currentValue);
18676
+ setEaxctValue(newValue);
18677
+ updateValue(newValue);
18964
18678
  };
18965
18679
  const onTouchEnd = (event) => {
18966
18680
  if (disabled) {
18967
18681
  return;
18968
18682
  }
18969
18683
  if (dragStatus === "draging") {
18970
- updateValue(currentValue, true);
18971
- dragEnd && dragEnd();
18972
- onDragEnd && onDragEnd();
18684
+ updateValue(current, true);
18973
18685
  }
18974
- SetDragStatus("");
18686
+ setDragStatus("");
18975
18687
  };
18976
18688
  const curValue = (idx) => {
18977
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18978
- const value = typeof idx === "number" ? modelVal[idx] : modelVal;
18979
- return value;
18689
+ const modelVal = current;
18690
+ const value2 = typeof idx === "number" ? modelVal[idx] : modelVal;
18691
+ return value2;
18980
18692
  };
18981
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${containerName}`, children: [
18982
- !hiddenRange ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min", children: minDesc || +min }) : null,
18983
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
18984
- "div",
18985
- {
18986
- ref: root2,
18987
- style: wrapperStyle(),
18988
- className: `${rangeName}`,
18989
- onClick: (e) => {
18990
- click(e);
18991
- },
18992
- children: [
18993
- marksList.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-mark", children: marksList.map((marks2) => {
18994
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
18995
- "span",
18996
- {
18997
- className: markClassName(marks2),
18998
- style: marksStyle(marks2),
18999
- children: [
19000
- marks2,
19001
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "nut-range-tick", style: tickStyle(marks2) })
19002
- ]
19003
- },
19004
- marks2
19005
- );
19006
- }) }) : null,
19007
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-bar", style: barStyle(), children: range3 ? [0, 1].map((item, index) => {
19008
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
19009
- "div",
19010
- {
19011
- role: "slider",
19012
- className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
18693
+ const renderButton = (index) => {
18694
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: button || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-button", children: currentDescription !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "number", children: currentDescription ? currentDescription(curValue(index)) : curValue(index) }) }) });
18695
+ };
18696
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: containerClasses, children: [
18697
+ minDescription !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min", children: minDescription || min }),
18698
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: root2, className: classes, onClick: (e) => click(e), children: [
18699
+ marksList.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-mark", children: marksList.map((marks2) => {
18700
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
18701
+ "span",
18702
+ {
18703
+ className: markClassName(marks2),
18704
+ style: marksStyle(marks2),
18705
+ children: [
18706
+ marks2,
18707
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
18708
+ "span",
18709
+ {
18710
+ className: classNames("nut-range-tick", {
18711
+ active: tickClass(marks2)
18712
+ })
18713
+ }
18714
+ )
18715
+ ]
18716
+ },
18717
+ marks2
18718
+ );
18719
+ }) }),
18720
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-bar", style: barStyle(), children: range3 ? [0, 1].map((item, index) => {
18721
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
18722
+ "div",
18723
+ {
18724
+ className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
19013
18725
  ${index === 1 ? "nut-range-button-wrapper-right" : ""}`,
19014
- tabIndex: disabled ? -1 : 0,
19015
- "aria-valuemin": +min,
19016
- "aria-valuenow": curValue(index),
19017
- "aria-valuemax": +max,
19018
- "aria-orientation": vertical ? "vertical" : "horizontal",
19019
- onTouchStart: (e) => {
19020
- if (typeof index === "number") {
19021
- SetButtonIndex(index);
19022
- }
19023
- onTouchStart(e);
19024
- },
19025
- onTouchMove: (e) => {
19026
- onTouchMove(e);
19027
- },
19028
- onTouchEnd: (e) => {
19029
- onTouchEnd();
19030
- },
19031
- onTouchCancel: (e) => {
19032
- onTouchEnd();
19033
- },
19034
- onClick: (e) => {
19035
- e.stopPropagation();
19036
- },
19037
- children: button || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-button", style: buttonStyle(), children: !hiddenTag ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "number", children: curValueDesc || curValue(index) }) : null })
19038
- },
19039
- index
19040
- );
19041
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
19042
- "div",
19043
- {
19044
- role: "slider",
19045
- className: "nut-range-button-wrapper",
19046
- tabIndex: disabled ? -1 : 0,
19047
- "aria-valuemin": +min,
19048
- "aria-valuenow": curValue(),
19049
- "aria-valuemax": +max,
19050
- "aria-orientation": vertical ? "vertical" : "horizontal",
19051
- onTouchStart: (e) => {
19052
- onTouchStart(e);
19053
- },
19054
- onTouchMove: (e) => {
19055
- onTouchMove(e);
19056
- },
19057
- onTouchEnd: (e) => {
19058
- onTouchEnd();
19059
- },
19060
- onTouchCancel: (e) => {
19061
- onTouchEnd();
19062
- },
19063
- onClick: (e) => {
19064
- e.stopPropagation();
19065
- },
19066
- children: button || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-button", style: buttonStyle(), children: !hiddenTag ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "number", children: curValueDesc || curValue() }) : null })
19067
- }
19068
- ) })
19069
- ]
19070
- }
19071
- ),
19072
- !hiddenRange ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max", children: maxDesc || +max }) : null
18726
+ onTouchStart: (e) => {
18727
+ if (typeof index === "number") {
18728
+ setButtonIndex(index);
18729
+ }
18730
+ onTouchStart(e);
18731
+ },
18732
+ onTouchMove: (e) => onTouchMove(e),
18733
+ onTouchEnd: (e) => onTouchEnd(),
18734
+ onTouchCancel: (e) => onTouchEnd(),
18735
+ onClick: (e) => e.stopPropagation(),
18736
+ children: renderButton(index)
18737
+ },
18738
+ index
18739
+ );
18740
+ }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
18741
+ "div",
18742
+ {
18743
+ className: "nut-range-button-wrapper",
18744
+ onTouchStart: (e) => onTouchStart(e),
18745
+ onTouchMove: (e) => onTouchMove(e),
18746
+ onTouchEnd: (e) => onTouchEnd(),
18747
+ onTouchCancel: (e) => onTouchEnd(),
18748
+ onClick: (e) => e.stopPropagation(),
18749
+ children: renderButton()
18750
+ }
18751
+ ) })
18752
+ ] }),
18753
+ maxDescription !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max", children: maxDescription || max })
19073
18754
  ] });
19074
18755
  };
19075
18756
  Range.defaultProps = defaultProps$M;
@@ -20573,6 +20254,58 @@ const ActionSheet = (props) => {
20573
20254
  };
20574
20255
  ActionSheet.defaultProps = defaultProps$D;
20575
20256
  ActionSheet.displayName = "NutActionSheet";
20257
+ const fullClone = {
20258
+ ...ReactDOM
20259
+ };
20260
+ const { version, render: reactRender, unmountComponentAtNode } = fullClone;
20261
+ let createRoot;
20262
+ try {
20263
+ const mainVersion = Number((version || "").split(".")[0]);
20264
+ if (mainVersion >= 18 && fullClone.createRoot) {
20265
+ createRoot = fullClone.createRoot;
20266
+ }
20267
+ } catch (e) {
20268
+ }
20269
+ function toggleWarning(skip) {
20270
+ const { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } = fullClone;
20271
+ if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === "object") {
20272
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
20273
+ }
20274
+ }
20275
+ const MARK = "__nutui_react_root__";
20276
+ function legacyRender(node, container) {
20277
+ reactRender(node, container);
20278
+ }
20279
+ function concurrentRender(node, container) {
20280
+ toggleWarning(true);
20281
+ const root2 = container[MARK] || createRoot(container);
20282
+ toggleWarning(false);
20283
+ root2.render(node);
20284
+ container[MARK] = root2;
20285
+ }
20286
+ function render(node, container) {
20287
+ if (createRoot) {
20288
+ concurrentRender(node, container);
20289
+ return;
20290
+ }
20291
+ legacyRender(node, container);
20292
+ }
20293
+ function legacyUnmount(container) {
20294
+ return unmountComponentAtNode(container);
20295
+ }
20296
+ async function concurrentUnmount(container) {
20297
+ return Promise.resolve().then(() => {
20298
+ var _a2;
20299
+ (_a2 = container[MARK]) == null ? void 0 : _a2.unmount();
20300
+ delete container[MARK];
20301
+ });
20302
+ }
20303
+ function unmount(container) {
20304
+ if (createRoot) {
20305
+ return concurrentUnmount(container);
20306
+ }
20307
+ return legacyUnmount(container);
20308
+ }
20576
20309
  function ConfirmDialog(props) {
20577
20310
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Dialog, { ...props, children: props.content });
20578
20311
  }
@@ -21619,7 +21352,7 @@ const NoticeBar = (props) => {
21619
21352
  };
21620
21353
  NoticeBar.defaultProps = defaultProps$y;
21621
21354
  NoticeBar.displayName = "NutNoticeBar";
21622
- class Notification extends React.PureComponent {
21355
+ let Notification$1 = (_a = class extends React.PureComponent {
21623
21356
  constructor(props) {
21624
21357
  super(props);
21625
21358
  __publicField(this, "closeTimer");
@@ -21710,9 +21443,8 @@ class Notification extends React.PureComponent {
21710
21443
  }
21711
21444
  ) });
21712
21445
  }
21713
- }
21714
- __publicField(Notification, "newInstance");
21715
- Notification.newInstance = (properties, callback) => {
21446
+ }, __publicField(_a, "newInstance"), _a);
21447
+ Notification$1.newInstance = (properties, callback) => {
21716
21448
  const element = document.createElement("div");
21717
21449
  const id = properties.id ? properties.id : `${(/* @__PURE__ */ new Date()).getTime()}`;
21718
21450
  element.id = id;
@@ -21734,10 +21466,10 @@ Notification.newInstance = (properties, callback) => {
21734
21466
  }
21735
21467
  });
21736
21468
  }
21737
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification, { ...properties, ref }), element);
21469
+ render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
21738
21470
  };
21739
- let messageInstance = null;
21740
- const options = {
21471
+ let messageInstance$1 = null;
21472
+ const options$1 = {
21741
21473
  msg: "",
21742
21474
  id: "",
21743
21475
  duration: 3e3,
@@ -21751,51 +21483,51 @@ const options = {
21751
21483
  onClick: () => {
21752
21484
  }
21753
21485
  };
21754
- function getInstance(props, callback) {
21755
- if (messageInstance) {
21756
- messageInstance.destroy();
21757
- messageInstance = null;
21486
+ function getInstance$1(props, callback) {
21487
+ if (messageInstance$1) {
21488
+ messageInstance$1.destroy();
21489
+ messageInstance$1 = null;
21758
21490
  }
21759
- Notification.newInstance(props, (notification) => {
21491
+ Notification$1.newInstance(props, (notification) => {
21760
21492
  return callback && callback(notification);
21761
21493
  });
21762
21494
  }
21763
- function notice(opts) {
21764
- opts = { ...options, ...opts };
21765
- getInstance(opts, (notification) => {
21766
- messageInstance = notification;
21495
+ function notice$1(opts) {
21496
+ opts = { ...options$1, ...opts };
21497
+ getInstance$1(opts, (notification) => {
21498
+ messageInstance$1 = notification;
21767
21499
  });
21768
21500
  }
21769
- const errorMsg = (msg) => {
21501
+ const errorMsg$1 = (msg) => {
21770
21502
  if (!msg) {
21771
21503
  console.warn("[NutUI Notify]: msg不能为空");
21772
21504
  }
21773
21505
  };
21774
21506
  const Notify = {
21775
21507
  text(msg, option = {}) {
21776
- errorMsg(msg);
21777
- return notice({ msg, type: "base", ...option });
21508
+ errorMsg$1(msg);
21509
+ return notice$1({ msg, type: "base", ...option });
21778
21510
  },
21779
21511
  success(msg, option = {}) {
21780
- errorMsg(msg);
21781
- return notice({ msg, type: "success", ...option });
21512
+ errorMsg$1(msg);
21513
+ return notice$1({ msg, type: "success", ...option });
21782
21514
  },
21783
21515
  primary(msg, option = {}) {
21784
- errorMsg(msg);
21785
- return notice({ msg, type: "primary", ...option });
21516
+ errorMsg$1(msg);
21517
+ return notice$1({ msg, type: "primary", ...option });
21786
21518
  },
21787
21519
  danger(msg, option = {}) {
21788
- errorMsg(msg);
21789
- return notice({ msg, type: "danger", ...option });
21520
+ errorMsg$1(msg);
21521
+ return notice$1({ msg, type: "danger", ...option });
21790
21522
  },
21791
21523
  warn(msg, option = {}) {
21792
- errorMsg(msg);
21793
- return notice({ msg, type: "warning", ...option });
21524
+ errorMsg$1(msg);
21525
+ return notice$1({ msg, type: "warning", ...option });
21794
21526
  },
21795
21527
  hide() {
21796
- if (messageInstance) {
21797
- messageInstance.destroy();
21798
- messageInstance = null;
21528
+ if (messageInstance$1) {
21529
+ messageInstance$1.destroy();
21530
+ messageInstance$1 = null;
21799
21531
  }
21800
21532
  }
21801
21533
  };
@@ -22569,6 +22301,218 @@ const Swipe = forwardRef((props, instanceRef) => {
22569
22301
  });
22570
22302
  Swipe.defaultProps = defaultProps$t;
22571
22303
  Swipe.displayName = "NutSwipe";
22304
+ class Notification extends React.PureComponent {
22305
+ constructor(props) {
22306
+ super(props);
22307
+ __publicField(this, "closeTimer");
22308
+ this.close = this.close.bind(this);
22309
+ this.startCloseTimer = this.startCloseTimer.bind(this);
22310
+ this.clearCloseTimer = this.clearCloseTimer.bind(this);
22311
+ this.close = this.close.bind(this);
22312
+ this.clickCover = this.clickCover.bind(this);
22313
+ }
22314
+ close() {
22315
+ this.clearCloseTimer();
22316
+ this.props.onClose();
22317
+ }
22318
+ startCloseTimer() {
22319
+ const { duration } = this.props;
22320
+ if (duration) {
22321
+ this.closeTimer = window.setTimeout(() => {
22322
+ this.close();
22323
+ }, duration * 1e3);
22324
+ }
22325
+ }
22326
+ clearCloseTimer() {
22327
+ if (this.closeTimer) {
22328
+ clearTimeout(this.closeTimer);
22329
+ this.closeTimer = -1;
22330
+ }
22331
+ }
22332
+ clickCover() {
22333
+ const { closeOnClickOverlay } = this.props;
22334
+ if (closeOnClickOverlay) {
22335
+ this.close();
22336
+ }
22337
+ }
22338
+ componentDidMount() {
22339
+ this.startCloseTimer();
22340
+ }
22341
+ componentWillUnmount() {
22342
+ this.clearCloseTimer();
22343
+ }
22344
+ render() {
22345
+ const {
22346
+ id,
22347
+ style,
22348
+ icon,
22349
+ title,
22350
+ msg,
22351
+ bottom,
22352
+ center,
22353
+ bgColor,
22354
+ coverColor,
22355
+ textAlignCenter,
22356
+ size,
22357
+ customClass,
22358
+ cover,
22359
+ type: type4
22360
+ } = this.props;
22361
+ const toastBem = cn("toast");
22362
+ const classes = classNames({
22363
+ "nut-toast-center": center,
22364
+ "nut-toast-has-icon": icon,
22365
+ "nut-toast-cover": cover,
22366
+ "nut-toast-loading": type4 === "loading",
22367
+ [`${customClass}`]: true,
22368
+ [`nut-toast-${size}`]: true
22369
+ });
22370
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22371
+ "div",
22372
+ {
22373
+ className: `${toastBem()} ${classes}`,
22374
+ id: `toast-${id}`,
22375
+ style: {
22376
+ bottom: center ? "auto" : `${bottom}`,
22377
+ backgroundColor: cover ? coverColor : "",
22378
+ ...style
22379
+ },
22380
+ onClick: () => {
22381
+ this.clickCover();
22382
+ },
22383
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
22384
+ "div",
22385
+ {
22386
+ className: toastBem("inner"),
22387
+ style: {
22388
+ textAlign: textAlignCenter ? "center" : "left",
22389
+ backgroundColor: bgColor
22390
+ },
22391
+ children: [
22392
+ icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: toastBem("icon-wrapper"), children: icon }) : null,
22393
+ title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-toast-title", children: title }) : null,
22394
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: toastBem("text"), children: msg })
22395
+ ]
22396
+ }
22397
+ )
22398
+ }
22399
+ ) });
22400
+ }
22401
+ }
22402
+ __publicField(Notification, "newInstance");
22403
+ Notification.newInstance = (properties, callback) => {
22404
+ const element = document.createElement("div");
22405
+ if (properties.id) {
22406
+ element.setAttribute("id", `${properties.id}`);
22407
+ }
22408
+ document.body.appendChild(element);
22409
+ let called = false;
22410
+ function ref(instance) {
22411
+ if (called) {
22412
+ return;
22413
+ }
22414
+ called = true;
22415
+ callback({
22416
+ component: instance,
22417
+ destroy() {
22418
+ unmount(element);
22419
+ element && element.parentNode && element.parentNode.removeChild(element);
22420
+ }
22421
+ });
22422
+ }
22423
+ render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification, { ...properties, ref }), element);
22424
+ };
22425
+ let messageInstance = null;
22426
+ const options = {
22427
+ msg: "",
22428
+ id: "",
22429
+ style: {},
22430
+ duration: 1.5,
22431
+ // 时长,duration为0则一直展示
22432
+ center: true,
22433
+ // toast是否居中展示
22434
+ type: "text",
22435
+ title: "",
22436
+ customClass: "",
22437
+ // 自定义样式名
22438
+ bottom: "30px",
22439
+ // center为false时生效,距离底部位置
22440
+ size: "base",
22441
+ // 设置字体大小,默认base,可选large\small\base
22442
+ icon: null,
22443
+ iconSize: "20",
22444
+ textAlignCenter: true,
22445
+ // 文字是否居中显示,true为居中,false为left
22446
+ loadingRotate: true,
22447
+ // 未实现
22448
+ bgColor: "rgba(0, 0, 0, .8)",
22449
+ onClose: () => {
22450
+ },
22451
+ cover: false,
22452
+ // 是否展示透明遮罩层
22453
+ coverColor: "rgba(0, 0, 0, 0)",
22454
+ // 遮罩颜色设定
22455
+ closeOnClickOverlay: false
22456
+ // 是否点击遮罩可关闭
22457
+ };
22458
+ function getInstance(props, callback) {
22459
+ if (messageInstance) {
22460
+ messageInstance.destroy();
22461
+ messageInstance = null;
22462
+ }
22463
+ Notification.newInstance(props, (notification) => {
22464
+ return callback && callback(notification);
22465
+ });
22466
+ }
22467
+ function notice(opts) {
22468
+ function close() {
22469
+ if (messageInstance) {
22470
+ messageInstance.destroy();
22471
+ messageInstance = null;
22472
+ }
22473
+ }
22474
+ const opts2 = { ...options, ...opts, onClose: close };
22475
+ getInstance(opts2, (notification) => {
22476
+ messageInstance = notification;
22477
+ });
22478
+ }
22479
+ const errorMsg = (msg) => {
22480
+ if (!msg) {
22481
+ console.warn("[NutUI Toast]: msg cannot be null");
22482
+ }
22483
+ };
22484
+ const Toast = {
22485
+ text(msg, option = {}) {
22486
+ errorMsg(msg);
22487
+ return notice({ msg, type: "text", ...option });
22488
+ },
22489
+ success(msg, option = {}) {
22490
+ errorMsg(msg);
22491
+ return notice({ msg, icon: "success", type: "success", ...option });
22492
+ },
22493
+ fail(msg, option = {}) {
22494
+ errorMsg(msg);
22495
+ return notice({ msg, icon: "failure", type: "fail", ...option });
22496
+ },
22497
+ loading(msg, option = {}) {
22498
+ errorMsg(msg);
22499
+ return notice({ msg, icon: /* @__PURE__ */ jsxRuntimeExports.jsx(k$3, {}), type: "loading", ...option });
22500
+ },
22501
+ warn(msg, option = {}) {
22502
+ errorMsg(msg);
22503
+ return notice({ msg, icon: "tips", type: "warn", ...option });
22504
+ },
22505
+ customIcon(msg, option = {}) {
22506
+ errorMsg(msg);
22507
+ return notice({ msg, ...option });
22508
+ },
22509
+ hide() {
22510
+ if (messageInstance) {
22511
+ messageInstance.destroy();
22512
+ messageInstance = null;
22513
+ }
22514
+ }
22515
+ };
22572
22516
  const defaultProps$s = {
22573
22517
  ...ComponentDefaults,
22574
22518
  type: "shake",
@@ -22845,9 +22789,11 @@ const Audio = (props) => {
22845
22789
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${classPrefix2}__progress-bar-wrapper`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22846
22790
  Range,
22847
22791
  {
22848
- modelValue: percent,
22849
- hiddenTag: true,
22850
- hiddenRange: true,
22792
+ value: percent,
22793
+ onChange: (val) => setPercent(val),
22794
+ currentDescription: null,
22795
+ maxDescription: null,
22796
+ minDescription: null,
22851
22797
  "inactive-color": "#cccccc",
22852
22798
  "active-color": "#fa2c19"
22853
22799
  }