@douyinfe/semi-ui 2.18.0-beta.0 → 2.18.1
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/checkbox/checkbox.tsx +10 -2
- package/dist/css/semi.css +8 -6
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +26416 -27922
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/baseForm.tsx +0 -1
- package/lib/cjs/checkbox/checkbox.d.ts +4 -0
- package/lib/cjs/checkbox/checkbox.js +9 -3
- package/lib/cjs/form/baseForm.js +0 -1
- package/lib/cjs/radio/radio.d.ts +2 -0
- package/lib/cjs/radio/radio.js +33 -8
- package/lib/cjs/table/ColumnFilter.js +4 -2
- package/lib/cjs/table/ColumnSorter.d.ts +1 -0
- package/lib/cjs/table/ColumnSorter.js +9 -6
- package/lib/cjs/table/Table.js +11 -4
- package/lib/cjs/tabs/TabBar.js +5 -1
- package/lib/cjs/transfer/index.js +7 -2
- package/lib/es/checkbox/checkbox.d.ts +4 -0
- package/lib/es/checkbox/checkbox.js +10 -4
- package/lib/es/form/baseForm.js +0 -1
- package/lib/es/radio/radio.d.ts +2 -0
- package/lib/es/radio/radio.js +31 -8
- package/lib/es/table/ColumnFilter.js +4 -2
- package/lib/es/table/ColumnSorter.d.ts +1 -0
- package/lib/es/table/ColumnSorter.js +9 -6
- package/lib/es/table/Table.js +10 -4
- package/lib/es/tabs/TabBar.js +5 -1
- package/lib/es/transfer/index.js +7 -2
- package/package.json +7 -7
- package/radio/radio.tsx +27 -5
- package/table/ColumnFilter.tsx +2 -1
- package/table/ColumnSorter.tsx +16 -10
- package/table/Table.tsx +7 -4
- package/tabs/TabBar.tsx +7 -1
- package/transfer/index.tsx +7 -2
- package/webpack.config.js +13 -3
package/lib/es/transfer/index.js
CHANGED
|
@@ -280,7 +280,8 @@ class Transfer extends BaseComponent {
|
|
|
280
280
|
const noMatch = inSearchMode && searchResult.size === 0;
|
|
281
281
|
const emptySearch = emptyContent.search ? emptyContent.search : locale.emptySearch;
|
|
282
282
|
const emptyLeft = emptyContent.left ? emptyContent.left : locale.emptyLeft;
|
|
283
|
-
const
|
|
283
|
+
const emptyDataCom = this.renderEmpty('left', emptyLeft);
|
|
284
|
+
const emptySearchCom = this.renderEmpty('left', emptySearch);
|
|
284
285
|
const loadingCom = /*#__PURE__*/React.createElement(Spin, null);
|
|
285
286
|
let content = null;
|
|
286
287
|
|
|
@@ -290,7 +291,11 @@ class Transfer extends BaseComponent {
|
|
|
290
291
|
break;
|
|
291
292
|
|
|
292
293
|
case noMatch:
|
|
293
|
-
content =
|
|
294
|
+
content = emptySearchCom;
|
|
295
|
+
break;
|
|
296
|
+
|
|
297
|
+
case data.length === 0:
|
|
298
|
+
content = emptyDataCom;
|
|
294
299
|
break;
|
|
295
300
|
|
|
296
301
|
case type === strings.TYPE_TREE_TO_LIST:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
17
|
"@douyinfe/semi-animation": "2.12.0",
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.18.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.18.
|
|
20
|
-
"@douyinfe/semi-icons": "2.18.
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.18.1",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.18.1",
|
|
20
|
+
"@douyinfe/semi-icons": "2.18.1",
|
|
21
21
|
"@douyinfe/semi-illustrations": "2.15.0",
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.18.
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.18.1",
|
|
23
23
|
"async-validator": "^3.5.0",
|
|
24
24
|
"classnames": "^2.2.6",
|
|
25
25
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
],
|
|
67
67
|
"author": "",
|
|
68
68
|
"license": "MIT",
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "42e7d9b618dc5cabad8d5ce7287f0c5f5d7691bd",
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
72
72
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
73
73
|
"@babel/preset-env": "^7.15.8",
|
|
74
74
|
"@babel/preset-react": "^7.14.5",
|
|
75
|
-
"@douyinfe/semi-scss-compile": "2.18.
|
|
75
|
+
"@douyinfe/semi-scss-compile": "2.18.1",
|
|
76
76
|
"@storybook/addon-knobs": "^6.3.1",
|
|
77
77
|
"@types/lodash": "^4.14.176",
|
|
78
78
|
"@types/react": ">=16.0.0",
|
package/radio/radio.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import cls from 'classnames';
|
|
5
|
-
import { noop } from 'lodash';
|
|
5
|
+
import { noop, isUndefined, isBoolean } from 'lodash';
|
|
6
6
|
|
|
7
7
|
import RadioFoundation, { RadioAdapter } from '@douyinfe/semi-foundation/radio/radioFoundation';
|
|
8
8
|
import { RadioChangeEvent } from '@douyinfe/semi-foundation/radio/radioInnerFoundation';
|
|
@@ -52,6 +52,7 @@ export interface RadioState {
|
|
|
52
52
|
addonId?: string;
|
|
53
53
|
extraId?: string;
|
|
54
54
|
focusVisible?: boolean;
|
|
55
|
+
checked?: boolean;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
export { RadioChangeEvent };
|
|
@@ -104,11 +105,22 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
104
105
|
hover: false,
|
|
105
106
|
addonId: props.addonId,
|
|
106
107
|
extraId: props.extraId,
|
|
108
|
+
checked: props.checked || props.defaultChecked || false,
|
|
107
109
|
};
|
|
108
110
|
this.foundation = new RadioFoundation(this.adapter);
|
|
109
111
|
this.radioEntity = null;
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
componentDidUpdate(prevProps: RadioProps) {
|
|
115
|
+
if (this.props.checked !== prevProps.checked) {
|
|
116
|
+
if (isUndefined(this.props.checked)) {
|
|
117
|
+
this.foundation.setChecked(false);
|
|
118
|
+
} else if (isBoolean(this.props.checked)) {
|
|
119
|
+
this.foundation.setChecked(this.props.checked);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
112
124
|
get adapter(): RadioAdapter {
|
|
113
125
|
return {
|
|
114
126
|
...super.adapter,
|
|
@@ -118,6 +130,9 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
118
130
|
setAddonId: () => {
|
|
119
131
|
this.setState({ addonId: getUuidShort({ prefix: 'addon' }) });
|
|
120
132
|
},
|
|
133
|
+
setChecked: (checked: boolean) => {
|
|
134
|
+
this.setState({ checked });
|
|
135
|
+
},
|
|
121
136
|
setExtraId: () => {
|
|
122
137
|
this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
|
|
123
138
|
},
|
|
@@ -146,6 +161,7 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
146
161
|
const { radioGroup } = this.context;
|
|
147
162
|
radioGroup.onChange && radioGroup.onChange(e);
|
|
148
163
|
}
|
|
164
|
+
!('checked' in this.props) && this.foundation.setChecked(e.target.checked);
|
|
149
165
|
onChange && onChange(e);
|
|
150
166
|
};
|
|
151
167
|
|
|
@@ -171,7 +187,6 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
171
187
|
const {
|
|
172
188
|
addonClassName,
|
|
173
189
|
addonStyle,
|
|
174
|
-
checked,
|
|
175
190
|
disabled,
|
|
176
191
|
style,
|
|
177
192
|
className,
|
|
@@ -194,8 +209,11 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
194
209
|
isButtonRadioComponent,
|
|
195
210
|
buttonSize,
|
|
196
211
|
realPrefixCls;
|
|
197
|
-
const { hover: isHover, addonId, extraId, focusVisible } = this.state;
|
|
198
|
-
|
|
212
|
+
const { hover: isHover, addonId, extraId, focusVisible, checked, } = this.state;
|
|
213
|
+
const props: Record<string, any> = {
|
|
214
|
+
checked,
|
|
215
|
+
disabled,
|
|
216
|
+
};
|
|
199
217
|
|
|
200
218
|
if (this.isInGroup()) {
|
|
201
219
|
realChecked = this.context.radioGroup.value === propValue;
|
|
@@ -206,13 +224,17 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
206
224
|
isPureCardRadioGroup = this.context.radioGroup.isPureCardRadio;
|
|
207
225
|
buttonSize = this.context.radioGroup.buttonSize;
|
|
208
226
|
realPrefixCls = prefixCls || this.context.radioGroup.prefixCls;
|
|
209
|
-
props =
|
|
227
|
+
props.checked = realChecked;
|
|
228
|
+
props.disabled = isDisabled;
|
|
210
229
|
} else {
|
|
211
230
|
realChecked = checked;
|
|
212
231
|
isDisabled = disabled;
|
|
213
232
|
realMode = mode;
|
|
214
233
|
isButtonRadioComponent = type === 'button';
|
|
215
234
|
realPrefixCls = prefixCls;
|
|
235
|
+
isButtonRadioGroup = type === strings.TYPE_BUTTON;
|
|
236
|
+
isPureCardRadioGroup = type === strings.TYPE_PURECARD;
|
|
237
|
+
isCardRadioGroup = type === strings.TYPE_CARD || isPureCardRadioGroup;
|
|
216
238
|
}
|
|
217
239
|
const isButtonRadio = typeof isButtonRadioGroup === 'undefined' ? isButtonRadioComponent : isButtonRadioGroup;
|
|
218
240
|
|
package/table/ColumnFilter.tsx
CHANGED
|
@@ -164,12 +164,13 @@ export default function ColumnFilter(props: ColumnFilterProps = {}): React.React
|
|
|
164
164
|
} else {
|
|
165
165
|
iconElem = (
|
|
166
166
|
<div className={finalCls}>
|
|
167
|
+
{'\u200b'/* ZWSP(zero-width space) */}
|
|
167
168
|
<IconFilter
|
|
168
169
|
role="button"
|
|
169
170
|
aria-label="Filter data with this column"
|
|
170
171
|
aria-haspopup="listbox"
|
|
171
172
|
tabIndex={-1}
|
|
172
|
-
size="
|
|
173
|
+
size="default"
|
|
173
174
|
/>
|
|
174
175
|
</div>
|
|
175
176
|
);
|
package/table/ColumnSorter.tsx
CHANGED
|
@@ -15,6 +15,7 @@ export interface ColumnSorterProps {
|
|
|
15
15
|
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
16
16
|
prefixCls?: string;
|
|
17
17
|
sortOrder?: SortOrder;
|
|
18
|
+
title?: React.ReactNode;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export default class ColumnSorter extends PureComponent<ColumnSorterProps> {
|
|
@@ -33,9 +34,9 @@ export default class ColumnSorter extends PureComponent<ColumnSorterProps> {
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
render() {
|
|
36
|
-
const { prefixCls, onClick, sortOrder, style } = this.props;
|
|
37
|
+
const { prefixCls, onClick, sortOrder, style, title } = this.props;
|
|
37
38
|
|
|
38
|
-
const iconBtnSize = '
|
|
39
|
+
const iconBtnSize = 'default';
|
|
39
40
|
|
|
40
41
|
const upCls = cls(`${prefixCls}-column-sorter-up`, {
|
|
41
42
|
on: sortOrder === strings.SORT_DIRECTIONS[0],
|
|
@@ -58,17 +59,22 @@ export default class ColumnSorter extends PureComponent<ColumnSorterProps> {
|
|
|
58
59
|
role='button'
|
|
59
60
|
{...ariaProps}
|
|
60
61
|
tabIndex={-1}
|
|
61
|
-
|
|
62
|
-
className={`${prefixCls}-column-sorter`}
|
|
62
|
+
className={`${prefixCls}-column-sorter-wrapper`}
|
|
63
63
|
onClick={onClick}
|
|
64
64
|
onKeyPress={e => isEnterPress(e) && onClick(e as any)}
|
|
65
65
|
>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
{title}
|
|
67
|
+
<div
|
|
68
|
+
style={style}
|
|
69
|
+
className={`${prefixCls}-column-sorter`}
|
|
70
|
+
>
|
|
71
|
+
<span className={`${upCls}`}>
|
|
72
|
+
<IconCaretup size={iconBtnSize} />
|
|
73
|
+
</span>
|
|
74
|
+
<span className={`${downCls}`}>
|
|
75
|
+
<IconCaretdown size={iconBtnSize} />
|
|
76
|
+
</span>
|
|
77
|
+
</div>
|
|
72
78
|
</div>
|
|
73
79
|
);
|
|
74
80
|
}
|
package/table/Table.tsx
CHANGED
|
@@ -933,16 +933,22 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
933
933
|
const stateSortOrder = get(curQuery, 'sortOrder');
|
|
934
934
|
const defaultSortOrder = get(curQuery, 'defaultSortOrder', false);
|
|
935
935
|
const sortOrder = this.foundation.isSortOrderValid(stateSortOrder) ? stateSortOrder : defaultSortOrder;
|
|
936
|
+
const TitleNode = typeof rawTitle !== 'function' && <React.Fragment key={strings.DEFAULT_KEY_COLUMN_TITLE}>{rawTitle as React.ReactNode}</React.Fragment>;
|
|
936
937
|
if (typeof column.sorter === 'function' || column.sorter === true) {
|
|
938
|
+
// In order to increase the click hot area of sorting, when sorting is required & useFullRender is false,
|
|
939
|
+
// both the title and sorting areas are used as the click hot area for sorting。
|
|
937
940
|
const sorter = (
|
|
938
941
|
<ColumnSorter
|
|
939
942
|
key={strings.DEFAULT_KEY_COLUMN_SORTER}
|
|
940
943
|
sortOrder={sortOrder}
|
|
941
944
|
onClick={e => this.foundation.handleSort(column, e)}
|
|
945
|
+
title={TitleNode}
|
|
942
946
|
/>
|
|
943
947
|
);
|
|
944
948
|
useFullRender && (titleMap.sorter = sorter);
|
|
945
949
|
titleArr.push(sorter);
|
|
950
|
+
} else {
|
|
951
|
+
titleArr.push(TitleNode);
|
|
946
952
|
}
|
|
947
953
|
|
|
948
954
|
const stateFilteredValue = get(curQuery, 'filteredValue');
|
|
@@ -964,10 +970,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
964
970
|
|
|
965
971
|
const newTitle =
|
|
966
972
|
typeof rawTitle === 'function' ?
|
|
967
|
-
() => rawTitle(titleMap) :
|
|
968
|
-
titleArr.unshift(
|
|
969
|
-
<React.Fragment key={strings.DEFAULT_KEY_COLUMN_TITLE}>{rawTitle}</React.Fragment>
|
|
970
|
-
) && titleArr;
|
|
973
|
+
() => rawTitle(titleMap) : titleArr;
|
|
971
974
|
|
|
972
975
|
column = { ...column, title: newTitle };
|
|
973
976
|
}
|
package/tabs/TabBar.tsx
CHANGED
|
@@ -147,7 +147,13 @@ class TabBar extends React.Component<TabBarProps, TabBarState> {
|
|
|
147
147
|
|
|
148
148
|
renderCollapse = (items: Array<OverflowItem>, icon: ReactNode, pos: 'start' | 'end'): ReactNode => {
|
|
149
149
|
if (isEmpty(items)) {
|
|
150
|
-
return
|
|
150
|
+
return (
|
|
151
|
+
<Button
|
|
152
|
+
disabled={true}
|
|
153
|
+
icon={icon}
|
|
154
|
+
theme="borderless"
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
151
157
|
}
|
|
152
158
|
const { dropdownClassName, dropdownStyle } = this.props;
|
|
153
159
|
const { rePosKey } = this.state;
|
package/transfer/index.tsx
CHANGED
|
@@ -393,7 +393,9 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
|
|
|
393
393
|
const noMatch = inSearchMode && searchResult.size === 0;
|
|
394
394
|
const emptySearch = emptyContent.search ? emptyContent.search : locale.emptySearch;
|
|
395
395
|
const emptyLeft = emptyContent.left ? emptyContent.left : locale.emptyLeft;
|
|
396
|
-
const
|
|
396
|
+
const emptyDataCom = this.renderEmpty('left', emptyLeft);
|
|
397
|
+
const emptySearchCom = this.renderEmpty('left', emptySearch);
|
|
398
|
+
|
|
397
399
|
const loadingCom = <Spin />;
|
|
398
400
|
|
|
399
401
|
let content: React.ReactNode = null;
|
|
@@ -402,7 +404,10 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
|
|
|
402
404
|
content = loadingCom;
|
|
403
405
|
break;
|
|
404
406
|
case noMatch:
|
|
405
|
-
content =
|
|
407
|
+
content = emptySearchCom;
|
|
408
|
+
break;
|
|
409
|
+
case data.length === 0:
|
|
410
|
+
content = emptyDataCom;
|
|
406
411
|
break;
|
|
407
412
|
case type === strings.TYPE_TREE_TO_LIST:
|
|
408
413
|
content = (
|
package/webpack.config.js
CHANGED
|
@@ -22,13 +22,16 @@ module.exports = function ({ minimize }) {
|
|
|
22
22
|
library: 'SemiUI',
|
|
23
23
|
libraryTarget: 'umd'
|
|
24
24
|
},
|
|
25
|
+
|
|
25
26
|
module: {
|
|
26
27
|
rules: [
|
|
27
28
|
{
|
|
28
29
|
test: /\.tsx?$/,
|
|
29
30
|
include: [
|
|
30
31
|
path.join(rootPath, 'packages/semi-ui'),
|
|
31
|
-
path.join(rootPath, 'packages/semi-foundation')
|
|
32
|
+
path.join(rootPath, 'packages/semi-foundation'),
|
|
33
|
+
path.join(rootPath, 'packages/semi-animation'),
|
|
34
|
+
path.join(rootPath, 'packages/semi-animation-react')
|
|
32
35
|
],
|
|
33
36
|
use: [
|
|
34
37
|
{
|
|
@@ -45,7 +48,7 @@ module.exports = function ({ minimize }) {
|
|
|
45
48
|
}
|
|
46
49
|
]
|
|
47
50
|
},
|
|
48
|
-
{
|
|
51
|
+
{
|
|
49
52
|
test: /semi-icons\/.+\.css$/,
|
|
50
53
|
loaders: 'null-loader'
|
|
51
54
|
},
|
|
@@ -66,7 +69,14 @@ module.exports = function ({ minimize }) {
|
|
|
66
69
|
new HashedModuleIdsPlugin()
|
|
67
70
|
],
|
|
68
71
|
resolve: {
|
|
69
|
-
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
|
|
72
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
73
|
+
alias: {
|
|
74
|
+
"@douyinfe/semi-foundation": path.resolve(__dirname, "../semi-foundation"),
|
|
75
|
+
"@douyinfe/semi-icons": path.resolve(__dirname, "../semi-icons"),
|
|
76
|
+
"@douyinfe/semi-illustrations":path.resolve(__dirname, "../semi-illustrations"),
|
|
77
|
+
"@douyinfe/semi-animation":path.resolve(__dirname, "../semi-animation"),
|
|
78
|
+
"@douyinfe/semi-animation-react":path.resolve(__dirname, "../semi-animation-react")
|
|
79
|
+
},
|
|
70
80
|
},
|
|
71
81
|
externals: {
|
|
72
82
|
react: {
|