@douyinfe/semi-ui 2.13.0 → 2.14.0-beta.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/autoComplete/_story/CustomTrigger/index.jsx +1 -1
- package/avatar/_story/avatar.stories.js +62 -5
- package/avatar/avatarGroup.tsx +16 -4
- package/avatar/index.tsx +88 -17
- package/backtop/index.tsx +11 -7
- package/badge/index.tsx +1 -1
- package/banner/index.tsx +5 -5
- package/breadcrumb/index.tsx +5 -3
- package/button/Button.tsx +10 -8
- package/calendar/_story/calendar.stories.js +125 -1
- package/card/index.tsx +43 -41
- package/carousel/CarouselArrow.tsx +2 -0
- package/carousel/index.tsx +1 -0
- package/cascader/_story/cascader.stories.js +21 -0
- package/cascader/index.tsx +99 -120
- package/cascader/item.tsx +1 -1
- package/checkbox/checkbox.tsx +13 -2
- package/collapsible/index.tsx +8 -1
- package/datePicker/dateInput.tsx +1 -0
- package/datePicker/datePicker.tsx +13 -5
- package/dist/css/semi.css +51 -35
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +933 -530
- 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/divider/index.tsx +8 -4
- package/dropdown/index.tsx +1 -1
- package/empty/index.tsx +13 -5
- package/form/hoc/withField.tsx +1 -1
- package/form/label.tsx +1 -1
- package/grid/col.tsx +1 -1
- package/grid/row.tsx +1 -1
- package/iconButton/index.tsx +2 -1
- package/input/_story/input.stories.js +32 -3
- package/input/index.tsx +45 -23
- package/input/inputGroup.tsx +3 -1
- package/input/textarea.tsx +2 -14
- package/lib/cjs/_base/base.css +14 -14
- package/lib/cjs/avatar/avatarGroup.d.ts +1 -1
- package/lib/cjs/avatar/avatarGroup.js +36 -9
- package/lib/cjs/avatar/index.d.ts +5 -0
- package/lib/cjs/avatar/index.js +121 -41
- package/lib/cjs/backtop/index.js +2 -1
- package/lib/cjs/badge/index.js +2 -1
- package/lib/cjs/banner/index.js +9 -4
- package/lib/cjs/breadcrumb/index.js +4 -3
- package/lib/cjs/button/Button.js +13 -3
- package/lib/cjs/card/index.js +10 -5
- package/lib/cjs/carousel/CarouselArrow.js +6 -2
- package/lib/cjs/carousel/index.js +2 -1
- package/lib/cjs/cascader/index.js +11 -6
- package/lib/cjs/cascader/item.js +2 -1
- package/lib/cjs/checkbox/checkbox.js +6 -2
- package/lib/cjs/collapsible/index.js +2 -1
- package/lib/cjs/datePicker/dateInput.js +2 -1
- package/lib/cjs/datePicker/datePicker.js +4 -2
- package/lib/cjs/divider/index.js +2 -1
- package/lib/cjs/dropdown/index.js +2 -1
- package/lib/cjs/empty/index.js +8 -4
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/hoc/withField.js +2 -1
- package/lib/cjs/form/label.js +2 -1
- package/lib/cjs/grid/col.js +2 -1
- package/lib/cjs/grid/row.js +2 -1
- package/lib/cjs/iconButton/index.js +3 -1
- package/lib/cjs/input/index.d.ts +0 -1
- package/lib/cjs/input/index.js +41 -36
- package/lib/cjs/input/inputGroup.js +2 -3
- package/lib/cjs/input/textarea.js +8 -15
- package/lib/cjs/list/index.js +6 -3
- package/lib/cjs/modal/ConfirmModal.js +2 -1
- package/lib/cjs/modal/Modal.js +6 -2
- package/lib/cjs/modal/ModalContent.js +13 -6
- package/lib/cjs/notification/notice.js +6 -3
- package/lib/cjs/pagination/index.js +4 -2
- package/lib/cjs/popconfirm/index.js +6 -3
- package/lib/cjs/radio/radio.d.ts +4 -0
- package/lib/cjs/radio/radio.js +32 -9
- package/lib/cjs/radio/radioInner.d.ts +6 -0
- package/lib/cjs/radio/radioInner.js +13 -4
- package/lib/cjs/rating/item.js +2 -1
- package/lib/cjs/scrollList/index.js +6 -3
- package/lib/cjs/select/index.js +10 -4
- package/lib/cjs/select/option.js +2 -1
- package/lib/cjs/sideSheet/SideSheetContent.js +6 -3
- package/lib/cjs/skeleton/index.js +3 -1
- package/lib/cjs/space/index.js +2 -1
- package/lib/cjs/spin/index.js +7 -3
- package/lib/cjs/switch/index.js +6 -4
- package/lib/cjs/table/Table.js +6 -3
- package/lib/cjs/tabs/TabBar.js +2 -1
- package/lib/cjs/tabs/TabPane.js +5 -2
- package/lib/cjs/tagInput/index.js +25 -15
- package/lib/cjs/timePicker/Combobox.js +3 -1
- package/lib/cjs/timePicker/TimePicker.js +2 -0
- package/lib/cjs/toast/toast.js +6 -3
- package/lib/cjs/tooltip/index.js +6 -1
- package/lib/cjs/transfer/index.js +2 -1
- package/lib/cjs/tree/treeNode.js +2 -1
- package/lib/cjs/treeSelect/index.js +10 -3
- package/lib/cjs/typography/base.js +2 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/upload/index.d.ts +1 -1
- package/lib/cjs/upload/index.js +13 -6
- package/lib/es/_base/base.css +14 -14
- package/lib/es/avatar/avatarGroup.d.ts +1 -1
- package/lib/es/avatar/avatarGroup.js +37 -9
- package/lib/es/avatar/index.d.ts +5 -0
- package/lib/es/avatar/index.js +119 -38
- package/lib/es/backtop/index.js +2 -1
- package/lib/es/badge/index.js +2 -1
- package/lib/es/banner/index.js +9 -4
- package/lib/es/breadcrumb/index.js +4 -3
- package/lib/es/button/Button.js +11 -3
- package/lib/es/card/index.js +10 -5
- package/lib/es/carousel/CarouselArrow.js +6 -2
- package/lib/es/carousel/index.js +2 -1
- package/lib/es/cascader/index.js +11 -6
- package/lib/es/cascader/item.js +2 -1
- package/lib/es/checkbox/checkbox.js +6 -2
- package/lib/es/collapsible/index.js +2 -1
- package/lib/es/datePicker/dateInput.js +2 -1
- package/lib/es/datePicker/datePicker.js +4 -2
- package/lib/es/divider/index.js +2 -1
- package/lib/es/dropdown/index.js +2 -1
- package/lib/es/empty/index.js +8 -4
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +2 -1
- package/lib/es/form/label.js +2 -1
- package/lib/es/grid/col.js +2 -1
- package/lib/es/grid/row.js +2 -1
- package/lib/es/iconButton/index.js +3 -1
- package/lib/es/input/index.d.ts +0 -1
- package/lib/es/input/index.js +41 -36
- package/lib/es/input/inputGroup.js +2 -3
- package/lib/es/input/textarea.js +8 -15
- package/lib/es/list/index.js +6 -3
- package/lib/es/modal/ConfirmModal.js +2 -1
- package/lib/es/modal/Modal.js +6 -2
- package/lib/es/modal/ModalContent.js +13 -6
- package/lib/es/notification/notice.js +6 -3
- package/lib/es/pagination/index.js +4 -2
- package/lib/es/popconfirm/index.js +6 -3
- package/lib/es/radio/radio.d.ts +4 -0
- package/lib/es/radio/radio.js +32 -9
- package/lib/es/radio/radioInner.d.ts +6 -0
- package/lib/es/radio/radioInner.js +13 -4
- package/lib/es/rating/item.js +2 -1
- package/lib/es/scrollList/index.js +6 -3
- package/lib/es/select/index.js +10 -4
- package/lib/es/select/option.js +2 -1
- package/lib/es/sideSheet/SideSheetContent.js +6 -3
- package/lib/es/skeleton/index.js +3 -1
- package/lib/es/space/index.js +2 -1
- package/lib/es/spin/index.js +7 -3
- package/lib/es/switch/index.js +6 -4
- package/lib/es/table/Table.js +6 -3
- package/lib/es/tabs/TabBar.js +2 -1
- package/lib/es/tabs/TabPane.js +5 -2
- package/lib/es/tagInput/index.js +25 -15
- package/lib/es/timePicker/Combobox.js +3 -1
- package/lib/es/timePicker/TimePicker.js +2 -0
- package/lib/es/toast/toast.js +6 -3
- package/lib/es/tooltip/index.js +6 -1
- package/lib/es/transfer/index.js +2 -1
- package/lib/es/tree/treeNode.js +2 -1
- package/lib/es/treeSelect/index.js +10 -3
- package/lib/es/typography/base.js +2 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/upload/index.d.ts +1 -1
- package/lib/es/upload/index.js +13 -6
- package/list/index.tsx +16 -4
- package/modal/ConfirmModal.tsx +1 -1
- package/modal/Modal.tsx +2 -0
- package/modal/ModalContent.tsx +27 -14
- package/notification/notice.tsx +16 -4
- package/package.json +8 -8
- package/pagination/index.tsx +16 -2
- package/popconfirm/index.tsx +11 -3
- package/radio/_story/radio.stories.js +9 -6
- package/radio/radio.tsx +37 -7
- package/radio/radioInner.tsx +11 -2
- package/rating/item.tsx +1 -1
- package/scrollList/index.tsx +19 -3
- package/select/index.tsx +13 -4
- package/select/option.tsx +5 -1
- package/sideSheet/SideSheetContent.tsx +3 -3
- package/skeleton/index.tsx +1 -1
- package/space/index.tsx +1 -1
- package/spin/index.tsx +15 -9
- package/switch/index.tsx +9 -14
- package/table/Table.tsx +5 -3
- package/tabs/TabBar.tsx +1 -1
- package/tabs/TabPane.tsx +9 -4
- package/tagInput/index.tsx +23 -4
- package/timePicker/Combobox.tsx +6 -1
- package/timePicker/TimePicker.tsx +1 -0
- package/toast/toast.tsx +3 -3
- package/tooltip/index.tsx +4 -1
- package/transfer/index.tsx +1 -0
- package/tree/treeNode.tsx +1 -1
- package/treeSelect/_story/treeSelect.stories.js +161 -2
- package/treeSelect/index.tsx +17 -3
- package/typography/base.tsx +1 -1
- package/upload/index.tsx +107 -38
- package/yarn-error.log +26235 -0
|
@@ -98,7 +98,7 @@ export default class ObjectDemo extends React.Component {
|
|
|
98
98
|
renderItem={this.renderItem}
|
|
99
99
|
renderSelectedItem={this.renderSelectedItem}
|
|
100
100
|
onSelect={this.handleSelect}
|
|
101
|
-
triggerRender={({ value, inputValue }) => <Button>{inputValue}</Button>}
|
|
101
|
+
triggerRender={({ value, inputValue, onFocus }) => <Button onFocus={onFocus}>{inputValue}</Button>}
|
|
102
102
|
/>
|
|
103
103
|
</div>
|
|
104
104
|
);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Avatar from '
|
|
3
|
-
import Popover from '../../popover/index';
|
|
4
|
-
import AvatarGroup from '../avatarGroup';
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
|
+
import { Avatar,Popover, AvatarGroup, RadioGroup, Radio } from '../../index';
|
|
5
3
|
|
|
6
4
|
export default {
|
|
7
5
|
title: 'Avatar',
|
|
@@ -188,4 +186,63 @@ export const ExtraExtraSmallOverlap = () => (
|
|
|
188
186
|
<Avatar style={{ backgroundColor: '#87d068' }}>YZ</Avatar>
|
|
189
187
|
</AvatarGroup>
|
|
190
188
|
</div>
|
|
191
|
-
);
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
export const focusTest = () => {
|
|
192
|
+
return (
|
|
193
|
+
<>
|
|
194
|
+
<div id='initial_focus_point' tabindex={0} style={{width: 10, height: 10}}></div>
|
|
195
|
+
<Avatar
|
|
196
|
+
alt="a cat 1"
|
|
197
|
+
src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/avatarDemo.jpeg"
|
|
198
|
+
style={{ margin: 4 }}
|
|
199
|
+
onClick={()=>{
|
|
200
|
+
console.log('click avatar 1');
|
|
201
|
+
}}
|
|
202
|
+
/>
|
|
203
|
+
<Avatar
|
|
204
|
+
alt="a cat 2"
|
|
205
|
+
size="small"
|
|
206
|
+
src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/avatarDemo.jpeg"
|
|
207
|
+
style={{ margin: 4 }}
|
|
208
|
+
onClick={()=>{
|
|
209
|
+
console.log('click avatar 2');
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
</>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const srcGroup = {
|
|
217
|
+
'successSrc1': 'https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/avatarDemo.jpeg',
|
|
218
|
+
'successSrc2': 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
|
|
219
|
+
'errorSrc': 'https://xxx.png',
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export const srcChange = () => {
|
|
223
|
+
const [src, setSrc] = useState('successSrc1');
|
|
224
|
+
|
|
225
|
+
const onChange = (e) => {
|
|
226
|
+
setSrc(e.target.value);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<>
|
|
231
|
+
<div>点击选择src类型</div>
|
|
232
|
+
<RadioGroup onChange={onChange} value={src} aria-label="单选组合示例">
|
|
233
|
+
<Radio value={'successSrc1'}>成功的src</Radio>
|
|
234
|
+
<Radio value={'successSrc2'}>成功的src</Radio>
|
|
235
|
+
<Radio value={'errorSrc'}>失败的src</Radio>
|
|
236
|
+
</RadioGroup>
|
|
237
|
+
<br />
|
|
238
|
+
<Avatar
|
|
239
|
+
alt="test image"
|
|
240
|
+
src={srcGroup[src]}
|
|
241
|
+
style={{ margin: 4 }}
|
|
242
|
+
onError={() => {
|
|
243
|
+
console.log('loading error');
|
|
244
|
+
}}
|
|
245
|
+
/>
|
|
246
|
+
</>
|
|
247
|
+
)
|
|
248
|
+
}
|
package/avatar/avatarGroup.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { PureComponent, Fragment } from 'react';
|
|
1
|
+
import React, { PureComponent, Fragment, ReactElement } from 'react';
|
|
2
2
|
import cls from 'classnames';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { get as lodashGet, isFunction, isNumber } from 'lodash';
|
|
@@ -28,7 +28,10 @@ export default class AvatarGroup extends PureComponent<AvatarGroupProps> {
|
|
|
28
28
|
|
|
29
29
|
getAllAvatars() {
|
|
30
30
|
const { children } = this.props;
|
|
31
|
-
|
|
31
|
+
if (children) {
|
|
32
|
+
return Array.isArray(children) ? React.Children.toArray(children) : [children];
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
getMergeAvatars(avatars: React.ReactNode[]) {
|
|
@@ -50,7 +53,16 @@ export default class AvatarGroup extends PureComponent<AvatarGroupProps> {
|
|
|
50
53
|
renderMoreAvatar(restNumber: number, restAvatars: React.ReactNode[]) {
|
|
51
54
|
const { renderMore } = this.props;
|
|
52
55
|
const moreCls = cls(`${prefixCls}-item-more`);
|
|
53
|
-
|
|
56
|
+
const restAvatarAlt = restAvatars?.reduce((pre, cur) => {
|
|
57
|
+
const { children, alt } = (cur as ReactElement).props;
|
|
58
|
+
const avatarInfo = alt ?? ((typeof children === 'string') ? children : '');
|
|
59
|
+
if (avatarInfo.length === 0) {
|
|
60
|
+
return pre;
|
|
61
|
+
}
|
|
62
|
+
return (pre as string).length > 0 ? `${pre},${avatarInfo}` : avatarInfo;
|
|
63
|
+
}, '');
|
|
64
|
+
const finalAlt = ` Number of remaining Avatars:${restNumber},${restAvatarAlt}`;
|
|
65
|
+
let moreAvatar = <Avatar className={moreCls} key="_+n" alt={finalAlt}>{`+${restNumber}`}</Avatar>;
|
|
54
66
|
if (isFunction(renderMore)) {
|
|
55
67
|
moreAvatar = <Fragment key="_+n">{renderMore(restNumber, restAvatars)}</Fragment>;
|
|
56
68
|
}
|
|
@@ -76,6 +88,6 @@ export default class AvatarGroup extends PureComponent<AvatarGroupProps> {
|
|
|
76
88
|
|
|
77
89
|
}
|
|
78
90
|
|
|
79
|
-
return <div className={groupCls}>{inner}</div>;
|
|
91
|
+
return <div className={groupCls} role='list'>{inner}</div>;
|
|
80
92
|
}
|
|
81
93
|
}
|
package/avatar/index.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import '@douyinfe/semi-foundation/avatar/avatar.scss';
|
|
|
7
7
|
import { noop } from '@douyinfe/semi-foundation/utils/function';
|
|
8
8
|
import BaseComponent from '../_base/baseComponent';
|
|
9
9
|
import { AvatarProps } from './interface';
|
|
10
|
+
import { handlePrevent } from '@douyinfe/semi-foundation/utils/a11y';
|
|
10
11
|
|
|
11
12
|
const sizeSet = strings.SIZE;
|
|
12
13
|
const shapeSet = strings.SHAPE;
|
|
@@ -17,6 +18,7 @@ export * from './interface';
|
|
|
17
18
|
export interface AvatarState {
|
|
18
19
|
isImgExist: boolean;
|
|
19
20
|
hoverContent: React.ReactNode;
|
|
21
|
+
focusVisible: boolean;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
@@ -53,10 +55,13 @@ export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
|
53
55
|
this.state = {
|
|
54
56
|
isImgExist: true,
|
|
55
57
|
hoverContent: '',
|
|
58
|
+
focusVisible: false,
|
|
56
59
|
};
|
|
57
60
|
this.onEnter = this.onEnter.bind(this);
|
|
58
61
|
this.onLeave = this.onLeave.bind(this);
|
|
59
62
|
this.handleError = this.handleError.bind(this);
|
|
63
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
64
|
+
this.getContent = this.getContent.bind(this);
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
get adapter(): AvatarAdapter<AvatarProps, AvatarState> {
|
|
@@ -78,7 +83,10 @@ export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
|
78
83
|
const { onMouseLeave } = this.props;
|
|
79
84
|
onMouseLeave && onMouseLeave(e);
|
|
80
85
|
});
|
|
81
|
-
}
|
|
86
|
+
},
|
|
87
|
+
setFocusVisible: (focusVisible: boolean): void => {
|
|
88
|
+
this.setState({ focusVisible });
|
|
89
|
+
},
|
|
82
90
|
};
|
|
83
91
|
}
|
|
84
92
|
|
|
@@ -119,10 +127,82 @@ export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
|
119
127
|
this.foundation.handleImgLoadError();
|
|
120
128
|
}
|
|
121
129
|
|
|
130
|
+
handleKeyDown(event: any) {
|
|
131
|
+
const { onClick } = this.props;
|
|
132
|
+
switch (event.key) {
|
|
133
|
+
case "Enter":
|
|
134
|
+
onClick(event);
|
|
135
|
+
handlePrevent(event);
|
|
136
|
+
break;
|
|
137
|
+
case 'Escape':
|
|
138
|
+
event.target.blur();
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
handleFocusVisible = (event: React.FocusEvent) => {
|
|
146
|
+
this.foundation.handleFocusVisible(event);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
handleBlur = (event: React.FocusEvent) => {
|
|
150
|
+
this.foundation.handleBlur();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
getContent = () => {
|
|
154
|
+
const { children, onClick, imgAttr, src, srcSet, alt } = this.props;
|
|
155
|
+
const { isImgExist } = this.state;
|
|
156
|
+
let content = children;
|
|
157
|
+
const clickable = onClick !== noop;
|
|
158
|
+
const isImg = src && isImgExist;
|
|
159
|
+
const a11yFocusProps = {
|
|
160
|
+
tabIndex: 0,
|
|
161
|
+
onKeyDown: this.handleKeyDown,
|
|
162
|
+
onFocus: this.handleFocusVisible,
|
|
163
|
+
onBlur: this.handleBlur,
|
|
164
|
+
};
|
|
165
|
+
if (isImg) {
|
|
166
|
+
const finalAlt = clickable ? `clickable Avatar: ${alt}` : alt;
|
|
167
|
+
const imgBasicProps = {
|
|
168
|
+
src,
|
|
169
|
+
srcSet,
|
|
170
|
+
onError: this.handleError,
|
|
171
|
+
...imgAttr,
|
|
172
|
+
className: cls({
|
|
173
|
+
[`${prefixCls}-no-focus-visible`]: clickable,
|
|
174
|
+
}),
|
|
175
|
+
};
|
|
176
|
+
const imgProps = clickable ? { ...imgBasicProps, ...a11yFocusProps } : imgBasicProps;
|
|
177
|
+
content = (
|
|
178
|
+
<img alt={finalAlt} {...imgProps}/>
|
|
179
|
+
);
|
|
180
|
+
} else if (typeof children === 'string') {
|
|
181
|
+
const tempAlt = alt ?? children;
|
|
182
|
+
const finalAlt = clickable ? `clickable Avatar: ${tempAlt}` : tempAlt;
|
|
183
|
+
const props = {
|
|
184
|
+
role: 'img',
|
|
185
|
+
'aria-label': finalAlt,
|
|
186
|
+
className: cls(`${prefixCls}-label`,
|
|
187
|
+
{
|
|
188
|
+
[`${prefixCls}-no-focus-visible`]: clickable,
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
};
|
|
192
|
+
const finalProps = clickable ? { ...props, ...a11yFocusProps } : props;
|
|
193
|
+
content = (
|
|
194
|
+
<span className={`${prefixCls}-content`}>
|
|
195
|
+
<span {...finalProps} x-semi-prop="children">{children}</span>
|
|
196
|
+
</span>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return content;
|
|
200
|
+
}
|
|
201
|
+
|
|
122
202
|
render() {
|
|
123
203
|
// eslint-disable-next-line max-len, no-unused-vars
|
|
124
204
|
const { shape, children, size, color, className, hoverMask, onClick, imgAttr, src, srcSet, style, alt, ...others } = this.props;
|
|
125
|
-
const { isImgExist, hoverContent } = this.state;
|
|
205
|
+
const { isImgExist, hoverContent, focusVisible } = this.state;
|
|
126
206
|
const isImg = src && isImgExist;
|
|
127
207
|
const avatarCls = cls(
|
|
128
208
|
prefixCls,
|
|
@@ -131,24 +211,14 @@ export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
|
131
211
|
[`${prefixCls}-${size}`]: size,
|
|
132
212
|
[`${prefixCls}-${color}`]: color && !isImg,
|
|
133
213
|
[`${prefixCls}-img`]: isImg,
|
|
214
|
+
[`${prefixCls}-focus`]: focusVisible,
|
|
134
215
|
},
|
|
135
216
|
className
|
|
136
217
|
);
|
|
137
|
-
|
|
138
|
-
const hoverRender = hoverContent ? (<div className={`${prefixCls}-hover`}>{hoverContent}</div>) : null;
|
|
139
|
-
|
|
140
|
-
content = (
|
|
141
|
-
<img src={src} srcSet={srcSet} onError={this.handleError} alt={alt} {...imgAttr} />
|
|
142
|
-
);
|
|
143
|
-
} else if (typeof children === 'string') {
|
|
144
|
-
content = (
|
|
145
|
-
<span className={`${prefixCls}-content`}>
|
|
146
|
-
<span className={`${prefixCls}-label`}>{children}</span>
|
|
147
|
-
</span>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
218
|
+
|
|
219
|
+
const hoverRender = hoverContent ? (<div className={`${prefixCls}-hover`} x-semi-prop="hoverContent">{hoverContent}</div>) : null;
|
|
220
|
+
|
|
150
221
|
return (
|
|
151
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events
|
|
152
222
|
<span
|
|
153
223
|
{...(others as any)}
|
|
154
224
|
style={style}
|
|
@@ -156,8 +226,9 @@ export default class Avatar extends BaseComponent<AvatarProps, AvatarState> {
|
|
|
156
226
|
onClick={onClick as any}
|
|
157
227
|
onMouseEnter={this.onEnter as any}
|
|
158
228
|
onMouseLeave={this.onLeave as any}
|
|
229
|
+
role='listitem'
|
|
159
230
|
>
|
|
160
|
-
{
|
|
231
|
+
{this.getContent()}
|
|
161
232
|
{hoverRender}
|
|
162
233
|
</span>
|
|
163
234
|
);
|
package/backtop/index.tsx
CHANGED
|
@@ -101,13 +101,17 @@ export default class BackTop extends BaseComponent<BackTopProps, BackTopState> {
|
|
|
101
101
|
className
|
|
102
102
|
);
|
|
103
103
|
const backtopBtn = children ? children : this.renderDefault();
|
|
104
|
-
const content = visible ?
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
const content = visible ? (
|
|
105
|
+
<div
|
|
106
|
+
{...others}
|
|
107
|
+
className={preCls}
|
|
108
|
+
style={style}
|
|
109
|
+
onClick={e => this.handleClick(e)}
|
|
110
|
+
x-semi-prop="children"
|
|
111
|
+
>
|
|
112
|
+
{backtopBtn}
|
|
113
|
+
</div>
|
|
114
|
+
) : null;
|
|
111
115
|
return content;
|
|
112
116
|
}
|
|
113
117
|
}
|
package/badge/index.tsx
CHANGED
|
@@ -82,7 +82,7 @@ export default class Badge extends PureComponent<BadgeProps> {
|
|
|
82
82
|
return (
|
|
83
83
|
<span className={prefixCls} {...rest}>
|
|
84
84
|
{children}
|
|
85
|
-
<span className={wrapper} style={style}>
|
|
85
|
+
<span className={wrapper} style={style} x-semi-prop="count">
|
|
86
86
|
{dot ? null : content}
|
|
87
87
|
</span>
|
|
88
88
|
</span>
|
package/banner/index.tsx
CHANGED
|
@@ -109,7 +109,7 @@ export default class Banner extends BaseComponent<BannerProps, BannerState> {
|
|
|
109
109
|
<Button
|
|
110
110
|
className={`${prefixCls}-close`}
|
|
111
111
|
onClick={this.remove}
|
|
112
|
-
icon={closeIcon || <IconClose aria-hidden={true}/>}
|
|
112
|
+
icon={closeIcon || <IconClose x-semi-prop="closeIcon" aria-hidden={true}/>}
|
|
113
113
|
theme="borderless"
|
|
114
114
|
size="small"
|
|
115
115
|
type="tertiary"
|
|
@@ -137,7 +137,7 @@ export default class Banner extends BaseComponent<BannerProps, BannerState> {
|
|
|
137
137
|
}
|
|
138
138
|
if (iconType) {
|
|
139
139
|
return (
|
|
140
|
-
<div className={iconCls}>
|
|
140
|
+
<div className={iconCls} x-semi-prop="icon">
|
|
141
141
|
{iconType}
|
|
142
142
|
</div>
|
|
143
143
|
);
|
|
@@ -160,13 +160,13 @@ export default class Banner extends BaseComponent<BannerProps, BannerState> {
|
|
|
160
160
|
<div className={`${prefixCls}-content`}>
|
|
161
161
|
{this.renderIcon()}
|
|
162
162
|
<div className={`${prefixCls}-content-body`}>
|
|
163
|
-
{title ? <Typography.Title heading={5} className={`${prefixCls}-title`} component="div">{title}</Typography.Title> : null}
|
|
164
|
-
{description ? <Typography.Paragraph className={`${prefixCls}-description`} component="div">{description}</Typography.Paragraph> : null}
|
|
163
|
+
{title ? <Typography.Title heading={5} className={`${prefixCls}-title`} component="div" x-semi-prop="title">{title}</Typography.Title> : null}
|
|
164
|
+
{description ? <Typography.Paragraph className={`${prefixCls}-description`} component="div" x-semi-prop="description">{description}</Typography.Paragraph> : null}
|
|
165
165
|
</div>
|
|
166
166
|
</div>
|
|
167
167
|
{this.renderCloser()}
|
|
168
168
|
</div>
|
|
169
|
-
{children ? <div className={`${prefixCls}-extra`}>{children}</div> : null}
|
|
169
|
+
{children ? <div className={`${prefixCls}-extra`} x-semi-prop="children">{children}</div> : null}
|
|
170
170
|
</div>
|
|
171
171
|
) : null;
|
|
172
172
|
return banner;
|
package/breadcrumb/index.tsx
CHANGED
|
@@ -167,9 +167,9 @@ class Breadcrumb extends BaseComponent<BreadcrumbProps, BreadcrumbState> {
|
|
|
167
167
|
<span className={`${clsPrefix}-collapse`} key={`more-${itemsLen}`}>
|
|
168
168
|
<span className={`${clsPrefix}-item-wrap`}>
|
|
169
169
|
<span
|
|
170
|
-
role=
|
|
170
|
+
role="button"
|
|
171
171
|
tabIndex={0}
|
|
172
|
-
aria-label=
|
|
172
|
+
aria-label="Expand breadcrumb items"
|
|
173
173
|
className={`${clsPrefix}-item ${clsPrefix}-item-more`}
|
|
174
174
|
onClick={item => this.foundation.handleExpand(item)}
|
|
175
175
|
onKeyPress={e => this.foundation.handleExpandEnterPress(e)}
|
|
@@ -178,7 +178,9 @@ class Breadcrumb extends BaseComponent<BreadcrumbProps, BreadcrumbState> {
|
|
|
178
178
|
{!hasRenderMore && moreType === 'default' && <IconMore />}
|
|
179
179
|
{!hasRenderMore && moreType === 'popover' && this.renderPopoverMore(restItem)}
|
|
180
180
|
</span>
|
|
181
|
-
<span className={`${clsPrefix}-separator`}
|
|
181
|
+
<span className={`${clsPrefix}-separator`} x-semi-prop="separator">
|
|
182
|
+
{this.props.separator}
|
|
183
|
+
</span>
|
|
182
184
|
</span>
|
|
183
185
|
</span>
|
|
184
186
|
);
|
package/button/Button.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/button/constants';
|
|
6
6
|
import '@douyinfe/semi-foundation/button/button.scss';
|
|
7
7
|
import { noop } from '@douyinfe/semi-foundation/utils/function';
|
|
8
|
+
import { omit } from 'lodash';
|
|
8
9
|
|
|
9
10
|
const btnSizes = strings.sizes;
|
|
10
11
|
const { htmlTypes, btnTypes } = strings;
|
|
@@ -93,7 +94,7 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
93
94
|
|
|
94
95
|
const baseProps = {
|
|
95
96
|
disabled,
|
|
96
|
-
...attr,
|
|
97
|
+
...omit(attr, ['x-semi-children-alias']),
|
|
97
98
|
className: classNames(
|
|
98
99
|
prefixCls,
|
|
99
100
|
{
|
|
@@ -113,16 +114,17 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
113
114
|
'aria-disabled': disabled,
|
|
114
115
|
};
|
|
115
116
|
|
|
117
|
+
const xSemiProps = {};
|
|
118
|
+
|
|
119
|
+
if (!(className && className.includes('-with-icon'))) {
|
|
120
|
+
xSemiProps['x-semi-prop'] = this.props['x-semi-children-alias'] || 'children';
|
|
121
|
+
}
|
|
122
|
+
|
|
116
123
|
return (
|
|
117
124
|
// eslint-disable-next-line react/button-has-type
|
|
118
|
-
<button
|
|
119
|
-
{...baseProps}
|
|
120
|
-
onClick={this.props.onClick}
|
|
121
|
-
onMouseDown={this.props.onMouseDown}
|
|
122
|
-
style={style}
|
|
123
|
-
>
|
|
125
|
+
<button {...baseProps} onClick={this.props.onClick} onMouseDown={this.props.onMouseDown} style={style}>
|
|
124
126
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}
|
|
125
|
-
<span className={`${prefixCls}-content`} onClick={e => disabled && e.stopPropagation()}>
|
|
127
|
+
<span className={`${prefixCls}-content`} onClick={e => disabled && e.stopPropagation()} {...xSemiProps}>
|
|
126
128
|
{children}
|
|
127
129
|
</span>
|
|
128
130
|
</button>
|
|
@@ -402,4 +402,128 @@ export const WithLocaleProvider = () => {
|
|
|
402
402
|
|
|
403
403
|
WithLocaleProvider.parameters = {
|
|
404
404
|
chromatic: { disableSnapshot: true }
|
|
405
|
-
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
class EventRenderDemo extends React.Component {
|
|
408
|
+
constructor() {
|
|
409
|
+
super();
|
|
410
|
+
this.state = {
|
|
411
|
+
mode: 'week',
|
|
412
|
+
clickDate: '?'
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
onSelect(e) {
|
|
417
|
+
this.setState({
|
|
418
|
+
mode: e.target.value,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
render() {
|
|
422
|
+
const { mode } = this.state;
|
|
423
|
+
const isMonthView = mode === 'month';
|
|
424
|
+
const dailyEventStyle = {
|
|
425
|
+
borderRadius: '3px',
|
|
426
|
+
boxSizing: 'border-box',
|
|
427
|
+
border: 'var(--semi-color-primary) 1px solid',
|
|
428
|
+
padding: '10px',
|
|
429
|
+
backgroundColor: 'var(--semi-color-primary-light-default)',
|
|
430
|
+
height: '100%',
|
|
431
|
+
overflow: 'hidden',
|
|
432
|
+
};
|
|
433
|
+
const allDayStyle = {
|
|
434
|
+
borderRadius: '3px',
|
|
435
|
+
boxSizing: 'border-box',
|
|
436
|
+
border: 'var(--semi-color-bg-1) 1px solid',
|
|
437
|
+
padding: '2px 4px',
|
|
438
|
+
backgroundColor: 'var(--semi-color-primary-light-active)',
|
|
439
|
+
height: '100%',
|
|
440
|
+
overflow: 'hidden',
|
|
441
|
+
};
|
|
442
|
+
const dailyStyle = isMonthView ? allDayStyle : dailyEventStyle;
|
|
443
|
+
const events = [
|
|
444
|
+
{
|
|
445
|
+
key: '0',
|
|
446
|
+
start: new Date(2019, 5, 25, 14, 45, 0),
|
|
447
|
+
end: new Date(2019, 6, 26, 6, 18, 0),
|
|
448
|
+
children: <div style={dailyStyle}>6月25日 14:45 ~ 7月26日 6:18</div>,
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
key: '1',
|
|
452
|
+
start: new Date(2019, 6, 18, 10, 0, 0),
|
|
453
|
+
end: new Date(2019, 6, 30, 8, 0, 0),
|
|
454
|
+
children: <div style={allDayStyle}>7月18日 10:00 ~ 7月30日 8:00</div>,
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
key: '2',
|
|
458
|
+
start: new Date(2019, 6, 19, 20, 0, 0),
|
|
459
|
+
end: new Date(2019, 6, 23, 14, 0, 0),
|
|
460
|
+
children: <div style={allDayStyle}>7月19日 20:00 ~ 7月23日 14:00</div>,
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
key: '3',
|
|
464
|
+
start: new Date(2019, 6, 21, 6, 0, 0),
|
|
465
|
+
end: new Date(2019, 6, 25, 6, 0, 0),
|
|
466
|
+
children: <div style={allDayStyle}>7月21日 6:00 ~ 7月25日 6:00</div>,
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
key: '4',
|
|
470
|
+
allDay: true,
|
|
471
|
+
start: new Date(2019, 6, 22, 8, 0, 0),
|
|
472
|
+
children: <div style={allDayStyle}>7月22日 全天</div>,
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
key: '5',
|
|
476
|
+
start: new Date(2019, 6, 22, 9, 0, 0),
|
|
477
|
+
end: new Date(2019, 6, 23, 23, 0, 0),
|
|
478
|
+
children: <div style={allDayStyle}>7月22日 9:00 ~ 7月23日 23:00</div>,
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
key: '6',
|
|
482
|
+
start: new Date(2019, 6, 23, 8, 32, 0),
|
|
483
|
+
children: <div style={dailyStyle}>7月23日 8:32</div>,
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
key: '7',
|
|
487
|
+
start: new Date(2019, 6, 23, 14, 30, 0),
|
|
488
|
+
end: new Date(2019, 6, 23, 20, 0, 0),
|
|
489
|
+
children: <div style={dailyStyle}>7月23日 14:30-20:00</div>,
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
key: '8',
|
|
493
|
+
start: new Date(2019, 6, 25, 8, 0, 0),
|
|
494
|
+
end: new Date(2019, 6, 27, 6, 0, 0),
|
|
495
|
+
children: <div style={allDayStyle}>7月25日 8:00 ~ 7月27日 6:00</div>,
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
key: '9',
|
|
499
|
+
start: new Date(2019, 6, 26, 10, 0, 0),
|
|
500
|
+
end: new Date(2019, 6, 27, 16, 0, 0),
|
|
501
|
+
children: <div style={allDayStyle}>7月26日 10:00 ~ 7月27日 16:00</div>,
|
|
502
|
+
},
|
|
503
|
+
];
|
|
504
|
+
const displayValue = new Date(2019, 6, 23, 8, 32, 0);
|
|
505
|
+
return (
|
|
506
|
+
<>
|
|
507
|
+
<RadioGroup onChange={e => this.onSelect(e)} value={mode}>
|
|
508
|
+
<Radio value={'day'}>日视图</Radio>
|
|
509
|
+
<Radio value={'week'}>周视图</Radio>
|
|
510
|
+
<Radio value={'month'}>月视图</Radio>
|
|
511
|
+
<Radio value={'range'}>多日视图</Radio>
|
|
512
|
+
</RadioGroup>
|
|
513
|
+
<br />
|
|
514
|
+
<br />
|
|
515
|
+
<Calendar
|
|
516
|
+
height={400}
|
|
517
|
+
mode={mode}
|
|
518
|
+
displayValue={displayValue}
|
|
519
|
+
events={events}
|
|
520
|
+
onClick={(e, date) => { this.setState({clickDate: date.getDate()}); console.log(date.getDate())}}
|
|
521
|
+
range={mode === 'range' ? [new Date(2019, 6, 23), new Date(2019, 6, 26)] : []}
|
|
522
|
+
></Calendar>
|
|
523
|
+
<div>当前点击的日期是{this.state.clickDate}号</div>
|
|
524
|
+
</>
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export const EventRender = () => <EventRenderDemo />;
|