@douyinfe/semi-ui 2.9.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.
Files changed (47) hide show
  1. package/banner/_story/banner.stories.js +62 -1
  2. package/banner/index.tsx +5 -5
  3. package/carousel/CarouselArrow.tsx +62 -0
  4. package/carousel/CarouselIndicator.tsx +84 -0
  5. package/carousel/__test__/carousel.test.js +159 -0
  6. package/carousel/_story/carousel.stories.js +486 -0
  7. package/carousel/index.tsx +294 -0
  8. package/carousel/interface.ts +64 -0
  9. package/cascader/index.tsx +1 -2
  10. package/dist/css/semi.css +342 -0
  11. package/dist/css/semi.min.css +1 -1
  12. package/dist/umd/semi-ui.js +884 -66
  13. package/dist/umd/semi-ui.js.map +1 -1
  14. package/dist/umd/semi-ui.min.js +1 -1
  15. package/dist/umd/semi-ui.min.js.map +1 -1
  16. package/index.ts +2 -0
  17. package/lib/cjs/banner/index.js +11 -5
  18. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  19. package/lib/cjs/carousel/CarouselArrow.js +91 -0
  20. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  21. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  22. package/lib/cjs/carousel/index.d.ts +58 -0
  23. package/lib/cjs/carousel/index.js +345 -0
  24. package/lib/cjs/carousel/interface.d.ts +62 -0
  25. package/lib/cjs/carousel/interface.js +7 -0
  26. package/lib/cjs/cascader/index.js +1 -1
  27. package/lib/cjs/index.d.ts +1 -0
  28. package/lib/cjs/index.js +9 -0
  29. package/lib/cjs/switch/index.d.ts +3 -0
  30. package/lib/cjs/switch/index.js +26 -6
  31. package/lib/es/banner/index.js +11 -5
  32. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  33. package/lib/es/carousel/CarouselArrow.js +72 -0
  34. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  35. package/lib/es/carousel/CarouselIndicator.js +125 -0
  36. package/lib/es/carousel/index.d.ts +58 -0
  37. package/lib/es/carousel/index.js +311 -0
  38. package/lib/es/carousel/interface.d.ts +62 -0
  39. package/lib/es/carousel/interface.js +1 -0
  40. package/lib/es/cascader/index.js +1 -1
  41. package/lib/es/index.d.ts +1 -0
  42. package/lib/es/index.js +1 -0
  43. package/lib/es/switch/index.d.ts +3 -0
  44. package/lib/es/switch/index.js +26 -6
  45. package/package.json +9 -9
  46. package/switch/index.tsx +20 -3
  47. package/tagInput/__test__/tagInput.test.js +11 -11
@@ -0,0 +1,486 @@
1
+ import React, { useState } from 'react';
2
+ import { Radio, RadioGroup, Button } from '@douyinfe/semi-ui';
3
+ import { IconArrowLeft, IconArrowRight } from "@douyinfe/semi-icons";
4
+ import Carousel from '../index';
5
+
6
+ export default {
7
+ title: 'Carousel',
8
+ }
9
+
10
+ const style = {
11
+ width: '600px',
12
+ height: '240px',
13
+ };
14
+
15
+ const contentPinkStyle = {
16
+ display:'flex',
17
+ justifyContent: 'center',
18
+ alignItems: 'center',
19
+ color: '#fff',
20
+ background: 'lightpink',
21
+ };
22
+
23
+ const contentBlueStyle = {
24
+ display:'flex',
25
+ justifyContent: 'center',
26
+ alignItems: 'center',
27
+ color: '#fff',
28
+ background: 'lightBlue',
29
+ };
30
+
31
+ const radioTitleStyle = {
32
+ marginRight: 20
33
+ }
34
+
35
+ export const BasicUsage = () => (
36
+ <Carousel style={style}>
37
+ <div style={contentPinkStyle}>
38
+ <h3>1</h3>
39
+ </div>
40
+ <div style={contentBlueStyle}>
41
+ <h3>2</h3>
42
+ </div>
43
+ <div style={contentPinkStyle}>
44
+ <h3>3</h3>
45
+ </div>
46
+ <div style={contentBlueStyle}>
47
+ <h3>4</h3>
48
+ </div>
49
+ <div style={contentPinkStyle}>
50
+ <h3>5</h3>
51
+ </div>
52
+ </Carousel>
53
+ );
54
+
55
+ BasicUsage.story = {
56
+ name: 'basic usage',
57
+ };
58
+
59
+ // 主题切换
60
+ export const theme = () => {
61
+ const [theme, setTheme] = useState('primary');
62
+
63
+ return (
64
+ <div>
65
+ <div>
66
+ <span style={radioTitleStyle}>主题</span>
67
+ <RadioGroup onChange={e => setTheme(e.target.value)} value={theme}>
68
+ <Radio value='primary'>primary</Radio>
69
+ <Radio value='light'>light</Radio>
70
+ <Radio value='dark'>dark</Radio>
71
+ </RadioGroup>
72
+ </div>
73
+ <br/>
74
+ <Carousel style={style} theme={theme}>
75
+ <div style={contentPinkStyle}>
76
+ <h3>1</h3>
77
+ </div>
78
+ <div style={contentBlueStyle}>
79
+ <h3>2</h3>
80
+ </div>
81
+ <div style={contentPinkStyle}>
82
+ <h3>3</h3>
83
+ </div>
84
+ <div style={contentBlueStyle}>
85
+ <h3>4</h3>
86
+ </div>
87
+ <div style={contentPinkStyle}>
88
+ <h3>5</h3>
89
+ </div>
90
+ </Carousel>
91
+ </div>
92
+ );
93
+ }
94
+
95
+ theme.story = {
96
+ name: 'theme',
97
+ };
98
+
99
+
100
+ // 指示器大小、类型、位置
101
+ export const indicatorUsage = () => {
102
+ const [size, setSize] = useState('small');
103
+ const [type, setType] = useState('dot');
104
+ const [position, setPosition] = useState('left');
105
+
106
+ return (
107
+ <div>
108
+ <div>
109
+ <span style={radioTitleStyle}>类型</span>
110
+ <RadioGroup onChange={e => setType(e.target.value)} value={type}>
111
+ <Radio value='dot'>dot</Radio>
112
+ <Radio value='line'>line</Radio>
113
+ <Radio value='columnar'>columnar</Radio>
114
+ </RadioGroup>
115
+ </div>
116
+ <div>
117
+ <span style={radioTitleStyle}>位置</span>
118
+ <RadioGroup onChange={e => setPosition(e.target.value)} value={position}>
119
+ <Radio value='left'>left</Radio>
120
+ <Radio value='center'>center</Radio>
121
+ <Radio value='right'>right</Radio>
122
+ </RadioGroup>
123
+ </div>
124
+ <div>
125
+ <span style={radioTitleStyle}>尺寸</span>
126
+ <RadioGroup onChange={e => setSize(e.target.value)} value={size}>
127
+ <Radio value={'small'}>small</Radio>
128
+ <Radio value={'medium'}>medium</Radio>
129
+ </RadioGroup>
130
+ </div>
131
+ <br/>
132
+ <Carousel style={style} indicatorType={type} indicatorPosition={position} indicatorSize={size}>
133
+ <div style={contentPinkStyle}>
134
+ <h3>1</h3>
135
+ </div>
136
+ <div style={contentBlueStyle}>
137
+ <h3>2</h3>
138
+ </div>
139
+ <div style={contentPinkStyle}>
140
+ <h3>3</h3>
141
+ </div>
142
+ <div style={contentBlueStyle}>
143
+ <h3>4</h3>
144
+ </div>
145
+ <div style={contentPinkStyle}>
146
+ <h3>5</h3>
147
+ </div>
148
+ </Carousel>
149
+ </div>
150
+ );
151
+ }
152
+
153
+ indicatorUsage.story = {
154
+ name: 'indicator usage',
155
+ };
156
+
157
+ // 箭头主题、显示时机
158
+ export const arrowShow = () => {
159
+ const [arrowType, setArrowTypew] = useState('always');
160
+ const [show, setShow] = useState(true);
161
+
162
+ return (
163
+ <div>
164
+ <div>
165
+ <span style={radioTitleStyle}>展示箭头</span>
166
+ <RadioGroup onChange={e => setShow(e.target.value)} value={show}>
167
+ <Radio value={true}>展示</Radio>
168
+ <Radio value={false}>不展示</Radio>
169
+ </RadioGroup>
170
+ </div>
171
+ <div>
172
+ <span style={radioTitleStyle}>展示时机</span>
173
+ <RadioGroup onChange={e => setArrowTypew(e.target.value)} value={arrowType}>
174
+ <Radio value='always'>always</Radio>
175
+ <Radio value='hover'>hover</Radio>
176
+ </RadioGroup>
177
+ </div>
178
+ <br/>
179
+ <Carousel style={style} showArrow={show} arrowType={arrowType}>
180
+ <div style={contentPinkStyle}>
181
+ <h3>1</h3>
182
+ </div>
183
+ <div style={contentBlueStyle}>
184
+ <h3>2</h3>
185
+ </div>
186
+ <div style={contentPinkStyle}>
187
+ <h3>3</h3>
188
+ </div>
189
+ <div style={contentBlueStyle}>
190
+ <h3>4</h3>
191
+ </div>
192
+ <div style={contentPinkStyle}>
193
+ <h3>5</h3>
194
+ </div>
195
+ </Carousel>
196
+ </div>
197
+ )
198
+ };
199
+
200
+ arrowShow.story = {
201
+ name: 'arrow show',
202
+ };
203
+
204
+
205
+ // 箭头参数
206
+ export const customArrow = () => {
207
+ const arrowProps = {
208
+ leftArrow: { children: <IconArrowLeft size='large'/>},
209
+ rightArrow: { children: <IconArrowRight size='large'/> },
210
+ };
211
+
212
+ return (
213
+ <div>
214
+ <Carousel style={style} arrowProps={arrowProps}>
215
+ <div style={contentPinkStyle}>
216
+ <h3>1</h3>
217
+ </div>
218
+ <div style={contentBlueStyle}>
219
+ <h3>2</h3>
220
+ </div>
221
+ <div style={contentPinkStyle}>
222
+ <h3>3</h3>
223
+ </div>
224
+ <div style={contentBlueStyle}>
225
+ <h3>4</h3>
226
+ </div>
227
+ <div style={contentPinkStyle}>
228
+ <h3>5</h3>
229
+ </div>
230
+ </Carousel>
231
+ </div>
232
+ );
233
+ }
234
+
235
+ customArrow.story = {
236
+ name: 'custom arrow',
237
+ };
238
+
239
+ // 自动播放参数
240
+ export const autoPlayExample = () => (
241
+ <div>
242
+ <Carousel style={style} autoPlay={{ interval: 1000, hoverToPause: true }}>
243
+ <div style={contentPinkStyle}>
244
+ <h3>1</h3>
245
+ </div>
246
+ <div style={contentBlueStyle}>
247
+ <h3>2</h3>
248
+ </div>
249
+ <div style={contentPinkStyle}>
250
+ <h3>3</h3>
251
+ </div>
252
+ <div style={contentBlueStyle}>
253
+ <h3>4</h3>
254
+ </div>
255
+ <div style={contentPinkStyle}>
256
+ <h3>5</h3>
257
+ </div>
258
+ </Carousel>
259
+ </div>
260
+ );
261
+
262
+ autoPlayExample.story = {
263
+ name: 'auto play example',
264
+ };
265
+
266
+ // 动画效果与速度
267
+ export const animationUsage = () => {
268
+ const [animation, setAnimation] = useState('slide');
269
+ const [speed, setSpeed] = useState(1000);
270
+
271
+ return (
272
+ <div>
273
+ <div>
274
+ <span style={radioTitleStyle}>动画效果</span>
275
+ <RadioGroup onChange={e => setAnimation(e.target.value)} value={animation}>
276
+ <Radio value='slide'>slide</Radio>
277
+ <Radio value='fade'>fade</Radio>
278
+ </RadioGroup>
279
+ </div>
280
+ <div>
281
+ <span style={radioTitleStyle}>切换速度</span>
282
+ <RadioGroup onChange={e => setSpeed(e.target.value)} value={speed}>
283
+ <Radio value={1000}>1000ms</Radio>
284
+ <Radio value={2000}>2000ms</Radio>
285
+ <Radio value={3000}>3000ms</Radio>
286
+ </RadioGroup>
287
+ </div>
288
+ <br/>
289
+ <Carousel style={style} speed={speed} animation={animation}>
290
+ <div style={contentPinkStyle}>
291
+ <h3>1</h3>
292
+ </div>
293
+ <div style={contentBlueStyle}>
294
+ <h3>2</h3>
295
+ </div>
296
+ <div style={contentPinkStyle}>
297
+ <h3>3</h3>
298
+ </div>
299
+ <div style={contentBlueStyle}>
300
+ <h3>4</h3>
301
+ </div>
302
+ <div style={contentPinkStyle}>
303
+ <h3>5</h3>
304
+ </div>
305
+ </Carousel>
306
+ </div>
307
+ )
308
+ };
309
+
310
+ animationUsage.story = {
311
+ name: 'animation usage',
312
+ };
313
+
314
+ // 受控的轮播图
315
+ class ControlledDemo extends React.Component {
316
+ constructor(props) {
317
+ super(props);
318
+ this.ref = React.createRef();
319
+ this.handleNext=this.handleNext.bind(this);
320
+ this.handlePrev=this.handlePrev.bind(this);
321
+ this.handleGoTo=this.handleGoTo.bind(this);
322
+ this.handlePlay=this.handlePlay.bind(this);
323
+ this.handleStop=this.handleStop.bind(this);
324
+ this.state = {
325
+ activeIndex: 0,
326
+ };
327
+ }
328
+
329
+ handleNext(){
330
+ this.ref.current.next();
331
+ }
332
+
333
+ handlePrev(){
334
+ this.ref.current.prev();
335
+ }
336
+
337
+ handleGoTo(){
338
+ this.ref.current.goTo(2);
339
+ }
340
+
341
+ handlePlay(){
342
+ this.ref.current.play();
343
+ }
344
+
345
+ handleStop(){
346
+ this.ref.current.stop();
347
+ }
348
+
349
+ onChange(activeIndex){
350
+ this.setState({ activeIndex });
351
+ }
352
+
353
+ render() {
354
+ return (
355
+ <div>
356
+ <Carousel style={style} animation='slide' ref={this.ref} activeIndex={this.state.activeIndex} onChange={this.onChange.bind(this)}>
357
+ <div style={contentPinkStyle}>
358
+ <h3>1</h3>
359
+ </div>
360
+ <div style={contentBlueStyle}>
361
+ <h3>2</h3>
362
+ </div>
363
+ <div style={contentPinkStyle}>
364
+ <h3>3</h3>
365
+ </div>
366
+ <div style={contentBlueStyle}>
367
+ <h3>4</h3>
368
+ </div>
369
+ <div style={contentPinkStyle}>
370
+ <h3>5</h3>
371
+ </div>
372
+ </Carousel>
373
+ <br/>
374
+ <Button onClick={this.handlePrev} style={{ marginRight: 10 }}>prev</Button>
375
+ <Button onClick={this.handleNext} style={{ marginRight: 10 }}>next</Button>
376
+ <Button onClick={this.handleGoTo} style={{ marginRight: 10 }}>goTo3</Button>
377
+ <Button onClick={this.handlePlay} style={{ marginRight: 10 }}>play</Button>
378
+ <Button onClick={this.handleStop} style={{ marginRight: 10 }}>stop</Button>
379
+ </div>
380
+ )
381
+ }
382
+ }
383
+
384
+ export const controlledUsage = () => <ControlledDemo />;
385
+
386
+ controlledUsage.story = {
387
+ name: 'controlled usage',
388
+ };
389
+
390
+ class RefDemo extends React.Component {
391
+ constructor(props) {
392
+ super(props);
393
+ this.ref = React.createRef();
394
+ this.handleNext=this.handleNext.bind(this);
395
+ this.handlePrev=this.handlePrev.bind(this);
396
+ this.handleGoTo=this.handleGoTo.bind(this);
397
+ this.handlePlay=this.handlePlay.bind(this);
398
+ this.handleStop=this.handleStop.bind(this);
399
+ }
400
+
401
+ handleNext(){
402
+ this.ref.current.next();
403
+ }
404
+
405
+ handlePrev(){
406
+ this.ref.current.prev();
407
+ }
408
+
409
+ handleGoTo(){
410
+ this.ref.current.goTo(2);
411
+ }
412
+
413
+ handlePlay(){
414
+ this.ref.current.play();
415
+ }
416
+
417
+ handleStop(){
418
+ this.ref.current.stop();
419
+ }
420
+
421
+
422
+ render() {
423
+ return (
424
+ <div>
425
+ <Carousel style={style} animation='slide' ref={this.ref}>
426
+ <div style={contentPinkStyle}>
427
+ <h3>1</h3>
428
+ </div>
429
+ <div style={contentBlueStyle}>
430
+ <h3>2</h3>
431
+ </div>
432
+ <div style={contentPinkStyle}>
433
+ <h3>3</h3>
434
+ </div>
435
+ <div style={contentBlueStyle}>
436
+ <h3>4</h3>
437
+ </div>
438
+ <div style={contentPinkStyle}>
439
+ <h3>5</h3>
440
+ </div>
441
+ </Carousel>
442
+ <br/>
443
+ <Button onClick={this.handlePrev} style={{ marginRight: 10 }}>prev</Button>
444
+ <Button onClick={this.handleNext} style={{ marginRight: 10 }}>next</Button>
445
+ <Button onClick={this.handleGoTo} style={{ marginRight: 10 }}>goTo3</Button>
446
+ <Button onClick={this.handlePlay} style={{ marginRight: 10 }}>play</Button>
447
+ <Button onClick={this.handleStop} style={{ marginRight: 10 }}>stop</Button>
448
+ </div>
449
+ )
450
+ }
451
+ }
452
+
453
+ export const refUsage = () => <RefDemo />;
454
+
455
+ refUsage.story = {
456
+ name: 'ref usage',
457
+ };
458
+
459
+ export const slideDirection = () => (
460
+ <Carousel style={style} autoPlay={false} slideDirection='right'>
461
+ <div style={contentPinkStyle}>
462
+ <h3>index0</h3>
463
+ </div>
464
+ <div style={contentPinkStyle}>
465
+ <h3>index1</h3>
466
+ </div>
467
+ <div style={contentPinkStyle}>
468
+ <h3>index2</h3>
469
+ </div>
470
+ </Carousel>
471
+ );
472
+
473
+ slideDirection.story = {
474
+ name: 'slide direction',
475
+ };
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+