@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.
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
9
9
  return value;
10
10
  };
11
11
  /*!
12
- * @nutui/nutui-react v2.0.0-alpha.6 Fri May 12 2023 15:13:32 GMT+0800 (China Standard Time)
12
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:07:24 GMT+0800 (China Standard Time)
13
13
  * (c) 2023 @jdf2e.
14
14
  * Released under the MIT License.
15
15
  */
@@ -7543,7 +7543,7 @@ Please add \`${key}Action\` when creating your handler.`);
7543
7543
  }, []);
7544
7544
  return isMounted;
7545
7545
  };
7546
- function useForceUpdate() {
7546
+ function useForceUpdate$1() {
7547
7547
  const update2 = React.useState()[1];
7548
7548
  const isMounted = useIsMounted();
7549
7549
  return () => {
@@ -7804,7 +7804,7 @@ Please add \`${key}Action\` when creating your handler.`);
7804
7804
  instanceRef.current = updateRef(givenRef, value);
7805
7805
  }, [givenRef]);
7806
7806
  const [props, deps] = getAnimatedState(givenProps, host2);
7807
- const forceUpdate = useForceUpdate();
7807
+ const forceUpdate = useForceUpdate$1();
7808
7808
  const callback = () => {
7809
7809
  const instance = instanceRef.current;
7810
7810
  if (hasInstance && !instance) {
@@ -9459,7 +9459,7 @@ Please add \`${key}Action\` when creating your handler.`);
9459
9459
  deps = [];
9460
9460
  const ref = React.useMemo(() => propsFn || arguments.length == 3 ? SpringRef() : void 0, []);
9461
9461
  const layoutId = React.useRef(0);
9462
- const forceUpdate = useForceUpdate();
9462
+ const forceUpdate = useForceUpdate$1();
9463
9463
  const state = React.useMemo(() => ({
9464
9464
  ctrls: [],
9465
9465
  queue: [],
@@ -12500,6 +12500,10 @@ Please add \`${key}Action\` when creating your handler.`);
12500
12500
  }
12501
12501
  }
12502
12502
  const requestAniFrame$1 = requestAniFrame();
12503
+ function useForceUpdate() {
12504
+ const [, updateState] = React.useState();
12505
+ return React.useCallback(() => updateState({}), []);
12506
+ }
12503
12507
  const defaultProps$15 = {
12504
12508
  ...ComponentDefaults,
12505
12509
  tabStyle: {},
@@ -12587,15 +12591,20 @@ Please add \`${key}Action\` when creating your handler.`);
12587
12591
  return titles2;
12588
12592
  };
12589
12593
  const titles = React.useRef(getTitles());
12594
+ const forceUpdate = useForceUpdate();
12590
12595
  React.useEffect(() => {
12591
12596
  titles.current = getTitles();
12592
12597
  let current = "";
12593
12598
  titles.current.forEach((title2) => {
12594
- if (title2.value === value) {
12599
+ if (title2.value == value) {
12595
12600
  current = value;
12596
12601
  }
12597
12602
  });
12598
- setValue(current);
12603
+ if (current !== "" && current !== value) {
12604
+ setValue(current);
12605
+ } else {
12606
+ forceUpdate();
12607
+ }
12599
12608
  }, [children]);
12600
12609
  const classes = classNames(
12601
12610
  classPrefix$a,
@@ -12612,14 +12621,16 @@ Please add \`${key}Action\` when creating your handler.`);
12612
12621
  background: activeType === "line" ? activeColor : ""
12613
12622
  };
12614
12623
  React.useEffect(() => {
12615
- const index = titles.current.findIndex((t) => t.value === value);
12624
+ const index = titles.current.findIndex((t) => t.value == value);
12616
12625
  setContentStyle({
12617
12626
  transform: direction === "horizontal" ? `translate3d(-${index * 100}%, 0, 0)` : `translate3d( 0,-${index * 100}%, 0)`,
12618
12627
  transitionDuration: `${duration}ms`
12619
12628
  });
12620
- scrollIntoView(index);
12629
+ setTimeout(() => {
12630
+ scrollIntoView(index);
12631
+ });
12621
12632
  }, [value]);
12622
- const tabChange = (item, index) => {
12633
+ const tabChange = (item) => {
12623
12634
  onClick && onClick(item.value);
12624
12635
  if (item.disabled) {
12625
12636
  return;
@@ -12627,11 +12638,11 @@ Please add \`${key}Action\` when creating your handler.`);
12627
12638
  setValue(item.value);
12628
12639
  };
12629
12640
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes, ...rest, children: [
12630
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classesTitle, style: { ...tabStyle }, ref: navRef, children: !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
12641
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classesTitle, style: { ...tabStyle }, ref: navRef, children: !!title && typeof title === "function" ? title() : titles.current.map((item) => {
12631
12642
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
12632
12643
  "div",
12633
12644
  {
12634
- onClick: (e) => {
12645
+ onClick: () => {
12635
12646
  tabChange(item);
12636
12647
  },
12637
12648
  className: classNames(`${classPrefix$a}__titles-item`, {
@@ -14480,7 +14491,6 @@ Please add \`${key}Action\` when creating your handler.`);
14480
14491
  popup: true,
14481
14492
  visible: false,
14482
14493
  options: [],
14483
- value: [],
14484
14494
  title: "",
14485
14495
  optionKey: { textKey: "text", valueKey: "value", childrenKey: "children" },
14486
14496
  format: {},
@@ -14495,8 +14505,7 @@ Please add \`${key}Action\` when creating your handler.`);
14495
14505
  onChange: () => {
14496
14506
  },
14497
14507
  onPathChange: () => {
14498
- },
14499
- ...Popup.defaultProps
14508
+ }
14500
14509
  };
14501
14510
  const InternalCascader = (props, ref) => {
14502
14511
  const {
@@ -14506,6 +14515,7 @@ Please add \`${key}Action\` when creating your handler.`);
14506
14515
  visible,
14507
14516
  options: options2,
14508
14517
  value,
14518
+ defaultValue,
14509
14519
  title,
14510
14520
  optionKey: optionKey2,
14511
14521
  format: format2,
@@ -14521,6 +14531,15 @@ Please add \`${key}Action\` when creating your handler.`);
14521
14531
  const [tabvalue, setTabvalue] = React.useState("c1");
14522
14532
  const [optionsData, setOptionsData] = React.useState([]);
14523
14533
  const isLazy = () => state.configs.lazy && Boolean(state.configs.onLoad);
14534
+ const [innerValue, setInnerValue] = usePropsValue({
14535
+ value,
14536
+ defaultValue,
14537
+ finalValue: defaultValue,
14538
+ onChange: (val) => {
14539
+ var _a2;
14540
+ (_a2 = props.onChange) == null ? void 0 : _a2.call(props, val);
14541
+ }
14542
+ });
14524
14543
  const [state] = React.useState({
14525
14544
  optionsData: [],
14526
14545
  panes: [
@@ -14530,7 +14549,6 @@ Please add \`${key}Action\` when creating your handler.`);
14530
14549
  paneKey: ""
14531
14550
  }
14532
14551
  ],
14533
- innerValue: value,
14534
14552
  tree: new Tree$1([], {}),
14535
14553
  tabsCursor: 0,
14536
14554
  // 选中的tab项
@@ -14550,12 +14568,12 @@ Please add \`${key}Action\` when creating your handler.`);
14550
14568
  });
14551
14569
  React.useEffect(() => {
14552
14570
  initData();
14553
- }, [options2]);
14571
+ }, [options2, format2]);
14554
14572
  React.useEffect(() => {
14555
- if (value !== state.innerValue) {
14556
- state.innerValue = value;
14573
+ if (defaultValue && defaultValue !== innerValue) {
14574
+ setInnerValue(defaultValue);
14557
14575
  }
14558
- }, [value]);
14576
+ }, [defaultValue]);
14559
14577
  const initData = async () => {
14560
14578
  state.lazyLoadMap.clear();
14561
14579
  if (format2 && Object.keys(format2).length > 0) {
@@ -14590,24 +14608,24 @@ Please add \`${key}Action\` when creating your handler.`);
14590
14608
  setOptionsData(state.panes);
14591
14609
  };
14592
14610
  const syncValue = async () => {
14593
- const currentValue2 = state.innerValue;
14594
- if (currentValue2 === void 0 || !state.tree.nodes.length) {
14611
+ const currentValue = innerValue;
14612
+ if (currentValue === void 0 || currentValue !== defaultValue || !state.tree.nodes.length) {
14595
14613
  return;
14596
14614
  }
14597
- if (currentValue2.length === 0) {
14615
+ if (currentValue.length === 0) {
14598
14616
  state.tabsCursor = 0;
14599
14617
  return;
14600
14618
  }
14601
- let needToSync = currentValue2;
14602
- if (isLazy() && Array.isArray(currentValue2) && currentValue2.length) {
14619
+ let needToSync = currentValue;
14620
+ if (isLazy() && Array.isArray(currentValue) && currentValue.length) {
14603
14621
  needToSync = [];
14604
14622
  const parent = state.tree.nodes.find(
14605
- (node) => node.value === currentValue2[0]
14623
+ (node) => node.value === currentValue[0]
14606
14624
  );
14607
14625
  if (parent) {
14608
14626
  needToSync = [parent.value];
14609
14627
  state.initLoading = true;
14610
- const last = await currentValue2.slice(1).reduce(async (p, value2) => {
14628
+ const last = await currentValue.slice(1).reduce(async (p, value2) => {
14611
14629
  var _a2;
14612
14630
  const parent2 = await p;
14613
14631
  await invokeLazyLoad(parent2);
@@ -14623,7 +14641,7 @@ Please add \`${key}Action\` when creating your handler.`);
14623
14641
  state.initLoading = false;
14624
14642
  }
14625
14643
  }
14626
- if (needToSync.length && currentValue2 === value) {
14644
+ if (needToSync.length && currentValue === defaultValue) {
14627
14645
  const pathNodes = state.tree.getPathNodesByValue(needToSync);
14628
14646
  pathNodes.forEach((node, index) => {
14629
14647
  state.tabsCursor = index;
@@ -14680,6 +14698,7 @@ Please add \`${key}Action\` when creating your handler.`);
14680
14698
  const optionParams = pathNodes.map((item) => item.value);
14681
14699
  onChange(optionParams, pathNodes);
14682
14700
  onPathChange(optionParams, pathNodes);
14701
+ setInnerValue(optionParams);
14683
14702
  }
14684
14703
  setOptionsData(state.panes);
14685
14704
  close();
@@ -18451,475 +18470,167 @@ Please add \`${key}Action\` when creating your handler.`);
18451
18470
  Radio.defaultProps = defaultProps$N;
18452
18471
  Radio.displayName = "NutRadio";
18453
18472
  Radio.RadioGroup = RadioGroup;
18454
- const fullClone = {
18455
- ...ReactDOM__namespace
18473
+ const defaultProps$M = {
18474
+ ...ComponentDefaults,
18475
+ range: false,
18476
+ min: 0,
18477
+ max: 100,
18478
+ step: 1,
18479
+ vertical: false,
18480
+ marks: {}
18456
18481
  };
18457
- const { version, render: reactRender, unmountComponentAtNode } = fullClone;
18458
- let createRoot;
18459
- try {
18460
- const mainVersion = Number((version || "").split(".")[0]);
18461
- if (mainVersion >= 18 && fullClone.createRoot) {
18462
- createRoot = fullClone.createRoot;
18463
- }
18464
- } catch (e) {
18465
- }
18466
- function toggleWarning(skip) {
18467
- const { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } = fullClone;
18468
- if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === "object") {
18469
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
18470
- }
18471
- }
18472
- const MARK = "__nutui_react_root__";
18473
- function legacyRender(node, container) {
18474
- reactRender(node, container);
18475
- }
18476
- function concurrentRender(node, container) {
18477
- toggleWarning(true);
18478
- const root2 = container[MARK] || createRoot(container);
18479
- toggleWarning(false);
18480
- root2.render(node);
18481
- container[MARK] = root2;
18482
- }
18483
- function render(node, container) {
18484
- if (createRoot) {
18485
- concurrentRender(node, container);
18486
- return;
18487
- }
18488
- legacyRender(node, container);
18489
- }
18490
- function legacyUnmount(container) {
18491
- return unmountComponentAtNode(container);
18492
- }
18493
- async function concurrentUnmount(container) {
18494
- return Promise.resolve().then(() => {
18495
- var _a2;
18496
- (_a2 = container[MARK]) == null ? void 0 : _a2.unmount();
18497
- delete container[MARK];
18482
+ const Range = (props) => {
18483
+ const {
18484
+ className,
18485
+ range: range2,
18486
+ disabled,
18487
+ button,
18488
+ vertical,
18489
+ marks,
18490
+ onChange,
18491
+ onStart,
18492
+ onEnd,
18493
+ minDescription,
18494
+ maxDescription,
18495
+ currentDescription,
18496
+ min,
18497
+ max,
18498
+ step,
18499
+ value,
18500
+ defaultValue
18501
+ } = { ...defaultProps$M, ...props };
18502
+ const classPrefix2 = "nut-range";
18503
+ const [buttonIndex, setButtonIndex] = React.useState(0);
18504
+ const [dragStatus, setDragStatus] = React.useState("start");
18505
+ const touch = useTouch();
18506
+ const root2 = React.useRef(null);
18507
+ const [marksList, setMarksList] = React.useState([]);
18508
+ const [startValue, setStartValue] = React.useState(0);
18509
+ const handleChange = (value2) => {
18510
+ onChange && onChange(value2);
18511
+ };
18512
+ const [current, setCurrent] = usePropsValue({
18513
+ value,
18514
+ defaultValue,
18515
+ finalValue: 0,
18516
+ onChange: handleChange
18498
18517
  });
18499
- }
18500
- function unmount(container) {
18501
- if (createRoot) {
18502
- return concurrentUnmount(container);
18503
- }
18504
- return legacyUnmount(container);
18505
- }
18506
- let Notification$1 = (_a = class extends React__namespace.PureComponent {
18507
- constructor(props) {
18508
- super(props);
18509
- __publicField(this, "closeTimer");
18510
- this.close = this.close.bind(this);
18511
- this.startCloseTimer = this.startCloseTimer.bind(this);
18512
- this.clearCloseTimer = this.clearCloseTimer.bind(this);
18513
- this.close = this.close.bind(this);
18514
- this.clickCover = this.clickCover.bind(this);
18515
- }
18516
- close() {
18517
- this.clearCloseTimer();
18518
- this.props.onClose();
18519
- }
18520
- startCloseTimer() {
18521
- const { duration } = this.props;
18522
- if (duration) {
18523
- this.closeTimer = window.setTimeout(() => {
18524
- this.close();
18525
- }, duration * 1e3);
18518
+ const [exactValue, setEaxctValue] = React.useState(
18519
+ () => value || defaultValue || 0
18520
+ );
18521
+ React.useEffect(() => {
18522
+ if (marks) {
18523
+ const marksKeys = Object.keys(marks);
18524
+ const list = marksKeys.map(parseFloat).sort((a2, b) => a2 - b).filter((point) => point >= min && point <= max);
18525
+ setMarksList(list);
18526
18526
  }
18527
- }
18528
- clearCloseTimer() {
18529
- if (this.closeTimer) {
18530
- clearTimeout(this.closeTimer);
18531
- this.closeTimer = -1;
18527
+ }, [marks]);
18528
+ const scope = () => {
18529
+ return max - min;
18530
+ };
18531
+ const classes = classNames(classPrefix2, {
18532
+ [`${classPrefix2}-disabled`]: disabled,
18533
+ [`${classPrefix2}-vertical`]: vertical
18534
+ });
18535
+ const containerClasses = classNames(`${classPrefix2}-container`, className, {
18536
+ [`${classPrefix2}-container-vertical`]: vertical
18537
+ });
18538
+ const markClassName = React.useCallback(
18539
+ (mark) => {
18540
+ const classPrefix22 = "nut-range-mark";
18541
+ let lowerBound = min;
18542
+ let upperBound = max;
18543
+ if (range2 && Array.isArray(current)) {
18544
+ lowerBound = current[0];
18545
+ upperBound = current[1];
18546
+ } else {
18547
+ upperBound = current;
18548
+ }
18549
+ const isActive = mark <= upperBound && mark >= lowerBound;
18550
+ return [
18551
+ `${classPrefix22}-text`,
18552
+ `${isActive ? `${classPrefix22}-text-active` : ""}`
18553
+ ].join(" ");
18554
+ },
18555
+ [range2, current, min, max]
18556
+ );
18557
+ const isRange = (val) => {
18558
+ return !!range2 && Array.isArray(val);
18559
+ };
18560
+ const calcMainAxis = () => {
18561
+ const modelVal = current;
18562
+ if (isRange(modelVal)) {
18563
+ return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
18532
18564
  }
18533
- }
18534
- clickCover() {
18535
- const { closeOnClickOverlay } = this.props;
18536
- if (closeOnClickOverlay) {
18537
- this.close();
18565
+ return `${(modelVal - min) * 100 / scope()}%`;
18566
+ };
18567
+ const calcOffset = () => {
18568
+ const modelVal = current;
18569
+ if (isRange(modelVal)) {
18570
+ return `${(modelVal[0] - min) * 100 / scope()}%`;
18538
18571
  }
18539
- }
18540
- componentDidMount() {
18541
- this.startCloseTimer();
18542
- }
18543
- componentWillUnmount() {
18544
- this.clearCloseTimer();
18545
- }
18546
- render() {
18547
- const {
18548
- id,
18549
- style,
18550
- icon,
18551
- title,
18552
- msg,
18553
- bottom,
18554
- center,
18555
- bgColor,
18556
- coverColor,
18557
- textAlignCenter,
18558
- size,
18559
- customClass,
18560
- cover,
18561
- type: type2
18562
- } = this.props;
18563
- const toastBem = cn("toast");
18564
- const classes = classNames({
18565
- "nut-toast-center": center,
18566
- "nut-toast-has-icon": icon,
18567
- "nut-toast-cover": cover,
18568
- "nut-toast-loading": type2 === "loading",
18569
- [`${customClass}`]: true,
18570
- [`nut-toast-${size}`]: true
18571
- });
18572
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
18573
- "div",
18574
- {
18575
- className: `${toastBem()} ${classes}`,
18576
- id: `toast-${id}`,
18577
- style: {
18578
- bottom: center ? "auto" : `${bottom}`,
18579
- backgroundColor: cover ? coverColor : "",
18580
- ...style
18581
- },
18582
- onClick: () => {
18583
- this.clickCover();
18584
- },
18585
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
18586
- "div",
18587
- {
18588
- className: toastBem("inner"),
18589
- style: {
18590
- textAlign: textAlignCenter ? "center" : "left",
18591
- backgroundColor: bgColor
18592
- },
18593
- children: [
18594
- icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: toastBem("icon-wrapper"), children: icon }) : null,
18595
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-toast-title", children: title }) : null,
18596
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: toastBem("text"), children: msg })
18597
- ]
18598
- }
18599
- )
18600
- }
18601
- ) });
18602
- }
18603
- }, __publicField(_a, "newInstance"), _a);
18604
- Notification$1.newInstance = (properties, callback) => {
18605
- const element = document.createElement("div");
18606
- if (properties.id) {
18607
- element.setAttribute("id", `${properties.id}`);
18608
- }
18609
- document.body.appendChild(element);
18610
- let called = false;
18611
- function ref(instance) {
18612
- if (called) {
18613
- return;
18614
- }
18615
- called = true;
18616
- callback({
18617
- component: instance,
18618
- destroy() {
18619
- unmount(element);
18620
- element && element.parentNode && element.parentNode.removeChild(element);
18621
- }
18622
- });
18623
- }
18624
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
18625
- };
18626
- let messageInstance$1 = null;
18627
- const options$1 = {
18628
- msg: "",
18629
- id: "",
18630
- style: {},
18631
- duration: 1.5,
18632
- // 时长,duration为0则一直展示
18633
- center: true,
18634
- // toast是否居中展示
18635
- type: "text",
18636
- title: "",
18637
- customClass: "",
18638
- // 自定义样式名
18639
- bottom: "30px",
18640
- // center为false时生效,距离底部位置
18641
- size: "base",
18642
- // 设置字体大小,默认base,可选large\small\base
18643
- icon: null,
18644
- iconSize: "20",
18645
- textAlignCenter: true,
18646
- // 文字是否居中显示,true为居中,false为left
18647
- loadingRotate: true,
18648
- // 未实现
18649
- bgColor: "rgba(0, 0, 0, .8)",
18650
- onClose: () => {
18651
- },
18652
- cover: false,
18653
- // 是否展示透明遮罩层
18654
- coverColor: "rgba(0, 0, 0, 0)",
18655
- // 遮罩颜色设定
18656
- closeOnClickOverlay: false
18657
- // 是否点击遮罩可关闭
18658
- };
18659
- function getInstance$1(props, callback) {
18660
- if (messageInstance$1) {
18661
- messageInstance$1.destroy();
18662
- messageInstance$1 = null;
18663
- }
18664
- Notification$1.newInstance(props, (notification) => {
18665
- return callback && callback(notification);
18666
- });
18667
- }
18668
- function notice$1(opts) {
18669
- function close() {
18670
- if (messageInstance$1) {
18671
- messageInstance$1.destroy();
18672
- messageInstance$1 = null;
18673
- }
18674
- }
18675
- const opts2 = { ...options$1, ...opts, onClose: close };
18676
- getInstance$1(opts2, (notification) => {
18677
- messageInstance$1 = notification;
18678
- });
18679
- }
18680
- const errorMsg$1 = (msg) => {
18681
- if (!msg) {
18682
- console.warn("[NutUI Toast]: msg cannot be null");
18683
- }
18684
- };
18685
- const Toast = {
18686
- text(msg, option = {}) {
18687
- errorMsg$1(msg);
18688
- return notice$1({ msg, type: "text", ...option });
18689
- },
18690
- success(msg, option = {}) {
18691
- errorMsg$1(msg);
18692
- return notice$1({ msg, icon: "success", type: "success", ...option });
18693
- },
18694
- fail(msg, option = {}) {
18695
- errorMsg$1(msg);
18696
- return notice$1({ msg, icon: "failure", type: "fail", ...option });
18697
- },
18698
- loading(msg, option = {}) {
18699
- errorMsg$1(msg);
18700
- return notice$1({ msg, icon: /* @__PURE__ */ jsxRuntimeExports.jsx(k$3, {}), type: "loading", ...option });
18701
- },
18702
- warn(msg, option = {}) {
18703
- errorMsg$1(msg);
18704
- return notice$1({ msg, icon: "tips", type: "warn", ...option });
18705
- },
18706
- customIcon(msg, option = {}) {
18707
- errorMsg$1(msg);
18708
- return notice$1({ msg, ...option });
18709
- },
18710
- hide() {
18711
- if (messageInstance$1) {
18712
- messageInstance$1.destroy();
18713
- messageInstance$1 = null;
18714
- }
18715
- }
18716
- };
18717
- const defaultProps$M = {
18718
- range: false,
18719
- hiddenRange: false,
18720
- hiddenTag: false,
18721
- min: 0,
18722
- max: 100,
18723
- step: 1,
18724
- modelValue: 0,
18725
- vertical: false,
18726
- marks: {}
18727
- };
18728
- let startValue;
18729
- let currentValue;
18730
- const Range = (props) => {
18731
- const { locale } = useConfig();
18732
- const {
18733
- className,
18734
- range: range2,
18735
- disabled,
18736
- activeColor,
18737
- inactiveColor,
18738
- buttonColor,
18739
- hiddenRange,
18740
- hiddenTag,
18741
- modelValue,
18742
- button,
18743
- vertical,
18744
- marks,
18745
- dragStart,
18746
- dragEnd,
18747
- onChange,
18748
- onDragStart,
18749
- onDragEnd,
18750
- minDesc,
18751
- maxDesc,
18752
- curValueDesc
18753
- } = { ...defaultProps$M, ...props };
18754
- let { min, max, step } = { ...defaultProps$M, ...props };
18755
- min = Number(min);
18756
- max = Number(max);
18757
- step = Number(step);
18758
- const [buttonIndex, SetButtonIndex] = React.useState(0);
18759
- const [initValue, SetInitValue] = React.useState();
18760
- const [dragStatus, SetDragStatus] = React.useState("start");
18761
- const touch = useTouch();
18762
- const root2 = React.useRef(null);
18763
- const [marksList, SetMarksList] = React.useState([]);
18764
- React.useEffect(() => {
18765
- if (typeof modelValue === "number") {
18766
- if (!range2 && (modelValue < min || modelValue > max)) {
18767
- SetInitValue(0);
18768
- Toast.text(`${modelValue} ${locale.range.rangeText}`);
18769
- return;
18770
- }
18771
- SetInitValue(modelValue);
18772
- }
18773
- }, [modelValue]);
18774
- React.useEffect(() => {
18775
- if (marks) {
18776
- const marksKeys = Object.keys(marks);
18777
- const list = marksKeys.map(parseFloat).sort((a2, b) => a2 - b).filter((point) => point >= min && point <= max);
18778
- SetMarksList(list);
18779
- }
18780
- }, [marks]);
18781
- const scope = () => {
18782
- return Number(max) - Number(min);
18783
- };
18784
- const classes = React.useCallback(() => {
18785
- const prefixCls2 = "nut-range";
18786
- return [
18787
- prefixCls2,
18788
- `${disabled ? `${prefixCls2}-disabled` : ""}`,
18789
- `${vertical ? `${prefixCls2}-vertical` : ""}`,
18790
- `${!hiddenRange ? `${prefixCls2}-show-number` : ""}`
18791
- ].filter(Boolean).join(" ");
18792
- }, [disabled, vertical, hiddenRange]);
18793
- const containerClasses = React.useCallback(() => {
18794
- const prefixCls2 = "nut-range-container";
18795
- return [prefixCls2, `${vertical ? `${prefixCls2}-vertical` : ""}`, className].filter(Boolean).join(" ");
18796
- }, [vertical, className]);
18797
- const markClassName = React.useCallback(
18798
- (mark) => {
18799
- const classPrefix2 = "nut-range-mark";
18800
- let lowerBound = Number(min);
18801
- let upperBound = Number(max);
18802
- if (range2) {
18803
- const [left, right] = modelValue;
18804
- lowerBound = left;
18805
- upperBound = right;
18806
- } else {
18807
- upperBound = modelValue;
18808
- }
18809
- const isActive = mark <= upperBound && mark >= lowerBound;
18810
- return [
18811
- `${classPrefix2}-text`,
18812
- `${isActive ? `${classPrefix2}-text-active` : ""}`
18813
- ].filter(Boolean).join(" ");
18814
- },
18815
- [range2, modelValue, min, max]
18816
- );
18817
- const [rangeName, setRangeName] = React.useState(classes());
18818
- const [containerName, setContainerName] = React.useState(containerClasses());
18819
- React.useEffect(() => {
18820
- setRangeName(classes());
18821
- setContainerName(containerClasses());
18822
- }, [classes, containerClasses]);
18823
- const wrapperStyle = () => {
18824
- return {
18825
- background: inactiveColor
18826
- };
18827
- };
18828
- const buttonStyle = () => {
18829
- return {
18830
- borderColor: buttonColor
18831
- };
18832
- };
18833
- const isRange = (val) => {
18834
- return !!range2 && Array.isArray(val);
18835
- };
18836
- const calcMainAxis = () => {
18837
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18838
- if (isRange(modelVal)) {
18839
- return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
18840
- }
18841
- return `${(modelVal - Number(min)) * 100 / scope()}%`;
18842
- };
18843
- const calcOffset = () => {
18844
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18845
- if (isRange(modelVal)) {
18846
- return `${(modelVal[0] - Number(min)) * 100 / scope()}%`;
18847
- }
18848
- return `0%`;
18849
- };
18850
- const barStyle = () => {
18851
- if (vertical) {
18852
- return {
18853
- height: calcMainAxis(),
18854
- top: calcOffset(),
18855
- background: activeColor,
18856
- transition: dragStatus ? "none" : void 0
18857
- };
18572
+ return `0%`;
18573
+ };
18574
+ const barStyle = () => {
18575
+ if (vertical) {
18576
+ return {
18577
+ height: calcMainAxis(),
18578
+ top: calcOffset(),
18579
+ transition: dragStatus ? "none" : void 0
18580
+ };
18858
18581
  }
18859
18582
  return {
18860
18583
  width: calcMainAxis(),
18861
18584
  left: calcOffset(),
18862
- background: activeColor,
18863
18585
  transition: dragStatus ? "none" : void 0
18864
18586
  };
18865
18587
  };
18866
18588
  const marksStyle = (mark) => {
18867
18589
  let style = {
18868
- left: `${(mark - Number(min)) / scope() * 100}%`
18590
+ left: `${(mark - min) / scope() * 100}%`
18869
18591
  };
18870
18592
  if (vertical) {
18871
18593
  style = {
18872
- top: `${(mark - Number(min)) / scope() * 100}%`
18594
+ top: `${(mark - min) / scope() * 100}%`
18873
18595
  };
18874
18596
  }
18875
18597
  return style;
18876
18598
  };
18877
- const tickStyle = (mark) => {
18878
- let lowerBound = Number(min);
18879
- let upperBound = Number(max);
18880
- if (range2) {
18881
- const [left, right] = modelValue;
18882
- lowerBound = left;
18883
- upperBound = right;
18599
+ const tickClass = (mark) => {
18600
+ if (range2 && Array.isArray(current)) {
18601
+ return mark <= current[1] && mark >= current[0];
18884
18602
  }
18885
- const isActive = mark <= upperBound && mark >= lowerBound;
18886
- const style = {
18887
- background: !isActive ? inactiveColor : activeColor
18888
- };
18889
- return style;
18603
+ return mark <= current;
18890
18604
  };
18891
- const format2 = (value) => {
18892
- value = Math.max(+min, Math.min(value, +max));
18893
- return Math.round(value / +step) * +step;
18605
+ const format2 = (value2) => {
18606
+ value2 = Math.max(+min, Math.min(value2, +max));
18607
+ return Math.round(value2 / +step) * +step;
18894
18608
  };
18895
18609
  const isSameValue = (newValue, oldValue) => {
18896
18610
  return JSON.stringify(newValue) === JSON.stringify(oldValue);
18897
18611
  };
18898
- const handleOverlap = (value) => {
18899
- if (value[0] > value[1]) {
18900
- return value.slice(0).reverse();
18612
+ const handleOverlap = (value2) => {
18613
+ if (value2[0] > value2[1]) {
18614
+ return value2.slice(0).reverse();
18901
18615
  }
18902
- return value;
18616
+ return value2;
18903
18617
  };
18904
- const updateValue = (value, end) => {
18905
- if (isRange(value)) {
18906
- value = handleOverlap(value).map(format2);
18618
+ const updateValue = (value2, end) => {
18619
+ if (isRange(value2)) {
18620
+ value2 = handleOverlap(value2).map(format2);
18907
18621
  } else {
18908
- value = format2(value);
18909
- }
18910
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18911
- if (!isSameValue(value, modelVal)) {
18912
- SetInitValue(value);
18622
+ value2 = format2(value2);
18913
18623
  }
18914
- if ((marks || end) && !isSameValue(value, startValue)) {
18915
- onChange && onChange(value);
18624
+ if (!isSameValue(value2, current)) {
18625
+ setCurrent(value2);
18916
18626
  }
18627
+ end && onEnd && onEnd(value2);
18917
18628
  };
18918
18629
  const click = (event) => {
18919
18630
  if (disabled || !root2.current) {
18920
18631
  return;
18921
18632
  }
18922
- SetDragStatus("");
18633
+ setDragStatus("");
18923
18634
  const rect = getRect(root2.current);
18924
18635
  let delta = event.clientX - rect.left;
18925
18636
  let total = rect.width;
@@ -18927,18 +18638,18 @@ Please add \`${key}Action\` when creating your handler.`);
18927
18638
  delta = event.clientY - rect.top;
18928
18639
  total = rect.height;
18929
18640
  }
18930
- const value = Number(min) + delta / total * scope();
18931
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18932
- if (isRange(currentValue)) {
18933
- const [left, right] = currentValue;
18641
+ const value2 = min + delta / total * scope();
18642
+ setEaxctValue(current);
18643
+ if (isRange(current)) {
18644
+ const [left, right] = current;
18934
18645
  const middle = (left + right) / 2;
18935
- if (value <= middle) {
18936
- updateValue([value, right], true);
18646
+ if (value2 <= middle) {
18647
+ updateValue([value2, right], true);
18937
18648
  } else {
18938
- updateValue([left, value], true);
18649
+ updateValue([left, value2], true);
18939
18650
  }
18940
18651
  } else {
18941
- updateValue(value, true);
18652
+ updateValue(value2, true);
18942
18653
  }
18943
18654
  };
18944
18655
  const onTouchStart = (event) => {
@@ -18946,24 +18657,24 @@ Please add \`${key}Action\` when creating your handler.`);
18946
18657
  return;
18947
18658
  }
18948
18659
  touch.start(event);
18949
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18950
- if (isRange(currentValue)) {
18951
- startValue = currentValue.map(format2);
18660
+ setEaxctValue(current);
18661
+ if (isRange(current)) {
18662
+ setStartValue(current.map(format2));
18952
18663
  } else {
18953
- startValue = format2(currentValue);
18664
+ setStartValue(format2(current));
18954
18665
  }
18955
- SetDragStatus("start");
18666
+ setDragStatus("start");
18956
18667
  };
18957
18668
  const onTouchMove = (event) => {
18669
+ event.stopPropagation();
18958
18670
  if (disabled || !root2.current) {
18959
18671
  return;
18960
18672
  }
18961
18673
  if (dragStatus === "start") {
18962
- dragStart && dragStart();
18963
- onDragStart && onDragStart();
18674
+ onStart && onStart();
18964
18675
  }
18965
18676
  touch.move(event);
18966
- SetDragStatus("draging");
18677
+ setDragStatus("draging");
18967
18678
  const rect = getRect(root2.current);
18968
18679
  let delta = touch.deltaX;
18969
18680
  let total = rect.width;
@@ -18973,121 +18684,91 @@ Please add \`${key}Action\` when creating your handler.`);
18973
18684
  total = rect.height;
18974
18685
  diff = delta / total * scope();
18975
18686
  }
18687
+ let newValue;
18976
18688
  if (isRange(startValue)) {
18977
- currentValue[buttonIndex] = startValue[buttonIndex] + diff;
18689
+ newValue = exactValue.slice();
18690
+ newValue[buttonIndex] = startValue[buttonIndex] + diff;
18978
18691
  } else {
18979
- currentValue = startValue + diff;
18692
+ newValue = startValue + diff;
18980
18693
  }
18981
- updateValue(currentValue);
18694
+ setEaxctValue(newValue);
18695
+ updateValue(newValue);
18982
18696
  };
18983
18697
  const onTouchEnd = (event) => {
18984
18698
  if (disabled) {
18985
18699
  return;
18986
18700
  }
18987
18701
  if (dragStatus === "draging") {
18988
- updateValue(currentValue, true);
18989
- dragEnd && dragEnd();
18990
- onDragEnd && onDragEnd();
18702
+ updateValue(current, true);
18991
18703
  }
18992
- SetDragStatus("");
18704
+ setDragStatus("");
18993
18705
  };
18994
18706
  const curValue = (idx) => {
18995
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18996
- const value = typeof idx === "number" ? modelVal[idx] : modelVal;
18997
- return value;
18707
+ const modelVal = current;
18708
+ const value2 = typeof idx === "number" ? modelVal[idx] : modelVal;
18709
+ return value2;
18998
18710
  };
18999
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${containerName}`, children: [
19000
- !hiddenRange ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min", children: minDesc || +min }) : null,
19001
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
19002
- "div",
19003
- {
19004
- ref: root2,
19005
- style: wrapperStyle(),
19006
- className: `${rangeName}`,
19007
- onClick: (e) => {
19008
- click(e);
19009
- },
19010
- children: [
19011
- marksList.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-mark", children: marksList.map((marks2) => {
19012
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
19013
- "span",
19014
- {
19015
- className: markClassName(marks2),
19016
- style: marksStyle(marks2),
19017
- children: [
19018
- marks2,
19019
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "nut-range-tick", style: tickStyle(marks2) })
19020
- ]
19021
- },
19022
- marks2
19023
- );
19024
- }) }) : null,
19025
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-bar", style: barStyle(), children: range2 ? [0, 1].map((item, index) => {
19026
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
19027
- "div",
19028
- {
19029
- role: "slider",
19030
- className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
18711
+ const renderButton = (index) => {
18712
+ 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) }) }) });
18713
+ };
18714
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: containerClasses, children: [
18715
+ minDescription !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min", children: minDescription || min }),
18716
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: root2, className: classes, onClick: (e) => click(e), children: [
18717
+ marksList.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-mark", children: marksList.map((marks2) => {
18718
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
18719
+ "span",
18720
+ {
18721
+ className: markClassName(marks2),
18722
+ style: marksStyle(marks2),
18723
+ children: [
18724
+ marks2,
18725
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
18726
+ "span",
18727
+ {
18728
+ className: classNames("nut-range-tick", {
18729
+ active: tickClass(marks2)
18730
+ })
18731
+ }
18732
+ )
18733
+ ]
18734
+ },
18735
+ marks2
18736
+ );
18737
+ }) }),
18738
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-bar", style: barStyle(), children: range2 ? [0, 1].map((item, index) => {
18739
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
18740
+ "div",
18741
+ {
18742
+ className: `${index === 0 ? "nut-range-button-wrapper-left" : ""}
19031
18743
  ${index === 1 ? "nut-range-button-wrapper-right" : ""}`,
19032
- tabIndex: disabled ? -1 : 0,
19033
- "aria-valuemin": +min,
19034
- "aria-valuenow": curValue(index),
19035
- "aria-valuemax": +max,
19036
- "aria-orientation": vertical ? "vertical" : "horizontal",
19037
- onTouchStart: (e) => {
19038
- if (typeof index === "number") {
19039
- SetButtonIndex(index);
19040
- }
19041
- onTouchStart(e);
19042
- },
19043
- onTouchMove: (e) => {
19044
- onTouchMove(e);
19045
- },
19046
- onTouchEnd: (e) => {
19047
- onTouchEnd();
19048
- },
19049
- onTouchCancel: (e) => {
19050
- onTouchEnd();
19051
- },
19052
- onClick: (e) => {
19053
- e.stopPropagation();
19054
- },
19055
- 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 })
19056
- },
19057
- index
19058
- );
19059
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
19060
- "div",
19061
- {
19062
- role: "slider",
19063
- className: "nut-range-button-wrapper",
19064
- tabIndex: disabled ? -1 : 0,
19065
- "aria-valuemin": +min,
19066
- "aria-valuenow": curValue(),
19067
- "aria-valuemax": +max,
19068
- "aria-orientation": vertical ? "vertical" : "horizontal",
19069
- onTouchStart: (e) => {
19070
- onTouchStart(e);
19071
- },
19072
- onTouchMove: (e) => {
19073
- onTouchMove(e);
19074
- },
19075
- onTouchEnd: (e) => {
19076
- onTouchEnd();
19077
- },
19078
- onTouchCancel: (e) => {
19079
- onTouchEnd();
19080
- },
19081
- onClick: (e) => {
19082
- e.stopPropagation();
19083
- },
19084
- children: button || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-button", style: buttonStyle(), children: !hiddenTag ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "number", children: curValueDesc || curValue() }) : null })
19085
- }
19086
- ) })
19087
- ]
19088
- }
19089
- ),
19090
- !hiddenRange ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max", children: maxDesc || +max }) : null
18744
+ onTouchStart: (e) => {
18745
+ if (typeof index === "number") {
18746
+ setButtonIndex(index);
18747
+ }
18748
+ onTouchStart(e);
18749
+ },
18750
+ onTouchMove: (e) => onTouchMove(e),
18751
+ onTouchEnd: (e) => onTouchEnd(),
18752
+ onTouchCancel: (e) => onTouchEnd(),
18753
+ onClick: (e) => e.stopPropagation(),
18754
+ children: renderButton(index)
18755
+ },
18756
+ index
18757
+ );
18758
+ }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
18759
+ "div",
18760
+ {
18761
+ className: "nut-range-button-wrapper",
18762
+ onTouchStart: (e) => onTouchStart(e),
18763
+ onTouchMove: (e) => onTouchMove(e),
18764
+ onTouchEnd: (e) => onTouchEnd(),
18765
+ onTouchCancel: (e) => onTouchEnd(),
18766
+ onClick: (e) => e.stopPropagation(),
18767
+ children: renderButton()
18768
+ }
18769
+ ) })
18770
+ ] }),
18771
+ maxDescription !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max", children: maxDescription || max })
19091
18772
  ] });
19092
18773
  };
19093
18774
  Range.defaultProps = defaultProps$M;
@@ -20591,6 +20272,58 @@ Please add \`${key}Action\` when creating your handler.`);
20591
20272
  };
20592
20273
  ActionSheet.defaultProps = defaultProps$D;
20593
20274
  ActionSheet.displayName = "NutActionSheet";
20275
+ const fullClone = {
20276
+ ...ReactDOM__namespace
20277
+ };
20278
+ const { version, render: reactRender, unmountComponentAtNode } = fullClone;
20279
+ let createRoot;
20280
+ try {
20281
+ const mainVersion = Number((version || "").split(".")[0]);
20282
+ if (mainVersion >= 18 && fullClone.createRoot) {
20283
+ createRoot = fullClone.createRoot;
20284
+ }
20285
+ } catch (e) {
20286
+ }
20287
+ function toggleWarning(skip) {
20288
+ const { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } = fullClone;
20289
+ if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === "object") {
20290
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
20291
+ }
20292
+ }
20293
+ const MARK = "__nutui_react_root__";
20294
+ function legacyRender(node, container) {
20295
+ reactRender(node, container);
20296
+ }
20297
+ function concurrentRender(node, container) {
20298
+ toggleWarning(true);
20299
+ const root2 = container[MARK] || createRoot(container);
20300
+ toggleWarning(false);
20301
+ root2.render(node);
20302
+ container[MARK] = root2;
20303
+ }
20304
+ function render(node, container) {
20305
+ if (createRoot) {
20306
+ concurrentRender(node, container);
20307
+ return;
20308
+ }
20309
+ legacyRender(node, container);
20310
+ }
20311
+ function legacyUnmount(container) {
20312
+ return unmountComponentAtNode(container);
20313
+ }
20314
+ async function concurrentUnmount(container) {
20315
+ return Promise.resolve().then(() => {
20316
+ var _a2;
20317
+ (_a2 = container[MARK]) == null ? void 0 : _a2.unmount();
20318
+ delete container[MARK];
20319
+ });
20320
+ }
20321
+ function unmount(container) {
20322
+ if (createRoot) {
20323
+ return concurrentUnmount(container);
20324
+ }
20325
+ return legacyUnmount(container);
20326
+ }
20594
20327
  function ConfirmDialog(props) {
20595
20328
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Dialog, { ...props, children: props.content });
20596
20329
  }
@@ -21637,7 +21370,7 @@ Please add \`${key}Action\` when creating your handler.`);
21637
21370
  };
21638
21371
  NoticeBar.defaultProps = defaultProps$y;
21639
21372
  NoticeBar.displayName = "NutNoticeBar";
21640
- class Notification extends React__namespace.PureComponent {
21373
+ let Notification$1 = (_a = class extends React__namespace.PureComponent {
21641
21374
  constructor(props) {
21642
21375
  super(props);
21643
21376
  __publicField(this, "closeTimer");
@@ -21728,9 +21461,8 @@ Please add \`${key}Action\` when creating your handler.`);
21728
21461
  }
21729
21462
  ) });
21730
21463
  }
21731
- }
21732
- __publicField(Notification, "newInstance");
21733
- Notification.newInstance = (properties, callback) => {
21464
+ }, __publicField(_a, "newInstance"), _a);
21465
+ Notification$1.newInstance = (properties, callback) => {
21734
21466
  const element = document.createElement("div");
21735
21467
  const id = properties.id ? properties.id : `${(/* @__PURE__ */ new Date()).getTime()}`;
21736
21468
  element.id = id;
@@ -21752,10 +21484,10 @@ Please add \`${key}Action\` when creating your handler.`);
21752
21484
  }
21753
21485
  });
21754
21486
  }
21755
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification, { ...properties, ref }), element);
21487
+ render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
21756
21488
  };
21757
- let messageInstance = null;
21758
- const options = {
21489
+ let messageInstance$1 = null;
21490
+ const options$1 = {
21759
21491
  msg: "",
21760
21492
  id: "",
21761
21493
  duration: 3e3,
@@ -21769,51 +21501,51 @@ Please add \`${key}Action\` when creating your handler.`);
21769
21501
  onClick: () => {
21770
21502
  }
21771
21503
  };
21772
- function getInstance(props, callback) {
21773
- if (messageInstance) {
21774
- messageInstance.destroy();
21775
- messageInstance = null;
21504
+ function getInstance$1(props, callback) {
21505
+ if (messageInstance$1) {
21506
+ messageInstance$1.destroy();
21507
+ messageInstance$1 = null;
21776
21508
  }
21777
- Notification.newInstance(props, (notification) => {
21509
+ Notification$1.newInstance(props, (notification) => {
21778
21510
  return callback && callback(notification);
21779
21511
  });
21780
21512
  }
21781
- function notice(opts) {
21782
- opts = { ...options, ...opts };
21783
- getInstance(opts, (notification) => {
21784
- messageInstance = notification;
21513
+ function notice$1(opts) {
21514
+ opts = { ...options$1, ...opts };
21515
+ getInstance$1(opts, (notification) => {
21516
+ messageInstance$1 = notification;
21785
21517
  });
21786
21518
  }
21787
- const errorMsg = (msg) => {
21519
+ const errorMsg$1 = (msg) => {
21788
21520
  if (!msg) {
21789
21521
  console.warn("[NutUI Notify]: msg不能为空");
21790
21522
  }
21791
21523
  };
21792
21524
  const Notify = {
21793
21525
  text(msg, option = {}) {
21794
- errorMsg(msg);
21795
- return notice({ msg, type: "base", ...option });
21526
+ errorMsg$1(msg);
21527
+ return notice$1({ msg, type: "base", ...option });
21796
21528
  },
21797
21529
  success(msg, option = {}) {
21798
- errorMsg(msg);
21799
- return notice({ msg, type: "success", ...option });
21530
+ errorMsg$1(msg);
21531
+ return notice$1({ msg, type: "success", ...option });
21800
21532
  },
21801
21533
  primary(msg, option = {}) {
21802
- errorMsg(msg);
21803
- return notice({ msg, type: "primary", ...option });
21534
+ errorMsg$1(msg);
21535
+ return notice$1({ msg, type: "primary", ...option });
21804
21536
  },
21805
21537
  danger(msg, option = {}) {
21806
- errorMsg(msg);
21807
- return notice({ msg, type: "danger", ...option });
21538
+ errorMsg$1(msg);
21539
+ return notice$1({ msg, type: "danger", ...option });
21808
21540
  },
21809
21541
  warn(msg, option = {}) {
21810
- errorMsg(msg);
21811
- return notice({ msg, type: "warning", ...option });
21542
+ errorMsg$1(msg);
21543
+ return notice$1({ msg, type: "warning", ...option });
21812
21544
  },
21813
21545
  hide() {
21814
- if (messageInstance) {
21815
- messageInstance.destroy();
21816
- messageInstance = null;
21546
+ if (messageInstance$1) {
21547
+ messageInstance$1.destroy();
21548
+ messageInstance$1 = null;
21817
21549
  }
21818
21550
  }
21819
21551
  };
@@ -22587,6 +22319,218 @@ Please add \`${key}Action\` when creating your handler.`);
22587
22319
  });
22588
22320
  Swipe.defaultProps = defaultProps$t;
22589
22321
  Swipe.displayName = "NutSwipe";
22322
+ class Notification extends React__namespace.PureComponent {
22323
+ constructor(props) {
22324
+ super(props);
22325
+ __publicField(this, "closeTimer");
22326
+ this.close = this.close.bind(this);
22327
+ this.startCloseTimer = this.startCloseTimer.bind(this);
22328
+ this.clearCloseTimer = this.clearCloseTimer.bind(this);
22329
+ this.close = this.close.bind(this);
22330
+ this.clickCover = this.clickCover.bind(this);
22331
+ }
22332
+ close() {
22333
+ this.clearCloseTimer();
22334
+ this.props.onClose();
22335
+ }
22336
+ startCloseTimer() {
22337
+ const { duration } = this.props;
22338
+ if (duration) {
22339
+ this.closeTimer = window.setTimeout(() => {
22340
+ this.close();
22341
+ }, duration * 1e3);
22342
+ }
22343
+ }
22344
+ clearCloseTimer() {
22345
+ if (this.closeTimer) {
22346
+ clearTimeout(this.closeTimer);
22347
+ this.closeTimer = -1;
22348
+ }
22349
+ }
22350
+ clickCover() {
22351
+ const { closeOnClickOverlay } = this.props;
22352
+ if (closeOnClickOverlay) {
22353
+ this.close();
22354
+ }
22355
+ }
22356
+ componentDidMount() {
22357
+ this.startCloseTimer();
22358
+ }
22359
+ componentWillUnmount() {
22360
+ this.clearCloseTimer();
22361
+ }
22362
+ render() {
22363
+ const {
22364
+ id,
22365
+ style,
22366
+ icon,
22367
+ title,
22368
+ msg,
22369
+ bottom,
22370
+ center,
22371
+ bgColor,
22372
+ coverColor,
22373
+ textAlignCenter,
22374
+ size,
22375
+ customClass,
22376
+ cover,
22377
+ type: type2
22378
+ } = this.props;
22379
+ const toastBem = cn("toast");
22380
+ const classes = classNames({
22381
+ "nut-toast-center": center,
22382
+ "nut-toast-has-icon": icon,
22383
+ "nut-toast-cover": cover,
22384
+ "nut-toast-loading": type2 === "loading",
22385
+ [`${customClass}`]: true,
22386
+ [`nut-toast-${size}`]: true
22387
+ });
22388
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22389
+ "div",
22390
+ {
22391
+ className: `${toastBem()} ${classes}`,
22392
+ id: `toast-${id}`,
22393
+ style: {
22394
+ bottom: center ? "auto" : `${bottom}`,
22395
+ backgroundColor: cover ? coverColor : "",
22396
+ ...style
22397
+ },
22398
+ onClick: () => {
22399
+ this.clickCover();
22400
+ },
22401
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
22402
+ "div",
22403
+ {
22404
+ className: toastBem("inner"),
22405
+ style: {
22406
+ textAlign: textAlignCenter ? "center" : "left",
22407
+ backgroundColor: bgColor
22408
+ },
22409
+ children: [
22410
+ icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: toastBem("icon-wrapper"), children: icon }) : null,
22411
+ title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-toast-title", children: title }) : null,
22412
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: toastBem("text"), children: msg })
22413
+ ]
22414
+ }
22415
+ )
22416
+ }
22417
+ ) });
22418
+ }
22419
+ }
22420
+ __publicField(Notification, "newInstance");
22421
+ Notification.newInstance = (properties, callback) => {
22422
+ const element = document.createElement("div");
22423
+ if (properties.id) {
22424
+ element.setAttribute("id", `${properties.id}`);
22425
+ }
22426
+ document.body.appendChild(element);
22427
+ let called = false;
22428
+ function ref(instance) {
22429
+ if (called) {
22430
+ return;
22431
+ }
22432
+ called = true;
22433
+ callback({
22434
+ component: instance,
22435
+ destroy() {
22436
+ unmount(element);
22437
+ element && element.parentNode && element.parentNode.removeChild(element);
22438
+ }
22439
+ });
22440
+ }
22441
+ render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification, { ...properties, ref }), element);
22442
+ };
22443
+ let messageInstance = null;
22444
+ const options = {
22445
+ msg: "",
22446
+ id: "",
22447
+ style: {},
22448
+ duration: 1.5,
22449
+ // 时长,duration为0则一直展示
22450
+ center: true,
22451
+ // toast是否居中展示
22452
+ type: "text",
22453
+ title: "",
22454
+ customClass: "",
22455
+ // 自定义样式名
22456
+ bottom: "30px",
22457
+ // center为false时生效,距离底部位置
22458
+ size: "base",
22459
+ // 设置字体大小,默认base,可选large\small\base
22460
+ icon: null,
22461
+ iconSize: "20",
22462
+ textAlignCenter: true,
22463
+ // 文字是否居中显示,true为居中,false为left
22464
+ loadingRotate: true,
22465
+ // 未实现
22466
+ bgColor: "rgba(0, 0, 0, .8)",
22467
+ onClose: () => {
22468
+ },
22469
+ cover: false,
22470
+ // 是否展示透明遮罩层
22471
+ coverColor: "rgba(0, 0, 0, 0)",
22472
+ // 遮罩颜色设定
22473
+ closeOnClickOverlay: false
22474
+ // 是否点击遮罩可关闭
22475
+ };
22476
+ function getInstance(props, callback) {
22477
+ if (messageInstance) {
22478
+ messageInstance.destroy();
22479
+ messageInstance = null;
22480
+ }
22481
+ Notification.newInstance(props, (notification) => {
22482
+ return callback && callback(notification);
22483
+ });
22484
+ }
22485
+ function notice(opts) {
22486
+ function close() {
22487
+ if (messageInstance) {
22488
+ messageInstance.destroy();
22489
+ messageInstance = null;
22490
+ }
22491
+ }
22492
+ const opts2 = { ...options, ...opts, onClose: close };
22493
+ getInstance(opts2, (notification) => {
22494
+ messageInstance = notification;
22495
+ });
22496
+ }
22497
+ const errorMsg = (msg) => {
22498
+ if (!msg) {
22499
+ console.warn("[NutUI Toast]: msg cannot be null");
22500
+ }
22501
+ };
22502
+ const Toast = {
22503
+ text(msg, option = {}) {
22504
+ errorMsg(msg);
22505
+ return notice({ msg, type: "text", ...option });
22506
+ },
22507
+ success(msg, option = {}) {
22508
+ errorMsg(msg);
22509
+ return notice({ msg, icon: "success", type: "success", ...option });
22510
+ },
22511
+ fail(msg, option = {}) {
22512
+ errorMsg(msg);
22513
+ return notice({ msg, icon: "failure", type: "fail", ...option });
22514
+ },
22515
+ loading(msg, option = {}) {
22516
+ errorMsg(msg);
22517
+ return notice({ msg, icon: /* @__PURE__ */ jsxRuntimeExports.jsx(k$3, {}), type: "loading", ...option });
22518
+ },
22519
+ warn(msg, option = {}) {
22520
+ errorMsg(msg);
22521
+ return notice({ msg, icon: "tips", type: "warn", ...option });
22522
+ },
22523
+ customIcon(msg, option = {}) {
22524
+ errorMsg(msg);
22525
+ return notice({ msg, ...option });
22526
+ },
22527
+ hide() {
22528
+ if (messageInstance) {
22529
+ messageInstance.destroy();
22530
+ messageInstance = null;
22531
+ }
22532
+ }
22533
+ };
22590
22534
  const defaultProps$s = {
22591
22535
  ...ComponentDefaults,
22592
22536
  type: "shake",
@@ -22863,9 +22807,11 @@ Please add \`${key}Action\` when creating your handler.`);
22863
22807
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${classPrefix2}__progress-bar-wrapper`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22864
22808
  Range,
22865
22809
  {
22866
- modelValue: percent,
22867
- hiddenTag: true,
22868
- hiddenRange: true,
22810
+ value: percent,
22811
+ onChange: (val) => setPercent(val),
22812
+ currentDescription: null,
22813
+ maxDescription: null,
22814
+ minDescription: null,
22869
22815
  "inactive-color": "#cccccc",
22870
22816
  "active-color": "#fa2c19"
22871
22817
  }