@douyinfe/semi-ui 2.43.1 → 2.44.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 +16 -1
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +27032 -26961
- 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.js +4 -2
- package/lib/cjs/cascader/item.d.ts +5 -1
- package/lib/cjs/cascader/item.js +92 -55
- package/lib/cjs/cascader/virtualRow.d.ts +8 -0
- package/lib/cjs/cascader/virtualRow.js +21 -0
- package/lib/cjs/popconfirm/index.js +8 -3
- package/lib/cjs/table/ColumnFilter.js +2 -1
- package/lib/cjs/tag/index.d.ts +2 -0
- package/lib/cjs/tag/index.js +15 -5
- package/lib/cjs/tag/interface.d.ts +3 -1
- package/lib/cjs/tooltip/index.js +5 -3
- package/lib/es/cascader/index.js +4 -2
- package/lib/es/cascader/item.d.ts +5 -1
- package/lib/es/cascader/item.js +92 -55
- package/lib/es/cascader/virtualRow.d.ts +8 -0
- package/lib/es/cascader/virtualRow.js +14 -0
- package/lib/es/popconfirm/index.js +8 -3
- package/lib/es/table/ColumnFilter.js +2 -1
- package/lib/es/tag/index.d.ts +2 -0
- package/lib/es/tag/index.js +15 -5
- package/lib/es/tag/interface.d.ts +3 -1
- package/lib/es/tooltip/index.js +5 -3
- package/package.json +8 -8
|
@@ -125,7 +125,8 @@ class Cascader extends _baseComponent.default {
|
|
|
125
125
|
bottomSlot,
|
|
126
126
|
showNext,
|
|
127
127
|
multiple,
|
|
128
|
-
filterRender
|
|
128
|
+
filterRender,
|
|
129
|
+
virtualizeInSearch
|
|
129
130
|
} = this.props;
|
|
130
131
|
const searchable = Boolean(filterTreeNode) && isSearching;
|
|
131
132
|
const popoverCls = (0, _classnames.default)(dropdownClassName, `${prefixcls}-popover`);
|
|
@@ -153,7 +154,8 @@ class Cascader extends _baseComponent.default {
|
|
|
153
154
|
multiple: multiple,
|
|
154
155
|
checkedKeys: checkedKeys,
|
|
155
156
|
halfCheckedKeys: halfCheckedKeys,
|
|
156
|
-
filterRender: filterRender
|
|
157
|
+
filterRender: filterRender,
|
|
158
|
+
virtualize: virtualizeInSearch
|
|
157
159
|
}), bottomSlot);
|
|
158
160
|
return content;
|
|
159
161
|
};
|
|
@@ -2,7 +2,7 @@ import React, { PureComponent, ReactNode } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ContextValue } from '../configProvider/context';
|
|
4
4
|
import { CheckboxEvent } from '../checkbox';
|
|
5
|
-
import { BasicCascaderData, BasicEntity, ShowNextType, BasicData } from '@douyinfe/semi-foundation/lib/cjs/cascader/foundation';
|
|
5
|
+
import { BasicCascaderData, BasicEntity, ShowNextType, BasicData, Virtualize } from '@douyinfe/semi-foundation/lib/cjs/cascader/foundation';
|
|
6
6
|
export interface CascaderData extends BasicCascaderData {
|
|
7
7
|
label: React.ReactNode;
|
|
8
8
|
}
|
|
@@ -52,6 +52,7 @@ export interface CascaderItemProps {
|
|
|
52
52
|
checkedKeys: Set<string>;
|
|
53
53
|
halfCheckedKeys: Set<string>;
|
|
54
54
|
filterRender?: (props: FilterRenderProps) => ReactNode;
|
|
55
|
+
virtualize?: Virtualize;
|
|
55
56
|
}
|
|
56
57
|
export default class Item extends PureComponent<CascaderItemProps> {
|
|
57
58
|
static contextType: React.Context<ContextValue>;
|
|
@@ -68,6 +69,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
68
69
|
onItemCheckboxClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
69
70
|
separator: PropTypes.Requireable<string>;
|
|
70
71
|
keyword: PropTypes.Requireable<string>;
|
|
72
|
+
virtualize: PropTypes.Requireable<object>;
|
|
71
73
|
};
|
|
72
74
|
static defaultProps: {
|
|
73
75
|
empty: boolean;
|
|
@@ -87,7 +89,9 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
87
89
|
};
|
|
88
90
|
renderIcon: (type: string, haveMarginLeft?: boolean) => JSX.Element;
|
|
89
91
|
highlight: (searchText: React.ReactNode[]) => React.ReactNode[];
|
|
92
|
+
renderFlattenOptionItem: (data: Data, index?: number, style?: any) => JSX.Element;
|
|
90
93
|
renderFlattenOption: (data: Data[]) => JSX.Element;
|
|
94
|
+
renderVirtualizeList: (visibleOptions: any) => JSX.Element;
|
|
91
95
|
renderItem(renderData: Array<Entity>, content?: Array<React.ReactNode>): React.ReactNode[];
|
|
92
96
|
renderEmpty(): JSX.Element;
|
|
93
97
|
render(): JSX.Element;
|
package/lib/cjs/cascader/item.js
CHANGED
|
@@ -15,6 +15,8 @@ var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer")
|
|
|
15
15
|
var _semiIcons = require("@douyinfe/semi-icons");
|
|
16
16
|
var _spin = _interopRequireDefault(require("../spin"));
|
|
17
17
|
var _checkbox = _interopRequireDefault(require("../checkbox"));
|
|
18
|
+
var _reactWindow = require("react-window");
|
|
19
|
+
var _virtualRow = _interopRequireDefault(require("./virtualRow"));
|
|
18
20
|
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); }
|
|
19
21
|
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; }
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -138,72 +140,106 @@ class Item extends _react.PureComponent {
|
|
|
138
140
|
});
|
|
139
141
|
return content;
|
|
140
142
|
};
|
|
141
|
-
this.
|
|
143
|
+
this.renderFlattenOptionItem = (data, index, style) => {
|
|
144
|
+
var _a;
|
|
142
145
|
const {
|
|
143
146
|
multiple,
|
|
144
147
|
selectedKeys,
|
|
145
148
|
checkedKeys,
|
|
146
149
|
halfCheckedKeys,
|
|
147
150
|
keyword,
|
|
148
|
-
filterRender
|
|
151
|
+
filterRender,
|
|
152
|
+
virtualize
|
|
153
|
+
} = this.props;
|
|
154
|
+
const {
|
|
155
|
+
searchText,
|
|
156
|
+
key,
|
|
157
|
+
disabled,
|
|
158
|
+
pathData
|
|
159
|
+
} = data;
|
|
160
|
+
const selected = selectedKeys.has(key);
|
|
161
|
+
const className = (0, _classnames.default)(prefixcls, {
|
|
162
|
+
[`${prefixcls}-flatten`]: true && !filterRender,
|
|
163
|
+
[`${prefixcls}-disabled`]: disabled,
|
|
164
|
+
[`${prefixcls}-select`]: selected && !multiple
|
|
165
|
+
});
|
|
166
|
+
const onClick = e => {
|
|
167
|
+
this.onClick(e, data);
|
|
168
|
+
};
|
|
169
|
+
const onKeyPress = e => this.handleItemEnterPress(e, data);
|
|
170
|
+
const onCheck = e => this.onCheckboxChange(e, data);
|
|
171
|
+
if (filterRender) {
|
|
172
|
+
const props = {
|
|
173
|
+
className,
|
|
174
|
+
inputValue: keyword,
|
|
175
|
+
disabled,
|
|
176
|
+
data: pathData,
|
|
177
|
+
checkStatus: {
|
|
178
|
+
checked: checkedKeys.has(data.key),
|
|
179
|
+
halfChecked: halfCheckedKeys.has(data.key)
|
|
180
|
+
},
|
|
181
|
+
selected,
|
|
182
|
+
onClick,
|
|
183
|
+
onCheck
|
|
184
|
+
};
|
|
185
|
+
const item = filterRender(props);
|
|
186
|
+
const otherProps = virtualize ? {
|
|
187
|
+
key,
|
|
188
|
+
style: Object.assign(Object.assign({}, (_a = item.props.style) !== null && _a !== void 0 ? _a : {}), style)
|
|
189
|
+
} : {
|
|
190
|
+
key
|
|
191
|
+
};
|
|
192
|
+
return /*#__PURE__*/_react.default.cloneElement(item, otherProps);
|
|
193
|
+
}
|
|
194
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
195
|
+
role: 'menuitem',
|
|
196
|
+
className: className,
|
|
197
|
+
style: style,
|
|
198
|
+
key: key,
|
|
199
|
+
onClick: onClick,
|
|
200
|
+
onKeyPress: onKeyPress
|
|
201
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
202
|
+
className: `${prefixcls}-label`
|
|
203
|
+
}, !multiple && this.renderIcon('empty'), multiple && /*#__PURE__*/_react.default.createElement(_checkbox.default, {
|
|
204
|
+
onChange: onCheck,
|
|
205
|
+
disabled: disabled,
|
|
206
|
+
indeterminate: halfCheckedKeys.has(data.key),
|
|
207
|
+
checked: checkedKeys.has(data.key),
|
|
208
|
+
className: `${prefixcls}-label-checkbox`
|
|
209
|
+
}), this.highlight(searchText)));
|
|
210
|
+
};
|
|
211
|
+
this.renderFlattenOption = data => {
|
|
212
|
+
const {
|
|
213
|
+
virtualize
|
|
149
214
|
} = this.props;
|
|
150
215
|
const content = /*#__PURE__*/_react.default.createElement("ul", {
|
|
151
216
|
className: `${prefixcls}-list`,
|
|
152
217
|
key: 'flatten-list'
|
|
153
|
-
}, data.map(item =>
|
|
154
|
-
const {
|
|
155
|
-
searchText,
|
|
156
|
-
key,
|
|
157
|
-
disabled,
|
|
158
|
-
pathData
|
|
159
|
-
} = item;
|
|
160
|
-
const selected = selectedKeys.has(key);
|
|
161
|
-
const className = (0, _classnames.default)(prefixcls, {
|
|
162
|
-
[`${prefixcls}-flatten`]: true && !filterRender,
|
|
163
|
-
[`${prefixcls}-disabled`]: disabled,
|
|
164
|
-
[`${prefixcls}-select`]: selected && !multiple
|
|
165
|
-
});
|
|
166
|
-
const onClick = e => {
|
|
167
|
-
this.onClick(e, item);
|
|
168
|
-
};
|
|
169
|
-
const onKeyPress = e => this.handleItemEnterPress(e, item);
|
|
170
|
-
const onCheck = e => this.onCheckboxChange(e, item);
|
|
171
|
-
if (filterRender) {
|
|
172
|
-
const props = {
|
|
173
|
-
className,
|
|
174
|
-
inputValue: keyword,
|
|
175
|
-
disabled,
|
|
176
|
-
data: pathData,
|
|
177
|
-
checkStatus: {
|
|
178
|
-
checked: checkedKeys.has(item.key),
|
|
179
|
-
halfChecked: halfCheckedKeys.has(item.key)
|
|
180
|
-
},
|
|
181
|
-
selected,
|
|
182
|
-
onClick,
|
|
183
|
-
onCheck
|
|
184
|
-
};
|
|
185
|
-
return /*#__PURE__*/_react.default.cloneElement(filterRender(props), {
|
|
186
|
-
key
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
return /*#__PURE__*/_react.default.createElement("li", {
|
|
190
|
-
role: 'menuitem',
|
|
191
|
-
className: className,
|
|
192
|
-
key: key,
|
|
193
|
-
onClick: onClick,
|
|
194
|
-
onKeyPress: onKeyPress
|
|
195
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
196
|
-
className: `${prefixcls}-label`
|
|
197
|
-
}, !multiple && this.renderIcon('empty'), multiple && /*#__PURE__*/_react.default.createElement(_checkbox.default, {
|
|
198
|
-
onChange: onCheck,
|
|
199
|
-
disabled: disabled,
|
|
200
|
-
indeterminate: halfCheckedKeys.has(item.key),
|
|
201
|
-
checked: checkedKeys.has(item.key),
|
|
202
|
-
className: `${prefixcls}-label-checkbox`
|
|
203
|
-
}), this.highlight(searchText)));
|
|
204
|
-
}));
|
|
218
|
+
}, virtualize ? this.renderVirtualizeList(data) : data.map(item => this.renderFlattenOptionItem(item)));
|
|
205
219
|
return content;
|
|
206
220
|
};
|
|
221
|
+
this.renderVirtualizeList = visibleOptions => {
|
|
222
|
+
var _a;
|
|
223
|
+
const {
|
|
224
|
+
direction
|
|
225
|
+
} = this.context;
|
|
226
|
+
const {
|
|
227
|
+
virtualize
|
|
228
|
+
} = this.props;
|
|
229
|
+
return /*#__PURE__*/_react.default.createElement(_reactWindow.FixedSizeList, {
|
|
230
|
+
height: virtualize.height,
|
|
231
|
+
itemCount: visibleOptions.length,
|
|
232
|
+
itemSize: virtualize.itemSize,
|
|
233
|
+
itemData: {
|
|
234
|
+
visibleOptions,
|
|
235
|
+
renderOption: this.renderFlattenOptionItem
|
|
236
|
+
},
|
|
237
|
+
width: (_a = virtualize.width) !== null && _a !== void 0 ? _a : '100%',
|
|
238
|
+
style: {
|
|
239
|
+
direction
|
|
240
|
+
}
|
|
241
|
+
}, _virtualRow.default);
|
|
242
|
+
};
|
|
207
243
|
}
|
|
208
244
|
renderItem(renderData) {
|
|
209
245
|
let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
@@ -333,7 +369,8 @@ Item.propTypes = {
|
|
|
333
369
|
halfCheckedKeys: _propTypes.default.object,
|
|
334
370
|
onItemCheckboxClick: _propTypes.default.func,
|
|
335
371
|
separator: _propTypes.default.string,
|
|
336
|
-
keyword: _propTypes.default.string
|
|
372
|
+
keyword: _propTypes.default.string,
|
|
373
|
+
virtualize: _propTypes.default.object
|
|
337
374
|
};
|
|
338
375
|
Item.defaultProps = {
|
|
339
376
|
empty: false
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const VirtualRow = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
index,
|
|
10
|
+
data,
|
|
11
|
+
style
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
visibleOptions,
|
|
15
|
+
renderOption
|
|
16
|
+
} = data;
|
|
17
|
+
const option = visibleOptions[index];
|
|
18
|
+
return renderOption(option, index, style);
|
|
19
|
+
};
|
|
20
|
+
var _default = VirtualRow;
|
|
21
|
+
exports.default = _default;
|
|
@@ -58,6 +58,11 @@ class Popconfirm extends _baseComponent.default {
|
|
|
58
58
|
});
|
|
59
59
|
const showTitle = title !== null && typeof title !== 'undefined';
|
|
60
60
|
const showContent = !(content === null || typeof content === 'undefined');
|
|
61
|
+
const hasIcon = /*#__PURE__*/_react.default.isValidElement(icon);
|
|
62
|
+
const bodyCls = (0, _classnames.default)({
|
|
63
|
+
[`${prefixCls}-body`]: true,
|
|
64
|
+
[`${prefixCls}-body-withIcon`]: hasIcon
|
|
65
|
+
});
|
|
61
66
|
return (
|
|
62
67
|
/*#__PURE__*/
|
|
63
68
|
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */
|
|
@@ -69,10 +74,10 @@ class Popconfirm extends _baseComponent.default {
|
|
|
69
74
|
className: `${prefixCls}-inner`
|
|
70
75
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
71
76
|
className: `${prefixCls}-header`
|
|
72
|
-
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
77
|
+
}, hasIcon ? /*#__PURE__*/_react.default.createElement("i", {
|
|
73
78
|
className: `${prefixCls}-header-icon`,
|
|
74
79
|
"x-semi-prop": "icon"
|
|
75
|
-
},
|
|
80
|
+
}, icon) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
76
81
|
className: `${prefixCls}-header-body`
|
|
77
82
|
}, showTitle ? /*#__PURE__*/_react.default.createElement("div", {
|
|
78
83
|
className: `${prefixCls}-header-title`,
|
|
@@ -85,7 +90,7 @@ class Popconfirm extends _baseComponent.default {
|
|
|
85
90
|
type: cancelType,
|
|
86
91
|
onClick: this.handleCancel
|
|
87
92
|
})), showContent ? /*#__PURE__*/_react.default.createElement("div", {
|
|
88
|
-
className:
|
|
93
|
+
className: bodyCls,
|
|
89
94
|
"x-semi-prop": "content"
|
|
90
95
|
}, (0, _isFunction2.default)(content) ? content({
|
|
91
96
|
initialFocusRef
|
|
@@ -104,7 +104,8 @@ function renderDropdown() {
|
|
|
104
104
|
dropdownProps.visible = filterDropdownVisible;
|
|
105
105
|
}
|
|
106
106
|
return /*#__PURE__*/_react.default.createElement(_dropdown.default, Object.assign({}, dropdownProps, {
|
|
107
|
-
key: `Dropdown_level_${level}
|
|
107
|
+
key: `Dropdown_level_${level}`,
|
|
108
|
+
className: `${_constants.cssClasses.PREFIX}-column-filter-dropdown`
|
|
108
109
|
}), nestedElem);
|
|
109
110
|
}
|
|
110
111
|
function ColumnFilter() {
|
package/lib/cjs/tag/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export default class Tag extends Component<TagProps, TagState> {
|
|
|
18
18
|
visible: PropTypes.Requireable<boolean>;
|
|
19
19
|
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
20
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
21
|
+
prefixIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
22
|
+
suffixIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
21
23
|
style: PropTypes.Requireable<object>;
|
|
22
24
|
className: PropTypes.Requireable<string>;
|
|
23
25
|
avatarSrc: PropTypes.Requireable<string>;
|
package/lib/cjs/tag/index.js
CHANGED
|
@@ -131,9 +131,11 @@ class Tag extends _react.Component {
|
|
|
131
131
|
shape,
|
|
132
132
|
avatarSrc,
|
|
133
133
|
avatarShape,
|
|
134
|
-
tabIndex
|
|
134
|
+
tabIndex,
|
|
135
|
+
prefixIcon,
|
|
136
|
+
suffixIcon
|
|
135
137
|
} = _a,
|
|
136
|
-
attr = __rest(_a, ["tagKey", "children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "shape", "avatarSrc", "avatarShape", "tabIndex"]);
|
|
138
|
+
attr = __rest(_a, ["tagKey", "children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "shape", "avatarSrc", "avatarShape", "tabIndex", "prefixIcon", "suffixIcon"]);
|
|
137
139
|
const {
|
|
138
140
|
visible: isVisible
|
|
139
141
|
} = this.state;
|
|
@@ -174,9 +176,13 @@ class Tag extends _react.Component {
|
|
|
174
176
|
const contentCls = (0, _classnames.default)(`${prefixCls}-content`, `${prefixCls}-content-${stringChild ? 'ellipsis' : 'center'}`);
|
|
175
177
|
return /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
|
176
178
|
"aria-label": this.props['aria-label'] || stringChild ? `${closable ? 'Closable ' : ''}Tag: ${children}` : ''
|
|
177
|
-
}, wrapProps),
|
|
179
|
+
}, wrapProps), prefixIcon ? /*#__PURE__*/_react.default.createElement("div", {
|
|
180
|
+
className: `${prefixCls}-prefix-icon`
|
|
181
|
+
}, prefixIcon) : null, avatarSrc ? this.renderAvatar() : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
178
182
|
className: contentCls
|
|
179
|
-
}, children),
|
|
183
|
+
}, children), suffixIcon ? /*#__PURE__*/_react.default.createElement("div", {
|
|
184
|
+
className: `${prefixCls}-suffix-icon`
|
|
185
|
+
}, suffixIcon) : null, closeIcon);
|
|
180
186
|
}
|
|
181
187
|
}
|
|
182
188
|
exports.default = Tag;
|
|
@@ -192,7 +198,9 @@ Tag.defaultProps = {
|
|
|
192
198
|
style: {},
|
|
193
199
|
className: '',
|
|
194
200
|
shape: 'square',
|
|
195
|
-
avatarShape: 'square'
|
|
201
|
+
avatarShape: 'square',
|
|
202
|
+
prefixIcon: null,
|
|
203
|
+
suffixIcon: null
|
|
196
204
|
};
|
|
197
205
|
Tag.propTypes = {
|
|
198
206
|
children: _propTypes.default.node,
|
|
@@ -204,6 +212,8 @@ Tag.propTypes = {
|
|
|
204
212
|
visible: _propTypes.default.bool,
|
|
205
213
|
onClose: _propTypes.default.func,
|
|
206
214
|
onClick: _propTypes.default.func,
|
|
215
|
+
prefixIcon: _propTypes.default.node,
|
|
216
|
+
suffixIcon: _propTypes.default.node,
|
|
207
217
|
style: _propTypes.default.object,
|
|
208
218
|
className: _propTypes.default.string,
|
|
209
219
|
avatarSrc: _propTypes.default.string,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { PopoverProps } from '../popover/index';
|
|
3
3
|
export type TagColor = 'amber' | 'blue' | 'cyan' | 'green' | 'grey' | 'indigo' | 'light-blue' | 'light-green' | 'lime' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'violet' | 'yellow' | 'white';
|
|
4
4
|
export type TagType = 'ghost' | 'solid' | 'light';
|
|
@@ -15,6 +15,8 @@ export interface TagProps {
|
|
|
15
15
|
visible?: boolean;
|
|
16
16
|
onClose?: (tagChildren: React.ReactNode, event: React.MouseEvent<HTMLElement>, tagKey: string | number) => void;
|
|
17
17
|
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
18
|
+
prefixIcon?: React.ReactNode;
|
|
19
|
+
suffixIcon?: React.ReactNode;
|
|
18
20
|
style?: React.CSSProperties;
|
|
19
21
|
className?: string;
|
|
20
22
|
avatarSrc?: string;
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -239,9 +239,11 @@ class Tooltip extends _baseComponent.default {
|
|
|
239
239
|
} = this.props;
|
|
240
240
|
const display = (0, _get2.default)(elem, 'props.style.display');
|
|
241
241
|
const block = (0, _get2.default)(elem, 'props.block');
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
const isStringElem = typeof elem == 'string';
|
|
243
|
+
const style = {};
|
|
244
|
+
if (!isStringElem) {
|
|
245
|
+
style.display = 'inline-block';
|
|
246
|
+
}
|
|
245
247
|
if (block || blockDisplays.includes(display)) {
|
|
246
248
|
style.width = '100%';
|
|
247
249
|
}
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -116,7 +116,8 @@ class Cascader extends BaseComponent {
|
|
|
116
116
|
bottomSlot,
|
|
117
117
|
showNext,
|
|
118
118
|
multiple,
|
|
119
|
-
filterRender
|
|
119
|
+
filterRender,
|
|
120
|
+
virtualizeInSearch
|
|
120
121
|
} = this.props;
|
|
121
122
|
const searchable = Boolean(filterTreeNode) && isSearching;
|
|
122
123
|
const popoverCls = cls(dropdownClassName, `${prefixcls}-popover`);
|
|
@@ -144,7 +145,8 @@ class Cascader extends BaseComponent {
|
|
|
144
145
|
multiple: multiple,
|
|
145
146
|
checkedKeys: checkedKeys,
|
|
146
147
|
halfCheckedKeys: halfCheckedKeys,
|
|
147
|
-
filterRender: filterRender
|
|
148
|
+
filterRender: filterRender,
|
|
149
|
+
virtualize: virtualizeInSearch
|
|
148
150
|
}), bottomSlot);
|
|
149
151
|
return content;
|
|
150
152
|
};
|
|
@@ -2,7 +2,7 @@ import React, { PureComponent, ReactNode } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ContextValue } from '../configProvider/context';
|
|
4
4
|
import { CheckboxEvent } from '../checkbox';
|
|
5
|
-
import { BasicCascaderData, BasicEntity, ShowNextType, BasicData } from '@douyinfe/semi-foundation/lib/es/cascader/foundation';
|
|
5
|
+
import { BasicCascaderData, BasicEntity, ShowNextType, BasicData, Virtualize } from '@douyinfe/semi-foundation/lib/es/cascader/foundation';
|
|
6
6
|
export interface CascaderData extends BasicCascaderData {
|
|
7
7
|
label: React.ReactNode;
|
|
8
8
|
}
|
|
@@ -52,6 +52,7 @@ export interface CascaderItemProps {
|
|
|
52
52
|
checkedKeys: Set<string>;
|
|
53
53
|
halfCheckedKeys: Set<string>;
|
|
54
54
|
filterRender?: (props: FilterRenderProps) => ReactNode;
|
|
55
|
+
virtualize?: Virtualize;
|
|
55
56
|
}
|
|
56
57
|
export default class Item extends PureComponent<CascaderItemProps> {
|
|
57
58
|
static contextType: React.Context<ContextValue>;
|
|
@@ -68,6 +69,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
68
69
|
onItemCheckboxClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
69
70
|
separator: PropTypes.Requireable<string>;
|
|
70
71
|
keyword: PropTypes.Requireable<string>;
|
|
72
|
+
virtualize: PropTypes.Requireable<object>;
|
|
71
73
|
};
|
|
72
74
|
static defaultProps: {
|
|
73
75
|
empty: boolean;
|
|
@@ -87,7 +89,9 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
87
89
|
};
|
|
88
90
|
renderIcon: (type: string, haveMarginLeft?: boolean) => JSX.Element;
|
|
89
91
|
highlight: (searchText: React.ReactNode[]) => React.ReactNode[];
|
|
92
|
+
renderFlattenOptionItem: (data: Data, index?: number, style?: any) => JSX.Element;
|
|
90
93
|
renderFlattenOption: (data: Data[]) => JSX.Element;
|
|
94
|
+
renderVirtualizeList: (visibleOptions: any) => JSX.Element;
|
|
91
95
|
renderItem(renderData: Array<Entity>, content?: Array<React.ReactNode>): React.ReactNode[];
|
|
92
96
|
renderEmpty(): JSX.Element;
|
|
93
97
|
render(): JSX.Element;
|
package/lib/es/cascader/item.js
CHANGED
|
@@ -9,6 +9,8 @@ import LocaleConsumer from '../locale/localeConsumer';
|
|
|
9
9
|
import { IconChevronRight, IconTick } from '@douyinfe/semi-icons';
|
|
10
10
|
import Spin from '../spin';
|
|
11
11
|
import Checkbox from '../checkbox';
|
|
12
|
+
import { FixedSizeList as List } from 'react-window';
|
|
13
|
+
import VirtualRow from './virtualRow';
|
|
12
14
|
const prefixcls = cssClasses.PREFIX_OPTION;
|
|
13
15
|
export default class Item extends PureComponent {
|
|
14
16
|
constructor() {
|
|
@@ -129,72 +131,106 @@ export default class Item extends PureComponent {
|
|
|
129
131
|
});
|
|
130
132
|
return content;
|
|
131
133
|
};
|
|
132
|
-
this.
|
|
134
|
+
this.renderFlattenOptionItem = (data, index, style) => {
|
|
135
|
+
var _a;
|
|
133
136
|
const {
|
|
134
137
|
multiple,
|
|
135
138
|
selectedKeys,
|
|
136
139
|
checkedKeys,
|
|
137
140
|
halfCheckedKeys,
|
|
138
141
|
keyword,
|
|
139
|
-
filterRender
|
|
142
|
+
filterRender,
|
|
143
|
+
virtualize
|
|
144
|
+
} = this.props;
|
|
145
|
+
const {
|
|
146
|
+
searchText,
|
|
147
|
+
key,
|
|
148
|
+
disabled,
|
|
149
|
+
pathData
|
|
150
|
+
} = data;
|
|
151
|
+
const selected = selectedKeys.has(key);
|
|
152
|
+
const className = cls(prefixcls, {
|
|
153
|
+
[`${prefixcls}-flatten`]: true && !filterRender,
|
|
154
|
+
[`${prefixcls}-disabled`]: disabled,
|
|
155
|
+
[`${prefixcls}-select`]: selected && !multiple
|
|
156
|
+
});
|
|
157
|
+
const onClick = e => {
|
|
158
|
+
this.onClick(e, data);
|
|
159
|
+
};
|
|
160
|
+
const onKeyPress = e => this.handleItemEnterPress(e, data);
|
|
161
|
+
const onCheck = e => this.onCheckboxChange(e, data);
|
|
162
|
+
if (filterRender) {
|
|
163
|
+
const props = {
|
|
164
|
+
className,
|
|
165
|
+
inputValue: keyword,
|
|
166
|
+
disabled,
|
|
167
|
+
data: pathData,
|
|
168
|
+
checkStatus: {
|
|
169
|
+
checked: checkedKeys.has(data.key),
|
|
170
|
+
halfChecked: halfCheckedKeys.has(data.key)
|
|
171
|
+
},
|
|
172
|
+
selected,
|
|
173
|
+
onClick,
|
|
174
|
+
onCheck
|
|
175
|
+
};
|
|
176
|
+
const item = filterRender(props);
|
|
177
|
+
const otherProps = virtualize ? {
|
|
178
|
+
key,
|
|
179
|
+
style: Object.assign(Object.assign({}, (_a = item.props.style) !== null && _a !== void 0 ? _a : {}), style)
|
|
180
|
+
} : {
|
|
181
|
+
key
|
|
182
|
+
};
|
|
183
|
+
return /*#__PURE__*/React.cloneElement(item, otherProps);
|
|
184
|
+
}
|
|
185
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
186
|
+
role: 'menuitem',
|
|
187
|
+
className: className,
|
|
188
|
+
style: style,
|
|
189
|
+
key: key,
|
|
190
|
+
onClick: onClick,
|
|
191
|
+
onKeyPress: onKeyPress
|
|
192
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
193
|
+
className: `${prefixcls}-label`
|
|
194
|
+
}, !multiple && this.renderIcon('empty'), multiple && /*#__PURE__*/React.createElement(Checkbox, {
|
|
195
|
+
onChange: onCheck,
|
|
196
|
+
disabled: disabled,
|
|
197
|
+
indeterminate: halfCheckedKeys.has(data.key),
|
|
198
|
+
checked: checkedKeys.has(data.key),
|
|
199
|
+
className: `${prefixcls}-label-checkbox`
|
|
200
|
+
}), this.highlight(searchText)));
|
|
201
|
+
};
|
|
202
|
+
this.renderFlattenOption = data => {
|
|
203
|
+
const {
|
|
204
|
+
virtualize
|
|
140
205
|
} = this.props;
|
|
141
206
|
const content = /*#__PURE__*/React.createElement("ul", {
|
|
142
207
|
className: `${prefixcls}-list`,
|
|
143
208
|
key: 'flatten-list'
|
|
144
|
-
}, data.map(item =>
|
|
145
|
-
const {
|
|
146
|
-
searchText,
|
|
147
|
-
key,
|
|
148
|
-
disabled,
|
|
149
|
-
pathData
|
|
150
|
-
} = item;
|
|
151
|
-
const selected = selectedKeys.has(key);
|
|
152
|
-
const className = cls(prefixcls, {
|
|
153
|
-
[`${prefixcls}-flatten`]: true && !filterRender,
|
|
154
|
-
[`${prefixcls}-disabled`]: disabled,
|
|
155
|
-
[`${prefixcls}-select`]: selected && !multiple
|
|
156
|
-
});
|
|
157
|
-
const onClick = e => {
|
|
158
|
-
this.onClick(e, item);
|
|
159
|
-
};
|
|
160
|
-
const onKeyPress = e => this.handleItemEnterPress(e, item);
|
|
161
|
-
const onCheck = e => this.onCheckboxChange(e, item);
|
|
162
|
-
if (filterRender) {
|
|
163
|
-
const props = {
|
|
164
|
-
className,
|
|
165
|
-
inputValue: keyword,
|
|
166
|
-
disabled,
|
|
167
|
-
data: pathData,
|
|
168
|
-
checkStatus: {
|
|
169
|
-
checked: checkedKeys.has(item.key),
|
|
170
|
-
halfChecked: halfCheckedKeys.has(item.key)
|
|
171
|
-
},
|
|
172
|
-
selected,
|
|
173
|
-
onClick,
|
|
174
|
-
onCheck
|
|
175
|
-
};
|
|
176
|
-
return /*#__PURE__*/React.cloneElement(filterRender(props), {
|
|
177
|
-
key
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
181
|
-
role: 'menuitem',
|
|
182
|
-
className: className,
|
|
183
|
-
key: key,
|
|
184
|
-
onClick: onClick,
|
|
185
|
-
onKeyPress: onKeyPress
|
|
186
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
187
|
-
className: `${prefixcls}-label`
|
|
188
|
-
}, !multiple && this.renderIcon('empty'), multiple && /*#__PURE__*/React.createElement(Checkbox, {
|
|
189
|
-
onChange: onCheck,
|
|
190
|
-
disabled: disabled,
|
|
191
|
-
indeterminate: halfCheckedKeys.has(item.key),
|
|
192
|
-
checked: checkedKeys.has(item.key),
|
|
193
|
-
className: `${prefixcls}-label-checkbox`
|
|
194
|
-
}), this.highlight(searchText)));
|
|
195
|
-
}));
|
|
209
|
+
}, virtualize ? this.renderVirtualizeList(data) : data.map(item => this.renderFlattenOptionItem(item)));
|
|
196
210
|
return content;
|
|
197
211
|
};
|
|
212
|
+
this.renderVirtualizeList = visibleOptions => {
|
|
213
|
+
var _a;
|
|
214
|
+
const {
|
|
215
|
+
direction
|
|
216
|
+
} = this.context;
|
|
217
|
+
const {
|
|
218
|
+
virtualize
|
|
219
|
+
} = this.props;
|
|
220
|
+
return /*#__PURE__*/React.createElement(List, {
|
|
221
|
+
height: virtualize.height,
|
|
222
|
+
itemCount: visibleOptions.length,
|
|
223
|
+
itemSize: virtualize.itemSize,
|
|
224
|
+
itemData: {
|
|
225
|
+
visibleOptions,
|
|
226
|
+
renderOption: this.renderFlattenOptionItem
|
|
227
|
+
},
|
|
228
|
+
width: (_a = virtualize.width) !== null && _a !== void 0 ? _a : '100%',
|
|
229
|
+
style: {
|
|
230
|
+
direction
|
|
231
|
+
}
|
|
232
|
+
}, VirtualRow);
|
|
233
|
+
};
|
|
198
234
|
}
|
|
199
235
|
renderItem(renderData) {
|
|
200
236
|
let content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
@@ -323,7 +359,8 @@ Item.propTypes = {
|
|
|
323
359
|
halfCheckedKeys: PropTypes.object,
|
|
324
360
|
onItemCheckboxClick: PropTypes.func,
|
|
325
361
|
separator: PropTypes.string,
|
|
326
|
-
keyword: PropTypes.string
|
|
362
|
+
keyword: PropTypes.string,
|
|
363
|
+
virtualize: PropTypes.object
|
|
327
364
|
};
|
|
328
365
|
Item.defaultProps = {
|
|
329
366
|
empty: false
|