@douyinfe/semi-ui 2.9.0-beta.1 → 2.10.0-beta.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/anchor/__test__/anchor.test.js +1 -0
- package/anchor/_story/anchor.stories.js +23 -1
- package/badge/_story/badge.stories.js +34 -2
- package/banner/_story/banner.stories.js +62 -1
- package/banner/index.tsx +5 -5
- package/carousel/CarouselArrow.tsx +62 -0
- package/carousel/CarouselIndicator.tsx +84 -0
- package/carousel/__test__/carousel.test.js +159 -0
- package/carousel/_story/carousel.stories.js +486 -0
- package/carousel/index.tsx +294 -0
- package/carousel/interface.ts +64 -0
- package/cascader/_story/cascader.stories.js +17 -2
- package/cascader/index.tsx +2 -3
- package/checkbox/_story/checkbox.stories.js +1 -1
- package/collapse/item.tsx +2 -0
- package/datePicker/_story/datePicker.stories.js +37 -0
- package/dist/css/semi.css +344 -2
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +1068 -330
- 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/hoc/withField.tsx +8 -5
- package/index.ts +2 -0
- package/input/__test__/input.test.js +12 -3
- package/input/__test__/textArea.test.js +53 -0
- package/lib/cjs/banner/index.js +11 -5
- package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
- package/lib/cjs/carousel/CarouselArrow.js +91 -0
- package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
- package/lib/cjs/carousel/CarouselIndicator.js +145 -0
- package/lib/cjs/carousel/index.d.ts +58 -0
- package/lib/cjs/carousel/index.js +345 -0
- package/lib/cjs/carousel/interface.d.ts +62 -0
- package/lib/cjs/carousel/interface.js +7 -0
- package/lib/cjs/cascader/index.js +2 -2
- package/lib/cjs/collapse/item.js +4 -2
- package/lib/cjs/form/hoc/withField.js +6 -4
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +9 -0
- package/lib/cjs/modal/Modal.js +3 -0
- package/lib/cjs/scrollList/scrollItem.js +5 -1
- package/lib/cjs/switch/index.d.ts +3 -0
- package/lib/cjs/switch/index.js +26 -6
- package/lib/cjs/tabs/TabPane.js +4 -0
- package/lib/cjs/tabs/index.js +2 -0
- package/lib/cjs/toast/toast.d.ts +1 -1
- package/lib/cjs/tooltip/index.js +1 -1
- package/lib/cjs/transfer/index.d.ts +1 -0
- package/lib/cjs/transfer/index.js +3 -1
- package/lib/es/banner/index.js +11 -5
- package/lib/es/carousel/CarouselArrow.d.ts +8 -0
- package/lib/es/carousel/CarouselArrow.js +72 -0
- package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
- package/lib/es/carousel/CarouselIndicator.js +125 -0
- package/lib/es/carousel/index.d.ts +58 -0
- package/lib/es/carousel/index.js +311 -0
- package/lib/es/carousel/interface.d.ts +62 -0
- package/lib/es/carousel/interface.js +1 -0
- package/lib/es/cascader/index.js +2 -2
- package/lib/es/collapse/item.js +4 -2
- package/lib/es/form/hoc/withField.js +6 -4
- package/lib/es/index.d.ts +1 -0
- package/lib/es/index.js +1 -0
- package/lib/es/modal/Modal.js +3 -0
- package/lib/es/scrollList/scrollItem.js +5 -1
- package/lib/es/switch/index.d.ts +3 -0
- package/lib/es/switch/index.js +26 -6
- package/lib/es/tabs/TabPane.js +4 -0
- package/lib/es/tabs/index.js +2 -0
- package/lib/es/toast/toast.d.ts +1 -1
- package/lib/es/tooltip/index.js +1 -1
- package/lib/es/transfer/index.d.ts +1 -0
- package/lib/es/transfer/index.js +3 -1
- package/modal/Modal.tsx +2 -0
- package/modal/confirm.tsx +1 -1
- package/overflowList/_story/overflowList.stories.js +44 -0
- package/package.json +9 -9
- package/scrollList/_story/SingleWheelList/index.js +72 -0
- package/scrollList/_story/scrolllist.stories.js +7 -0
- package/scrollList/scrollItem.tsx +4 -1
- package/switch/index.tsx +20 -3
- package/table/__test__/table.test.js +1 -0
- package/tabs/TabPane.tsx +2 -0
- package/tabs/_story/tabs.stories.js +72 -0
- package/tabs/index.tsx +1 -0
- package/tagInput/__test__/tagInput.test.js +11 -11
- package/tagInput/_story/tagInput.stories.js +14 -1
- package/timePicker/TimePicker.tsx +1 -1
- package/timePicker/_story/timepicker.stories.js +20 -1
- package/tooltip/_story/tooltip.stories.js +127 -15
- package/tooltip/index.tsx +1 -1
- package/transfer/index.tsx +4 -1
- package/typography/__test__/typography.test.js +1 -0
- package/upload/__test__/upload.test.js +2 -0
- package/upload/_story/upload.stories.js +2 -2
package/switch/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable max-len
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import cls from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
@@ -33,6 +33,7 @@ export interface SwitchProps {
|
|
|
33
33
|
export interface SwitchState {
|
|
34
34
|
nativeControlChecked: boolean;
|
|
35
35
|
nativeControlDisabled: boolean;
|
|
36
|
+
focusVisible: boolean;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
@@ -74,6 +75,7 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
74
75
|
this.state = {
|
|
75
76
|
nativeControlChecked: false,
|
|
76
77
|
nativeControlDisabled: false,
|
|
78
|
+
focusVisible: false
|
|
77
79
|
};
|
|
78
80
|
this.switchRef = React.createRef();
|
|
79
81
|
this.foundation = new SwitchFoudation(this.adapter);
|
|
@@ -105,14 +107,25 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
105
107
|
setNativeControlDisabled: (nativeControlDisabled: boolean): void => {
|
|
106
108
|
this.setState({ nativeControlDisabled });
|
|
107
109
|
},
|
|
110
|
+
setFocusVisible: (focusVisible: boolean): void => {
|
|
111
|
+
this.setState({ focusVisible });
|
|
112
|
+
},
|
|
108
113
|
notifyChange: (checked: boolean, e: React.ChangeEvent<HTMLInputElement>): void => {
|
|
109
114
|
this.props.onChange(checked, e);
|
|
110
115
|
},
|
|
111
116
|
};
|
|
112
117
|
}
|
|
113
118
|
|
|
119
|
+
handleFocusVisible = (event: React.FocusEvent) => {
|
|
120
|
+
this.foundation.handleFocusVisible(event);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
handleBlur = (event: React.FocusEvent) => {
|
|
124
|
+
this.foundation.handleBlur();
|
|
125
|
+
}
|
|
126
|
+
|
|
114
127
|
render() {
|
|
115
|
-
const { nativeControlChecked, nativeControlDisabled } = this.state;
|
|
128
|
+
const { nativeControlChecked, nativeControlDisabled, focusVisible } = this.state;
|
|
116
129
|
const { className, style, onMouseEnter, onMouseLeave, size, checkedText, uncheckedText, loading, id } = this.props;
|
|
117
130
|
const wrapperCls = cls(className, {
|
|
118
131
|
[cssClasses.PREFIX]: true,
|
|
@@ -121,10 +134,10 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
121
134
|
[cssClasses.LARGE]: size === 'large',
|
|
122
135
|
[cssClasses.SMALL]: size === 'small',
|
|
123
136
|
[cssClasses.LOADING]: loading,
|
|
137
|
+
[cssClasses.FOCUS]: focusVisible,
|
|
124
138
|
});
|
|
125
139
|
const switchProps = {
|
|
126
140
|
type: 'checkbox',
|
|
127
|
-
role: 'switch',
|
|
128
141
|
className: cssClasses.NATIVE_CONTROL,
|
|
129
142
|
disabled: nativeControlDisabled || loading,
|
|
130
143
|
checked: nativeControlChecked || false,
|
|
@@ -157,13 +170,17 @@ class Switch extends BaseComponent<SwitchProps, SwitchState> {
|
|
|
157
170
|
{...switchProps}
|
|
158
171
|
ref={this.switchRef}
|
|
159
172
|
id={id}
|
|
173
|
+
role='switch'
|
|
160
174
|
aria-checked={nativeControlChecked}
|
|
161
175
|
aria-invalid={this.props['aria-invalid']}
|
|
162
176
|
aria-errormessage={this.props['aria-errormessage']}
|
|
163
177
|
aria-label={this.props['aria-label']}
|
|
164
178
|
aria-labelledby={this.props['aria-labelledby']}
|
|
165
179
|
aria-describedby={this.props["aria-describedby"]}
|
|
180
|
+
aria-disabled={this.props['disabled']}
|
|
166
181
|
onChange={e => this.foundation.handleChange(e.target.checked, e)}
|
|
182
|
+
onFocus={e => this.handleFocusVisible(e)}
|
|
183
|
+
onBlur={e => this.handleBlur(e)}
|
|
167
184
|
/>
|
|
168
185
|
</div>
|
|
169
186
|
);
|
package/tabs/TabPane.tsx
CHANGED
|
@@ -53,6 +53,7 @@ class TabPane extends PureComponent<TabPaneProps> {
|
|
|
53
53
|
return false;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
/* istanbul ignore next */
|
|
56
57
|
hideScroll = (): void => {
|
|
57
58
|
if (this.ref && this.ref.current) {
|
|
58
59
|
this.ref.current.style.overflow = 'hidden';
|
|
@@ -60,6 +61,7 @@ class TabPane extends PureComponent<TabPaneProps> {
|
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
|
|
64
|
+
/* istanbul ignore next */
|
|
63
65
|
autoScroll = (): void => {
|
|
64
66
|
if (this.ref && this.ref.current) {
|
|
65
67
|
this.ref.current.style.overflow = '';
|
|
@@ -795,3 +795,75 @@ export const TabSize = () => <TabSizeDemo />;
|
|
|
795
795
|
TabSize.story = {
|
|
796
796
|
name: 'tab size',
|
|
797
797
|
};
|
|
798
|
+
|
|
799
|
+
class TabListChangeDemo extends React.Component {
|
|
800
|
+
constructor() {
|
|
801
|
+
super();
|
|
802
|
+
this.state = {
|
|
803
|
+
itemKey: '1',
|
|
804
|
+
tabList:[
|
|
805
|
+
{
|
|
806
|
+
tab: '文档',
|
|
807
|
+
itemKey: '1',
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
tab: '快速起步',
|
|
811
|
+
itemKey: '2',
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
tab: '帮助',
|
|
815
|
+
itemKey: '3',
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
tab: '关于',
|
|
819
|
+
itemKey: '4',
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
tab: '资源工具',
|
|
823
|
+
itemKey: '5',
|
|
824
|
+
},
|
|
825
|
+
]
|
|
826
|
+
};
|
|
827
|
+
this.onTabClick = this.onTabClick.bind(this);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
onTabClick(itemKey, type) {
|
|
831
|
+
this.setState({
|
|
832
|
+
[type]: itemKey,
|
|
833
|
+
tabList: [{
|
|
834
|
+
tab: '文档',
|
|
835
|
+
itemKey: '1',
|
|
836
|
+
}]
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
render() {
|
|
841
|
+
const contentList = [
|
|
842
|
+
<div>文档</div>,
|
|
843
|
+
<div>快速起步</div>,
|
|
844
|
+
<div>帮助</div>,
|
|
845
|
+
<div>关于</div>,
|
|
846
|
+
<div>资源工具</div>,
|
|
847
|
+
];
|
|
848
|
+
return (
|
|
849
|
+
<Tabs
|
|
850
|
+
style={style}
|
|
851
|
+
type="line"
|
|
852
|
+
tabList={this.state.tabList}
|
|
853
|
+
onTabClick={itemKey => {
|
|
854
|
+
this.onTabClick(itemKey, 'itemKey');
|
|
855
|
+
}}
|
|
856
|
+
>
|
|
857
|
+
{contentList[this.state.itemKey]}
|
|
858
|
+
<span>test</span>
|
|
859
|
+
<span>test2</span>
|
|
860
|
+
</Tabs>
|
|
861
|
+
);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
export const TabListChange = () => <TabListChangeDemo />;
|
|
866
|
+
|
|
867
|
+
TabListChange.story = {
|
|
868
|
+
name: 'tablist change',
|
|
869
|
+
};
|
package/tabs/index.tsx
CHANGED
|
@@ -192,6 +192,7 @@ class Tabs extends BaseComponent<TabsProps, TabsState> {
|
|
|
192
192
|
this.foundation.handleTabClick(activeKey, event);
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
+
/* istanbul ignore next */
|
|
195
196
|
rePosChildren = (children: ReactElement[], activeKey: string): ReactElement[] => {
|
|
196
197
|
const newChildren: ReactElement[] = [];
|
|
197
198
|
|
|
@@ -78,7 +78,7 @@ describe('TagInput', () => {
|
|
|
78
78
|
|
|
79
79
|
it('TagInput with defaultValue and value is undefined', () => {
|
|
80
80
|
const props = {
|
|
81
|
-
defaultValue: ['
|
|
81
|
+
defaultValue: ['semi', 'hotsoon'],
|
|
82
82
|
value: undefined,
|
|
83
83
|
};
|
|
84
84
|
const tagInput = getTagInput(props);
|
|
@@ -89,7 +89,7 @@ describe('TagInput', () => {
|
|
|
89
89
|
|
|
90
90
|
it('TagInput with defaultValue and value is null', () => {
|
|
91
91
|
const props = {
|
|
92
|
-
defaultValue: ['
|
|
92
|
+
defaultValue: ['semi', 'hotsoon'],
|
|
93
93
|
value: null,
|
|
94
94
|
};
|
|
95
95
|
const tagInput = getTagInput(props);
|
|
@@ -123,26 +123,26 @@ describe('TagInput', () => {
|
|
|
123
123
|
/* when separator is null */
|
|
124
124
|
const props2 = {
|
|
125
125
|
separator: null,
|
|
126
|
-
inputValue: '
|
|
126
|
+
inputValue: 'semi-hotsoon'
|
|
127
127
|
}
|
|
128
128
|
const tagInput2 = getTagInput(props2);
|
|
129
129
|
tagInput2.find('input').simulate('keyDown', { keyCode: 13 });
|
|
130
130
|
const tags2 = tagInput2.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|
|
131
131
|
expect(tags2.length).toEqual(1);
|
|
132
|
-
expect(tags2.at(0).getDOMNode().textContent).toEqual('
|
|
132
|
+
expect(tags2.at(0).getDOMNode().textContent).toEqual('semi-hotsoon');
|
|
133
133
|
tagInput2.unmount();
|
|
134
134
|
|
|
135
135
|
/* when separator is number */
|
|
136
136
|
const props3 = {
|
|
137
137
|
separator: 1,
|
|
138
|
-
inputValue: '
|
|
138
|
+
inputValue: 'semi1design'
|
|
139
139
|
}
|
|
140
140
|
const tagInput3 = getTagInput(props3);
|
|
141
141
|
tagInput3.find('input').simulate('keyDown', { keyCode: 13 });
|
|
142
142
|
const tags3 = tagInput3.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|
|
143
143
|
expect(tags3.length).toEqual(2);
|
|
144
|
-
expect(tags3.at(0).getDOMNode().textContent).toEqual('
|
|
145
|
-
expect(tags3.at(1).getDOMNode().textContent).toEqual('
|
|
144
|
+
expect(tags3.at(0).getDOMNode().textContent).toEqual('semi');
|
|
145
|
+
expect(tags3.at(1).getDOMNode().textContent).toEqual('design');
|
|
146
146
|
tagInput3.unmount();
|
|
147
147
|
});
|
|
148
148
|
|
|
@@ -352,10 +352,10 @@ describe('TagInput', () => {
|
|
|
352
352
|
|
|
353
353
|
it('tagInput with set value to null ', () => {
|
|
354
354
|
const props = {
|
|
355
|
-
value: ['
|
|
355
|
+
value: ['semi']
|
|
356
356
|
};
|
|
357
357
|
const tagInput = getTagInput(props);
|
|
358
|
-
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('
|
|
358
|
+
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('semi');
|
|
359
359
|
tagInput.setProps({ value: null });
|
|
360
360
|
tagInput.update();
|
|
361
361
|
const tags = tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|
|
@@ -364,10 +364,10 @@ describe('TagInput', () => {
|
|
|
364
364
|
|
|
365
365
|
it('tagInput with set value to null ', () => {
|
|
366
366
|
const props = {
|
|
367
|
-
value: ['
|
|
367
|
+
value: ['semi']
|
|
368
368
|
};
|
|
369
369
|
const tagInput = getTagInput(props);
|
|
370
|
-
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('
|
|
370
|
+
expect(tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`).getDOMNode().textContent).toEqual('semi');
|
|
371
371
|
tagInput.setProps({ value: undefined });
|
|
372
372
|
tagInput.update();
|
|
373
373
|
const tags = tagInput.find(`.${BASE_CLASS_PREFIX}-tagInput-wrapper .${BASE_CLASS_PREFIX}-tag-content`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Toast, Icon, Button, Avatar } from '@douyinfe/semi-ui/';
|
|
2
|
+
import { Toast, Icon, Button, Avatar, Form } from '@douyinfe/semi-ui/';
|
|
3
3
|
import TagInput from '../index';
|
|
4
4
|
import { IconGift, IconVigoLogo } from '@douyinfe/semi-icons';
|
|
5
5
|
const style = {
|
|
@@ -412,3 +412,16 @@ export const PrefixSuffix = () => (
|
|
|
412
412
|
PrefixSuffix.story = {
|
|
413
413
|
name: 'prefix / suffix',
|
|
414
414
|
};
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
export const TagInputInForm = () => (
|
|
418
|
+
<>
|
|
419
|
+
<Form onSubmit={() => Toast.info('123')}>
|
|
420
|
+
<TagInput showClear />
|
|
421
|
+
</Form>
|
|
422
|
+
</>
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
PrefixSuffix.story = {
|
|
426
|
+
name: 'TagInputInForm'
|
|
427
|
+
};
|
|
@@ -475,7 +475,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
475
475
|
|
|
476
476
|
const panelPrefix = classNames({
|
|
477
477
|
[`${prefixCls}-panel`]: true,
|
|
478
|
-
[`${prefixCls}-panel-${
|
|
478
|
+
[`${prefixCls}-panel-${size}`]: size,
|
|
479
479
|
});
|
|
480
480
|
|
|
481
481
|
const inputProps = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component, useState } from 'react';
|
|
2
2
|
import TimePickerPanel from '../index';
|
|
3
|
-
import { TimePicker as BasicTimePicker, Button } from '../../index';
|
|
3
|
+
import { TimePicker as BasicTimePicker, Button, Form } from '../../index';
|
|
4
4
|
import { strings } from '@douyinfe/semi-foundation/timePicker/constants';
|
|
5
5
|
import { get } from 'lodash';
|
|
6
6
|
|
|
@@ -44,6 +44,12 @@ const init = () => {
|
|
|
44
44
|
init();
|
|
45
45
|
|
|
46
46
|
export const TimePickerPanelDefault = () => {
|
|
47
|
+
const initValues = {
|
|
48
|
+
testRange: [
|
|
49
|
+
new Date("2022-04-17T15:00:00"),
|
|
50
|
+
new Date("2022-04-17T18:00:00"),
|
|
51
|
+
],
|
|
52
|
+
};
|
|
47
53
|
return (
|
|
48
54
|
<div>
|
|
49
55
|
<TimePicker panelHeader={'Time Select'} onChange={val => console.log(val)} />
|
|
@@ -53,6 +59,19 @@ export const TimePickerPanelDefault = () => {
|
|
|
53
59
|
defaultOpen={true}
|
|
54
60
|
scrollItemProps={{ cycled: false }}
|
|
55
61
|
/>
|
|
62
|
+
<TimePicker use12Hours defaultValue={"上午 10:32:33"}/>
|
|
63
|
+
<br/><br/>
|
|
64
|
+
<TimePicker type="timeRange" use12Hours format="a h:mm" defaultValue={["下午 08:11", "上午 11:21"]} />
|
|
65
|
+
<Form initValues={initValues}>
|
|
66
|
+
<pre>{JSON.stringify(initValues)}</pre>
|
|
67
|
+
<Form.TimePicker
|
|
68
|
+
use12Hours
|
|
69
|
+
field="testRange"
|
|
70
|
+
label="Time Range"
|
|
71
|
+
type="timeRange"
|
|
72
|
+
format="a hh:mm"
|
|
73
|
+
/>
|
|
74
|
+
</Form>
|
|
56
75
|
</div>
|
|
57
76
|
);
|
|
58
77
|
};
|
|
@@ -404,6 +404,115 @@ AdjustPosition.story = {
|
|
|
404
404
|
name: '自适应',
|
|
405
405
|
};
|
|
406
406
|
|
|
407
|
+
export const AdjustPosIfNeed = () => {
|
|
408
|
+
const tops = [
|
|
409
|
+
['topLeft', 'TL'],
|
|
410
|
+
['top', 'Top'],
|
|
411
|
+
['topRight', 'TR'],
|
|
412
|
+
];
|
|
413
|
+
const lefts = [
|
|
414
|
+
['leftTop', 'LT'],
|
|
415
|
+
['left', 'Left'],
|
|
416
|
+
['leftBottom', 'LB'],
|
|
417
|
+
];
|
|
418
|
+
const rights = [
|
|
419
|
+
['rightTop', 'RT'],
|
|
420
|
+
['right', 'Right'],
|
|
421
|
+
['rightBottom', 'RB'],
|
|
422
|
+
];
|
|
423
|
+
const bottoms = [
|
|
424
|
+
['bottomLeft', 'BL'],
|
|
425
|
+
['bottom', 'Bottom'],
|
|
426
|
+
['bottomRight', 'BR'],
|
|
427
|
+
];
|
|
428
|
+
|
|
429
|
+
return (
|
|
430
|
+
<div style={{ paddingLeft: 40 }}>
|
|
431
|
+
<div style={{ marginLeft: 40, whiteSpace: 'nowrap' }}>
|
|
432
|
+
{tops.map((pos, index) => (
|
|
433
|
+
<Tooltip
|
|
434
|
+
showArrow
|
|
435
|
+
arrowPointAtCenter
|
|
436
|
+
content={
|
|
437
|
+
<article>
|
|
438
|
+
Hi ByteDancer, this is a tooltip.
|
|
439
|
+
<br /> We have 2 lines.
|
|
440
|
+
</article>
|
|
441
|
+
}
|
|
442
|
+
position={Array.isArray(pos) ? pos[0] : pos}
|
|
443
|
+
key={index}
|
|
444
|
+
>
|
|
445
|
+
<Tag
|
|
446
|
+
style={{ marginRight: '8px' }}
|
|
447
|
+
data-cy={Array.isArray(pos) ? pos[0] : pos}
|
|
448
|
+
>
|
|
449
|
+
{Array.isArray(pos) ? pos[1] : pos}
|
|
450
|
+
</Tag>
|
|
451
|
+
</Tooltip>
|
|
452
|
+
))}
|
|
453
|
+
</div>
|
|
454
|
+
<div style={{ width: 40, float: 'left' }}>
|
|
455
|
+
{lefts.map((pos, index) => (
|
|
456
|
+
<Tooltip
|
|
457
|
+
showArrow
|
|
458
|
+
arrowPointAtCenter
|
|
459
|
+
content={
|
|
460
|
+
<article>
|
|
461
|
+
Hi ByteDancer, this is a tooltip.
|
|
462
|
+
<br /> We have 2 lines.
|
|
463
|
+
</article>
|
|
464
|
+
}
|
|
465
|
+
position={Array.isArray(pos) ? pos[0] : pos}
|
|
466
|
+
key={index}
|
|
467
|
+
>
|
|
468
|
+
<Tag data-cy={Array.isArray(pos) ? pos[0] : pos} style={{ marginBottom: '8px' }}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
|
|
469
|
+
</Tooltip>
|
|
470
|
+
))}
|
|
471
|
+
</div>
|
|
472
|
+
<div style={{ width: 40, marginLeft: 180 }}>
|
|
473
|
+
{rights.map((pos, index) => (
|
|
474
|
+
<Tooltip
|
|
475
|
+
showArrow
|
|
476
|
+
arrowPointAtCenter
|
|
477
|
+
content={
|
|
478
|
+
<article>
|
|
479
|
+
Hi ByteDancer, this is a tooltip.
|
|
480
|
+
<br /> We have 2 lines.
|
|
481
|
+
</article>
|
|
482
|
+
}
|
|
483
|
+
position={Array.isArray(pos) ? pos[0] : pos}
|
|
484
|
+
key={index}
|
|
485
|
+
>
|
|
486
|
+
<Tag data-cy={Array.isArray(pos) ? pos[0] : pos} style={{ marginBottom: '8px' }}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
|
|
487
|
+
</Tooltip>
|
|
488
|
+
))}
|
|
489
|
+
</div>
|
|
490
|
+
<div style={{ marginLeft: 40, clear: 'both', whiteSpace: 'nowrap' }}>
|
|
491
|
+
{bottoms.map((pos, index) => (
|
|
492
|
+
<Tooltip
|
|
493
|
+
showArrow
|
|
494
|
+
arrowPointAtCenter
|
|
495
|
+
content={
|
|
496
|
+
<article>
|
|
497
|
+
Hi ByteDancer, this is a tooltip.
|
|
498
|
+
<br /> We have 2 lines.
|
|
499
|
+
</article>
|
|
500
|
+
}
|
|
501
|
+
position={Array.isArray(pos) ? pos[0] : pos}
|
|
502
|
+
key={index}
|
|
503
|
+
>
|
|
504
|
+
<Tag data-cy={Array.isArray(pos) ? pos[0] : pos} position={Array.isArray(pos) ? pos[0] : pos} style={{ marginRight: '8px' }}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
|
|
505
|
+
</Tooltip>
|
|
506
|
+
))}
|
|
507
|
+
</div>
|
|
508
|
+
</div>
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
AdjustPosIfNeed.story = {
|
|
513
|
+
name: '自适应位置',
|
|
514
|
+
};
|
|
515
|
+
|
|
407
516
|
export const CompositeComponent = () => (
|
|
408
517
|
<div
|
|
409
518
|
style={{
|
|
@@ -764,7 +873,7 @@ export const leftTopOverDemo = () => {
|
|
|
764
873
|
content,
|
|
765
874
|
trigger: 'click',
|
|
766
875
|
showArrow: false,
|
|
767
|
-
visible,
|
|
876
|
+
visible:true,
|
|
768
877
|
trigger: 'custom',
|
|
769
878
|
motion: false,
|
|
770
879
|
};
|
|
@@ -774,34 +883,37 @@ export const leftTopOverDemo = () => {
|
|
|
774
883
|
|
|
775
884
|
return (
|
|
776
885
|
<div data-cy="wrapper">
|
|
777
|
-
<Button onClick={() => setVisible(!visible)}>toggle visible</Button>
|
|
778
|
-
<div style={{ paddingTop:
|
|
886
|
+
<Button onClick={() => setVisible(!visible)} data-cy="toggleVisible">toggle visible</Button>
|
|
887
|
+
<div style={{ paddingTop: 110 }}>
|
|
779
888
|
<Space spacing={80}>
|
|
780
|
-
<Tooltip {...commonProps} position="
|
|
781
|
-
<Button data-cy="leftTopOver" style={buttonStyle}>
|
|
782
|
-
leftTopOver
|
|
783
|
-
</Button>
|
|
784
|
-
</Tooltip>
|
|
785
|
-
<Tooltip {...commonProps} position="leftBottomOver">
|
|
889
|
+
<Tooltip {...commonProps} position="leftBottomOver" trigger="click">
|
|
786
890
|
<Button data-cy="leftBottomOver" style={buttonStyle}>
|
|
787
891
|
leftBottomOver
|
|
788
892
|
</Button>
|
|
789
893
|
</Tooltip>
|
|
790
|
-
<Tooltip {...commonProps} position="
|
|
791
|
-
<Button data-cy="rightTopOver" style={buttonStyle}>
|
|
792
|
-
rightTopOver
|
|
793
|
-
</Button>
|
|
794
|
-
</Tooltip>
|
|
795
|
-
<Tooltip {...commonProps} position="rightBottomOver">
|
|
894
|
+
<Tooltip {...commonProps} position="rightBottomOver" trigger="click">
|
|
796
895
|
<Button data-cy="rightBottomOver" style={buttonStyle}>
|
|
797
896
|
rightBottomOver
|
|
798
897
|
</Button>
|
|
799
898
|
</Tooltip>
|
|
800
899
|
</Space>
|
|
801
900
|
</div>
|
|
901
|
+
<Space spacing={80}>
|
|
902
|
+
<Tooltip {...commonProps} position="leftTopOver" trigger="click">
|
|
903
|
+
<Button data-cy="leftTopOver" style={buttonStyle}>
|
|
904
|
+
leftTopOver
|
|
905
|
+
</Button>
|
|
906
|
+
</Tooltip>
|
|
907
|
+
<Tooltip {...commonProps} position="rightTopOver" trigger="click">
|
|
908
|
+
<Button data-cy="rightTopOver" style={buttonStyle}>
|
|
909
|
+
rightTopOver
|
|
910
|
+
</Button>
|
|
911
|
+
</Tooltip>
|
|
912
|
+
</Space>
|
|
802
913
|
</div>
|
|
803
914
|
);
|
|
804
915
|
};
|
|
916
|
+
|
|
805
917
|
leftTopOverDemo.storyName = `leftTopOver visible`;
|
|
806
918
|
leftTopOverDemo.parameters = {
|
|
807
919
|
chromatic: {
|
package/tooltip/index.tsx
CHANGED
|
@@ -581,7 +581,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
581
581
|
}
|
|
582
582
|
</TooltipTransition>
|
|
583
583
|
) : (
|
|
584
|
-
<div className={className} {...portalEventSet} x-placement={placement} style={{ visibility: motion ?
|
|
584
|
+
<div className={className} {...portalEventSet} x-placement={placement} style={{ visibility: motion ? 'hidden' : 'visible', ...style }}>
|
|
585
585
|
{contentNode}
|
|
586
586
|
{icon}
|
|
587
587
|
</div>
|
package/transfer/index.tsx
CHANGED
|
@@ -60,6 +60,8 @@ export interface SourcePanelProps {
|
|
|
60
60
|
filterData: Array<DataItem>;
|
|
61
61
|
/* All items */
|
|
62
62
|
sourceData: Array<DataItem>;
|
|
63
|
+
/* transfer props' dataSource */
|
|
64
|
+
propsDataSource: DataSource,
|
|
63
65
|
/* Whether to select all */
|
|
64
66
|
allChecked: boolean;
|
|
65
67
|
/* Number of filtered results */
|
|
@@ -359,7 +361,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
|
|
|
359
361
|
|
|
360
362
|
renderLeft(locale: Locale['Transfer']) {
|
|
361
363
|
const { data, selectedItems, inputValue, searchResult } = this.state;
|
|
362
|
-
const { loading, type, emptyContent, renderSourcePanel } = this.props;
|
|
364
|
+
const { loading, type, emptyContent, renderSourcePanel, dataSource } = this.props;
|
|
363
365
|
const totalToken = locale.total;
|
|
364
366
|
const inSearchMode = inputValue !== '';
|
|
365
367
|
const showNumber = inSearchMode ? searchResult.size : data.length;
|
|
@@ -423,6 +425,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
|
|
|
423
425
|
noMatch,
|
|
424
426
|
filterData,
|
|
425
427
|
sourceData: data,
|
|
428
|
+
propsDataSource: dataSource,
|
|
426
429
|
allChecked: !leftContainesNotInSelected,
|
|
427
430
|
showNumber,
|
|
428
431
|
inputValue,
|
|
@@ -24,6 +24,7 @@ describe(`Typography`, () => {
|
|
|
24
24
|
const typographyParagraph = mount(<Typography.Paragraph {...props}>Semi Design</Typography.Paragraph>)
|
|
25
25
|
const p = typographyParagraph.find('div.semi-typography-paragraph');
|
|
26
26
|
expect(p.length).toEqual(1);
|
|
27
|
+
typographyParagraph.unmount();
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
it('typography copyable', () => {
|
|
@@ -564,6 +564,7 @@ describe('Upload', () => {
|
|
|
564
564
|
requests[0].respond(200, { 'Content-Type': 'application/json' }, 'success');
|
|
565
565
|
const previewContent = upload.find(`.${BASE_CLASS_PREFIX}-upload-file-card-preview`);
|
|
566
566
|
expect(previewContent.contains(specificContent)).toEqual(true);
|
|
567
|
+
upload.unmount();
|
|
567
568
|
});
|
|
568
569
|
|
|
569
570
|
it('afterUpload', () => {
|
|
@@ -642,6 +643,7 @@ describe('Upload', () => {
|
|
|
642
643
|
).toEqual(true);
|
|
643
644
|
expect(stateFileList.every(item => item.name !== 'remove.jpg')).toEqual(true);
|
|
644
645
|
expect(stateFileList[3].status === 'uploadFail' && stateFileList[3].name === rename).toEqual(true);
|
|
646
|
+
upload.unmount();
|
|
645
647
|
});
|
|
646
648
|
|
|
647
649
|
it('uploadTrigger', () => {
|
|
@@ -572,8 +572,8 @@ export const Draggable = () => (
|
|
|
572
572
|
<Upload
|
|
573
573
|
{...commonProps}
|
|
574
574
|
draggable={true}
|
|
575
|
-
disabled
|
|
576
|
-
accept="application/
|
|
575
|
+
// disabled
|
|
576
|
+
accept="application/image/*,.md"
|
|
577
577
|
dragMainText={'点击上传文件或拖拽文件到这里'}
|
|
578
578
|
dragSubText="支持的文件类型:.jpg、.pdf"
|
|
579
579
|
></Upload>
|