@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/CHANGELOG.md +10 -0
- package/dist/esm/Audio.js +7 -3
- package/dist/esm/Cascader.js +20 -12
- package/dist/esm/Range/style/index.js +1 -1
- package/dist/esm/Range.js +119 -174
- package/dist/esm/tabs2.js +21 -8
- package/dist/locales/base.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/id-ID.js +1 -1
- package/dist/locales/zh-CN.js +1 -1
- package/dist/locales/zh-TW.js +1 -1
- package/dist/locales/zh-UG.js +1 -1
- package/dist/nutui.react.mjs +555 -609
- package/dist/nutui.react.umd.js +555 -609
- package/dist/packages/range/range.scss +24 -49
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +11 -17
- package/dist/styles/variables.scss +11 -14
- package/dist/types/index.d.ts +20 -26
- package/package.json +1 -1
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
|
|
114
|
+
if (title2.value == value) {
|
|
108
115
|
current = value;
|
|
109
116
|
}
|
|
110
117
|
});
|
|
111
|
-
|
|
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
|
|
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
|
-
|
|
138
|
+
setTimeout(function() {
|
|
139
|
+
scrollIntoView(index);
|
|
140
|
+
});
|
|
128
141
|
}, [value]);
|
|
129
|
-
var tabChange = function tabChange2(item
|
|
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
|
|
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(
|
|
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)),
|
package/dist/locales/base.js
CHANGED
package/dist/locales/en-US.js
CHANGED
package/dist/locales/id-ID.js
CHANGED
package/dist/locales/zh-CN.js
CHANGED
package/dist/locales/zh-TW.js
CHANGED
package/dist/locales/zh-UG.js
CHANGED