@douyinfe/semi-ui 2.9.0-beta.1 → 2.10.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/anchor/__test__/anchor.test.js +1 -0
  2. package/anchor/_story/anchor.stories.js +23 -1
  3. package/badge/_story/badge.stories.js +34 -2
  4. package/banner/_story/banner.stories.js +62 -1
  5. package/banner/index.tsx +5 -5
  6. package/carousel/CarouselArrow.tsx +62 -0
  7. package/carousel/CarouselIndicator.tsx +84 -0
  8. package/carousel/__test__/carousel.test.js +159 -0
  9. package/carousel/_story/carousel.stories.js +486 -0
  10. package/carousel/index.tsx +294 -0
  11. package/carousel/interface.ts +64 -0
  12. package/cascader/_story/cascader.stories.js +17 -2
  13. package/cascader/index.tsx +2 -3
  14. package/checkbox/_story/checkbox.stories.js +1 -1
  15. package/collapse/item.tsx +2 -0
  16. package/datePicker/_story/datePicker.stories.js +37 -0
  17. package/dist/css/semi.css +344 -2
  18. package/dist/css/semi.min.css +1 -1
  19. package/dist/umd/semi-ui.js +1068 -330
  20. package/dist/umd/semi-ui.js.map +1 -1
  21. package/dist/umd/semi-ui.min.js +1 -1
  22. package/dist/umd/semi-ui.min.js.map +1 -1
  23. package/form/hoc/withField.tsx +8 -5
  24. package/index.ts +2 -0
  25. package/input/__test__/input.test.js +12 -3
  26. package/input/__test__/textArea.test.js +53 -0
  27. package/lib/cjs/banner/index.js +11 -5
  28. package/lib/cjs/carousel/CarouselArrow.d.ts +8 -0
  29. package/lib/cjs/carousel/CarouselArrow.js +91 -0
  30. package/lib/cjs/carousel/CarouselIndicator.d.ts +23 -0
  31. package/lib/cjs/carousel/CarouselIndicator.js +145 -0
  32. package/lib/cjs/carousel/index.d.ts +58 -0
  33. package/lib/cjs/carousel/index.js +345 -0
  34. package/lib/cjs/carousel/interface.d.ts +62 -0
  35. package/lib/cjs/carousel/interface.js +7 -0
  36. package/lib/cjs/cascader/index.js +2 -2
  37. package/lib/cjs/collapse/item.js +4 -2
  38. package/lib/cjs/form/hoc/withField.js +6 -4
  39. package/lib/cjs/index.d.ts +1 -0
  40. package/lib/cjs/index.js +9 -0
  41. package/lib/cjs/modal/Modal.js +3 -0
  42. package/lib/cjs/scrollList/scrollItem.js +5 -1
  43. package/lib/cjs/switch/index.d.ts +3 -0
  44. package/lib/cjs/switch/index.js +26 -6
  45. package/lib/cjs/tabs/TabPane.js +4 -0
  46. package/lib/cjs/tabs/index.js +2 -0
  47. package/lib/cjs/toast/toast.d.ts +1 -1
  48. package/lib/cjs/tooltip/index.js +1 -1
  49. package/lib/cjs/transfer/index.d.ts +1 -0
  50. package/lib/cjs/transfer/index.js +3 -1
  51. package/lib/es/banner/index.js +11 -5
  52. package/lib/es/carousel/CarouselArrow.d.ts +8 -0
  53. package/lib/es/carousel/CarouselArrow.js +72 -0
  54. package/lib/es/carousel/CarouselIndicator.d.ts +23 -0
  55. package/lib/es/carousel/CarouselIndicator.js +125 -0
  56. package/lib/es/carousel/index.d.ts +58 -0
  57. package/lib/es/carousel/index.js +311 -0
  58. package/lib/es/carousel/interface.d.ts +62 -0
  59. package/lib/es/carousel/interface.js +1 -0
  60. package/lib/es/cascader/index.js +2 -2
  61. package/lib/es/collapse/item.js +4 -2
  62. package/lib/es/form/hoc/withField.js +6 -4
  63. package/lib/es/index.d.ts +1 -0
  64. package/lib/es/index.js +1 -0
  65. package/lib/es/modal/Modal.js +3 -0
  66. package/lib/es/scrollList/scrollItem.js +5 -1
  67. package/lib/es/switch/index.d.ts +3 -0
  68. package/lib/es/switch/index.js +26 -6
  69. package/lib/es/tabs/TabPane.js +4 -0
  70. package/lib/es/tabs/index.js +2 -0
  71. package/lib/es/toast/toast.d.ts +1 -1
  72. package/lib/es/tooltip/index.js +1 -1
  73. package/lib/es/transfer/index.d.ts +1 -0
  74. package/lib/es/transfer/index.js +3 -1
  75. package/modal/Modal.tsx +2 -0
  76. package/modal/confirm.tsx +1 -1
  77. package/overflowList/_story/overflowList.stories.js +44 -0
  78. package/package.json +9 -9
  79. package/scrollList/_story/SingleWheelList/index.js +72 -0
  80. package/scrollList/_story/scrolllist.stories.js +7 -0
  81. package/scrollList/scrollItem.tsx +4 -1
  82. package/switch/index.tsx +20 -3
  83. package/table/__test__/table.test.js +1 -0
  84. package/tabs/TabPane.tsx +2 -0
  85. package/tabs/_story/tabs.stories.js +72 -0
  86. package/tabs/index.tsx +1 -0
  87. package/tagInput/__test__/tagInput.test.js +11 -11
  88. package/tagInput/_story/tagInput.stories.js +14 -1
  89. package/timePicker/TimePicker.tsx +1 -1
  90. package/timePicker/_story/timepicker.stories.js +20 -1
  91. package/tooltip/_story/tooltip.stories.js +127 -15
  92. package/tooltip/index.tsx +1 -1
  93. package/transfer/index.tsx +4 -1
  94. package/typography/__test__/typography.test.js +1 -0
  95. package/upload/__test__/upload.test.js +2 -0
  96. package/upload/_story/upload.stories.js +2 -2
@@ -0,0 +1,62 @@
1
+ import React, { ReactNode } from "react";
2
+ import { strings } from '@douyinfe/semi-foundation/lib/es/carousel/constants';
3
+ export interface CarouselMethod {
4
+ next?: () => void;
5
+ prev?: () => void;
6
+ goTo?: () => void;
7
+ play?: () => void;
8
+ stop?: () => void;
9
+ }
10
+ export interface CarouselProps {
11
+ activeIndex?: number;
12
+ animation?: typeof strings.ANIMATION_MAP[number];
13
+ arrowProps?: ArrowProps;
14
+ autoPlay?: boolean | {
15
+ interval?: number;
16
+ hoverToPause?: boolean;
17
+ };
18
+ arrowType?: typeof strings.ARROW_MAP[number];
19
+ children?: ReactNode | Array<ReactNode>;
20
+ className?: string;
21
+ defaultActiveIndex?: number;
22
+ indicatorPosition?: typeof strings.POSITION_MAP[number];
23
+ indicatorSize?: typeof strings.SIZE[number];
24
+ theme?: typeof strings.THEME_MAP[number];
25
+ indicatorType?: typeof strings.TYPE_MAP[number];
26
+ onChange?: (index: number, preIndex: number) => void;
27
+ showArrow?: boolean;
28
+ showIndicator?: boolean;
29
+ slideDirection?: typeof strings.DIRECTION[number];
30
+ speed?: number;
31
+ style?: React.CSSProperties;
32
+ trigger?: typeof strings.TRIGGER[number];
33
+ }
34
+ export interface CarouselIndicatorProps {
35
+ activeIndex?: number;
36
+ className?: string;
37
+ defaultActiveIndex?: number;
38
+ position?: typeof strings.POSITION_MAP[number];
39
+ size?: typeof strings.SIZE[number];
40
+ total?: number;
41
+ theme?: typeof strings.THEME_MAP[number];
42
+ type?: typeof strings.TYPE_MAP[number];
43
+ onIndicatorChange?: (activeIndex: number) => void;
44
+ style?: React.CSSProperties;
45
+ trigger?: typeof strings.TRIGGER[number];
46
+ }
47
+ export interface CarouselArrowProps {
48
+ type?: typeof strings.ARROW_MAP[number];
49
+ theme?: typeof strings.THEME_MAP[number];
50
+ prev?: () => void;
51
+ next?: () => void;
52
+ arrowProps?: ArrowProps;
53
+ timing: number;
54
+ }
55
+ export interface ArrowButton {
56
+ props?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
57
+ children?: React.ReactNode;
58
+ }
59
+ export interface ArrowProps {
60
+ leftArrow?: ArrowButton;
61
+ rightArrow?: ArrowButton;
62
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -84,7 +84,7 @@ class Cascader extends BaseComponent {
84
84
  e.preventDefault();
85
85
  this.handleTagRemove(e, keyEntities[nodeKey].valuePath);
86
86
  }
87
- }, displayProp === 'label' && keyEntities[nodeKey].data.label, displayProp === 'value' && keyEntities[nodeKey].data.value);
87
+ }, keyEntities[nodeKey].data[displayProp]);
88
88
  }
89
89
  }
90
90
 
@@ -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,
@@ -112,7 +112,8 @@ function withField(Component, opts) {
112
112
  const [cursor, setCursor, getCursor] = useStateWithGetter(0);
113
113
  const [status, setStatus] = useState(validateStatus); // use props.validateStatus to init
114
114
 
115
- const rulesRef = useRef(rules); // notNotify is true means that the onChange of the Form does not need to be triggered
115
+ const rulesRef = useRef(rules);
116
+ const validateRef = useRef(validate); // notNotify is true means that the onChange of the Form does not need to be triggered
116
117
  // notUpdate is true means that this operation does not need to trigger the forceUpdate
117
118
 
118
119
  const updateTouched = (isTouched, callOpts) => {
@@ -213,7 +214,7 @@ function withField(Component, opts) {
213
214
  let maybePromisedErrors; // let errorThrowSync;
214
215
 
215
216
  try {
216
- maybePromisedErrors = validate(val, values);
217
+ maybePromisedErrors = validateRef.current(val, values);
217
218
  } catch (err) {
218
219
  // error throw by syncValidate
219
220
  maybePromisedErrors = err;
@@ -253,7 +254,7 @@ function withField(Component, opts) {
253
254
  finalVal = transform(val);
254
255
  }
255
256
 
256
- if (validate) {
257
+ if (validateRef.current) {
257
258
  return _validate(finalVal, updater.getValue(), callOpts);
258
259
  } else if (latestRules) {
259
260
  return _validateInternal(finalVal, callOpts);
@@ -362,7 +363,8 @@ function withField(Component, opts) {
362
363
 
363
364
  useLayoutEffect(() => {
364
365
  rulesRef.current = rules;
365
- }, [rules]); // exec validate once when trigger inlcude 'mount'
366
+ validateRef.current = validate;
367
+ }, [rules, validate]); // exec validate once when trigger inlcude 'mount'
366
368
 
367
369
  useLayoutEffect(() => {
368
370
  if (validateOnMount) {
package/lib/es/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export { default as ButtonGroup } from './button/buttonGroup';
12
12
  export { default as Calendar } from './calendar';
13
13
  export { default as Card } from './card';
14
14
  export { default as CardGroup } from './card/cardGroup';
15
+ export { default as Carousel } from './carousel';
15
16
  export { default as Cascader } from './cascader';
16
17
  export { default as Checkbox } from './checkbox';
17
18
  export { default as CheckboxGroup } from './checkbox/checkboxGroup';
package/lib/es/index.js CHANGED
@@ -12,6 +12,7 @@ export { default as ButtonGroup } from './button/buttonGroup';
12
12
  export { default as Calendar } from './calendar';
13
13
  export { default as Card } from './card';
14
14
  export { default as CardGroup } from './card/cardGroup';
15
+ export { default as Carousel } from './carousel';
15
16
  export { default as Cascader } from './cascader';
16
17
  export { default as Checkbox } from './checkbox';
17
18
  export { default as CheckboxGroup } from './checkbox/checkboxGroup';
@@ -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 {
@@ -172,7 +176,7 @@ export default class ScrollItem extends BaseComponent {
172
176
  } = this;
173
177
  const wrapperHeight = wrapper.offsetHeight;
174
178
  const itemHeight = this.getItmHeight(node);
175
- const targetTop = node.offsetTop - (wrapperHeight - itemHeight) / 2;
179
+ const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2) - (wrapperHeight - itemHeight) / 2;
176
180
  this.scrollToPos(targetTop, duration);
177
181
  };
178
182
 
@@ -26,6 +26,7 @@ export interface SwitchProps {
26
26
  export interface SwitchState {
27
27
  nativeControlChecked: boolean;
28
28
  nativeControlDisabled: boolean;
29
+ focusVisible: boolean;
29
30
  }
30
31
  declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
31
32
  static propTypes: {
@@ -55,6 +56,8 @@ declare class Switch extends BaseComponent<SwitchProps, SwitchState> {
55
56
  componentDidUpdate(prevProps: SwitchProps): void;
56
57
  componentWillUnmount(): void;
57
58
  get adapter(): SwitchAdapter<SwitchProps, SwitchState>;
59
+ handleFocusVisible: (event: React.FocusEvent) => void;
60
+ handleBlur: (event: React.FocusEvent) => void;
58
61
  render(): JSX.Element;
59
62
  }
60
63
  export default Switch;
@@ -1,7 +1,7 @@
1
1
  import _noop from "lodash/noop";
2
2
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
3
3
 
4
- /* eslint-disable max-len, jsx-a11y/role-supports-aria-props */
4
+ /* eslint-disable max-len */
5
5
  import React from 'react';
6
6
  import cls from 'classnames';
7
7
  import PropTypes from 'prop-types';
@@ -14,9 +14,19 @@ import Spin from '../spin';
14
14
  class Switch extends BaseComponent {
15
15
  constructor(props) {
16
16
  super(props);
17
+
18
+ this.handleFocusVisible = event => {
19
+ this.foundation.handleFocusVisible(event);
20
+ };
21
+
22
+ this.handleBlur = event => {
23
+ this.foundation.handleBlur();
24
+ };
25
+
17
26
  this.state = {
18
27
  nativeControlChecked: false,
19
- nativeControlDisabled: false
28
+ nativeControlDisabled: false,
29
+ focusVisible: false
20
30
  };
21
31
  this.switchRef = /*#__PURE__*/React.createRef();
22
32
  this.foundation = new SwitchFoudation(this.adapter);
@@ -52,6 +62,11 @@ class Switch extends BaseComponent {
52
62
  nativeControlDisabled
53
63
  });
54
64
  },
65
+ setFocusVisible: focusVisible => {
66
+ this.setState({
67
+ focusVisible
68
+ });
69
+ },
55
70
  notifyChange: (checked, e) => {
56
71
  this.props.onChange(checked, e);
57
72
  }
@@ -61,7 +76,8 @@ class Switch extends BaseComponent {
61
76
  render() {
62
77
  const {
63
78
  nativeControlChecked,
64
- nativeControlDisabled
79
+ nativeControlDisabled,
80
+ focusVisible
65
81
  } = this.state;
66
82
  const {
67
83
  className,
@@ -80,11 +96,11 @@ class Switch extends BaseComponent {
80
96
  [cssClasses.DISABLED]: nativeControlDisabled,
81
97
  [cssClasses.LARGE]: size === 'large',
82
98
  [cssClasses.SMALL]: size === 'small',
83
- [cssClasses.LOADING]: loading
99
+ [cssClasses.LOADING]: loading,
100
+ [cssClasses.FOCUS]: focusVisible
84
101
  });
85
102
  const switchProps = {
86
103
  type: 'checkbox',
87
- role: 'switch',
88
104
  className: cssClasses.NATIVE_CONTROL,
89
105
  disabled: nativeControlDisabled || loading,
90
106
  checked: nativeControlChecked || false
@@ -109,13 +125,17 @@ class Switch extends BaseComponent {
109
125
  }, uncheckedText) : null, /*#__PURE__*/React.createElement("input", _Object$assign({}, switchProps, {
110
126
  ref: this.switchRef,
111
127
  id: id,
128
+ role: 'switch',
112
129
  "aria-checked": nativeControlChecked,
113
130
  "aria-invalid": this.props['aria-invalid'],
114
131
  "aria-errormessage": this.props['aria-errormessage'],
115
132
  "aria-label": this.props['aria-label'],
116
133
  "aria-labelledby": this.props['aria-labelledby'],
117
134
  "aria-describedby": this.props["aria-describedby"],
118
- onChange: e => this.foundation.handleChange(e.target.checked, e)
135
+ "aria-disabled": this.props['disabled'],
136
+ onChange: e => this.foundation.handleChange(e.target.checked, e),
137
+ onFocus: e => this.handleFocusVisible(e),
138
+ onBlur: e => this.handleBlur(e)
119
139
  })));
120
140
  }
121
141
 
@@ -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 = [];
@@ -41,7 +41,7 @@ declare class Toast extends BaseComponent<ToastReactProps, ToastState> {
41
41
  close(e: React.MouseEvent): void;
42
42
  clearCloseTimer: () => void;
43
43
  startCloseTimer: () => void;
44
- renderIcon(): true | React.ReactChild | React.ReactFragment;
44
+ renderIcon(): string | number | true | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment;
45
45
  render(): JSX.Element;
46
46
  }
47
47
  export default Toast;
@@ -212,7 +212,7 @@ export default class Tooltip extends BaseComponent {
212
212
  }, portalEventSet, {
213
213
  "x-placement": placement,
214
214
  style: _Object$assign({
215
- visibility: motion ? undefined : 'visible'
215
+ visibility: motion ? 'hidden' : 'visible'
216
216
  }, style)
217
217
  }), contentNode, icon);
218
218
  return /*#__PURE__*/React.createElement(Portal, {
@@ -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.10.0-beta.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.10.0-beta.0",
18
+ "@douyinfe/semi-animation-react": "2.10.0-beta.0",
19
+ "@douyinfe/semi-foundation": "2.10.0-beta.0",
20
+ "@douyinfe/semi-icons": "2.10.0-beta.0",
21
+ "@douyinfe/semi-illustrations": "2.10.0-beta.0",
22
+ "@douyinfe/semi-theme-default": "2.10.0-beta.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": "10c5eff42fe3144451fd73d9d542a710d165d456",
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.10.0-beta.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
 
@@ -326,7 +329,7 @@ export default class ScrollItem<T extends Item> extends BaseComponent<ScrollItem
326
329
  const { wrapper } = this;
327
330
  const wrapperHeight = wrapper.offsetHeight;
328
331
  const itemHeight = this.getItmHeight(node);
329
- const targetTop = node.offsetTop - (wrapperHeight - itemHeight) / 2;
332
+ const targetTop = (node.offsetTop || this.list.children.length * itemHeight / 2 ) - (wrapperHeight - itemHeight) / 2;
330
333
 
331
334
  this.scrollToPos(targetTop, duration);
332
335
  };