@douyinfe/semi-ui 2.9.0-beta.1 → 2.9.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.
Files changed (48) hide show
  1. package/anchor/__test__/anchor.test.js +1 -0
  2. package/anchor/_story/anchor.stories.js +23 -1
  3. package/cascader/_story/cascader.stories.js +17 -2
  4. package/cascader/index.tsx +1 -1
  5. package/checkbox/_story/checkbox.stories.js +1 -1
  6. package/collapse/item.tsx +2 -0
  7. package/datePicker/_story/datePicker.stories.js +37 -0
  8. package/dist/css/semi.css +1 -2
  9. package/dist/css/semi.min.css +1 -1
  10. package/dist/umd/semi-ui.js +27 -6
  11. package/dist/umd/semi-ui.js.map +1 -1
  12. package/dist/umd/semi-ui.min.js +1 -1
  13. package/dist/umd/semi-ui.min.js.map +1 -1
  14. package/input/__test__/input.test.js +12 -3
  15. package/input/__test__/textArea.test.js +53 -0
  16. package/lib/cjs/cascader/index.js +1 -1
  17. package/lib/cjs/collapse/item.js +4 -2
  18. package/lib/cjs/modal/Modal.js +3 -0
  19. package/lib/cjs/scrollList/scrollItem.js +4 -0
  20. package/lib/cjs/tabs/TabPane.js +4 -0
  21. package/lib/cjs/tabs/index.js +2 -0
  22. package/lib/cjs/transfer/index.d.ts +1 -0
  23. package/lib/cjs/transfer/index.js +3 -1
  24. package/lib/es/cascader/index.js +1 -1
  25. package/lib/es/collapse/item.js +4 -2
  26. package/lib/es/modal/Modal.js +3 -0
  27. package/lib/es/scrollList/scrollItem.js +4 -0
  28. package/lib/es/tabs/TabPane.js +4 -0
  29. package/lib/es/tabs/index.js +2 -0
  30. package/lib/es/transfer/index.d.ts +1 -0
  31. package/lib/es/transfer/index.js +3 -1
  32. package/modal/Modal.tsx +2 -0
  33. package/modal/confirm.tsx +1 -1
  34. package/overflowList/_story/overflowList.stories.js +44 -0
  35. package/package.json +9 -9
  36. package/scrollList/_story/SingleWheelList/index.js +72 -0
  37. package/scrollList/_story/scrolllist.stories.js +7 -0
  38. package/scrollList/scrollItem.tsx +3 -0
  39. package/table/__test__/table.test.js +1 -0
  40. package/tabs/TabPane.tsx +2 -0
  41. package/tabs/_story/tabs.stories.js +72 -0
  42. package/tabs/index.tsx +1 -0
  43. package/tagInput/_story/tagInput.stories.js +14 -1
  44. package/tooltip/_story/tooltip.stories.js +127 -15
  45. package/transfer/index.tsx +4 -1
  46. package/typography/__test__/typography.test.js +1 -0
  47. package/upload/__test__/upload.test.js +2 -0
  48. package/upload/_story/upload.stories.js +2 -2
@@ -113,9 +113,18 @@ describe('Input', () => {
113
113
  });
114
114
 
115
115
  it('input password mode', () => {
116
- const inputMode = mount(<Input mode="password" />);
117
- const input = inputMode.find('input');
118
- expect(input.instance().type).toEqual('password');
116
+ const inputMode = mount(<Input />);
117
+ expect(inputMode.find('input').instance().type).toEqual('text');
118
+ inputMode.setProps({ mode: 'password' }) ;
119
+ expect(inputMode.find('input').instance().type).toEqual('password');
120
+ inputMode.setProps({ mode: '' }) ;
121
+ expect(inputMode.find('input').instance().type).toEqual('text');
122
+ });
123
+
124
+ it('input password click eyes icon', () => {
125
+ const inputMode = mount(<Input mode='password' defaultValue="123456" autofocus/>);
126
+ inputMode.simulate('mouseEnter', {}).find(`.${BASE_CLASS_PREFIX}-input-modebtn`).simulate('click');
127
+ expect(inputMode.find('input').instance().type).toEqual('text');
119
128
  });
120
129
 
121
130
  it('input controlled mode', () => {
@@ -116,4 +116,57 @@ describe('TextArea', () => {
116
116
  const counter2 = textarea.find(`.${BASE_CLASS_PREFIX}-input-textarea-counter`);
117
117
  expect(counter2.hasClass('semi-input-textarea-counter-exceed')).toEqual(false);
118
118
  });
119
+
120
+ it('test minLength', () => {
121
+ let inputValue = '💖💖💖';
122
+ let inputValue1 = '💖💖💖💖';
123
+ let minLength = 4;
124
+ let event = { target: { value: inputValue } };
125
+ let event1 = { target: { value: inputValue1 } };
126
+
127
+ let onChange = value => {
128
+ console.log(value);
129
+ };
130
+ let spyOnChange = sinon.spy(onChange);
131
+ const textArea = mount(<TextArea onChange={spyOnChange} minLength={minLength} getValueLength={getValueLength} />);
132
+ const textAreaDom = textArea.find('textarea');
133
+
134
+ textAreaDom.simulate('change', event);
135
+ expect(spyOnChange.calledOnce).toBe(true);
136
+ expect(spyOnChange.calledWithMatch(textAreaDom)).toBe(true);
137
+ expect(textAreaDom.instance().minLength).toEqual(inputValue.length + (minLength - getValueLength(inputValue)));
138
+
139
+ textAreaDom.simulate('change', event1);
140
+ expect(spyOnChange.calledWithMatch(textAreaDom)).toBe(true);
141
+ expect(textAreaDom.instance().minLength).toEqual(minLength)
142
+ });
143
+
144
+ it('test maxLength + truncateValue', () => {
145
+ function truncateValue(inputValue, maxLength, getValueLength) {
146
+ let event = { target: { value: inputValue } };
147
+ let onChange = value => {
148
+ console.log(value);
149
+ };
150
+
151
+ let spyOnChange = sinon.spy(onChange);
152
+ const textArea = mount(<TextArea onChange={spyOnChange} maxLength={maxLength} getValueLength={getValueLength} />);
153
+ const textAreaDom = textArea.find('textarea');
154
+ textAreaDom.simulate('change', event);
155
+ expect(spyOnChange.calledOnce).toBe(true);
156
+ return textAreaDom.instance().value;
157
+ }
158
+
159
+ const testCases = [
160
+ // 自定义valueLength
161
+ ['Semi', 5, getValueLength, 'Semi'],
162
+ ['Semi Design', 4, getValueLength, 'Semi'],
163
+ ['💖💖💖💖💖💖💖💖💖💖👨👩👧👦', 10, getValueLength, '💖💖💖💖💖💖💖💖💖💖'],
164
+ ['💖', -1, getValueLength, ''],
165
+ ['🆗', 1, getValueLength, '🆗'],
166
+ ];
167
+
168
+ for (let [value, length, fc, result] of testCases) {
169
+ expect(truncateValue(value, length, fc)).toBe(result);
170
+ }
171
+ })
119
172
  })
@@ -423,7 +423,7 @@ class Cascader extends _baseComponent.default {
423
423
 
424
424
  this.handleClearEnterPress = e => {
425
425
  e && e.stopPropagation();
426
- this.foundation.handleClearEnterPress();
426
+ this.foundation.handleClearEnterPress(e);
427
427
  };
428
428
 
429
429
  this.showClearBtn = () => {
@@ -103,9 +103,11 @@ class CollapsePanel extends _react.PureComponent {
103
103
  className,
104
104
  children,
105
105
  itemKey,
106
- reCalcKey
106
+ reCalcKey,
107
+ header,
108
+ extra
107
109
  } = _a,
108
- restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey"]);
110
+ restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey", "header", "extra"]);
109
111
 
110
112
  const {
111
113
  keepDOM,
@@ -253,6 +253,9 @@ class Modal extends _baseComponent.default {
253
253
  this.props.onOk(e);
254
254
  },
255
255
  notifyClose: () => {
256
+ var _a, _b;
257
+
258
+ (_b = (_a = this.props.motion) === null || _a === void 0 ? void 0 : _a.didLeave) === null || _b === void 0 ? void 0 : _b.call(_a);
256
259
  this.props.afterClose();
257
260
  },
258
261
  toggleHidden: (hidden, callback) => {
@@ -71,6 +71,8 @@ class ScrollItem extends _baseComponent.default {
71
71
  this._cacheSelectorNode = selector => this._cacheNode('selector', selector);
72
72
 
73
73
  this._cacheWrapperNode = wrapper => this._cacheNode('wrapper', wrapper);
74
+ /* istanbul ignore next */
75
+
74
76
 
75
77
  this._isFirst = node => {
76
78
  const {
@@ -85,6 +87,8 @@ class ScrollItem extends _baseComponent.default {
85
87
 
86
88
  return false;
87
89
  };
90
+ /* istanbul ignore next */
91
+
88
92
 
89
93
  this._isLast = node => {
90
94
  const {
@@ -75,6 +75,8 @@ class TabPane extends _react.PureComponent {
75
75
 
76
76
  return false;
77
77
  };
78
+ /* istanbul ignore next */
79
+
78
80
 
79
81
  this.hideScroll = () => {
80
82
  if (this.ref && this.ref.current) {
@@ -82,6 +84,8 @@ class TabPane extends _react.PureComponent {
82
84
  this.isAnimating = true;
83
85
  }
84
86
  };
87
+ /* istanbul ignore next */
88
+
85
89
 
86
90
  this.autoScroll = () => {
87
91
  if (this.ref && this.ref.current) {
@@ -112,6 +112,8 @@ class Tabs extends _baseComponent.default {
112
112
  this.onTabClick = (activeKey, event) => {
113
113
  this.foundation.handleTabClick(activeKey, event);
114
114
  };
115
+ /* istanbul ignore next */
116
+
115
117
 
116
118
  this.rePosChildren = (children, activeKey) => {
117
119
  const newChildren = [];
@@ -39,6 +39,7 @@ export interface SourcePanelProps {
39
39
  noMatch: boolean;
40
40
  filterData: Array<DataItem>;
41
41
  sourceData: Array<DataItem>;
42
+ propsDataSource: DataSource;
42
43
  allChecked: boolean;
43
44
  showNumber: number;
44
45
  inputValue: string;
@@ -296,7 +296,8 @@ class Transfer extends _baseComponent.default {
296
296
  loading,
297
297
  type,
298
298
  emptyContent,
299
- renderSourcePanel
299
+ renderSourcePanel,
300
+ dataSource
300
301
  } = this.props;
301
302
  const totalToken = locale.total;
302
303
  const inSearchMode = inputValue !== '';
@@ -356,6 +357,7 @@ class Transfer extends _baseComponent.default {
356
357
  noMatch,
357
358
  filterData,
358
359
  sourceData: data,
360
+ propsDataSource: dataSource,
359
361
  allChecked: !leftContainesNotInSelected,
360
362
  showNumber,
361
363
  inputValue,
@@ -366,7 +366,7 @@ class Cascader extends BaseComponent {
366
366
 
367
367
  this.handleClearEnterPress = e => {
368
368
  e && e.stopPropagation();
369
- this.foundation.handleClearEnterPress();
369
+ this.foundation.handleClearEnterPress(e);
370
370
  };
371
371
 
372
372
  this.showClearBtn = () => {
@@ -72,9 +72,11 @@ export default class CollapsePanel extends PureComponent {
72
72
  className,
73
73
  children,
74
74
  itemKey,
75
- reCalcKey
75
+ reCalcKey,
76
+ header,
77
+ extra
76
78
  } = _a,
77
- restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey"]);
79
+ restProps = __rest(_a, ["className", "children", "itemKey", "reCalcKey", "header", "extra"]);
78
80
 
79
81
  const {
80
82
  keepDOM,
@@ -214,6 +214,9 @@ class Modal extends BaseComponent {
214
214
  this.props.onOk(e);
215
215
  },
216
216
  notifyClose: () => {
217
+ var _a, _b;
218
+
219
+ (_b = (_a = this.props.motion) === null || _a === void 0 ? void 0 : _a.didLeave) === null || _b === void 0 ? void 0 : _b.call(_a);
217
220
  this.props.afterClose();
218
221
  },
219
222
  toggleHidden: (hidden, callback) => {
@@ -39,6 +39,8 @@ export default class ScrollItem extends BaseComponent {
39
39
  this._cacheSelectorNode = selector => this._cacheNode('selector', selector);
40
40
 
41
41
  this._cacheWrapperNode = wrapper => this._cacheNode('wrapper', wrapper);
42
+ /* istanbul ignore next */
43
+
42
44
 
43
45
  this._isFirst = node => {
44
46
  const {
@@ -55,6 +57,8 @@ export default class ScrollItem extends BaseComponent {
55
57
 
56
58
  return false;
57
59
  };
60
+ /* istanbul ignore next */
61
+
58
62
 
59
63
  this._isLast = node => {
60
64
  const {
@@ -48,6 +48,8 @@ class TabPane extends PureComponent {
48
48
 
49
49
  return false;
50
50
  };
51
+ /* istanbul ignore next */
52
+
51
53
 
52
54
  this.hideScroll = () => {
53
55
  if (this.ref && this.ref.current) {
@@ -55,6 +57,8 @@ class TabPane extends PureComponent {
55
57
  this.isAnimating = true;
56
58
  }
57
59
  };
60
+ /* istanbul ignore next */
61
+
58
62
 
59
63
  this.autoScroll = () => {
60
64
  if (this.ref && this.ref.current) {
@@ -49,6 +49,8 @@ class Tabs extends BaseComponent {
49
49
  this.onTabClick = (activeKey, event) => {
50
50
  this.foundation.handleTabClick(activeKey, event);
51
51
  };
52
+ /* istanbul ignore next */
53
+
52
54
 
53
55
  this.rePosChildren = (children, activeKey) => {
54
56
  const newChildren = [];
@@ -39,6 +39,7 @@ export interface SourcePanelProps {
39
39
  noMatch: boolean;
40
40
  filterData: Array<DataItem>;
41
41
  sourceData: Array<DataItem>;
42
+ propsDataSource: DataSource;
42
43
  allChecked: boolean;
43
44
  showNumber: number;
44
45
  inputValue: string;
@@ -254,7 +254,8 @@ class Transfer extends BaseComponent {
254
254
  loading,
255
255
  type,
256
256
  emptyContent,
257
- renderSourcePanel
257
+ renderSourcePanel,
258
+ dataSource
258
259
  } = this.props;
259
260
  const totalToken = locale.total;
260
261
  const inSearchMode = inputValue !== '';
@@ -312,6 +313,7 @@ class Transfer extends BaseComponent {
312
313
  noMatch,
313
314
  filterData,
314
315
  sourceData: data,
316
+ propsDataSource: dataSource,
315
317
  allChecked: !leftContainesNotInSelected,
316
318
  showNumber,
317
319
  inputValue,
package/modal/Modal.tsx CHANGED
@@ -15,6 +15,7 @@ import confirm, { withConfirm, withError, withInfo, withSuccess, withWarning } f
15
15
  import { Locale } from '../locale/interface';
16
16
  import useModal from './useModal';
17
17
  import { ButtonProps } from '../button/Button';
18
+ import { MotionObject } from "@douyinfe/semi-foundation/utils/type";
18
19
 
19
20
  export const destroyFns: any[] = [];
20
21
  export type ConfirmType = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
@@ -156,6 +157,7 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
156
157
  this.props.onOk(e);
157
158
  },
158
159
  notifyClose: () => {
160
+ (this.props.motion as MotionObject)?.didLeave?.();
159
161
  this.props.afterClose();
160
162
  },
161
163
  toggleHidden: (hidden: boolean, callback?: (hidden: boolean) => void) => {
package/modal/confirm.tsx CHANGED
@@ -118,4 +118,4 @@ export function withConfirm(props: ModalReactProps) {
118
118
  icon: <IconHelpCircle />,
119
119
  ...props
120
120
  };
121
- }
121
+ }
@@ -352,5 +352,49 @@ const LargeData = () => {
352
352
  );
353
353
  };
354
354
 
355
+ export const OverflowListWithSlide = () =>{
356
+ const [width, setWidth] = useState(100);
357
+ const renderOverflow = items => {
358
+ return items.length ? <Tag style={{ flex: '0 0 auto' }}>+{items.length}</Tag> : null;
359
+ };
360
+ const renderItem = (item, ind) => {
361
+ return (
362
+ <Tag color="blue" key={item.key} style={{ marginRight: 8, flex: '0 0 auto' }}>
363
+ {item.icon}
364
+ {item.key}
365
+ </Tag>
366
+ );
367
+ };
368
+
369
+ const items = [
370
+ { icon: <IconAlarm style={{ marginRight: 4 }} />, key: 'alarm' },
371
+ { icon: <IconBookmark style={{ marginRight: 4 }} />, key: 'bookmark' },
372
+ { icon: <IconCamera style={{ marginRight: 4 }} />, key: 'camera' },
373
+ { icon: <IconDuration style={{ marginRight: 4 }} />, key: 'duration' },
374
+ { icon: <IconEdit style={{ marginRight: 4 }} />, key: 'edit' },
375
+ { icon: <IconFolder style={{ marginRight: 4 }} />, key: 'folder' },
376
+ ];
377
+
378
+ return (
379
+ <div>
380
+ <Slider step={1} value={width} onChange={value => setWidth(value)} />
381
+ <br />
382
+ <br />
383
+ <div style={{ width: `${width}%` }}>
384
+ <OverflowList
385
+ items={items}
386
+ // minVisibleItems={3}
387
+ overflowRenderer={renderOverflow}
388
+ visibleItemRenderer={renderItem}
389
+ />
390
+ </div>
391
+ </div>
392
+ );
393
+ }
394
+
395
+ OverflowListWithSlide.story = {
396
+ name: 'overflowList with slide',
397
+ };
398
+
355
399
  // TODO large data will cause memory heap
356
400
  // stories.add('large amount of data', () => <LargeData />);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.9.0-beta.1",
3
+ "version": "2.9.0",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
- "@douyinfe/semi-animation": "2.9.0-beta.1",
18
- "@douyinfe/semi-animation-react": "2.9.0-beta.1",
19
- "@douyinfe/semi-foundation": "2.9.0-beta.1",
20
- "@douyinfe/semi-icons": "2.9.0-beta.1",
21
- "@douyinfe/semi-illustrations": "2.9.0-beta.1",
22
- "@douyinfe/semi-theme-default": "2.9.0-beta.1",
17
+ "@douyinfe/semi-animation": "2.9.0",
18
+ "@douyinfe/semi-animation-react": "2.9.0",
19
+ "@douyinfe/semi-foundation": "2.9.0",
20
+ "@douyinfe/semi-icons": "2.9.0",
21
+ "@douyinfe/semi-illustrations": "2.9.0",
22
+ "@douyinfe/semi-theme-default": "2.9.0",
23
23
  "@types/react-window": "^1.8.2",
24
24
  "async-validator": "^3.5.0",
25
25
  "classnames": "^2.2.6",
@@ -69,13 +69,13 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "b246f204d2f33e5de4155b5d0377eace25b6456f",
72
+ "gitHead": "22b74e58077b068daa6b35bc8b32f47a064734a3",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",
76
76
  "@babel/preset-env": "^7.15.8",
77
77
  "@babel/preset-react": "^7.14.5",
78
- "@douyinfe/semi-scss-compile": "2.9.0-beta.1",
78
+ "@douyinfe/semi-scss-compile": "2.9.0",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "babel-loader": "^8.2.2",
@@ -0,0 +1,72 @@
1
+ import { ScrollList, ScrollItem, Button } from '@douyinfe/semi-ui';
2
+ import React from 'react';
3
+
4
+ class SingleScrollListDemo extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.state = {
8
+ selectIndex3: -2,
9
+ };
10
+
11
+ this.minutes = new Array(60).fill(0).map((itm, index) => {
12
+ return {
13
+ value: index,
14
+ disabled: index % 2 === 1 ? true : false,
15
+ };
16
+ });
17
+ this.onSelectMinute = this.onSelectMinute.bind(this);
18
+ this.handleClose = this.handleClose.bind(this);
19
+ this.renderFooter = this.renderFooter.bind(this);
20
+ }
21
+
22
+
23
+ onSelectMinute(data) {
24
+ console.log('You have choose the minute for: ', data.value);
25
+ this.setState({
26
+ ['selectIndex' + data.type]: data.index,
27
+ });
28
+ }
29
+
30
+ handleClose() {
31
+ console.log('close');
32
+ }
33
+
34
+ renderFooter() {
35
+ return (
36
+ <Button size="small" type="primary" onClick={this.handleClose}>
37
+ Ok
38
+ </Button>
39
+ );
40
+ }
41
+
42
+ render() {
43
+ let list = this.list;
44
+ const scrollStyle = {
45
+ border: 'unset',
46
+ boxShadow: 'unset',
47
+ };
48
+ const commonProps = {
49
+ // mode: 'normal',
50
+ mode: 'wheel',
51
+ cycled: false,
52
+ motion: false,
53
+ };
54
+ return (
55
+ <div>
56
+ <ScrollList style={scrollStyle} header={'单个无限滚动列表'} footer={this.renderFooter()}>
57
+ <ScrollItem
58
+ {...commonProps}
59
+ list={this.minutes}
60
+ type={3}
61
+ selectedIndex={this.state.selectIndex3}
62
+ onSelect={this.onSelectMinute}
63
+ aria-label="分钟"
64
+ cycled
65
+ />
66
+ </ScrollList>
67
+ </div>
68
+ );
69
+ }
70
+ }
71
+
72
+ export default SingleScrollListDemo;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import WheelListDemo from './WheelList';
3
3
  import ScrollListDemo from './ScrollList';
4
+ import SingleScrollListDemo from './SingleWheelList';
4
5
 
5
6
 
6
7
  export default {
@@ -24,3 +25,9 @@ export const _WheelListDemo = () => <WheelListDemo />;
24
25
  _WheelListDemo.story = {
25
26
  name: 'wheel list demo',
26
27
  };
28
+
29
+ export const SingleScrollList = () => <SingleScrollListDemo />;
30
+
31
+ SingleScrollList.story = {
32
+ name: 'single scroll list demo',
33
+ };
@@ -178,6 +178,7 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
178
178
 
179
179
  _cacheWrapperNode = (wrapper: Element) => this._cacheNode('wrapper', wrapper);
180
180
 
181
+ /* istanbul ignore next */
181
182
  _isFirst = (node: Element) => {
182
183
  const { list } = this;
183
184
 
@@ -191,6 +192,8 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
191
192
  return false;
192
193
  };
193
194
 
195
+
196
+ /* istanbul ignore next */
194
197
  _isLast = (node: Element) => {
195
198
  const { list } = this;
196
199
 
@@ -109,6 +109,7 @@ describe(`Table`, () => {
109
109
  myCls,
110
110
  myClsIndex,
111
111
  });
112
+ demo.unmount();
112
113
  });
113
114
  it(`test object columns appearance`, async () => {
114
115
  const myCls = `my-tr-class`;
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
 
@@ -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
+ };