@douyinfe/semi-ui 2.0.9-alpha.4 → 2.1.0-alpha.3
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.
- package/dist/css/semi.css +14 -1
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +1625 -2525
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/es/_base/baseComponent.js +1 -5
- package/lib/es/_portal/index.js +7 -17
- package/lib/es/_utils/index.js +13 -16
- package/lib/es/breadcrumb/index.js +2 -4
- package/lib/es/breadcrumb/item.js +4 -6
- package/lib/es/button/index.d.ts +0 -1
- package/lib/es/button/index.js +2 -4
- package/lib/es/calendar/monthCalendar.js +9 -11
- package/lib/es/cascader/index.d.ts +1 -0
- package/lib/es/cascader/index.js +23 -14
- package/lib/es/cascader/item.js +1 -2
- package/lib/es/collapse/item.js +1 -2
- package/lib/es/collapsible/index.js +9 -9
- package/lib/es/datePicker/dateInput.js +9 -29
- package/lib/es/datePicker/datePicker.js +12 -49
- package/lib/es/datePicker/footer.js +1 -2
- package/lib/es/datePicker/index.js +12 -15
- package/lib/es/datePicker/yearAndMonth.js +17 -23
- package/lib/es/dropdown/dropdownDivider.js +1 -2
- package/lib/es/form/baseForm.d.ts +4 -10
- package/lib/es/form/field.d.ts +4 -22
- package/lib/es/form/field.js +2 -18
- package/lib/es/form/hoc/withField.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +3 -14
- package/lib/es/iconButton/index.d.ts +0 -1
- package/lib/es/iconButton/index.js +0 -1
- package/lib/es/inputNumber/index.js +4 -12
- package/lib/es/locale/localeConsumer.js +3 -6
- package/lib/es/modal/ConfirmModal.js +2 -2
- package/lib/es/modal/confirm.js +2 -2
- package/lib/es/modal/useModal/HookModal.js +2 -2
- package/lib/es/motions/Rotate.js +4 -6
- package/lib/es/navigation/CollapseButton.js +7 -9
- package/lib/es/navigation/Item.js +7 -33
- package/lib/es/navigation/OpenIconTransition.js +4 -6
- package/lib/es/navigation/SubNav.js +6 -33
- package/lib/es/navigation/SubNavTransition.js +5 -7
- package/lib/es/navigation/index.js +6 -24
- package/lib/es/notification/NoticeTransition.js +5 -7
- package/lib/es/notification/index.js +8 -16
- package/lib/es/notification/useNotification/index.js +7 -11
- package/lib/es/overflowList/index.js +4 -9
- package/lib/es/overflowList/intersectionObserver.js +1 -2
- package/lib/es/popconfirm/index.d.ts +5 -1
- package/lib/es/popconfirm/index.js +10 -4
- package/lib/es/popover/Arrow.js +1 -3
- package/lib/es/popover/index.d.ts +3 -1
- package/lib/es/popover/index.js +4 -8
- package/lib/es/radio/context.d.ts +1 -1
- package/lib/es/radio/radio.d.ts +2 -2
- package/lib/es/radio/radioGroup.d.ts +4 -4
- package/lib/es/resizeObserver/index.js +1 -2
- package/lib/es/scrollList/scrollItem.js +24 -40
- package/lib/es/select/index.js +19 -16
- package/lib/es/select/option.js +8 -10
- package/lib/es/select/utils.d.ts +1 -1
- package/lib/es/select/utils.js +10 -4
- package/lib/es/select/virtualRow.js +5 -6
- package/lib/es/sideSheet/SideSheetTransition.js +1 -3
- package/lib/es/slider/index.js +11 -23
- package/lib/es/spin/icon.js +1 -3
- package/lib/es/table/Body/BaseRow.js +8 -16
- package/lib/es/table/Body/SectionRow.js +3 -6
- package/lib/es/table/Body/index.js +32 -49
- package/lib/es/table/Column.js +1 -2
- package/lib/es/table/ColumnFilter.js +2 -6
- package/lib/es/table/ColumnSelection.js +1 -5
- package/lib/es/table/HeadTable.js +3 -4
- package/lib/es/table/ResizableTable.js +20 -31
- package/lib/es/table/Table.js +63 -160
- package/lib/es/table/TableCell.js +3 -5
- package/lib/es/table/TableContextProvider.js +15 -16
- package/lib/es/table/TableHeader.js +1 -4
- package/lib/es/table/utils.js +1 -3
- package/lib/es/tabs/TabBar.d.ts +4 -2
- package/lib/es/tabs/TabBar.js +12 -4
- package/lib/es/tabs/TabPane.d.ts +2 -1
- package/lib/es/tabs/TabPane.js +3 -2
- package/lib/es/tabs/TabPaneTransition.js +9 -12
- package/lib/es/tabs/index.d.ts +3 -1
- package/lib/es/tabs/index.js +83 -14
- package/lib/es/tabs/interface.d.ts +6 -1
- package/lib/es/tagInput/index.d.ts +3 -0
- package/lib/es/tagInput/index.js +6 -1
- package/lib/es/timePicker/Combobox.js +5 -6
- package/lib/es/timePicker/TimeInput.js +3 -11
- package/lib/es/timePicker/TimePicker.js +7 -21
- package/lib/es/timePicker/index.js +12 -15
- package/lib/es/toast/ToastTransition.js +8 -12
- package/lib/es/toast/useToast/index.js +3 -6
- package/lib/es/tooltip/TooltipStyledTransition.js +10 -14
- package/lib/es/tooltip/index.d.ts +3 -0
- package/lib/es/tooltip/index.js +22 -28
- package/lib/es/transfer/index.js +15 -18
- package/lib/es/tree/index.js +28 -38
- package/lib/es/tree/interface.d.ts +2 -2
- package/lib/es/treeSelect/index.d.ts +2 -11
- package/lib/es/treeSelect/index.js +32 -44
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/typography/util.js +3 -12
- package/lib/es/upload/fileCard.js +53 -62
- package/lib/es/upload/index.d.ts +1 -1
- package/lib/es/upload/index.js +23 -32
- package/package.json +8 -8
|
@@ -31,10 +31,7 @@ const defaultConfig = {
|
|
|
31
31
|
|
|
32
32
|
class NotificationList extends BaseComponent {
|
|
33
33
|
constructor(props) {
|
|
34
|
-
var _this;
|
|
35
|
-
|
|
36
34
|
super(props);
|
|
37
|
-
_this = this;
|
|
38
35
|
|
|
39
36
|
this.add = noticeOpts => this.foundation.addNotice(noticeOpts);
|
|
40
37
|
|
|
@@ -44,13 +41,11 @@ class NotificationList extends BaseComponent {
|
|
|
44
41
|
|
|
45
42
|
this.destroyAll = () => this.foundation.destroyAll();
|
|
46
43
|
|
|
47
|
-
this.renderNoticeInPosition =
|
|
48
|
-
let removedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
44
|
+
this.renderNoticeInPosition = (notices, position, removedItems = []) => {
|
|
49
45
|
const className = cls(cssClasses.LIST); // TODO notifyOnClose
|
|
50
46
|
|
|
51
47
|
if (notices.length) {
|
|
52
|
-
const style =
|
|
53
|
-
|
|
48
|
+
const style = this.setPosInStyle(notices[0]);
|
|
54
49
|
return (
|
|
55
50
|
/*#__PURE__*/
|
|
56
51
|
// @ts-ignore
|
|
@@ -66,11 +61,11 @@ class NotificationList extends BaseComponent {
|
|
|
66
61
|
}, _findInstanceProperty(removedItems).call(removedItems, item => item.id === notice.id) ? null : transitionStyle => /*#__PURE__*/React.createElement(Notice, _Object$assign({}, notice, {
|
|
67
62
|
style: _Object$assign(_Object$assign({}, transitionStyle), notice.style),
|
|
68
63
|
key: notice.id,
|
|
69
|
-
close:
|
|
64
|
+
close: this.remove
|
|
70
65
|
}))) : /*#__PURE__*/React.createElement(Notice, _Object$assign({}, notice, {
|
|
71
66
|
style: _Object$assign({}, notice.style),
|
|
72
67
|
key: notice.id,
|
|
73
|
-
close:
|
|
68
|
+
close: this.remove
|
|
74
69
|
}))))
|
|
75
70
|
);
|
|
76
71
|
}
|
|
@@ -88,15 +83,12 @@ class NotificationList extends BaseComponent {
|
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
get adapter() {
|
|
91
|
-
var _this2 = this;
|
|
92
|
-
|
|
93
86
|
return _Object$assign(_Object$assign({}, super.adapter), {
|
|
94
|
-
updateNotices:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
_this2.removeItemStorage = [...removedItems]; // setState is async sometimes and react often merges state, so use "this" , make sure other code always get right data.
|
|
87
|
+
updateNotices: (notices, removedItems = []) => {
|
|
88
|
+
this.noticeStorage = [...notices];
|
|
89
|
+
this.removeItemStorage = [...removedItems]; // setState is async sometimes and react often merges state, so use "this" , make sure other code always get right data.
|
|
98
90
|
|
|
99
|
-
|
|
91
|
+
this.setState({
|
|
100
92
|
notices,
|
|
101
93
|
removedItems
|
|
102
94
|
});
|
|
@@ -30,12 +30,9 @@ function usePatchElement() {
|
|
|
30
30
|
config
|
|
31
31
|
}, ...originElements]);
|
|
32
32
|
return id => {
|
|
33
|
-
setElements(originElements => _filterInstanceProperty(originElements).call(originElements,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} = _ref;
|
|
37
|
-
return configOfCurrentElement.id !== id;
|
|
38
|
-
}));
|
|
33
|
+
setElements(originElements => _filterInstanceProperty(originElements).call(originElements, ({
|
|
34
|
+
config: configOfCurrentElement
|
|
35
|
+
}) => configOfCurrentElement.id !== id));
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
38
|
|
|
@@ -51,11 +48,10 @@ function usePatchElement() {
|
|
|
51
48
|
bottomRight: []
|
|
52
49
|
};
|
|
53
50
|
|
|
54
|
-
_forEachInstanceProperty(elements).call(elements,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} = _ref2;
|
|
51
|
+
_forEachInstanceProperty(elements).call(elements, ({
|
|
52
|
+
element,
|
|
53
|
+
config
|
|
54
|
+
}) => {
|
|
59
55
|
const {
|
|
60
56
|
position
|
|
61
57
|
} = config;
|
|
@@ -22,10 +22,7 @@ const RenderMode = strings.MODE_MAP; // reference to https://github.com/palantir
|
|
|
22
22
|
|
|
23
23
|
class OverflowList extends BaseComponent {
|
|
24
24
|
constructor(props) {
|
|
25
|
-
var _this;
|
|
26
|
-
|
|
27
25
|
super(props);
|
|
28
|
-
_this = this;
|
|
29
26
|
this.scroller = null;
|
|
30
27
|
this.spacer = null;
|
|
31
28
|
|
|
@@ -36,18 +33,16 @@ class OverflowList extends BaseComponent {
|
|
|
36
33
|
return renderMode === RenderMode.SCROLL;
|
|
37
34
|
};
|
|
38
35
|
|
|
39
|
-
this.resize =
|
|
40
|
-
let entries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
41
|
-
|
|
36
|
+
this.resize = (entries = []) => {
|
|
42
37
|
// if any parent is growing, assume we have more room than before
|
|
43
38
|
const growing = _someInstanceProperty(entries).call(entries, entry => {
|
|
44
|
-
const previousWidth =
|
|
39
|
+
const previousWidth = this.previousWidths.get(entry.target) || 0;
|
|
45
40
|
return entry.contentRect.width > previousWidth;
|
|
46
41
|
});
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
this.repartition(growing);
|
|
49
44
|
|
|
50
|
-
_forEachInstanceProperty(entries).call(entries, entry =>
|
|
45
|
+
_forEachInstanceProperty(entries).call(entries, entry => this.previousWidths.set(entry.target, entry.contentRect.width));
|
|
51
46
|
};
|
|
52
47
|
|
|
53
48
|
this.repartition = growing => {
|
|
@@ -45,10 +45,9 @@ export default class ReactIntersectionObserver extends React.PureComponent {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
observeElement() {
|
|
48
|
+
observeElement(force = false) {
|
|
49
49
|
var _context;
|
|
50
50
|
|
|
51
|
-
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
52
51
|
const {
|
|
53
52
|
items
|
|
54
53
|
} = this.props;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
};
|
package/lib/es/popover/Arrow.js
CHANGED
|
@@ -19,9 +19,7 @@ import classnames from 'classnames';
|
|
|
19
19
|
import { get } from 'lodash-es';
|
|
20
20
|
import { numbers, cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/popover/constants';
|
|
21
21
|
|
|
22
|
-
const Arrow =
|
|
23
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
24
|
-
|
|
22
|
+
const Arrow = (props = {}) => {
|
|
25
23
|
const {
|
|
26
24
|
position = '',
|
|
27
25
|
className,
|
|
@@ -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
|
}
|
package/lib/es/popover/index.js
CHANGED
|
@@ -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;
|
package/lib/es/radio/radio.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare type RadioProps = {
|
|
|
13
13
|
autoFocus?: boolean;
|
|
14
14
|
checked?: boolean;
|
|
15
15
|
defaultChecked?: boolean;
|
|
16
|
-
value?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
20
|
+
defaultValue?: string | number;
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
name?: string;
|
|
23
23
|
options?: Options;
|
|
24
|
-
value?:
|
|
24
|
+
value?: string | number;
|
|
25
25
|
onChange?: (event: RadioChangeEvent) => void;
|
|
26
26
|
className?: string;
|
|
27
27
|
style?: React.CSSProperties;
|
|
@@ -48,8 +48,7 @@ export default class ReactResizeObserver extends BaseComponent {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
observeElement() {
|
|
52
|
-
let force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
51
|
+
observeElement(force = false) {
|
|
53
52
|
const element = this.getElement();
|
|
54
53
|
|
|
55
54
|
if (!(element && element instanceof Element)) {
|
|
@@ -15,12 +15,8 @@ const msPerFrame = 1000 / 60;
|
|
|
15
15
|
const blankReg = /^\s*$/;
|
|
16
16
|
const wheelMode = 'wheel';
|
|
17
17
|
export default class ScrollItem extends BaseComponent {
|
|
18
|
-
constructor() {
|
|
19
|
-
var _this;
|
|
20
|
-
|
|
21
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18
|
+
constructor(props = {}) {
|
|
22
19
|
super(props);
|
|
23
|
-
_this = this;
|
|
24
20
|
|
|
25
21
|
this._cacheNode = (name, node) => name && node && Object.prototype.hasOwnProperty.call(this, name) && (this[name] = node);
|
|
26
22
|
|
|
@@ -105,12 +101,11 @@ export default class ScrollItem extends BaseComponent {
|
|
|
105
101
|
|
|
106
102
|
this.isWheelMode = () => this.props.mode === wheelMode;
|
|
107
103
|
|
|
108
|
-
this.addClassToNode =
|
|
109
|
-
let selectedCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : cssClasses.SELECTED;
|
|
104
|
+
this.addClassToNode = (selectedNode, selectedCls = cssClasses.SELECTED) => {
|
|
110
105
|
const {
|
|
111
106
|
list
|
|
112
|
-
} =
|
|
113
|
-
selectedNode = selectedNode ||
|
|
107
|
+
} = this;
|
|
108
|
+
selectedNode = selectedNode || this.selectedNode;
|
|
114
109
|
|
|
115
110
|
if (isElement(selectedNode) && isElement(list)) {
|
|
116
111
|
const {
|
|
@@ -163,37 +158,31 @@ export default class ScrollItem extends BaseComponent {
|
|
|
163
158
|
this.scrollToPos(targetTop, duration);
|
|
164
159
|
};
|
|
165
160
|
|
|
166
|
-
this.scrollToPos =
|
|
167
|
-
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : numbers.DEFAULT_SCROLL_DURATION;
|
|
161
|
+
this.scrollToPos = (targetTop, duration = numbers.DEFAULT_SCROLL_DURATION) => {
|
|
168
162
|
const {
|
|
169
163
|
wrapper
|
|
170
|
-
} =
|
|
164
|
+
} = this; // this.isWheelMode() && this.addClassToNode();
|
|
171
165
|
|
|
172
|
-
if (duration &&
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
_this.scrolling = false;
|
|
166
|
+
if (duration && this.props.motion) {
|
|
167
|
+
if (this.scrollAnimation) {
|
|
168
|
+
this.scrollAnimation.destroy();
|
|
169
|
+
this.scrolling = false;
|
|
177
170
|
}
|
|
178
171
|
|
|
179
172
|
if (wrapper.scrollTop === targetTop) {
|
|
180
|
-
if (
|
|
181
|
-
const nodeInfo =
|
|
182
|
-
|
|
183
|
-
_this.addClassToNode(nodeInfo.nearestNode);
|
|
173
|
+
if (this.isWheelMode()) {
|
|
174
|
+
const nodeInfo = this.foundation.getNearestNodeInfo(this.list, this.selector);
|
|
175
|
+
this.addClassToNode(nodeInfo.nearestNode);
|
|
184
176
|
}
|
|
185
177
|
} else {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
_this.addClassToNode(nodeInfo.nearestNode);
|
|
178
|
+
this.scrollAnimation = animatedScrollTo(wrapper, targetTop, duration);
|
|
179
|
+
this.scrollAnimation.on('rest', () => {
|
|
180
|
+
if (this.isWheelMode()) {
|
|
181
|
+
const nodeInfo = this.foundation.getNearestNodeInfo(this.list, this.selector);
|
|
182
|
+
this.addClassToNode(nodeInfo.nearestNode);
|
|
193
183
|
}
|
|
194
184
|
});
|
|
195
|
-
|
|
196
|
-
_this.scrollAnimation.start();
|
|
185
|
+
this.scrollAnimation.start();
|
|
197
186
|
}
|
|
198
187
|
} else {
|
|
199
188
|
wrapper.scrollTop = targetTop;
|
|
@@ -248,14 +237,13 @@ export default class ScrollItem extends BaseComponent {
|
|
|
248
237
|
|
|
249
238
|
this.getItmHeight = itm => itm && itm.offsetHeight || numbers.DEFAULT_ITEM_HEIGHT;
|
|
250
239
|
|
|
251
|
-
this.renderItemList =
|
|
252
|
-
let prefixKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
240
|
+
this.renderItemList = (prefixKey = '') => {
|
|
253
241
|
const {
|
|
254
242
|
selectedIndex,
|
|
255
243
|
mode,
|
|
256
244
|
transform: commonTrans,
|
|
257
245
|
list
|
|
258
|
-
} =
|
|
246
|
+
} = this.props;
|
|
259
247
|
return _mapInstanceProperty(list).call(list, (item, index) => {
|
|
260
248
|
const {
|
|
261
249
|
transform: itemTrans
|
|
@@ -281,8 +269,8 @@ export default class ScrollItem extends BaseComponent {
|
|
|
281
269
|
|
|
282
270
|
const events = {};
|
|
283
271
|
|
|
284
|
-
if (!
|
|
285
|
-
events.onClick = () =>
|
|
272
|
+
if (!this.isWheelMode() && !item.disabled) {
|
|
273
|
+
events.onClick = () => this.foundation.selectIndex(index, this.list);
|
|
286
274
|
}
|
|
287
275
|
|
|
288
276
|
return (
|
|
@@ -397,8 +385,6 @@ export default class ScrollItem extends BaseComponent {
|
|
|
397
385
|
}
|
|
398
386
|
|
|
399
387
|
get adapter() {
|
|
400
|
-
var _this2 = this;
|
|
401
|
-
|
|
402
388
|
return _Object$assign(_Object$assign({}, super.adapter), {
|
|
403
389
|
setState: (states, callback) => this.setState(_Object$assign({}, states), callback),
|
|
404
390
|
setPrependCount: prependCount => this.setState({
|
|
@@ -409,9 +395,7 @@ export default class ScrollItem extends BaseComponent {
|
|
|
409
395
|
}),
|
|
410
396
|
isDisabledIndex: this.isDisabledIndex,
|
|
411
397
|
setSelectedNode: selectedNode => this._cacheWillSelectNode(selectedNode),
|
|
412
|
-
notifySelectItem:
|
|
413
|
-
return _this2.props.onSelect(...arguments);
|
|
414
|
-
},
|
|
398
|
+
notifySelectItem: (...args) => this.props.onSelect(...args),
|
|
415
399
|
scrollToCenter: this.scrollToCenter
|
|
416
400
|
});
|
|
417
401
|
}
|
package/lib/es/select/index.js
CHANGED
|
@@ -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 LocaleConsumer from '../locale/localeConsumer';
|
|
@@ -84,8 +84,6 @@ class Select extends BaseComponent {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
get adapter() {
|
|
87
|
-
var _this = this;
|
|
88
|
-
|
|
89
87
|
const keyboardAdapter = {
|
|
90
88
|
registerKeyDown: cb => {
|
|
91
89
|
const keyboardEventSet = {
|
|
@@ -168,18 +166,18 @@ class Select extends BaseComponent {
|
|
|
168
166
|
};
|
|
169
167
|
return _Object$assign(_Object$assign(_Object$assign(_Object$assign(_Object$assign({}, super.adapter), keyboardAdapter), filterAdapter), multipleAdapter), {
|
|
170
168
|
// Collect all subitems, each item is visible by default when collected, and is not selected
|
|
171
|
-
getOptionsFromChildren:
|
|
172
|
-
let children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.children;
|
|
169
|
+
getOptionsFromChildren: (children = this.props.children) => {
|
|
173
170
|
let optionGroups = [];
|
|
174
171
|
let options = [];
|
|
175
172
|
const {
|
|
176
173
|
optionList
|
|
177
|
-
} =
|
|
174
|
+
} = this.props;
|
|
178
175
|
|
|
179
176
|
if (optionList && optionList.length) {
|
|
180
|
-
options = _mapInstanceProperty(optionList).call(optionList, itemOpt => _Object$assign({
|
|
177
|
+
options = _mapInstanceProperty(optionList).call(optionList, (itemOpt, index) => _Object$assign({
|
|
181
178
|
_show: true,
|
|
182
|
-
_selected: false
|
|
179
|
+
_selected: false,
|
|
180
|
+
_scrollIndex: index
|
|
183
181
|
}, itemOpt));
|
|
184
182
|
optionGroups[0] = {
|
|
185
183
|
children: options,
|
|
@@ -191,10 +189,9 @@ class Select extends BaseComponent {
|
|
|
191
189
|
options = result.options;
|
|
192
190
|
}
|
|
193
191
|
|
|
194
|
-
|
|
192
|
+
this.setState({
|
|
195
193
|
optionGroups
|
|
196
194
|
});
|
|
197
|
-
|
|
198
195
|
return options;
|
|
199
196
|
},
|
|
200
197
|
updateOptions: options => {
|
|
@@ -754,15 +751,21 @@ class Select extends BaseComponent {
|
|
|
754
751
|
}
|
|
755
752
|
|
|
756
753
|
if (virtualize) {
|
|
757
|
-
let
|
|
754
|
+
let minItemIndex = -1;
|
|
755
|
+
|
|
756
|
+
_forEachInstanceProperty(selections).call(selections, item => {
|
|
757
|
+
const itemIndex = get(item, '_scrollIndex');
|
|
758
|
+
/* When the itemIndex is legal */
|
|
758
759
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
760
|
+
if (isNumber(itemIndex) && itemIndex >= 0) {
|
|
761
|
+
minItemIndex = minItemIndex !== -1 && minItemIndex < itemIndex ? minItemIndex : itemIndex;
|
|
762
|
+
}
|
|
762
763
|
});
|
|
763
764
|
|
|
764
|
-
if (
|
|
765
|
-
|
|
765
|
+
if (minItemIndex !== -1) {
|
|
766
|
+
try {
|
|
767
|
+
this.virtualizeListRef.current.scrollToItem(minItemIndex, 'center');
|
|
768
|
+
} catch (error) {}
|
|
766
769
|
}
|
|
767
770
|
} else {
|
|
768
771
|
this.foundation.updateScrollTop();
|
package/lib/es/select/option.js
CHANGED
|
@@ -46,14 +46,12 @@ class Option extends PureComponent {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
renderOptionContent(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} = _ref;
|
|
56
|
-
|
|
49
|
+
renderOptionContent({
|
|
50
|
+
config,
|
|
51
|
+
children,
|
|
52
|
+
inputValue,
|
|
53
|
+
prefixCls
|
|
54
|
+
}) {
|
|
57
55
|
if (isString(children) && inputValue) {
|
|
58
56
|
return getHighLightTextHTML(config);
|
|
59
57
|
}
|
|
@@ -144,14 +142,14 @@ class Option extends PureComponent {
|
|
|
144
142
|
style: style
|
|
145
143
|
}, showTick ? /*#__PURE__*/React.createElement("div", {
|
|
146
144
|
className: selectedIconClassName
|
|
147
|
-
}, /*#__PURE__*/React.createElement(IconTick, null)) : null, /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
}, /*#__PURE__*/React.createElement(IconTick, null)) : null, isString(children) ? /*#__PURE__*/React.createElement("div", {
|
|
148
146
|
className: "".concat(prefixCls, "-text")
|
|
149
147
|
}, this.renderOptionContent({
|
|
150
148
|
children,
|
|
151
149
|
config,
|
|
152
150
|
inputValue,
|
|
153
151
|
prefixCls
|
|
154
|
-
})));
|
|
152
|
+
})) : children);
|
|
155
153
|
}
|
|
156
154
|
|
|
157
155
|
}
|
package/lib/es/select/utils.d.ts
CHANGED
|
@@ -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
|
|
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[];
|