@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.
@@ -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.7 Fri May 12 2023 15:35:24 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,16 +12591,19 @@ 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
- if (current !== "") {
12603
+ if (current !== "" && current !== value) {
12599
12604
  setValue(current);
12605
+ } else {
12606
+ forceUpdate();
12600
12607
  }
12601
12608
  }, [children]);
12602
12609
  const classes = classNames(
@@ -12614,14 +12621,16 @@ Please add \`${key}Action\` when creating your handler.`);
12614
12621
  background: activeType === "line" ? activeColor : ""
12615
12622
  };
12616
12623
  React.useEffect(() => {
12617
- const index = titles.current.findIndex((t) => t.value === value);
12624
+ const index = titles.current.findIndex((t) => t.value == value);
12618
12625
  setContentStyle({
12619
12626
  transform: direction === "horizontal" ? `translate3d(-${index * 100}%, 0, 0)` : `translate3d( 0,-${index * 100}%, 0)`,
12620
12627
  transitionDuration: `${duration}ms`
12621
12628
  });
12622
- scrollIntoView(index);
12629
+ setTimeout(() => {
12630
+ scrollIntoView(index);
12631
+ });
12623
12632
  }, [value]);
12624
- const tabChange = (item, index) => {
12633
+ const tabChange = (item) => {
12625
12634
  onClick && onClick(item.value);
12626
12635
  if (item.disabled) {
12627
12636
  return;
@@ -12629,11 +12638,11 @@ Please add \`${key}Action\` when creating your handler.`);
12629
12638
  setValue(item.value);
12630
12639
  };
12631
12640
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes, ...rest, children: [
12632
- /* @__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) => {
12633
12642
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
12634
12643
  "div",
12635
12644
  {
12636
- onClick: (e) => {
12645
+ onClick: () => {
12637
12646
  tabChange(item);
12638
12647
  },
12639
12648
  className: classNames(`${classPrefix$a}__titles-item`, {
@@ -14482,7 +14491,6 @@ Please add \`${key}Action\` when creating your handler.`);
14482
14491
  popup: true,
14483
14492
  visible: false,
14484
14493
  options: [],
14485
- value: [],
14486
14494
  title: "",
14487
14495
  optionKey: { textKey: "text", valueKey: "value", childrenKey: "children" },
14488
14496
  format: {},
@@ -14497,8 +14505,7 @@ Please add \`${key}Action\` when creating your handler.`);
14497
14505
  onChange: () => {
14498
14506
  },
14499
14507
  onPathChange: () => {
14500
- },
14501
- ...Popup.defaultProps
14508
+ }
14502
14509
  };
14503
14510
  const InternalCascader = (props, ref) => {
14504
14511
  const {
@@ -14508,6 +14515,7 @@ Please add \`${key}Action\` when creating your handler.`);
14508
14515
  visible,
14509
14516
  options: options2,
14510
14517
  value,
14518
+ defaultValue,
14511
14519
  title,
14512
14520
  optionKey: optionKey2,
14513
14521
  format: format2,
@@ -14523,6 +14531,15 @@ Please add \`${key}Action\` when creating your handler.`);
14523
14531
  const [tabvalue, setTabvalue] = React.useState("c1");
14524
14532
  const [optionsData, setOptionsData] = React.useState([]);
14525
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
+ });
14526
14543
  const [state] = React.useState({
14527
14544
  optionsData: [],
14528
14545
  panes: [
@@ -14532,7 +14549,6 @@ Please add \`${key}Action\` when creating your handler.`);
14532
14549
  paneKey: ""
14533
14550
  }
14534
14551
  ],
14535
- innerValue: value,
14536
14552
  tree: new Tree$1([], {}),
14537
14553
  tabsCursor: 0,
14538
14554
  // 选中的tab项
@@ -14552,12 +14568,12 @@ Please add \`${key}Action\` when creating your handler.`);
14552
14568
  });
14553
14569
  React.useEffect(() => {
14554
14570
  initData();
14555
- }, [options2]);
14571
+ }, [options2, format2]);
14556
14572
  React.useEffect(() => {
14557
- if (value !== state.innerValue) {
14558
- state.innerValue = value;
14573
+ if (defaultValue && defaultValue !== innerValue) {
14574
+ setInnerValue(defaultValue);
14559
14575
  }
14560
- }, [value]);
14576
+ }, [defaultValue]);
14561
14577
  const initData = async () => {
14562
14578
  state.lazyLoadMap.clear();
14563
14579
  if (format2 && Object.keys(format2).length > 0) {
@@ -14592,24 +14608,24 @@ Please add \`${key}Action\` when creating your handler.`);
14592
14608
  setOptionsData(state.panes);
14593
14609
  };
14594
14610
  const syncValue = async () => {
14595
- const currentValue2 = state.innerValue;
14596
- if (currentValue2 === void 0 || !state.tree.nodes.length) {
14611
+ const currentValue = innerValue;
14612
+ if (currentValue === void 0 || currentValue !== defaultValue || !state.tree.nodes.length) {
14597
14613
  return;
14598
14614
  }
14599
- if (currentValue2.length === 0) {
14615
+ if (currentValue.length === 0) {
14600
14616
  state.tabsCursor = 0;
14601
14617
  return;
14602
14618
  }
14603
- let needToSync = currentValue2;
14604
- if (isLazy() && Array.isArray(currentValue2) && currentValue2.length) {
14619
+ let needToSync = currentValue;
14620
+ if (isLazy() && Array.isArray(currentValue) && currentValue.length) {
14605
14621
  needToSync = [];
14606
14622
  const parent = state.tree.nodes.find(
14607
- (node) => node.value === currentValue2[0]
14623
+ (node) => node.value === currentValue[0]
14608
14624
  );
14609
14625
  if (parent) {
14610
14626
  needToSync = [parent.value];
14611
14627
  state.initLoading = true;
14612
- const last = await currentValue2.slice(1).reduce(async (p, value2) => {
14628
+ const last = await currentValue.slice(1).reduce(async (p, value2) => {
14613
14629
  var _a2;
14614
14630
  const parent2 = await p;
14615
14631
  await invokeLazyLoad(parent2);
@@ -14625,7 +14641,7 @@ Please add \`${key}Action\` when creating your handler.`);
14625
14641
  state.initLoading = false;
14626
14642
  }
14627
14643
  }
14628
- if (needToSync.length && currentValue2 === value) {
14644
+ if (needToSync.length && currentValue === defaultValue) {
14629
14645
  const pathNodes = state.tree.getPathNodesByValue(needToSync);
14630
14646
  pathNodes.forEach((node, index) => {
14631
14647
  state.tabsCursor = index;
@@ -14682,6 +14698,7 @@ Please add \`${key}Action\` when creating your handler.`);
14682
14698
  const optionParams = pathNodes.map((item) => item.value);
14683
14699
  onChange(optionParams, pathNodes);
14684
14700
  onPathChange(optionParams, pathNodes);
14701
+ setInnerValue(optionParams);
14685
14702
  }
14686
14703
  setOptionsData(state.panes);
14687
14704
  close();
@@ -18453,475 +18470,167 @@ Please add \`${key}Action\` when creating your handler.`);
18453
18470
  Radio.defaultProps = defaultProps$N;
18454
18471
  Radio.displayName = "NutRadio";
18455
18472
  Radio.RadioGroup = RadioGroup;
18456
- const fullClone = {
18457
- ...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: {}
18458
18481
  };
18459
- const { version, render: reactRender, unmountComponentAtNode } = fullClone;
18460
- let createRoot;
18461
- try {
18462
- const mainVersion = Number((version || "").split(".")[0]);
18463
- if (mainVersion >= 18 && fullClone.createRoot) {
18464
- createRoot = fullClone.createRoot;
18465
- }
18466
- } catch (e) {
18467
- }
18468
- function toggleWarning(skip) {
18469
- const { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } = fullClone;
18470
- if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === "object") {
18471
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
18472
- }
18473
- }
18474
- const MARK = "__nutui_react_root__";
18475
- function legacyRender(node, container) {
18476
- reactRender(node, container);
18477
- }
18478
- function concurrentRender(node, container) {
18479
- toggleWarning(true);
18480
- const root2 = container[MARK] || createRoot(container);
18481
- toggleWarning(false);
18482
- root2.render(node);
18483
- container[MARK] = root2;
18484
- }
18485
- function render(node, container) {
18486
- if (createRoot) {
18487
- concurrentRender(node, container);
18488
- return;
18489
- }
18490
- legacyRender(node, container);
18491
- }
18492
- function legacyUnmount(container) {
18493
- return unmountComponentAtNode(container);
18494
- }
18495
- async function concurrentUnmount(container) {
18496
- return Promise.resolve().then(() => {
18497
- var _a2;
18498
- (_a2 = container[MARK]) == null ? void 0 : _a2.unmount();
18499
- 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
18500
18517
  });
18501
- }
18502
- function unmount(container) {
18503
- if (createRoot) {
18504
- return concurrentUnmount(container);
18505
- }
18506
- return legacyUnmount(container);
18507
- }
18508
- let Notification$1 = (_a = class extends React__namespace.PureComponent {
18509
- constructor(props) {
18510
- super(props);
18511
- __publicField(this, "closeTimer");
18512
- this.close = this.close.bind(this);
18513
- this.startCloseTimer = this.startCloseTimer.bind(this);
18514
- this.clearCloseTimer = this.clearCloseTimer.bind(this);
18515
- this.close = this.close.bind(this);
18516
- this.clickCover = this.clickCover.bind(this);
18517
- }
18518
- close() {
18519
- this.clearCloseTimer();
18520
- this.props.onClose();
18521
- }
18522
- startCloseTimer() {
18523
- const { duration } = this.props;
18524
- if (duration) {
18525
- this.closeTimer = window.setTimeout(() => {
18526
- this.close();
18527
- }, 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);
18528
18526
  }
18529
- }
18530
- clearCloseTimer() {
18531
- if (this.closeTimer) {
18532
- clearTimeout(this.closeTimer);
18533
- 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()}%`;
18534
18564
  }
18535
- }
18536
- clickCover() {
18537
- const { closeOnClickOverlay } = this.props;
18538
- if (closeOnClickOverlay) {
18539
- 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()}%`;
18540
18571
  }
18541
- }
18542
- componentDidMount() {
18543
- this.startCloseTimer();
18544
- }
18545
- componentWillUnmount() {
18546
- this.clearCloseTimer();
18547
- }
18548
- render() {
18549
- const {
18550
- id,
18551
- style,
18552
- icon,
18553
- title,
18554
- msg,
18555
- bottom,
18556
- center,
18557
- bgColor,
18558
- coverColor,
18559
- textAlignCenter,
18560
- size,
18561
- customClass,
18562
- cover,
18563
- type: type2
18564
- } = this.props;
18565
- const toastBem = cn("toast");
18566
- const classes = classNames({
18567
- "nut-toast-center": center,
18568
- "nut-toast-has-icon": icon,
18569
- "nut-toast-cover": cover,
18570
- "nut-toast-loading": type2 === "loading",
18571
- [`${customClass}`]: true,
18572
- [`nut-toast-${size}`]: true
18573
- });
18574
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
18575
- "div",
18576
- {
18577
- className: `${toastBem()} ${classes}`,
18578
- id: `toast-${id}`,
18579
- style: {
18580
- bottom: center ? "auto" : `${bottom}`,
18581
- backgroundColor: cover ? coverColor : "",
18582
- ...style
18583
- },
18584
- onClick: () => {
18585
- this.clickCover();
18586
- },
18587
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
18588
- "div",
18589
- {
18590
- className: toastBem("inner"),
18591
- style: {
18592
- textAlign: textAlignCenter ? "center" : "left",
18593
- backgroundColor: bgColor
18594
- },
18595
- children: [
18596
- icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: toastBem("icon-wrapper"), children: icon }) : null,
18597
- title ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-toast-title", children: title }) : null,
18598
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: toastBem("text"), children: msg })
18599
- ]
18600
- }
18601
- )
18602
- }
18603
- ) });
18604
- }
18605
- }, __publicField(_a, "newInstance"), _a);
18606
- Notification$1.newInstance = (properties, callback) => {
18607
- const element = document.createElement("div");
18608
- if (properties.id) {
18609
- element.setAttribute("id", `${properties.id}`);
18610
- }
18611
- document.body.appendChild(element);
18612
- let called = false;
18613
- function ref(instance) {
18614
- if (called) {
18615
- return;
18616
- }
18617
- called = true;
18618
- callback({
18619
- component: instance,
18620
- destroy() {
18621
- unmount(element);
18622
- element && element.parentNode && element.parentNode.removeChild(element);
18623
- }
18624
- });
18625
- }
18626
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
18627
- };
18628
- let messageInstance$1 = null;
18629
- const options$1 = {
18630
- msg: "",
18631
- id: "",
18632
- style: {},
18633
- duration: 1.5,
18634
- // 时长,duration为0则一直展示
18635
- center: true,
18636
- // toast是否居中展示
18637
- type: "text",
18638
- title: "",
18639
- customClass: "",
18640
- // 自定义样式名
18641
- bottom: "30px",
18642
- // center为false时生效,距离底部位置
18643
- size: "base",
18644
- // 设置字体大小,默认base,可选large\small\base
18645
- icon: null,
18646
- iconSize: "20",
18647
- textAlignCenter: true,
18648
- // 文字是否居中显示,true为居中,false为left
18649
- loadingRotate: true,
18650
- // 未实现
18651
- bgColor: "rgba(0, 0, 0, .8)",
18652
- onClose: () => {
18653
- },
18654
- cover: false,
18655
- // 是否展示透明遮罩层
18656
- coverColor: "rgba(0, 0, 0, 0)",
18657
- // 遮罩颜色设定
18658
- closeOnClickOverlay: false
18659
- // 是否点击遮罩可关闭
18660
- };
18661
- function getInstance$1(props, callback) {
18662
- if (messageInstance$1) {
18663
- messageInstance$1.destroy();
18664
- messageInstance$1 = null;
18665
- }
18666
- Notification$1.newInstance(props, (notification) => {
18667
- return callback && callback(notification);
18668
- });
18669
- }
18670
- function notice$1(opts) {
18671
- function close() {
18672
- if (messageInstance$1) {
18673
- messageInstance$1.destroy();
18674
- messageInstance$1 = null;
18675
- }
18676
- }
18677
- const opts2 = { ...options$1, ...opts, onClose: close };
18678
- getInstance$1(opts2, (notification) => {
18679
- messageInstance$1 = notification;
18680
- });
18681
- }
18682
- const errorMsg$1 = (msg) => {
18683
- if (!msg) {
18684
- console.warn("[NutUI Toast]: msg cannot be null");
18685
- }
18686
- };
18687
- const Toast = {
18688
- text(msg, option = {}) {
18689
- errorMsg$1(msg);
18690
- return notice$1({ msg, type: "text", ...option });
18691
- },
18692
- success(msg, option = {}) {
18693
- errorMsg$1(msg);
18694
- return notice$1({ msg, icon: "success", type: "success", ...option });
18695
- },
18696
- fail(msg, option = {}) {
18697
- errorMsg$1(msg);
18698
- return notice$1({ msg, icon: "failure", type: "fail", ...option });
18699
- },
18700
- loading(msg, option = {}) {
18701
- errorMsg$1(msg);
18702
- return notice$1({ msg, icon: /* @__PURE__ */ jsxRuntimeExports.jsx(k$3, {}), type: "loading", ...option });
18703
- },
18704
- warn(msg, option = {}) {
18705
- errorMsg$1(msg);
18706
- return notice$1({ msg, icon: "tips", type: "warn", ...option });
18707
- },
18708
- customIcon(msg, option = {}) {
18709
- errorMsg$1(msg);
18710
- return notice$1({ msg, ...option });
18711
- },
18712
- hide() {
18713
- if (messageInstance$1) {
18714
- messageInstance$1.destroy();
18715
- messageInstance$1 = null;
18716
- }
18717
- }
18718
- };
18719
- const defaultProps$M = {
18720
- range: false,
18721
- hiddenRange: false,
18722
- hiddenTag: false,
18723
- min: 0,
18724
- max: 100,
18725
- step: 1,
18726
- modelValue: 0,
18727
- vertical: false,
18728
- marks: {}
18729
- };
18730
- let startValue;
18731
- let currentValue;
18732
- const Range = (props) => {
18733
- const { locale } = useConfig();
18734
- const {
18735
- className,
18736
- range: range2,
18737
- disabled,
18738
- activeColor,
18739
- inactiveColor,
18740
- buttonColor,
18741
- hiddenRange,
18742
- hiddenTag,
18743
- modelValue,
18744
- button,
18745
- vertical,
18746
- marks,
18747
- dragStart,
18748
- dragEnd,
18749
- onChange,
18750
- onDragStart,
18751
- onDragEnd,
18752
- minDesc,
18753
- maxDesc,
18754
- curValueDesc
18755
- } = { ...defaultProps$M, ...props };
18756
- let { min, max, step } = { ...defaultProps$M, ...props };
18757
- min = Number(min);
18758
- max = Number(max);
18759
- step = Number(step);
18760
- const [buttonIndex, SetButtonIndex] = React.useState(0);
18761
- const [initValue, SetInitValue] = React.useState();
18762
- const [dragStatus, SetDragStatus] = React.useState("start");
18763
- const touch = useTouch();
18764
- const root2 = React.useRef(null);
18765
- const [marksList, SetMarksList] = React.useState([]);
18766
- React.useEffect(() => {
18767
- if (typeof modelValue === "number") {
18768
- if (!range2 && (modelValue < min || modelValue > max)) {
18769
- SetInitValue(0);
18770
- Toast.text(`${modelValue} ${locale.range.rangeText}`);
18771
- return;
18772
- }
18773
- SetInitValue(modelValue);
18774
- }
18775
- }, [modelValue]);
18776
- React.useEffect(() => {
18777
- if (marks) {
18778
- const marksKeys = Object.keys(marks);
18779
- const list = marksKeys.map(parseFloat).sort((a2, b) => a2 - b).filter((point) => point >= min && point <= max);
18780
- SetMarksList(list);
18781
- }
18782
- }, [marks]);
18783
- const scope = () => {
18784
- return Number(max) - Number(min);
18785
- };
18786
- const classes = React.useCallback(() => {
18787
- const prefixCls2 = "nut-range";
18788
- return [
18789
- prefixCls2,
18790
- `${disabled ? `${prefixCls2}-disabled` : ""}`,
18791
- `${vertical ? `${prefixCls2}-vertical` : ""}`,
18792
- `${!hiddenRange ? `${prefixCls2}-show-number` : ""}`
18793
- ].filter(Boolean).join(" ");
18794
- }, [disabled, vertical, hiddenRange]);
18795
- const containerClasses = React.useCallback(() => {
18796
- const prefixCls2 = "nut-range-container";
18797
- return [prefixCls2, `${vertical ? `${prefixCls2}-vertical` : ""}`, className].filter(Boolean).join(" ");
18798
- }, [vertical, className]);
18799
- const markClassName = React.useCallback(
18800
- (mark) => {
18801
- const classPrefix2 = "nut-range-mark";
18802
- let lowerBound = Number(min);
18803
- let upperBound = Number(max);
18804
- if (range2) {
18805
- const [left, right] = modelValue;
18806
- lowerBound = left;
18807
- upperBound = right;
18808
- } else {
18809
- upperBound = modelValue;
18810
- }
18811
- const isActive = mark <= upperBound && mark >= lowerBound;
18812
- return [
18813
- `${classPrefix2}-text`,
18814
- `${isActive ? `${classPrefix2}-text-active` : ""}`
18815
- ].filter(Boolean).join(" ");
18816
- },
18817
- [range2, modelValue, min, max]
18818
- );
18819
- const [rangeName, setRangeName] = React.useState(classes());
18820
- const [containerName, setContainerName] = React.useState(containerClasses());
18821
- React.useEffect(() => {
18822
- setRangeName(classes());
18823
- setContainerName(containerClasses());
18824
- }, [classes, containerClasses]);
18825
- const wrapperStyle = () => {
18826
- return {
18827
- background: inactiveColor
18828
- };
18829
- };
18830
- const buttonStyle = () => {
18831
- return {
18832
- borderColor: buttonColor
18833
- };
18834
- };
18835
- const isRange = (val) => {
18836
- return !!range2 && Array.isArray(val);
18837
- };
18838
- const calcMainAxis = () => {
18839
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18840
- if (isRange(modelVal)) {
18841
- return `${(modelVal[1] - modelVal[0]) * 100 / scope()}%`;
18842
- }
18843
- return `${(modelVal - Number(min)) * 100 / scope()}%`;
18844
- };
18845
- const calcOffset = () => {
18846
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18847
- if (isRange(modelVal)) {
18848
- return `${(modelVal[0] - Number(min)) * 100 / scope()}%`;
18849
- }
18850
- return `0%`;
18851
- };
18852
- const barStyle = () => {
18853
- if (vertical) {
18854
- return {
18855
- height: calcMainAxis(),
18856
- top: calcOffset(),
18857
- background: activeColor,
18858
- transition: dragStatus ? "none" : void 0
18859
- };
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
+ };
18860
18581
  }
18861
18582
  return {
18862
18583
  width: calcMainAxis(),
18863
18584
  left: calcOffset(),
18864
- background: activeColor,
18865
18585
  transition: dragStatus ? "none" : void 0
18866
18586
  };
18867
18587
  };
18868
18588
  const marksStyle = (mark) => {
18869
18589
  let style = {
18870
- left: `${(mark - Number(min)) / scope() * 100}%`
18590
+ left: `${(mark - min) / scope() * 100}%`
18871
18591
  };
18872
18592
  if (vertical) {
18873
18593
  style = {
18874
- top: `${(mark - Number(min)) / scope() * 100}%`
18594
+ top: `${(mark - min) / scope() * 100}%`
18875
18595
  };
18876
18596
  }
18877
18597
  return style;
18878
18598
  };
18879
- const tickStyle = (mark) => {
18880
- let lowerBound = Number(min);
18881
- let upperBound = Number(max);
18882
- if (range2) {
18883
- const [left, right] = modelValue;
18884
- lowerBound = left;
18885
- upperBound = right;
18599
+ const tickClass = (mark) => {
18600
+ if (range2 && Array.isArray(current)) {
18601
+ return mark <= current[1] && mark >= current[0];
18886
18602
  }
18887
- const isActive = mark <= upperBound && mark >= lowerBound;
18888
- const style = {
18889
- background: !isActive ? inactiveColor : activeColor
18890
- };
18891
- return style;
18603
+ return mark <= current;
18892
18604
  };
18893
- const format2 = (value) => {
18894
- value = Math.max(+min, Math.min(value, +max));
18895
- 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;
18896
18608
  };
18897
18609
  const isSameValue = (newValue, oldValue) => {
18898
18610
  return JSON.stringify(newValue) === JSON.stringify(oldValue);
18899
18611
  };
18900
- const handleOverlap = (value) => {
18901
- if (value[0] > value[1]) {
18902
- return value.slice(0).reverse();
18612
+ const handleOverlap = (value2) => {
18613
+ if (value2[0] > value2[1]) {
18614
+ return value2.slice(0).reverse();
18903
18615
  }
18904
- return value;
18616
+ return value2;
18905
18617
  };
18906
- const updateValue = (value, end) => {
18907
- if (isRange(value)) {
18908
- value = handleOverlap(value).map(format2);
18618
+ const updateValue = (value2, end) => {
18619
+ if (isRange(value2)) {
18620
+ value2 = handleOverlap(value2).map(format2);
18909
18621
  } else {
18910
- value = format2(value);
18622
+ value2 = format2(value2);
18911
18623
  }
18912
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18913
- if (!isSameValue(value, modelVal)) {
18914
- SetInitValue(value);
18915
- }
18916
- if ((marks || end) && !isSameValue(value, startValue)) {
18917
- onChange && onChange(value);
18624
+ if (!isSameValue(value2, current)) {
18625
+ setCurrent(value2);
18918
18626
  }
18627
+ end && onEnd && onEnd(value2);
18919
18628
  };
18920
18629
  const click = (event) => {
18921
18630
  if (disabled || !root2.current) {
18922
18631
  return;
18923
18632
  }
18924
- SetDragStatus("");
18633
+ setDragStatus("");
18925
18634
  const rect = getRect(root2.current);
18926
18635
  let delta = event.clientX - rect.left;
18927
18636
  let total = rect.width;
@@ -18929,18 +18638,18 @@ Please add \`${key}Action\` when creating your handler.`);
18929
18638
  delta = event.clientY - rect.top;
18930
18639
  total = rect.height;
18931
18640
  }
18932
- const value = Number(min) + delta / total * scope();
18933
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18934
- if (isRange(currentValue)) {
18935
- const [left, right] = currentValue;
18641
+ const value2 = min + delta / total * scope();
18642
+ setEaxctValue(current);
18643
+ if (isRange(current)) {
18644
+ const [left, right] = current;
18936
18645
  const middle = (left + right) / 2;
18937
- if (value <= middle) {
18938
- updateValue([value, right], true);
18646
+ if (value2 <= middle) {
18647
+ updateValue([value2, right], true);
18939
18648
  } else {
18940
- updateValue([left, value], true);
18649
+ updateValue([left, value2], true);
18941
18650
  }
18942
18651
  } else {
18943
- updateValue(value, true);
18652
+ updateValue(value2, true);
18944
18653
  }
18945
18654
  };
18946
18655
  const onTouchStart = (event) => {
@@ -18948,24 +18657,24 @@ Please add \`${key}Action\` when creating your handler.`);
18948
18657
  return;
18949
18658
  }
18950
18659
  touch.start(event);
18951
- currentValue = initValue || initValue === 0 ? initValue : modelValue;
18952
- if (isRange(currentValue)) {
18953
- startValue = currentValue.map(format2);
18660
+ setEaxctValue(current);
18661
+ if (isRange(current)) {
18662
+ setStartValue(current.map(format2));
18954
18663
  } else {
18955
- startValue = format2(currentValue);
18664
+ setStartValue(format2(current));
18956
18665
  }
18957
- SetDragStatus("start");
18666
+ setDragStatus("start");
18958
18667
  };
18959
18668
  const onTouchMove = (event) => {
18669
+ event.stopPropagation();
18960
18670
  if (disabled || !root2.current) {
18961
18671
  return;
18962
18672
  }
18963
18673
  if (dragStatus === "start") {
18964
- dragStart && dragStart();
18965
- onDragStart && onDragStart();
18674
+ onStart && onStart();
18966
18675
  }
18967
18676
  touch.move(event);
18968
- SetDragStatus("draging");
18677
+ setDragStatus("draging");
18969
18678
  const rect = getRect(root2.current);
18970
18679
  let delta = touch.deltaX;
18971
18680
  let total = rect.width;
@@ -18975,121 +18684,91 @@ Please add \`${key}Action\` when creating your handler.`);
18975
18684
  total = rect.height;
18976
18685
  diff = delta / total * scope();
18977
18686
  }
18687
+ let newValue;
18978
18688
  if (isRange(startValue)) {
18979
- currentValue[buttonIndex] = startValue[buttonIndex] + diff;
18689
+ newValue = exactValue.slice();
18690
+ newValue[buttonIndex] = startValue[buttonIndex] + diff;
18980
18691
  } else {
18981
- currentValue = startValue + diff;
18692
+ newValue = startValue + diff;
18982
18693
  }
18983
- updateValue(currentValue);
18694
+ setEaxctValue(newValue);
18695
+ updateValue(newValue);
18984
18696
  };
18985
18697
  const onTouchEnd = (event) => {
18986
18698
  if (disabled) {
18987
18699
  return;
18988
18700
  }
18989
18701
  if (dragStatus === "draging") {
18990
- updateValue(currentValue, true);
18991
- dragEnd && dragEnd();
18992
- onDragEnd && onDragEnd();
18702
+ updateValue(current, true);
18993
18703
  }
18994
- SetDragStatus("");
18704
+ setDragStatus("");
18995
18705
  };
18996
18706
  const curValue = (idx) => {
18997
- const modelVal = initValue || initValue === 0 ? initValue : modelValue;
18998
- const value = typeof idx === "number" ? modelVal[idx] : modelVal;
18999
- return value;
18707
+ const modelVal = current;
18708
+ const value2 = typeof idx === "number" ? modelVal[idx] : modelVal;
18709
+ return value2;
19000
18710
  };
19001
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${containerName}`, children: [
19002
- !hiddenRange ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min", children: minDesc || +min }) : null,
19003
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
19004
- "div",
19005
- {
19006
- ref: root2,
19007
- style: wrapperStyle(),
19008
- className: `${rangeName}`,
19009
- onClick: (e) => {
19010
- click(e);
19011
- },
19012
- children: [
19013
- marksList.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-mark", children: marksList.map((marks2) => {
19014
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
19015
- "span",
19016
- {
19017
- className: markClassName(marks2),
19018
- style: marksStyle(marks2),
19019
- children: [
19020
- marks2,
19021
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "nut-range-tick", style: tickStyle(marks2) })
19022
- ]
19023
- },
19024
- marks2
19025
- );
19026
- }) }) : null,
19027
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-bar", style: barStyle(), children: range2 ? [0, 1].map((item, index) => {
19028
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
19029
- "div",
19030
- {
19031
- role: "slider",
19032
- 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" : ""}
19033
18743
  ${index === 1 ? "nut-range-button-wrapper-right" : ""}`,
19034
- tabIndex: disabled ? -1 : 0,
19035
- "aria-valuemin": +min,
19036
- "aria-valuenow": curValue(index),
19037
- "aria-valuemax": +max,
19038
- "aria-orientation": vertical ? "vertical" : "horizontal",
19039
- onTouchStart: (e) => {
19040
- if (typeof index === "number") {
19041
- SetButtonIndex(index);
19042
- }
19043
- onTouchStart(e);
19044
- },
19045
- onTouchMove: (e) => {
19046
- onTouchMove(e);
19047
- },
19048
- onTouchEnd: (e) => {
19049
- onTouchEnd();
19050
- },
19051
- onTouchCancel: (e) => {
19052
- onTouchEnd();
19053
- },
19054
- onClick: (e) => {
19055
- e.stopPropagation();
19056
- },
19057
- 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 })
19058
- },
19059
- index
19060
- );
19061
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
19062
- "div",
19063
- {
19064
- role: "slider",
19065
- className: "nut-range-button-wrapper",
19066
- tabIndex: disabled ? -1 : 0,
19067
- "aria-valuemin": +min,
19068
- "aria-valuenow": curValue(),
19069
- "aria-valuemax": +max,
19070
- "aria-orientation": vertical ? "vertical" : "horizontal",
19071
- onTouchStart: (e) => {
19072
- onTouchStart(e);
19073
- },
19074
- onTouchMove: (e) => {
19075
- onTouchMove(e);
19076
- },
19077
- onTouchEnd: (e) => {
19078
- onTouchEnd();
19079
- },
19080
- onTouchCancel: (e) => {
19081
- onTouchEnd();
19082
- },
19083
- onClick: (e) => {
19084
- e.stopPropagation();
19085
- },
19086
- children: button || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "nut-range-button", style: buttonStyle(), children: !hiddenTag ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "number", children: curValueDesc || curValue() }) : null })
19087
- }
19088
- ) })
19089
- ]
19090
- }
19091
- ),
19092
- !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 })
19093
18772
  ] });
19094
18773
  };
19095
18774
  Range.defaultProps = defaultProps$M;
@@ -20593,6 +20272,58 @@ Please add \`${key}Action\` when creating your handler.`);
20593
20272
  };
20594
20273
  ActionSheet.defaultProps = defaultProps$D;
20595
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
+ }
20596
20327
  function ConfirmDialog(props) {
20597
20328
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Dialog, { ...props, children: props.content });
20598
20329
  }
@@ -21639,7 +21370,7 @@ Please add \`${key}Action\` when creating your handler.`);
21639
21370
  };
21640
21371
  NoticeBar.defaultProps = defaultProps$y;
21641
21372
  NoticeBar.displayName = "NutNoticeBar";
21642
- class Notification extends React__namespace.PureComponent {
21373
+ let Notification$1 = (_a = class extends React__namespace.PureComponent {
21643
21374
  constructor(props) {
21644
21375
  super(props);
21645
21376
  __publicField(this, "closeTimer");
@@ -21730,9 +21461,8 @@ Please add \`${key}Action\` when creating your handler.`);
21730
21461
  }
21731
21462
  ) });
21732
21463
  }
21733
- }
21734
- __publicField(Notification, "newInstance");
21735
- Notification.newInstance = (properties, callback) => {
21464
+ }, __publicField(_a, "newInstance"), _a);
21465
+ Notification$1.newInstance = (properties, callback) => {
21736
21466
  const element = document.createElement("div");
21737
21467
  const id = properties.id ? properties.id : `${(/* @__PURE__ */ new Date()).getTime()}`;
21738
21468
  element.id = id;
@@ -21754,10 +21484,10 @@ Please add \`${key}Action\` when creating your handler.`);
21754
21484
  }
21755
21485
  });
21756
21486
  }
21757
- render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification, { ...properties, ref }), element);
21487
+ render(/* @__PURE__ */ jsxRuntimeExports.jsx(Notification$1, { ...properties, ref }), element);
21758
21488
  };
21759
- let messageInstance = null;
21760
- const options = {
21489
+ let messageInstance$1 = null;
21490
+ const options$1 = {
21761
21491
  msg: "",
21762
21492
  id: "",
21763
21493
  duration: 3e3,
@@ -21771,51 +21501,51 @@ Please add \`${key}Action\` when creating your handler.`);
21771
21501
  onClick: () => {
21772
21502
  }
21773
21503
  };
21774
- function getInstance(props, callback) {
21775
- if (messageInstance) {
21776
- messageInstance.destroy();
21777
- messageInstance = null;
21504
+ function getInstance$1(props, callback) {
21505
+ if (messageInstance$1) {
21506
+ messageInstance$1.destroy();
21507
+ messageInstance$1 = null;
21778
21508
  }
21779
- Notification.newInstance(props, (notification) => {
21509
+ Notification$1.newInstance(props, (notification) => {
21780
21510
  return callback && callback(notification);
21781
21511
  });
21782
21512
  }
21783
- function notice(opts) {
21784
- opts = { ...options, ...opts };
21785
- getInstance(opts, (notification) => {
21786
- messageInstance = notification;
21513
+ function notice$1(opts) {
21514
+ opts = { ...options$1, ...opts };
21515
+ getInstance$1(opts, (notification) => {
21516
+ messageInstance$1 = notification;
21787
21517
  });
21788
21518
  }
21789
- const errorMsg = (msg) => {
21519
+ const errorMsg$1 = (msg) => {
21790
21520
  if (!msg) {
21791
21521
  console.warn("[NutUI Notify]: msg不能为空");
21792
21522
  }
21793
21523
  };
21794
21524
  const Notify = {
21795
21525
  text(msg, option = {}) {
21796
- errorMsg(msg);
21797
- return notice({ msg, type: "base", ...option });
21526
+ errorMsg$1(msg);
21527
+ return notice$1({ msg, type: "base", ...option });
21798
21528
  },
21799
21529
  success(msg, option = {}) {
21800
- errorMsg(msg);
21801
- return notice({ msg, type: "success", ...option });
21530
+ errorMsg$1(msg);
21531
+ return notice$1({ msg, type: "success", ...option });
21802
21532
  },
21803
21533
  primary(msg, option = {}) {
21804
- errorMsg(msg);
21805
- return notice({ msg, type: "primary", ...option });
21534
+ errorMsg$1(msg);
21535
+ return notice$1({ msg, type: "primary", ...option });
21806
21536
  },
21807
21537
  danger(msg, option = {}) {
21808
- errorMsg(msg);
21809
- return notice({ msg, type: "danger", ...option });
21538
+ errorMsg$1(msg);
21539
+ return notice$1({ msg, type: "danger", ...option });
21810
21540
  },
21811
21541
  warn(msg, option = {}) {
21812
- errorMsg(msg);
21813
- return notice({ msg, type: "warning", ...option });
21542
+ errorMsg$1(msg);
21543
+ return notice$1({ msg, type: "warning", ...option });
21814
21544
  },
21815
21545
  hide() {
21816
- if (messageInstance) {
21817
- messageInstance.destroy();
21818
- messageInstance = null;
21546
+ if (messageInstance$1) {
21547
+ messageInstance$1.destroy();
21548
+ messageInstance$1 = null;
21819
21549
  }
21820
21550
  }
21821
21551
  };
@@ -22589,6 +22319,218 @@ Please add \`${key}Action\` when creating your handler.`);
22589
22319
  });
22590
22320
  Swipe.defaultProps = defaultProps$t;
22591
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
+ };
22592
22534
  const defaultProps$s = {
22593
22535
  ...ComponentDefaults,
22594
22536
  type: "shake",
@@ -22865,9 +22807,11 @@ Please add \`${key}Action\` when creating your handler.`);
22865
22807
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${classPrefix2}__progress-bar-wrapper`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22866
22808
  Range,
22867
22809
  {
22868
- modelValue: percent,
22869
- hiddenTag: true,
22870
- hiddenRange: true,
22810
+ value: percent,
22811
+ onChange: (val) => setPercent(val),
22812
+ currentDescription: null,
22813
+ maxDescription: null,
22814
+ minDescription: null,
22871
22815
  "inactive-color": "#cccccc",
22872
22816
  "active-color": "#fa2c19"
22873
22817
  }