@douyinfe/semi-ui 2.0.8 → 2.1.0-beta.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.
Files changed (49) hide show
  1. package/dist/css/semi.css +166 -6
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +318 -172
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/es/autoComplete/index.d.ts +0 -1
  8. package/lib/es/autoComplete/index.js +0 -1
  9. package/lib/es/button/index.d.ts +0 -1
  10. package/lib/es/button/index.js +1 -2
  11. package/lib/es/cascader/index.d.ts +1 -0
  12. package/lib/es/cascader/index.js +15 -3
  13. package/lib/es/datePicker/yearAndMonth.js +1 -1
  14. package/lib/es/form/hoc/withField.d.ts +2 -2
  15. package/lib/es/form/interface.d.ts +2 -2
  16. package/lib/es/iconButton/index.d.ts +0 -1
  17. package/lib/es/iconButton/index.js +0 -1
  18. package/lib/es/notification/index.d.ts +1 -1
  19. package/lib/es/popconfirm/index.d.ts +5 -1
  20. package/lib/es/popconfirm/index.js +10 -4
  21. package/lib/es/popover/index.d.ts +3 -1
  22. package/lib/es/popover/index.js +4 -8
  23. package/lib/es/radio/context.d.ts +1 -1
  24. package/lib/es/radio/radio.d.ts +2 -2
  25. package/lib/es/radio/radioGroup.d.ts +4 -4
  26. package/lib/es/select/index.d.ts +0 -1
  27. package/lib/es/select/index.js +16 -10
  28. package/lib/es/select/option.js +2 -2
  29. package/lib/es/select/utils.d.ts +1 -1
  30. package/lib/es/select/utils.js +10 -4
  31. package/lib/es/slider/index.js +3 -1
  32. package/lib/es/spin/index.d.ts +2 -2
  33. package/lib/es/spin/index.js +1 -1
  34. package/lib/es/tabs/TabBar.d.ts +4 -2
  35. package/lib/es/tabs/TabBar.js +12 -4
  36. package/lib/es/tabs/TabPane.d.ts +2 -1
  37. package/lib/es/tabs/TabPane.js +3 -2
  38. package/lib/es/tabs/index.d.ts +4 -2
  39. package/lib/es/tabs/index.js +83 -14
  40. package/lib/es/tabs/interface.d.ts +6 -1
  41. package/lib/es/tagInput/index.d.ts +3 -0
  42. package/lib/es/tagInput/index.js +6 -1
  43. package/lib/es/toast/index.d.ts +1 -1
  44. package/lib/es/tooltip/index.d.ts +3 -0
  45. package/lib/es/tooltip/index.js +3 -0
  46. package/lib/es/tree/interface.d.ts +2 -2
  47. package/lib/es/treeSelect/index.d.ts +2 -11
  48. package/lib/es/upload/index.d.ts +1 -0
  49. package/package.json +8 -8
@@ -5,7 +5,6 @@ import BaseComponent, { ValidateStatus } from '../_base/baseComponent';
5
5
  import { Position } from '../tooltip';
6
6
  import Option from '../select/option';
7
7
  import '@douyinfe/semi-foundation/lib/es/autoComplete/autoComplete.css';
8
- import '@douyinfe/semi-foundation/lib/es/select/option.css';
9
8
  import { Motion } from '../_base/base';
10
9
  /**
11
10
  * AutoComplete is an enhanced Input (candidates suggest that users can choose or not),
@@ -21,7 +21,6 @@ import Trigger from '../trigger';
21
21
  import Option from '../select/option';
22
22
  import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
23
23
  import '@douyinfe/semi-foundation/lib/es/autoComplete/autoComplete.css';
24
- import '@douyinfe/semi-foundation/lib/es/select/option.css';
25
24
  const prefixCls = cssClasses.PREFIX;
26
25
  const sizeSet = strings.SIZE;
27
26
  const positionSet = strings.POSITION;
@@ -14,7 +14,6 @@ declare class Button extends React.PureComponent<ButtonProps> {
14
14
  loading: import("prop-types").Requireable<boolean>;
15
15
  prefixCls: import("prop-types").Requireable<string>;
16
16
  icon: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
17
- iconType: import("prop-types").Requireable<import("prop-types").ReactElementLike>;
18
17
  iconSize: import("prop-types").Requireable<string>;
19
18
  noHorizontalPadding: import("prop-types").Requireable<string | boolean | any[]>;
20
19
  children: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
@@ -12,8 +12,7 @@ class Button extends React.PureComponent {
12
12
  render() {
13
13
  const props = _Object$assign({}, this.props);
14
14
 
15
- const hasIcon = Boolean(props.icon || props.iconType); // TODO: iconType needs to be confirmed
16
-
15
+ const hasIcon = Boolean(props.icon);
17
16
  const isLoading = Boolean(props.loading);
18
17
  const isDisabled = Boolean(props.disabled);
19
18
 
@@ -7,6 +7,7 @@ import Input from '../input/index';
7
7
  import { PopoverProps } from '../popover/index';
8
8
  import { CascaderData, Entities, Entity, Data } from './item';
9
9
  import { Motion } from '../_base/base';
10
+ export { CascaderType, ShowNextType } from '@douyinfe/semi-foundation/cascader/foundation';
10
11
  export { CascaderData, Entity, Data, CascaderItemProps } from './item';
11
12
  export interface ScrollPanelProps extends BasicScrollPanelProps {
12
13
  activeNode: CascaderData;
@@ -272,15 +272,27 @@ class Cascader extends BaseComponent {
272
272
  this.renderCustomTrigger = () => {
273
273
  const {
274
274
  disabled,
275
- triggerRender
275
+ triggerRender,
276
+ multiple,
277
+ autoMergeValue
276
278
  } = this.props;
277
279
  const {
278
280
  selectedKeys,
279
281
  inputValue,
280
- inputPlaceHolder
282
+ inputPlaceHolder,
283
+ mergedCheckedKeys,
284
+ checkedKeys
281
285
  } = this.state;
286
+ let realValue;
287
+
288
+ if (multiple) {
289
+ realValue = autoMergeValue ? mergedCheckedKeys : checkedKeys;
290
+ } else {
291
+ realValue = [...selectedKeys][0];
292
+ }
293
+
282
294
  return /*#__PURE__*/React.createElement(Trigger, {
283
- value: [...selectedKeys][0],
295
+ value: realValue,
284
296
  inputValue: inputValue,
285
297
  onChange: this.handleInputChange,
286
298
  onClear: this.handleClear,
@@ -220,7 +220,7 @@ class YearAndMonth extends BaseComponent {
220
220
  className: prefix
221
221
  }, /*#__PURE__*/React.createElement(IconButton, {
222
222
  noHorizontalPadding: false,
223
- iconType: /*#__PURE__*/React.createElement(IconChevronLeft, {
223
+ icon: /*#__PURE__*/React.createElement(IconChevronLeft, {
224
224
  size: iconSize
225
225
  }),
226
226
  size: buttonSize,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { withFieldOption } from '@douyinfe/semi-foundation/lib/es/form/interface';
2
+ import { WithFieldOption } from '@douyinfe/semi-foundation/lib/es/form/interface';
3
3
  import { CommonFieldProps, CommonexcludeType } from '../interface';
4
4
  import { Subtract } from 'utility-types';
5
5
  /**
@@ -8,5 +8,5 @@ import { Subtract } from 'utility-types';
8
8
  * 2. Insert <Label>
9
9
  * 3. Insert <ErrorMessage>
10
10
  */
11
- declare function withField<C extends React.ComponentType<React.ComponentProps<C>>, T extends React.ComponentType<Subtract<React.ComponentProps<C>, CommonexcludeType> & CommonFieldProps>>(Component: C, opts?: withFieldOption): T;
11
+ declare function withField<C extends React.ComponentType<React.ComponentProps<C>>, T extends React.ComponentType<Subtract<React.ComponentProps<C>, CommonexcludeType> & CommonFieldProps>>(Component: C, opts?: WithFieldOption): T;
12
12
  export default withField;
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { Subtract } from 'utility-types';
3
3
  import type { RuleItem } from 'async-validator';
4
4
  import { Options as scrollIntoViewOptions } from 'scroll-into-view-if-needed';
5
- import { BaseFormApi as FormApi, FormState } from '@douyinfe/semi-foundation/lib/es/form/interface';
5
+ import { BaseFormApi as FormApi, FormState, WithFieldOption } from '@douyinfe/semi-foundation/lib/es/form/interface';
6
6
  import { SelectProps } from '../select/index';
7
7
  import Option from '../select/option';
8
8
  import OptGroup from '../select/optionGroup';
@@ -10,7 +10,7 @@ import { CheckboxProps } from '../checkbox/index';
10
10
  import { RadioProps } from '../radio/index';
11
11
  import { ReactFieldError as FieldError } from './errorMessage';
12
12
  import { LabelProps } from './label';
13
- export { FormState, FormApi };
13
+ export { FormState, FormApi, WithFieldOption };
14
14
  export declare type CommonFieldProps = {
15
15
  /** Field is required (except Form. Checkbox within the Group, Form. Radio) */
16
16
  field: string;
@@ -32,7 +32,6 @@ declare class IconButton extends PureComponent<IconButtonProps> {
32
32
  loading: PropTypes.Requireable<boolean>;
33
33
  prefixCls: PropTypes.Requireable<string>;
34
34
  icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
35
- iconType: PropTypes.Requireable<PropTypes.ReactElementLike>;
36
35
  iconSize: PropTypes.Requireable<string>;
37
36
  noHorizontalPadding: PropTypes.Requireable<string | boolean | any[]>;
38
37
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
@@ -108,7 +108,6 @@ IconButton.propTypes = {
108
108
  loading: PropTypes.bool,
109
109
  prefixCls: PropTypes.string,
110
110
  icon: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.node]),
111
- iconType: PropTypes.element,
112
111
  iconSize: PropTypes.oneOf(iconSizes),
113
112
  noHorizontalPadding: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.array]),
114
113
  children: PropTypes.node,
@@ -9,7 +9,7 @@ export { NoticeTransitionProps } from './NoticeTransition';
9
9
  export interface NoticeReactProps extends NoticeProps {
10
10
  style?: CSSProperties;
11
11
  }
12
- export { NoticeState, NotificationListProps, NotificationListState };
12
+ export { NoticeState, NotificationListProps, NotificationListState, ConfigProps };
13
13
  export declare type NoticesInPosition = {
14
14
  top: NoticeInstance[];
15
15
  topLeft: NoticeInstance[];
@@ -29,6 +29,7 @@ export interface PopconfirmProps extends PopoverProps {
29
29
  onCancel?: (e: React.MouseEvent) => void;
30
30
  onConfirm?: (e: React.MouseEvent) => void;
31
31
  onVisibleChange?: (visible: boolean) => void;
32
+ onClickOutSide?: (e: React.MouseEvent) => void;
32
33
  }
33
34
  export interface PopconfirmState {
34
35
  visible: boolean;
@@ -50,13 +51,14 @@ export default class Popconfirm extends BaseComponent<PopconfirmProps, Popconfir
50
51
  cancelType: PropTypes.Requireable<string>;
51
52
  onCancel: PropTypes.Requireable<(...args: any[]) => any>;
52
53
  onConfirm: PropTypes.Requireable<(...args: any[]) => any>;
53
- zIndex: PropTypes.Requireable<number>;
54
+ onClickOutSide: PropTypes.Requireable<(...args: any[]) => any>;
54
55
  onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
55
56
  visible: PropTypes.Requireable<boolean>;
56
57
  defaultVisible: PropTypes.Requireable<boolean>;
57
58
  okButtonProps: PropTypes.Requireable<object>;
58
59
  cancelButtonProps: PropTypes.Requireable<object>;
59
60
  stopPropagation: PropTypes.Requireable<string | boolean>;
61
+ zIndex: PropTypes.Requireable<number>;
60
62
  trigger: PropTypes.Requireable<string>;
61
63
  position: PropTypes.Requireable<string>;
62
64
  };
@@ -72,6 +74,7 @@ export default class Popconfirm extends BaseComponent<PopconfirmProps, Popconfir
72
74
  zIndex: number;
73
75
  onCancel: (...args: any[]) => void;
74
76
  onConfirm: (...args: any[]) => void;
77
+ onClickOutSide: (...args: any[]) => void;
75
78
  };
76
79
  constructor(props: PopconfirmProps);
77
80
  static getDerivedStateFromProps(props: PopconfirmProps, state: PopconfirmState): Partial<PopconfirmState>;
@@ -79,6 +82,7 @@ export default class Popconfirm extends BaseComponent<PopconfirmProps, Popconfir
79
82
  handleCancel: (e: React.MouseEvent) => void;
80
83
  handleConfirm: (e: React.MouseEvent) => void;
81
84
  handleVisibleChange: (visible: boolean) => void;
85
+ handleClickOutSide: (e: React.MouseEvent) => any;
82
86
  stopImmediatePropagation: (e: React.SyntheticEvent) => void;
83
87
  renderControls(): JSX.Element;
84
88
  renderConfirmPopCard(): JSX.Element;
@@ -38,6 +38,8 @@ export default class Popconfirm extends BaseComponent {
38
38
 
39
39
  this.handleVisibleChange = visible => this.foundation.handleVisibleChange(visible);
40
40
 
41
+ this.handleClickOutSide = e => this.foundation.handleClickOutSide(e);
42
+
41
43
  this.stopImmediatePropagation = e => e && e.nativeEvent && e.nativeEvent.stopImmediatePropagation();
42
44
 
43
45
  this.state = {
@@ -66,7 +68,8 @@ export default class Popconfirm extends BaseComponent {
66
68
  }),
67
69
  notifyConfirm: e => this.props.onConfirm(e),
68
70
  notifyCancel: e => this.props.onCancel(e),
69
- notifyVisibleChange: visible => this.props.onVisibleChange(visible)
71
+ notifyVisibleChange: visible => this.props.onVisibleChange(visible),
72
+ notifyClickOutSide: e => this.props.onClickOutSide(e)
70
73
  });
71
74
  }
72
75
 
@@ -165,7 +168,8 @@ export default class Popconfirm extends BaseComponent {
165
168
  const popContent = this.renderConfirmPopCard();
166
169
  const popProps = {
167
170
  onVisibleChange: this.handleVisibleChange,
168
- className: cssClasses.POPOVER
171
+ className: cssClasses.POPOVER,
172
+ onClickOutSide: this.handleClickOutSide
169
173
  };
170
174
 
171
175
  if (this.isControlled('visible')) {
@@ -196,13 +200,14 @@ Popconfirm.propTypes = {
196
200
  cancelType: PropTypes.string,
197
201
  onCancel: PropTypes.func,
198
202
  onConfirm: PropTypes.func,
199
- zIndex: PropTypes.number,
203
+ onClickOutSide: PropTypes.func,
200
204
  onVisibleChange: PropTypes.func,
201
205
  visible: PropTypes.bool,
202
206
  defaultVisible: PropTypes.bool,
203
207
  okButtonProps: PropTypes.object,
204
208
  cancelButtonProps: PropTypes.object,
205
209
  stopPropagation: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
210
+ zIndex: PropTypes.number,
206
211
  // private
207
212
  trigger: PropTypes.string,
208
213
  position: PropTypes.string
@@ -221,5 +226,6 @@ Popconfirm.defaultProps = {
221
226
  prefixCls: cssClasses.PREFIX,
222
227
  zIndex: numbers.DEFAULT_Z_INDEX,
223
228
  onCancel: noop,
224
- onConfirm: noop
229
+ onConfirm: noop,
230
+ onClickOutSide: noop
225
231
  };
@@ -22,6 +22,7 @@ export interface PopoverProps extends BaseProps {
22
22
  trigger?: Trigger;
23
23
  contentClassName?: string | any[];
24
24
  onVisibleChange?: (visible: boolean) => void;
25
+ onClickOutSide?: (e: React.MouseEvent) => void;
25
26
  showArrow?: boolean;
26
27
  spacing?: number;
27
28
  stopPropagation?: boolean | string;
@@ -50,6 +51,7 @@ declare class Popover extends React.PureComponent<PopoverProps, PopoverState> {
50
51
  trigger: PropTypes.Validator<"hover" | "focus" | "click" | "custom">;
51
52
  contentClassName: PropTypes.Requireable<string | any[]>;
52
53
  onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
54
+ onClickOutSide: PropTypes.Requireable<(...args: any[]) => any>;
53
55
  style: PropTypes.Requireable<object>;
54
56
  spacing: PropTypes.Requireable<number>;
55
57
  zIndex: PropTypes.Requireable<number>;
@@ -79,8 +81,8 @@ declare class Popover extends React.PureComponent<PopoverProps, PopoverState> {
79
81
  okText: string;
80
82
  position: string;
81
83
  prefixCls: string;
84
+ onClickOutSide: (...args: any[]) => void;
82
85
  };
83
- constructor(props: PopoverProps);
84
86
  renderPopCard(): JSX.Element;
85
87
  render(): JSX.Element;
86
88
  }
@@ -21,17 +21,11 @@ import { cssClasses, strings, numbers } from '@douyinfe/semi-foundation/lib/es/p
21
21
  import Tooltip from '../tooltip/index';
22
22
  import Arrow from './Arrow';
23
23
  import '@douyinfe/semi-foundation/lib/es/popover/popover.css';
24
+ import { noop } from 'lodash-es';
24
25
  const positionSet = strings.POSITION_SET;
25
26
  const triggerSet = strings.TRIGGER_SET;
26
27
 
27
28
  class Popover extends React.PureComponent {
28
- constructor(props) {
29
- super(props);
30
- this.state = {
31
- popConfirmVisible: false
32
- };
33
- }
34
-
35
29
  renderPopCard() {
36
30
  const {
37
31
  content,
@@ -107,6 +101,7 @@ Popover.propTypes = {
107
101
  trigger: PropTypes.oneOf(triggerSet).isRequired,
108
102
  contentClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
109
103
  onVisibleChange: PropTypes.func,
104
+ onClickOutSide: PropTypes.func,
110
105
  style: PropTypes.object,
111
106
  spacing: PropTypes.number,
112
107
  zIndex: PropTypes.number,
@@ -130,6 +125,7 @@ Popover.defaultProps = {
130
125
  cancelText: 'No',
131
126
  okText: 'Yes',
132
127
  position: 'bottom',
133
- prefixCls: cssClasses.PREFIX
128
+ prefixCls: cssClasses.PREFIX,
129
+ onClickOutSide: noop
134
130
  };
135
131
  export default Popover;
@@ -7,7 +7,7 @@ export declare type RadioMode = ArrayElement<typeof strings.MODE>;
7
7
  export interface RadioContextValue {
8
8
  mode?: RadioMode;
9
9
  radioGroup?: {
10
- value?: any;
10
+ value?: string | number;
11
11
  isButtonRadio?: any;
12
12
  disabled?: boolean;
13
13
  prefixCls?: string;
@@ -13,7 +13,7 @@ export declare type RadioProps = {
13
13
  autoFocus?: boolean;
14
14
  checked?: boolean;
15
15
  defaultChecked?: boolean;
16
- value?: any;
16
+ value?: string | number;
17
17
  disabled?: boolean;
18
18
  prefixCls?: string;
19
19
  displayMode?: RadioDisplayMode;
@@ -59,7 +59,7 @@ declare class Radio extends BaseComponent<RadioProps, RadioState> {
59
59
  constructor(props: RadioProps);
60
60
  get adapter(): RadioAdapter;
61
61
  isInGroup(): {
62
- value?: any;
62
+ value?: string | number;
63
63
  isButtonRadio?: any;
64
64
  disabled?: boolean;
65
65
  prefixCls?: string;
@@ -8,8 +8,8 @@ import { ArrayElement } from '../_base/base';
8
8
  import { RadioType } from './radio';
9
9
  import { RadioGroupButtonSize, RadioMode } from './context';
10
10
  export interface OptionItem {
11
- label?: string;
12
- value?: string;
11
+ label?: React.ReactNode;
12
+ value?: string | number;
13
13
  disabled?: boolean;
14
14
  extra?: React.ReactNode;
15
15
  style?: React.CSSProperties;
@@ -17,11 +17,11 @@ export interface OptionItem {
17
17
  }
18
18
  export declare type Options = string[] | Array<OptionItem>;
19
19
  export declare type RadioGroupProps = {
20
- defaultValue?: any;
20
+ defaultValue?: string | number;
21
21
  disabled?: boolean;
22
22
  name?: string;
23
23
  options?: Options;
24
- value?: any;
24
+ value?: string | number;
25
25
  onChange?: (event: RadioChangeEvent) => void;
26
26
  className?: string;
27
27
  style?: React.CSSProperties;
@@ -5,7 +5,6 @@ import BaseComponent, { ValidateStatus } from '../_base/baseComponent';
5
5
  import Option, { OptionProps } from './option';
6
6
  import OptionGroup from './optionGroup';
7
7
  import '@douyinfe/semi-foundation/lib/es/select/select.css';
8
- import '@douyinfe/semi-foundation/lib/es/select/option.css';
9
8
  import { Position, TooltipProps } from '../tooltip';
10
9
  export { OptionProps } from './option';
11
10
  export { OptionGroupProps } from './optionGroup';
@@ -22,7 +22,7 @@ import ConfigContext from '../configProvider/context';
22
22
  import SelectFoundation from '@douyinfe/semi-foundation/lib/es/select/foundation';
23
23
  import { cssClasses, strings, numbers } from '@douyinfe/semi-foundation/lib/es/select/constants';
24
24
  import BaseComponent from '../_base/baseComponent';
25
- import { isEqual, isString, noop } from 'lodash-es';
25
+ import { isEqual, isString, noop, get, isNumber } from 'lodash-es';
26
26
  import Tag from '../tag/index';
27
27
  import TagGroup from '../tag/group';
28
28
  import LocaleCosumer from '../locale/localeConsumer';
@@ -40,7 +40,6 @@ import { IconChevronDown, IconClear } from '@douyinfe/semi-icons';
40
40
  import { isSemiIcon } from '../_utils';
41
41
  import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
42
42
  import '@douyinfe/semi-foundation/lib/es/select/select.css';
43
- import '@douyinfe/semi-foundation/lib/es/select/option.css';
44
43
  const prefixcls = cssClasses.PREFIX;
45
44
  const key = 0; // Notes: Use the label of the option as the identifier, that is, the option in Select, the value is allowed to be the same, but the label must be unique
46
45
 
@@ -178,9 +177,10 @@ class Select extends BaseComponent {
178
177
  } = _this.props;
179
178
 
180
179
  if (optionList && optionList.length) {
181
- options = _mapInstanceProperty(optionList).call(optionList, itemOpt => _Object$assign({
180
+ options = _mapInstanceProperty(optionList).call(optionList, (itemOpt, index) => _Object$assign({
182
181
  _show: true,
183
- _selected: false
182
+ _selected: false,
183
+ _scrollIndex: index
184
184
  }, itemOpt));
185
185
  optionGroups[0] = {
186
186
  children: options,
@@ -755,15 +755,21 @@ class Select extends BaseComponent {
755
755
  }
756
756
 
757
757
  if (virtualize) {
758
- let minKey;
758
+ let minItemIndex = -1;
759
759
 
760
- _forEachInstanceProperty(selections).call(selections, (v, k) => {
761
- const tempKey = Number(String(k).match(/option-(.*)/)[1]);
762
- minKey = typeof minKey === 'number' && minKey < tempKey ? minKey : tempKey;
760
+ _forEachInstanceProperty(selections).call(selections, item => {
761
+ const itemIndex = get(item, '_scrollIndex');
762
+ /* When the itemIndex is legal */
763
+
764
+ if (isNumber(itemIndex) && itemIndex >= 0) {
765
+ minItemIndex = minItemIndex !== -1 && minItemIndex < itemIndex ? minItemIndex : itemIndex;
766
+ }
763
767
  });
764
768
 
765
- if (minKey) {
766
- this.virtualizeListRef.current.scrollToItem(minKey, 'center');
769
+ if (minItemIndex !== -1) {
770
+ try {
771
+ this.virtualizeListRef.current.scrollToItem(minItemIndex, 'center');
772
+ } catch (error) {}
767
773
  }
768
774
  } else {
769
775
  this.foundation.updateScrollTop();
@@ -144,14 +144,14 @@ class Option extends PureComponent {
144
144
  style: style
145
145
  }, showTick ? /*#__PURE__*/React.createElement("div", {
146
146
  className: selectedIconClassName
147
- }, /*#__PURE__*/React.createElement(IconTick, null)) : null, /*#__PURE__*/React.createElement("div", {
147
+ }, /*#__PURE__*/React.createElement(IconTick, null)) : null, isString(children) ? /*#__PURE__*/React.createElement("div", {
148
148
  className: "".concat(prefixCls, "-text")
149
149
  }, this.renderOptionContent({
150
150
  children,
151
151
  config,
152
152
  inputValue,
153
153
  prefixCls
154
- })));
154
+ })) : children);
155
155
  }
156
156
 
157
157
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { OptionProps } from './option';
3
3
  import { OptionGroupProps } from './optionGroup';
4
- declare const generateOption: (child: React.ReactElement, parent?: any) => OptionProps;
4
+ declare const generateOption: (child: React.ReactElement, parent: any, index: number) => OptionProps;
5
5
  declare const getOptionsFromGroup: (selectChildren: React.ReactNode) => {
6
6
  optionGroups: OptionGroupProps[];
7
7
  options: OptionProps[];
@@ -20,7 +20,7 @@ var __rest = this && this.__rest || function (s, e) {
20
20
  import React from 'react';
21
21
  import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
22
22
 
23
- const generateOption = (child, parent) => {
23
+ const generateOption = (child, parent, index) => {
24
24
  const childProps = child.props;
25
25
 
26
26
  if (!child || !childProps) {
@@ -32,7 +32,8 @@ const generateOption = (child, parent) => {
32
32
  // Drop-down menu rendering priority label value, children, value in turn downgrade
33
33
  label: childProps.label || childProps.children || childProps.value,
34
34
  _show: true,
35
- _selected: false
35
+ _selected: false,
36
+ _scrollIndex: index
36
37
  }, childProps), {
37
38
  _parentGroup: parent
38
39
  });
@@ -55,11 +56,13 @@ const getOptionsFromGroup = selectChildren => {
55
56
  const childNodes = _filterInstanceProperty(_context = React.Children.toArray(selectChildren)).call(_context, childNode => childNode && childNode.props);
56
57
 
57
58
  let type = '';
59
+ let optionIndex = -1;
58
60
 
59
61
  _forEachInstanceProperty(childNodes).call(childNodes, child => {
60
62
  if (child.type.isSelectOption) {
61
63
  type = 'option';
62
- const option = generateOption(child);
64
+ optionIndex++;
65
+ const option = generateOption(child, undefined, optionIndex);
63
66
  emptyGroup.children.push(option);
64
67
  options.push(option);
65
68
  } else if (child.type.isSelectOptionGroup) {
@@ -74,7 +77,10 @@ const getOptionsFromGroup = selectChildren => {
74
77
 
75
78
  children = React.Children.toArray(children);
76
79
 
77
- const childrenOption = _mapInstanceProperty(children).call(children, option => generateOption(option, restGroupProps));
80
+ const childrenOption = _mapInstanceProperty(children).call(children, option => {
81
+ optionIndex++;
82
+ return generateOption(option, restGroupProps, optionIndex);
83
+ });
78
84
 
79
85
  const group = _Object$assign(_Object$assign({}, child.props), {
80
86
  children: childrenOption,
@@ -399,6 +399,7 @@ export default class Slider extends BaseComponent {
399
399
  },
400
400
  onHandleMove: function (mousePos, isMin) {
401
401
  let stateChangeCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
402
+ let clickTrack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
402
403
 
403
404
  const sliderDOMIsInRenderTree = _this.foundation.checkAndUpdateIsInRenderTreeState();
404
405
 
@@ -426,7 +427,8 @@ export default class Slider extends BaseComponent {
426
427
  if (!isEqual(_this.foundation.outPutValue(currentValue), outPutValue)) {
427
428
  onChange(outPutValue);
428
429
 
429
- if (_this.foundation.valueFormatIsCorrect(value)) {
430
+ if (!clickTrack && _this.foundation.valueFormatIsCorrect(value)) {
431
+ // still require afterChangeCallback when click on the track directly, need skip here
430
432
  return false;
431
433
  }
432
434
 
@@ -8,7 +8,7 @@ export interface SpinProps {
8
8
  spinning?: boolean;
9
9
  indicator?: React.ReactNode;
10
10
  delay?: number;
11
- tip?: string;
11
+ tip?: React.ReactNode;
12
12
  wrapperClassName?: string;
13
13
  style?: React.CSSProperties;
14
14
  childStyle?: React.CSSProperties;
@@ -25,7 +25,7 @@ declare class Spin extends BaseComponent<SpinProps, SpinState> {
25
25
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
26
26
  indicator: PropTypes.Requireable<PropTypes.ReactNodeLike>;
27
27
  delay: PropTypes.Requireable<number>;
28
- tip: PropTypes.Requireable<string>;
28
+ tip: PropTypes.Requireable<PropTypes.ReactNodeLike>;
29
29
  wrapperClassName: PropTypes.Requireable<string>;
30
30
  childStyle: PropTypes.Requireable<object>;
31
31
  style: PropTypes.Requireable<object>;
@@ -107,7 +107,7 @@ Spin.propTypes = {
107
107
  children: PropTypes.node,
108
108
  indicator: PropTypes.node,
109
109
  delay: PropTypes.number,
110
- tip: PropTypes.string,
110
+ tip: PropTypes.node,
111
111
  wrapperClassName: PropTypes.string,
112
112
  childStyle: PropTypes.object,
113
113
  style: PropTypes.object
@@ -1,6 +1,6 @@
1
- import React, { ReactNode, MouseEvent } from 'react';
1
+ import React, { MouseEvent, ReactNode } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { TabBarProps, PlainTab } from './interface';
3
+ import { PlainTab, TabBarProps } from './interface';
4
4
  export interface TabBarState {
5
5
  endInd: number;
6
6
  rePosKey: number;
@@ -22,6 +22,8 @@ declare class TabBar extends React.Component<TabBarProps, TabBarState> {
22
22
  tabBarExtraContent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
23
23
  tabPosition: PropTypes.Requireable<string>;
24
24
  type: PropTypes.Requireable<string>;
25
+ closable: PropTypes.Requireable<boolean>;
26
+ deleteTabItem: PropTypes.Requireable<(...args: any[]) => any>;
25
27
  };
26
28
  uuid: string;
27
29
  constructor(props: TabBarProps);
@@ -24,7 +24,7 @@ import OverflowList from '../overflowList';
24
24
  import Dropdown from '../dropdown';
25
25
  import Button from '../button';
26
26
  import { isEmpty } from 'lodash-es';
27
- import { IconChevronRight, IconChevronLeft } from '@douyinfe/semi-icons';
27
+ import { IconChevronLeft, IconChevronRight, IconClose } from '@douyinfe/semi-icons';
28
28
  import { getUuidv4 } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
29
29
 
30
30
  class TabBar extends React.Component {
@@ -51,9 +51,15 @@ class TabBar extends React.Component {
51
51
 
52
52
  this.renderTabItem = panel => {
53
53
  const {
54
- size
54
+ size,
55
+ type,
56
+ deleteTabItem
55
57
  } = this.props;
56
58
  const panelIcon = panel.icon ? this.renderIcon(panel.icon) : null;
59
+ const closableIcon = type === 'card' && panel.closable ? /*#__PURE__*/React.createElement(IconClose, {
60
+ className: "".concat(cssClasses.TABS_TAB, "-icon-close"),
61
+ onClick: e => deleteTabItem(panel.itemKey, e)
62
+ }) : null;
57
63
  let events = {};
58
64
  const key = panel.itemKey;
59
65
 
@@ -76,7 +82,7 @@ class TabBar extends React.Component {
76
82
  }, events, {
77
83
  className: className,
78
84
  key: this._getItemKey(key)
79
- }), panelIcon, panel.tab);
85
+ }), panelIcon, panel.tab, closableIcon);
80
86
  };
81
87
 
82
88
  this.renderTabComponents = list => _mapInstanceProperty(list).call(list, panel => this.renderTabItem(panel));
@@ -278,6 +284,8 @@ TabBar.propTypes = {
278
284
  style: PropTypes.object,
279
285
  tabBarExtraContent: PropTypes.node,
280
286
  tabPosition: PropTypes.oneOf(strings.POSITION_MAP),
281
- type: PropTypes.oneOf(strings.TYPE_MAP)
287
+ type: PropTypes.oneOf(strings.TYPE_MAP),
288
+ closable: PropTypes.bool,
289
+ deleteTabItem: PropTypes.func
282
290
  };
283
291
  export default TabBar;
@@ -1,6 +1,6 @@
1
1
  import React, { PureComponent, ReactNode } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { TabPaneProps, PlainTab } from './interface';
3
+ import { PlainTab, TabPaneProps } from './interface';
4
4
  declare class TabPane extends PureComponent<TabPaneProps> {
5
5
  static isTabPane: boolean;
6
6
  static contextType: React.Context<import("./interface").TabContextValue>;
@@ -12,6 +12,7 @@ declare class TabPane extends PureComponent<TabPaneProps> {
12
12
  itemKey: PropTypes.Requireable<string>;
13
13
  tab: PropTypes.Requireable<PropTypes.ReactNodeLike>;
14
14
  icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
15
+ closable: PropTypes.Requireable<boolean>;
15
16
  };
16
17
  lastActiveKey: string;
17
18
  ref: React.RefObject<HTMLDivElement>;
@@ -15,7 +15,7 @@ var __rest = this && this.__rest || function (s, e) {
15
15
  return t;
16
16
  };
17
17
 
18
- import React, { PureComponent, createRef } from 'react';
18
+ import React, { createRef, PureComponent } from 'react';
19
19
  import PropTypes from 'prop-types';
20
20
  import cls from 'classnames';
21
21
  import { cssClasses } from '@douyinfe/semi-foundation/lib/es/tabs/constants';
@@ -131,6 +131,7 @@ TabPane.propTypes = {
131
131
  disabled: PropTypes.bool,
132
132
  itemKey: PropTypes.string,
133
133
  tab: PropTypes.node,
134
- icon: PropTypes.node
134
+ icon: PropTypes.node,
135
+ closable: PropTypes.bool
135
136
  };
136
137
  export default TabPane;