@nutui/nutui-react-taro 2.0.0-alpha.3 → 2.0.0-alpha.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.
- package/CHANGELOG.md +9 -0
- package/dist/esm/CircleProgress.js +2 -3
- package/dist/esm/Input.js +4 -1
- package/dist/esm/Tabbar.js +6 -3
- package/dist/esm/TabbarItem.js +3 -4
- package/dist/esm/{circleprogress.taro-d8973ae9.js → circleprogress.taro-d4943109.js} +21 -27
- package/dist/esm/input.taro-1aca4a45.js +167 -0
- package/dist/esm/nutui-react.es.js +5 -5
- package/dist/esm/tabbar.taro-48413fb8.js +51 -0
- package/dist/esm/tabbaritem.taro-5afa3562.js +37 -0
- 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 +642 -851
- package/dist/nutui.react.umd.js +640 -849
- package/dist/packages/badge/badge.scss +0 -1
- package/dist/packages/circleprogress/circleprogress.scss +0 -9
- package/dist/packages/input/input.scss +13 -180
- package/dist/packages/tabbar/tabbar.scss +16 -23
- package/dist/packages/tabbaritem/tabbaritem.scss +9 -70
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/variables-jmapp.scss +12 -16
- package/dist/styles/variables.scss +12 -16
- package/dist/types/index.d.ts +48 -84
- package/package.json +1 -1
- package/dist/esm/input.taro-f4e067f7.js +0 -237
- package/dist/esm/tabbar.taro-eefd0f8e.js +0 -59
- package/dist/esm/tabbaritem.taro-7a97e645.js +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# v2.0.0-alpha.4
|
|
2
|
+
`2023-05-05`
|
|
3
|
+
|
|
4
|
+
* 🛠 refactor: circleprogress-v2.0 (#949) @junjun666
|
|
5
|
+
* 🛠 refactor: input (#962) @oasis-cloud
|
|
6
|
+
* 🛠 refactor: Tabbar (#935) @Eiinu
|
|
7
|
+
* :bug: fix: badge 组件的默认样式中,去掉 margin-right (#967) @xiaoyatong
|
|
8
|
+
* 🎨 style: fix endLine display error (#964) @HaiTao
|
|
9
|
+
|
|
1
10
|
# v2.0.0-alpha.3
|
|
2
11
|
`2023-04-28`
|
|
3
12
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { C as CircleProgress } from './circleprogress.taro-
|
|
1
|
+
import { C as CircleProgress } from './circleprogress.taro-d4943109.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'classnames';
|
|
4
4
|
import './index-5bcb0ff8.js';
|
|
5
|
-
import './
|
|
6
|
-
import '@bem-react/classname';
|
|
5
|
+
import './typings-d8491423.js';
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
package/dist/esm/Input.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { I as Input } from './input.taro-
|
|
1
|
+
import { I as Input } from './input.taro-1aca4a45.js';
|
|
2
2
|
import 'react';
|
|
3
|
+
import '@tarojs/components';
|
|
3
4
|
import '@nutui/icons-react-taro';
|
|
5
|
+
import '@tarojs/taro';
|
|
4
6
|
import './configprovider.taro-43a3c646.js';
|
|
5
7
|
import 'lodash.kebabcase';
|
|
6
8
|
import './zh-CN-b4f493ba.js';
|
|
7
9
|
import './typings-d8491423.js';
|
|
10
|
+
import './use-props-value-ae7ee726.js';
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
|
package/dist/esm/Tabbar.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { T as Tabbar } from './tabbar.taro-
|
|
1
|
+
import { T as Tabbar } from './tabbar.taro-48413fb8.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import '
|
|
4
|
-
import '
|
|
3
|
+
import 'classnames';
|
|
4
|
+
import './typings-d8491423.js';
|
|
5
|
+
import './use-props-value-ae7ee726.js';
|
|
6
|
+
import './tabbaritem.taro-5afa3562.js';
|
|
7
|
+
import './badge.taro-e2169fbe.js';
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
|
package/dist/esm/TabbarItem.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { T as TabbarItem } from './tabbaritem.taro-
|
|
1
|
+
import { T as TabbarItem } from './tabbaritem.taro-5afa3562.js';
|
|
2
2
|
import 'react';
|
|
3
|
-
import '
|
|
4
|
-
import './bem-350c1702.js';
|
|
5
|
-
import '@bem-react/classname';
|
|
3
|
+
import 'classnames';
|
|
6
4
|
import './typings-d8491423.js';
|
|
5
|
+
import './badge.taro-e2169fbe.js';
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { a as isObject } from './index-5bcb0ff8.js';
|
|
4
|
-
import {
|
|
4
|
+
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
5
5
|
|
|
6
6
|
const defaultProps = {
|
|
7
|
+
...ComponentDefaults,
|
|
7
8
|
strokeWidth: 5,
|
|
8
9
|
radius: 50,
|
|
9
10
|
strokeLinecap: 'round',
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
color: '#fa2c19',
|
|
12
|
+
background: '#e5e9f2',
|
|
12
13
|
clockwise: true,
|
|
13
14
|
};
|
|
15
|
+
const classPrefix = `nut-circleprogress`;
|
|
14
16
|
const CircleProgress = (props) => {
|
|
15
|
-
const { children,
|
|
17
|
+
const { children, percent, className, radius, background, clockwise, color, strokeWidth, style, strokeLinecap, ...restProps } = {
|
|
16
18
|
...defaultProps,
|
|
17
19
|
...props,
|
|
18
20
|
};
|
|
19
|
-
const [oldValue, setOldValue] = useState(
|
|
20
|
-
const
|
|
21
|
-
const classes = classNames(className, b(''));
|
|
21
|
+
const [oldValue, setOldValue] = useState(percent);
|
|
22
|
+
const classes = classNames(className, classPrefix);
|
|
22
23
|
const refRandomId = Math.random().toString(36).slice(-8);
|
|
24
|
+
const animateIdRef = useRef(0);
|
|
23
25
|
const styles = {
|
|
24
26
|
height: `${Number(radius) * 2}px`,
|
|
25
27
|
width: `${Number(radius) * 2}px`,
|
|
26
28
|
...style,
|
|
27
29
|
};
|
|
28
30
|
useEffect(() => {
|
|
29
|
-
let rafId;
|
|
30
31
|
const startTime = Date.now();
|
|
31
32
|
const startRate = Number(oldValue); // 30
|
|
32
|
-
const endRate = Number(
|
|
33
|
+
const endRate = Number(percent); // 40
|
|
33
34
|
const duration = Math.abs(((startRate - endRate) * 1000) / +100); // 100
|
|
34
35
|
const animate = () => {
|
|
35
36
|
const now = Date.now();
|
|
@@ -37,22 +38,17 @@ const CircleProgress = (props) => {
|
|
|
37
38
|
const rate = progress * (endRate - startRate) + startRate;
|
|
38
39
|
setOldValue(Math.min(Math.max(+rate, 0), 100));
|
|
39
40
|
if (endRate > startRate ? rate < endRate : rate > endRate) {
|
|
40
|
-
|
|
41
|
+
animateIdRef.current = window.requestAnimationFrame(animate);
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
rafId = window.requestAnimationFrame(animate);
|
|
47
|
-
}, [progress]);
|
|
48
|
-
const cancelAnimationFrame = function (id) {
|
|
49
|
-
clearTimeout(id);
|
|
50
|
-
};
|
|
44
|
+
animateIdRef.current = window.requestAnimationFrame(animate);
|
|
45
|
+
return () => window.cancelAnimationFrame(animateIdRef.current);
|
|
46
|
+
}, [percent]);
|
|
51
47
|
const stop = () => {
|
|
52
|
-
if (!isObject(
|
|
48
|
+
if (!isObject(props.color)) {
|
|
53
49
|
return [];
|
|
54
50
|
}
|
|
55
|
-
const color =
|
|
51
|
+
const color = props.color;
|
|
56
52
|
const colorArr = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b));
|
|
57
53
|
const stopArr = [];
|
|
58
54
|
colorArr.map((item) => {
|
|
@@ -84,12 +80,12 @@ const CircleProgress = (props) => {
|
|
|
84
80
|
const progress = +oldValue;
|
|
85
81
|
const offset = (perimeter * Number(format(parseFloat(progress.toFixed(1))))) / 100;
|
|
86
82
|
const isWise = props.clockwise ? 1 : 0;
|
|
87
|
-
const color = isObject(
|
|
83
|
+
const color = isObject(props.color)
|
|
88
84
|
? `url(%23${refRandomId})`
|
|
89
|
-
: transColor(
|
|
85
|
+
: transColor(props.color);
|
|
90
86
|
const d = `M 50 50 m 0 -45 a 45 45 0 1 ${isWise} 0 90 a 45 45 0 1, ${isWise} 0 -90`;
|
|
91
87
|
const pa = `%3Cdefs%3E%3ClinearGradient id='${refRandomId}' x1='100%25' y1='0%25' x2='0%25' y2='0%25'%3E${stopDom}%3C/linearGradient%3E%3C/defs%3E`;
|
|
92
|
-
const path = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke='${transColor(props.
|
|
88
|
+
const path = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke='${transColor(props.background)}' fill='none'/%3E`;
|
|
93
89
|
const path1 = `%3Cpath d='${d}' stroke-width='${strokeWidth}' stroke-dasharray='${offset},${perimeter}' stroke-linecap='round' stroke='${transColor(color)}' fill='none'/%3E`;
|
|
94
90
|
return {
|
|
95
91
|
background: `url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E${pa}${path}${path1}%3C/svg%3E")`,
|
|
@@ -99,9 +95,7 @@ const CircleProgress = (props) => {
|
|
|
99
95
|
};
|
|
100
96
|
return (React.createElement("div", { className: classes, style: styles, ...restProps },
|
|
101
97
|
React.createElement("div", { style: circleStyle() }),
|
|
102
|
-
React.createElement("div", { className: "nut-circleprogress-text" }, children
|
|
103
|
-
progress,
|
|
104
|
-
"%"))));
|
|
98
|
+
React.createElement("div", { className: "nut-circleprogress-text" }, children)));
|
|
105
99
|
};
|
|
106
100
|
CircleProgress.defaultProps = defaultProps;
|
|
107
101
|
CircleProgress.displayName = 'NutCircleProgress';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useState, useImperativeHandle, useCallback } from 'react';
|
|
2
|
+
import { View, Input as Input$1 } from '@tarojs/components';
|
|
3
|
+
import { MaskClose } from '@nutui/icons-react-taro';
|
|
4
|
+
import { getEnv, ENV_TYPE } from '@tarojs/taro';
|
|
5
|
+
import { u as useConfig } from './configprovider.taro-43a3c646.js';
|
|
6
|
+
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
7
|
+
import { u as usePropsValue } from './use-props-value-ae7ee726.js';
|
|
8
|
+
|
|
9
|
+
function trimExtraChar(value, char, regExp) {
|
|
10
|
+
const index = value.indexOf(char);
|
|
11
|
+
if (index === -1) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
if (char === '-' && index !== 0) {
|
|
15
|
+
return value.slice(0, index);
|
|
16
|
+
}
|
|
17
|
+
return value.slice(0, index + 1) + value.slice(index).replace(regExp, '');
|
|
18
|
+
}
|
|
19
|
+
function formatNumber(value, allowDot = true, allowMinus = true) {
|
|
20
|
+
if (allowDot) {
|
|
21
|
+
value = trimExtraChar(value, '.', /\./g);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
value = value.split('.')[0];
|
|
25
|
+
}
|
|
26
|
+
if (allowMinus) {
|
|
27
|
+
value = trimExtraChar(value, '-', /-/g);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
value = value.replace(/-/, '');
|
|
31
|
+
}
|
|
32
|
+
const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
|
|
33
|
+
return value.replace(regExp, '');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const defaultProps = {
|
|
37
|
+
...ComponentDefaults,
|
|
38
|
+
type: 'text',
|
|
39
|
+
name: '',
|
|
40
|
+
placeholder: '',
|
|
41
|
+
confirmType: 'done',
|
|
42
|
+
align: 'left',
|
|
43
|
+
required: false,
|
|
44
|
+
disabled: false,
|
|
45
|
+
readOnly: false,
|
|
46
|
+
maxLength: 9999,
|
|
47
|
+
clearable: false,
|
|
48
|
+
clearIcon: null,
|
|
49
|
+
formatTrigger: 'onChange',
|
|
50
|
+
autoFocus: false,
|
|
51
|
+
};
|
|
52
|
+
const Input = forwardRef((props, ref) => {
|
|
53
|
+
const { locale } = useConfig();
|
|
54
|
+
const { type, name, placeholder, align, disabled, readOnly, maxLength, clearable, clearIcon, formatTrigger, autoFocus, style, className, onChange, onFocus, onBlur, onClear, formatter, onClick, confirmType, defaultValue, value: _value, ...rest } = {
|
|
55
|
+
...defaultProps,
|
|
56
|
+
...props,
|
|
57
|
+
};
|
|
58
|
+
const [value, setValue] = usePropsValue({
|
|
59
|
+
value: props.value,
|
|
60
|
+
defaultValue: props.defaultValue,
|
|
61
|
+
finalValue: '',
|
|
62
|
+
onChange,
|
|
63
|
+
});
|
|
64
|
+
const inputRef = useRef(null);
|
|
65
|
+
const [active, setActive] = useState(false);
|
|
66
|
+
useImperativeHandle(ref, () => {
|
|
67
|
+
return {
|
|
68
|
+
clear: () => {
|
|
69
|
+
setValue('');
|
|
70
|
+
},
|
|
71
|
+
focus: () => {
|
|
72
|
+
inputRef.current?.focus();
|
|
73
|
+
},
|
|
74
|
+
blur: () => {
|
|
75
|
+
inputRef.current?.blur();
|
|
76
|
+
},
|
|
77
|
+
get nativeElement() {
|
|
78
|
+
return inputRef.current;
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
const inputClass = useCallback(() => {
|
|
83
|
+
const classPrefix = 'nut-input';
|
|
84
|
+
return [classPrefix, `${disabled ? `${classPrefix}-disabled` : ''}`]
|
|
85
|
+
.filter(Boolean)
|
|
86
|
+
.join(' ');
|
|
87
|
+
}, [disabled]);
|
|
88
|
+
const [, updateState] = React.useState();
|
|
89
|
+
const forceUpdate = React.useCallback(() => updateState({}), []);
|
|
90
|
+
const updateValue = (value, trigger = 'onChange') => {
|
|
91
|
+
let val = value;
|
|
92
|
+
if (getEnv() === ENV_TYPE.WEB) {
|
|
93
|
+
if (type === 'number') {
|
|
94
|
+
val = formatNumber(val, false, true);
|
|
95
|
+
}
|
|
96
|
+
if (type === 'digit') {
|
|
97
|
+
val = formatNumber(val, true, true);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (formatter && trigger === formatTrigger) {
|
|
101
|
+
val = formatter(val);
|
|
102
|
+
}
|
|
103
|
+
setValue(val);
|
|
104
|
+
const eventHandler = props[trigger];
|
|
105
|
+
if (eventHandler && typeof eventHandler === 'function') {
|
|
106
|
+
eventHandler(val);
|
|
107
|
+
}
|
|
108
|
+
forceUpdate();
|
|
109
|
+
};
|
|
110
|
+
const handleFocus = (event) => {
|
|
111
|
+
const val = event.target.value;
|
|
112
|
+
onFocus && onFocus(val);
|
|
113
|
+
setActive(true);
|
|
114
|
+
};
|
|
115
|
+
const handleInput = (value) => {
|
|
116
|
+
updateValue(value, 'onChange');
|
|
117
|
+
};
|
|
118
|
+
const handleBlur = (event) => {
|
|
119
|
+
const val = event.target.value;
|
|
120
|
+
updateValue(val, 'onBlur');
|
|
121
|
+
setTimeout(() => {
|
|
122
|
+
setActive(false);
|
|
123
|
+
}, 50);
|
|
124
|
+
};
|
|
125
|
+
const inputType = (type) => {
|
|
126
|
+
if (getEnv() === ENV_TYPE.WEB) {
|
|
127
|
+
if (type === 'digit') {
|
|
128
|
+
return 'text';
|
|
129
|
+
}
|
|
130
|
+
if (type === 'number') {
|
|
131
|
+
return 'tel';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (type === 'password') {
|
|
135
|
+
return 'text';
|
|
136
|
+
}
|
|
137
|
+
return type;
|
|
138
|
+
};
|
|
139
|
+
return (React.createElement(View, { className: `${inputClass()} ${className || ''}`, style: style, onClick: (e) => {
|
|
140
|
+
onClick && onClick(e);
|
|
141
|
+
} },
|
|
142
|
+
React.createElement(Input$1, { ...rest, name: name, className: "nut-input-native", ref: inputRef, style: { textAlign: align }, type: inputType(type), password: type === 'password', maxlength: maxLength, placeholder: placeholder || locale.placeholder, disabled: disabled || readOnly, value: value, focus: autoFocus, confirmType: confirmType, onBlur: (e) => {
|
|
143
|
+
handleBlur(e);
|
|
144
|
+
}, onFocus: (e) => {
|
|
145
|
+
handleFocus(e);
|
|
146
|
+
}, onInput: (e) => {
|
|
147
|
+
handleInput(e.currentTarget.value);
|
|
148
|
+
} }),
|
|
149
|
+
React.createElement(View, { style: {
|
|
150
|
+
display: clearable && !readOnly && active && value.length > 0
|
|
151
|
+
? 'flex'
|
|
152
|
+
: 'none',
|
|
153
|
+
alignItems: 'center',
|
|
154
|
+
}, onClick: (e) => {
|
|
155
|
+
e.stopPropagation();
|
|
156
|
+
if (!disabled) {
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
setValue('');
|
|
159
|
+
onClear && onClear('');
|
|
160
|
+
}, 50);
|
|
161
|
+
}
|
|
162
|
+
} }, clearIcon || React.createElement(MaskClose, { className: "nut-input-clear" }))));
|
|
163
|
+
});
|
|
164
|
+
Input.defaultProps = defaultProps;
|
|
165
|
+
Input.displayName = 'NutInput';
|
|
166
|
+
|
|
167
|
+
export { Input as I };
|
|
@@ -18,8 +18,8 @@ export { N as NavBar } from './navbar.taro-92bab9c4.js';
|
|
|
18
18
|
export { S as SideNavBar } from './sidenavbar.taro-f8ffb7dc.js';
|
|
19
19
|
export { S as SideNavBarItem } from './sidenavbaritem.taro-6cb0821e.js';
|
|
20
20
|
export { S as SubSideNavBar } from './subsidenavbar.taro-85c03291.js';
|
|
21
|
-
export { T as Tabbar } from './tabbar.taro-
|
|
22
|
-
export { T as TabbarItem } from './tabbaritem.taro-
|
|
21
|
+
export { T as Tabbar } from './tabbar.taro-48413fb8.js';
|
|
22
|
+
export { T as TabbarItem } from './tabbaritem.taro-5afa3562.js';
|
|
23
23
|
export { T as TabPane } from './tabpane.taro-406cc0d3.js';
|
|
24
24
|
export { T as Tabs } from './tabs.taro-d47ccfc5.js';
|
|
25
25
|
export { A as Address } from './address.taro-67e32c33.js';
|
|
@@ -30,7 +30,7 @@ export { C as Checkbox, a as CheckboxGroup } from './checkbox.taro-ae460d3a.js';
|
|
|
30
30
|
export { D as DatePicker } from './datepicker.taro-7d522ff8.js';
|
|
31
31
|
export { F as Form } from './form.taro-7413d868.js';
|
|
32
32
|
export { F as FormItem } from './formitem.taro-b550d29c.js';
|
|
33
|
-
export { I as Input } from './input.taro-
|
|
33
|
+
export { I as Input } from './input.taro-1aca4a45.js';
|
|
34
34
|
export { I as InputNumber } from './inputnumber.taro-1f893d42.js';
|
|
35
35
|
export { M as Menu } from './menu.taro-e5c68cb8.js';
|
|
36
36
|
export { M as MenuItem } from './menuitem.taro-37c18382.js';
|
|
@@ -64,7 +64,7 @@ export { A as AnimatingNumbers } from './animatingnumbers.taro-f6eaffef.js';
|
|
|
64
64
|
export { A as Audio } from './audio.taro-51eafc9d.js';
|
|
65
65
|
export { A as Avatar } from './avatar.taro-a840f345.js';
|
|
66
66
|
export { A as AvatarGroup } from './avatargroup-0eadb514.js';
|
|
67
|
-
export { C as CircleProgress } from './circleprogress.taro-
|
|
67
|
+
export { C as CircleProgress } from './circleprogress.taro-d4943109.js';
|
|
68
68
|
export { C as Collapse } from './collapse.taro-89bcadf2.js';
|
|
69
69
|
export { C as CollapseItem } from './collapseitem-0e228cec.js';
|
|
70
70
|
export { C as CountDown } from './countdown.taro-c14b5c1f.js';
|
|
@@ -102,9 +102,9 @@ import './use-client-rect-1f8ed1fe.js';
|
|
|
102
102
|
import './get-scroll-parent-b4a07e65.js';
|
|
103
103
|
import './can-use-dom-3eeb5af4.js';
|
|
104
104
|
import './offsetContext-c2a746fa.js';
|
|
105
|
+
import './use-props-value-ae7ee726.js';
|
|
105
106
|
import './bem-350c1702.js';
|
|
106
107
|
import '@bem-react/classname';
|
|
107
|
-
import './use-props-value-ae7ee726.js';
|
|
108
108
|
import './configprovider-9960f0fb.js';
|
|
109
109
|
import 'react-transition-group';
|
|
110
110
|
import './use-touch-db24bb5c.js';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
4
|
+
import { u as usePropsValue } from './use-props-value-ae7ee726.js';
|
|
5
|
+
import { T as TabbarItem } from './tabbaritem.taro-5afa3562.js';
|
|
6
|
+
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
...ComponentDefaults,
|
|
9
|
+
defaultValue: 0,
|
|
10
|
+
fixed: false,
|
|
11
|
+
inactiveColor: '',
|
|
12
|
+
activeColor: '',
|
|
13
|
+
safeArea: false,
|
|
14
|
+
onSwitch: (value) => { },
|
|
15
|
+
};
|
|
16
|
+
const Tabbar = (props) => {
|
|
17
|
+
const { children, defaultValue, value, fixed, activeColor, inactiveColor, safeArea, className, style, onSwitch, } = {
|
|
18
|
+
...defaultProps,
|
|
19
|
+
...props,
|
|
20
|
+
};
|
|
21
|
+
const classPrefix = 'nut-tabbar';
|
|
22
|
+
const [selectIndex, setSelectIndex] = usePropsValue({
|
|
23
|
+
value,
|
|
24
|
+
defaultValue,
|
|
25
|
+
finalValue: 0,
|
|
26
|
+
onChange: onSwitch,
|
|
27
|
+
});
|
|
28
|
+
return (React.createElement("div", { className: classNames(classPrefix, className, {
|
|
29
|
+
[`${classPrefix}__fixed`]: fixed,
|
|
30
|
+
}), style: style },
|
|
31
|
+
React.createElement("div", { className: `${classPrefix}__wrap` }, React.Children.map(children, (child, idx) => {
|
|
32
|
+
if (!React.isValidElement(child)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const childProps = {
|
|
36
|
+
...child.props,
|
|
37
|
+
active: idx === selectIndex,
|
|
38
|
+
index: idx,
|
|
39
|
+
inactiveColor,
|
|
40
|
+
activeColor,
|
|
41
|
+
handleClick: setSelectIndex,
|
|
42
|
+
};
|
|
43
|
+
return React.cloneElement(child, childProps);
|
|
44
|
+
})),
|
|
45
|
+
(fixed || safeArea) && React.createElement("div", { className: `${classPrefix}__safe-area` })));
|
|
46
|
+
};
|
|
47
|
+
Tabbar.defaultProps = defaultProps;
|
|
48
|
+
Tabbar.displayName = 'NutTabbar';
|
|
49
|
+
Tabbar.Item = TabbarItem;
|
|
50
|
+
|
|
51
|
+
export { Tabbar as T };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
4
|
+
import { B as Badge } from './badge.taro-e2169fbe.js';
|
|
5
|
+
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
...ComponentDefaults,
|
|
8
|
+
title: '',
|
|
9
|
+
icon: null,
|
|
10
|
+
active: false,
|
|
11
|
+
index: 0,
|
|
12
|
+
handleClick: (idx) => { },
|
|
13
|
+
};
|
|
14
|
+
const TabbarItem = (props) => {
|
|
15
|
+
const { className, style, title, icon, active, activeColor, inactiveColor, index, handleClick, ...rest } = {
|
|
16
|
+
...defaultProps,
|
|
17
|
+
...props,
|
|
18
|
+
};
|
|
19
|
+
const classPrefix = 'nut-tabbar-item';
|
|
20
|
+
const tabbarItemClass = classNames(className, classPrefix, {
|
|
21
|
+
[`${classPrefix}-active`]: active,
|
|
22
|
+
});
|
|
23
|
+
const boxPrefix = `${classPrefix}__icon-box`;
|
|
24
|
+
const titleClass = classNames(boxPrefix, `${boxPrefix}-nav`, {
|
|
25
|
+
[`${boxPrefix}-large`]: !icon,
|
|
26
|
+
});
|
|
27
|
+
return (React.createElement("div", { className: tabbarItemClass, style: {
|
|
28
|
+
color: active ? activeColor : inactiveColor,
|
|
29
|
+
...style,
|
|
30
|
+
}, onClick: () => handleClick(index) }, icon ? (React.createElement(React.Fragment, null,
|
|
31
|
+
React.createElement(Badge, { ...rest },
|
|
32
|
+
React.createElement("div", { className: boxPrefix }, icon)),
|
|
33
|
+
React.createElement("div", { className: titleClass }, title))) : (React.createElement(Badge, { ...rest },
|
|
34
|
+
React.createElement("div", { className: titleClass }, title)))));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { TabbarItem as T };
|
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