@nutui/nutui-react 2.3.8-beta.0 → 2.3.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/esm/NavBar/style/style.css +1 -1
  3. package/dist/esm/NavBar.js +49 -5
  4. package/dist/esm/Picker.js +1 -13
  5. package/dist/esm/RadioGroup.js +3 -2
  6. package/dist/esm/Rate/style/style.css +1 -1
  7. package/dist/esm/Rate.js +90 -4
  8. package/dist/esm/Step/style/style.css +1 -1
  9. package/dist/esm/Step.js +1 -1
  10. package/dist/esm/Steps/style/style.css +1 -1
  11. package/dist/esm/radio2.js +4 -4
  12. package/dist/esm/types/src/packages/navbar/navbar.taro.d.ts +2 -1
  13. package/dist/esm/types/src/packages/radio/index.d.ts +2 -1
  14. package/dist/esm/types/src/packages/radio/index.taro.d.ts +2 -1
  15. package/dist/esm/types/src/packages/radio/radio.d.ts +1 -2
  16. package/dist/esm/types/src/packages/radio/radio.taro.d.ts +1 -2
  17. package/dist/esm/types/src/packages/radio/types.d.ts +2 -0
  18. package/dist/esm/types/src/packages/radiogroup/context.d.ts +2 -0
  19. package/dist/esm/types/src/packages/radiogroup/index.d.ts +1 -0
  20. package/dist/esm/types/src/packages/radiogroup/index.taro.d.ts +1 -0
  21. package/dist/esm/types/src/packages/radiogroup/radiogroup.d.ts +4 -6
  22. package/dist/esm/types/src/packages/radiogroup/radiogroup.taro.d.ts +4 -6
  23. package/dist/esm/types/src/packages/radiogroup/types.d.ts +4 -0
  24. package/dist/esm/types/src/packages/rate/rate.d.ts +2 -0
  25. package/dist/esm/types/src/packages/rate/rate.taro.d.ts +2 -0
  26. package/dist/esm/types/src/packages/video/video.taro.d.ts +4 -5
  27. package/dist/esm/use-refs.js +17 -0
  28. package/dist/locales/base.js +1 -1
  29. package/dist/locales/en-US.js +1 -1
  30. package/dist/locales/id-ID.js +1 -1
  31. package/dist/locales/tr-TR.js +1 -1
  32. package/dist/locales/zh-CN.js +1 -1
  33. package/dist/locales/zh-TW.js +1 -1
  34. package/dist/locales/zh-UG.js +1 -1
  35. package/dist/nutui.react.es.js +136 -21
  36. package/dist/nutui.react.umd.js +136 -21
  37. package/dist/packages/navbar/navbar.scss +7 -0
  38. package/dist/packages/rate/rate.scss +1 -0
  39. package/dist/packages/step/step.scss +5 -4
  40. package/dist/style.css +1 -1
  41. package/dist/style.mjs +1 -1
  42. package/dist/types/packages/navbar/navbar.taro.d.ts +2 -1
  43. package/dist/types/packages/overlay/overlay.d.ts +5 -1
  44. package/dist/types/packages/radio/index.d.ts +2 -1
  45. package/dist/types/packages/radio/index.taro.d.ts +2 -1
  46. package/dist/types/packages/radio/radio.d.ts +1 -2
  47. package/dist/types/packages/radio/radio.taro.d.ts +1 -2
  48. package/dist/types/packages/radio/types.d.ts +2 -0
  49. package/dist/types/packages/radiogroup/context.d.ts +2 -0
  50. package/dist/types/packages/radiogroup/index.d.ts +1 -0
  51. package/dist/types/packages/radiogroup/index.taro.d.ts +1 -0
  52. package/dist/types/packages/radiogroup/radiogroup.d.ts +8 -6
  53. package/dist/types/packages/radiogroup/radiogroup.taro.d.ts +4 -6
  54. package/dist/types/packages/radiogroup/types.d.ts +4 -0
  55. package/dist/types/packages/rate/rate.d.ts +10 -0
  56. package/dist/types/packages/rate/rate.taro.d.ts +2 -0
  57. package/dist/types/packages/video/video.taro.d.ts +4 -5
  58. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.3.8-beta.0 Tue Jan 23 2024 11:21:40 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.3.8 Fri Jan 26 2024 15:14:38 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.3.8-beta.0 Tue Jan 23 2024 11:21:40 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.3.8 Fri Jan 26 2024 15:14:38 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.3.8-beta.0 Tue Jan 23 2024 11:21:40 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.3.8 Fri Jan 26 2024 15:14:38 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  /*!
8
- * @nutui/nutui-react v2.3.8-beta.0 Tue Jan 23 2024 11:20:59 GMT+0800 (China Standard Time)
8
+ * @nutui/nutui-react v2.3.8 Fri Jan 26 2024 15:13:59 GMT+0800 (China Standard Time)
9
9
  * (c) 2023 @jdf2e.
10
10
  * Released under the MIT License.
11
11
  */
@@ -10663,8 +10663,38 @@ const NavBar = (props) => {
10663
10663
  zIndex
10664
10664
  };
10665
10665
  };
10666
+ const leftRef = useRef(null);
10667
+ const rightRef = useRef(null);
10668
+ const wrapperRef = useRef(null);
10669
+ const [contentWidth, setContentWidth] = useState("50%");
10670
+ const getNodeWidth = (node) => {
10671
+ if (node) {
10672
+ const ele = getRect(node);
10673
+ return ele.width;
10674
+ }
10675
+ return 0;
10676
+ };
10677
+ useEffect(() => {
10678
+ if (titleAlign === "left") {
10679
+ return;
10680
+ }
10681
+ if (!(back || left || right)) {
10682
+ setContentWidth("100%");
10683
+ return;
10684
+ }
10685
+ const leftRectWidth = getNodeWidth(leftRef == null ? void 0 : leftRef.current);
10686
+ const rightRectWidth = getNodeWidth(rightRef == null ? void 0 : rightRef.current);
10687
+ const wrapperWidth = getNodeWidth(wrapperRef == null ? void 0 : wrapperRef.current);
10688
+ let centerWidth = wrapperWidth / 2;
10689
+ if (leftRectWidth && rightRectWidth) {
10690
+ centerWidth = wrapperWidth - (leftRectWidth > rightRectWidth ? leftRectWidth * 2 : rightRectWidth * 2);
10691
+ } else {
10692
+ centerWidth = wrapperWidth - leftRectWidth * 2 - rightRectWidth * 2;
10693
+ }
10694
+ setContentWidth(centerWidth.toFixed(2));
10695
+ }, [left, right, back]);
10666
10696
  const renderLeft = () => {
10667
- return back || left ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-left` }, back && /* @__PURE__ */ React__default.createElement(
10697
+ return back || left ? /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-left`, ref: leftRef }, back && /* @__PURE__ */ React__default.createElement(
10668
10698
  "div",
10669
10699
  {
10670
10700
  className: `${classPrefix2}-left-back`,
@@ -10674,13 +10704,21 @@ const NavBar = (props) => {
10674
10704
  ), left) : null;
10675
10705
  };
10676
10706
  const renderContent = () => {
10677
- return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-title` }, children);
10707
+ let titleStyle = {};
10708
+ if (titleAlign === "center") {
10709
+ const contentRealWidth = `${contentWidth}${/%$/i.test(contentWidth) ? "" : "px"}`;
10710
+ titleStyle = {
10711
+ minWidth: contentRealWidth,
10712
+ width: contentRealWidth
10713
+ };
10714
+ }
10715
+ return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-title`, style: titleStyle }, children);
10678
10716
  };
10679
10717
  const renderRight = () => {
10680
- return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-right` }, right);
10718
+ return /* @__PURE__ */ React__default.createElement("div", { className: `${classPrefix2}-right`, ref: rightRef }, right);
10681
10719
  };
10682
10720
  const renderWrapper = () => {
10683
- return /* @__PURE__ */ React__default.createElement("div", { className: cls, style: styles() }, renderLeft(), renderContent(), renderRight());
10721
+ return /* @__PURE__ */ React__default.createElement("div", { className: cls, style: styles(), ref: wrapperRef }, renderLeft(), renderContent(), renderRight());
10684
10722
  };
10685
10723
  const classes = classNames({
10686
10724
  [`${classPrefix2}-fixed`]: fixed,
@@ -17198,6 +17236,7 @@ const RadioGroup = React__default.forwardRef(
17198
17236
  value,
17199
17237
  defaultValue,
17200
17238
  onChange,
17239
+ shape,
17201
17240
  labelPosition,
17202
17241
  direction,
17203
17242
  options: options2,
@@ -17233,6 +17272,7 @@ const RadioGroup = React__default.forwardRef(
17233
17272
  value: {
17234
17273
  labelPosition: labelPosition || "right",
17235
17274
  disabled,
17275
+ shape,
17236
17276
  value: val2State,
17237
17277
  check: (value2) => {
17238
17278
  setVal2State(value2);
@@ -17360,11 +17400,11 @@ const Radio = (props) => {
17360
17400
  className: classNames(color())
17361
17401
  }) : /* @__PURE__ */ React__default.createElement(o$7, { className: classNames(color()) });
17362
17402
  };
17403
+ const renderByShape = (shape2) => {
17404
+ return shape2 === "button" ? renderButton() : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderIcon(), renderLabel());
17405
+ };
17363
17406
  const renderRadioItem = () => {
17364
- if (shape === "button") {
17365
- return renderButton();
17366
- }
17367
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderIcon(), renderLabel());
17407
+ return renderByShape(context && context.shape ? context.shape : shape);
17368
17408
  };
17369
17409
  const handleClick2 = (e2) => {
17370
17410
  if (disabled || checkedStatement)
@@ -17706,7 +17746,8 @@ const defaultProps$N = {
17706
17746
  uncheckedIcon: null,
17707
17747
  disabled: false,
17708
17748
  readOnly: false,
17709
- allowHalf: false
17749
+ allowHalf: false,
17750
+ touchable: false
17710
17751
  };
17711
17752
  const Rate = (props) => {
17712
17753
  const {
@@ -17721,13 +17762,17 @@ const Rate = (props) => {
17721
17762
  disabled,
17722
17763
  readOnly,
17723
17764
  allowHalf,
17724
- onChange
17765
+ touchable,
17766
+ onChange,
17767
+ onTouchEnd
17725
17768
  } = {
17726
17769
  ...defaultProps$N,
17727
17770
  ...props
17728
17771
  };
17729
17772
  const classPrefix2 = "nut-rate";
17730
17773
  const [countArray, setCountArray] = useState([1, 2, 3, 4, 5]);
17774
+ const [refs, setRefs] = useRefs();
17775
+ const rateRects = useRef([]);
17731
17776
  const [score, setScore] = usePropsValue({
17732
17777
  value,
17733
17778
  defaultValue: Math.max(defaultValue || 0, min),
@@ -17764,6 +17809,81 @@ const Rate = (props) => {
17764
17809
  const value2 = Math.max(min, n - 0.5);
17765
17810
  setScore(value2);
17766
17811
  };
17812
+ const getScoreByPosition = (x) => {
17813
+ var _a2;
17814
+ if ((_a2 = rateRects.current) == null ? void 0 : _a2.length) {
17815
+ for (let index = rateRects.current.length - 1; index >= 0; index--) {
17816
+ const item = rateRects.current[index];
17817
+ if (item && x > item.left) {
17818
+ return allowHalf ? index + (x > item.left + item.width / 2 ? 1 : 0.5) : index + 1;
17819
+ }
17820
+ }
17821
+ return 0;
17822
+ }
17823
+ };
17824
+ const updateRects = () => {
17825
+ for (let index = 0; index < refs.length; index++) {
17826
+ const item = refs[index];
17827
+ if (item) {
17828
+ rateRects.current[index] = getRect(item);
17829
+ }
17830
+ }
17831
+ };
17832
+ const handleTouchStart = (e2) => {
17833
+ if (!touchable || readOnly || disabled) {
17834
+ return;
17835
+ }
17836
+ if (e2.cancelable) {
17837
+ e2.preventDefault();
17838
+ }
17839
+ e2.stopPropagation();
17840
+ updateRects();
17841
+ };
17842
+ const handleTouchMove = (e2) => {
17843
+ if (!touchable || readOnly || disabled) {
17844
+ return;
17845
+ }
17846
+ if (e2.cancelable) {
17847
+ e2.preventDefault();
17848
+ }
17849
+ e2.stopPropagation();
17850
+ const val = getScoreByPosition(e2.touches[0].clientX);
17851
+ if (val !== void 0) {
17852
+ setScore(Math.max(min, val));
17853
+ }
17854
+ };
17855
+ const handleTouchEnd = (e2) => {
17856
+ if (!touchable || readOnly || disabled) {
17857
+ return;
17858
+ }
17859
+ if (e2.cancelable) {
17860
+ e2.preventDefault();
17861
+ }
17862
+ e2.stopPropagation();
17863
+ const val = getScoreByPosition(e2.changedTouches[0].clientX);
17864
+ if (val !== void 0) {
17865
+ setScore(Math.max(min, val));
17866
+ onTouchEnd && onTouchEnd(e2, Math.max(min, val));
17867
+ }
17868
+ };
17869
+ const rateRef = useRef(null);
17870
+ useEffect(() => {
17871
+ const element = rateRef.current;
17872
+ if (element) {
17873
+ element.addEventListener("touchstart", handleTouchStart, {
17874
+ passive: false
17875
+ });
17876
+ element.addEventListener("touchmove", handleTouchMove, { passive: false });
17877
+ element.addEventListener("touchend", handleTouchEnd, { passive: false });
17878
+ }
17879
+ return () => {
17880
+ if (element) {
17881
+ element.removeEventListener("touchstart", handleTouchStart);
17882
+ element.removeEventListener("touchmove", handleTouchMove);
17883
+ element.removeEventListener("touchend", handleTouchEnd);
17884
+ }
17885
+ };
17886
+ }, []);
17767
17887
  return /* @__PURE__ */ React__default.createElement(
17768
17888
  "div",
17769
17889
  {
@@ -17775,14 +17895,16 @@ const Rate = (props) => {
17775
17895
  },
17776
17896
  className
17777
17897
  ),
17898
+ ref: rateRef,
17778
17899
  style
17779
17900
  },
17780
- countArray.map((n) => {
17901
+ countArray.map((n, index) => {
17781
17902
  return /* @__PURE__ */ React__default.createElement(
17782
17903
  "div",
17783
17904
  {
17784
17905
  className: `${classPrefix2}-item`,
17785
17906
  key: n,
17907
+ ref: setRefs(index),
17786
17908
  onClick: (event) => onClick(event, n)
17787
17909
  },
17788
17910
  /* @__PURE__ */ React__default.createElement(
@@ -23502,7 +23624,7 @@ const Step = (props) => {
23502
23624
  }
23503
23625
  return `${classPrefix2}-icon`;
23504
23626
  };
23505
- return /* @__PURE__ */ React__default.createElement("div", { className: classes, ...restProps, onClick: handleClickStep }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-head" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-line" }), /* @__PURE__ */ React__default.createElement("div", { className: renderIconClass() }, icon || !dot && /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-inner" }, value))), /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-main" }, /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-title" }, title), description && /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-description" }, description)));
23627
+ return /* @__PURE__ */ React__default.createElement("div", { className: classes, ...restProps, onClick: handleClickStep }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-head" }, /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-line" }), /* @__PURE__ */ React__default.createElement("div", { className: renderIconClass() }, icon || !dot && /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-inner" }, value))), (title || description) && /* @__PURE__ */ React__default.createElement("div", { className: "nut-step-main" }, /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-title" }, title), description && /* @__PURE__ */ React__default.createElement("span", { className: "nut-step-description" }, description)));
23506
23628
  };
23507
23629
  Step.defaultProps = defaultProps$c;
23508
23630
  Step.displayName = "NutStep";
@@ -23535,14 +23657,7 @@ const Steps = (props) => {
23535
23657
  },
23536
23658
  className
23537
23659
  );
23538
- return /* @__PURE__ */ React__default.createElement(DataContext.Provider, { value: parentSteps }, React__default.createElement(
23539
- "div",
23540
- {
23541
- className: classes,
23542
- ...restProps
23543
- },
23544
- children
23545
- ));
23660
+ return /* @__PURE__ */ React__default.createElement(DataContext.Provider, { value: parentSteps }, /* @__PURE__ */ React__default.createElement("div", { className: classes, ...restProps }, children));
23546
23661
  };
23547
23662
  Steps.defaultProps = defaultProps$b;
23548
23663
  Steps.displayName = "NutSteps";
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
8
8
  return value;
9
9
  };
10
10
  /*!
11
- * @nutui/nutui-react v2.3.8-beta.0 Tue Jan 23 2024 11:20:59 GMT+0800 (China Standard Time)
11
+ * @nutui/nutui-react v2.3.8 Fri Jan 26 2024 15:13:59 GMT+0800 (China Standard Time)
12
12
  * (c) 2023 @jdf2e.
13
13
  * Released under the MIT License.
14
14
  */
@@ -10681,8 +10681,38 @@ Please add \`${key}Action\` when creating your handler.`);
10681
10681
  zIndex
10682
10682
  };
10683
10683
  };
10684
+ const leftRef = React.useRef(null);
10685
+ const rightRef = React.useRef(null);
10686
+ const wrapperRef = React.useRef(null);
10687
+ const [contentWidth, setContentWidth] = React.useState("50%");
10688
+ const getNodeWidth = (node) => {
10689
+ if (node) {
10690
+ const ele = getRect(node);
10691
+ return ele.width;
10692
+ }
10693
+ return 0;
10694
+ };
10695
+ React.useEffect(() => {
10696
+ if (titleAlign === "left") {
10697
+ return;
10698
+ }
10699
+ if (!(back || left || right)) {
10700
+ setContentWidth("100%");
10701
+ return;
10702
+ }
10703
+ const leftRectWidth = getNodeWidth(leftRef == null ? void 0 : leftRef.current);
10704
+ const rightRectWidth = getNodeWidth(rightRef == null ? void 0 : rightRef.current);
10705
+ const wrapperWidth = getNodeWidth(wrapperRef == null ? void 0 : wrapperRef.current);
10706
+ let centerWidth = wrapperWidth / 2;
10707
+ if (leftRectWidth && rightRectWidth) {
10708
+ centerWidth = wrapperWidth - (leftRectWidth > rightRectWidth ? leftRectWidth * 2 : rightRectWidth * 2);
10709
+ } else {
10710
+ centerWidth = wrapperWidth - leftRectWidth * 2 - rightRectWidth * 2;
10711
+ }
10712
+ setContentWidth(centerWidth.toFixed(2));
10713
+ }, [left, right, back]);
10684
10714
  const renderLeft = () => {
10685
- return back || left ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-left` }, back && /* @__PURE__ */ React.createElement(
10715
+ return back || left ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-left`, ref: leftRef }, back && /* @__PURE__ */ React.createElement(
10686
10716
  "div",
10687
10717
  {
10688
10718
  className: `${classPrefix2}-left-back`,
@@ -10692,13 +10722,21 @@ Please add \`${key}Action\` when creating your handler.`);
10692
10722
  ), left) : null;
10693
10723
  };
10694
10724
  const renderContent = () => {
10695
- return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-title` }, children);
10725
+ let titleStyle = {};
10726
+ if (titleAlign === "center") {
10727
+ const contentRealWidth = `${contentWidth}${/%$/i.test(contentWidth) ? "" : "px"}`;
10728
+ titleStyle = {
10729
+ minWidth: contentRealWidth,
10730
+ width: contentRealWidth
10731
+ };
10732
+ }
10733
+ return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-title`, style: titleStyle }, children);
10696
10734
  };
10697
10735
  const renderRight = () => {
10698
- return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-right` }, right);
10736
+ return /* @__PURE__ */ React.createElement("div", { className: `${classPrefix2}-right`, ref: rightRef }, right);
10699
10737
  };
10700
10738
  const renderWrapper = () => {
10701
- return /* @__PURE__ */ React.createElement("div", { className: cls, style: styles() }, renderLeft(), renderContent(), renderRight());
10739
+ return /* @__PURE__ */ React.createElement("div", { className: cls, style: styles(), ref: wrapperRef }, renderLeft(), renderContent(), renderRight());
10702
10740
  };
10703
10741
  const classes = classNames({
10704
10742
  [`${classPrefix2}-fixed`]: fixed,
@@ -17216,6 +17254,7 @@ Please add \`${key}Action\` when creating your handler.`);
17216
17254
  value,
17217
17255
  defaultValue,
17218
17256
  onChange,
17257
+ shape,
17219
17258
  labelPosition,
17220
17259
  direction,
17221
17260
  options: options2,
@@ -17251,6 +17290,7 @@ Please add \`${key}Action\` when creating your handler.`);
17251
17290
  value: {
17252
17291
  labelPosition: labelPosition || "right",
17253
17292
  disabled,
17293
+ shape,
17254
17294
  value: val2State,
17255
17295
  check: (value2) => {
17256
17296
  setVal2State(value2);
@@ -17378,11 +17418,11 @@ Please add \`${key}Action\` when creating your handler.`);
17378
17418
  className: classNames(color())
17379
17419
  }) : /* @__PURE__ */ React.createElement(o$7, { className: classNames(color()) });
17380
17420
  };
17421
+ const renderByShape = (shape2) => {
17422
+ return shape2 === "button" ? renderButton() : /* @__PURE__ */ React.createElement(React.Fragment, null, renderIcon(), renderLabel());
17423
+ };
17381
17424
  const renderRadioItem = () => {
17382
- if (shape === "button") {
17383
- return renderButton();
17384
- }
17385
- return /* @__PURE__ */ React.createElement(React.Fragment, null, renderIcon(), renderLabel());
17425
+ return renderByShape(context && context.shape ? context.shape : shape);
17386
17426
  };
17387
17427
  const handleClick2 = (e2) => {
17388
17428
  if (disabled || checkedStatement)
@@ -17724,7 +17764,8 @@ Please add \`${key}Action\` when creating your handler.`);
17724
17764
  uncheckedIcon: null,
17725
17765
  disabled: false,
17726
17766
  readOnly: false,
17727
- allowHalf: false
17767
+ allowHalf: false,
17768
+ touchable: false
17728
17769
  };
17729
17770
  const Rate = (props) => {
17730
17771
  const {
@@ -17739,13 +17780,17 @@ Please add \`${key}Action\` when creating your handler.`);
17739
17780
  disabled,
17740
17781
  readOnly,
17741
17782
  allowHalf,
17742
- onChange
17783
+ touchable,
17784
+ onChange,
17785
+ onTouchEnd
17743
17786
  } = {
17744
17787
  ...defaultProps$N,
17745
17788
  ...props
17746
17789
  };
17747
17790
  const classPrefix2 = "nut-rate";
17748
17791
  const [countArray, setCountArray] = React.useState([1, 2, 3, 4, 5]);
17792
+ const [refs, setRefs] = useRefs();
17793
+ const rateRects = React.useRef([]);
17749
17794
  const [score, setScore] = usePropsValue({
17750
17795
  value,
17751
17796
  defaultValue: Math.max(defaultValue || 0, min),
@@ -17782,6 +17827,81 @@ Please add \`${key}Action\` when creating your handler.`);
17782
17827
  const value2 = Math.max(min, n - 0.5);
17783
17828
  setScore(value2);
17784
17829
  };
17830
+ const getScoreByPosition = (x) => {
17831
+ var _a2;
17832
+ if ((_a2 = rateRects.current) == null ? void 0 : _a2.length) {
17833
+ for (let index = rateRects.current.length - 1; index >= 0; index--) {
17834
+ const item = rateRects.current[index];
17835
+ if (item && x > item.left) {
17836
+ return allowHalf ? index + (x > item.left + item.width / 2 ? 1 : 0.5) : index + 1;
17837
+ }
17838
+ }
17839
+ return 0;
17840
+ }
17841
+ };
17842
+ const updateRects = () => {
17843
+ for (let index = 0; index < refs.length; index++) {
17844
+ const item = refs[index];
17845
+ if (item) {
17846
+ rateRects.current[index] = getRect(item);
17847
+ }
17848
+ }
17849
+ };
17850
+ const handleTouchStart = (e2) => {
17851
+ if (!touchable || readOnly || disabled) {
17852
+ return;
17853
+ }
17854
+ if (e2.cancelable) {
17855
+ e2.preventDefault();
17856
+ }
17857
+ e2.stopPropagation();
17858
+ updateRects();
17859
+ };
17860
+ const handleTouchMove = (e2) => {
17861
+ if (!touchable || readOnly || disabled) {
17862
+ return;
17863
+ }
17864
+ if (e2.cancelable) {
17865
+ e2.preventDefault();
17866
+ }
17867
+ e2.stopPropagation();
17868
+ const val = getScoreByPosition(e2.touches[0].clientX);
17869
+ if (val !== void 0) {
17870
+ setScore(Math.max(min, val));
17871
+ }
17872
+ };
17873
+ const handleTouchEnd = (e2) => {
17874
+ if (!touchable || readOnly || disabled) {
17875
+ return;
17876
+ }
17877
+ if (e2.cancelable) {
17878
+ e2.preventDefault();
17879
+ }
17880
+ e2.stopPropagation();
17881
+ const val = getScoreByPosition(e2.changedTouches[0].clientX);
17882
+ if (val !== void 0) {
17883
+ setScore(Math.max(min, val));
17884
+ onTouchEnd && onTouchEnd(e2, Math.max(min, val));
17885
+ }
17886
+ };
17887
+ const rateRef = React.useRef(null);
17888
+ React.useEffect(() => {
17889
+ const element = rateRef.current;
17890
+ if (element) {
17891
+ element.addEventListener("touchstart", handleTouchStart, {
17892
+ passive: false
17893
+ });
17894
+ element.addEventListener("touchmove", handleTouchMove, { passive: false });
17895
+ element.addEventListener("touchend", handleTouchEnd, { passive: false });
17896
+ }
17897
+ return () => {
17898
+ if (element) {
17899
+ element.removeEventListener("touchstart", handleTouchStart);
17900
+ element.removeEventListener("touchmove", handleTouchMove);
17901
+ element.removeEventListener("touchend", handleTouchEnd);
17902
+ }
17903
+ };
17904
+ }, []);
17785
17905
  return /* @__PURE__ */ React.createElement(
17786
17906
  "div",
17787
17907
  {
@@ -17793,14 +17913,16 @@ Please add \`${key}Action\` when creating your handler.`);
17793
17913
  },
17794
17914
  className
17795
17915
  ),
17916
+ ref: rateRef,
17796
17917
  style
17797
17918
  },
17798
- countArray.map((n) => {
17919
+ countArray.map((n, index) => {
17799
17920
  return /* @__PURE__ */ React.createElement(
17800
17921
  "div",
17801
17922
  {
17802
17923
  className: `${classPrefix2}-item`,
17803
17924
  key: n,
17925
+ ref: setRefs(index),
17804
17926
  onClick: (event) => onClick(event, n)
17805
17927
  },
17806
17928
  /* @__PURE__ */ React.createElement(
@@ -23520,7 +23642,7 @@ Please add \`${key}Action\` when creating your handler.`);
23520
23642
  }
23521
23643
  return `${classPrefix2}-icon`;
23522
23644
  };
23523
- return /* @__PURE__ */ React.createElement("div", { className: classes, ...restProps, onClick: handleClickStep }, /* @__PURE__ */ React.createElement("div", { className: "nut-step-head" }, /* @__PURE__ */ React.createElement("div", { className: "nut-step-line" }), /* @__PURE__ */ React.createElement("div", { className: renderIconClass() }, icon || !dot && /* @__PURE__ */ React.createElement("span", { className: "nut-step-inner" }, value))), /* @__PURE__ */ React.createElement("div", { className: "nut-step-main" }, /* @__PURE__ */ React.createElement("span", { className: "nut-step-title" }, title), description && /* @__PURE__ */ React.createElement("span", { className: "nut-step-description" }, description)));
23645
+ return /* @__PURE__ */ React.createElement("div", { className: classes, ...restProps, onClick: handleClickStep }, /* @__PURE__ */ React.createElement("div", { className: "nut-step-head" }, /* @__PURE__ */ React.createElement("div", { className: "nut-step-line" }), /* @__PURE__ */ React.createElement("div", { className: renderIconClass() }, icon || !dot && /* @__PURE__ */ React.createElement("span", { className: "nut-step-inner" }, value))), (title || description) && /* @__PURE__ */ React.createElement("div", { className: "nut-step-main" }, /* @__PURE__ */ React.createElement("span", { className: "nut-step-title" }, title), description && /* @__PURE__ */ React.createElement("span", { className: "nut-step-description" }, description)));
23524
23646
  };
23525
23647
  Step.defaultProps = defaultProps$c;
23526
23648
  Step.displayName = "NutStep";
@@ -23553,14 +23675,7 @@ Please add \`${key}Action\` when creating your handler.`);
23553
23675
  },
23554
23676
  className
23555
23677
  );
23556
- return /* @__PURE__ */ React.createElement(DataContext.Provider, { value: parentSteps }, React.createElement(
23557
- "div",
23558
- {
23559
- className: classes,
23560
- ...restProps
23561
- },
23562
- children
23563
- ));
23678
+ return /* @__PURE__ */ React.createElement(DataContext.Provider, { value: parentSteps }, /* @__PURE__ */ React.createElement("div", { className: classes, ...restProps }, children));
23564
23679
  };
23565
23680
  Steps.defaultProps = defaultProps$b;
23566
23681
  Steps.displayName = "NutSteps";
@@ -108,10 +108,17 @@
108
108
  }
109
109
  }
110
110
  }
111
+ .nut-navbar-right {
112
+ position: static;
113
+ display: inline-flex;
114
+ white-space: nowrap;
115
+ padding-left: 0;
116
+ }
111
117
  .nut-navbar-left-back {
112
118
  margin-right: 0;
113
119
  }
114
120
  .nut-navbar-title {
121
+ min-width: 0;
115
122
  margin: 0;
116
123
  flex: 1;
117
124
  justify-content: flex-start;
@@ -1,5 +1,6 @@
1
1
  .nut-rate {
2
2
  display: flex;
3
+ touch-action: pan-x;
3
4
 
4
5
  &.disabled {
5
6
  .nut-rate-item-icon {
@@ -56,10 +56,11 @@
56
56
  }
57
57
 
58
58
  &-main {
59
- display: inline-block;
60
- padding-left: 10%;
61
- padding-right: 10%;
62
- text-align: center;
59
+ padding: 0 10%;
60
+ display: flex;
61
+ flex-direction: column;
62
+ justify-content: center;
63
+ align-items: center;
63
64
  }
64
65
 
65
66
  &-title {