@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.
Files changed (39) hide show
  1. package/CHANGELOG.md +29 -7
  2. package/dist/esm/Address/style/style.css +1 -1
  3. package/dist/esm/Animate/style/style.css +1 -1
  4. package/dist/esm/Animate.js +6 -9
  5. package/dist/esm/Calendar/style/style.css +1 -1
  6. package/dist/esm/Calendar.js +2 -2
  7. package/dist/esm/CalendarCard.js +4 -4
  8. package/dist/esm/CalendarItem.js +177 -180
  9. package/dist/esm/Cascader/style/style.css +1 -1
  10. package/dist/esm/DatePicker.js +8 -0
  11. package/dist/esm/Empty.js +1 -1
  12. package/dist/esm/Form.js +2 -1
  13. package/dist/esm/TabPane.js +1 -1
  14. package/dist/esm/Tabs/style/style.css +1 -1
  15. package/dist/esm/date.js +109 -181
  16. package/dist/esm/formitem2.js +121 -31
  17. package/dist/esm/tabs2.js +26 -42
  18. package/dist/locales/base.js +1 -1
  19. package/dist/locales/en-US.js +1 -1
  20. package/dist/locales/id-ID.js +1 -1
  21. package/dist/locales/tr-TR.js +1 -1
  22. package/dist/locales/zh-CN.js +1 -1
  23. package/dist/locales/zh-TW.js +1 -1
  24. package/dist/locales/zh-UG.js +1 -1
  25. package/dist/nutui.react.es.js +477 -517
  26. package/dist/nutui.react.umd.js +477 -517
  27. package/dist/packages/animate/animate.scss +63 -105
  28. package/dist/packages/calendar/calendar.scss +9 -9
  29. package/dist/packages/tabs/tabs.scss +72 -115
  30. package/dist/style.css +1 -1
  31. package/dist/types/packages/animate/animate.taro.d.ts +2 -1
  32. package/dist/types/packages/form/__tests__/merge.spec.d.ts +1 -0
  33. package/dist/types/packages/form/index.d.ts +2 -1
  34. package/dist/types/packages/form/index.taro.d.ts +2 -1
  35. package/dist/types/packages/form/useform.d.ts +2 -1
  36. package/dist/types/packages/form/useform.taro.d.ts +2 -1
  37. package/dist/types/utils/date.d.ts +54 -52
  38. package/dist/types/utils/merge.d.ts +14 -1
  39. 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, direction2) => {
24
- let count = 0;
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
- function animate() {
28
- if (direction2 === "horizontal") {
25
+ let count = 0;
26
+ const animate = () => {
27
+ if (direction === "horizontal")
29
28
  nav.scrollLeft += (to - from) / frames;
30
- } else {
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 = titleItemsRef.current.length;
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, direction);
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 props2 = child === null || child === void 0 ? void 0 : child.props;
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 == 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,-${index * 100}%, 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 == 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
- return;
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: Object.assign({}, tabStyle), ref: navRef }, !!title && typeof title === "function" ? title() : titles.current.map((item) => {
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
- }), ref: (ref) => titleItemsRef.current.push(ref), key: item.value },
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`, style: tabsActiveStyle },
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(`${classPrefix}-ellipsis`, `${classPrefix}-titles-item-text`) }, item.title)
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
  );
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v2.7.6 Fri Jan 10 2025 10:41:53 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:53 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.7.6 Fri Jan 10 2025 10:41:53 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:53 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.7.6 Fri Jan 10 2025 10:41:53 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:53 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.7.6 Fri Jan 10 2025 10:41:53 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:53 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.7.6 Fri Jan 10 2025 10:41:53 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:53 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.7.6 Fri Jan 10 2025 10:41:53 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:53 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.7.6 Fri Jan 10 2025 10:41:53 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v2.7.8 Fri Feb 14 2025 16:19:53 GMT+0800 (China Standard Time)
3
3
  * (c) 2023 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */