@douyinfe/semi-ui 2.10.0-alpha.0 → 2.10.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/badge/_story/badge.stories.js +34 -2
- package/banner/_story/banner.stories.js +62 -1
- package/banner/index.tsx +5 -5
- package/button/buttonGroup.tsx +2 -2
- package/carousel/CarouselArrow.tsx +62 -0
- package/carousel/CarouselIndicator.tsx +83 -0
- package/carousel/__test__/carousel.test.js +159 -0
- package/carousel/_story/carousel.stories.js +486 -0
- package/carousel/index.tsx +292 -0
- package/carousel/interface.ts +63 -0
- package/cascader/index.tsx +1 -2
- package/checkbox/checkbox.tsx +8 -18
- package/datePicker/monthsGrid.tsx +8 -8
- package/dist/css/semi.css +343 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +23525 -22602
- 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 +10 -1
- package/form/hoc/withField.tsx +25 -10
- package/index.ts +2 -0
- package/inputNumber/__test__/inputNumber.test.js +40 -3
- package/inputNumber/_story/inputNumber.stories.js +56 -1
- package/inputNumber/index.tsx +22 -14
- package/lib/cjs/_portal/index.d.ts +1 -1
- package/lib/cjs/banner/index.js +11 -5
- package/lib/cjs/button/buttonGroup.d.ts +1 -1
- package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
- package/lib/cjs/carousel/CarouselArrow.js +88 -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 +343 -0
- package/lib/cjs/carousel/interface.d.ts +61 -0
- package/lib/cjs/carousel/interface.js +7 -0
- package/lib/cjs/cascader/index.js +1 -1
- package/lib/cjs/checkbox/checkbox.d.ts +0 -4
- package/lib/cjs/checkbox/checkbox.js +13 -25
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/insetInput.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.js +6 -6
- package/lib/cjs/dropdown/dropdownMenu.d.ts +1 -0
- package/lib/cjs/form/baseForm.d.ts +2 -1
- package/lib/cjs/form/baseForm.js +10 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/hoc/withField.js +14 -5
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +9 -0
- package/lib/cjs/inputNumber/index.d.ts +2 -6
- package/lib/cjs/inputNumber/index.js +27 -11
- package/lib/cjs/modal/useModal/index.d.ts +1 -0
- package/lib/cjs/notification/useNotification/index.d.ts +1 -0
- package/lib/cjs/radio/radio.d.ts +1 -5
- package/lib/cjs/radio/radio.js +12 -26
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/scrollList/scrollItem.js +1 -1
- package/lib/cjs/switch/index.d.ts +3 -0
- package/lib/cjs/switch/index.js +26 -6
- package/lib/cjs/timePicker/Combobox.d.ts +1 -0
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/toast/useToast/index.d.ts +1 -0
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/tooltip/index.js +11 -13
- package/lib/cjs/transfer/index.js +5 -5
- package/lib/cjs/treeSelect/index.js +1 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/upload/index.d.ts +1 -1
- package/lib/es/_portal/index.d.ts +1 -1
- package/lib/es/banner/index.js +11 -5
- package/lib/es/button/buttonGroup.d.ts +1 -1
- package/lib/es/carousel/CarouselArrow.d.ts +8 -0
- package/lib/es/carousel/CarouselArrow.js +70 -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 +309 -0
- package/lib/es/carousel/interface.d.ts +61 -0
- package/lib/es/carousel/interface.js +1 -0
- package/lib/es/cascader/index.js +1 -1
- package/lib/es/checkbox/checkbox.d.ts +0 -4
- package/lib/es/checkbox/checkbox.js +13 -25
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/insetInput.d.ts +1 -0
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.js +7 -7
- package/lib/es/dropdown/dropdownMenu.d.ts +1 -0
- package/lib/es/form/baseForm.d.ts +2 -1
- package/lib/es/form/baseForm.js +10 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +14 -5
- package/lib/es/index.d.ts +1 -0
- package/lib/es/index.js +1 -0
- package/lib/es/inputNumber/index.d.ts +2 -6
- package/lib/es/inputNumber/index.js +26 -11
- package/lib/es/modal/useModal/index.d.ts +1 -0
- package/lib/es/notification/useNotification/index.d.ts +1 -0
- package/lib/es/radio/radio.d.ts +1 -5
- package/lib/es/radio/radio.js +12 -26
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/scrollList/scrollItem.js +1 -1
- package/lib/es/switch/index.d.ts +3 -0
- package/lib/es/switch/index.js +26 -6
- package/lib/es/timePicker/Combobox.d.ts +1 -0
- package/lib/es/timePicker/TimePicker.d.ts +2 -2
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/toast/useToast/index.d.ts +1 -0
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/tooltip/index.js +11 -13
- package/lib/es/transfer/index.js +1 -1
- package/lib/es/treeSelect/index.js +1 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/upload/index.d.ts +1 -1
- package/package.json +9 -9
- package/popover/_story/popover.stories.js +38 -2
- package/radio/radio.tsx +7 -17
- package/scrollList/scrollItem.tsx +1 -1
- package/switch/index.tsx +20 -3
- package/tagInput/__test__/tagInput.test.js +11 -11
- package/timePicker/TimePicker.tsx +1 -1
- package/timePicker/_story/timepicker.stories.js +20 -1
- package/tooltip/index.tsx +11 -8
- package/transfer/index.tsx +1 -1
- package/treeSelect/index.tsx +1 -1
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import Popover from '../index';
|
|
4
4
|
import { strings } from '@douyinfe/semi-foundation/tooltip/constants';
|
|
5
|
-
import { Button, Input, Table, IconButton, Modal, Tag, Space } from '@douyinfe/semi-ui';
|
|
5
|
+
import { Button, Input, Table, IconButton, Modal, Tag, Space, Select } from '@douyinfe/semi-ui';
|
|
6
6
|
import SelectInPopover from './SelectInPopover';
|
|
7
7
|
import BtnClose from './BtnClose';
|
|
8
8
|
import PopRight from './PopRight';
|
|
@@ -10,6 +10,8 @@ import NestedPopover from './NestedPopover';
|
|
|
10
10
|
import ArrowPointAtCenter from './ArrowPointAtCenter';
|
|
11
11
|
import { IconDelete } from '@douyinfe/semi-icons';
|
|
12
12
|
|
|
13
|
+
const Option = Select.Option;
|
|
14
|
+
|
|
13
15
|
export default {
|
|
14
16
|
title: 'Popover',
|
|
15
17
|
parameters: {
|
|
@@ -645,4 +647,38 @@ export const A11yKeyboard = () => {
|
|
|
645
647
|
</div>
|
|
646
648
|
);
|
|
647
649
|
};
|
|
648
|
-
A11yKeyboard.storyName = "a11y keyboard and focus";
|
|
650
|
+
A11yKeyboard.storyName = "a11y keyboard and focus";
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* fix 嵌套 popover 的弹出层会导致外部 popover 关闭问题
|
|
654
|
+
*
|
|
655
|
+
* @see https://github.com/DouyinFE/semi-design/issues/818
|
|
656
|
+
* @see https://github.com/facebook/react/issues/4335#issuecomment-421705171
|
|
657
|
+
*/
|
|
658
|
+
export const FixNestedPopover = () => {
|
|
659
|
+
return (
|
|
660
|
+
<div data-cy="fix-nested-popover" style={{ paddingLeft: 100 }}>
|
|
661
|
+
<Popover
|
|
662
|
+
content={(
|
|
663
|
+
<div data-cy="select-in-popover" style={{ padding: 20 }}>
|
|
664
|
+
<Select
|
|
665
|
+
defaultValue="abc"
|
|
666
|
+
style={{ width: 120 }}
|
|
667
|
+
>
|
|
668
|
+
<Option value="abc">抖音</Option>
|
|
669
|
+
<Option value="hotsoon">火山</Option>
|
|
670
|
+
<Option value="pipixia" disabled>
|
|
671
|
+
皮皮虾
|
|
672
|
+
</Option>
|
|
673
|
+
<Option value="xigua">西瓜视频</Option>
|
|
674
|
+
</Select>
|
|
675
|
+
</div>
|
|
676
|
+
)}
|
|
677
|
+
trigger="click"
|
|
678
|
+
showArrow
|
|
679
|
+
>
|
|
680
|
+
<Tag>点击此处</Tag>
|
|
681
|
+
</Popover>
|
|
682
|
+
</div>
|
|
683
|
+
);
|
|
684
|
+
}
|
package/radio/radio.tsx
CHANGED
|
@@ -41,14 +41,10 @@ export type RadioProps = {
|
|
|
41
41
|
addonClassName?: string;
|
|
42
42
|
type?: RadioType;
|
|
43
43
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
44
|
-
addonId?: string;
|
|
45
|
-
extraId?: string;
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
export interface RadioState {
|
|
49
47
|
hover?: boolean;
|
|
50
|
-
addonId?: string;
|
|
51
|
-
extraId?: string;
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
export { RadioChangeEvent };
|
|
@@ -98,11 +94,11 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
98
94
|
super(props);
|
|
99
95
|
this.state = {
|
|
100
96
|
hover: false,
|
|
101
|
-
addonId: props.addonId,
|
|
102
|
-
extraId: props.extraId,
|
|
103
97
|
};
|
|
104
98
|
this.foundation = new RadioFoundation(this.adapter);
|
|
105
99
|
this.radioEntity = null;
|
|
100
|
+
this.addonId = getUuidShort({ prefix: 'addon' });
|
|
101
|
+
this.extraId = getUuidShort({ prefix: 'extra' });
|
|
106
102
|
}
|
|
107
103
|
|
|
108
104
|
get adapter(): RadioAdapter {
|
|
@@ -110,12 +106,6 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
110
106
|
...super.adapter,
|
|
111
107
|
setHover: (hover: boolean) => {
|
|
112
108
|
this.setState({ hover });
|
|
113
|
-
},
|
|
114
|
-
setAddonId: () => {
|
|
115
|
-
this.setState({ addonId: getUuidShort({ prefix: 'addon' }) });
|
|
116
|
-
},
|
|
117
|
-
setExtraId: () => {
|
|
118
|
-
this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
|
|
119
109
|
}
|
|
120
110
|
};
|
|
121
111
|
}
|
|
@@ -178,7 +168,7 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
178
168
|
isButtonRadioComponent,
|
|
179
169
|
buttonSize,
|
|
180
170
|
realPrefixCls;
|
|
181
|
-
const
|
|
171
|
+
const isHover = this.state.hover;
|
|
182
172
|
let props = {};
|
|
183
173
|
|
|
184
174
|
if (this.isInGroup()) {
|
|
@@ -228,8 +218,8 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
228
218
|
}, addonClassName);
|
|
229
219
|
const renderContent = () => (
|
|
230
220
|
<>
|
|
231
|
-
{children ? <span className={addonCls} style={addonStyle} id={addonId}>{children}</span> : null}
|
|
232
|
-
{extra && !isButtonRadio ? <div className={`${prefix}-extra`} id={extraId}>{extra}</div> : null}
|
|
221
|
+
{children ? <span className={addonCls} style={addonStyle} id={this.addonId}>{children}</span> : null}
|
|
222
|
+
{extra && !isButtonRadio ? <div className={`${prefix}-extra`} id={this.extraId}>{extra}</div> : null}
|
|
233
223
|
</>
|
|
234
224
|
);
|
|
235
225
|
return (
|
|
@@ -250,8 +240,8 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
250
240
|
ref={(ref: RadioInner) => {
|
|
251
241
|
this.radioEntity = ref;
|
|
252
242
|
}}
|
|
253
|
-
addonId={children && addonId}
|
|
254
|
-
extraId={extra && extraId}
|
|
243
|
+
addonId={children && this.addonId}
|
|
244
|
+
extraId={extra && this.extraId}
|
|
255
245
|
/>
|
|
256
246
|
{
|
|
257
247
|
isCardRadioGroup ?
|
|
@@ -329,7 +329,7 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
|
|
|
329
329
|
const { wrapper } = this;
|
|
330
330
|
const wrapperHeight = wrapper.offsetHeight;
|
|
331
331
|
const itemHeight = this.getItmHeight(node);
|
|
332
|
-
const targetTop =
|
|
332
|
+
const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2 ) - (wrapperHeight - itemHeight) / 2;
|
|
333
333
|
|
|
334
334
|
this.scrollToPos(targetTop, duration);
|
|
335
335
|
};
|
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
|
);
|
|
@@ -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`);
|
|
@@ -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
|
};
|
package/tooltip/index.tsx
CHANGED
|
@@ -75,7 +75,6 @@ export interface TooltipProps extends BaseProps {
|
|
|
75
75
|
guardFocus?: boolean;
|
|
76
76
|
returnFocusOnClose?: boolean;
|
|
77
77
|
onEscKeyDown?: (e: React.KeyboardEvent) => void;
|
|
78
|
-
wrapperId?: string;
|
|
79
78
|
}
|
|
80
79
|
interface TooltipState {
|
|
81
80
|
visible: boolean;
|
|
@@ -194,7 +193,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
194
193
|
placement: props.position || 'top',
|
|
195
194
|
transitionStyle: {},
|
|
196
195
|
isPositionUpdated: false,
|
|
197
|
-
id:
|
|
196
|
+
id: getUuidShort(), // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
|
|
198
197
|
};
|
|
199
198
|
this.foundation = new TooltipFoundation(this.adapter);
|
|
200
199
|
this.eventManager = new Event();
|
|
@@ -344,11 +343,11 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
344
343
|
cb();
|
|
345
344
|
}
|
|
346
345
|
};
|
|
347
|
-
|
|
346
|
+
window.addEventListener('mousedown', this.clickOutsideHandler);
|
|
348
347
|
},
|
|
349
348
|
unregisterClickOutsideHandler: () => {
|
|
350
349
|
if (this.clickOutsideHandler) {
|
|
351
|
-
|
|
350
|
+
window.removeEventListener('mousedown', this.clickOutsideHandler);
|
|
352
351
|
this.clickOutsideHandler = null;
|
|
353
352
|
}
|
|
354
353
|
},
|
|
@@ -429,9 +428,6 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
429
428
|
},
|
|
430
429
|
notifyEscKeydown: (event: React.KeyboardEvent) => {
|
|
431
430
|
this.props.onEscKeyDown(event);
|
|
432
|
-
},
|
|
433
|
-
setId: () => {
|
|
434
|
-
this.setState({ id: getUuidShort() });
|
|
435
431
|
}
|
|
436
432
|
};
|
|
437
433
|
}
|
|
@@ -532,6 +528,12 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
532
528
|
}
|
|
533
529
|
};
|
|
534
530
|
|
|
531
|
+
handlePortalMouseDown = (e: React.MouseEvent) => {
|
|
532
|
+
if (this.props.stopPropagation) {
|
|
533
|
+
stopPropagation(e);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
535
537
|
handlePortalInnerKeyDown = (e: React.KeyboardEvent) => {
|
|
536
538
|
this.foundation.handleContainerKeydown(e);
|
|
537
539
|
}
|
|
@@ -585,7 +587,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
585
587
|
}
|
|
586
588
|
</TooltipTransition>
|
|
587
589
|
) : (
|
|
588
|
-
<div className={className} {...portalEventSet} x-placement={placement} style={{ visibility: motion ?
|
|
590
|
+
<div className={className} {...portalEventSet} x-placement={placement} style={{ visibility: motion ? 'hidden' : 'visible', ...style }}>
|
|
589
591
|
{contentNode}
|
|
590
592
|
{icon}
|
|
591
593
|
</div>
|
|
@@ -599,6 +601,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
599
601
|
style={portalInnerStyle}
|
|
600
602
|
ref={this.setContainerEl}
|
|
601
603
|
onClick={this.handlePortalInnerClick}
|
|
604
|
+
onMouseDown={this.handlePortalMouseDown}
|
|
602
605
|
onKeyDown={this.handlePortalInnerKeyDown}
|
|
603
606
|
>
|
|
604
607
|
{inner}
|
package/transfer/index.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { SortableContainer, SortableElement, SortableHandle } from 'react-sortab
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { isEqual, noop, omit, isEmpty, isArray } from 'lodash';
|
|
6
6
|
import TransferFoundation, { TransferAdapter, BasicDataItem, OnSortEndProps } from '@douyinfe/semi-foundation/transfer/foundation';
|
|
7
|
-
import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/transfer/
|
|
7
|
+
import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/transfer/transferUtils';
|
|
8
8
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/transfer/constants';
|
|
9
9
|
import '@douyinfe/semi-foundation/transfer/transfer.scss';
|
|
10
10
|
import BaseComponent from '../_base/baseComponent';
|
package/treeSelect/index.tsx
CHANGED