@para-ui/core 4.0.0-rc.3 → 4.0.0-rc.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/AutoBox/index.js +72 -85
- package/AutoTips/index.js +72 -95
- package/Badge/index.js +18 -17
- package/Breadcrumbs/index.js +57 -73
- package/Button/index.js +89 -117
- package/ButtonGroup/index.js +30 -33
- package/Carousel/index.js +29 -33
- package/Cascader/index.js +7 -9
- package/Checkbox/index.js +28 -35
- package/CheckboxGroup/index.js +43 -58
- package/Collapse/index.js +52 -49
- package/CollapseBox/index.js +65 -70
- package/CollapseLayout/index.js +106 -101
- package/ColorPicker/index.js +3 -3
- package/ComboSelect/index.js +242 -330
- package/ComboSelect/utils.d.ts +0 -5
- package/Container/index.js +17 -21
- package/CopyText/index.js +50 -83
- package/DatePicker/index.js +22 -27
- package/Descriptions/index.js +50 -59
- package/Desktop/index.js +161 -180
- package/DragVerify/index.js +77 -113
- package/Drawer/index.js +82 -97
- package/Dropdown/index.js +3 -3
- package/DynamicMultiBox/index.js +219 -224
- package/DynamicMultiBox/interface.d.ts +7 -0
- package/Empty/index.js +26 -28
- package/Form/index.js +66 -74
- package/FormItem/index.js +14 -15
- package/FunctionModal/index.js +7 -14
- package/GlobalContext/index.js +17 -20
- package/Help/index.js +9 -12
- package/HelperText/index.js +11 -11
- package/InputLang/index.js +104 -124
- package/InputNumber/index.js +62 -81
- package/Label/index.js +19 -21
- package/Loading/index.js +11 -10
- package/Menu/index.js +302 -371
- package/Message/index.js +105 -114
- package/Modal/index.js +122 -148
- package/MultiBox/index.d.ts +5 -0
- package/MultiBox/index.js +111 -115
- package/Notification/index.js +105 -103
- package/OperateBtn/index.d.ts +3 -0
- package/OperateBtn/index.js +77 -107
- package/PageHeader/index.js +327 -406
- package/Pagination/index.js +107 -137
- package/ParauiProvider/index.js +20 -22
- package/PasswordRules/index.js +36 -40
- package/PopConfirm/index.js +62 -79
- package/Popover/index.js +12 -12
- package/Progress/index.js +72 -74
- package/Querying/index.js +52 -59
- package/README.md +2 -0
- package/Radio/index.js +27 -34
- package/RadioGroup/index.js +38 -52
- package/Search/index.js +35 -44
- package/Select/index.js +323 -364
- package/SelectInput/index.js +8 -13
- package/Selector/index.js +905 -796
- package/SelectorPicker/index.js +111 -133
- package/SingleBox/index.d.ts +5 -0
- package/SingleBox/index.js +92 -88
- package/Slider/index.js +46 -57
- package/Status/index.js +14 -13
- package/Stepper/index.js +25 -26
- package/Styles/theme.scss +9 -9
- package/Switch/index.js +32 -35
- package/Table/index.js +767 -963
- package/Tabs/index.js +102 -102
- package/Tag/index.js +115 -162
- package/TextEditor/index.js +81 -103
- package/TextField/index.js +142 -183
- package/TimePicker/index.js +27 -28
- package/Timeline/index.js +67 -58
- package/Title/index.js +32 -34
- package/ToggleButton/index.js +53 -52
- package/Tooltip/index.js +79 -82
- package/Transfer/index.js +160 -203
- package/Tree/index.js +7 -12
- package/Upload/index.js +527 -759
- package/Upload/interface.d.ts +5 -0
- package/_verture/{constant-0d9802f7.js → constant-5317fc89.js} +2 -2
- package/_verture/{index-f48d5ce6.js → index-0ced30f7.js} +1128 -1080
- package/_verture/{index-024bbc9b.js → index-775ad32d.js} +29 -25
- package/_verture/{index-05f7bf11.js → index-c568f272.js} +2 -2
- package/_verture/index-da9097d3.js +239 -0
- package/_verture/{index-56601c94.js → index-ef1235fb.js} +125 -134
- package/_verture/{index-de8f4428.js → index-f186b5e8.js} +315 -399
- package/_verture/intl-f2f27722.js +69 -0
- package/_verture/{modalContext-736ff215.js → modalContext-5df08980.js} +36 -64
- package/_verture/{slicedToArray-a8206399.js → slicedToArray-8223a2ef.js} +15 -2
- package/_verture/{useFormatMessage-703f8b20.js → useFormatMessage-eb13cf56.js} +5 -4
- package/_verture/{useGlobalProps-1b846a65.js → useGlobalProps-1e416658.js} +4 -3
- package/_verture/{usePopupContainer-87febeb9.js → usePopupContainer-635f66f4.js} +16 -15
- package/_verture/{util-7e1fb1e2.js → util-82646c4f.js} +5 -4
- package/_verture/{utils-06d86594.js → utils-46e99c9a.js} +34 -26
- package/index.js +21 -22
- package/locale/index.js +10 -10
- package/package.json +1 -1
- package/umd/AutoBox.js +9 -8
- package/umd/AutoTips.js +9 -8
- package/umd/Badge.js +1 -1
- package/umd/Breadcrumbs.js +9 -8
- package/umd/Button.js +9 -8
- package/umd/ButtonGroup.js +9 -8
- package/umd/Carousel.js +5 -5
- package/umd/Cascader.js +9 -8
- package/umd/Checkbox.js +9 -8
- package/umd/CheckboxGroup.js +9 -8
- package/umd/Collapse.js +8 -7
- package/umd/CollapseBox.js +1 -1
- package/umd/CollapseLayout.js +4 -4
- package/umd/ColorPicker.js +1 -1
- package/umd/ComboSelect.js +9 -8
- package/umd/Container.js +1 -1
- package/umd/CopyText.js +9 -8
- package/umd/DatePicker.js +9 -8
- package/umd/Descriptions.js +9 -8
- package/umd/Desktop.js +9 -8
- package/umd/DragVerify.js +4 -4
- package/umd/Drawer.js +9 -8
- package/umd/Dropdown.js +6 -5
- package/umd/DynamicMultiBox.js +11 -10
- package/umd/Empty.js +1 -1
- package/umd/Form.js +9 -8
- package/umd/FormItem.js +9 -8
- package/umd/FunctionModal.js +9 -8
- package/umd/GlobalContext.js +1 -1
- package/umd/Help.js +9 -8
- package/umd/HelperText.js +1 -1
- package/umd/InputLang.js +9 -8
- package/umd/InputNumber.js +9 -8
- package/umd/Label.js +9 -8
- package/umd/Loading.js +4 -4
- package/umd/Menu.js +4 -4
- package/umd/Message.js +4 -4
- package/umd/Modal.js +9 -8
- package/umd/MultiBox.js +9 -8
- package/umd/Notification.js +8 -7
- package/umd/OperateBtn.js +9 -8
- package/umd/PageHeader.js +9 -8
- package/umd/Pagination.js +9 -8
- package/umd/ParauiProvider.js +1 -1
- package/umd/PasswordRules.js +4 -4
- package/umd/PopConfirm.js +9 -8
- package/umd/Popover.js +9 -8
- package/umd/Progress.js +5 -5
- package/umd/Querying.js +1 -1
- package/umd/Radio.js +9 -8
- package/umd/RadioGroup.js +9 -8
- package/umd/Search.js +9 -8
- package/umd/Select.js +9 -8
- package/umd/SelectInput.js +9 -8
- package/umd/Selector.js +9 -8
- package/umd/SelectorPicker.js +9 -8
- package/umd/SingleBox.js +9 -8
- package/umd/Slider.js +6 -5
- package/umd/Status.js +4 -4
- package/umd/Stepper.js +9 -8
- package/umd/Switch.js +9 -8
- package/umd/Table.js +9 -8
- package/umd/Tabs.js +9 -8
- package/umd/Tag.js +9 -8
- package/umd/TextEditor.js +22 -21
- package/umd/TextField.js +9 -8
- package/umd/TimePicker.js +9 -8
- package/umd/Timeline.js +1 -1
- package/umd/Title.js +9 -8
- package/umd/ToggleButton.js +9 -8
- package/umd/Tooltip.js +9 -8
- package/umd/Transfer.js +10 -9
- package/umd/Tree.js +9 -8
- package/umd/Upload.js +10 -9
- package/umd/locale.js +1 -1
- package/_verture/index-232d890b.js +0 -327
- package/_verture/index-e9007d6a.js +0 -236
- package/_verture/intl-5c1ec055.js +0 -81
- package/_verture/toConsumableArray-8f4c9589.js +0 -19
- package/_verture/unsupportedIterableToArray-cb478f24.js +0 -16
package/Tag/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { _ as _defineProperty } from '../_verture/defineProperty-1d116156.js';
|
|
2
|
-
import { _ as _slicedToArray } from '../_verture/slicedToArray-a8206399.js';
|
|
3
1
|
import { _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
|
|
4
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
3
|
import { useState, useRef, useEffect } from 'react';
|
|
6
4
|
import CloseIcon from '@para-ui/icons/Close';
|
|
7
5
|
import EditIcon from '@para-ui/icons/EditOutline';
|
|
8
6
|
import clsx from 'clsx';
|
|
9
|
-
import {
|
|
10
|
-
import { _ as _typeof } from '../_verture/typeof-adeedc13.js';
|
|
11
|
-
import { $ as $prefixCls } from '../_verture/constant-0d9802f7.js';
|
|
7
|
+
import { $ as $prefixCls } from '../_verture/constant-5317fc89.js';
|
|
12
8
|
import AutoTips from '../AutoTips/index.js';
|
|
13
9
|
import { t as tinycolor } from '../_verture/tinycolor-ece3542d.js';
|
|
14
10
|
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
|
|
15
11
|
import Plus from '@para-ui/icons/Plus';
|
|
16
|
-
import '../_verture/unsupportedIterableToArray-cb478f24.js';
|
|
17
12
|
import '../Tooltip/index.js';
|
|
18
13
|
import 'rc-tooltip';
|
|
19
14
|
import 'rc-tooltip/lib/placements';
|
|
@@ -24,121 +19,97 @@ var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2022/1/12 上
|
|
|
24
19
|
styleInject(css_248z);
|
|
25
20
|
|
|
26
21
|
//tag group
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
size =
|
|
31
|
-
style
|
|
32
|
-
defaultInputValue
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
inputValue = _useState4[0],
|
|
46
|
-
setInputValue = _useState4[1]; //input value
|
|
47
|
-
var _useState5 = useState(false),
|
|
48
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
49
|
-
inputVisible = _useState6[0],
|
|
50
|
-
setInputVisible = _useState6[1]; //input visible
|
|
51
|
-
var inputRef = useRef(); //input ref
|
|
52
|
-
var _useState7 = useState(),
|
|
53
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
54
|
-
increasedInputWidth = _useState8[0],
|
|
55
|
-
setIncreasedInputWidth = _useState8[1]; //添加标签的最小宽
|
|
56
|
-
useEffect(function () {
|
|
22
|
+
const TagGroup = props => {
|
|
23
|
+
const {
|
|
24
|
+
className,
|
|
25
|
+
size = 'large',
|
|
26
|
+
style,
|
|
27
|
+
defaultInputValue,
|
|
28
|
+
increased = false,
|
|
29
|
+
increasedTag,
|
|
30
|
+
inputClassName,
|
|
31
|
+
inputWidth,
|
|
32
|
+
onChange
|
|
33
|
+
} = props;
|
|
34
|
+
const [inData, setInData] = useState([]); //数据源
|
|
35
|
+
const [inputValue, setInputValue] = useState(defaultInputValue !== null && defaultInputValue !== void 0 ? defaultInputValue : ''); //input value
|
|
36
|
+
const [inputVisible, setInputVisible] = useState(false); //input visible
|
|
37
|
+
const inputRef = useRef(); //input ref
|
|
38
|
+
const [increasedInputWidth, setIncreasedInputWidth] = useState(); //添加标签的最小宽
|
|
39
|
+
useEffect(() => {
|
|
57
40
|
if (props.data) {
|
|
58
|
-
|
|
41
|
+
let tArr = props.data;
|
|
59
42
|
//Item[]
|
|
60
|
-
|
|
61
|
-
return ['string', 'number'].includes(_typeof(v));
|
|
62
|
-
});
|
|
43
|
+
const unObjType = tArr.some(v => ['string', 'number'].includes(typeof v));
|
|
63
44
|
if (unObjType) {
|
|
64
|
-
tArr = tArr.map(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
});
|
|
45
|
+
tArr = tArr.map(_ => ({
|
|
46
|
+
value: _,
|
|
47
|
+
label: _
|
|
48
|
+
}));
|
|
70
49
|
}
|
|
71
|
-
setInData(
|
|
50
|
+
setInData([...tArr]);
|
|
72
51
|
}
|
|
73
52
|
}, [props.data]);
|
|
74
53
|
//tag value
|
|
75
|
-
|
|
76
|
-
return data.map(
|
|
77
|
-
return _.value;
|
|
78
|
-
});
|
|
54
|
+
const getTagGroupVal = data => {
|
|
55
|
+
return data.map(_ => _.value);
|
|
79
56
|
};
|
|
80
57
|
//show input
|
|
81
|
-
|
|
58
|
+
const showInput = () => {
|
|
82
59
|
setInputVisible(true);
|
|
83
|
-
setTimeout(
|
|
60
|
+
setTimeout(() => {
|
|
84
61
|
var _a;
|
|
85
62
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
86
63
|
});
|
|
87
64
|
};
|
|
88
|
-
|
|
65
|
+
const handleTagEdit = (value, idx) => {
|
|
89
66
|
inData[idx].value = value;
|
|
90
|
-
setInData(
|
|
67
|
+
setInData([...inData]);
|
|
91
68
|
onChange === null || onChange === void 0 ? void 0 : onChange(inData, getTagGroupVal(inData));
|
|
92
69
|
};
|
|
93
70
|
//input change
|
|
94
|
-
|
|
71
|
+
const handleInputChange = e => {
|
|
95
72
|
setInputValue(e.target.value);
|
|
96
73
|
};
|
|
97
74
|
//input confirm
|
|
98
|
-
|
|
99
|
-
|
|
75
|
+
const handleInputConfirm = () => {
|
|
76
|
+
const val = inputValue.trim();
|
|
100
77
|
if (val !== '') {
|
|
101
78
|
inData.push({
|
|
102
79
|
value: val,
|
|
103
80
|
label: val,
|
|
104
81
|
closable: true
|
|
105
82
|
});
|
|
106
|
-
setInData(
|
|
83
|
+
setInData([...inData]);
|
|
107
84
|
onChange === null || onChange === void 0 ? void 0 : onChange(inData, getTagGroupVal(inData));
|
|
108
85
|
}
|
|
109
86
|
setInputValue(defaultInputValue !== null && defaultInputValue !== void 0 ? defaultInputValue : '');
|
|
110
87
|
setInputVisible(false);
|
|
111
88
|
};
|
|
112
89
|
//input enter
|
|
113
|
-
|
|
90
|
+
const handleInputEnter = e => {
|
|
114
91
|
if (e.keyCode === 13 || e.which === 13) {
|
|
115
92
|
handleInputConfirm();
|
|
116
93
|
}
|
|
117
94
|
};
|
|
118
95
|
//handle close
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
if (item.onClose) item.onClose(e);
|
|
129
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(inData, getTagGroupVal(inData));
|
|
130
|
-
};
|
|
96
|
+
const handleClose = item => e => {
|
|
97
|
+
const idx = inData.findIndex(_ => _.value === item.value);
|
|
98
|
+
if (idx > -1) {
|
|
99
|
+
inData.splice(idx, 1);
|
|
100
|
+
setInData([...inData]);
|
|
101
|
+
}
|
|
102
|
+
if (item.onClose) item.onClose(e);
|
|
103
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(inData, getTagGroupVal(inData));
|
|
131
104
|
};
|
|
132
105
|
//渲染Tag组
|
|
133
|
-
|
|
106
|
+
const renderTagGroup = () => {
|
|
134
107
|
if (!(inData === null || inData === void 0 ? void 0 : inData.length)) return null;
|
|
135
|
-
return inData.map(
|
|
108
|
+
return inData.map((item, idx) => {
|
|
136
109
|
return jsx(Tag, Object.assign({}, item, {
|
|
137
110
|
size: size,
|
|
138
111
|
visible: true,
|
|
139
|
-
tagChange:
|
|
140
|
-
return handleTagEdit(value, idx);
|
|
141
|
-
},
|
|
112
|
+
tagChange: value => handleTagEdit(value, idx),
|
|
142
113
|
onClose: handleClose(item)
|
|
143
114
|
}, {
|
|
144
115
|
children: item.label
|
|
@@ -146,10 +117,10 @@ var TagGroup = function TagGroup(props) {
|
|
|
146
117
|
});
|
|
147
118
|
};
|
|
148
119
|
//动态增加tag
|
|
149
|
-
|
|
120
|
+
const renderNewInput = () => {
|
|
150
121
|
var _a;
|
|
151
122
|
if (inputVisible) {
|
|
152
|
-
|
|
123
|
+
const inputCls = clsx('tag-group-input', {
|
|
153
124
|
'tag-group-input-large': size === 'large'
|
|
154
125
|
}, inputClassName);
|
|
155
126
|
return jsx("input", {
|
|
@@ -166,19 +137,17 @@ var TagGroup = function TagGroup(props) {
|
|
|
166
137
|
onKeyDown: handleInputEnter
|
|
167
138
|
});
|
|
168
139
|
}
|
|
169
|
-
|
|
170
|
-
|
|
140
|
+
let icon = jsx(Plus, {});
|
|
141
|
+
let text = 'New Tag';
|
|
171
142
|
if (increasedTag) {
|
|
172
143
|
icon = increasedTag.icon || jsx(Plus, {});
|
|
173
144
|
text = (_a = increasedTag.text) !== null && _a !== void 0 ? _a : 'New Tag';
|
|
174
145
|
}
|
|
175
|
-
|
|
146
|
+
const newCls = clsx('tag-group-new', {
|
|
176
147
|
'tag-group-new-icon': !text
|
|
177
148
|
}, 'tag-group-add-btn');
|
|
178
149
|
return jsx(Tag, Object.assign({
|
|
179
|
-
getWidth:
|
|
180
|
-
return setIncreasedInputWidth(width);
|
|
181
|
-
},
|
|
150
|
+
getWidth: width => setIncreasedInputWidth(width),
|
|
182
151
|
className: newCls,
|
|
183
152
|
size: size,
|
|
184
153
|
icon: icon,
|
|
@@ -196,104 +165,88 @@ var TagGroup = function TagGroup(props) {
|
|
|
196
165
|
};
|
|
197
166
|
|
|
198
167
|
//预设颜色列表
|
|
199
|
-
|
|
168
|
+
const PresetColors = ['blue', 'green', 'yellow', 'red'];
|
|
200
169
|
//tag
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
style = props.style,
|
|
224
|
-
visibleTag = props.visible,
|
|
225
|
-
editInputWidth = props.editInputWidth,
|
|
226
|
-
tipMaxWidth = props.tipMaxWidth,
|
|
170
|
+
const InternalTag = props => {
|
|
171
|
+
const {
|
|
172
|
+
type = 'normal',
|
|
173
|
+
className,
|
|
174
|
+
children,
|
|
175
|
+
icon,
|
|
176
|
+
color,
|
|
177
|
+
onClose,
|
|
178
|
+
onEdit,
|
|
179
|
+
getWidth,
|
|
180
|
+
tagChange,
|
|
181
|
+
editInputClassName,
|
|
182
|
+
closeIcon,
|
|
183
|
+
closable = false,
|
|
184
|
+
editable = false,
|
|
185
|
+
size = 'larage',
|
|
186
|
+
maxWidth,
|
|
187
|
+
style,
|
|
188
|
+
visible: visibleTag,
|
|
189
|
+
editInputWidth,
|
|
190
|
+
tipMaxWidth
|
|
191
|
+
} = props,
|
|
227
192
|
restProps = __rest(props, ["type", "className", "children", "icon", "color", "onClose", "onEdit", "getWidth", "tagChange", "editInputClassName", "closeIcon", "closable", "editable", "size", "maxWidth", "style", "visible", "editInputWidth", "tipMaxWidth"]);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
238
|
-
inputValue = _useState6[0],
|
|
239
|
-
setInputValue = _useState6[1]; // 编辑输入框的值
|
|
240
|
-
var _useState7 = useState(''),
|
|
241
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
242
|
-
inputWidth = _useState8[0],
|
|
243
|
-
setInputWidth = _useState8[1]; // 编辑输入框的值
|
|
244
|
-
var _useState9 = useState(false),
|
|
245
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
246
|
-
closeIconEnter = _useState10[0],
|
|
247
|
-
setCloseIconEnter = _useState10[1]; // 鼠标是否进入closeIcon
|
|
248
|
-
var _useState11 = useState(false),
|
|
249
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
250
|
-
editIconEnter = _useState12[0],
|
|
251
|
-
setEditIconEnter = _useState12[1]; // 鼠标是否进入closeIcon
|
|
252
|
-
var inputRef = useRef(); //input ref
|
|
253
|
-
var tagRef = useRef(); //tagRef ref
|
|
254
|
-
useEffect(function () {
|
|
193
|
+
const [visible, setVisible] = useState(true); //显示tag
|
|
194
|
+
const [inputVisible, setInputVisible] = useState(false); //显示输入框
|
|
195
|
+
const [inputValue, setInputValue] = useState(''); // 编辑输入框的值
|
|
196
|
+
const [inputWidth, setInputWidth] = useState(''); // 编辑输入框的值
|
|
197
|
+
const [closeIconEnter, setCloseIconEnter] = useState(false); // 鼠标是否进入closeIcon
|
|
198
|
+
const [editIconEnter, setEditIconEnter] = useState(false); // 鼠标是否进入closeIcon
|
|
199
|
+
const inputRef = useRef(); //input ref
|
|
200
|
+
const tagRef = useRef(); //tagRef ref
|
|
201
|
+
useEffect(() => {
|
|
255
202
|
if ('visible' in props) {
|
|
256
203
|
setVisible(!!visibleTag);
|
|
257
204
|
}
|
|
258
205
|
}, [visibleTag]);
|
|
259
|
-
useEffect(
|
|
206
|
+
useEffect(() => {
|
|
260
207
|
if (!tagRef.current) return;
|
|
261
|
-
|
|
208
|
+
const {
|
|
209
|
+
offsetWidth
|
|
210
|
+
} = tagRef.current;
|
|
262
211
|
setInputWidth(offsetWidth);
|
|
263
212
|
getWidth && getWidth(offsetWidth);
|
|
264
213
|
}, [tagRef, inputVisible]);
|
|
265
|
-
useEffect(
|
|
214
|
+
useEffect(() => {
|
|
266
215
|
if (typeof children === 'string') {
|
|
267
216
|
setInputValue(children);
|
|
268
217
|
}
|
|
269
218
|
}, [children]);
|
|
270
219
|
//是否预设颜色
|
|
271
|
-
|
|
220
|
+
const isPresetColor = () => {
|
|
272
221
|
if (!color) return false;
|
|
273
222
|
return PresetColors.includes(color);
|
|
274
223
|
};
|
|
275
224
|
//tag style
|
|
276
|
-
|
|
225
|
+
const tagStyle = Object.assign({
|
|
277
226
|
color: color && !isPresetColor() ? color : undefined,
|
|
278
227
|
backgroundColor: color && !isPresetColor() ? tinycolor(color).setAlpha(0.1).toRgbString() : undefined,
|
|
279
228
|
borderColor: color && !isPresetColor() && type === 'outline' ? color : undefined,
|
|
280
|
-
maxWidth
|
|
229
|
+
maxWidth
|
|
281
230
|
}, style);
|
|
282
231
|
//tag closeIcon style
|
|
283
|
-
|
|
232
|
+
const closeIconStyle = {
|
|
284
233
|
backgroundColor: closeIconEnter ? tinycolor(color).setAlpha(0.1).toRgbString() : undefined,
|
|
285
234
|
borderRadius: '2px'
|
|
286
235
|
};
|
|
287
236
|
//tag editIcon style
|
|
288
|
-
|
|
237
|
+
const editIconStyle = {
|
|
289
238
|
backgroundColor: editIconEnter ? tinycolor(color).setAlpha(0.1).toRgbString() : undefined,
|
|
290
239
|
marginRight: children ? size === 'small' ? '2px' : '4px' : undefined,
|
|
291
240
|
borderRadius: '2px'
|
|
292
241
|
};
|
|
293
242
|
//tag cls
|
|
294
|
-
|
|
243
|
+
const tagClassName = clsx("".concat($prefixCls, "-tag"), "".concat($prefixCls, "-tag-").concat(type), "".concat($prefixCls, "-tag-").concat(size), className, {
|
|
244
|
+
["".concat($prefixCls, "-tag-has-color")]: color,
|
|
245
|
+
["".concat($prefixCls, "-tag-hidden")]: !visible,
|
|
246
|
+
["".concat($prefixCls, "-tag-").concat(color)]: isPresetColor()
|
|
247
|
+
});
|
|
295
248
|
//tag close click
|
|
296
|
-
|
|
249
|
+
const handleCloseClick = e => {
|
|
297
250
|
e.stopPropagation();
|
|
298
251
|
onClose === null || onClose === void 0 ? void 0 : onClose(e);
|
|
299
252
|
setCloseIconEnter(false);
|
|
@@ -304,19 +257,19 @@ var InternalTag = function InternalTag(props) {
|
|
|
304
257
|
setVisible(false);
|
|
305
258
|
}
|
|
306
259
|
};
|
|
307
|
-
|
|
260
|
+
const handleCloseEnter = () => {
|
|
308
261
|
setCloseIconEnter(true);
|
|
309
262
|
};
|
|
310
|
-
|
|
263
|
+
const handleCloseLeave = () => {
|
|
311
264
|
setCloseIconEnter(false);
|
|
312
265
|
};
|
|
313
|
-
|
|
266
|
+
const handleEditEnter = () => {
|
|
314
267
|
setEditIconEnter(true);
|
|
315
268
|
};
|
|
316
|
-
|
|
269
|
+
const handleEditLeave = () => {
|
|
317
270
|
setEditIconEnter(false);
|
|
318
271
|
};
|
|
319
|
-
|
|
272
|
+
const handleEditClick = e => {
|
|
320
273
|
e.stopPropagation();
|
|
321
274
|
onEdit && onEdit(e);
|
|
322
275
|
if (e.defaultPrevented) {
|
|
@@ -327,7 +280,7 @@ var InternalTag = function InternalTag(props) {
|
|
|
327
280
|
setInputVisible(true);
|
|
328
281
|
};
|
|
329
282
|
//渲染close icon
|
|
330
|
-
|
|
283
|
+
const renderCloseIcon = () => {
|
|
331
284
|
if (!closable) return null;
|
|
332
285
|
return closeIcon ? jsx("span", Object.assign({
|
|
333
286
|
className: 'tag-close-icon',
|
|
@@ -346,7 +299,7 @@ var InternalTag = function InternalTag(props) {
|
|
|
346
299
|
});
|
|
347
300
|
};
|
|
348
301
|
// 渲染前缀icon
|
|
349
|
-
|
|
302
|
+
const renderPrefixIcon = () => {
|
|
350
303
|
return (editable || icon) && jsx("span", Object.assign({
|
|
351
304
|
className: "tag-edit-icon ".concat(icon ? "tag-custom-icon" : ''),
|
|
352
305
|
style: editIconStyle,
|
|
@@ -364,23 +317,23 @@ var InternalTag = function InternalTag(props) {
|
|
|
364
317
|
}));
|
|
365
318
|
};
|
|
366
319
|
//input change
|
|
367
|
-
|
|
320
|
+
const handleInputChange = e => {
|
|
368
321
|
setInputValue(e.target.value);
|
|
369
322
|
tagChange && tagChange(e.target.value);
|
|
370
323
|
};
|
|
371
324
|
//input confirm
|
|
372
|
-
|
|
325
|
+
const handleInputConfirm = () => {
|
|
373
326
|
setInputVisible(false);
|
|
374
327
|
};
|
|
375
328
|
//input enter
|
|
376
|
-
|
|
329
|
+
const handleInputEnter = e => {
|
|
377
330
|
if (e.keyCode === 13 || e.which === 13) {
|
|
378
331
|
handleInputConfirm();
|
|
379
332
|
}
|
|
380
333
|
};
|
|
381
334
|
//
|
|
382
|
-
|
|
383
|
-
|
|
335
|
+
const renderNewInput = () => {
|
|
336
|
+
const inputCls = clsx("".concat($prefixCls, "-tag-edit-input"), editInputClassName);
|
|
384
337
|
return jsx("input", {
|
|
385
338
|
style: {
|
|
386
339
|
width: editInputWidth || inputWidth,
|
|
@@ -414,6 +367,6 @@ var InternalTag = function InternalTag(props) {
|
|
|
414
367
|
}))
|
|
415
368
|
});
|
|
416
369
|
};
|
|
417
|
-
|
|
370
|
+
const Tag = InternalTag;
|
|
418
371
|
|
|
419
372
|
export { Tag, TagGroup, Tag as default };
|