@douyinfe/semi-ui 2.18.0-beta.0 → 2.19.0-alpha.0
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 +14 -7
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +36496 -38001
- 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/lib/cjs/checkbox/checkbox.d.ts +4 -0
- package/lib/cjs/checkbox/checkbox.js +9 -3
- 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/tree/treeNode.d.ts +4 -1
- package/lib/cjs/tree/treeNode.js +13 -4
- package/lib/es/checkbox/checkbox.d.ts +4 -0
- package/lib/es/checkbox/checkbox.js +10 -4
- 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/tree/treeNode.d.ts +4 -1
- package/lib/es/tree/treeNode.js +13 -4
- 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/tree/treeNode.tsx +11 -5
- package/webpack.config.js +13 -3
package/lib/es/tree/treeNode.js
CHANGED
|
@@ -300,7 +300,11 @@ export default class TreeNode extends PureComponent {
|
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
renderCheckbox() {
|
|
303
|
+
renderCheckbox(options) {
|
|
304
|
+
const {
|
|
305
|
+
label,
|
|
306
|
+
icon
|
|
307
|
+
} = options;
|
|
304
308
|
const {
|
|
305
309
|
checked,
|
|
306
310
|
halfChecked,
|
|
@@ -317,7 +321,7 @@ export default class TreeNode extends PureComponent {
|
|
|
317
321
|
indeterminate: halfChecked,
|
|
318
322
|
checked: checked,
|
|
319
323
|
disabled: Boolean(disabled)
|
|
320
|
-
}));
|
|
324
|
+
}, icon, label));
|
|
321
325
|
}
|
|
322
326
|
|
|
323
327
|
renderIcon() {
|
|
@@ -487,6 +491,8 @@ export default class TreeNode extends PureComponent {
|
|
|
487
491
|
const setsize = _get(rest, ['data', 'children', 'length']);
|
|
488
492
|
|
|
489
493
|
const posinset = _isString(rest.pos) ? Number(rest.pos.split('-')[level + 1]) + 1 : 1;
|
|
494
|
+
const label = this.renderRealLabel();
|
|
495
|
+
const icon = this.renderIcon();
|
|
490
496
|
return /*#__PURE__*/React.createElement("li", _Object$assign({
|
|
491
497
|
className: nodeCls,
|
|
492
498
|
role: "treeitem",
|
|
@@ -506,9 +512,12 @@ export default class TreeNode extends PureComponent {
|
|
|
506
512
|
style: style
|
|
507
513
|
}, dragProps), this.renderArrow(), /*#__PURE__*/React.createElement("span", {
|
|
508
514
|
className: labelCls
|
|
509
|
-
}, multiple ? this.renderCheckbox(
|
|
515
|
+
}, multiple ? this.renderCheckbox({
|
|
516
|
+
label,
|
|
517
|
+
icon
|
|
518
|
+
}) : null, !multiple && icon, !multiple && /*#__PURE__*/React.createElement("span", {
|
|
510
519
|
className: "".concat(prefixcls, "-label-text")
|
|
511
|
-
},
|
|
520
|
+
}, label)));
|
|
512
521
|
}
|
|
513
522
|
|
|
514
523
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0-alpha.0",
|
|
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.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.
|
|
20
|
-
"@douyinfe/semi-icons": "2.
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.19.0-alpha.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.19.0-alpha.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.19.0-alpha.0",
|
|
21
21
|
"@douyinfe/semi-illustrations": "2.15.0",
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.19.0-alpha.0",
|
|
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": "58f801d44b0fb3079606c9e7b060f5c782d37e0a",
|
|
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.
|
|
75
|
+
"@douyinfe/semi-scss-compile": "2.19.0-alpha.0",
|
|
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/tree/treeNode.tsx
CHANGED
|
@@ -220,7 +220,8 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
|
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
renderCheckbox() {
|
|
223
|
+
renderCheckbox(options: { label: React.ReactNode; icon: React.ReactNode }) {
|
|
224
|
+
const { label, icon } = options;
|
|
224
225
|
const { checked, halfChecked, eventKey } = this.props;
|
|
225
226
|
const disabled = this.isDisabled();
|
|
226
227
|
return (
|
|
@@ -235,7 +236,10 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
|
|
|
235
236
|
indeterminate={halfChecked}
|
|
236
237
|
checked={checked}
|
|
237
238
|
disabled={Boolean(disabled)}
|
|
238
|
-
|
|
239
|
+
>
|
|
240
|
+
{icon}
|
|
241
|
+
{label}
|
|
242
|
+
</Checkbox>
|
|
239
243
|
</div>
|
|
240
244
|
);
|
|
241
245
|
}
|
|
@@ -409,6 +413,8 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
|
|
|
409
413
|
});
|
|
410
414
|
const setsize = get(rest, ['data', 'children', 'length']);
|
|
411
415
|
const posinset = isString(rest.pos) ? Number(rest.pos.split('-')[level+1]) + 1 : 1;
|
|
416
|
+
const label = this.renderRealLabel();
|
|
417
|
+
const icon = this.renderIcon();
|
|
412
418
|
return (
|
|
413
419
|
<li
|
|
414
420
|
className={nodeCls}
|
|
@@ -433,9 +439,9 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
|
|
|
433
439
|
<span
|
|
434
440
|
className={labelCls}
|
|
435
441
|
>
|
|
436
|
-
{multiple ? this.renderCheckbox() : null}
|
|
437
|
-
{
|
|
438
|
-
<span className={`${prefixcls}-label-text`}>{
|
|
442
|
+
{multiple ? this.renderCheckbox({ label, icon }) : null}
|
|
443
|
+
{!multiple && icon}
|
|
444
|
+
{!multiple && <span className={`${prefixcls}-label-text`}>{label}</span> }
|
|
439
445
|
</span>
|
|
440
446
|
</li>
|
|
441
447
|
);
|
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: {
|