@nutui/nutui-react-taro 2.0.0-alpha.3 → 2.0.0-alpha.5
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 +24 -0
- package/dist/esm/Address.js +3 -5
- package/dist/esm/Audio.js +3 -4
- package/dist/esm/Avatar.js +6 -5
- package/dist/esm/AvatarGroup.js +3 -7
- package/dist/esm/Calendar.js +3 -4
- package/dist/esm/CalendarItem.js +2 -3
- package/dist/esm/CellGroup.js +1 -1
- package/dist/esm/Checkbox.js +3 -3
- package/dist/esm/CheckboxGroup.js +3 -3
- package/dist/esm/CircleProgress.js +2 -3
- package/dist/esm/ConfigProvider.js +2 -3
- package/dist/esm/CountDown.js +2 -3
- package/dist/esm/DatePicker.js +3 -4
- package/dist/esm/Dialog.js +2 -3
- package/dist/esm/Elevator.js +1 -1
- package/dist/esm/Ellipsis.js +3 -4
- package/dist/esm/Empty.js +3 -5
- package/dist/esm/FixedNav.js +2 -3
- package/dist/esm/Form.js +2 -2
- package/dist/esm/Grid.js +3 -4
- package/dist/esm/GridItem.js +2 -3
- package/dist/esm/Image.js +2 -3
- package/dist/esm/Infiniteloading.js +2 -3
- package/dist/esm/Input.js +5 -3
- package/dist/esm/NumberKeyboard.js +2 -3
- package/dist/esm/Pagination.js +2 -3
- package/dist/esm/Picker.js +2 -3
- package/dist/esm/PullToRefresh.js +2 -3
- package/dist/esm/Range.js +2 -3
- package/dist/esm/SearchBar.js +2 -3
- package/dist/esm/ShortPassword.js +2 -3
- package/dist/esm/Signature.js +2 -3
- package/dist/esm/Skeleton.js +8 -5
- package/dist/esm/Swipe.js +1 -1
- package/dist/esm/Tabbar/style/index.js +1 -1
- package/dist/esm/Tabbar.js +6 -3
- package/dist/esm/TabbarItem.js +3 -4
- package/dist/esm/Table.js +2 -3
- package/dist/esm/TextArea.js +2 -3
- package/dist/esm/TimeDetail.js +2 -3
- package/dist/esm/TimePannel.js +2 -3
- package/dist/esm/TimeSelect.js +4 -5
- package/dist/esm/Uploader.js +2 -3
- package/dist/esm/VirtualList.js +2 -3
- package/dist/esm/WaterMark.js +2 -3
- package/dist/esm/{address.taro-67e32c33.js → address.taro-cab0ea22.js} +18 -4
- package/dist/esm/{audio.taro-51eafc9d.js → audio.taro-ff280f5e.js} +2 -2
- package/dist/esm/{avatar.taro-a840f345.js → avatar.taro-6e8f1f5c.js} +31 -29
- package/dist/esm/{avatargroup-0eadb514.js → avatargroup-f4375806.js} +9 -12
- package/dist/esm/{calendar.taro-b3ebdc35.js → calendar.taro-2fc9b899.js} +2 -2
- package/dist/esm/{calendaritem.taro-ab1ec154.js → calendaritem.taro-2d4a8c34.js} +1 -1
- package/dist/esm/{cellgroup.taro-660faffc.js → cellgroup.taro-e05ea802.js} +3 -2
- package/dist/esm/checkbox.taro-9d02f86c.js +175 -0
- package/dist/esm/{circleprogress.taro-d8973ae9.js → circleprogress.taro-d4943109.js} +21 -27
- package/dist/esm/{zh-CN-b4f493ba.js → configprovider.taro-ce34d482.js} +44 -1
- package/dist/esm/{countdown.taro-c14b5c1f.js → countdown.taro-3118ba23.js} +1 -1
- package/dist/esm/{datepicker.taro-7d522ff8.js → datepicker.taro-2e3e955b.js} +2 -2
- package/dist/esm/{dialog.taro-f9ca73a2.js → dialog.taro-eab19eab.js} +1 -1
- package/dist/esm/{elevator.taro-360a831f.js → elevator.taro-1a4e3356.js} +16 -8
- package/dist/esm/{ellipsis.taro-79044d54.js → ellipsis.taro-e1ac99a1.js} +7 -4
- package/dist/esm/{empty.taro-f8585835.js → empty.taro-26363c66.js} +12 -18
- package/dist/esm/{fixednav.taro-cca9a6df.js → fixednav.taro-ddb21e87.js} +1 -1
- package/dist/esm/{form.taro-7413d868.js → form.taro-423b0f0a.js} +1 -1
- package/dist/esm/{grid.taro-10eb7716.js → grid.taro-883a9c35.js} +1 -1
- package/dist/esm/{griditem.taro-fb15eeec.js → griditem.taro-16c7055b.js} +1 -1
- package/dist/esm/{image.taro-b897a058.js → image.taro-3025e659.js} +1 -1
- package/dist/esm/{infiniteloading.taro-cce53c60.js → infiniteloading.taro-721bca1f.js} +1 -1
- package/dist/esm/input.taro-06c1e4d5.js +167 -0
- package/dist/esm/{numberkeyboard.taro-10ab54d6.js → numberkeyboard.taro-d9b1721b.js} +1 -1
- package/dist/esm/nutui-react.es.js +45 -47
- package/dist/esm/{pagination.taro-df441058.js → pagination.taro-94f9be5e.js} +1 -1
- package/dist/esm/{picker.taro-9f1bb6a4.js → picker.taro-e16b4312.js} +1 -1
- package/dist/esm/{pulltorefresh.taro-37dadbc5.js → pulltorefresh.taro-016d0079.js} +1 -1
- package/dist/esm/{range.taro-432d20d7.js → range.taro-8953e8c3.js} +1 -1
- package/dist/esm/{searchbar.taro-4aa300df.js → searchbar.taro-4467040f.js} +1 -1
- package/dist/esm/{shortpassword.taro-99645f99.js → shortpassword.taro-433b86a4.js} +1 -1
- package/dist/esm/{signature.taro-e5ede25a.js → signature.taro-a4d9b5c9.js} +1 -1
- package/dist/esm/{skeleton.taro-fabd423a.js → skeleton.taro-8ec11af9.js} +2 -2
- package/dist/esm/{swipe.taro-b18a73ff.js → swipe.taro-0b8cc872.js} +3 -5
- package/dist/esm/tabbar.taro-48413fb8.js +51 -0
- package/dist/esm/tabbaritem.taro-5afa3562.js +37 -0
- package/dist/esm/{table.taro-eca757f3.js → table.taro-327b4248.js} +1 -1
- package/dist/esm/{textarea.taro-e256e741.js → textarea.taro-add72cf3.js} +1 -1
- package/dist/esm/{timedetail.taro-cae362b9.js → timedetail.taro-82a2900b.js} +1 -1
- package/dist/esm/{timepannel.taro-d6f4cf80.js → timepannel.taro-0573bb65.js} +1 -1
- package/dist/esm/{timeselect.taro-804199f9.js → timeselect.taro-29124a34.js} +3 -3
- package/dist/esm/{uploader.taro-716f9a50.js → uploader.taro-c70d00de.js} +1 -1
- package/dist/esm/{virtuallist.taro-0bd611cb.js → virtuallist.taro-ba8e1f21.js} +1 -1
- package/dist/esm/{watermark.taro-8966896a.js → watermark.taro-168cdac5.js} +1 -1
- 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 +975 -1094
- package/dist/nutui.react.umd.js +973 -1092
- package/dist/packages/badge/badge.scss +0 -1
- package/dist/packages/cellgroup/cellgroup.scss +20 -16
- package/dist/packages/checkbox/checkbox.scss +8 -11
- package/dist/packages/circleprogress/circleprogress.scss +0 -9
- package/dist/packages/empty/empty.scss +0 -9
- package/dist/packages/input/input.scss +13 -180
- package/dist/packages/tabbar/tabbar.scss +16 -22
- package/dist/packages/tabbaritem/tabbaritem.scss +9 -70
- package/dist/style.css +1 -1
- package/dist/style.mjs +1 -1
- package/dist/styles/themes/default.scss +0 -1
- package/dist/styles/variables-jmapp.scss +12 -16
- package/dist/styles/variables.scss +12 -16
- package/dist/types/index.d.ts +86 -129
- package/package.json +1 -1
- package/dist/esm/Icon.js +0 -64
- package/dist/esm/checkbox.taro-ae460d3a.js +0 -168
- package/dist/esm/configprovider-9960f0fb.js +0 -19
- package/dist/esm/configprovider.taro-43a3c646.js +0 -45
- 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/dist/packages/icon/icon.scss +0 -0
- /package/dist/esm/{AvatarContext-c96afdcc.js → context-c96afdcc.js} +0 -0
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useImperativeHandle, useState, useEffect, useCallback, useContext } from 'react';
|
|
2
|
-
import { CheckNormal, CheckDisabled, Checked } from '@nutui/icons-react-taro';
|
|
3
|
-
import { c as cn } from './bem-350c1702.js';
|
|
4
|
-
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
5
|
-
|
|
6
|
-
const CheckboxGroupContext = createContext(null);
|
|
7
|
-
|
|
8
|
-
const defaultProps$1 = {
|
|
9
|
-
disabled: false,
|
|
10
|
-
checkedValue: [],
|
|
11
|
-
max: undefined,
|
|
12
|
-
textPosition: 'right',
|
|
13
|
-
direction: 'vertical',
|
|
14
|
-
onChange: (value) => { },
|
|
15
|
-
options: [],
|
|
16
|
-
};
|
|
17
|
-
const CheckboxGroup = React.forwardRef((props, ref) => {
|
|
18
|
-
const { children } = { ...defaultProps$1, ...props };
|
|
19
|
-
const b = cn('checkboxgroup');
|
|
20
|
-
const { className, disabled, onChange, checkedValue, max, textPosition, direction, options, ...rest } = props;
|
|
21
|
-
useImperativeHandle(ref, () => ({
|
|
22
|
-
toggleAll(state) {
|
|
23
|
-
if (state === false) {
|
|
24
|
-
setInnerValue([]);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
const childrenLabel = [];
|
|
28
|
-
React.Children.map(children, (child) => {
|
|
29
|
-
const childProps = child.props;
|
|
30
|
-
childrenLabel.push(childProps.label || child.children);
|
|
31
|
-
});
|
|
32
|
-
setInnerValue(childrenLabel);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
toggleReverse() {
|
|
36
|
-
const childrenLabel = [];
|
|
37
|
-
React.Children.map(children, (child) => {
|
|
38
|
-
const childProps = child.props;
|
|
39
|
-
childrenLabel.push(childProps.label || child.children);
|
|
40
|
-
});
|
|
41
|
-
const reverse = childrenLabel.filter((c) => innerValue?.findIndex((v) => v === c) === -1);
|
|
42
|
-
setInnerValue(reverse);
|
|
43
|
-
},
|
|
44
|
-
}));
|
|
45
|
-
const [innerValue, setInnerValue] = useState(checkedValue || []);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
setInnerValue(checkedValue || []);
|
|
48
|
-
}, [checkedValue]);
|
|
49
|
-
const renderOptions = useCallback(() => {
|
|
50
|
-
return options?.map(({ label, value, disabled, onChange, ...rest }) => {
|
|
51
|
-
return (React.createElement(Checkbox, { key: value?.toString(), children: label, label: value, ...rest }));
|
|
52
|
-
});
|
|
53
|
-
}, [options, max]);
|
|
54
|
-
return (React.createElement(CheckboxGroupContext.Provider, { value: {
|
|
55
|
-
textPosition: textPosition || 'left',
|
|
56
|
-
disabled,
|
|
57
|
-
max,
|
|
58
|
-
checkedValue: innerValue || [],
|
|
59
|
-
check: (value) => {
|
|
60
|
-
const combined = [...innerValue, value];
|
|
61
|
-
setInnerValue(combined);
|
|
62
|
-
onChange && onChange(combined);
|
|
63
|
-
},
|
|
64
|
-
uncheck: (value) => {
|
|
65
|
-
const reduced = innerValue.filter((item) => item !== value);
|
|
66
|
-
setInnerValue(reduced);
|
|
67
|
-
onChange && onChange(reduced);
|
|
68
|
-
},
|
|
69
|
-
} },
|
|
70
|
-
React.createElement("div", { className: `${b()} nut-checkboxgroup--${props.direction} ${className || ''}`, ...rest }, options?.length ? renderOptions() : children)));
|
|
71
|
-
});
|
|
72
|
-
CheckboxGroup.defaultProps = defaultProps$1;
|
|
73
|
-
CheckboxGroup.displayName = 'NutCheckboxGroup';
|
|
74
|
-
|
|
75
|
-
const defaultProps = {
|
|
76
|
-
...ComponentDefaults,
|
|
77
|
-
checked: false,
|
|
78
|
-
disabled: false,
|
|
79
|
-
textPosition: 'right',
|
|
80
|
-
iconSize: 18,
|
|
81
|
-
icon: 'check-normal',
|
|
82
|
-
checkedIcon: 'checked',
|
|
83
|
-
iconClassPrefix: 'nut-icon',
|
|
84
|
-
iconFontClassName: 'nutui-iconfont',
|
|
85
|
-
indeterminateIcon: 'check-disabled',
|
|
86
|
-
onChange: (state, label) => { },
|
|
87
|
-
};
|
|
88
|
-
const Checkbox = (props) => {
|
|
89
|
-
const { children } = {
|
|
90
|
-
...defaultProps,
|
|
91
|
-
...props,
|
|
92
|
-
};
|
|
93
|
-
const b = cn('checkbox');
|
|
94
|
-
const { icon, iconSize, label, className, checkedIcon, checked, disabled, onChange, indeterminate, iconClassPrefix, iconFontClassName, indeterminateIcon, ...others } = props;
|
|
95
|
-
// eslint-disable-next-line prefer-const
|
|
96
|
-
let { textPosition, ...rest } = others;
|
|
97
|
-
const ctx = useContext(CheckboxGroupContext);
|
|
98
|
-
let [innerChecked, setInnerChecked] = useState(checked);
|
|
99
|
-
// eslint-disable-next-line prefer-const
|
|
100
|
-
let [innerDisabled, setDisabled] = useState(disabled);
|
|
101
|
-
const [_indeterminate, setIndeterminate] = useState(indeterminate);
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
!ctx && setInnerChecked(checked);
|
|
104
|
-
setDisabled(disabled);
|
|
105
|
-
setIndeterminate(indeterminate);
|
|
106
|
-
}, [disabled, checked, indeterminate]);
|
|
107
|
-
if (ctx) {
|
|
108
|
-
if (ctx.textPosition !== undefined) {
|
|
109
|
-
textPosition = ctx.textPosition;
|
|
110
|
-
}
|
|
111
|
-
innerDisabled = ctx.disabled;
|
|
112
|
-
innerChecked = ctx.checkedValue.includes(label);
|
|
113
|
-
setInnerChecked = (checked) => {
|
|
114
|
-
if (ctx.disabled)
|
|
115
|
-
return;
|
|
116
|
-
if (checked)
|
|
117
|
-
ctx.check(label);
|
|
118
|
-
if (!checked)
|
|
119
|
-
ctx.uncheck(label);
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const renderIcon = () => {
|
|
123
|
-
if (!innerChecked) {
|
|
124
|
-
return React.isValidElement(icon) ? (icon) : (React.createElement(CheckNormal, { size: iconSize, className: color() }));
|
|
125
|
-
}
|
|
126
|
-
if (_indeterminate) {
|
|
127
|
-
return React.isValidElement(indeterminateIcon) ? (indeterminateIcon) : (React.createElement(CheckDisabled, { size: iconSize, className: color() }));
|
|
128
|
-
}
|
|
129
|
-
return React.isValidElement(checkedIcon) ? (checkedIcon) : (React.createElement(Checked, { size: iconSize, className: color() }));
|
|
130
|
-
};
|
|
131
|
-
const color = () => {
|
|
132
|
-
if (innerDisabled) {
|
|
133
|
-
return 'nut-checkbox__icon--disable';
|
|
134
|
-
}
|
|
135
|
-
if (innerChecked) {
|
|
136
|
-
if (_indeterminate) {
|
|
137
|
-
return 'nut-checkbox__icon--indeterminate';
|
|
138
|
-
}
|
|
139
|
-
return 'nut-checkbox__icon';
|
|
140
|
-
}
|
|
141
|
-
return 'nut-checkbox__icon--unchecked';
|
|
142
|
-
};
|
|
143
|
-
const renderLabel = () => {
|
|
144
|
-
return (React.createElement("span", { className: `${b('label', { disabled: innerDisabled })} ` }, children || label));
|
|
145
|
-
};
|
|
146
|
-
const handleClick = () => {
|
|
147
|
-
// 禁用的时候直接返回
|
|
148
|
-
if (disabled)
|
|
149
|
-
return;
|
|
150
|
-
// 先转换状态
|
|
151
|
-
const latestChecked = !innerChecked;
|
|
152
|
-
// 判断是不是有 context 和 max,有的话需要判断是不是超过最大限制
|
|
153
|
-
if (ctx && ctx.max !== undefined) {
|
|
154
|
-
if (latestChecked && ctx.checkedValue.length >= ctx.max)
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
onChange && onChange(latestChecked, label || children);
|
|
158
|
-
setInnerChecked(latestChecked);
|
|
159
|
-
};
|
|
160
|
-
return (React.createElement("div", { className: `${b({ reverse: textPosition === 'left' })} ${className || ''}`, ...rest, onClick: handleClick },
|
|
161
|
-
renderIcon(),
|
|
162
|
-
renderLabel()));
|
|
163
|
-
};
|
|
164
|
-
Checkbox.defaultProps = defaultProps;
|
|
165
|
-
Checkbox.displayName = 'NutCheckBox';
|
|
166
|
-
Checkbox.Group = CheckboxGroup;
|
|
167
|
-
|
|
168
|
-
export { Checkbox as C, CheckboxGroup as a };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
import 'lodash.kebabcase';
|
|
3
|
-
import { z as zhCN } from './zh-CN-b4f493ba.js';
|
|
4
|
-
|
|
5
|
-
const defaultConfigRef = {
|
|
6
|
-
current: {
|
|
7
|
-
locale: zhCN,
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
const getDefaultConfig = () => {
|
|
11
|
-
return defaultConfigRef.current;
|
|
12
|
-
};
|
|
13
|
-
// 创建一个 Context 对象
|
|
14
|
-
const ConfigContext = createContext(null);
|
|
15
|
-
const useConfig = () => {
|
|
16
|
-
return useContext(ConfigContext) ?? getDefaultConfig();
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { useConfig as u };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useMemo } from 'react';
|
|
2
|
-
import kebabCase from 'lodash.kebabcase';
|
|
3
|
-
import { z as zhCN } from './zh-CN-b4f493ba.js';
|
|
4
|
-
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
locale: zhCN,
|
|
7
|
-
};
|
|
8
|
-
const defaultConfigRef = {
|
|
9
|
-
current: {
|
|
10
|
-
locale: zhCN,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
const setDefaultConfig = (config) => {
|
|
14
|
-
defaultConfigRef.current = config;
|
|
15
|
-
};
|
|
16
|
-
const getDefaultConfig = () => {
|
|
17
|
-
return defaultConfigRef.current;
|
|
18
|
-
};
|
|
19
|
-
// 创建一个 Context 对象
|
|
20
|
-
const ConfigContext = createContext(null);
|
|
21
|
-
const useConfig = () => {
|
|
22
|
-
return useContext(ConfigContext) ?? getDefaultConfig();
|
|
23
|
-
};
|
|
24
|
-
function convertThemeVarsToCSSVars(themeVars) {
|
|
25
|
-
const cssVars = {};
|
|
26
|
-
Object.keys(themeVars).forEach((key) => {
|
|
27
|
-
cssVars[`--${kebabCase(key)}`] = themeVars[key];
|
|
28
|
-
});
|
|
29
|
-
return cssVars;
|
|
30
|
-
}
|
|
31
|
-
const ConfigProvider = (props) => {
|
|
32
|
-
const { children, ...config } = { ...defaultProps, ...props };
|
|
33
|
-
const parentConfig = useConfig();
|
|
34
|
-
const theme = config.theme || {};
|
|
35
|
-
const style = useMemo(() => convertThemeVarsToCSSVars(theme), [theme]);
|
|
36
|
-
return (React.createElement(ConfigContext.Provider, { value: {
|
|
37
|
-
...parentConfig,
|
|
38
|
-
...config,
|
|
39
|
-
} },
|
|
40
|
-
React.createElement("div", { style: style }, children)));
|
|
41
|
-
};
|
|
42
|
-
ConfigProvider.defaultProps = defaultProps;
|
|
43
|
-
ConfigProvider.displayName = 'NutConfigProvider';
|
|
44
|
-
|
|
45
|
-
export { ConfigProvider as C, getDefaultConfig as g, setDefaultConfig as s, useConfig as u };
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useRef, useEffect, useImperativeHandle, useCallback } from 'react';
|
|
2
|
-
import { MaskClose } from '@nutui/icons-react-taro';
|
|
3
|
-
import { u as useConfig } from './configprovider.taro-43a3c646.js';
|
|
4
|
-
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
5
|
-
|
|
6
|
-
function trimExtraChar(value, char, regExp) {
|
|
7
|
-
const index = value.indexOf(char);
|
|
8
|
-
if (index === -1) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
if (char === '-' && index !== 0) {
|
|
12
|
-
return value.slice(0, index);
|
|
13
|
-
}
|
|
14
|
-
return value.slice(0, index + 1) + value.slice(index).replace(regExp, '');
|
|
15
|
-
}
|
|
16
|
-
function formatNumber(value, allowDot = true, allowMinus = true) {
|
|
17
|
-
if (allowDot) {
|
|
18
|
-
value = trimExtraChar(value, '.', /\./g);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
value = value.split('.')[0];
|
|
22
|
-
}
|
|
23
|
-
if (allowMinus) {
|
|
24
|
-
value = trimExtraChar(value, '-', /-/g);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
value = value.replace(/-/, '');
|
|
28
|
-
}
|
|
29
|
-
const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
|
|
30
|
-
return value.replace(regExp, '');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const defaultProps = {
|
|
34
|
-
...ComponentDefaults,
|
|
35
|
-
type: 'text',
|
|
36
|
-
name: '',
|
|
37
|
-
defaultValue: '',
|
|
38
|
-
placeholder: '',
|
|
39
|
-
label: '',
|
|
40
|
-
labelClass: '',
|
|
41
|
-
labelWidth: '80',
|
|
42
|
-
labelAlign: 'left',
|
|
43
|
-
colon: false,
|
|
44
|
-
inputAlign: 'left',
|
|
45
|
-
center: false,
|
|
46
|
-
required: false,
|
|
47
|
-
disabled: false,
|
|
48
|
-
readonly: false,
|
|
49
|
-
error: false,
|
|
50
|
-
maxlength: '9999',
|
|
51
|
-
leftIcon: null,
|
|
52
|
-
rightIcon: null,
|
|
53
|
-
clearable: false,
|
|
54
|
-
clearIcon: null,
|
|
55
|
-
clearSize: '14',
|
|
56
|
-
border: true,
|
|
57
|
-
formatTrigger: 'onChange',
|
|
58
|
-
rules: [],
|
|
59
|
-
rows: null,
|
|
60
|
-
errorMessage: '',
|
|
61
|
-
errorMessageAlign: '',
|
|
62
|
-
showWordLimit: false,
|
|
63
|
-
autofocus: false,
|
|
64
|
-
slotButton: null,
|
|
65
|
-
slotInput: null,
|
|
66
|
-
};
|
|
67
|
-
const Input = forwardRef((props, ref) => {
|
|
68
|
-
const { locale } = useConfig();
|
|
69
|
-
const { children, type, name, defaultValue, placeholder, label, labelClass, labelWidth, labelAlign, colon, inputAlign, center, required, disabled, readonly, error, maxlength, leftIcon, rightIcon, clearable, clearIcon, clearSize, border, formatTrigger, rules, errorMessage, errorMessageAlign, showWordLimit, autofocus, style, className, rows, slotButton, slotInput, onChange, onBlur, onFocus, onClear, formatter, keypress, onClickInput, onClickLeftIcon, onClickRightIcon, onClick, ...rest } = {
|
|
70
|
-
...defaultProps,
|
|
71
|
-
...props,
|
|
72
|
-
};
|
|
73
|
-
const inputPlaceholder = placeholder || locale.placeholder;
|
|
74
|
-
const [inputValue, SetInputValue] = useState('');
|
|
75
|
-
const [active, SetActive] = useState(false);
|
|
76
|
-
const [classes, setClasses] = useState('');
|
|
77
|
-
const getModelValue = () => String(inputValue ?? '');
|
|
78
|
-
const inputRef = useRef(null);
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
setClasses(inputClass);
|
|
81
|
-
SetInputValue(defaultValue);
|
|
82
|
-
}, [defaultValue]);
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (inputValue) {
|
|
85
|
-
updateValue(getModelValue());
|
|
86
|
-
resetValidation();
|
|
87
|
-
}
|
|
88
|
-
}, [inputValue]);
|
|
89
|
-
useImperativeHandle(ref, () => {
|
|
90
|
-
return inputRef.current;
|
|
91
|
-
});
|
|
92
|
-
const inputClass = useCallback(() => {
|
|
93
|
-
const prefixCls = 'nut-input';
|
|
94
|
-
return [
|
|
95
|
-
prefixCls,
|
|
96
|
-
`${center ? 'center' : ''}`,
|
|
97
|
-
`${disabled ? `${prefixCls}-disabled` : ''}`,
|
|
98
|
-
`${required ? `${prefixCls}-required` : ''}`,
|
|
99
|
-
`${error ? `${prefixCls}-error` : ''}`,
|
|
100
|
-
`${border ? `${prefixCls}-border` : ''}`,
|
|
101
|
-
`${slotButton || rightIcon ? `${prefixCls}-right-mark` : ''}`,
|
|
102
|
-
]
|
|
103
|
-
.filter(Boolean)
|
|
104
|
-
.join(' ');
|
|
105
|
-
}, [disabled, required, error, border, slotButton, rightIcon, center]);
|
|
106
|
-
// 样式状态重置
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
setClasses(inputClass);
|
|
109
|
-
}, [disabled, required, error, border, slotButton, rightIcon, center]);
|
|
110
|
-
const updateValue = (value, trigger = 'onChange') => {
|
|
111
|
-
let val = value;
|
|
112
|
-
if (type === 'digit' || type === 'tel') {
|
|
113
|
-
val = formatNumber(val, false, false);
|
|
114
|
-
}
|
|
115
|
-
if (type === 'number') {
|
|
116
|
-
val = formatNumber(val, true, true);
|
|
117
|
-
}
|
|
118
|
-
if (type === 'tel' && !formatter) {
|
|
119
|
-
const regTel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
|
|
120
|
-
const regNumber = /[^-0-9]/g;
|
|
121
|
-
val =
|
|
122
|
-
!regTel.test(val) && val.length > 11
|
|
123
|
-
? val.substring(0, 11)
|
|
124
|
-
: val.replace(regNumber, '');
|
|
125
|
-
}
|
|
126
|
-
if (formatter && trigger === formatTrigger) {
|
|
127
|
-
val = formatter(val);
|
|
128
|
-
}
|
|
129
|
-
if (inputRef?.current?.value !== val) {
|
|
130
|
-
inputRef.current.value = val;
|
|
131
|
-
}
|
|
132
|
-
SetInputValue(val);
|
|
133
|
-
};
|
|
134
|
-
const handleFocus = (event) => {
|
|
135
|
-
const val = event.target.value;
|
|
136
|
-
SetActive(true);
|
|
137
|
-
onFocus && onFocus(val, event);
|
|
138
|
-
};
|
|
139
|
-
const handleInput = (event) => {
|
|
140
|
-
let val = event.target.value;
|
|
141
|
-
if (maxlength && val.length > Number(maxlength)) {
|
|
142
|
-
val = val.slice(0, Number(maxlength));
|
|
143
|
-
}
|
|
144
|
-
updateValue(val, 'onChange');
|
|
145
|
-
onChange && onChange(val, event);
|
|
146
|
-
};
|
|
147
|
-
const handleBlur = (event) => {
|
|
148
|
-
setTimeout(() => {
|
|
149
|
-
SetActive(false);
|
|
150
|
-
}, 200);
|
|
151
|
-
let val = event.target.value;
|
|
152
|
-
if (maxlength && val.length > Number(maxlength)) {
|
|
153
|
-
val = val.slice(0, Number(maxlength));
|
|
154
|
-
}
|
|
155
|
-
updateValue(val, 'onBlur');
|
|
156
|
-
onBlur && onBlur(val, event);
|
|
157
|
-
};
|
|
158
|
-
const handleClickInput = (event) => {
|
|
159
|
-
onClickInput && onClickInput(event);
|
|
160
|
-
};
|
|
161
|
-
const handleClickLeftIcon = (event) => {
|
|
162
|
-
onClickLeftIcon && onClickLeftIcon(event);
|
|
163
|
-
};
|
|
164
|
-
const handleClickRightIcon = (event) => {
|
|
165
|
-
onClickRightIcon && onClickRightIcon(event);
|
|
166
|
-
};
|
|
167
|
-
const resetValidation = () => {
|
|
168
|
-
};
|
|
169
|
-
const inputType = (type) => {
|
|
170
|
-
if (type === 'number') {
|
|
171
|
-
return 'text';
|
|
172
|
-
}
|
|
173
|
-
if (type === 'digit') {
|
|
174
|
-
return 'tel';
|
|
175
|
-
}
|
|
176
|
-
return type;
|
|
177
|
-
};
|
|
178
|
-
const handleClear = (event) => {
|
|
179
|
-
updateValue('');
|
|
180
|
-
onClear && onClear('', event);
|
|
181
|
-
};
|
|
182
|
-
return (React.createElement("div", { className: `${classes} ${className || ''}`, style: style, onClick: (e) => {
|
|
183
|
-
onClick && onClick(e);
|
|
184
|
-
} }, slotInput ? (React.createElement(React.Fragment, null,
|
|
185
|
-
label ? (React.createElement("div", { className: `nut-input-label ${labelClass}`, style: { width: `${labelWidth}px`, textAlign: labelAlign } },
|
|
186
|
-
React.createElement("div", { className: "label-string" },
|
|
187
|
-
label,
|
|
188
|
-
colon ? ':' : ''))) : null,
|
|
189
|
-
React.createElement("div", { className: "nut-input-value" },
|
|
190
|
-
React.createElement("div", { className: "nut-input-inner", onClick: (e) => {
|
|
191
|
-
handleClickInput(e);
|
|
192
|
-
} }, slotInput)))) : (React.createElement(React.Fragment, null,
|
|
193
|
-
React.isValidElement(leftIcon) ? (React.createElement("div", { className: "nut-input-left-icon", onClick: (e) => {
|
|
194
|
-
handleClickLeftIcon(e);
|
|
195
|
-
} }, leftIcon)) : null,
|
|
196
|
-
label ? (React.createElement("div", { className: `nut-input-label ${labelClass}`, style: { width: `${labelWidth}px`, textAlign: labelAlign } },
|
|
197
|
-
React.createElement("div", { className: "label-string" },
|
|
198
|
-
label,
|
|
199
|
-
colon ? ':' : ''))) : null,
|
|
200
|
-
React.createElement("div", { className: "nut-input-value" },
|
|
201
|
-
React.createElement("div", { className: "nut-input-main-con" },
|
|
202
|
-
React.createElement("div", { className: "nut-input-inner", onClick: (e) => {
|
|
203
|
-
handleClickInput(e);
|
|
204
|
-
} },
|
|
205
|
-
type === 'textarea' ? (React.createElement("textarea", { name: name, className: "input-text", ref: inputRef, style: {
|
|
206
|
-
textAlign: inputAlign,
|
|
207
|
-
height: `${Number(rows) * 24}px`,
|
|
208
|
-
}, maxLength: maxlength, placeholder: inputPlaceholder, disabled: disabled, readOnly: readonly, value: inputValue, autoFocus: autofocus, onBlur: (e) => {
|
|
209
|
-
handleBlur(e);
|
|
210
|
-
}, onFocus: (e) => {
|
|
211
|
-
handleFocus(e);
|
|
212
|
-
}, onInput: (e) => {
|
|
213
|
-
handleInput(e);
|
|
214
|
-
} })) : (React.createElement("input", { ...rest, name: name, className: "input-text", ref: inputRef, style: { textAlign: inputAlign }, type: inputType(type), maxLength: maxlength, placeholder: inputPlaceholder, disabled: disabled, readOnly: readonly, value: inputValue, autoFocus: autofocus, onBlur: (e) => {
|
|
215
|
-
handleBlur(e);
|
|
216
|
-
}, onFocus: (e) => {
|
|
217
|
-
handleFocus(e);
|
|
218
|
-
}, onInput: (e) => {
|
|
219
|
-
handleInput(e);
|
|
220
|
-
} })),
|
|
221
|
-
clearable && !readonly && active && inputValue.length > 0 ? (React.createElement("span", { className: "nut-input-clear-wrap", onClick: (e) => handleClear(e) }, clearIcon || React.createElement(MaskClose, { className: "nut-input-clear" }))) : null),
|
|
222
|
-
React.isValidElement(rightIcon) ? (React.createElement("div", { className: "nut-input-right-icon", onClick: (e) => {
|
|
223
|
-
handleClickRightIcon(e);
|
|
224
|
-
} }, rightIcon)) : null,
|
|
225
|
-
slotButton ? (React.createElement("div", { className: "nut-input-button" }, slotButton)) : null,
|
|
226
|
-
showWordLimit && maxlength ? (React.createElement("div", { className: "nut-input-word-limit" },
|
|
227
|
-
React.createElement("span", { className: "nut-input-word-num" }, inputValue ? inputValue.length : 0),
|
|
228
|
-
"/",
|
|
229
|
-
maxlength)) : null),
|
|
230
|
-
errorMessage ? (React.createElement("div", { className: "nut-input-error-message", style: {
|
|
231
|
-
textAlign: errorMessageAlign,
|
|
232
|
-
} }, errorMessage)) : (React.createElement("div", null)))))));
|
|
233
|
-
});
|
|
234
|
-
Input.defaultProps = defaultProps;
|
|
235
|
-
Input.displayName = 'NutInput';
|
|
236
|
-
|
|
237
|
-
export { Input as I };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { c as cn } from './bem-350c1702.js';
|
|
3
|
-
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
visible: 0,
|
|
6
|
-
bottom: false,
|
|
7
|
-
size: 20,
|
|
8
|
-
unactiveColor: '',
|
|
9
|
-
activeColor: '',
|
|
10
|
-
safeAreaInsetBottom: false,
|
|
11
|
-
className: '',
|
|
12
|
-
style: {},
|
|
13
|
-
onSwitch: (child, activeVisible) => { },
|
|
14
|
-
};
|
|
15
|
-
const Tabbar = (props) => {
|
|
16
|
-
const { children, visible, activeVisible, bottom, size, activeColor, unactiveColor, safeAreaInsetBottom, className, style, onSwitch, } = {
|
|
17
|
-
...defaultProps,
|
|
18
|
-
...props,
|
|
19
|
-
};
|
|
20
|
-
const b = cn('tabbar');
|
|
21
|
-
const [selectIndex, setSelectIndex] = useState(activeVisible || visible);
|
|
22
|
-
const handleClick = (idx) => {
|
|
23
|
-
if (!('activeVisible' in props)) {
|
|
24
|
-
setSelectIndex(idx);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (activeVisible !== undefined) {
|
|
29
|
-
setSelectIndex(activeVisible);
|
|
30
|
-
}
|
|
31
|
-
}, [activeVisible]);
|
|
32
|
-
return (React.createElement("div", { className: [
|
|
33
|
-
`${b()}`,
|
|
34
|
-
bottom ? `${b('bottom')}` : '',
|
|
35
|
-
safeAreaInsetBottom ? `${b('bottom')} ${b('safebottom')}` : '',
|
|
36
|
-
className,
|
|
37
|
-
].join(' '), style: style }, React.Children.map(children, (child, idx) => {
|
|
38
|
-
if (!React.isValidElement(child)) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
const childProps = {
|
|
42
|
-
...child.props,
|
|
43
|
-
active: idx === selectIndex,
|
|
44
|
-
index: idx,
|
|
45
|
-
unactiveColor,
|
|
46
|
-
activeColor,
|
|
47
|
-
size,
|
|
48
|
-
handleClick: () => {
|
|
49
|
-
handleClick(idx);
|
|
50
|
-
onSwitch(child, idx);
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
return React.cloneElement(child, childProps);
|
|
54
|
-
})));
|
|
55
|
-
};
|
|
56
|
-
Tabbar.defaultProps = defaultProps;
|
|
57
|
-
Tabbar.displayName = 'NutTabbar';
|
|
58
|
-
|
|
59
|
-
export { Tabbar as T };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import Taro from '@tarojs/taro';
|
|
3
|
-
import { c as cn } from './bem-350c1702.js';
|
|
4
|
-
import { C as ComponentDefaults } from './typings-d8491423.js';
|
|
5
|
-
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
...ComponentDefaults,
|
|
8
|
-
dot: false,
|
|
9
|
-
className: '',
|
|
10
|
-
tabTitle: '',
|
|
11
|
-
icon: null,
|
|
12
|
-
href: '',
|
|
13
|
-
to: '',
|
|
14
|
-
num: '',
|
|
15
|
-
active: false,
|
|
16
|
-
activeColor: '',
|
|
17
|
-
unactiveColor: '',
|
|
18
|
-
index: 0,
|
|
19
|
-
handleClick: (idx) => { },
|
|
20
|
-
};
|
|
21
|
-
const TabbarItem = (props) => {
|
|
22
|
-
const { dot, className, style, tabTitle, icon, href, to, num, active, activeColor, unactiveColor, index, handleClick, } = {
|
|
23
|
-
...defaultProps,
|
|
24
|
-
...props,
|
|
25
|
-
};
|
|
26
|
-
const b = cn('tabbar-item');
|
|
27
|
-
const bIcon = cn('tabbar-item__icon-box');
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (active && href) {
|
|
30
|
-
window.location.href = href;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (active && to) {
|
|
34
|
-
Taro.navigateTo({
|
|
35
|
-
url: to,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}, [active, href, to]);
|
|
39
|
-
return (React.createElement("div", { className: `${b({ active })} ${className}`, style: {
|
|
40
|
-
...style,
|
|
41
|
-
color: active ? activeColor : unactiveColor,
|
|
42
|
-
}, onClick: () => {
|
|
43
|
-
handleClick(index);
|
|
44
|
-
} },
|
|
45
|
-
React.createElement("div", { className: `${bIcon()}` },
|
|
46
|
-
!dot ? (React.createElement(React.Fragment, null,
|
|
47
|
-
num && num <= 99 && (React.createElement("div", { className: `${bIcon('tips', [bIcon('num')])}` }, num)),
|
|
48
|
-
num && num >= 100 && (React.createElement("div", { className: `${bIcon('tips', [bIcon('nums')])}` }, "99+")))) : (React.createElement("div", { className: `${bIcon('tips', [bIcon('dot')])}` })),
|
|
49
|
-
icon || null),
|
|
50
|
-
tabTitle && (React.createElement("div", { className: bIcon({ 'nav-word': true }, [
|
|
51
|
-
bIcon({ 'big-word': !icon }),
|
|
52
|
-
]) }, tabTitle))));
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { TabbarItem as T };
|
|
File without changes
|
|
File without changes
|