@nutui/nutui-react 2.0.0-alpha.6 → 2.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/tabs2.js CHANGED
@@ -1,6 +1,6 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  var _excluded = ["activeColor", "tabStyle", "direction", "activeType", "duration", "align", "title", "children", "onClick", "onChange", "className", "autoHeight"];
5
5
  function ownKeys(object, enumerableOnly) {
6
6
  var keys = Object.keys(object);
@@ -30,6 +30,12 @@ import { C as ComponentDefaults } from "./typings.js";
30
30
  import TabPane from "./TabPane.js";
31
31
  import { r as requestAniFrame } from "./raf.js";
32
32
  import { u as usePropsValue } from "./use-props-value.js";
33
+ function useForceUpdate() {
34
+ var _React__default$useSt = React__default.useState(), _React__default$useSt2 = _slicedToArray(_React__default$useSt, 2), updateState = _React__default$useSt2[1];
35
+ return React__default.useCallback(function() {
36
+ return updateState({});
37
+ }, []);
38
+ }
33
39
  var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
34
40
  tabStyle: {},
35
41
  activeColor: "",
@@ -100,15 +106,20 @@ var Tabs = function Tabs2(props) {
100
106
  return titles2;
101
107
  };
102
108
  var titles = useRef(getTitles());
109
+ var forceUpdate = useForceUpdate();
103
110
  useEffect(function() {
104
111
  titles.current = getTitles();
105
112
  var current = "";
106
113
  titles.current.forEach(function(title2) {
107
- if (title2.value === value) {
114
+ if (title2.value == value) {
108
115
  current = value;
109
116
  }
110
117
  });
111
- setValue(current);
118
+ if (current !== "" && current !== value) {
119
+ setValue(current);
120
+ } else {
121
+ forceUpdate();
122
+ }
112
123
  }, [children]);
113
124
  var classes = classNames(classPrefix, "".concat(classPrefix, "--").concat(direction), className);
114
125
  var classesTitle = classNames("".concat(classPrefix, "__titles"), (_classNames = {}, _defineProperty(_classNames, "".concat(classPrefix, "__titles--").concat(activeType), activeType), _defineProperty(_classNames, "".concat(classPrefix, "__titles--scrollable"), true), _defineProperty(_classNames, "".concat(classPrefix, "__titles--").concat(align), align), _classNames));
@@ -118,15 +129,17 @@ var Tabs = function Tabs2(props) {
118
129
  };
119
130
  useEffect(function() {
120
131
  var index = titles.current.findIndex(function(t) {
121
- return t.value === value;
132
+ return t.value == value;
122
133
  });
123
134
  setContentStyle({
124
135
  transform: direction === "horizontal" ? "translate3d(-".concat(index * 100, "%, 0, 0)") : "translate3d( 0,-".concat(index * 100, "%, 0)"),
125
136
  transitionDuration: "".concat(duration, "ms")
126
137
  });
127
- scrollIntoView(index);
138
+ setTimeout(function() {
139
+ scrollIntoView(index);
140
+ });
128
141
  }, [value]);
129
- var tabChange = function tabChange2(item, index) {
142
+ var tabChange = function tabChange2(item) {
130
143
  onClick && onClick(item.value);
131
144
  if (item.disabled) {
132
145
  return;
@@ -139,10 +152,10 @@ var Tabs = function Tabs2(props) {
139
152
  className: classesTitle,
140
153
  style: _objectSpread({}, tabStyle),
141
154
  ref: navRef
142
- }, !!title && typeof title === "function" ? title() : titles.current.map(function(item, index) {
155
+ }, !!title && typeof title === "function" ? title() : titles.current.map(function(item) {
143
156
  var _classNames2;
144
157
  return React__default.createElement("div", {
145
- onClick: function onClick2(e) {
158
+ onClick: function onClick2() {
146
159
  tabChange(item);
147
160
  },
148
161
  className: classNames("".concat(classPrefix, "__titles-item"), (_classNames2 = {}, _defineProperty(_classNames2, "nut-tabs__titles-item--active", !item.disabled && String(item.value) === String(value)), _defineProperty(_classNames2, "nut-tabs__titles-item--disabled", item.disabled), _defineProperty(_classNames2, "nut-tabs__titles-item--".concat(align), align), _classNames2)),
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.0.0-alpha.6 Fri May 12 2023 15:14:14 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:08:16 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.0.0-alpha.6 Fri May 12 2023 15:14:14 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:08:16 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.0.0-alpha.6 Fri May 12 2023 15:14:14 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:08:16 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.0.0-alpha.6 Fri May 12 2023 15:14:14 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:08:16 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.0.0-alpha.6 Fri May 12 2023 15:14:14 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:08:16 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.0.0-alpha.6 Fri May 12 2023 15:14:14 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.0.0-alpha.8 Fri May 12 2023 19:08:16 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */