@douyinfe/semi-ui 2.5.0 → 2.5.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.
@@ -1,7 +1,20 @@
1
1
  import React, { useState, useMemo } from 'react';
2
2
  import Tooltip from '../index';
3
3
  import './story.scss';
4
- import { Tag, Icon, IconButton, Switch, Checkbox, Radio, Button, Select, InputNumber, Space } from '@douyinfe/semi-ui';
4
+ import {
5
+ Tag,
6
+ Icon,
7
+ IconButton,
8
+ Switch,
9
+ Checkbox,
10
+ Radio,
11
+ Button,
12
+ Select,
13
+ InputNumber,
14
+ Space,
15
+ Popover,
16
+ Input,
17
+ } from '@douyinfe/semi-ui';
5
18
 
6
19
  import InTableDemo from './InTable';
7
20
  import EdgeDemo from './Edge';
@@ -13,185 +26,185 @@ import ContainerPosition from './ContainerPosition';
13
26
  import { IconList, IconSidebar, IconEdit } from '@douyinfe/semi-icons';
14
27
 
15
28
  export default {
16
- title: 'Tooltip',
17
- parameters: {
18
- chromatic: { disableSnapshot: true },
19
- },
29
+ title: 'Tooltip',
30
+ parameters: {
31
+ chromatic: { disableSnapshot: true },
32
+ },
20
33
  };
21
34
 
22
35
  function test(visible) {
23
- console.log('visible Change:' + visible);
36
+ console.log('visible Change:' + visible);
24
37
  }
25
38
 
26
39
  const ScrollDemo = function ScrollDemo(props = {}) {
27
- const tops = [
28
- ['topLeft', 'TL'],
29
- ['top', 'Top'],
30
- ['topRight', 'TR'],
31
- ];
32
- const lefts = [
33
- ['leftTop', 'LT'],
34
- ['left', 'Left'],
35
- ['leftBottom', 'LB'],
36
- ];
37
- const rights = [
38
- ['rightTop', 'RT'],
39
- ['right', 'Right'],
40
- ['rightBottom', 'RB'],
41
- ];
42
- const bottoms = [
43
- ['bottomLeft', 'BL'],
44
- ['bottom', 'Bottom'],
45
- ['bottomRight', 'BR'],
46
- ];
47
- const { tagStyle, ...restProps } = props;
48
- return (
49
- <div
50
- style={{
51
- paddingLeft: 40,
52
- }}
53
- >
54
- <div
55
- style={{
56
- marginLeft: 40,
57
- whiteSpace: 'nowrap',
58
- }}
59
- >
60
- {tops.map((pos, index) => (
61
- <Tooltip
62
- content={
63
- <article>
64
- <p>hi bytedance</p>
65
- <p>hi bytedance</p>
66
- </article>
67
- }
68
- position={Array.isArray(pos) ? pos[0] : pos}
69
- key={index}
70
- trigger={'click'}
71
- {...restProps}
72
- >
73
- <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
74
- </Tooltip>
75
- ))}
76
- </div>
77
- <div
78
- style={{
79
- width: 40,
80
- float: 'left',
81
- }}
82
- >
83
- {lefts.map((pos, index) => (
84
- <Tooltip
85
- content={
86
- <article>
87
- <p>hi bytedance</p>
88
- <p>hi bytedance</p>
89
- </article>
90
- }
91
- position={Array.isArray(pos) ? pos[0] : pos}
92
- key={index}
93
- trigger={'click'}
94
- {...restProps}
95
- >
96
- <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
97
- </Tooltip>
98
- ))}
99
- </div>
100
- <div
101
- style={{
102
- width: 40,
103
- marginLeft: 180,
104
- }}
105
- >
106
- {rights.map((pos, index) => (
107
- <Tooltip
108
- content={
109
- <article>
110
- <p>hi bytedance</p>
111
- <p>hi bytedance</p>
112
- </article>
113
- }
114
- position={Array.isArray(pos) ? pos[0] : pos}
115
- key={index}
116
- trigger={'click'}
117
- {...restProps}
118
- >
119
- <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
120
- </Tooltip>
121
- ))}
122
- </div>
123
- <div
124
- style={{
125
- marginLeft: 40,
126
- clear: 'both',
127
- whiteSpace: 'nowrap',
128
- }}
129
- >
130
- {bottoms.map((pos, index) => (
131
- <Tooltip
132
- content={
133
- <article>
134
- <p>hi bytedance</p>
135
- <p>hi bytedance</p>
136
- </article>
137
- }
138
- position={Array.isArray(pos) ? pos[0] : pos}
139
- key={index}
140
- trigger={'click'}
141
- {...restProps}
142
- >
143
- <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
144
- </Tooltip>
145
- ))}
146
- </div>
147
- </div>
148
- );
40
+ const tops = [
41
+ ['topLeft', 'TL'],
42
+ ['top', 'Top'],
43
+ ['topRight', 'TR'],
44
+ ];
45
+ const lefts = [
46
+ ['leftTop', 'LT'],
47
+ ['left', 'Left'],
48
+ ['leftBottom', 'LB'],
49
+ ];
50
+ const rights = [
51
+ ['rightTop', 'RT'],
52
+ ['right', 'Right'],
53
+ ['rightBottom', 'RB'],
54
+ ];
55
+ const bottoms = [
56
+ ['bottomLeft', 'BL'],
57
+ ['bottom', 'Bottom'],
58
+ ['bottomRight', 'BR'],
59
+ ];
60
+ const { tagStyle, ...restProps } = props;
61
+ return (
62
+ <div
63
+ style={{
64
+ paddingLeft: 40,
65
+ }}
66
+ >
67
+ <div
68
+ style={{
69
+ marginLeft: 40,
70
+ whiteSpace: 'nowrap',
71
+ }}
72
+ >
73
+ {tops.map((pos, index) => (
74
+ <Tooltip
75
+ content={
76
+ <article>
77
+ <p>hi bytedance</p>
78
+ <p>hi bytedance</p>
79
+ </article>
80
+ }
81
+ position={Array.isArray(pos) ? pos[0] : pos}
82
+ key={index}
83
+ trigger={'click'}
84
+ {...restProps}
85
+ >
86
+ <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
87
+ </Tooltip>
88
+ ))}
89
+ </div>
90
+ <div
91
+ style={{
92
+ width: 40,
93
+ float: 'left',
94
+ }}
95
+ >
96
+ {lefts.map((pos, index) => (
97
+ <Tooltip
98
+ content={
99
+ <article>
100
+ <p>hi bytedance</p>
101
+ <p>hi bytedance</p>
102
+ </article>
103
+ }
104
+ position={Array.isArray(pos) ? pos[0] : pos}
105
+ key={index}
106
+ trigger={'click'}
107
+ {...restProps}
108
+ >
109
+ <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
110
+ </Tooltip>
111
+ ))}
112
+ </div>
113
+ <div
114
+ style={{
115
+ width: 40,
116
+ marginLeft: 180,
117
+ }}
118
+ >
119
+ {rights.map((pos, index) => (
120
+ <Tooltip
121
+ content={
122
+ <article>
123
+ <p>hi bytedance</p>
124
+ <p>hi bytedance</p>
125
+ </article>
126
+ }
127
+ position={Array.isArray(pos) ? pos[0] : pos}
128
+ key={index}
129
+ trigger={'click'}
130
+ {...restProps}
131
+ >
132
+ <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
133
+ </Tooltip>
134
+ ))}
135
+ </div>
136
+ <div
137
+ style={{
138
+ marginLeft: 40,
139
+ clear: 'both',
140
+ whiteSpace: 'nowrap',
141
+ }}
142
+ >
143
+ {bottoms.map((pos, index) => (
144
+ <Tooltip
145
+ content={
146
+ <article>
147
+ <p>hi bytedance</p>
148
+ <p>hi bytedance</p>
149
+ </article>
150
+ }
151
+ position={Array.isArray(pos) ? pos[0] : pos}
152
+ key={index}
153
+ trigger={'click'}
154
+ {...restProps}
155
+ >
156
+ <Tag style={tagStyle}>{Array.isArray(pos) ? pos[1] : pos}</Tag>
157
+ </Tooltip>
158
+ ))}
159
+ </div>
160
+ </div>
161
+ );
149
162
  };
150
163
 
151
164
  export const TooltipOnVisibleChange = () => {
152
- const [visible, setVisible] = useState(true);
153
- return (
154
- <div className="demo">
155
- <div>
156
- <label>受控</label>
157
- <Tooltip
158
- content={
159
- <article>
160
- <p>hi bytedance</p>
161
- <p>hi bytedance</p>
162
- </article>
163
- }
164
- position="top"
165
- onVisibleChange={setVisible}
166
- trigger="click"
167
- visible={visible}
168
- >
169
- <Tag>demo</Tag>
170
- </Tooltip>
171
- </div>
172
-
173
- <br />
174
- <br />
175
- <div>
176
- <label>非受控</label>
177
- <Tooltip
178
- content={
179
- <article>
180
- <p>hi bytedance</p>
181
- <p>hi bytedance</p>
182
- </article>
183
- }
184
- position="leftTop"
185
- onVisibleChange={test}
186
- trigger="click"
187
- >
188
- <Tag>demo</Tag>
189
- </Tooltip>
190
- </div>
191
- <br />
192
- <br />
193
-
194
- {/* <Tooltip
165
+ const [visible, setVisible] = useState(true);
166
+ return (
167
+ <div className="demo">
168
+ <div>
169
+ <label>受控</label>
170
+ <Tooltip
171
+ content={
172
+ <article>
173
+ <p>hi bytedance</p>
174
+ <p>hi bytedance</p>
175
+ </article>
176
+ }
177
+ position="top"
178
+ onVisibleChange={setVisible}
179
+ trigger="click"
180
+ visible={visible}
181
+ >
182
+ <Tag>demo</Tag>
183
+ </Tooltip>
184
+ </div>
185
+
186
+ <br />
187
+ <br />
188
+ <div>
189
+ <label>非受控</label>
190
+ <Tooltip
191
+ content={
192
+ <article>
193
+ <p>hi bytedance</p>
194
+ <p>hi bytedance</p>
195
+ </article>
196
+ }
197
+ position="leftTop"
198
+ onVisibleChange={test}
199
+ trigger="click"
200
+ >
201
+ <Tag>demo</Tag>
202
+ </Tooltip>
203
+ </div>
204
+ <br />
205
+ <br />
206
+
207
+ {/* <Tooltip
195
208
  content={
196
209
  <article>
197
210
  <p>hi bytedance</p>
@@ -235,502 +248,505 @@ export const TooltipOnVisibleChange = () => {
235
248
  >
236
249
  <Tag>click</Tag>
237
250
  </Tooltip> */}
238
- </div>
239
- );
251
+ </div>
252
+ );
240
253
  };
241
254
 
242
255
  TooltipOnVisibleChange.story = {
243
- name: 'tooltip onVisibleChange',
256
+ name: 'tooltip onVisibleChange',
244
257
  };
245
258
 
246
259
  export const GetPopupContainerDemo = () => (
247
- <div className="demo">
248
- <div className="content-layer" />
249
- <Tooltip
250
- content={
251
- <article>
252
- <p>hi bytedance</p> <p>hi bytedance</p>
253
- </article>
254
- }
255
- position="bottom"
256
- visible
257
- trigger="custom"
258
- getPopupContainer={() => document.querySelector('.content-layer')}
259
- >
260
- <Tag>指定弹出层的容器</Tag>
261
- {/* <div className='content'></div> */}
262
- </Tooltip>
263
- <div>
264
- <label>给定容器为window,看是否报错</label>
265
- <Tooltip content={'单选'} position="top" getPopupContainer={() => window}>
266
- <Radio style={{ display: 'inline-flex' }}>单选</Radio>
267
- </Tooltip>
268
- </div>
260
+ <div className="demo">
261
+ <div className="content-layer" />
262
+ <Tooltip
263
+ content={
264
+ <article>
265
+ <p>hi bytedance</p> <p>hi bytedance</p>
266
+ </article>
267
+ }
268
+ position="bottom"
269
+ visible
270
+ trigger="custom"
271
+ getPopupContainer={() => document.querySelector('.content-layer')}
272
+ >
273
+ <Tag>指定弹出层的容器</Tag>
274
+ {/* <div className='content'></div> */}
275
+ </Tooltip>
276
+ <div>
277
+ <label>给定容器为window,看是否报错</label>
278
+ <Tooltip content={'单选'} position="top" getPopupContainer={() => window}>
279
+ <Radio style={{ display: 'inline-flex' }}>单选</Radio>
280
+ </Tooltip>
269
281
  </div>
282
+ </div>
270
283
  );
271
284
 
272
285
  GetPopupContainerDemo.story = {
273
- name: 'tooltip指定弹出层的容器',
286
+ name: 'tooltip指定弹出层的容器',
274
287
  };
275
288
 
276
289
  export const TooltipAll = () => (
277
- <div className="demo">
278
- <ScrollDemo />
279
- <div
280
- style={{
281
- padding: 120,
282
- }}
283
- >
284
- <ScrollDemo
285
- showArrow
286
- tagStyle={{
287
- height: 80,
288
- }}
289
- />
290
- </div>
290
+ <div className="demo">
291
+ <ScrollDemo />
292
+ <div
293
+ style={{
294
+ padding: 120,
295
+ }}
296
+ >
297
+ <ScrollDemo
298
+ showArrow
299
+ tagStyle={{
300
+ height: 80,
301
+ }}
302
+ />
291
303
  </div>
304
+ </div>
292
305
  );
293
306
 
294
307
  TooltipAll.story = {
295
- name: 'tooltip All',
308
+ name: 'tooltip All',
296
309
  };
297
310
 
298
311
  export const NoContent = () => (
299
- <div className="demo">
300
- <div
301
- style={{
302
- padding: 120,
303
- }}
304
- >
305
- <ScrollDemo showArrow content={''} />
306
- </div>
307
- <div
308
- style={{
309
- padding: 120,
310
- }}
311
- >
312
- <ScrollDemo
313
- showArrow
314
- tagStyle={{
315
- minHeight: 80,
316
- minWidth: 120,
317
- }}
318
- content={''}
319
- />
320
- </div>
312
+ <div className="demo">
313
+ <div
314
+ style={{
315
+ padding: 120,
316
+ }}
317
+ >
318
+ <ScrollDemo showArrow content={''} />
319
+ </div>
320
+ <div
321
+ style={{
322
+ padding: 120,
323
+ }}
324
+ >
325
+ <ScrollDemo
326
+ showArrow
327
+ tagStyle={{
328
+ minHeight: 80,
329
+ minWidth: 120,
330
+ }}
331
+ content={''}
332
+ />
321
333
  </div>
334
+ </div>
322
335
  );
323
336
 
324
337
  NoContent.story = {
325
- name: 'no content',
338
+ name: 'no content',
326
339
  };
327
340
 
328
341
  export const AdjustPosition = () => (
329
- <>
330
- <div className="adjust">
331
- <div className="wrapper">
332
- 第一个滚动区域
333
- <Tooltip
334
- content={
335
- <article>
336
- <p>hi bytedance</p>
337
- <p>hi bytedance</p>
338
- </article>
339
- }
340
- position="rightBottom"
341
- trigger="click"
342
- >
343
- {/* <Tag className='topLeft'>topleft</Tag> */}
344
- <div>test</div>
345
- </Tooltip>
346
- <Tooltip
347
- content={
348
- <article>
349
- <p>hi bytedance</p>
350
- <p>hi bytedance</p>
351
- </article>
352
- }
353
- position="topRight"
354
- trigger="click"
355
- >
356
- <Tag className="topRight">topRight</Tag>
357
- </Tooltip>
358
- <Tooltip
359
- content={
360
- <article>
361
- <p>hi bytedance</p>
362
- <p>hi bytedance</p>
363
- </article>
364
- }
365
- position="bottomLeft"
366
- trigger="click"
367
- >
368
- <Tag className="bottomLeft">bottomLeft</Tag>
369
- </Tooltip>
370
- <Tooltip
371
- content={
372
- <article>
373
- <p>hi bytedance</p>
374
- <p>hi bytedance</p>
375
- </article>
376
- }
377
- position="bottomRight"
378
- trigger="click"
379
- >
380
- <Tag className="bottomRight">bottomRight</Tag>
381
- </Tooltip>
382
- </div>
383
- </div>
384
- <div className="adjust2">
385
- <div className="wrapper2">第二个滚动区域</div>
386
- </div>
387
- </>
342
+ <>
343
+ <div className="adjust">
344
+ <div className="wrapper">
345
+ 第一个滚动区域
346
+ <Tooltip
347
+ content={
348
+ <article>
349
+ <p>hi bytedance</p>
350
+ <p>hi bytedance</p>
351
+ </article>
352
+ }
353
+ position="rightBottom"
354
+ trigger="click"
355
+ >
356
+ {/* <Tag className='topLeft'>topleft</Tag> */}
357
+ <div>test</div>
358
+ </Tooltip>
359
+ <Tooltip
360
+ content={
361
+ <article>
362
+ <p>hi bytedance</p>
363
+ <p>hi bytedance</p>
364
+ </article>
365
+ }
366
+ position="topRight"
367
+ trigger="click"
368
+ >
369
+ <Tag className="topRight">topRight</Tag>
370
+ </Tooltip>
371
+ <Tooltip
372
+ content={
373
+ <article>
374
+ <p>hi bytedance</p>
375
+ <p>hi bytedance</p>
376
+ </article>
377
+ }
378
+ position="bottomLeft"
379
+ trigger="click"
380
+ >
381
+ <Tag className="bottomLeft">bottomLeft</Tag>
382
+ </Tooltip>
383
+ <Tooltip
384
+ content={
385
+ <article>
386
+ <p>hi bytedance</p>
387
+ <p>hi bytedance</p>
388
+ </article>
389
+ }
390
+ position="bottomRight"
391
+ trigger="click"
392
+ >
393
+ <Tag className="bottomRight">bottomRight</Tag>
394
+ </Tooltip>
395
+ </div>
396
+ </div>
397
+ <div className="adjust2">
398
+ <div className="wrapper2">第二个滚动区域</div>
399
+ </div>
400
+ </>
388
401
  );
389
402
 
390
403
  AdjustPosition.story = {
391
- name: '自适应',
404
+ name: '自适应',
392
405
  };
393
406
 
394
407
  export const CompositeComponent = () => (
395
- <div
408
+ <div
409
+ style={{
410
+ padding: 50,
411
+ }}
412
+ >
413
+ <Tooltip
414
+ content={
415
+ <article>
416
+ <p>hi bytedance</p> <p>hi bytedance</p>
417
+ </article>
418
+ }
419
+ position="top"
420
+ >
421
+ <IconList />
422
+ </Tooltip>
423
+ <Tooltip content={'收起'} position="top">
424
+ <IconButton icon={<IconSidebar />} />
425
+ </Tooltip>
426
+ <Tooltip content={'开关'} position="top">
427
+ <Switch />
428
+ </Tooltip>
429
+ <Tooltip content={'选择框'} position="top">
430
+ <Checkbox
396
431
  style={{
397
- padding: 50,
432
+ display: 'inline-flex',
398
433
  }}
399
- >
400
- <Tooltip
401
- content={
402
- <article>
403
- <p>hi bytedance</p> <p>hi bytedance</p>
404
- </article>
405
- }
406
- position="top"
407
- >
408
- <IconList />
409
- </Tooltip>
410
- <Tooltip content={'收起'} position="top">
411
- <IconButton icon={<IconSidebar />} />
412
- </Tooltip>
413
- <Tooltip content={'开关'} position="top">
414
- <Switch />
415
- </Tooltip>
416
- <Tooltip content={'选择框'} position="top">
417
- <Checkbox
418
- style={{
419
- display: 'inline-flex',
420
- }}
421
- >
422
- 选择框
423
- </Checkbox>
424
- </Tooltip>
425
- <Tooltip content={'单选'} position="top">
426
- <Radio
427
- style={{
428
- display: 'inline-flex',
429
- }}
430
- >
431
- 单选
432
- </Radio>
433
- </Tooltip>
434
- </div>
434
+ >
435
+ 选择框
436
+ </Checkbox>
437
+ </Tooltip>
438
+ <Tooltip content={'单选'} position="top">
439
+ <Radio
440
+ style={{
441
+ display: 'inline-flex',
442
+ }}
443
+ >
444
+ 单选
445
+ </Radio>
446
+ </Tooltip>
447
+ </div>
435
448
  );
436
449
 
437
450
  CompositeComponent.story = {
438
- name: '复合组件',
451
+ name: '复合组件',
439
452
  };
440
453
 
441
454
  export const WrapDisabledElems = () => (
442
- <div
455
+ <div
456
+ style={{
457
+ padding: 50,
458
+ }}
459
+ >
460
+ <Tooltip content="disabled">
461
+ <IconButton disabled icon={<IconEdit />} />
462
+ </Tooltip>
463
+ <Tooltip content="disabled">
464
+ <IconButton disabled icon={<IconEdit />} block />
465
+ </Tooltip>
466
+ <Tooltip content="disabled">
467
+ <Button disabled block>
468
+ 编辑
469
+ </Button>
470
+ </Tooltip>
471
+ <Tooltip content="disabled">
472
+ <Button
473
+ disabled
443
474
  style={{
444
- padding: 50,
475
+ display: 'block',
445
476
  }}
446
- >
447
- <Tooltip content="disabled">
448
- <IconButton disabled icon={<IconEdit />} />
449
- </Tooltip>
450
- <Tooltip content="disabled">
451
- <IconButton disabled icon={<IconEdit />} block />
452
- </Tooltip>
453
- <Tooltip content="disabled">
454
- <Button disabled block>
455
- 编辑
456
- </Button>
457
- </Tooltip>
458
- <Tooltip content="disabled">
459
- <Button
460
- disabled
461
- style={{
462
- display: 'block',
463
- }}
464
- >
465
- 编辑
466
- </Button>
467
- </Tooltip>
468
- </div>
477
+ >
478
+ 编辑
479
+ </Button>
480
+ </Tooltip>
481
+ </div>
469
482
  );
470
483
 
471
484
  WrapDisabledElems.story = {
472
- name: 'wrap disabled elems',
485
+ name: 'wrap disabled elems',
473
486
  };
474
487
 
475
488
  export const InTable = () => (
476
- <div
477
- style={{
478
- marginTop: 50,
479
- }}
480
- >
481
- <InTableDemo />
482
- </div>
489
+ <div
490
+ style={{
491
+ marginTop: 50,
492
+ }}
493
+ >
494
+ <InTableDemo />
495
+ </div>
483
496
  );
484
497
 
485
498
  InTable.story = {
486
- name: 'in table',
499
+ name: 'in table',
487
500
  };
488
501
 
489
502
  export const _EdgeDemo = () => <EdgeDemo />;
490
503
 
491
504
  _EdgeDemo.story = {
492
- name: 'edge demo',
505
+ name: 'edge demo',
493
506
  };
494
507
 
495
508
  export const ScrollTooltipDemo = () => <ScrollTooltip />;
496
509
  ScrollTooltipDemo.story = {
497
- name: 'scroll demo and set popup container',
510
+ name: 'scroll demo and set popup container',
498
511
  };
499
512
  export const DangerousHtmlDemo = () => <DangerousHtml />;
500
513
  DangerousHtmlDemo.story = {
501
- name: 'in dangerous html',
514
+ name: 'in dangerous html',
502
515
  };
503
516
  export const ArrowPointAtCenterDemo = () => <ArrowPointAtCenter />;
504
517
  ArrowPointAtCenterDemo.story = {
505
- name: 'arrow point at center',
518
+ name: 'arrow point at center',
506
519
  };
507
520
  export const CustomContainerDemo = () => <CustomContainer />;
508
521
  CustomContainerDemo.story = {
509
- name: 'custom container',
522
+ name: 'custom container',
510
523
  };
511
524
  export const ContainerPositionDemo = () => <ContainerPosition />;
512
525
  ContainerPositionDemo.story = {
513
- name: 'container observer',
526
+ name: 'container observer',
514
527
  };
515
528
 
516
529
  export const QuickMoveMouse = () => {
517
- /**
518
- * mouseEnterDelay, mouseLeaveDelay 默认都为 50
519
- * mouseEnterDelay, mouseLeaveDelay 都为 0,快速滑动可能出现两个 tooltip 出现
520
- */
521
- const Demo = () => {
522
- const props = {
523
- mouseEnterDelay: 50,
524
- mouseLeaveDelay: 0,
525
- };
526
- return (
527
- <div className="demo">
528
- <div>
529
- <Tooltip content={'1'} {...props}>
530
- aaaaaaaaaaa
531
- </Tooltip>
532
- </div>
533
- <div>
534
- <Tooltip content={'2'} {...props}>
535
- bbbbbbbbbbb
536
- </Tooltip>
537
- </div>
538
- <div>
539
- <Tooltip content={'3'} {...props}>
540
- ccccccccccc
541
- </Tooltip>
542
- </div>
543
- <div>
544
- <Tooltip content={'4'} {...props}>
545
- aaaaaaaaaaa
546
- </Tooltip>
547
- </div>
548
- <div>
549
- <Tooltip content={'5'} {...props}>
550
- bbbbbbbbbbb
551
- </Tooltip>
552
- </div>
553
- <div>
554
- <Tooltip content={'6'} {...props}>
555
- ccccccccccc
556
- </Tooltip>
557
- </div>
558
- <div>
559
- <Tooltip content={'7'} {...props}>
560
- aaaaaaaaaaa
561
- </Tooltip>
562
- </div>
563
- <div>
564
- <Tooltip content={'8'} {...props}>
565
- bbbbbbbbbbb
566
- </Tooltip>
567
- </div>
568
- <div>
569
- <Tooltip content={'9'} {...props}>
570
- ccccccccccc
571
- </Tooltip>
572
- </div>
573
- </div>
574
- );
530
+ /**
531
+ * mouseEnterDelay, mouseLeaveDelay 默认都为 50
532
+ * mouseEnterDelay, mouseLeaveDelay 都为 0,快速滑动可能出现两个 tooltip 出现
533
+ */
534
+ const Demo = () => {
535
+ const props = {
536
+ mouseEnterDelay: 50,
537
+ mouseLeaveDelay: 0,
575
538
  };
539
+ return (
540
+ <div className="demo">
541
+ <div>
542
+ <Tooltip content={'1'} {...props}>
543
+ aaaaaaaaaaa
544
+ </Tooltip>
545
+ </div>
546
+ <div>
547
+ <Tooltip content={'2'} {...props}>
548
+ bbbbbbbbbbb
549
+ </Tooltip>
550
+ </div>
551
+ <div>
552
+ <Tooltip content={'3'} {...props}>
553
+ ccccccccccc
554
+ </Tooltip>
555
+ </div>
556
+ <div>
557
+ <Tooltip content={'4'} {...props}>
558
+ aaaaaaaaaaa
559
+ </Tooltip>
560
+ </div>
561
+ <div>
562
+ <Tooltip content={'5'} {...props}>
563
+ bbbbbbbbbbb
564
+ </Tooltip>
565
+ </div>
566
+ <div>
567
+ <Tooltip content={'6'} {...props}>
568
+ ccccccccccc
569
+ </Tooltip>
570
+ </div>
571
+ <div>
572
+ <Tooltip content={'7'} {...props}>
573
+ aaaaaaaaaaa
574
+ </Tooltip>
575
+ </div>
576
+ <div>
577
+ <Tooltip content={'8'} {...props}>
578
+ bbbbbbbbbbb
579
+ </Tooltip>
580
+ </div>
581
+ <div>
582
+ <Tooltip content={'9'} {...props}>
583
+ ccccccccccc
584
+ </Tooltip>
585
+ </div>
586
+ </div>
587
+ );
588
+ };
576
589
 
577
- return <Demo />;
590
+ return <Demo />;
578
591
  };
579
592
 
580
593
  QuickMoveMouse.story = {
581
- name: '快速移动鼠标可见性',
594
+ name: '快速移动鼠标可见性',
582
595
  };
583
596
 
584
597
  export const MotionFalseFix1402 = () => {
585
- function Demo() {
586
- const Test = React.forwardRef((props, ref) => (
587
- <span {...props} ref={ref}>
588
- Test
589
- </span>
590
- ));
591
- return (
592
- <div>
593
- <Tooltip content={'hi bytedance'} motion={false}>
594
- <Test />
595
- </Tooltip>
596
- <br />
597
- <br />
598
- <Tooltip content={'hi bytedance'}>
599
- <Test />
600
- </Tooltip>
601
- </div>
602
- );
603
- }
604
-
605
- return <Demo />;
598
+ function Demo() {
599
+ const Test = React.forwardRef((props, ref) => (
600
+ <span {...props} ref={ref}>
601
+ Test
602
+ </span>
603
+ ));
604
+ return (
605
+ <div>
606
+ <Tooltip content={'hi bytedance'} motion={false}>
607
+ <Test />
608
+ </Tooltip>
609
+ <br />
610
+ <br />
611
+ <Tooltip content={'hi bytedance'}>
612
+ <Test />
613
+ </Tooltip>
614
+ </div>
615
+ );
616
+ }
617
+
618
+ return <Demo />;
606
619
  };
607
620
 
608
621
  MotionFalseFix1402.story = {
609
- name: 'motion=false fix #1402',
622
+ name: 'motion=false fix #1402',
610
623
  };
611
624
 
612
625
  export const DisabledWrapperCls = () => (
613
- <>
614
- <Tooltip wrapperClassName="test" content={'hi bytedance'}>
615
- <Button>按钮</Button>
616
- </Tooltip>
617
- <br />
618
- <br />
619
- <Tooltip wrapperClassName="test" content={'hi bytedance'}>
620
- <Button disabled>禁用的单个按钮</Button>
621
- </Tooltip>
622
- <br />
623
- <br />
624
- <Tooltip wrapperClassName="test" content={'hi bytedance'}>
625
- <Button>正常的多个按钮</Button>
626
- <Button>正常的多个按钮</Button>
627
- </Tooltip>
628
- <br />
629
- <br />
630
- <Tooltip wrapperClassName="test" content={'hi bytedance'}>
631
- <Select disabled placeholder="请选择业务线" style={{ width: 120 }}>
632
- <Select.Option value="abc">抖音</Select.Option>
633
- <Select.Option value="hotsoon">火山</Select.Option>
634
- <Select.Option value="jianying" disabled>
635
- 剪映
636
- </Select.Option>
637
- <Select.Option value="xigua">西瓜视频</Select.Option>
638
- </Select>
639
- </Tooltip>
640
- <br />
641
- <br />
642
- </>
626
+ <>
627
+ <Tooltip wrapperClassName="test" content={'hi bytedance'}>
628
+ <Button>按钮</Button>
629
+ </Tooltip>
630
+ <br />
631
+ <br />
632
+ <Tooltip wrapperClassName="test" content={'hi bytedance'}>
633
+ <Button disabled>禁用的单个按钮</Button>
634
+ </Tooltip>
635
+ <br />
636
+ <br />
637
+ <Tooltip wrapperClassName="test" content={'hi bytedance'}>
638
+ <Button>正常的多个按钮</Button>
639
+ <Button>正常的多个按钮</Button>
640
+ </Tooltip>
641
+ <br />
642
+ <br />
643
+ <Tooltip wrapperClassName="test" content={'hi bytedance'}>
644
+ <Select disabled placeholder="请选择业务线" style={{ width: 120 }}>
645
+ <Select.Option value="abc">抖音</Select.Option>
646
+ <Select.Option value="hotsoon">火山</Select.Option>
647
+ <Select.Option value="jianying" disabled>
648
+ 剪映
649
+ </Select.Option>
650
+ <Select.Option value="xigua">西瓜视频</Select.Option>
651
+ </Select>
652
+ </Tooltip>
653
+ <br />
654
+ <br />
655
+ </>
643
656
  );
644
657
 
645
658
  DisabledWrapperCls.story = {
646
- name: 'disabledWrapperCls',
659
+ name: 'disabledWrapperCls',
647
660
  };
648
661
 
649
662
  export const ShowArrow = () => {
650
- function Demo() {
651
- const Test = React.forwardRef((props, ref) => (
652
- <Tag {...props} ref={ref}>
653
- Test
654
- </Tag>
655
- ));
656
- return (
657
- <div>
658
- <h4>should show content and arrow when click</h4>
659
- <Tooltip showArrow trigger="click" content={'hi bytedance'}>
660
- <Test />
661
- </Tooltip>
662
- </div>
663
- );
664
- }
665
-
666
- return <Demo />;
663
+ function Demo() {
664
+ const Test = React.forwardRef((props, ref) => (
665
+ <Tag {...props} ref={ref}>
666
+ Test
667
+ </Tag>
668
+ ));
669
+ return (
670
+ <div>
671
+ <h4>should show content and arrow when click</h4>
672
+ <Tooltip showArrow trigger="click" content={'hi bytedance'}>
673
+ <Test />
674
+ </Tooltip>
675
+ </div>
676
+ );
677
+ }
678
+
679
+ return <Demo />;
667
680
  };
668
681
 
669
682
  ShowArrow.story = {
670
- name: 'showArrow',
683
+ name: 'showArrow',
671
684
  };
672
685
 
673
686
  export const OnClickOutSideDemo = () => {
674
- let [v, setV] = useState(false);
675
- let clickOutSide = () => {
676
- console.log('clickOutSide');
677
- setV(false);
678
- };
679
- return (
680
- <>
681
- <Tooltip onClickOutSide={() => clickOutSide()} content={'hi bytedance'} visible={v} trigger="custom">
682
- <Button onClick={() => setV(true)}>按钮</Button>
683
- </Tooltip>
684
- <br />
685
- <br />
686
- <Tooltip onClickOutSide={() => console.log('clickOutSide')} content={'hi bytedance'} trigger="click">
687
- <Button>单个按钮</Button>
688
- </Tooltip>
689
- </>
690
- );
687
+ let [v, setV] = useState(false);
688
+ let clickOutSide = () => {
689
+ console.log('clickOutSide');
690
+ setV(false);
691
+ };
692
+ return (
693
+ <>
694
+ <Tooltip onClickOutSide={() => clickOutSide()} content={'hi bytedance'} visible={v} trigger="custom">
695
+ <Button onClick={() => setV(true)}>按钮</Button>
696
+ </Tooltip>
697
+ <br />
698
+ <br />
699
+ <Tooltip onClickOutSide={() => console.log('clickOutSide')} content={'hi bytedance'} trigger="click">
700
+ <Button>单个按钮</Button>
701
+ </Tooltip>
702
+ </>
703
+ );
691
704
  };
692
705
  OnClickOutSideDemo.story = {
693
706
  name: 'OnClickOutSide',
694
707
  };
695
708
 
696
709
  export const AutoAdjustWithSpacing = () => {
697
- const [height, setHeight] = useState(84);
698
- const [key, setKey] = useState(1);
699
- const initSpacing = 8;
700
- const [spacing, setSpacing] = useState(initSpacing);
701
-
702
- const change = (height, hasSpace) => {
703
- setHeight(height);
704
- hasSpace ? setSpacing(initSpacing) : setSpacing(0);
705
- setKey(Math.random());
706
- };
707
-
708
- return (
709
- <div className="demo1">
710
- <div>
711
- <Tooltip
712
- motion={false}
713
- rePosKey={key}
714
- // spacing={spacing}
715
- content={
716
- <article style={{ boxSizing: 'border-box', height: height }}>
717
- <p>hi bytedance, + padding 20</p>
718
- <p>hi bytedance</p>
719
- </article>
720
- }
721
- position="top"
722
- trigger="custom"
723
- visible={true}
724
- >
725
- <Tag>demo</Tag>
726
- </Tooltip>
727
- </div>
728
- <div style={{ marginTop: 200 }}>
729
- <Switch onChange={hasSpace => change(height, hasSpace)} checked={spacing === initSpacing ? true : false}></Switch>
730
- <InputNumber onChange={height => change(Number(height))} value={height} style={{ width: 200 }} />
731
- </div>
732
- </div>
733
- )
710
+ const [height, setHeight] = useState(84);
711
+ const [key, setKey] = useState(1);
712
+ const initSpacing = 8;
713
+ const [spacing, setSpacing] = useState(initSpacing);
714
+
715
+ const change = (height, hasSpace) => {
716
+ setHeight(height);
717
+ hasSpace ? setSpacing(initSpacing) : setSpacing(0);
718
+ setKey(Math.random());
719
+ };
720
+
721
+ return (
722
+ <div className="demo1">
723
+ <div>
724
+ <Tooltip
725
+ motion={false}
726
+ rePosKey={key}
727
+ // spacing={spacing}
728
+ content={
729
+ <article style={{ boxSizing: 'border-box', height: height }}>
730
+ <p>hi bytedance, + padding 20</p>
731
+ <p>hi bytedance</p>
732
+ </article>
733
+ }
734
+ position="top"
735
+ trigger="custom"
736
+ visible={true}
737
+ >
738
+ <Tag>demo</Tag>
739
+ </Tooltip>
740
+ </div>
741
+ <div style={{ marginTop: 200 }}>
742
+ <Switch
743
+ onChange={hasSpace => change(height, hasSpace)}
744
+ checked={spacing === initSpacing ? true : false}
745
+ ></Switch>
746
+ <InputNumber onChange={height => change(Number(height))} value={height} style={{ width: 200 }} />
747
+ </div>
748
+ </div>
749
+ );
734
750
  };
735
751
 
736
752
  AutoAdjustWithSpacing.story = {
@@ -741,80 +757,141 @@ AutoAdjustWithSpacing.story = {
741
757
  * Chromatic UI test
742
758
  */
743
759
  export const leftTopOverDemo = () => {
744
- const [visible, setVisible] = useState(true);
745
- const content = (
746
- <div style={{ height: 200, width: 200 }}>
747
- Semi Design
748
- </div>
749
- );
750
-
751
- const commonProps = {
752
- content,
753
- trigger: 'click',
754
- showArrow: false,
755
- visible,
756
- trigger: 'custom',
757
- motion: false,
758
- };
759
- const buttonStyle = {
760
- width: 200,
761
- };
762
-
763
- return (
764
- <div data-cy='wrapper'>
765
- <Button onClick={() => setVisible(!visible)}>toggle visible</Button>
766
- <div style={{ paddingTop: 200 }}>
767
- <Space spacing={80}>
768
- <Tooltip {...commonProps} position='leftTopOver' >
769
- <Button data-cy='leftTopOver' style={buttonStyle}>leftTopOver</Button>
770
- </Tooltip>
771
- <Tooltip {...commonProps} position='leftBottomOver'>
772
- <Button data-cy='leftBottomOver' style={buttonStyle}>leftBottomOver</Button>
773
- </Tooltip>
774
- <Tooltip {...commonProps} position='rightTopOver'>
775
- <Button data-cy='rightTopOver' style={buttonStyle}>rightTopOver</Button>
776
- </Tooltip>
777
- <Tooltip {...commonProps} position='rightBottomOver'>
778
- <Button data-cy='rightBottomOver' style={buttonStyle}>rightBottomOver</Button>
779
- </Tooltip>
780
- </Space>
781
- </div>
782
- </div>
783
- )
760
+ const [visible, setVisible] = useState(true);
761
+ const content = <div style={{ height: 200, width: 200 }}>Semi Design</div>;
762
+
763
+ const commonProps = {
764
+ content,
765
+ trigger: 'click',
766
+ showArrow: false,
767
+ visible,
768
+ trigger: 'custom',
769
+ motion: false,
770
+ };
771
+ const buttonStyle = {
772
+ width: 200,
773
+ };
774
+
775
+ return (
776
+ <div data-cy="wrapper">
777
+ <Button onClick={() => setVisible(!visible)}>toggle visible</Button>
778
+ <div style={{ paddingTop: 200 }}>
779
+ <Space spacing={80}>
780
+ <Tooltip {...commonProps} position="leftTopOver">
781
+ <Button data-cy="leftTopOver" style={buttonStyle}>
782
+ leftTopOver
783
+ </Button>
784
+ </Tooltip>
785
+ <Tooltip {...commonProps} position="leftBottomOver">
786
+ <Button data-cy="leftBottomOver" style={buttonStyle}>
787
+ leftBottomOver
788
+ </Button>
789
+ </Tooltip>
790
+ <Tooltip {...commonProps} position="rightTopOver">
791
+ <Button data-cy="rightTopOver" style={buttonStyle}>
792
+ rightTopOver
793
+ </Button>
794
+ </Tooltip>
795
+ <Tooltip {...commonProps} position="rightBottomOver">
796
+ <Button data-cy="rightBottomOver" style={buttonStyle}>
797
+ rightBottomOver
798
+ </Button>
799
+ </Tooltip>
800
+ </Space>
801
+ </div>
802
+ </div>
803
+ );
784
804
  };
785
805
  leftTopOverDemo.storyName = `leftTopOver visible`;
786
- leftTopOverDemo.parameters = {
787
- chromatic: {
788
- disableSnapshot: false,
789
- delay: 3000,
790
- viewports: [1200]
791
- }
806
+ leftTopOverDemo.parameters = {
807
+ chromatic: {
808
+ disableSnapshot: false,
809
+ delay: 3000,
810
+ viewports: [1200],
811
+ },
792
812
  };
793
813
 
794
814
  /**
795
815
  * Cypress test
796
816
  */
797
817
  export const leftTopOverAutoAdjustOverflow = () => {
798
- const content = (
799
- <div style={{ height: 200, width: 200 }}>
800
- Semi Design
801
- </div>
802
- );
818
+ const content = <div style={{ height: 200, width: 200 }}>Semi Design</div>;
803
819
 
804
- const commonProps = {
805
- content,
806
- trigger: 'click',
807
- showArrow: false,
808
- };
820
+ const commonProps = {
821
+ content,
822
+ trigger: 'click',
823
+ showArrow: false,
824
+ };
809
825
 
810
- return (
811
- <div data-cy='wrapper' style={{ width: '200vw', height: '200vw', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
812
- <div>
813
- <Tooltip {...commonProps} position='leftTopOver' >
814
- <Button data-cy='leftTopOver' style={{ width: 200 }}>leftTopOver</Button>
815
- </Tooltip>
816
- </div>
817
- </div>
818
- )
826
+ return (
827
+ <div
828
+ data-cy="wrapper"
829
+ style={{ width: '200vw', height: '200vw', display: 'flex', alignItems: 'center', justifyContent: 'center' }}
830
+ >
831
+ <div>
832
+ <Tooltip {...commonProps} position="leftTopOver">
833
+ <Button data-cy="leftTopOver" style={{ width: 200 }}>
834
+ leftTopOver
835
+ </Button>
836
+ </Tooltip>
837
+ </div>
838
+ </div>
839
+ );
840
+ };
841
+ leftTopOverAutoAdjustOverflow.storyName = `leftTopOver autoAdjustOverflow`;
842
+
843
+ export const autoFocusContentDemo = () => {
844
+ const [controlMotionVisible, setControlMotionVisible] = React.useState(false);
845
+ const [controlNoMotionVisible, setControlNoMotionVisible] = React.useState(false);
846
+
847
+ const onMotionVisibleChange = React.useCallback(() => {
848
+ setControlMotionVisible(!controlMotionVisible);
849
+ }, [setControlMotionVisible, controlMotionVisible]);
850
+
851
+ const onNoMotionVisibleChange = React.useCallback(() => {
852
+ setControlNoMotionVisible(!controlNoMotionVisible);
853
+ }, [setControlNoMotionVisible, controlNoMotionVisible]);
854
+
855
+ return (
856
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
857
+ <div style={{ display: 'flex', gap: 18, flex: 1, alignItems: 'center' }}>
858
+ <span>Hover触发</span>
859
+ <Popover position="bottomLeft" content={<Input autofocus data-cy="hoverInput"/>}>
860
+ <Button data-cy="hover">motion</Button>
861
+ </Popover>
862
+
863
+ <Popover motion={false} position="bottomLeft" content={<Input autofocus data-cy="hoverNoMotionInput"/>}>
864
+ <Button data-cy="hoverNoMotion">no motion</Button>
865
+ </Popover>
866
+ </div>
867
+ <div style={{ display: 'flex', gap: 18, flex: 1, alignItems: 'center' }}>
868
+ <span>Click触发</span>
869
+ <Popover position="bottomLeft" content={<Input autofocus data-cy="clickInput"/>} trigger="click">
870
+ <Button data-cy="click">motion</Button>
871
+ </Popover>
872
+
873
+ <Popover motion={false} position="bottomLeft" content={<Input autofocus data-cy="clickNoMotionInput"/>} trigger="click">
874
+ <Button data-cy="clickNoMotion">no motion</Button>
875
+ </Popover>
876
+ </div>
877
+ <div style={{ display: 'flex', gap: 18, flex: 1, alignItems: 'center' }}>
878
+ <span>受控</span>
879
+ <Button onClick={onMotionVisibleChange} data-cy="controlled">motion状态切换</Button>
880
+ <Popover visible={controlMotionVisible} trigger="custom" position="bottomLeft" content={<Input autofocus data-cy="controlledInput"/>}>
881
+ <Button disabled data-cy="controlledDisableBtn">motion</Button>
882
+ </Popover>
883
+
884
+ <Button onClick={onNoMotionVisibleChange } data-cy="controlledNoMotion">no motion状态切换</Button>
885
+ <Popover
886
+ visible={controlNoMotionVisible}
887
+ trigger="custom"
888
+ motion={false}
889
+ position="bottomLeft"
890
+ content={<Input autofocus data-cy="controlledNoMotionInput"/>}
891
+ >
892
+ <Button disabled data-cy="controlledNoMotionDisableBtn">no motion</Button>
893
+ </Popover>
894
+ </div>
895
+ </div>
896
+ );
819
897
  };
820
- leftTopOverAutoAdjustOverflow.storyName = `leftTopOver autoAdjustOverflow`;