@douyinfe/semi-ui 2.53.3-alpha.1 → 2.54.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/semi.css +9 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +603 -438
- 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/cascader/index.d.ts +3 -0
- package/lib/cjs/cascader/index.js +11 -4
- package/lib/cjs/collapsible/index.d.ts +1 -0
- package/lib/cjs/collapsible/index.js +4 -3
- package/lib/cjs/descriptions/descriptions-context.d.ts +2 -0
- package/lib/cjs/descriptions/index.d.ts +17 -4
- package/lib/cjs/descriptions/index.js +52 -16
- package/lib/cjs/descriptions/item.d.ts +1 -0
- package/lib/cjs/descriptions/item.js +20 -13
- package/lib/cjs/image/interface.d.ts +1 -0
- package/lib/cjs/image/previewInner.js +6 -0
- package/lib/cjs/modal/Modal.d.ts +4 -4
- package/lib/cjs/modal/Modal.js +12 -11
- package/lib/cjs/modal/confirm.d.ts +1 -1
- package/lib/cjs/toast/index.js +3 -0
- package/lib/cjs/typography/base.js +3 -3
- package/lib/es/cascader/index.d.ts +3 -0
- package/lib/es/cascader/index.js +11 -4
- package/lib/es/collapsible/index.d.ts +1 -0
- package/lib/es/collapsible/index.js +4 -3
- package/lib/es/descriptions/descriptions-context.d.ts +2 -0
- package/lib/es/descriptions/index.d.ts +17 -4
- package/lib/es/descriptions/index.js +52 -14
- package/lib/es/descriptions/item.d.ts +1 -0
- package/lib/es/descriptions/item.js +20 -13
- package/lib/es/image/interface.d.ts +1 -0
- package/lib/es/image/previewInner.js +6 -0
- package/lib/es/modal/Modal.d.ts +4 -4
- package/lib/es/modal/Modal.js +12 -11
- package/lib/es/modal/confirm.d.ts +1 -1
- package/lib/es/toast/index.js +3 -0
- package/lib/es/typography/base.js +3 -3
- package/package.json +8 -8
|
@@ -59,6 +59,7 @@ export interface CascaderProps extends BasicCascaderProps {
|
|
|
59
59
|
onFocus?: (e: MouseEvent) => void;
|
|
60
60
|
validateStatus?: ValidateStatus;
|
|
61
61
|
position?: Position;
|
|
62
|
+
searchPosition?: string;
|
|
62
63
|
}
|
|
63
64
|
export interface CascaderState extends BasicCascaderInnerData {
|
|
64
65
|
keyEntities: Entities;
|
|
@@ -143,6 +144,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
143
144
|
enableLeafClick: PropTypes.Requireable<boolean>;
|
|
144
145
|
preventScroll: PropTypes.Requireable<boolean>;
|
|
145
146
|
position: PropTypes.Requireable<string>;
|
|
147
|
+
searchPosition: PropTypes.Requireable<string>;
|
|
146
148
|
};
|
|
147
149
|
static defaultProps: any;
|
|
148
150
|
options: any;
|
|
@@ -161,6 +163,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
161
163
|
componentDidMount(): void;
|
|
162
164
|
componentWillUnmount(): void;
|
|
163
165
|
componentDidUpdate(prevProps: CascaderProps): void;
|
|
166
|
+
search: (value: string) => void;
|
|
164
167
|
handleInputChange: (value: string) => void;
|
|
165
168
|
handleTagRemoveInTrigger: (pos: string) => void;
|
|
166
169
|
handleTagClose: (tagChildren: React.ReactNode, e: React.MouseEvent<HTMLElement>, tagKey: string | number) => void;
|
|
@@ -40,6 +40,10 @@ const resetkey = 0;
|
|
|
40
40
|
class Cascader extends _baseComponent.default {
|
|
41
41
|
constructor(props) {
|
|
42
42
|
super(props);
|
|
43
|
+
// ref method
|
|
44
|
+
this.search = value => {
|
|
45
|
+
this.handleInputChange(value);
|
|
46
|
+
};
|
|
43
47
|
this.handleInputChange = value => {
|
|
44
48
|
this.foundation.handleInputChange(value);
|
|
45
49
|
};
|
|
@@ -226,12 +230,13 @@ class Cascader extends _baseComponent.default {
|
|
|
226
230
|
const {
|
|
227
231
|
placeholder,
|
|
228
232
|
filterTreeNode,
|
|
229
|
-
multiple
|
|
233
|
+
multiple,
|
|
234
|
+
searchPosition
|
|
230
235
|
} = this.props;
|
|
231
236
|
const {
|
|
232
237
|
checkedKeys
|
|
233
238
|
} = this.state;
|
|
234
|
-
const searchable = Boolean(filterTreeNode);
|
|
239
|
+
const searchable = Boolean(filterTreeNode) && searchPosition === _constants.strings.SEARCH_POSITION_TRIGGER;
|
|
235
240
|
if (!searchable) {
|
|
236
241
|
if (multiple) {
|
|
237
242
|
if (checkedKeys.size === 0) {
|
|
@@ -991,7 +996,8 @@ Cascader.propTypes = {
|
|
|
991
996
|
leafOnly: _propTypes.default.bool,
|
|
992
997
|
enableLeafClick: _propTypes.default.bool,
|
|
993
998
|
preventScroll: _propTypes.default.bool,
|
|
994
|
-
position: _propTypes.default.string
|
|
999
|
+
position: _propTypes.default.string,
|
|
1000
|
+
searchPosition: _propTypes.default.string
|
|
995
1001
|
};
|
|
996
1002
|
Cascader.defaultProps = (0, _utils.getDefaultPropsFromGlobalConfig)(Cascader.__SemiComponentName__, {
|
|
997
1003
|
borderless: false,
|
|
@@ -1022,7 +1028,8 @@ Cascader.defaultProps = (0, _utils.getDefaultPropsFromGlobalConfig)(Cascader.__S
|
|
|
1022
1028
|
onDropdownVisibleChange: _noop2.default,
|
|
1023
1029
|
onListScroll: _noop2.default,
|
|
1024
1030
|
enableLeafClick: false,
|
|
1025
|
-
'aria-label': 'Cascader'
|
|
1031
|
+
'aria-label': 'Cascader',
|
|
1032
|
+
searchPosition: _constants.strings.SEARCH_POSITION_TRIGGER
|
|
1026
1033
|
});
|
|
1027
1034
|
var _default = Cascader;
|
|
1028
1035
|
exports.default = _default;
|
|
@@ -29,9 +29,8 @@ class Collapsible extends _baseComponent.default {
|
|
|
29
29
|
this.isChildrenInRenderTree = () => {
|
|
30
30
|
if (this.domRef.current) {
|
|
31
31
|
return this.domRef.current.offsetHeight > 0;
|
|
32
|
-
} else {
|
|
33
|
-
return false;
|
|
34
32
|
}
|
|
33
|
+
return false;
|
|
35
34
|
};
|
|
36
35
|
this.state = {
|
|
37
36
|
domInRenderTree: false,
|
|
@@ -115,6 +114,7 @@ class Collapsible extends _baseComponent.default {
|
|
|
115
114
|
const wrapperCls = (0, _classnames.default)(`${_constants.cssClasses.PREFIX}-wrapper`, {
|
|
116
115
|
[`${_constants.cssClasses.PREFIX}-transition`]: this.props.motion && this.state.isTransitioning
|
|
117
116
|
}, this.props.className);
|
|
117
|
+
const shouldRender = this.props.keepDOM && !this.props.lazyRender || this.props.collapseHeight !== 0 || this.state.visible || this.props.isOpen;
|
|
118
118
|
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
119
119
|
className: wrapperCls,
|
|
120
120
|
style: wrapperStyle,
|
|
@@ -133,7 +133,7 @@ class Collapsible extends _baseComponent.default {
|
|
|
133
133
|
overflow: 'hidden'
|
|
134
134
|
},
|
|
135
135
|
id: this.props.id
|
|
136
|
-
},
|
|
136
|
+
}, shouldRender && this.props.children));
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
Collapsible.__SemiComponentName__ = "Collapsible";
|
|
@@ -142,6 +142,7 @@ Collapsible.defaultProps = (0, _utils.getDefaultPropsFromGlobalConfig)(Collapsib
|
|
|
142
142
|
duration: 250,
|
|
143
143
|
motion: true,
|
|
144
144
|
keepDOM: false,
|
|
145
|
+
lazyRender: true,
|
|
145
146
|
collapseHeight: 0,
|
|
146
147
|
fade: false
|
|
147
148
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type DescriptionsAlign = 'center' | 'justify' | 'left' | 'plain';
|
|
3
|
+
export type DescriptionLayout = 'horizontal' | 'vertical';
|
|
3
4
|
export interface DescriptionsContextValue {
|
|
4
5
|
align?: DescriptionsAlign;
|
|
6
|
+
layout?: DescriptionLayout;
|
|
5
7
|
}
|
|
6
8
|
declare const DescriptionsContext: React.Context<DescriptionsContextValue>;
|
|
7
9
|
export default DescriptionsContext;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import '@douyinfe/semi-foundation/lib/cjs/descriptions/descriptions.css';
|
|
4
|
-
import { DescriptionsAlign,
|
|
4
|
+
import { DescriptionsAlign, DescriptionLayout } from './descriptions-context';
|
|
5
5
|
import Item from './item';
|
|
6
|
+
import DescriptionsFoundation, { DescriptionsAdapter } from '@douyinfe/semi-foundation/lib/cjs/descriptions/foundation';
|
|
7
|
+
import BaseComponent from '../_base/baseComponent';
|
|
6
8
|
export type { DescriptionsItemProps } from './item';
|
|
7
9
|
export type DescriptionsSize = 'small' | 'medium' | 'large';
|
|
8
10
|
export interface Data {
|
|
9
11
|
key?: React.ReactNode;
|
|
10
12
|
value?: (() => React.ReactNode) | React.ReactNode;
|
|
11
13
|
hidden?: boolean;
|
|
14
|
+
span?: number;
|
|
12
15
|
}
|
|
13
16
|
export interface DescriptionsProps {
|
|
14
17
|
align?: DescriptionsAlign;
|
|
@@ -18,10 +21,12 @@ export interface DescriptionsProps {
|
|
|
18
21
|
className?: string;
|
|
19
22
|
children?: React.ReactNode;
|
|
20
23
|
data?: Data[];
|
|
24
|
+
layout?: DescriptionLayout;
|
|
25
|
+
column?: number;
|
|
21
26
|
}
|
|
22
|
-
declare class Descriptions extends
|
|
27
|
+
declare class Descriptions extends BaseComponent<DescriptionsProps> {
|
|
23
28
|
static Item: typeof Item;
|
|
24
|
-
static contextType: React.Context<DescriptionsContextValue>;
|
|
29
|
+
static contextType: React.Context<import("./descriptions-context").DescriptionsContextValue>;
|
|
25
30
|
static propTypes: {
|
|
26
31
|
align: PropTypes.Requireable<string>;
|
|
27
32
|
row: PropTypes.Requireable<boolean>;
|
|
@@ -35,13 +40,21 @@ declare class Descriptions extends PureComponent<DescriptionsProps> {
|
|
|
35
40
|
className: PropTypes.Requireable<string>;
|
|
36
41
|
style: PropTypes.Requireable<object>;
|
|
37
42
|
}>[]>;
|
|
43
|
+
layout: PropTypes.Requireable<string>;
|
|
44
|
+
column: PropTypes.Requireable<number>;
|
|
38
45
|
};
|
|
39
46
|
static defaultProps: {
|
|
40
47
|
align: string;
|
|
41
48
|
row: boolean;
|
|
42
49
|
size: string;
|
|
43
50
|
data: Data[];
|
|
51
|
+
layout: string;
|
|
52
|
+
column: number;
|
|
44
53
|
};
|
|
54
|
+
foundation: DescriptionsFoundation;
|
|
55
|
+
constructor(props: DescriptionsProps);
|
|
56
|
+
get adapter(): DescriptionsAdapter<DescriptionsProps>;
|
|
57
|
+
renderChildrenList: () => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | JSX.Element[];
|
|
45
58
|
render(): JSX.Element;
|
|
46
59
|
}
|
|
47
60
|
export default Descriptions;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/descriptions/constants");
|
|
@@ -13,8 +13,8 @@ require("@douyinfe/semi-foundation/lib/cjs/descriptions/descriptions.css");
|
|
|
13
13
|
var _getDataAttr = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/getDataAttr"));
|
|
14
14
|
var _descriptionsContext = _interopRequireDefault(require("./descriptions-context"));
|
|
15
15
|
var _item = _interopRequireDefault(require("./item"));
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
var _foundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/descriptions/foundation"));
|
|
17
|
+
var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
20
20
|
var t = {};
|
|
@@ -25,7 +25,40 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
25
25
|
return t;
|
|
26
26
|
};
|
|
27
27
|
const prefixCls = _constants.cssClasses.PREFIX;
|
|
28
|
-
class Descriptions extends
|
|
28
|
+
class Descriptions extends _baseComponent.default {
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super(props);
|
|
31
|
+
this.renderChildrenList = () => {
|
|
32
|
+
const props = this.props;
|
|
33
|
+
const {
|
|
34
|
+
layout,
|
|
35
|
+
data,
|
|
36
|
+
children
|
|
37
|
+
} = props;
|
|
38
|
+
if (layout === 'horizontal') {
|
|
39
|
+
const horizontalList = this.foundation.getHorizontalList();
|
|
40
|
+
return horizontalList.map((row, index) => {
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
42
|
+
key: index
|
|
43
|
+
}, row.map((item, itemIndex) => (0, _isPlainObject2.default)(item) ? /*#__PURE__*/_react.default.createElement(_item.default, Object.assign({
|
|
44
|
+
itemKey: item.key
|
|
45
|
+
}, item, {
|
|
46
|
+
key: index + '-' + itemIndex
|
|
47
|
+
}), item.value) : null));
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
return data && data.length ? data.map((item, index) => (0, _isPlainObject2.default)(item) ? /*#__PURE__*/_react.default.createElement(_item.default, Object.assign({
|
|
51
|
+
itemKey: item.key
|
|
52
|
+
}, item, {
|
|
53
|
+
key: index
|
|
54
|
+
}), item.value) : null) : children;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
this.foundation = new _foundation.default(this.adapter);
|
|
58
|
+
}
|
|
59
|
+
get adapter() {
|
|
60
|
+
return Object.assign({}, super.adapter);
|
|
61
|
+
}
|
|
29
62
|
render() {
|
|
30
63
|
const _a = this.props,
|
|
31
64
|
{
|
|
@@ -35,27 +68,26 @@ class Descriptions extends _react.PureComponent {
|
|
|
35
68
|
className,
|
|
36
69
|
style,
|
|
37
70
|
children,
|
|
38
|
-
data
|
|
71
|
+
data,
|
|
72
|
+
layout
|
|
39
73
|
} = _a,
|
|
40
|
-
rest = __rest(_a, ["align", "row", "size", "className", "style", "children", "data"]);
|
|
74
|
+
rest = __rest(_a, ["align", "row", "size", "className", "style", "children", "data", "layout"]);
|
|
41
75
|
const classNames = (0, _classnames.default)(prefixCls, className, {
|
|
42
76
|
[`${prefixCls}-${align}`]: !row,
|
|
43
77
|
[`${prefixCls}-double`]: row,
|
|
44
|
-
[`${prefixCls}-double-${size}`]: row
|
|
78
|
+
[`${prefixCls}-double-${size}`]: row,
|
|
79
|
+
[`${prefixCls}-horizontal`]: layout === 'horizontal',
|
|
80
|
+
[`${prefixCls}-vertical`]: layout === 'vertical'
|
|
45
81
|
});
|
|
46
|
-
const childrenList = data && data.length ? data.map((item, index) => (0, _isPlainObject2.default)(item) ? /*#__PURE__*/_react.default.createElement(_item.default, Object.assign({
|
|
47
|
-
itemKey: item.key
|
|
48
|
-
}, item, {
|
|
49
|
-
key: index
|
|
50
|
-
}), item.value) : null) : children;
|
|
51
82
|
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
52
83
|
className: classNames,
|
|
53
84
|
style: style
|
|
54
85
|
}, (0, _getDataAttr.default)(rest)), /*#__PURE__*/_react.default.createElement("table", null, /*#__PURE__*/_react.default.createElement("tbody", null, /*#__PURE__*/_react.default.createElement(_descriptionsContext.default.Provider, {
|
|
55
86
|
value: {
|
|
56
|
-
align
|
|
87
|
+
align,
|
|
88
|
+
layout
|
|
57
89
|
}
|
|
58
|
-
},
|
|
90
|
+
}, this.renderChildrenList()))));
|
|
59
91
|
}
|
|
60
92
|
}
|
|
61
93
|
Descriptions.Item = _item.default;
|
|
@@ -72,13 +104,17 @@ Descriptions.propTypes = {
|
|
|
72
104
|
hidden: _propTypes.default.bool,
|
|
73
105
|
className: _propTypes.default.string,
|
|
74
106
|
style: _propTypes.default.object
|
|
75
|
-
}))
|
|
107
|
+
})),
|
|
108
|
+
layout: _propTypes.default.oneOf(_constants.strings.LAYOUT_SET),
|
|
109
|
+
column: _propTypes.default.number
|
|
76
110
|
};
|
|
77
111
|
Descriptions.defaultProps = {
|
|
78
112
|
align: 'center',
|
|
79
113
|
row: false,
|
|
80
114
|
size: 'medium',
|
|
81
|
-
data: []
|
|
115
|
+
data: [],
|
|
116
|
+
layout: 'vertical',
|
|
117
|
+
column: 3
|
|
82
118
|
};
|
|
83
119
|
var _default = Descriptions;
|
|
84
120
|
exports.default = _default;
|
|
@@ -8,6 +8,7 @@ export interface DescriptionsItemProps {
|
|
|
8
8
|
children?: React.ReactNode | (() => React.ReactNode);
|
|
9
9
|
style?: React.CSSProperties;
|
|
10
10
|
itemKey?: React.ReactNode;
|
|
11
|
+
span?: number;
|
|
11
12
|
}
|
|
12
13
|
export default class Item extends PureComponent<DescriptionsItemProps> {
|
|
13
14
|
static propTypes: {
|
|
@@ -31,38 +31,45 @@ class Item extends _react.PureComponent {
|
|
|
31
31
|
itemKey,
|
|
32
32
|
hidden,
|
|
33
33
|
className,
|
|
34
|
+
span,
|
|
34
35
|
style,
|
|
35
36
|
children
|
|
36
37
|
} = _a,
|
|
37
|
-
rest = __rest(_a, ["itemKey", "hidden", "className", "style", "children"]);
|
|
38
|
+
rest = __rest(_a, ["itemKey", "hidden", "className", "span", "style", "children"]);
|
|
38
39
|
const {
|
|
39
|
-
align
|
|
40
|
+
align,
|
|
41
|
+
layout
|
|
40
42
|
} = this.context;
|
|
41
43
|
if (hidden) {
|
|
42
44
|
return null;
|
|
43
45
|
}
|
|
44
|
-
const
|
|
45
|
-
className:
|
|
46
|
-
|
|
47
|
-
}, (0, _getDataAttr.default)(rest)), /*#__PURE__*/_react.default.createElement("td", {
|
|
48
|
-
className: `${prefixCls}-item`
|
|
46
|
+
const plainItem = /*#__PURE__*/_react.default.createElement("td", {
|
|
47
|
+
className: `${prefixCls}-item`,
|
|
48
|
+
colSpan: span || 1
|
|
49
49
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
50
50
|
className: keyCls
|
|
51
51
|
}, itemKey, ":"), /*#__PURE__*/_react.default.createElement("span", {
|
|
52
52
|
className: valCls
|
|
53
|
-
}, typeof children === 'function' ? children() : children))
|
|
54
|
-
|
|
55
|
-
style: style
|
|
56
|
-
}, (0, _getDataAttr.default)(rest)), /*#__PURE__*/_react.default.createElement("th", {
|
|
53
|
+
}, typeof children === 'function' ? children() : children));
|
|
54
|
+
const alignItem = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("th", {
|
|
57
55
|
className: `${prefixCls}-item ${prefixCls}-item-th`
|
|
58
56
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
59
57
|
className: keyCls
|
|
60
58
|
}, itemKey)), /*#__PURE__*/_react.default.createElement("td", {
|
|
61
|
-
className: `${prefixCls}-item ${prefixCls}-item-td
|
|
59
|
+
className: `${prefixCls}-item ${prefixCls}-item-td`,
|
|
60
|
+
colSpan: span || 1
|
|
62
61
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
63
62
|
className: valCls
|
|
64
63
|
}, typeof children === 'function' ? children() : children)));
|
|
65
|
-
|
|
64
|
+
const item = align === 'plain' ? /*#__PURE__*/_react.default.createElement("tr", Object.assign({
|
|
65
|
+
className: className,
|
|
66
|
+
style: style
|
|
67
|
+
}, (0, _getDataAttr.default)(rest)), plainItem) : /*#__PURE__*/_react.default.createElement("tr", Object.assign({
|
|
68
|
+
className: className,
|
|
69
|
+
style: style
|
|
70
|
+
}, (0, _getDataAttr.default)(rest)), alignItem);
|
|
71
|
+
const horizontalItem = align === 'plain' ? plainItem : alignItem;
|
|
72
|
+
return layout === 'horizontal' ? horizontalItem : item;
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
exports.default = Item;
|
|
@@ -71,6 +71,7 @@ export interface PreviewProps extends BaseProps {
|
|
|
71
71
|
onRatioChange?: (type: RatioType) => void;
|
|
72
72
|
onRotateLeft?: (angle: number) => void;
|
|
73
73
|
onDownload?: (src: string, index: number) => void;
|
|
74
|
+
onDownloadError?: (src: string) => void;
|
|
74
75
|
setDownloadName?: (src: string) => string;
|
|
75
76
|
}
|
|
76
77
|
export interface PreviewInnerProps extends Omit<PreviewProps, "previewCls" | "previewStyle"> {
|
|
@@ -98,6 +98,12 @@ class PreviewInner extends _baseComponent.default {
|
|
|
98
98
|
} = this.props;
|
|
99
99
|
(0, _isFunction2.default)(onDownload) && onDownload(src, index);
|
|
100
100
|
},
|
|
101
|
+
notifyDownloadError: src => {
|
|
102
|
+
const {
|
|
103
|
+
onDownloadError
|
|
104
|
+
} = this.props;
|
|
105
|
+
(0, _isFunction2.default)(onDownloadError) && onDownloadError(src);
|
|
106
|
+
},
|
|
101
107
|
registerKeyDownListener: () => {
|
|
102
108
|
window && window.addEventListener("keydown", this.handleKeyDown);
|
|
103
109
|
},
|
package/lib/cjs/modal/Modal.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@douyinfe/semi-foundation/lib/cjs/modal/modal.css';
|
|
2
2
|
import ModalFoundation, { ModalAdapter, ModalProps, ModalState } from '@douyinfe/semi-foundation/lib/cjs/modal/modalFoundation';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import '
|
|
4
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
5
5
|
import BaseComponent from '../_base/baseComponent';
|
|
6
|
-
import useModal from './useModal';
|
|
7
6
|
import { ButtonProps } from '../button/Button';
|
|
8
|
-
|
|
7
|
+
import useModal from './useModal';
|
|
8
|
+
export declare let destroyFns: any[];
|
|
9
9
|
export type ConfirmType = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
10
10
|
export type Directions = 'ltr' | 'rtl';
|
|
11
11
|
export type { ModalState };
|
package/lib/cjs/modal/Modal.js
CHANGED
|
@@ -5,21 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.destroyFns = exports.default = void 0;
|
|
7
7
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
8
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/modal/constants");
|
|
10
|
-
|
|
9
|
+
require("@douyinfe/semi-foundation/lib/cjs/modal/modal.css");
|
|
11
10
|
var _modalFoundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/modal/modalFoundation"));
|
|
12
|
-
var _ModalContent = _interopRequireDefault(require("./ModalContent"));
|
|
13
|
-
var _portal = _interopRequireDefault(require("../_portal"));
|
|
14
|
-
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
15
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
require("
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
18
14
|
var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
19
|
-
var _confirm = _interopRequireWildcard(require("./confirm"));
|
|
20
|
-
var _useModal = _interopRequireDefault(require("./useModal"));
|
|
21
15
|
var _cssAnimation = _interopRequireDefault(require("../_cssAnimation"));
|
|
16
|
+
var _portal = _interopRequireDefault(require("../_portal"));
|
|
22
17
|
var _utils = require("../_utils");
|
|
18
|
+
var _button = _interopRequireDefault(require("../button"));
|
|
19
|
+
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
20
|
+
var _ModalContent = _interopRequireDefault(require("./ModalContent"));
|
|
21
|
+
var _confirm = _interopRequireWildcard(require("./confirm"));
|
|
22
|
+
var _useModal = _interopRequireDefault(require("./useModal"));
|
|
23
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -31,7 +31,7 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
31
31
|
}
|
|
32
32
|
return t;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
let destroyFns = [];
|
|
35
35
|
exports.destroyFns = destroyFns;
|
|
36
36
|
class Modal extends _baseComponent.default {
|
|
37
37
|
constructor(props) {
|
|
@@ -359,12 +359,13 @@ Modal.confirm = function (props) {
|
|
|
359
359
|
return (0, _confirm.default)((0, _confirm.withConfirm)(props));
|
|
360
360
|
};
|
|
361
361
|
Modal.destroyAll = function destroyAllFn() {
|
|
362
|
-
|
|
363
|
-
const close = destroyFns
|
|
362
|
+
for (let i = 0, len = destroyFns.length; i < len; i++) {
|
|
363
|
+
const close = destroyFns[i];
|
|
364
364
|
if (close) {
|
|
365
365
|
close();
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
+
exports.destroyFns = destroyFns = [];
|
|
368
369
|
};
|
|
369
370
|
var _default = Modal;
|
|
370
371
|
exports.default = _default;
|
|
@@ -166,6 +166,7 @@ export declare function withError(props: ModalReactProps): {
|
|
|
166
166
|
icon: string | number | boolean | React.ReactFragment | JSX.Element;
|
|
167
167
|
closable?: boolean;
|
|
168
168
|
onCancel?: (e: React.MouseEvent<Element, MouseEvent>) => void | Promise<any>;
|
|
169
|
+
lazyRender?: boolean;
|
|
169
170
|
bodyStyle?: React.CSSProperties;
|
|
170
171
|
cancelButtonProps?: import("../button").BaseButtonProps;
|
|
171
172
|
cancelText?: string;
|
|
@@ -180,7 +181,6 @@ export declare function withError(props: ModalReactProps): {
|
|
|
180
181
|
okType?: import("@douyinfe/semi-foundation/lib/cjs/modal/modalFoundation").OKType;
|
|
181
182
|
onOk?: (e: React.MouseEvent<Element, MouseEvent>) => void | Promise<any>;
|
|
182
183
|
closeIcon?: React.ReactNode;
|
|
183
|
-
lazyRender?: boolean;
|
|
184
184
|
fullScreen?: boolean;
|
|
185
185
|
footerFill?: boolean;
|
|
186
186
|
type: "error";
|
package/lib/cjs/toast/index.js
CHANGED
|
@@ -185,6 +185,9 @@ const createBaseToast = () => {
|
|
|
185
185
|
ToastList.defaultOpts[pos] = opts[pos];
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
|
+
if (typeof opts.theme === 'string' && _constants.strings.themes.includes(opts.theme)) {
|
|
189
|
+
ToastList.defaultOpts.theme = opts.theme;
|
|
190
|
+
}
|
|
188
191
|
if (typeof opts.zIndex === 'number') {
|
|
189
192
|
ToastList.defaultOpts.zIndex = opts.zIndex;
|
|
190
193
|
}
|
|
@@ -433,7 +433,7 @@ class Base extends _react.Component {
|
|
|
433
433
|
ellipsisContent: props.children,
|
|
434
434
|
expanded: false,
|
|
435
435
|
// if text is truncated with js
|
|
436
|
-
isTruncated:
|
|
436
|
+
isTruncated: false,
|
|
437
437
|
prevChildren: null
|
|
438
438
|
};
|
|
439
439
|
this.wrapperRef = /*#__PURE__*/_react.default.createRef();
|
|
@@ -454,10 +454,10 @@ class Base extends _react.Component {
|
|
|
454
454
|
newState.prevChildren = props.children;
|
|
455
455
|
if (props.ellipsis && prevChildren !== props.children) {
|
|
456
456
|
// reset ellipsis state if children update
|
|
457
|
-
newState.isOverflowed =
|
|
457
|
+
newState.isOverflowed = false;
|
|
458
458
|
newState.ellipsisContent = props.children;
|
|
459
459
|
newState.expanded = false;
|
|
460
|
-
newState.isTruncated =
|
|
460
|
+
newState.isTruncated = false;
|
|
461
461
|
}
|
|
462
462
|
return newState;
|
|
463
463
|
}
|
|
@@ -59,6 +59,7 @@ export interface CascaderProps extends BasicCascaderProps {
|
|
|
59
59
|
onFocus?: (e: MouseEvent) => void;
|
|
60
60
|
validateStatus?: ValidateStatus;
|
|
61
61
|
position?: Position;
|
|
62
|
+
searchPosition?: string;
|
|
62
63
|
}
|
|
63
64
|
export interface CascaderState extends BasicCascaderInnerData {
|
|
64
65
|
keyEntities: Entities;
|
|
@@ -143,6 +144,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
143
144
|
enableLeafClick: PropTypes.Requireable<boolean>;
|
|
144
145
|
preventScroll: PropTypes.Requireable<boolean>;
|
|
145
146
|
position: PropTypes.Requireable<string>;
|
|
147
|
+
searchPosition: PropTypes.Requireable<string>;
|
|
146
148
|
};
|
|
147
149
|
static defaultProps: any;
|
|
148
150
|
options: any;
|
|
@@ -161,6 +163,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
161
163
|
componentDidMount(): void;
|
|
162
164
|
componentWillUnmount(): void;
|
|
163
165
|
componentDidUpdate(prevProps: CascaderProps): void;
|
|
166
|
+
search: (value: string) => void;
|
|
164
167
|
handleInputChange: (value: string) => void;
|
|
165
168
|
handleTagRemoveInTrigger: (pos: string) => void;
|
|
166
169
|
handleTagClose: (tagChildren: React.ReactNode, e: React.MouseEvent<HTMLElement>, tagKey: string | number) => void;
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -31,6 +31,10 @@ const resetkey = 0;
|
|
|
31
31
|
class Cascader extends BaseComponent {
|
|
32
32
|
constructor(props) {
|
|
33
33
|
super(props);
|
|
34
|
+
// ref method
|
|
35
|
+
this.search = value => {
|
|
36
|
+
this.handleInputChange(value);
|
|
37
|
+
};
|
|
34
38
|
this.handleInputChange = value => {
|
|
35
39
|
this.foundation.handleInputChange(value);
|
|
36
40
|
};
|
|
@@ -217,12 +221,13 @@ class Cascader extends BaseComponent {
|
|
|
217
221
|
const {
|
|
218
222
|
placeholder,
|
|
219
223
|
filterTreeNode,
|
|
220
|
-
multiple
|
|
224
|
+
multiple,
|
|
225
|
+
searchPosition
|
|
221
226
|
} = this.props;
|
|
222
227
|
const {
|
|
223
228
|
checkedKeys
|
|
224
229
|
} = this.state;
|
|
225
|
-
const searchable = Boolean(filterTreeNode);
|
|
230
|
+
const searchable = Boolean(filterTreeNode) && searchPosition === strings.SEARCH_POSITION_TRIGGER;
|
|
226
231
|
if (!searchable) {
|
|
227
232
|
if (multiple) {
|
|
228
233
|
if (checkedKeys.size === 0) {
|
|
@@ -982,7 +987,8 @@ Cascader.propTypes = {
|
|
|
982
987
|
leafOnly: PropTypes.bool,
|
|
983
988
|
enableLeafClick: PropTypes.bool,
|
|
984
989
|
preventScroll: PropTypes.bool,
|
|
985
|
-
position: PropTypes.string
|
|
990
|
+
position: PropTypes.string,
|
|
991
|
+
searchPosition: PropTypes.string
|
|
986
992
|
};
|
|
987
993
|
Cascader.defaultProps = getDefaultPropsFromGlobalConfig(Cascader.__SemiComponentName__, {
|
|
988
994
|
borderless: false,
|
|
@@ -1013,6 +1019,7 @@ Cascader.defaultProps = getDefaultPropsFromGlobalConfig(Cascader.__SemiComponent
|
|
|
1013
1019
|
onDropdownVisibleChange: _noop,
|
|
1014
1020
|
onListScroll: _noop,
|
|
1015
1021
|
enableLeafClick: false,
|
|
1016
|
-
'aria-label': 'Cascader'
|
|
1022
|
+
'aria-label': 'Cascader',
|
|
1023
|
+
searchPosition: strings.SEARCH_POSITION_TRIGGER
|
|
1017
1024
|
});
|
|
1018
1025
|
export default Cascader;
|
|
@@ -22,9 +22,8 @@ class Collapsible extends BaseComponent {
|
|
|
22
22
|
this.isChildrenInRenderTree = () => {
|
|
23
23
|
if (this.domRef.current) {
|
|
24
24
|
return this.domRef.current.offsetHeight > 0;
|
|
25
|
-
} else {
|
|
26
|
-
return false;
|
|
27
25
|
}
|
|
26
|
+
return false;
|
|
28
27
|
};
|
|
29
28
|
this.state = {
|
|
30
29
|
domInRenderTree: false,
|
|
@@ -108,6 +107,7 @@ class Collapsible extends BaseComponent {
|
|
|
108
107
|
const wrapperCls = cls(`${cssClasses.PREFIX}-wrapper`, {
|
|
109
108
|
[`${cssClasses.PREFIX}-transition`]: this.props.motion && this.state.isTransitioning
|
|
110
109
|
}, this.props.className);
|
|
110
|
+
const shouldRender = this.props.keepDOM && !this.props.lazyRender || this.props.collapseHeight !== 0 || this.state.visible || this.props.isOpen;
|
|
111
111
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
112
112
|
className: wrapperCls,
|
|
113
113
|
style: wrapperStyle,
|
|
@@ -126,7 +126,7 @@ class Collapsible extends BaseComponent {
|
|
|
126
126
|
overflow: 'hidden'
|
|
127
127
|
},
|
|
128
128
|
id: this.props.id
|
|
129
|
-
},
|
|
129
|
+
}, shouldRender && this.props.children));
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
Collapsible.__SemiComponentName__ = "Collapsible";
|
|
@@ -135,6 +135,7 @@ Collapsible.defaultProps = getDefaultPropsFromGlobalConfig(Collapsible.__SemiCom
|
|
|
135
135
|
duration: 250,
|
|
136
136
|
motion: true,
|
|
137
137
|
keepDOM: false,
|
|
138
|
+
lazyRender: true,
|
|
138
139
|
collapseHeight: 0,
|
|
139
140
|
fade: false
|
|
140
141
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export type DescriptionsAlign = 'center' | 'justify' | 'left' | 'plain';
|
|
3
|
+
export type DescriptionLayout = 'horizontal' | 'vertical';
|
|
3
4
|
export interface DescriptionsContextValue {
|
|
4
5
|
align?: DescriptionsAlign;
|
|
6
|
+
layout?: DescriptionLayout;
|
|
5
7
|
}
|
|
6
8
|
declare const DescriptionsContext: React.Context<DescriptionsContextValue>;
|
|
7
9
|
export default DescriptionsContext;
|