@douyinfe/semi-ui 2.44.1 → 2.45.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.
- package/dist/umd/semi-ui.js +98 -54
- 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/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.js +1 -1
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/dropdown/index.js +1 -1
- package/lib/cjs/input/textarea.d.ts +5 -1
- package/lib/cjs/input/textarea.js +4 -2
- package/lib/cjs/notification/index.d.ts +9 -7
- package/lib/cjs/notification/index.js +27 -8
- package/lib/cjs/popover/index.d.ts +5 -2
- package/lib/cjs/popover/index.js +3 -2
- package/lib/cjs/select/index.d.ts +1 -1
- package/lib/cjs/select/index.js +1 -1
- package/lib/cjs/toast/index.js +0 -3
- package/lib/cjs/tooltip/index.d.ts +5 -2
- package/lib/cjs/tooltip/index.js +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/datePicker.js +1 -1
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/dropdown/index.js +1 -1
- package/lib/es/input/textarea.d.ts +5 -1
- package/lib/es/input/textarea.js +4 -2
- package/lib/es/notification/index.d.ts +9 -7
- package/lib/es/notification/index.js +27 -8
- package/lib/es/popover/index.d.ts +5 -2
- package/lib/es/popover/index.js +3 -2
- package/lib/es/select/index.d.ts +1 -1
- package/lib/es/select/index.js +1 -1
- package/lib/es/toast/index.js +0 -3
- package/lib/es/tooltip/index.d.ts +5 -2
- package/lib/es/tooltip/index.js +1 -1
- package/package.json +8 -8
|
@@ -110,7 +110,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
110
110
|
validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
|
|
111
111
|
renderDate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
112
112
|
renderFullDate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
113
|
-
spacing: PropTypes.Requireable<number
|
|
113
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
114
114
|
startDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
115
115
|
endDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
116
116
|
autoSwitchDate: PropTypes.Requireable<boolean>;
|
|
@@ -827,7 +827,7 @@ DatePicker.propTypes = {
|
|
|
827
827
|
validateStatus: _propTypes.default.oneOf(_constants.strings.STATUS),
|
|
828
828
|
renderDate: _propTypes.default.func,
|
|
829
829
|
renderFullDate: _propTypes.default.func,
|
|
830
|
-
spacing: _propTypes.default.number,
|
|
830
|
+
spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
|
|
831
831
|
startDateOffset: _propTypes.default.func,
|
|
832
832
|
endDateOffset: _propTypes.default.func,
|
|
833
833
|
autoSwitchDate: _propTypes.default.bool,
|
|
@@ -69,7 +69,7 @@ declare class Dropdown extends BaseComponent<DropdownProps, DropdownState> {
|
|
|
69
69
|
position: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
70
70
|
rePosKey: PropTypes.Requireable<NonNullable<string | number>>;
|
|
71
71
|
render: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
72
|
-
spacing: PropTypes.Requireable<number
|
|
72
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
73
73
|
showTick: PropTypes.Requireable<boolean>;
|
|
74
74
|
style: PropTypes.Requireable<object>;
|
|
75
75
|
trigger: PropTypes.Requireable<string>;
|
|
@@ -229,7 +229,7 @@ Dropdown.propTypes = {
|
|
|
229
229
|
position: _propTypes.default.oneOf(positionSet),
|
|
230
230
|
rePosKey: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
231
231
|
render: _propTypes.default.node,
|
|
232
|
-
spacing: _propTypes.default.number,
|
|
232
|
+
spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
|
|
233
233
|
showTick: _propTypes.default.bool,
|
|
234
234
|
style: _propTypes.default.object,
|
|
235
235
|
trigger: _propTypes.default.oneOf(triggerSet),
|
|
@@ -2,8 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { ValidateStatus } from '../_base/baseComponent';
|
|
3
3
|
import '@douyinfe/semi-foundation/lib/cjs/input/textarea.css';
|
|
4
4
|
type OmitTextareaAttr = 'onChange' | 'onInput' | 'prefix' | 'size' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyPress' | 'onKeyUp' | 'onResize';
|
|
5
|
+
export type AutosizeRow = {
|
|
6
|
+
minRows?: number;
|
|
7
|
+
maxRows?: number;
|
|
8
|
+
};
|
|
5
9
|
export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, OmitTextareaAttr> {
|
|
6
|
-
autosize?: boolean;
|
|
10
|
+
autosize?: boolean | AutosizeRow;
|
|
7
11
|
borderless?: boolean;
|
|
8
12
|
placeholder?: string;
|
|
9
13
|
value?: string;
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
8
|
+
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
7
9
|
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
8
10
|
var _omit2 = _interopRequireDefault(require("lodash/omit"));
|
|
9
11
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
@@ -219,7 +221,7 @@ class TextArea extends _baseComponent.default {
|
|
|
219
221
|
const itemCls = (0, _classnames.default)(`${prefixCls}-textarea`, {
|
|
220
222
|
[`${prefixCls}-textarea-disabled`]: disabled,
|
|
221
223
|
[`${prefixCls}-textarea-readonly`]: readonly,
|
|
222
|
-
[`${prefixCls}-textarea-autosize`]: autosize,
|
|
224
|
+
[`${prefixCls}-textarea-autosize`]: (0, _isObject2.default)(autosize) ? (0, _isUndefined2.default)(autosize === null || autosize === void 0 ? void 0 : autosize.maxRows) : autosize,
|
|
223
225
|
[`${prefixCls}-textarea-showClear`]: showClear
|
|
224
226
|
});
|
|
225
227
|
const itemProps = Object.assign(Object.assign({}, (0, _omit2.default)(rest, 'insetLabel', 'insetLabelId', 'getValueLength', 'onClear', 'showClear')), {
|
|
@@ -251,7 +253,7 @@ class TextArea extends _baseComponent.default {
|
|
|
251
253
|
}
|
|
252
254
|
}
|
|
253
255
|
TextArea.propTypes = {
|
|
254
|
-
autosize: _propTypes.default.bool,
|
|
256
|
+
autosize: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
|
|
255
257
|
borderless: _propTypes.default.bool,
|
|
256
258
|
placeholder: _propTypes.default.string,
|
|
257
259
|
value: _propTypes.default.string,
|
|
@@ -33,20 +33,22 @@ declare class NotificationList extends BaseComponent<NotificationListProps, Noti
|
|
|
33
33
|
constructor(props: NotificationListProps);
|
|
34
34
|
context: ContextValue;
|
|
35
35
|
get adapter(): NotificationListAdapter;
|
|
36
|
-
static addNotice(notice: NoticeProps): string;
|
|
36
|
+
static addNotice(notice: NoticeProps): string | number;
|
|
37
37
|
static removeNotice(id: string): string;
|
|
38
|
-
static info(opts: NoticeProps): string;
|
|
39
|
-
static success(opts: NoticeProps): string;
|
|
40
|
-
static error(opts: NoticeProps): string;
|
|
41
|
-
static warning(opts: NoticeProps): string;
|
|
42
|
-
static open(opts: NoticeProps): string;
|
|
38
|
+
static info(opts: NoticeProps): string | number;
|
|
39
|
+
static success(opts: NoticeProps): string | number;
|
|
40
|
+
static error(opts: NoticeProps): string | number;
|
|
41
|
+
static warning(opts: NoticeProps): string | number;
|
|
42
|
+
static open(opts: NoticeProps): string | number;
|
|
43
43
|
static close(id: string): string;
|
|
44
44
|
static destroyAll(): void;
|
|
45
45
|
static config(opts: ConfigProps): void;
|
|
46
46
|
add: (noticeOpts: NoticeProps) => any;
|
|
47
|
+
has: (id: string) => any;
|
|
47
48
|
remove: (id: string | number) => void;
|
|
49
|
+
update: (id: string | number, opts: NoticeProps) => any;
|
|
48
50
|
destroyAll: () => any;
|
|
49
|
-
renderNoticeInPosition: (notices: NoticeInstance[], position: NoticePosition, removedItems?: NoticeInstance[]) => JSX.Element;
|
|
51
|
+
renderNoticeInPosition: (notices: NoticeInstance[], position: NoticePosition, removedItems?: NoticeInstance[], updatedItems?: NoticeInstance[]) => JSX.Element;
|
|
50
52
|
setPosInStyle(noticeInstance: NoticeInstance): {};
|
|
51
53
|
render(): JSX.Element;
|
|
52
54
|
}
|
|
@@ -33,12 +33,17 @@ class NotificationList extends _baseComponent.default {
|
|
|
33
33
|
super(props);
|
|
34
34
|
_this = this;
|
|
35
35
|
this.add = noticeOpts => this.foundation.addNotice(noticeOpts);
|
|
36
|
+
this.has = id => this.foundation.has(id);
|
|
36
37
|
this.remove = id => {
|
|
37
38
|
this.foundation.removeNotice(String(id));
|
|
38
39
|
};
|
|
40
|
+
this.update = (id, opts) => {
|
|
41
|
+
return this.foundation.update(id, opts);
|
|
42
|
+
};
|
|
39
43
|
this.destroyAll = () => this.foundation.destroyAll();
|
|
40
44
|
this.renderNoticeInPosition = function (notices, position) {
|
|
41
45
|
let removedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
46
|
+
let updatedItems = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
42
47
|
const className = (0, _classnames.default)(_constants.cssClasses.LIST);
|
|
43
48
|
// TODO notifyOnClose
|
|
44
49
|
if (notices.length) {
|
|
@@ -64,6 +69,11 @@ class NotificationList extends _baseComponent.default {
|
|
|
64
69
|
isAnimating
|
|
65
70
|
} = _ref;
|
|
66
71
|
return isRemoved && !isAnimating ? null : /*#__PURE__*/_react.default.createElement(_notice.default, Object.assign({}, notice, {
|
|
72
|
+
ref: notice => {
|
|
73
|
+
if (notice && updatedItems.some(item => item.id === notice.props.id)) {
|
|
74
|
+
notice.foundation.restartCloseTimer();
|
|
75
|
+
}
|
|
76
|
+
},
|
|
67
77
|
className: (0, _classnames.default)({
|
|
68
78
|
[notice.className]: Boolean(notice.className),
|
|
69
79
|
[animationClassName]: true
|
|
@@ -80,7 +90,8 @@ class NotificationList extends _baseComponent.default {
|
|
|
80
90
|
};
|
|
81
91
|
this.state = {
|
|
82
92
|
notices: [],
|
|
83
|
-
removedItems: []
|
|
93
|
+
removedItems: [],
|
|
94
|
+
updatedItems: []
|
|
84
95
|
};
|
|
85
96
|
this.noticeStorage = [];
|
|
86
97
|
this.removeItemStorage = [];
|
|
@@ -91,19 +102,22 @@ class NotificationList extends _baseComponent.default {
|
|
|
91
102
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
92
103
|
updateNotices: function (notices) {
|
|
93
104
|
let removedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
105
|
+
let updatedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
94
106
|
_this2.noticeStorage = [...notices];
|
|
95
107
|
_this2.removeItemStorage = [...removedItems];
|
|
96
108
|
// setState is async sometimes and react often merges state, so use "this" , make sure other code always get right data.
|
|
97
109
|
_this2.setState({
|
|
98
110
|
notices,
|
|
99
|
-
removedItems
|
|
111
|
+
removedItems,
|
|
112
|
+
updatedItems
|
|
100
113
|
});
|
|
101
114
|
},
|
|
102
115
|
getNotices: () => this.noticeStorage
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
static addNotice(notice) {
|
|
106
|
-
|
|
119
|
+
var _a;
|
|
120
|
+
const id = (_a = notice.id) !== null && _a !== void 0 ? _a : (0, _uuid.default)('notification');
|
|
107
121
|
if (!ref) {
|
|
108
122
|
const {
|
|
109
123
|
getPopupContainer
|
|
@@ -129,9 +143,13 @@ class NotificationList extends _baseComponent.default {
|
|
|
129
143
|
}));
|
|
130
144
|
});
|
|
131
145
|
} else {
|
|
132
|
-
ref.
|
|
133
|
-
id
|
|
134
|
-
}
|
|
146
|
+
if (ref.has(`${id}`)) {
|
|
147
|
+
ref.update(id, notice);
|
|
148
|
+
} else {
|
|
149
|
+
ref.add(Object.assign(Object.assign({}, notice), {
|
|
150
|
+
id
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
135
153
|
}
|
|
136
154
|
return id;
|
|
137
155
|
}
|
|
@@ -210,7 +228,8 @@ class NotificationList extends _baseComponent.default {
|
|
|
210
228
|
notices
|
|
211
229
|
} = this.state;
|
|
212
230
|
const {
|
|
213
|
-
removedItems
|
|
231
|
+
removedItems,
|
|
232
|
+
updatedItems
|
|
214
233
|
} = this.state;
|
|
215
234
|
notices = Array.from(new Set([...notices, ...removedItems]));
|
|
216
235
|
const noticesInPosition = {
|
|
@@ -230,7 +249,7 @@ class NotificationList extends _baseComponent.default {
|
|
|
230
249
|
const noticesList = Object.entries(noticesInPosition).map(obj => {
|
|
231
250
|
const pos = obj[0];
|
|
232
251
|
const noticesInPos = obj[1];
|
|
233
|
-
return this.renderNoticeInPosition(noticesInPos, pos, removedItems);
|
|
252
|
+
return this.renderNoticeInPosition(noticesInPos, pos, removedItems, updatedItems);
|
|
234
253
|
});
|
|
235
254
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, noticesList);
|
|
236
255
|
}
|
|
@@ -26,7 +26,10 @@ export interface PopoverProps extends BaseProps {
|
|
|
26
26
|
onVisibleChange?: (visible: boolean) => void;
|
|
27
27
|
onClickOutSide?: (e: React.MouseEvent) => void;
|
|
28
28
|
showArrow?: boolean;
|
|
29
|
-
spacing?: number
|
|
29
|
+
spacing?: number | {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
30
33
|
stopPropagation?: boolean | string;
|
|
31
34
|
arrowStyle?: ArrowStyle;
|
|
32
35
|
arrowBounding?: ArrowBounding;
|
|
@@ -64,7 +67,7 @@ declare class Popover extends React.PureComponent<PopoverProps, PopoverState> {
|
|
|
64
67
|
onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
65
68
|
onClickOutSide: PropTypes.Requireable<(...args: any[]) => any>;
|
|
66
69
|
style: PropTypes.Requireable<object>;
|
|
67
|
-
spacing: PropTypes.Requireable<number
|
|
70
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
68
71
|
zIndex: PropTypes.Requireable<number>;
|
|
69
72
|
showArrow: PropTypes.Requireable<boolean>;
|
|
70
73
|
arrowStyle: PropTypes.Requireable<PropTypes.InferProps<{
|
package/lib/cjs/popover/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var _constants = require("@douyinfe/semi-foundation/lib/cjs/popover/constants");
|
|
|
14
14
|
var _index = _interopRequireDefault(require("../tooltip/index"));
|
|
15
15
|
var _Arrow = _interopRequireDefault(require("./Arrow"));
|
|
16
16
|
require("@douyinfe/semi-foundation/lib/cjs/popover/popover.css");
|
|
17
|
+
var _isNullOrUndefined = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/isNullOrUndefined"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
19
20
|
var t = {};
|
|
@@ -95,7 +96,7 @@ class Popover extends _react.default.PureComponent {
|
|
|
95
96
|
arrowStyle
|
|
96
97
|
};
|
|
97
98
|
const arrow = showArrow ? /*#__PURE__*/_react.default.createElement(_Arrow.default, Object.assign({}, arrowProps)) : false;
|
|
98
|
-
if (
|
|
99
|
+
if ((0, _isNullOrUndefined.default)(spacing)) {
|
|
99
100
|
spacing = showArrow ? _constants.numbers.SPACING_WITH_ARROW : _constants.numbers.SPACING;
|
|
100
101
|
}
|
|
101
102
|
const role = trigger === 'click' || trigger === 'custom' ? 'dialog' : 'tooltip';
|
|
@@ -132,7 +133,7 @@ Popover.propTypes = {
|
|
|
132
133
|
onVisibleChange: _propTypes.default.func,
|
|
133
134
|
onClickOutSide: _propTypes.default.func,
|
|
134
135
|
style: _propTypes.default.object,
|
|
135
|
-
spacing: _propTypes.default.number,
|
|
136
|
+
spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
|
|
136
137
|
zIndex: _propTypes.default.number,
|
|
137
138
|
showArrow: _propTypes.default.bool,
|
|
138
139
|
arrowStyle: _propTypes.default.shape({
|
|
@@ -241,7 +241,7 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
241
241
|
autoAdjustOverflow: PropTypes.Requireable<boolean>;
|
|
242
242
|
mouseEnterDelay: PropTypes.Requireable<number>;
|
|
243
243
|
mouseLeaveDelay: PropTypes.Requireable<number>;
|
|
244
|
-
spacing: PropTypes.Requireable<number
|
|
244
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
245
245
|
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
246
246
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
247
247
|
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
package/lib/cjs/select/index.js
CHANGED
|
@@ -1280,7 +1280,7 @@ Select.propTypes = {
|
|
|
1280
1280
|
autoAdjustOverflow: _propTypes.default.bool,
|
|
1281
1281
|
mouseEnterDelay: _propTypes.default.number,
|
|
1282
1282
|
mouseLeaveDelay: _propTypes.default.number,
|
|
1283
|
-
spacing: _propTypes.default.number,
|
|
1283
|
+
spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
|
|
1284
1284
|
onBlur: _propTypes.default.func,
|
|
1285
1285
|
onFocus: _propTypes.default.func,
|
|
1286
1286
|
onClear: _propTypes.default.func,
|
package/lib/cjs/toast/index.js
CHANGED
|
@@ -228,9 +228,6 @@ const createBaseToast = () => {
|
|
|
228
228
|
const refFn = toast => {
|
|
229
229
|
var _a;
|
|
230
230
|
if (((_a = toast === null || toast === void 0 ? void 0 : toast.foundation) === null || _a === void 0 ? void 0 : _a._id) && updatedIds.includes(toast.foundation._id)) {
|
|
231
|
-
toast.foundation.setState({
|
|
232
|
-
duration: toast.props.duration
|
|
233
|
-
});
|
|
234
231
|
toast.foundation.restartCloseTimer();
|
|
235
232
|
}
|
|
236
233
|
};
|
|
@@ -36,7 +36,10 @@ export interface TooltipProps extends BaseProps {
|
|
|
36
36
|
prefixCls?: string;
|
|
37
37
|
onVisibleChange?: (visible: boolean) => void;
|
|
38
38
|
onClickOutSide?: (e: React.MouseEvent) => void;
|
|
39
|
-
spacing?: number
|
|
39
|
+
spacing?: number | {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
40
43
|
margin?: number | {
|
|
41
44
|
marginLeft: number;
|
|
42
45
|
marginTop: number;
|
|
@@ -103,7 +106,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
103
106
|
prefixCls: PropTypes.Requireable<string>;
|
|
104
107
|
onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
105
108
|
onClickOutSide: PropTypes.Requireable<(...args: any[]) => any>;
|
|
106
|
-
spacing: PropTypes.Requireable<number
|
|
109
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
107
110
|
margin: PropTypes.Requireable<NonNullable<number | object>>;
|
|
108
111
|
showArrow: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
109
112
|
zIndex: PropTypes.Requireable<number>;
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -665,7 +665,7 @@ Tooltip.propTypes = {
|
|
|
665
665
|
prefixCls: _propTypes.default.string,
|
|
666
666
|
onVisibleChange: _propTypes.default.func,
|
|
667
667
|
onClickOutSide: _propTypes.default.func,
|
|
668
|
-
spacing: _propTypes.default.number,
|
|
668
|
+
spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
|
|
669
669
|
margin: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.object]),
|
|
670
670
|
showArrow: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.node]),
|
|
671
671
|
zIndex: _propTypes.default.number,
|
|
@@ -110,7 +110,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
110
110
|
validateStatus: PropTypes.Requireable<"default" | "error" | "warning" | "success">;
|
|
111
111
|
renderDate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
112
112
|
renderFullDate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
113
|
-
spacing: PropTypes.Requireable<number
|
|
113
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
114
114
|
startDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
115
115
|
endDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
116
116
|
autoSwitchDate: PropTypes.Requireable<boolean>;
|
|
@@ -818,7 +818,7 @@ DatePicker.propTypes = {
|
|
|
818
818
|
validateStatus: PropTypes.oneOf(strings.STATUS),
|
|
819
819
|
renderDate: PropTypes.func,
|
|
820
820
|
renderFullDate: PropTypes.func,
|
|
821
|
-
spacing: PropTypes.number,
|
|
821
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
822
822
|
startDateOffset: PropTypes.func,
|
|
823
823
|
endDateOffset: PropTypes.func,
|
|
824
824
|
autoSwitchDate: PropTypes.bool,
|
|
@@ -69,7 +69,7 @@ declare class Dropdown extends BaseComponent<DropdownProps, DropdownState> {
|
|
|
69
69
|
position: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
70
70
|
rePosKey: PropTypes.Requireable<NonNullable<string | number>>;
|
|
71
71
|
render: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
72
|
-
spacing: PropTypes.Requireable<number
|
|
72
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
73
73
|
showTick: PropTypes.Requireable<boolean>;
|
|
74
74
|
style: PropTypes.Requireable<object>;
|
|
75
75
|
trigger: PropTypes.Requireable<string>;
|
package/lib/es/dropdown/index.js
CHANGED
|
@@ -222,7 +222,7 @@ Dropdown.propTypes = {
|
|
|
222
222
|
position: PropTypes.oneOf(positionSet),
|
|
223
223
|
rePosKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
224
224
|
render: PropTypes.node,
|
|
225
|
-
spacing: PropTypes.number,
|
|
225
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
226
226
|
showTick: PropTypes.bool,
|
|
227
227
|
style: PropTypes.object,
|
|
228
228
|
trigger: PropTypes.oneOf(triggerSet),
|
|
@@ -2,8 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { ValidateStatus } from '../_base/baseComponent';
|
|
3
3
|
import '@douyinfe/semi-foundation/lib/es/input/textarea.css';
|
|
4
4
|
type OmitTextareaAttr = 'onChange' | 'onInput' | 'prefix' | 'size' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyPress' | 'onKeyUp' | 'onResize';
|
|
5
|
+
export type AutosizeRow = {
|
|
6
|
+
minRows?: number;
|
|
7
|
+
maxRows?: number;
|
|
8
|
+
};
|
|
5
9
|
export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, OmitTextareaAttr> {
|
|
6
|
-
autosize?: boolean;
|
|
10
|
+
autosize?: boolean | AutosizeRow;
|
|
7
11
|
borderless?: boolean;
|
|
8
12
|
placeholder?: string;
|
|
9
13
|
value?: string;
|
package/lib/es/input/textarea.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _isObject from "lodash/isObject";
|
|
2
|
+
import _isUndefined from "lodash/isUndefined";
|
|
1
3
|
import _isFunction from "lodash/isFunction";
|
|
2
4
|
import _omit from "lodash/omit";
|
|
3
5
|
import _noop from "lodash/noop";
|
|
@@ -212,7 +214,7 @@ class TextArea extends BaseComponent {
|
|
|
212
214
|
const itemCls = cls(`${prefixCls}-textarea`, {
|
|
213
215
|
[`${prefixCls}-textarea-disabled`]: disabled,
|
|
214
216
|
[`${prefixCls}-textarea-readonly`]: readonly,
|
|
215
|
-
[`${prefixCls}-textarea-autosize`]: autosize,
|
|
217
|
+
[`${prefixCls}-textarea-autosize`]: _isObject(autosize) ? _isUndefined(autosize === null || autosize === void 0 ? void 0 : autosize.maxRows) : autosize,
|
|
216
218
|
[`${prefixCls}-textarea-showClear`]: showClear
|
|
217
219
|
});
|
|
218
220
|
const itemProps = Object.assign(Object.assign({}, _omit(rest, 'insetLabel', 'insetLabelId', 'getValueLength', 'onClear', 'showClear')), {
|
|
@@ -244,7 +246,7 @@ class TextArea extends BaseComponent {
|
|
|
244
246
|
}
|
|
245
247
|
}
|
|
246
248
|
TextArea.propTypes = {
|
|
247
|
-
autosize: PropTypes.bool,
|
|
249
|
+
autosize: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
248
250
|
borderless: PropTypes.bool,
|
|
249
251
|
placeholder: PropTypes.string,
|
|
250
252
|
value: PropTypes.string,
|
|
@@ -33,20 +33,22 @@ declare class NotificationList extends BaseComponent<NotificationListProps, Noti
|
|
|
33
33
|
constructor(props: NotificationListProps);
|
|
34
34
|
context: ContextValue;
|
|
35
35
|
get adapter(): NotificationListAdapter;
|
|
36
|
-
static addNotice(notice: NoticeProps): string;
|
|
36
|
+
static addNotice(notice: NoticeProps): string | number;
|
|
37
37
|
static removeNotice(id: string): string;
|
|
38
|
-
static info(opts: NoticeProps): string;
|
|
39
|
-
static success(opts: NoticeProps): string;
|
|
40
|
-
static error(opts: NoticeProps): string;
|
|
41
|
-
static warning(opts: NoticeProps): string;
|
|
42
|
-
static open(opts: NoticeProps): string;
|
|
38
|
+
static info(opts: NoticeProps): string | number;
|
|
39
|
+
static success(opts: NoticeProps): string | number;
|
|
40
|
+
static error(opts: NoticeProps): string | number;
|
|
41
|
+
static warning(opts: NoticeProps): string | number;
|
|
42
|
+
static open(opts: NoticeProps): string | number;
|
|
43
43
|
static close(id: string): string;
|
|
44
44
|
static destroyAll(): void;
|
|
45
45
|
static config(opts: ConfigProps): void;
|
|
46
46
|
add: (noticeOpts: NoticeProps) => any;
|
|
47
|
+
has: (id: string) => any;
|
|
47
48
|
remove: (id: string | number) => void;
|
|
49
|
+
update: (id: string | number, opts: NoticeProps) => any;
|
|
48
50
|
destroyAll: () => any;
|
|
49
|
-
renderNoticeInPosition: (notices: NoticeInstance[], position: NoticePosition, removedItems?: NoticeInstance[]) => JSX.Element;
|
|
51
|
+
renderNoticeInPosition: (notices: NoticeInstance[], position: NoticePosition, removedItems?: NoticeInstance[], updatedItems?: NoticeInstance[]) => JSX.Element;
|
|
50
52
|
setPosInStyle(noticeInstance: NoticeInstance): {};
|
|
51
53
|
render(): JSX.Element;
|
|
52
54
|
}
|
|
@@ -26,12 +26,17 @@ class NotificationList extends BaseComponent {
|
|
|
26
26
|
super(props);
|
|
27
27
|
_this = this;
|
|
28
28
|
this.add = noticeOpts => this.foundation.addNotice(noticeOpts);
|
|
29
|
+
this.has = id => this.foundation.has(id);
|
|
29
30
|
this.remove = id => {
|
|
30
31
|
this.foundation.removeNotice(String(id));
|
|
31
32
|
};
|
|
33
|
+
this.update = (id, opts) => {
|
|
34
|
+
return this.foundation.update(id, opts);
|
|
35
|
+
};
|
|
32
36
|
this.destroyAll = () => this.foundation.destroyAll();
|
|
33
37
|
this.renderNoticeInPosition = function (notices, position) {
|
|
34
38
|
let removedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
39
|
+
let updatedItems = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
35
40
|
const className = cls(cssClasses.LIST);
|
|
36
41
|
// TODO notifyOnClose
|
|
37
42
|
if (notices.length) {
|
|
@@ -57,6 +62,11 @@ class NotificationList extends BaseComponent {
|
|
|
57
62
|
isAnimating
|
|
58
63
|
} = _ref;
|
|
59
64
|
return isRemoved && !isAnimating ? null : /*#__PURE__*/React.createElement(Notice, Object.assign({}, notice, {
|
|
65
|
+
ref: notice => {
|
|
66
|
+
if (notice && updatedItems.some(item => item.id === notice.props.id)) {
|
|
67
|
+
notice.foundation.restartCloseTimer();
|
|
68
|
+
}
|
|
69
|
+
},
|
|
60
70
|
className: cls({
|
|
61
71
|
[notice.className]: Boolean(notice.className),
|
|
62
72
|
[animationClassName]: true
|
|
@@ -73,7 +83,8 @@ class NotificationList extends BaseComponent {
|
|
|
73
83
|
};
|
|
74
84
|
this.state = {
|
|
75
85
|
notices: [],
|
|
76
|
-
removedItems: []
|
|
86
|
+
removedItems: [],
|
|
87
|
+
updatedItems: []
|
|
77
88
|
};
|
|
78
89
|
this.noticeStorage = [];
|
|
79
90
|
this.removeItemStorage = [];
|
|
@@ -84,19 +95,22 @@ class NotificationList extends BaseComponent {
|
|
|
84
95
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
85
96
|
updateNotices: function (notices) {
|
|
86
97
|
let removedItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
98
|
+
let updatedItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
87
99
|
_this2.noticeStorage = [...notices];
|
|
88
100
|
_this2.removeItemStorage = [...removedItems];
|
|
89
101
|
// setState is async sometimes and react often merges state, so use "this" , make sure other code always get right data.
|
|
90
102
|
_this2.setState({
|
|
91
103
|
notices,
|
|
92
|
-
removedItems
|
|
104
|
+
removedItems,
|
|
105
|
+
updatedItems
|
|
93
106
|
});
|
|
94
107
|
},
|
|
95
108
|
getNotices: () => this.noticeStorage
|
|
96
109
|
});
|
|
97
110
|
}
|
|
98
111
|
static addNotice(notice) {
|
|
99
|
-
|
|
112
|
+
var _a;
|
|
113
|
+
const id = (_a = notice.id) !== null && _a !== void 0 ? _a : getUuid('notification');
|
|
100
114
|
if (!ref) {
|
|
101
115
|
const {
|
|
102
116
|
getPopupContainer
|
|
@@ -122,9 +136,13 @@ class NotificationList extends BaseComponent {
|
|
|
122
136
|
}));
|
|
123
137
|
});
|
|
124
138
|
} else {
|
|
125
|
-
ref.
|
|
126
|
-
id
|
|
127
|
-
}
|
|
139
|
+
if (ref.has(`${id}`)) {
|
|
140
|
+
ref.update(id, notice);
|
|
141
|
+
} else {
|
|
142
|
+
ref.add(Object.assign(Object.assign({}, notice), {
|
|
143
|
+
id
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
128
146
|
}
|
|
129
147
|
return id;
|
|
130
148
|
}
|
|
@@ -203,7 +221,8 @@ class NotificationList extends BaseComponent {
|
|
|
203
221
|
notices
|
|
204
222
|
} = this.state;
|
|
205
223
|
const {
|
|
206
|
-
removedItems
|
|
224
|
+
removedItems,
|
|
225
|
+
updatedItems
|
|
207
226
|
} = this.state;
|
|
208
227
|
notices = Array.from(new Set([...notices, ...removedItems]));
|
|
209
228
|
const noticesInPosition = {
|
|
@@ -223,7 +242,7 @@ class NotificationList extends BaseComponent {
|
|
|
223
242
|
const noticesList = Object.entries(noticesInPosition).map(obj => {
|
|
224
243
|
const pos = obj[0];
|
|
225
244
|
const noticesInPos = obj[1];
|
|
226
|
-
return this.renderNoticeInPosition(noticesInPos, pos, removedItems);
|
|
245
|
+
return this.renderNoticeInPosition(noticesInPos, pos, removedItems, updatedItems);
|
|
227
246
|
});
|
|
228
247
|
return /*#__PURE__*/React.createElement(React.Fragment, null, noticesList);
|
|
229
248
|
}
|
|
@@ -26,7 +26,10 @@ export interface PopoverProps extends BaseProps {
|
|
|
26
26
|
onVisibleChange?: (visible: boolean) => void;
|
|
27
27
|
onClickOutSide?: (e: React.MouseEvent) => void;
|
|
28
28
|
showArrow?: boolean;
|
|
29
|
-
spacing?: number
|
|
29
|
+
spacing?: number | {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
30
33
|
stopPropagation?: boolean | string;
|
|
31
34
|
arrowStyle?: ArrowStyle;
|
|
32
35
|
arrowBounding?: ArrowBounding;
|
|
@@ -64,7 +67,7 @@ declare class Popover extends React.PureComponent<PopoverProps, PopoverState> {
|
|
|
64
67
|
onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
65
68
|
onClickOutSide: PropTypes.Requireable<(...args: any[]) => any>;
|
|
66
69
|
style: PropTypes.Requireable<object>;
|
|
67
|
-
spacing: PropTypes.Requireable<number
|
|
70
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
68
71
|
zIndex: PropTypes.Requireable<number>;
|
|
69
72
|
showArrow: PropTypes.Requireable<boolean>;
|
|
70
73
|
arrowStyle: PropTypes.Requireable<PropTypes.InferProps<{
|
package/lib/es/popover/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { cssClasses, strings, numbers } from '@douyinfe/semi-foundation/lib/es/p
|
|
|
16
16
|
import Tooltip from '../tooltip/index';
|
|
17
17
|
import Arrow from './Arrow';
|
|
18
18
|
import '@douyinfe/semi-foundation/lib/es/popover/popover.css';
|
|
19
|
+
import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
|
|
19
20
|
const positionSet = strings.POSITION_SET;
|
|
20
21
|
const triggerSet = strings.TRIGGER_SET;
|
|
21
22
|
class Popover extends React.PureComponent {
|
|
@@ -88,7 +89,7 @@ class Popover extends React.PureComponent {
|
|
|
88
89
|
arrowStyle
|
|
89
90
|
};
|
|
90
91
|
const arrow = showArrow ? /*#__PURE__*/React.createElement(Arrow, Object.assign({}, arrowProps)) : false;
|
|
91
|
-
if (
|
|
92
|
+
if (isNullOrUndefined(spacing)) {
|
|
92
93
|
spacing = showArrow ? numbers.SPACING_WITH_ARROW : numbers.SPACING;
|
|
93
94
|
}
|
|
94
95
|
const role = trigger === 'click' || trigger === 'custom' ? 'dialog' : 'tooltip';
|
|
@@ -125,7 +126,7 @@ Popover.propTypes = {
|
|
|
125
126
|
onVisibleChange: PropTypes.func,
|
|
126
127
|
onClickOutSide: PropTypes.func,
|
|
127
128
|
style: PropTypes.object,
|
|
128
|
-
spacing: PropTypes.number,
|
|
129
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
129
130
|
zIndex: PropTypes.number,
|
|
130
131
|
showArrow: PropTypes.bool,
|
|
131
132
|
arrowStyle: PropTypes.shape({
|
package/lib/es/select/index.d.ts
CHANGED
|
@@ -241,7 +241,7 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
241
241
|
autoAdjustOverflow: PropTypes.Requireable<boolean>;
|
|
242
242
|
mouseEnterDelay: PropTypes.Requireable<number>;
|
|
243
243
|
mouseLeaveDelay: PropTypes.Requireable<number>;
|
|
244
|
-
spacing: PropTypes.Requireable<number
|
|
244
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
245
245
|
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
246
246
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
247
247
|
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
package/lib/es/select/index.js
CHANGED
|
@@ -1271,7 +1271,7 @@ Select.propTypes = {
|
|
|
1271
1271
|
autoAdjustOverflow: PropTypes.bool,
|
|
1272
1272
|
mouseEnterDelay: PropTypes.number,
|
|
1273
1273
|
mouseLeaveDelay: PropTypes.number,
|
|
1274
|
-
spacing: PropTypes.number,
|
|
1274
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
1275
1275
|
onBlur: PropTypes.func,
|
|
1276
1276
|
onFocus: PropTypes.func,
|
|
1277
1277
|
onClear: PropTypes.func,
|
package/lib/es/toast/index.js
CHANGED
|
@@ -221,9 +221,6 @@ const createBaseToast = () => {
|
|
|
221
221
|
const refFn = toast => {
|
|
222
222
|
var _a;
|
|
223
223
|
if (((_a = toast === null || toast === void 0 ? void 0 : toast.foundation) === null || _a === void 0 ? void 0 : _a._id) && updatedIds.includes(toast.foundation._id)) {
|
|
224
|
-
toast.foundation.setState({
|
|
225
|
-
duration: toast.props.duration
|
|
226
|
-
});
|
|
227
224
|
toast.foundation.restartCloseTimer();
|
|
228
225
|
}
|
|
229
226
|
};
|
|
@@ -36,7 +36,10 @@ export interface TooltipProps extends BaseProps {
|
|
|
36
36
|
prefixCls?: string;
|
|
37
37
|
onVisibleChange?: (visible: boolean) => void;
|
|
38
38
|
onClickOutSide?: (e: React.MouseEvent) => void;
|
|
39
|
-
spacing?: number
|
|
39
|
+
spacing?: number | {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
40
43
|
margin?: number | {
|
|
41
44
|
marginLeft: number;
|
|
42
45
|
marginTop: number;
|
|
@@ -103,7 +106,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
103
106
|
prefixCls: PropTypes.Requireable<string>;
|
|
104
107
|
onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
105
108
|
onClickOutSide: PropTypes.Requireable<(...args: any[]) => any>;
|
|
106
|
-
spacing: PropTypes.Requireable<number
|
|
109
|
+
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
107
110
|
margin: PropTypes.Requireable<NonNullable<number | object>>;
|
|
108
111
|
showArrow: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
109
112
|
zIndex: PropTypes.Requireable<number>;
|