@nutui/nutui-react 2.7.6 → 2.7.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 +29 -7
- package/dist/esm/Address/style/style.css +1 -1
- package/dist/esm/Animate/style/style.css +1 -1
- package/dist/esm/Animate.js +6 -9
- package/dist/esm/Calendar/style/style.css +1 -1
- package/dist/esm/Calendar.js +2 -2
- package/dist/esm/CalendarCard.js +4 -4
- package/dist/esm/CalendarItem.js +177 -180
- package/dist/esm/Cascader/style/style.css +1 -1
- package/dist/esm/DatePicker.js +8 -0
- package/dist/esm/Empty.js +1 -1
- package/dist/esm/Form.js +2 -1
- package/dist/esm/TabPane.js +1 -1
- package/dist/esm/Tabs/style/style.css +1 -1
- package/dist/esm/date.js +109 -181
- package/dist/esm/formitem2.js +121 -31
- package/dist/esm/tabs2.js +26 -42
- 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/tr-TR.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.es.js +477 -517
- package/dist/nutui.react.umd.js +477 -517
- package/dist/packages/animate/animate.scss +63 -105
- package/dist/packages/calendar/calendar.scss +9 -9
- package/dist/packages/tabs/tabs.scss +72 -115
- package/dist/style.css +1 -1
- package/dist/types/packages/animate/animate.taro.d.ts +2 -1
- package/dist/types/packages/form/__tests__/merge.spec.d.ts +1 -0
- package/dist/types/packages/form/index.d.ts +2 -1
- package/dist/types/packages/form/index.taro.d.ts +2 -1
- package/dist/types/packages/form/useform.d.ts +2 -1
- package/dist/types/packages/form/useform.taro.d.ts +2 -1
- package/dist/types/utils/date.d.ts +54 -52
- package/dist/types/utils/merge.d.ts +14 -1
- package/package.json +1 -1
package/dist/esm/tabs2.js
CHANGED
|
@@ -15,32 +15,29 @@ const Tabs = (props) => {
|
|
|
15
15
|
const [value, setValue] = usePropsValue({
|
|
16
16
|
value: outerValue,
|
|
17
17
|
defaultValue: outerDefaultValue,
|
|
18
|
-
finalValue: 0,
|
|
19
18
|
onChange
|
|
20
19
|
});
|
|
21
20
|
const titleItemsRef = useRef([]);
|
|
22
21
|
const navRef = useRef(null);
|
|
23
|
-
const scrollDirection = (nav, to, duration2
|
|
24
|
-
|
|
25
|
-
const from = direction2 === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
22
|
+
const scrollDirection = (nav, to, duration2) => {
|
|
23
|
+
const from = direction === "horizontal" ? nav.scrollLeft : nav.scrollTop;
|
|
26
24
|
const frames = Math.round(duration2 * 1e3 / 16);
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
let count = 0;
|
|
26
|
+
const animate = () => {
|
|
27
|
+
if (direction === "horizontal")
|
|
29
28
|
nav.scrollLeft += (to - from) / frames;
|
|
30
|
-
|
|
29
|
+
else
|
|
31
30
|
nav.scrollTop += (to - from) / frames;
|
|
32
|
-
|
|
33
|
-
if (++count < frames) {
|
|
31
|
+
if (++count < frames)
|
|
34
32
|
requestAniFrame(animate);
|
|
35
|
-
|
|
36
|
-
}
|
|
33
|
+
};
|
|
37
34
|
animate();
|
|
38
35
|
};
|
|
39
36
|
const scrollIntoView = (index, immediate) => {
|
|
40
37
|
const nav = navRef.current;
|
|
41
38
|
const titleItem = titleItemsRef.current;
|
|
42
39
|
const titlesLength = titles.current.length;
|
|
43
|
-
const itemLength =
|
|
40
|
+
const itemLength = titleItem.length;
|
|
44
41
|
if (!nav || !titleItem || !titleItem[itemLength - titlesLength + index]) {
|
|
45
42
|
return;
|
|
46
43
|
}
|
|
@@ -52,13 +49,13 @@ const Tabs = (props) => {
|
|
|
52
49
|
} else {
|
|
53
50
|
to = title2.offsetLeft - (nav.offsetWidth - title2.offsetWidth) / 2;
|
|
54
51
|
}
|
|
55
|
-
scrollDirection(nav, to, 0.3
|
|
52
|
+
scrollDirection(nav, to, 0.3);
|
|
56
53
|
};
|
|
57
54
|
const getTitles = () => {
|
|
58
55
|
const titles2 = [];
|
|
59
56
|
React__default.Children.forEach(children, (child, idx) => {
|
|
60
57
|
if (React__default.isValidElement(child)) {
|
|
61
|
-
const
|
|
58
|
+
const { props: props2 } = child;
|
|
62
59
|
if ((props2 === null || props2 === void 0 ? void 0 : props2.title) || (props2 === null || props2 === void 0 ? void 0 : props2.value)) {
|
|
63
60
|
titles2.push({
|
|
64
61
|
title: props2.title,
|
|
@@ -89,23 +86,18 @@ const Tabs = (props) => {
|
|
|
89
86
|
const classes = classNames(classPrefix, `${classPrefix}-${direction}`, className);
|
|
90
87
|
const classesTitle = classNames(`${classPrefix}-titles`, {
|
|
91
88
|
[`${classPrefix}-titles-${activeType}`]: activeType,
|
|
92
|
-
[`${classPrefix}-titles-scrollable`]: true,
|
|
93
89
|
[`${classPrefix}-titles-${align}`]: align
|
|
94
90
|
});
|
|
95
|
-
const tabsActiveStyle = {
|
|
96
|
-
color: activeType === "smile" ? activeColor : "",
|
|
97
|
-
background: activeType === "line" ? activeColor : ""
|
|
98
|
-
};
|
|
99
91
|
const getContentStyle = () => {
|
|
100
|
-
let index = titles.current.findIndex((t) => t.value
|
|
92
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
101
93
|
index = index < 0 ? 0 : index;
|
|
102
94
|
return {
|
|
103
|
-
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0
|
|
95
|
+
transform: direction === "horizontal" ? `translate3d(${rtl ? "" : "-"}${index * 100}%, 0, 0)` : `translate3d( 0, -${index * 100}%, 0)`,
|
|
104
96
|
transitionDuration: `${duration}ms`
|
|
105
97
|
};
|
|
106
98
|
};
|
|
107
99
|
useEffect(() => {
|
|
108
|
-
let index = titles.current.findIndex((t) => t.value
|
|
100
|
+
let index = titles.current.findIndex((t) => t.value === value);
|
|
109
101
|
index = index < 0 ? 0 : index;
|
|
110
102
|
setTimeout(() => {
|
|
111
103
|
scrollIntoView(index);
|
|
@@ -113,47 +105,39 @@ const Tabs = (props) => {
|
|
|
113
105
|
}, [value]);
|
|
114
106
|
const tabChange = (item) => {
|
|
115
107
|
onClick && onClick(item.value);
|
|
116
|
-
if (item.disabled) {
|
|
117
|
-
|
|
108
|
+
if (!item.disabled) {
|
|
109
|
+
setValue(item.value);
|
|
118
110
|
}
|
|
119
|
-
setValue(item.value);
|
|
120
111
|
};
|
|
121
112
|
return React__default.createElement(
|
|
122
113
|
"div",
|
|
123
114
|
Object.assign({ className: classes }, rest),
|
|
124
|
-
React__default.createElement("div", { className: classesTitle, style:
|
|
115
|
+
React__default.createElement("div", { className: classesTitle, style: tabStyle, ref: navRef }, !!title && typeof title === "function" ? title() : titles.current.map((item) => {
|
|
125
116
|
return React__default.createElement(
|
|
126
117
|
"div",
|
|
127
|
-
{ onClick: () => {
|
|
128
|
-
tabChange(item);
|
|
129
|
-
}, className: classNames(`${classPrefix}-titles-item`, {
|
|
118
|
+
{ key: item.value, ref: (ref) => titleItemsRef.current.push(ref), onClick: () => tabChange(item), className: classNames(`${classPrefix}-titles-item`, {
|
|
130
119
|
[`nut-tabs-titles-item-active`]: !item.disabled && String(item.value) === String(value),
|
|
131
120
|
[`nut-tabs-titles-item-disabled`]: item.disabled,
|
|
132
121
|
[`nut-tabs-titles-item-${align}`]: align
|
|
133
|
-
})
|
|
134
|
-
activeType === "line" && React__default.createElement("div", { className: classNames(`${classPrefix}-titles-item-line`, {
|
|
135
|
-
[`${classPrefix}-titles-item-line-${direction}`]: true
|
|
136
|
-
}), style: tabsActiveStyle }),
|
|
122
|
+
}) },
|
|
123
|
+
activeType === "line" && React__default.createElement("div", { className: classNames(`${classPrefix}-titles-item-line`, `${classPrefix}-titles-item-line-${direction}`), style: { background: activeColor } }),
|
|
137
124
|
activeType === "smile" && React__default.createElement(
|
|
138
125
|
"div",
|
|
139
|
-
{ className: `${classPrefix}-titles-item-smile
|
|
126
|
+
{ className: `${classPrefix}-titles-item-smile` },
|
|
140
127
|
React__default.createElement(JoySmile, { color: activeColor, width: 40, height: 20 })
|
|
141
128
|
),
|
|
142
|
-
React__default.createElement("div", { className: classNames(
|
|
129
|
+
React__default.createElement("div", { className: classNames({
|
|
130
|
+
[`${classPrefix}-ellipsis`]: direction === "vertical"
|
|
131
|
+
}, `${classPrefix}-titles-item-text`), style: { color: activeColor } }, item.title)
|
|
143
132
|
);
|
|
144
133
|
})),
|
|
145
134
|
React__default.createElement(
|
|
146
135
|
"div",
|
|
147
136
|
{ className: `${classPrefix}-content-wrap` },
|
|
148
137
|
React__default.createElement("div", { className: `${classPrefix}-content`, style: getContentStyle() }, React__default.Children.map(children, (child, idx) => {
|
|
149
|
-
if (!React__default.isValidElement(child))
|
|
138
|
+
if (!React__default.isValidElement(child))
|
|
150
139
|
return null;
|
|
151
|
-
}
|
|
152
|
-
let childProps = Object.assign(Object.assign({}, child.props), { active: value === child.props.value });
|
|
153
|
-
if (String(value) !== String(child.props.value || idx) && autoHeight) {
|
|
154
|
-
childProps = Object.assign(Object.assign({}, childProps), { autoHeightClassName: "inactive" });
|
|
155
|
-
}
|
|
156
|
-
return React__default.cloneElement(child, childProps);
|
|
140
|
+
return React__default.cloneElement(child, Object.assign(Object.assign({}, child.props), { active: value === child.props.value, autoHeightClassName: autoHeight && String(value) !== String(child.props.value || idx) ? "inactive" : void 0 }));
|
|
157
141
|
}))
|
|
158
142
|
)
|
|
159
143
|
);
|
package/dist/locales/base.js
CHANGED
package/dist/locales/en-US.js
CHANGED
package/dist/locales/id-ID.js
CHANGED
package/dist/locales/tr-TR.js
CHANGED
package/dist/locales/zh-CN.js
CHANGED
package/dist/locales/zh-TW.js
CHANGED
package/dist/locales/zh-UG.js
CHANGED