@nutui/nutui-react-taro 2.0.3 → 2.0.4

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 (101) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/esm/Address/style/style.css +1 -1
  3. package/dist/esm/Address.js +6 -4
  4. package/dist/esm/Audio/style/style.css +1 -1
  5. package/dist/esm/Audio.js +2 -2
  6. package/dist/esm/Button/style/style.css +1 -1
  7. package/dist/esm/Calendar.js +4 -3
  8. package/dist/esm/CalendarItem.js +3 -2
  9. package/dist/esm/Cascader/style/style.css +1 -1
  10. package/dist/esm/Cascader.js +4 -2
  11. package/dist/esm/ConfigProvider.js +4 -2
  12. package/dist/esm/CountDown.js +3 -2
  13. package/dist/esm/DatePicker.js +3 -3
  14. package/dist/esm/Dialog/style/style.css +1 -1
  15. package/dist/esm/Dialog.js +2 -2
  16. package/dist/esm/Empty.js +3 -2
  17. package/dist/esm/FixedNav.js +2 -2
  18. package/dist/esm/Form.js +2 -2
  19. package/dist/esm/FormItem.js +1 -1
  20. package/dist/esm/Grid.js +4 -3
  21. package/dist/esm/GridItem.js +3 -2
  22. package/dist/esm/InfiniteLoading.js +2 -2
  23. package/dist/esm/Input.js +3 -2
  24. package/dist/esm/NumberKeyboard.js +2 -2
  25. package/dist/esm/Pagination.js +3 -3
  26. package/dist/esm/Picker.js +2 -2
  27. package/dist/esm/PullToRefresh.js +4 -3
  28. package/dist/esm/SearchBar.js +3 -2
  29. package/dist/esm/ShortPassword.js +2 -2
  30. package/dist/esm/Signature/style/style.css +1 -1
  31. package/dist/esm/Table.js +2 -2
  32. package/dist/esm/Tabs/style/style.css +1 -1
  33. package/dist/esm/Tabs.js +3 -1
  34. package/dist/esm/TextArea.js +2 -2
  35. package/dist/esm/TimeSelect.js +2 -2
  36. package/dist/esm/Uploader.js +2 -2
  37. package/dist/esm/WaterMark.js +2 -2
  38. package/dist/esm/{address.taro-8fa9f15c.js → address.taro-dc981f3b.js} +2 -2
  39. package/dist/esm/{audio.taro-38889f9d.js → audio.taro-672e02c2.js} +1 -1
  40. package/dist/esm/{calendar.taro-ac2a1c47.js → calendar.taro-4e0f6821.js} +2 -2
  41. package/dist/esm/{calendaritem.taro-1af09287.js → calendaritem.taro-332af5b7.js} +3 -14
  42. package/dist/esm/{cascader.taro-840fdc66.js → cascader.taro-69230aa4.js} +2 -11
  43. package/dist/esm/{configprovider.taro-a7f3bcfd.js → configprovider.taro-510947ea.js} +11 -5
  44. package/dist/esm/{countdown.taro-384168de.js → countdown.taro-77749251.js} +1 -1
  45. package/dist/esm/{datepicker.taro-afea03e5.js → datepicker.taro-45d5235c.js} +2 -2
  46. package/dist/esm/{dialog.taro-e25e7241.js → dialog.taro-be862b5a.js} +1 -1
  47. package/dist/esm/{empty.taro-a670f621.js → empty.taro-ef1b390a.js} +1 -1
  48. package/dist/esm/{fixednav.taro-5c8dd9c2.js → fixednav.taro-a8b0d089.js} +1 -1
  49. package/dist/esm/{form.taro-1a66c97a.js → form.taro-aa11d488.js} +1 -1
  50. package/dist/esm/{formitem.taro-8828760a.js → formitem.taro-6316e0f9.js} +1 -1
  51. package/dist/esm/{grid.taro-8a6bc264.js → grid.taro-0202c062.js} +1 -1
  52. package/dist/esm/{griditem.taro-8fc37b25.js → griditem.taro-08a3e7dc.js} +1 -1
  53. package/dist/esm/{infiniteloading.taro-1b43b959.js → infiniteloading.taro-d4dd2cd9.js} +1 -1
  54. package/dist/esm/{input.taro-c611c122.js → input.taro-9dce4ce2.js} +1 -1
  55. package/dist/esm/{numberkeyboard.taro-f89f210b.js → numberkeyboard.taro-eef4087f.js} +1 -1
  56. package/dist/esm/nutui-react.es.js +30 -29
  57. package/dist/esm/{pagination.taro-2c68b943.js → pagination.taro-04ed7371.js} +1 -1
  58. package/dist/esm/{picker.taro-9f2024c6.js → picker.taro-53bb8322.js} +1 -1
  59. package/dist/esm/{pulltorefresh.taro-71ad5d15.js → pulltorefresh.taro-1a96ae6f.js} +1 -1
  60. package/dist/esm/raf-a9ff50ad.js +15 -0
  61. package/dist/esm/{searchbar.taro-5d83279d.js → searchbar.taro-f5bbc140.js} +1 -1
  62. package/dist/esm/{shortpassword.taro-897e620f.js → shortpassword.taro-16eaa16b.js} +1 -1
  63. package/dist/esm/{table.taro-4fd3bfe8.js → table.taro-c8241b30.js} +1 -1
  64. package/dist/esm/tabs.taro-e944cce9.js +244 -0
  65. package/dist/esm/{textarea.taro-a09e8563.js → textarea.taro-484b08c0.js} +1 -1
  66. package/dist/esm/{timeselect.taro-abdbb92f.js → timeselect.taro-8354e37d.js} +1 -1
  67. package/dist/esm/types/src/packages/configprovider/__test__/configprovider.spec.d.ts +1 -0
  68. package/dist/esm/types/src/packages/configprovider/configprovider.d.ts +2 -1
  69. package/dist/esm/types/src/packages/configprovider/configprovider.taro.d.ts +2 -1
  70. package/dist/esm/types/src/packages/configprovider/types.d.ts +1 -1
  71. package/dist/esm/types/src/packages/countdown/demo.d.ts +1 -0
  72. package/dist/esm/types/src/packages/countdown/demo.taro.d.ts +1 -0
  73. package/dist/esm/types/src/packages/formitem/formitem.d.ts +2 -4
  74. package/dist/esm/types/src/packages/formitem/formitem.taro.d.ts +2 -4
  75. package/dist/esm/types/src/packages/tabs/tabs.taro.d.ts +1 -0
  76. package/dist/esm/{uploader.taro-3bbe2503.js → uploader.taro-3d52a0ed.js} +1 -1
  77. package/dist/esm/{watermark.taro-788cb452.js → watermark.taro-5ff0bd9d.js} +1 -1
  78. package/dist/locales/base.js +1 -1
  79. package/dist/locales/en-US.js +1 -1
  80. package/dist/locales/id-ID.js +1 -1
  81. package/dist/locales/tr-TR.js +1 -1
  82. package/dist/locales/zh-CN.js +1 -1
  83. package/dist/locales/zh-TW.js +1 -1
  84. package/dist/locales/zh-UG.js +1 -1
  85. package/dist/nutui.react.es.js +134 -45
  86. package/dist/nutui.react.umd.js +133 -44
  87. package/dist/packages/button/button.scss +0 -11
  88. package/dist/packages/signature/signature.scss +4 -6
  89. package/dist/packages/tabs/tabs.scss +23 -0
  90. package/dist/style.css +1 -1
  91. package/dist/style.mjs +1 -1
  92. package/dist/styles/variables-jmapp.scss +8 -5
  93. package/dist/styles/variables.scss +8 -5
  94. package/dist/types/packages/calendar/calendar.taro.d.ts +4 -4
  95. package/dist/types/packages/configprovider/configprovider.d.ts +2 -1
  96. package/dist/types/packages/configprovider/configprovider.taro.d.ts +2 -1
  97. package/dist/types/packages/configprovider/types.d.ts +1 -1
  98. package/dist/types/packages/formitem/formitem.taro.d.ts +2 -4
  99. package/dist/types/packages/tabs/tabs.taro.d.ts +1 -0
  100. package/package.json +1 -1
  101. package/dist/esm/tabs.taro-67bdf3bb.js +0 -142
@@ -5,11 +5,11 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  /*!
8
- * @nutui/nutui-react-taro v2.0.3 Wed Jul 12 2023 18:04:02 GMT+0800 (China Standard Time)
8
+ * @nutui/nutui-react-taro v2.0.4 Fri Jul 14 2023 14:21:48 GMT+0800 (China Standard Time)
9
9
  * (c) 2023 @jdf2e.
10
10
  * Released under the MIT License.
11
11
  */
12
- import React, { useCallback, createContext, useMemo, useContext, useState, useEffect, useRef, isValidElement, useImperativeHandle, forwardRef, Component, Children } from "react";
12
+ import React, { useCallback, createContext, useContext, useState, useEffect, useRef, useMemo, isValidElement, useImperativeHandle, forwardRef, Component, Children } from "react";
13
13
  import Taro, { getEnv, usePageScroll, getSystemInfoSync, pageScrollTo, nextTick, createSelectorQuery, ENV_TYPE, canvasToTempFilePath, uploadFile, chooseMedia, chooseImage, useReady, createInnerAudioContext, getSystemInfo, createOffscreenCanvas } from "@tarojs/taro";
14
14
  import { Image as Image$2, View, ScrollView, PickerView, PickerViewColumn, Input as Input$1, Textarea, Swiper as Swiper$1, SwiperItem as SwiperItem$1, Video as Video$1 } from "@tarojs/components";
15
15
  import ReactDOM, { createPortal } from "react-dom";
@@ -1957,16 +1957,16 @@ const defaultProps$1r = {
1957
1957
  description: "",
1958
1958
  divider: true
1959
1959
  };
1960
- const classPrefix$n = "nut-cell-group";
1960
+ const classPrefix$o = "nut-cell-group";
1961
1961
  const CellGroup = (props) => {
1962
1962
  const { children, className, style, title, description, divider, ...rest } = {
1963
1963
  ...defaultProps$1r,
1964
1964
  ...props
1965
1965
  };
1966
- return /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix$n, className), ...rest }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__description` }, description) : null, /* @__PURE__ */ React.createElement(
1966
+ return /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix$o, className), ...rest }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$o}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$o}__description` }, description) : null, /* @__PURE__ */ React.createElement(
1967
1967
  "div",
1968
1968
  {
1969
- className: `${classPrefix$n}__wrap ${divider ? `${classPrefix$n}__wrap--divider` : ""}`
1969
+ className: `${classPrefix$o}__wrap ${divider ? `${classPrefix$o}__wrap--divider` : ""}`
1970
1970
  },
1971
1971
  children
1972
1972
  ));
@@ -1983,7 +1983,7 @@ const defaultProps$1q = {
1983
1983
  onClick: (event) => {
1984
1984
  }
1985
1985
  };
1986
- const classPrefix$m = "nut-cell";
1986
+ const classPrefix$n = "nut-cell";
1987
1987
  const Cell = (props) => {
1988
1988
  const {
1989
1989
  children,
@@ -2014,19 +2014,19 @@ const Cell = (props) => {
2014
2014
  return /* @__PURE__ */ React.createElement(
2015
2015
  "div",
2016
2016
  {
2017
- className: classNames(classPrefix$m, className),
2017
+ className: classNames(classPrefix$n, className),
2018
2018
  onClick: (event) => handleClick(event),
2019
2019
  style: baseStyle,
2020
2020
  ...rest
2021
2021
  },
2022
- children || /* @__PURE__ */ React.createElement(React.Fragment, null, title || description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__left` }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__description` }, description) : null) : null, extra ? /* @__PURE__ */ React.createElement(
2022
+ children || /* @__PURE__ */ React.createElement(React.Fragment, null, title || description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__left` }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__description` }, description) : null) : null, extra ? /* @__PURE__ */ React.createElement(
2023
2023
  "div",
2024
2024
  {
2025
- className: `${classPrefix$m}__extra`,
2025
+ className: `${classPrefix$n}__extra`,
2026
2026
  style: styles
2027
2027
  },
2028
2028
  extra
2029
- ) : null, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__divider` }))
2029
+ ) : null, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__divider` }))
2030
2030
  );
2031
2031
  };
2032
2032
  Cell.defaultProps = defaultProps$1q;
@@ -2446,8 +2446,10 @@ const zhCN = {
2446
2446
  }
2447
2447
  };
2448
2448
  const defaultProps$1p = {
2449
+ ...ComponentDefaults,
2449
2450
  locale: zhCN
2450
2451
  };
2452
+ const classPrefix$m = "nut-configprovider";
2451
2453
  const defaultConfigRef = {
2452
2454
  current: {
2453
2455
  locale: zhCN
@@ -2468,13 +2470,12 @@ function convertThemeVarsToCSSVars(themeVars) {
2468
2470
  return cssVars;
2469
2471
  }
2470
2472
  const ConfigProvider = (props) => {
2471
- const { children, ...config2 } = { ...defaultProps$1p, ...props };
2473
+ const { children, className, ...config2 } = { ...defaultProps$1p, ...props };
2472
2474
  const parentConfig = useConfig();
2473
- const theme = config2.theme || {};
2474
- const style = useMemo(
2475
- () => convertThemeVarsToCSSVars(theme),
2476
- [theme]
2477
- );
2475
+ const style = {
2476
+ ...convertThemeVarsToCSSVars(config2.theme || {}),
2477
+ ...config2.style
2478
+ };
2478
2479
  return /* @__PURE__ */ React.createElement(
2479
2480
  ConfigContext.Provider,
2480
2481
  {
@@ -2483,7 +2484,7 @@ const ConfigProvider = (props) => {
2483
2484
  ...config2
2484
2485
  }
2485
2486
  },
2486
- /* @__PURE__ */ React.createElement("div", { style }, children)
2487
+ /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix$m, className), style }, children)
2487
2488
  );
2488
2489
  };
2489
2490
  ConfigProvider.defaultProps = defaultProps$1p;
@@ -5854,9 +5855,22 @@ const TabPane = (props) => {
5854
5855
  );
5855
5856
  return children ? /* @__PURE__ */ React.createElement("div", { className: classes }, !disabled && children) : null;
5856
5857
  };
5858
+ function requestAniFrame() {
5859
+ if (typeof window !== "undefined") {
5860
+ const _window = window;
5861
+ return _window.requestAnimationFrame || _window.webkitRequestAnimationFrame || function(callback) {
5862
+ _window.setTimeout(callback, 1e3 / 60);
5863
+ };
5864
+ }
5865
+ return function(callback) {
5866
+ setTimeout(callback, 1e3 / 60);
5867
+ };
5868
+ }
5869
+ const requestAniFrame$1 = requestAniFrame();
5857
5870
  const defaultProps$15 = {
5858
5871
  ...ComponentDefaults,
5859
5872
  tabStyle: {},
5873
+ name: "",
5860
5874
  activeColor: "",
5861
5875
  direction: "horizontal",
5862
5876
  activeType: "line",
@@ -5873,6 +5887,7 @@ const Tabs = (props) => {
5873
5887
  duration,
5874
5888
  align,
5875
5889
  title,
5890
+ name,
5876
5891
  children,
5877
5892
  onClick,
5878
5893
  onChange,
@@ -5938,6 +5953,98 @@ const Tabs = (props) => {
5938
5953
  color: activeType === "smile" ? activeColor : "",
5939
5954
  background: activeType === "line" ? activeColor : ""
5940
5955
  };
5956
+ const getRect2 = (selector) => {
5957
+ return new Promise((resolve) => {
5958
+ Taro.createSelectorQuery().select(selector).boundingClientRect().exec((rect = []) => {
5959
+ resolve(rect[0]);
5960
+ });
5961
+ });
5962
+ };
5963
+ const getAllRect = (selector) => {
5964
+ return new Promise((resolve) => {
5965
+ Taro.createSelectorQuery().selectAll(selector).boundingClientRect().exec((rect = []) => resolve(rect[0]));
5966
+ });
5967
+ };
5968
+ const scrollWithAnimation = useRef(false);
5969
+ const navRectRef = useRef();
5970
+ const titleRectRef = useRef([]);
5971
+ const canShowLabel = useRef(false);
5972
+ const scrollLeft = useRef(0);
5973
+ const scrollTop = useRef(0);
5974
+ const scrollDirection = (to, direction2) => {
5975
+ let count = 0;
5976
+ const from = direction2 === "horizontal" ? scrollLeft.current : scrollTop.current;
5977
+ const frames = 1;
5978
+ function animate() {
5979
+ if (direction2 === "horizontal") {
5980
+ scrollLeft.current += (to - from) / frames;
5981
+ } else {
5982
+ scrollTop.current += (to - from) / frames;
5983
+ }
5984
+ if (++count < frames) {
5985
+ requestAniFrame$1(animate);
5986
+ }
5987
+ }
5988
+ animate();
5989
+ };
5990
+ const scrollIntoView = () => {
5991
+ console.log(name, props);
5992
+ if (!name)
5993
+ return;
5994
+ requestAniFrame$1(() => {
5995
+ Promise.all([
5996
+ getRect2(`#nut-tabs__titles_${name}`),
5997
+ getAllRect(`#nut-tabs__titles_${name} .nut-tabs__titles-item`)
5998
+ ]).then(([navRect, titleRects]) => {
5999
+ navRectRef.current = navRect;
6000
+ titleRectRef.current = titleRects;
6001
+ if (navRectRef.current) {
6002
+ if (props.direction === "vertical") {
6003
+ const titlesTotalHeight = titleRects.reduce(
6004
+ (prev, curr) => prev + curr.height,
6005
+ 0
6006
+ );
6007
+ if (titlesTotalHeight > navRectRef.current.height) {
6008
+ canShowLabel.current = true;
6009
+ } else {
6010
+ canShowLabel.current = false;
6011
+ }
6012
+ } else {
6013
+ const titlesTotalWidth = titleRects.reduce(
6014
+ (prev, curr) => prev + curr.width,
6015
+ 0
6016
+ );
6017
+ if (titlesTotalWidth > navRectRef.current.width) {
6018
+ canShowLabel.current = true;
6019
+ } else {
6020
+ canShowLabel.current = false;
6021
+ }
6022
+ }
6023
+ }
6024
+ const titleRect = titleRectRef.current[value];
6025
+ let to = 0;
6026
+ if (props.direction === "vertical") {
6027
+ const DEFAULT_PADDING = 11;
6028
+ const top = titleRects.slice(0, value).reduce(
6029
+ (prev, curr) => prev + curr.height + 0,
6030
+ DEFAULT_PADDING
6031
+ );
6032
+ to = top - (navRectRef.current.height - titleRect.height) / 2;
6033
+ } else {
6034
+ const DEFAULT_PADDING = 31;
6035
+ const left = titleRects.slice(0, value).reduce(
6036
+ (prev, curr) => prev + curr.width + 20,
6037
+ DEFAULT_PADDING
6038
+ );
6039
+ to = left - (navRectRef.current.width - titleRect.width) / 2;
6040
+ }
6041
+ nextTick(() => {
6042
+ scrollWithAnimation.current = true;
6043
+ });
6044
+ scrollDirection(to, direction);
6045
+ });
6046
+ });
6047
+ };
5941
6048
  const scrollIntoRef = useRef(0);
5942
6049
  useEffect(() => {
5943
6050
  const index = titles.current.findIndex((t) => t.value === value);
@@ -5947,6 +6054,7 @@ const Tabs = (props) => {
5947
6054
  });
5948
6055
  const scrollToIndex = index - 2;
5949
6056
  scrollIntoRef.current = scrollToIndex < 0 ? 0 : scrollToIndex;
6057
+ scrollIntoView();
5950
6058
  }, [value]);
5951
6059
  const tabChange = (item, index) => {
5952
6060
  onClick && onClick(item.value);
@@ -5961,15 +6069,17 @@ const Tabs = (props) => {
5961
6069
  enableFlex: true,
5962
6070
  scrollX: direction === "horizontal",
5963
6071
  scrollY: direction === "vertical",
6072
+ scrollLeft: scrollLeft.current,
6073
+ scrollTop: scrollTop.current,
5964
6074
  showScrollbar: false,
5965
6075
  scrollIntoViewAlignment: "center",
5966
- scrollWithAnimation: true,
5967
- scrollIntoView: `scrollIntoView${scrollIntoRef.current}`,
6076
+ scrollWithAnimation: scrollWithAnimation.current,
6077
+ id: `nut-tabs__titles_${name}`,
5968
6078
  className: classesTitle,
5969
6079
  style: { ...tabStyle },
5970
6080
  ref: navRef
5971
6081
  },
5972
- !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
6082
+ /* @__PURE__ */ React.createElement(View, { className: "nut-tabs__list" }, !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
5973
6083
  return /* @__PURE__ */ React.createElement(
5974
6084
  View,
5975
6085
  {
@@ -5978,7 +6088,7 @@ const Tabs = (props) => {
5978
6088
  onClick: (e) => {
5979
6089
  tabChange(item);
5980
6090
  },
5981
- className: classNames(`${classPrefix$i}__titles-item`, {
6091
+ className: classNames(`${classPrefix$i}__titles-item taro`, {
5982
6092
  [`nut-tabs__titles-item--active`]: !item.disabled && String(item.value) === String(value),
5983
6093
  [`nut-tabs__titles-item--disabled`]: item.disabled,
5984
6094
  [`nut-tabs__titles-item--${align}`]: align
@@ -6013,7 +6123,7 @@ const Tabs = (props) => {
6013
6123
  item.title
6014
6124
  )
6015
6125
  );
6016
- })
6126
+ }))
6017
6127
  ), /* @__PURE__ */ React.createElement(View, { className: `${classPrefix$i}__content__wrap` }, /* @__PURE__ */ React.createElement(View, { className: `${classPrefix$i}__content`, style: contentStyle }, React.Children.map(children, (child, idx) => {
6018
6128
  if (!React.isValidElement(child)) {
6019
6129
  return null;
@@ -6264,11 +6374,7 @@ const InternalCascader = (props, ref) => {
6264
6374
  const [innerValue, setInnerValue] = usePropsValue({
6265
6375
  value,
6266
6376
  defaultValue,
6267
- finalValue: defaultValue,
6268
- onChange: (val) => {
6269
- var _a;
6270
- (_a = props.onChange) == null ? void 0 : _a.call(props, val);
6271
- }
6377
+ finalValue: defaultValue
6272
6378
  });
6273
6379
  const [state] = useState({
6274
6380
  optionsData: [],
@@ -6299,11 +6405,6 @@ const InternalCascader = (props, ref) => {
6299
6405
  useEffect(() => {
6300
6406
  initData();
6301
6407
  }, [options, format2]);
6302
- useEffect(() => {
6303
- if (defaultValue && defaultValue !== innerValue) {
6304
- setInnerValue(defaultValue);
6305
- }
6306
- }, [defaultValue]);
6307
6408
  const initData = async () => {
6308
6409
  state.lazyLoadMap.clear();
6309
6410
  if (format2 && Object.keys(format2).length > 0) {
@@ -6955,18 +7056,6 @@ const getPreMonthDates = (type4, year, month, firstDayOfWeek) => {
6955
7056
  });
6956
7057
  return months.slice(preDates - days);
6957
7058
  };
6958
- function requestAniFrame() {
6959
- if (typeof window !== "undefined") {
6960
- const _window = window;
6961
- return _window.requestAnimationFrame || _window.webkitRequestAnimationFrame || function(callback) {
6962
- _window.setTimeout(callback, 1e3 / 60);
6963
- };
6964
- }
6965
- return function(callback) {
6966
- setTimeout(callback, 1e3 / 60);
6967
- };
6968
- }
6969
- const requestAniFrame$1 = requestAniFrame();
6970
7059
  const splitDate = (date4) => {
6971
7060
  const split = date4.indexOf("-") !== -1 ? "-" : "/";
6972
7061
  return date4.split(split);
@@ -10153,7 +10242,7 @@ class FormItem extends React.Component {
10153
10242
  __publicField(this, "getControlled", (children) => {
10154
10243
  var _a;
10155
10244
  const { setFieldsValue, getFieldValue } = this.context;
10156
- const { name } = this.props;
10245
+ const { name = "" } = this.props;
10157
10246
  if ((_a = children == null ? void 0 : children.props) == null ? void 0 : _a.defaultValue) {
10158
10247
  console.warn("通过 initialValue 设置初始值");
10159
10248
  }
@@ -8,7 +8,7 @@ var __publicField = (obj, key, value) => {
8
8
  return value;
9
9
  };
10
10
  /*!
11
- * @nutui/nutui-react-taro v2.0.3 Wed Jul 12 2023 18:04:02 GMT+0800 (China Standard Time)
11
+ * @nutui/nutui-react-taro v2.0.4 Fri Jul 14 2023 14:21:48 GMT+0800 (China Standard Time)
12
12
  * (c) 2023 @jdf2e.
13
13
  * Released under the MIT License.
14
14
  */
@@ -1957,16 +1957,16 @@ var __publicField = (obj, key, value) => {
1957
1957
  description: "",
1958
1958
  divider: true
1959
1959
  };
1960
- const classPrefix$n = "nut-cell-group";
1960
+ const classPrefix$o = "nut-cell-group";
1961
1961
  const CellGroup = (props) => {
1962
1962
  const { children, className, style, title, description, divider, ...rest } = {
1963
1963
  ...defaultProps$1r,
1964
1964
  ...props
1965
1965
  };
1966
- return /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix$n, className), ...rest }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__description` }, description) : null, /* @__PURE__ */ React.createElement(
1966
+ return /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix$o, className), ...rest }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$o}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$o}__description` }, description) : null, /* @__PURE__ */ React.createElement(
1967
1967
  "div",
1968
1968
  {
1969
- className: `${classPrefix$n}__wrap ${divider ? `${classPrefix$n}__wrap--divider` : ""}`
1969
+ className: `${classPrefix$o}__wrap ${divider ? `${classPrefix$o}__wrap--divider` : ""}`
1970
1970
  },
1971
1971
  children
1972
1972
  ));
@@ -1983,7 +1983,7 @@ var __publicField = (obj, key, value) => {
1983
1983
  onClick: (event) => {
1984
1984
  }
1985
1985
  };
1986
- const classPrefix$m = "nut-cell";
1986
+ const classPrefix$n = "nut-cell";
1987
1987
  const Cell = (props) => {
1988
1988
  const {
1989
1989
  children,
@@ -2014,19 +2014,19 @@ var __publicField = (obj, key, value) => {
2014
2014
  return /* @__PURE__ */ React.createElement(
2015
2015
  "div",
2016
2016
  {
2017
- className: classNames(classPrefix$m, className),
2017
+ className: classNames(classPrefix$n, className),
2018
2018
  onClick: (event) => handleClick(event),
2019
2019
  style: baseStyle,
2020
2020
  ...rest
2021
2021
  },
2022
- children || /* @__PURE__ */ React.createElement(React.Fragment, null, title || description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__left` }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__description` }, description) : null) : null, extra ? /* @__PURE__ */ React.createElement(
2022
+ children || /* @__PURE__ */ React.createElement(React.Fragment, null, title || description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__left` }, title ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__title` }, title) : null, description ? /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__description` }, description) : null) : null, extra ? /* @__PURE__ */ React.createElement(
2023
2023
  "div",
2024
2024
  {
2025
- className: `${classPrefix$m}__extra`,
2025
+ className: `${classPrefix$n}__extra`,
2026
2026
  style: styles
2027
2027
  },
2028
2028
  extra
2029
- ) : null, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$m}__divider` }))
2029
+ ) : null, /* @__PURE__ */ React.createElement("div", { className: `${classPrefix$n}__divider` }))
2030
2030
  );
2031
2031
  };
2032
2032
  Cell.defaultProps = defaultProps$1q;
@@ -2446,8 +2446,10 @@ var __publicField = (obj, key, value) => {
2446
2446
  }
2447
2447
  };
2448
2448
  const defaultProps$1p = {
2449
+ ...ComponentDefaults,
2449
2450
  locale: zhCN
2450
2451
  };
2452
+ const classPrefix$m = "nut-configprovider";
2451
2453
  const defaultConfigRef = {
2452
2454
  current: {
2453
2455
  locale: zhCN
@@ -2468,13 +2470,12 @@ var __publicField = (obj, key, value) => {
2468
2470
  return cssVars;
2469
2471
  }
2470
2472
  const ConfigProvider = (props) => {
2471
- const { children, ...config2 } = { ...defaultProps$1p, ...props };
2473
+ const { children, className, ...config2 } = { ...defaultProps$1p, ...props };
2472
2474
  const parentConfig = useConfig();
2473
- const theme = config2.theme || {};
2474
- const style = React.useMemo(
2475
- () => convertThemeVarsToCSSVars(theme),
2476
- [theme]
2477
- );
2475
+ const style = {
2476
+ ...convertThemeVarsToCSSVars(config2.theme || {}),
2477
+ ...config2.style
2478
+ };
2478
2479
  return /* @__PURE__ */ React.createElement(
2479
2480
  ConfigContext.Provider,
2480
2481
  {
@@ -2483,7 +2484,7 @@ var __publicField = (obj, key, value) => {
2483
2484
  ...config2
2484
2485
  }
2485
2486
  },
2486
- /* @__PURE__ */ React.createElement("div", { style }, children)
2487
+ /* @__PURE__ */ React.createElement("div", { className: classNames(classPrefix$m, className), style }, children)
2487
2488
  );
2488
2489
  };
2489
2490
  ConfigProvider.defaultProps = defaultProps$1p;
@@ -5854,9 +5855,22 @@ var __publicField = (obj, key, value) => {
5854
5855
  );
5855
5856
  return children ? /* @__PURE__ */ React.createElement("div", { className: classes }, !disabled && children) : null;
5856
5857
  };
5858
+ function requestAniFrame() {
5859
+ if (typeof window !== "undefined") {
5860
+ const _window = window;
5861
+ return _window.requestAnimationFrame || _window.webkitRequestAnimationFrame || function(callback) {
5862
+ _window.setTimeout(callback, 1e3 / 60);
5863
+ };
5864
+ }
5865
+ return function(callback) {
5866
+ setTimeout(callback, 1e3 / 60);
5867
+ };
5868
+ }
5869
+ const requestAniFrame$1 = requestAniFrame();
5857
5870
  const defaultProps$15 = {
5858
5871
  ...ComponentDefaults,
5859
5872
  tabStyle: {},
5873
+ name: "",
5860
5874
  activeColor: "",
5861
5875
  direction: "horizontal",
5862
5876
  activeType: "line",
@@ -5873,6 +5887,7 @@ var __publicField = (obj, key, value) => {
5873
5887
  duration,
5874
5888
  align,
5875
5889
  title,
5890
+ name,
5876
5891
  children,
5877
5892
  onClick,
5878
5893
  onChange,
@@ -5938,6 +5953,98 @@ var __publicField = (obj, key, value) => {
5938
5953
  color: activeType === "smile" ? activeColor : "",
5939
5954
  background: activeType === "line" ? activeColor : ""
5940
5955
  };
5956
+ const getRect2 = (selector) => {
5957
+ return new Promise((resolve) => {
5958
+ Taro.createSelectorQuery().select(selector).boundingClientRect().exec((rect = []) => {
5959
+ resolve(rect[0]);
5960
+ });
5961
+ });
5962
+ };
5963
+ const getAllRect = (selector) => {
5964
+ return new Promise((resolve) => {
5965
+ Taro.createSelectorQuery().selectAll(selector).boundingClientRect().exec((rect = []) => resolve(rect[0]));
5966
+ });
5967
+ };
5968
+ const scrollWithAnimation = React.useRef(false);
5969
+ const navRectRef = React.useRef();
5970
+ const titleRectRef = React.useRef([]);
5971
+ const canShowLabel = React.useRef(false);
5972
+ const scrollLeft = React.useRef(0);
5973
+ const scrollTop = React.useRef(0);
5974
+ const scrollDirection = (to, direction2) => {
5975
+ let count = 0;
5976
+ const from = direction2 === "horizontal" ? scrollLeft.current : scrollTop.current;
5977
+ const frames = 1;
5978
+ function animate() {
5979
+ if (direction2 === "horizontal") {
5980
+ scrollLeft.current += (to - from) / frames;
5981
+ } else {
5982
+ scrollTop.current += (to - from) / frames;
5983
+ }
5984
+ if (++count < frames) {
5985
+ requestAniFrame$1(animate);
5986
+ }
5987
+ }
5988
+ animate();
5989
+ };
5990
+ const scrollIntoView = () => {
5991
+ console.log(name, props);
5992
+ if (!name)
5993
+ return;
5994
+ requestAniFrame$1(() => {
5995
+ Promise.all([
5996
+ getRect2(`#nut-tabs__titles_${name}`),
5997
+ getAllRect(`#nut-tabs__titles_${name} .nut-tabs__titles-item`)
5998
+ ]).then(([navRect, titleRects]) => {
5999
+ navRectRef.current = navRect;
6000
+ titleRectRef.current = titleRects;
6001
+ if (navRectRef.current) {
6002
+ if (props.direction === "vertical") {
6003
+ const titlesTotalHeight = titleRects.reduce(
6004
+ (prev, curr) => prev + curr.height,
6005
+ 0
6006
+ );
6007
+ if (titlesTotalHeight > navRectRef.current.height) {
6008
+ canShowLabel.current = true;
6009
+ } else {
6010
+ canShowLabel.current = false;
6011
+ }
6012
+ } else {
6013
+ const titlesTotalWidth = titleRects.reduce(
6014
+ (prev, curr) => prev + curr.width,
6015
+ 0
6016
+ );
6017
+ if (titlesTotalWidth > navRectRef.current.width) {
6018
+ canShowLabel.current = true;
6019
+ } else {
6020
+ canShowLabel.current = false;
6021
+ }
6022
+ }
6023
+ }
6024
+ const titleRect = titleRectRef.current[value];
6025
+ let to = 0;
6026
+ if (props.direction === "vertical") {
6027
+ const DEFAULT_PADDING = 11;
6028
+ const top = titleRects.slice(0, value).reduce(
6029
+ (prev, curr) => prev + curr.height + 0,
6030
+ DEFAULT_PADDING
6031
+ );
6032
+ to = top - (navRectRef.current.height - titleRect.height) / 2;
6033
+ } else {
6034
+ const DEFAULT_PADDING = 31;
6035
+ const left = titleRects.slice(0, value).reduce(
6036
+ (prev, curr) => prev + curr.width + 20,
6037
+ DEFAULT_PADDING
6038
+ );
6039
+ to = left - (navRectRef.current.width - titleRect.width) / 2;
6040
+ }
6041
+ Taro.nextTick(() => {
6042
+ scrollWithAnimation.current = true;
6043
+ });
6044
+ scrollDirection(to, direction);
6045
+ });
6046
+ });
6047
+ };
5941
6048
  const scrollIntoRef = React.useRef(0);
5942
6049
  React.useEffect(() => {
5943
6050
  const index = titles.current.findIndex((t) => t.value === value);
@@ -5947,6 +6054,7 @@ var __publicField = (obj, key, value) => {
5947
6054
  });
5948
6055
  const scrollToIndex = index - 2;
5949
6056
  scrollIntoRef.current = scrollToIndex < 0 ? 0 : scrollToIndex;
6057
+ scrollIntoView();
5950
6058
  }, [value]);
5951
6059
  const tabChange = (item, index) => {
5952
6060
  onClick && onClick(item.value);
@@ -5961,15 +6069,17 @@ var __publicField = (obj, key, value) => {
5961
6069
  enableFlex: true,
5962
6070
  scrollX: direction === "horizontal",
5963
6071
  scrollY: direction === "vertical",
6072
+ scrollLeft: scrollLeft.current,
6073
+ scrollTop: scrollTop.current,
5964
6074
  showScrollbar: false,
5965
6075
  scrollIntoViewAlignment: "center",
5966
- scrollWithAnimation: true,
5967
- scrollIntoView: `scrollIntoView${scrollIntoRef.current}`,
6076
+ scrollWithAnimation: scrollWithAnimation.current,
6077
+ id: `nut-tabs__titles_${name}`,
5968
6078
  className: classesTitle,
5969
6079
  style: { ...tabStyle },
5970
6080
  ref: navRef
5971
6081
  },
5972
- !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
6082
+ /* @__PURE__ */ React.createElement(components.View, { className: "nut-tabs__list" }, !!title && typeof title === "function" ? title() : titles.current.map((item, index) => {
5973
6083
  return /* @__PURE__ */ React.createElement(
5974
6084
  components.View,
5975
6085
  {
@@ -5978,7 +6088,7 @@ var __publicField = (obj, key, value) => {
5978
6088
  onClick: (e) => {
5979
6089
  tabChange(item);
5980
6090
  },
5981
- className: classNames(`${classPrefix$i}__titles-item`, {
6091
+ className: classNames(`${classPrefix$i}__titles-item taro`, {
5982
6092
  [`nut-tabs__titles-item--active`]: !item.disabled && String(item.value) === String(value),
5983
6093
  [`nut-tabs__titles-item--disabled`]: item.disabled,
5984
6094
  [`nut-tabs__titles-item--${align}`]: align
@@ -6013,7 +6123,7 @@ var __publicField = (obj, key, value) => {
6013
6123
  item.title
6014
6124
  )
6015
6125
  );
6016
- })
6126
+ }))
6017
6127
  ), /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$i}__content__wrap` }, /* @__PURE__ */ React.createElement(components.View, { className: `${classPrefix$i}__content`, style: contentStyle }, React.Children.map(children, (child, idx) => {
6018
6128
  if (!React.isValidElement(child)) {
6019
6129
  return null;
@@ -6264,11 +6374,7 @@ var __publicField = (obj, key, value) => {
6264
6374
  const [innerValue, setInnerValue] = usePropsValue({
6265
6375
  value,
6266
6376
  defaultValue,
6267
- finalValue: defaultValue,
6268
- onChange: (val) => {
6269
- var _a;
6270
- (_a = props.onChange) == null ? void 0 : _a.call(props, val);
6271
- }
6377
+ finalValue: defaultValue
6272
6378
  });
6273
6379
  const [state] = React.useState({
6274
6380
  optionsData: [],
@@ -6299,11 +6405,6 @@ var __publicField = (obj, key, value) => {
6299
6405
  React.useEffect(() => {
6300
6406
  initData();
6301
6407
  }, [options, format2]);
6302
- React.useEffect(() => {
6303
- if (defaultValue && defaultValue !== innerValue) {
6304
- setInnerValue(defaultValue);
6305
- }
6306
- }, [defaultValue]);
6307
6408
  const initData = async () => {
6308
6409
  state.lazyLoadMap.clear();
6309
6410
  if (format2 && Object.keys(format2).length > 0) {
@@ -6955,18 +7056,6 @@ var __publicField = (obj, key, value) => {
6955
7056
  });
6956
7057
  return months.slice(preDates - days);
6957
7058
  };
6958
- function requestAniFrame() {
6959
- if (typeof window !== "undefined") {
6960
- const _window = window;
6961
- return _window.requestAnimationFrame || _window.webkitRequestAnimationFrame || function(callback) {
6962
- _window.setTimeout(callback, 1e3 / 60);
6963
- };
6964
- }
6965
- return function(callback) {
6966
- setTimeout(callback, 1e3 / 60);
6967
- };
6968
- }
6969
- const requestAniFrame$1 = requestAniFrame();
6970
7059
  const splitDate = (date2) => {
6971
7060
  const split = date2.indexOf("-") !== -1 ? "-" : "/";
6972
7061
  return date2.split(split);
@@ -10153,7 +10242,7 @@ var __publicField = (obj, key, value) => {
10153
10242
  __publicField(this, "getControlled", (children) => {
10154
10243
  var _a;
10155
10244
  const { setFieldsValue, getFieldValue } = this.context;
10156
- const { name } = this.props;
10245
+ const { name = "" } = this.props;
10157
10246
  if ((_a = children == null ? void 0 : children.props) == null ? void 0 : _a.defaultValue) {
10158
10247
  console.warn("通过 initialValue 设置初始值");
10159
10248
  }