@nutui/nutui-react 2.0.0-alpha.7 → 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.7 Fri May 12 2023 15:35:24 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,16 +12573,19 @@ 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
- if (current !== "") {
12585
+ if (current !== "" && current !== value) {
12581
12586
  setValue(current);
12587
+ } else {
12588
+ forceUpdate();
12582
12589
  }
12583
12590
  }, [children]);
12584
12591
  const classes = classNames(
@@ -12596,14 +12603,16 @@ const Tabs = (props) => {
12596
12603
  background: activeType === "line" ? activeColor : ""
12597
12604
  };
12598
12605
  useEffect(() => {
12599
- const index = titles.current.findIndex((t) => t.value === value);
12606
+ const index = titles.current.findIndex((t) => t.value == value);
12600
12607
  setContentStyle({
12601
12608
  transform: direction === "horizontal" ? `translate3d(-${index * 100}%, 0, 0)` : `translate3d( 0,-${index * 100}%, 0)`,
12602
12609
  transitionDuration: `${duration}ms`
12603
12610
  });
12604
- scrollIntoView(index);
12611
+ setTimeout(() => {
12612
+ scrollIntoView(index);
12613
+ });
12605
12614
  }, [value]);
12606
- const tabChange = (item, index) => {
12615
+ const tabChange = (item) => {
12607
12616
  onClick && onClick(item.value);
12608
12617
  if (item.disabled) {
12609
12618
  return;
@@ -12611,11 +12620,11 @@ const Tabs = (props) => {
12611
12620
  setValue(item.value);
12612
12621
  };
12613
12622
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes, ...rest, children: [
12614
- /* @__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) => {
12615
12624
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
12616
12625
  "div",
12617
12626
  {
12618
- onClick: (e) => {
12627
+ onClick: () => {
12619
12628
  tabChange(item);
12620
12629
  },
12621
12630
  className: classNames(`${classPrefix$a}__titles-item`, {
@@ -14464,7 +14473,6 @@ const defaultProps$_ = {
14464
14473
  popup: true,
14465
14474
  visible: false,
14466
14475
  options: [],
14467
- value: [],
14468
14476
  title: "",
14469
14477
  optionKey: { textKey: "text", valueKey: "value", childrenKey: "children" },
14470
14478
  format: {},
@@ -14479,8 +14487,7 @@ const defaultProps$_ = {
14479
14487
  onChange: () => {
14480
14488
  },
14481
14489
  onPathChange: () => {
14482
- },
14483
- ...Popup.defaultProps
14490
+ }
14484
14491
  };
14485
14492
  const InternalCascader = (props, ref) => {
14486
14493
  const {
@@ -14490,6 +14497,7 @@ const InternalCascader = (props, ref) => {
14490
14497
  visible,
14491
14498
  options: options2,
14492
14499
  value,
14500
+ defaultValue,
14493
14501
  title,
14494
14502
  optionKey: optionKey2,
14495
14503
  format: format2,
@@ -14505,6 +14513,15 @@ const InternalCascader = (props, ref) => {
14505
14513
  const [tabvalue, setTabvalue] = useState("c1");
14506
14514
  const [optionsData, setOptionsData] = useState([]);
14507
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
+ });
14508
14525
  const [state] = useState({
14509
14526
  optionsData: [],
14510
14527
  panes: [
@@ -14514,7 +14531,6 @@ const InternalCascader = (props, ref) => {
14514
14531
  paneKey: ""
14515
14532
  }
14516
14533
  ],
14517
- innerValue: value,
14518
14534
  tree: new Tree$1([], {}),
14519
14535
  tabsCursor: 0,
14520
14536
  // 选中的tab项
@@ -14534,12 +14550,12 @@ const InternalCascader = (props, ref) => {
14534
14550
  });
14535
14551
  useEffect(() => {
14536
14552
  initData();
14537
- }, [options2]);
14553
+ }, [options2, format2]);
14538
14554
  useEffect(() => {
14539
- if (value !== state.innerValue) {
14540
- state.innerValue = value;
14555
+ if (defaultValue && defaultValue !== innerValue) {
14556
+ setInnerValue(defaultValue);
14541
14557
  }
14542
- }, [value]);
14558
+ }, [defaultValue]);
14543
14559
  const initData = async () => {
14544
14560
  state.lazyLoadMap.clear();
14545
14561
  if (format2 && Object.keys(format2).length > 0) {
@@ -14574,24 +14590,24 @@ const InternalCascader = (props, ref) => {
14574
14590
  setOptionsData(state.panes);
14575
14591
  };
14576
14592
  const syncValue = async () => {
14577
- const currentValue2 = state.innerValue;
14578
- if (currentValue2 === void 0 || !state.tree.nodes.length) {
14593
+ const currentValue = innerValue;
14594
+ if (currentValue === void 0 || currentValue !== defaultValue || !state.tree.nodes.length) {
14579
14595
  return;
14580
14596
  }
14581
- if (currentValue2.length === 0) {
14597
+ if (currentValue.length === 0) {
14582
14598
  state.tabsCursor = 0;
14583
14599
  return;
14584
14600
  }
14585
- let needToSync = currentValue2;
14586
- if (isLazy() && Array.isArray(currentValue2) && currentValue2.length) {
14601
+ let needToSync = currentValue;
14602
+ if (isLazy() && Array.isArray(currentValue) && currentValue.length) {
14587
14603
  needToSync = [];
14588
14604
  const parent = state.tree.nodes.find(
14589
- (node) => node.value === currentValue2[0]
14605
+ (node) => node.value === currentValue[0]
14590
14606
  );
14591
14607
  if (parent) {
14592
14608
  needToSync = [parent.value];
14593
14609
  state.initLoading = true;
14594
- const last = await currentValue2.slice(1).reduce(async (p, value2) => {
14610
+ const last = await currentValue.slice(1).reduce(async (p, value2) => {
14595
14611
  var _a2;
14596
14612
  const parent2 = await p;
14597
14613
  await invokeLazyLoad(parent2);
@@ -14607,7 +14623,7 @@ const InternalCascader = (props, ref) => {
14607
14623
  state.initLoading = false;
14608
14624
  }
14609
14625
  }
14610
- if (needToSync.length && currentValue2 === value) {
14626
+ if (needToSync.length && currentValue === defaultValue) {
14611
14627
  const pathNodes = state.tree.getPathNodesByValue(needToSync);
14612
14628
  pathNodes.forEach((node, index) => {
14613
14629
  state.tabsCursor = index;
@@ -14664,6 +14680,7 @@ const InternalCascader = (props, ref) => {
14664
14680
  const optionParams = pathNodes.map((item) => item.value);
14665
14681
  onChange(optionParams, pathNodes);
14666
14682
  onPathChange(optionParams, pathNodes);
14683
+ setInnerValue(optionParams);
14667
14684
  }
14668
14685
  setOptionsData(state.panes);
14669
14686
  close();
@@ -18435,475 +18452,167 @@ const Radio = (props) => {
18435
18452
  Radio.defaultProps = defaultProps$N;
18436
18453
  Radio.displayName = "NutRadio";
18437
18454
  Radio.RadioGroup = RadioGroup;
18438
- const fullClone = {
18439
- ...ReactDOM
18455
+ const defaultProps$M = {
18456
+ ...ComponentDefaults,
18457
+ range: false,
18458
+ min: 0,
18459
+ max: 100,
18460
+ step: 1,
18461
+ vertical: false,
18462
+ marks: {}
18440
18463
  };
18441
- const { version, render: reactRender, unmountComponentAtNode } = fullClone;
18442
- let createRoot;
18443
- try {
18444
- const mainVersion = Number((version || "").split(".")[0]);
18445
- if (mainVersion >= 18 && fullClone.createRoot) {
18446
- createRoot = fullClone.createRoot;
18447
- }
18448
- } catch (e) {
18449
- }
18450
- function toggleWarning(skip) {
18451
- const { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } = fullClone;
18452
- if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === "object") {
18453
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
18454
- }
18455
- }
18456
- const MARK = "__nutui_react_root__";
18457
- function legacyRender(node, container) {
18458
- reactRender(node, container);
18459
- }
18460
- function concurrentRender(node, container) {
18461
- toggleWarning(true);
18462
- const root2 = container[MARK] || createRoot(container);
18463
- toggleWarning(false);
18464
- root2.render(node);
18465
- container[MARK] = root2;
18466
- }
18467
- function render(node, container) {
18468
- if (createRoot) {
18469
- concurrentRender(node, container);
18470
- return;
18471
- }
18472
- legacyRender(node, container);
18473
- }
18474
- function legacyUnmount(container) {
18475
- return unmountComponentAtNode(container);
18476
- }
18477
- async function concurrentUnmount(container) {
18478
- return Promise.resolve().then(() => {
18479
- var _a2;
18480
- (_a2 = container[MARK]) == null ? void 0 : _a2.unmount();
18481
- 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
18482
18499
  });
18483
- }
18484
- function unmount(container) {
18485
- if (createRoot) {
18486
- return concurrentUnmount(container);
18487
- }
18488
- return legacyUnmount(container);
18489
- }
18490
- let Notification$1 = (_a = class extends React.PureComponent {
18491
- constructor(props) {
18492
- super(props);
18493
- __publicField(this, "closeTimer");
18494
- this.close = this.close.bind(this);
18495
- this.startCloseTimer = this.startCloseTimer.bind(this);
18496
- this.clearCloseTimer = this.clearCloseTimer.bind(this);
18497
- this.close = this.close.bind(this);
18498
- this.clickCover = this.clickCover.bind(this);
18499
- }
18500
- close() {
18501
- this.clearCloseTimer();
18502
- this.props.onClose();
18503
- }
18504
- startCloseTimer() {
18505
- const { duration } = this.props;
18506
- if (duration) {
18507
- this.closeTimer = window.setTimeout(() => {
18508
- this.close();
18509
- }, 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);
18510
18508
  }
18511
- }
18512
- clearCloseTimer() {
18513
- if (this.closeTimer) {
18514
- clearTimeout(this.closeTimer);
18515
- 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()}%`;
18516
18546
  }
18517
- }
18518
- clickCover() {
18519
- const { closeOnClickOverlay } = this.props;
18520
- if (closeOnClickOverlay) {
18521
- 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()}%`;
18522
18553
  }
18523
- }
18524
- componentDidMount() {
18525
- this.startCloseTimer();
18526
- }
18527
- componentWillUnmount() {
18528
- this.clearCloseTimer();
18529
- }
18530
- render() {
18531
- const {
18532
- id,
18533
- style,
18534
- icon,
18535
- title,
18536
- msg,
18537
- bottom,
18538
- center,
18539
- bgColor,
18540
- coverColor,
18541
- textAlignCenter,
18542
- size,
18543
- customClass,
18544
- cover,
18545
- type: type4
18546
- } = this.props;
18547
- const toastBem = cn("toast");
18548
- const classes = classNames({
18549
- "nut-toast-center": center,
18550
- "nut-toast-has-icon": icon,
18551
- "nut-toast-cover": cover,
18552
- "nut-toast-loading": type4 === "loading",
18553
- [`${customClass}`]: true,
18554
- [`nut-toast-${size}`]: true
18555
- });
18556
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
18557
- "div",
18558
- {
18559
- className: `${toastBem()} ${classes}`,
18560
- id: `toast-${id}`,
18561
- style: {
18562
- bottom: center ? "auto" : `${bottom}`,
18563
- backgroundColor: cover ? coverColor : "",
18564
- ...style
18565
- },
18566
- onClick: () => {
18567
- this.clickCover();
18568
- },
18569
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
18570
- "div",
18571
- {
18572
- className: toastBem("inner"),
18573
- style: {
18574
- textAlign: textAlignCenter ? "center" : "left",
18575
- backgroundColor: bgColor
18576
- },
18577
- children: [
18578
- icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: toastBem("icon-wrapper"), children: icon }) : null,
18579
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-toast-title", children: title }) : null,
18580
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: toastBem("text"), children: msg })
18581
- ]
18582
- }
18583
- )
18584
- }
18585
- ) });
18586
- }
18587
- }, __publicField(_a, "newInstance"), _a);
18588
- Notification$1.newInstance = (properties, callback) => {
18589
- const element = document.createElement("div");
18590
- if (properties.id) {
18591
- element.setAttribute("id", `${properties.id}`);
18592
- }
18593
- document.body.appendChild(element);
18594
- let called = false;
18595
- function ref(instance) {
18596
- if (called) {
18597
- return;
18598
- }
18599
- called = true;
18600
- callback({
18601
- component: instance,
18602
- destroy() {
18603
- unmount(element);
18604
- element && element.parentNode && element.parentNode.removeChild(element);
18605
- }
18606
- });
18607
- }
18608
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
18609
- };
18610
- let messageInstance$1 = null;
18611
- const options$1 = {
18612
- msg: "",
18613
- id: "",
18614
- style: {},
18615
- duration: 1.5,
18616
- // 时长,duration为0则一直展示
18617
- center: true,
18618
- // toast是否居中展示
18619
- type: "text",
18620
- title: "",
18621
- customClass: "",
18622
- // 自定义样式名
18623
- bottom: "30px",
18624
- // center为false时生效,距离底部位置
18625
- size: "base",
18626
- // 设置字体大小,默认base,可选large\small\base
18627
- icon: null,
18628
- iconSize: "20",
18629
- textAlignCenter: true,
18630
- // 文字是否居中显示,true为居中,false为left
18631
- loadingRotate: true,
18632
- // 未实现
18633
- bgColor: "rgba(0, 0, 0, .8)",
18634
- onClose: () => {
18635
- },
18636
- cover: false,
18637
- // 是否展示透明遮罩层
18638
- coverColor: "rgba(0, 0, 0, 0)",
18639
- // 遮罩颜色设定
18640
- closeOnClickOverlay: false
18641
- // 是否点击遮罩可关闭
18642
- };
18643
- function getInstance$1(props, callback) {
18644
- if (messageInstance$1) {
18645
- messageInstance$1.destroy();
18646
- messageInstance$1 = null;
18647
- }
18648
- Notification$1.newInstance(props, (notification) => {
18649
- return callback && callback(notification);
18650
- });
18651
- }
18652
- function notice$1(opts) {
18653
- function close() {
18654
- if (messageInstance$1) {
18655
- messageInstance$1.destroy();
18656
- messageInstance$1 = null;
18657
- }
18658
- }
18659
- const opts2 = { ...options$1, ...opts, onClose: close };
18660
- getInstance$1(opts2, (notification) => {
18661
- messageInstance$1 = notification;
18662
- });
18663
- }
18664
- const errorMsg$1 = (msg) => {
18665
- if (!msg) {
18666
- console.warn("[NutUI Toast]: msg cannot be null");
18667
- }
18668
- };
18669
- const Toast = {
18670
- text(msg, option = {}) {
18671
- errorMsg$1(msg);
18672
- return notice$1({ msg, type: "text", ...option });
18673
- },
18674
- success(msg, option = {}) {
18675
- errorMsg$1(msg);
18676
- return notice$1({ msg, icon: "success", type: "success", ...option });
18677
- },
18678
- fail(msg, option = {}) {
18679
- errorMsg$1(msg);
18680
- return notice$1({ msg, icon: "failure", type: "fail", ...option });
18681
- },
18682
- loading(msg, option = {}) {
18683
- errorMsg$1(msg);
18684
- return notice$1({ msg, icon: /* @__PURE__ */ jsxRuntimeExports.jsx(k$3, {}), type: "loading", ...option });
18685
- },
18686
- warn(msg, option = {}) {
18687
- errorMsg$1(msg);
18688
- return notice$1({ msg, icon: "tips", type: "warn", ...option });
18689
- },
18690
- customIcon(msg, option = {}) {
18691
- errorMsg$1(msg);
18692
- return notice$1({ msg, ...option });
18693
- },
18694
- hide() {
18695
- if (messageInstance$1) {
18696
- messageInstance$1.destroy();
18697
- messageInstance$1 = null;
18698
- }
18699
- }
18700
- };
18701
- const defaultProps$M = {
18702
- range: false,
18703
- hiddenRange: false,
18704
- hiddenTag: false,
18705
- min: 0,
18706
- max: 100,
18707
- step: 1,
18708
- modelValue: 0,
18709
- vertical: false,
18710
- marks: {}
18711
- };
18712
- let startValue;
18713
- let currentValue;
18714
- const Range = (props) => {
18715
- const { locale } = useConfig();
18716
- const {
18717
- className,
18718
- range: range3,
18719
- disabled,
18720
- activeColor,
18721
- inactiveColor,
18722
- buttonColor,
18723
- hiddenRange,
18724
- hiddenTag,
18725
- modelValue,
18726
- button,
18727
- vertical,
18728
- marks,
18729
- dragStart,
18730
- dragEnd,
18731
- onChange,
18732
- onDragStart,
18733
- onDragEnd,
18734
- minDesc,
18735
- maxDesc,
18736
- curValueDesc
18737
- } = { ...defaultProps$M, ...props };
18738
- let { min, max, step } = { ...defaultProps$M, ...props };
18739
- min = Number(min);
18740
- max = Number(max);
18741
- step = Number(step);
18742
- const [buttonIndex, SetButtonIndex] = useState(0);
18743
- const [initValue, SetInitValue] = useState();
18744
- const [dragStatus, SetDragStatus] = useState("start");
18745
- const touch = useTouch();
18746
- const root2 = useRef(null);
18747
- const [marksList, SetMarksList] = useState([]);
18748
- useEffect(() => {
18749
- if (typeof modelValue === "number") {
18750
- if (!range3 && (modelValue < min || modelValue > max)) {
18751
- SetInitValue(0);
18752
- Toast.text(`${modelValue} ${locale.range.rangeText}`);
18753
- return;
18754
- }
18755
- SetInitValue(modelValue);
18756
- }
18757
- }, [modelValue]);
18758
- useEffect(() => {
18759
- if (marks) {
18760
- const marksKeys = Object.keys(marks);
18761
- const list = marksKeys.map(parseFloat).sort((a2, b) => a2 - b).filter((point) => point >= min && point <= max);
18762
- SetMarksList(list);
18763
- }
18764
- }, [marks]);
18765
- const scope = () => {
18766
- return Number(max) - Number(min);
18767
- };
18768
- const classes = useCallback(() => {
18769
- const prefixCls2 = "nut-range";
18770
- return [
18771
- prefixCls2,
18772
- `${disabled ? `${prefixCls2}-disabled` : ""}`,
18773
- `${vertical ? `${prefixCls2}-vertical` : ""}`,
18774
- `${!hiddenRange ? `${prefixCls2}-show-number` : ""}`
18775
- ].filter(Boolean).join(" ");
18776
- }, [disabled, vertical, hiddenRange]);
18777
- const containerClasses = useCallback(() => {
18778
- const prefixCls2 = "nut-range-container";
18779
- return [prefixCls2, `${vertical ? `${prefixCls2}-vertical` : ""}`, className].filter(Boolean).join(" ");
18780
- }, [vertical, className]);
18781
- const markClassName = useCallback(
18782
- (mark) => {
18783
- const classPrefix2 = "nut-range-mark";
18784
- let lowerBound = Number(min);
18785
- let upperBound = Number(max);
18786
- if (range3) {
18787
- const [left, right] = modelValue;
18788
- lowerBound = left;
18789
- upperBound = right;
18790
- } else {
18791
- upperBound = modelValue;
18792
- }
18793
- const isActive = mark <= upperBound && mark >= lowerBound;
18794
- return [
18795
- `${classPrefix2}-text`,
18796
- `${isActive ? `${classPrefix2}-text-active` : ""}`
18797
- ].filter(Boolean).join(" ");
18798
- },
18799
- [range3, modelValue, min, max]
18800
- );
18801
- const [rangeName, setRangeName] = useState(classes());
18802
- const [containerName, setContainerName] = useState(containerClasses());
18803
- useEffect(() => {
18804
- setRangeName(classes());
18805
- setContainerName(containerClasses());
18806
- }, [classes, containerClasses]);
18807
- const wrapperStyle = () => {
18808
- return {
18809
- background: inactiveColor
18810
- };
18811
- };
18812
- const buttonStyle = () => {
18813
- return {
18814
- borderColor: buttonColor
18815
- };
18816
- };
18817
- const isRange = (val) => {
18818
- return !!range3 && Array.isArray(val);
18819
- };
18820
- const calcMainAxis = () => {
18821
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18822
- if (isRange(modelVal)) {
18823
- return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
18824
- }
18825
- return `${(modelVal - Number(min)) * 100 / scope()}%`;
18826
- };
18827
- const calcOffset = () => {
18828
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18829
- if (isRange(modelVal)) {
18830
- return `${(modelVal[0] - Number(min)) * 100 / scope()}%`;
18831
- }
18832
- return `0%`;
18833
- };
18834
- const barStyle = () => {
18835
- if (vertical) {
18836
- return {
18837
- height: calcMainAxis(),
18838
- top: calcOffset(),
18839
- background: activeColor,
18840
- transition: dragStatus ? "none" : void 0
18841
- };
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
+ };
18842
18563
  }
18843
18564
  return {
18844
18565
  width: calcMainAxis(),
18845
18566
  left: calcOffset(),
18846
- background: activeColor,
18847
18567
  transition: dragStatus ? "none" : void 0
18848
18568
  };
18849
18569
  };
18850
18570
  const marksStyle = (mark) => {
18851
18571
  let style = {
18852
- left: `${(mark - Number(min)) / scope() * 100}%`
18572
+ left: `${(mark - min) / scope() * 100}%`
18853
18573
  };
18854
18574
  if (vertical) {
18855
18575
  style = {
18856
- top: `${(mark - Number(min)) / scope() * 100}%`
18576
+ top: `${(mark - min) / scope() * 100}%`
18857
18577
  };
18858
18578
  }
18859
18579
  return style;
18860
18580
  };
18861
- const tickStyle = (mark) => {
18862
- let lowerBound = Number(min);
18863
- let upperBound = Number(max);
18864
- if (range3) {
18865
- const [left, right] = modelValue;
18866
- lowerBound = left;
18867
- upperBound = right;
18581
+ const tickClass = (mark) => {
18582
+ if (range3 && Array.isArray(current)) {
18583
+ return mark <= current[1] && mark >= current[0];
18868
18584
  }
18869
- const isActive = mark <= upperBound && mark >= lowerBound;
18870
- const style = {
18871
- background: !isActive ? inactiveColor : activeColor
18872
- };
18873
- return style;
18585
+ return mark <= current;
18874
18586
  };
18875
- const format2 = (value) => {
18876
- value = Math.max(+min, Math.min(value, +max));
18877
- 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;
18878
18590
  };
18879
18591
  const isSameValue = (newValue, oldValue) => {
18880
18592
  return JSON.stringify(newValue) === JSON.stringify(oldValue);
18881
18593
  };
18882
- const handleOverlap = (value) => {
18883
- if (value[0] > value[1]) {
18884
- return value.slice(0).reverse();
18594
+ const handleOverlap = (value2) => {
18595
+ if (value2[0] > value2[1]) {
18596
+ return value2.slice(0).reverse();
18885
18597
  }
18886
- return value;
18598
+ return value2;
18887
18599
  };
18888
- const updateValue = (value, end) => {
18889
- if (isRange(value)) {
18890
- value = handleOverlap(value).map(format2);
18600
+ const updateValue = (value2, end) => {
18601
+ if (isRange(value2)) {
18602
+ value2 = handleOverlap(value2).map(format2);
18891
18603
  } else {
18892
- value = format2(value);
18604
+ value2 = format2(value2);
18893
18605
  }
18894
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18895
- if (!isSameValue(value, modelVal)) {
18896
- SetInitValue(value);
18897
- }
18898
- if ((marks || end) && !isSameValue(value, startValue)) {
18899
- onChange && onChange(value);
18606
+ if (!isSameValue(value2, current)) {
18607
+ setCurrent(value2);
18900
18608
  }
18609
+ end && onEnd && onEnd(value2);
18901
18610
  };
18902
18611
  const click = (event) => {
18903
18612
  if (disabled || !root2.current) {
18904
18613
  return;
18905
18614
  }
18906
- SetDragStatus("");
18615
+ setDragStatus("");
18907
18616
  const rect = getRect(root2.current);
18908
18617
  let delta = event.clientX - rect.left;
18909
18618
  let total = rect.width;
@@ -18911,18 +18620,18 @@ const Range = (props) => {
18911
18620
  delta = event.clientY - rect.top;
18912
18621
  total = rect.height;
18913
18622
  }
18914
- const value = Number(min) + delta / total * scope();
18915
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18916
- if (isRange(currentValue)) {
18917
- const [left, right] = currentValue;
18623
+ const value2 = min + delta / total * scope();
18624
+ setEaxctValue(current);
18625
+ if (isRange(current)) {
18626
+ const [left, right] = current;
18918
18627
  const middle = (left + right) / 2;
18919
- if (value <= middle) {
18920
- updateValue([value, right], true);
18628
+ if (value2 <= middle) {
18629
+ updateValue([value2, right], true);
18921
18630
  } else {
18922
- updateValue([left, value], true);
18631
+ updateValue([left, value2], true);
18923
18632
  }
18924
18633
  } else {
18925
- updateValue(value, true);
18634
+ updateValue(value2, true);
18926
18635
  }
18927
18636
  };
18928
18637
  const onTouchStart = (event) => {
@@ -18930,24 +18639,24 @@ const Range = (props) => {
18930
18639
  return;
18931
18640
  }
18932
18641
  touch.start(event);
18933
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18934
- if (isRange(currentValue)) {
18935
- startValue = currentValue.map(format2);
18642
+ setEaxctValue(current);
18643
+ if (isRange(current)) {
18644
+ setStartValue(current.map(format2));
18936
18645
  } else {
18937
- startValue = format2(currentValue);
18646
+ setStartValue(format2(current));
18938
18647
  }
18939
- SetDragStatus("start");
18648
+ setDragStatus("start");
18940
18649
  };
18941
18650
  const onTouchMove = (event) => {
18651
+ event.stopPropagation();
18942
18652
  if (disabled || !root2.current) {
18943
18653
  return;
18944
18654
  }
18945
18655
  if (dragStatus === "start") {
18946
- dragStart && dragStart();
18947
- onDragStart && onDragStart();
18656
+ onStart && onStart();
18948
18657
  }
18949
18658
  touch.move(event);
18950
- SetDragStatus("draging");
18659
+ setDragStatus("draging");
18951
18660
  const rect = getRect(root2.current);
18952
18661
  let delta = touch.deltaX;
18953
18662
  let total = rect.width;
@@ -18957,121 +18666,91 @@ const Range = (props) => {
18957
18666
  total = rect.height;
18958
18667
  diff = delta / total * scope();
18959
18668
  }
18669
+ let newValue;
18960
18670
  if (isRange(startValue)) {
18961
- currentValue[buttonIndex] = startValue[buttonIndex] + diff;
18671
+ newValue = exactValue.slice();
18672
+ newValue[buttonIndex] = startValue[buttonIndex] + diff;
18962
18673
  } else {
18963
- currentValue = startValue + diff;
18674
+ newValue = startValue + diff;
18964
18675
  }
18965
- updateValue(currentValue);
18676
+ setEaxctValue(newValue);
18677
+ updateValue(newValue);
18966
18678
  };
18967
18679
  const onTouchEnd = (event) => {
18968
18680
  if (disabled) {
18969
18681
  return;
18970
18682
  }
18971
18683
  if (dragStatus === "draging") {
18972
- updateValue(currentValue, true);
18973
- dragEnd && dragEnd();
18974
- onDragEnd && onDragEnd();
18684
+ updateValue(current, true);
18975
18685
  }
18976
- SetDragStatus("");
18686
+ setDragStatus("");
18977
18687
  };
18978
18688
  const curValue = (idx) => {
18979
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18980
- const value = typeof idx === "number" ? modelVal[idx] : modelVal;
18981
- return value;
18689
+ const modelVal = current;
18690
+ const value2 = typeof idx === "number" ? modelVal[idx] : modelVal;
18691
+ return value2;
18982
18692
  };
18983
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${containerName}`, children: [
18984
- !hiddenRange ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min", children: minDesc || +min }) : null,
18985
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
18986
- "div",
18987
- {
18988
- ref: root2,
18989
- style: wrapperStyle(),
18990
- className: `${rangeName}`,
18991
- onClick: (e) => {
18992
- click(e);
18993
- },
18994
- children: [
18995
- marksList.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-mark", children: marksList.map((marks2) => {
18996
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
18997
- "span",
18998
- {
18999
- className: markClassName(marks2),
19000
- style: marksStyle(marks2),
19001
- children: [
19002
- marks2,
19003
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "nut-range-tick", style: tickStyle(marks2) })
19004
- ]
19005
- },
19006
- marks2
19007
- );
19008
- }) }) : null,
19009
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-bar", style: barStyle(), children: range3 ? [0, 1].map((item, index) => {
19010
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
19011
- "div",
19012
- {
19013
- role: "slider",
19014
- 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" : ""}
19015
18725
  ${index === 1 ? "nut-range-button-wrapper-right" : ""}`,
19016
- tabIndex: disabled ? -1 : 0,
19017
- "aria-valuemin": +min,
19018
- "aria-valuenow": curValue(index),
19019
- "aria-valuemax": +max,
19020
- "aria-orientation": vertical ? "vertical" : "horizontal",
19021
- onTouchStart: (e) => {
19022
- if (typeof index === "number") {
19023
- SetButtonIndex(index);
19024
- }
19025
- onTouchStart(e);
19026
- },
19027
- onTouchMove: (e) => {
19028
- onTouchMove(e);
19029
- },
19030
- onTouchEnd: (e) => {
19031
- onTouchEnd();
19032
- },
19033
- onTouchCancel: (e) => {
19034
- onTouchEnd();
19035
- },
19036
- onClick: (e) => {
19037
- e.stopPropagation();
19038
- },
19039
- 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 })
19040
- },
19041
- index
19042
- );
19043
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
19044
- "div",
19045
- {
19046
- role: "slider",
19047
- className: "nut-range-button-wrapper",
19048
- tabIndex: disabled ? -1 : 0,
19049
- "aria-valuemin": +min,
19050
- "aria-valuenow": curValue(),
19051
- "aria-valuemax": +max,
19052
- "aria-orientation": vertical ? "vertical" : "horizontal",
19053
- onTouchStart: (e) => {
19054
- onTouchStart(e);
19055
- },
19056
- onTouchMove: (e) => {
19057
- onTouchMove(e);
19058
- },
19059
- onTouchEnd: (e) => {
19060
- onTouchEnd();
19061
- },
19062
- onTouchCancel: (e) => {
19063
- onTouchEnd();
19064
- },
19065
- onClick: (e) => {
19066
- e.stopPropagation();
19067
- },
19068
- children: button || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-button", style: buttonStyle(), children: !hiddenTag ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "number", children: curValueDesc || curValue() }) : null })
19069
- }
19070
- ) })
19071
- ]
19072
- }
19073
- ),
19074
- !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 })
19075
18754
  ] });
19076
18755
  };
19077
18756
  Range.defaultProps = defaultProps$M;
@@ -20575,6 +20254,58 @@ const ActionSheet = (props) => {
20575
20254
  };
20576
20255
  ActionSheet.defaultProps = defaultProps$D;
20577
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
+ }
20578
20309
  function ConfirmDialog(props) {
20579
20310
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Dialog, { ...props, children: props.content });
20580
20311
  }
@@ -21621,7 +21352,7 @@ const NoticeBar = (props) => {
21621
21352
  };
21622
21353
  NoticeBar.defaultProps = defaultProps$y;
21623
21354
  NoticeBar.displayName = "NutNoticeBar";
21624
- class Notification extends React.PureComponent {
21355
+ let Notification$1 = (_a = class extends React.PureComponent {
21625
21356
  constructor(props) {
21626
21357
  super(props);
21627
21358
  __publicField(this, "closeTimer");
@@ -21712,9 +21443,8 @@ class Notification extends React.PureComponent {
21712
21443
  }
21713
21444
  ) });
21714
21445
  }
21715
- }
21716
- __publicField(Notification, "newInstance");
21717
- Notification.newInstance = (properties, callback) => {
21446
+ }, __publicField(_a, "newInstance"), _a);
21447
+ Notification$1.newInstance = (properties, callback) => {
21718
21448
  const element = document.createElement("div");
21719
21449
  const id = properties.id ? properties.id : `${(/* @__PURE__ */ new Date()).getTime()}`;
21720
21450
  element.id = id;
@@ -21736,10 +21466,10 @@ Notification.newInstance = (properties, callback) => {
21736
21466
  }
21737
21467
  });
21738
21468
  }
21739
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification, { ...properties, ref }), element);
21469
+ render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
21740
21470
  };
21741
- let messageInstance = null;
21742
- const options = {
21471
+ let messageInstance$1 = null;
21472
+ const options$1 = {
21743
21473
  msg: "",
21744
21474
  id: "",
21745
21475
  duration: 3e3,
@@ -21753,51 +21483,51 @@ const options = {
21753
21483
  onClick: () => {
21754
21484
  }
21755
21485
  };
21756
- function getInstance(props, callback) {
21757
- if (messageInstance) {
21758
- messageInstance.destroy();
21759
- messageInstance = null;
21486
+ function getInstance$1(props, callback) {
21487
+ if (messageInstance$1) {
21488
+ messageInstance$1.destroy();
21489
+ messageInstance$1 = null;
21760
21490
  }
21761
- Notification.newInstance(props, (notification) => {
21491
+ Notification$1.newInstance(props, (notification) => {
21762
21492
  return callback && callback(notification);
21763
21493
  });
21764
21494
  }
21765
- function notice(opts) {
21766
- opts = { ...options, ...opts };
21767
- getInstance(opts, (notification) => {
21768
- messageInstance = notification;
21495
+ function notice$1(opts) {
21496
+ opts = { ...options$1, ...opts };
21497
+ getInstance$1(opts, (notification) => {
21498
+ messageInstance$1 = notification;
21769
21499
  });
21770
21500
  }
21771
- const errorMsg = (msg) => {
21501
+ const errorMsg$1 = (msg) => {
21772
21502
  if (!msg) {
21773
21503
  console.warn("[NutUI Notify]: msg不能为空");
21774
21504
  }
21775
21505
  };
21776
21506
  const Notify = {
21777
21507
  text(msg, option = {}) {
21778
- errorMsg(msg);
21779
- return notice({ msg, type: "base", ...option });
21508
+ errorMsg$1(msg);
21509
+ return notice$1({ msg, type: "base", ...option });
21780
21510
  },
21781
21511
  success(msg, option = {}) {
21782
- errorMsg(msg);
21783
- return notice({ msg, type: "success", ...option });
21512
+ errorMsg$1(msg);
21513
+ return notice$1({ msg, type: "success", ...option });
21784
21514
  },
21785
21515
  primary(msg, option = {}) {
21786
- errorMsg(msg);
21787
- return notice({ msg, type: "primary", ...option });
21516
+ errorMsg$1(msg);
21517
+ return notice$1({ msg, type: "primary", ...option });
21788
21518
  },
21789
21519
  danger(msg, option = {}) {
21790
- errorMsg(msg);
21791
- return notice({ msg, type: "danger", ...option });
21520
+ errorMsg$1(msg);
21521
+ return notice$1({ msg, type: "danger", ...option });
21792
21522
  },
21793
21523
  warn(msg, option = {}) {
21794
- errorMsg(msg);
21795
- return notice({ msg, type: "warning", ...option });
21524
+ errorMsg$1(msg);
21525
+ return notice$1({ msg, type: "warning", ...option });
21796
21526
  },
21797
21527
  hide() {
21798
- if (messageInstance) {
21799
- messageInstance.destroy();
21800
- messageInstance = null;
21528
+ if (messageInstance$1) {
21529
+ messageInstance$1.destroy();
21530
+ messageInstance$1 = null;
21801
21531
  }
21802
21532
  }
21803
21533
  };
@@ -22571,6 +22301,218 @@ const Swipe = forwardRef((props, instanceRef) => {
22571
22301
  });
22572
22302
  Swipe.defaultProps = defaultProps$t;
22573
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
+ };
22574
22516
  const defaultProps$s = {
22575
22517
  ...ComponentDefaults,
22576
22518
  type: "shake",
@@ -22847,9 +22789,11 @@ const Audio = (props) => {
22847
22789
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${classPrefix2}__progress-bar-wrapper`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22848
22790
  Range,
22849
22791
  {
22850
- modelValue: percent,
22851
- hiddenTag: true,
22852
- hiddenRange: true,
22792
+ value: percent,
22793
+ onChange: (val) => setPercent(val),
22794
+ currentDescription: null,
22795
+ maxDescription: null,
22796
+ minDescription: null,
22853
22797
  "inactive-color": "#cccccc",
22854
22798
  "active-color": "#fa2c19"
22855
22799
  }