@hi-ui/check-select 4.1.2 → 4.2.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/CHANGELOG.md +24 -0
- package/lib/cjs/CheckSelect.js +49 -21
- package/lib/cjs/styles/index.scss.js +1 -1
- package/lib/esm/CheckSelect.js +50 -23
- package/lib/esm/styles/index.scss.js +1 -1
- package/lib/types/CheckSelect.d.ts +6 -7
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# @hi-ui/check-select
|
2
2
|
|
3
|
+
## 4.2.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- [#2531](https://github.com/XiaoMi/hiui/pull/2531) [`0a9d90ac5`](https://github.com/XiaoMi/hiui/commit/0a9d90ac53bdf66aa2b83b698b58d2cdeb98d912) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: 增加 tagInputProps API,支持显示内容高度自适应
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- [#2567](https://github.com/XiaoMi/hiui/pull/2567) [`bd5940eba`](https://github.com/XiaoMi/hiui/commit/bd5940eba7d7a80aa676f37bb804ea27544864d2) Thanks [@zyprepare](https://github.com/zyprepare)! - feat: 支持回车选中值
|
12
|
+
|
13
|
+
- Updated dependencies [[`bd5940eba`](https://github.com/XiaoMi/hiui/commit/bd5940eba7d7a80aa676f37bb804ea27544864d2), [`0a9d90ac5`](https://github.com/XiaoMi/hiui/commit/0a9d90ac53bdf66aa2b83b698b58d2cdeb98d912)]:
|
14
|
+
- @hi-ui/picker@4.1.1
|
15
|
+
- @hi-ui/popper@4.0.5
|
16
|
+
- @hi-ui/tag-input@4.0.6
|
17
|
+
|
18
|
+
## 4.1.3
|
19
|
+
|
20
|
+
### Patch Changes
|
21
|
+
|
22
|
+
- [#2482](https://github.com/XiaoMi/hiui/pull/2482) [`3301a290f`](https://github.com/XiaoMi/hiui/commit/3301a290fa9bd8b8717e24ef69ed832aa392b11e) Thanks [@zyprepare](https://github.com/zyprepare)! - fix: 数据改变后显示一次滚动条
|
23
|
+
|
24
|
+
- Updated dependencies [[`6980d058f`](https://github.com/XiaoMi/hiui/commit/6980d058f165b309695d10248d7511bd05bee457)]:
|
25
|
+
- @hi-ui/input@4.0.9
|
26
|
+
|
3
27
|
## 4.1.2
|
4
28
|
|
5
29
|
### Patch Changes
|
package/lib/cjs/CheckSelect.js
CHANGED
@@ -41,6 +41,8 @@ var VirtualList = require('@hi-ui/virtual-list');
|
|
41
41
|
|
42
42
|
var picker = require('@hi-ui/picker');
|
43
43
|
|
44
|
+
var domUtils = require('@hi-ui/dom-utils');
|
45
|
+
|
44
46
|
var arrayUtils = require('@hi-ui/array-utils');
|
45
47
|
|
46
48
|
var highlighter = require('@hi-ui/highlighter');
|
@@ -77,7 +79,7 @@ var _prefix = classname.getPrefixCls(_role);
|
|
77
79
|
|
78
80
|
var DEFAULT_FIELD_NAMES = {};
|
79
81
|
/**
|
80
|
-
*
|
82
|
+
* 多项选择器
|
81
83
|
*/
|
82
84
|
|
83
85
|
var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
@@ -116,7 +118,9 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
116
118
|
_a$fieldNames = _a.fieldNames,
|
117
119
|
fieldNames = _a$fieldNames === void 0 ? DEFAULT_FIELD_NAMES : _a$fieldNames,
|
118
120
|
customRender = _a.customRender,
|
119
|
-
|
121
|
+
tagInputProps = _a.tagInputProps,
|
122
|
+
onKeyDownProp = _a.onKeyDown,
|
123
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "children", "disabled", "clearable", "showCheckAll", "showOnlyShowChecked", "placeholder", "displayRender", "onSelect", "height", "itemHeight", "virtual", "visible", "onOpen", "onClose", "appearance", "invalid", "dataSource", "filterOption", "searchable", "render", "renderExtraFooter", "onSearch", "fieldNames", "customRender", "tagInputProps", "onKeyDown"]);
|
120
124
|
|
121
125
|
var i18n = core.useLocaleContext();
|
122
126
|
var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('checkSelect.placeholder') : placeholderProp; // ************************** Picker ************************* //
|
@@ -149,7 +153,9 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
149
153
|
var value = context$1.value,
|
150
154
|
tryChangeValue = context$1.tryChangeValue,
|
151
155
|
flattedData = context$1.flattedData,
|
152
|
-
checkedItems = context$1.checkedItems
|
156
|
+
checkedItems = context$1.checkedItems,
|
157
|
+
onSelect = context$1.onSelect,
|
158
|
+
isCheckedId = context$1.isCheckedId; // ************************** 搜索 ************************* //
|
153
159
|
|
154
160
|
var _c = useSearchMode.useAsyncSearch({
|
155
161
|
dataSource: dataSource,
|
@@ -268,7 +274,31 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
268
274
|
|
269
275
|
tryChangeValue(_nextCheckedIds, _changedItems, shouldChecked);
|
270
276
|
}
|
271
|
-
}, [dropdownItems, mergedData, valueLatestRef, tryChangeValue]);
|
277
|
+
}, [dropdownItems, mergedData, valueLatestRef, tryChangeValue]); // ************************** 回车选中处理 ************************* //
|
278
|
+
|
279
|
+
var defaultIndex = showData.findIndex(function (item) {
|
280
|
+
return !item.disabled;
|
281
|
+
});
|
282
|
+
|
283
|
+
var _useState2 = React.useState(defaultIndex),
|
284
|
+
focusedIndex = _useState2[0],
|
285
|
+
setFocusedIndex = _useState2[1];
|
286
|
+
|
287
|
+
var handleKeyDown = useLatest.useLatestCallback(function (evt) {
|
288
|
+
var key = evt.key;
|
289
|
+
|
290
|
+
if (key === 'Enter') {
|
291
|
+
var focusedItem = showData[focusedIndex];
|
292
|
+
|
293
|
+
if (focusedItem) {
|
294
|
+
onSelect(focusedItem, !isCheckedId(focusedItem.id));
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}); // 更新 focused 索引
|
298
|
+
|
299
|
+
React.useEffect(function () {
|
300
|
+
setFocusedIndex(defaultIndex);
|
301
|
+
}, [defaultIndex, menuVisible]);
|
272
302
|
|
273
303
|
var renderDefaultFooter = function renderDefaultFooter() {
|
274
304
|
var extra = renderExtraFooter ? renderExtraFooter() : null;
|
@@ -298,13 +328,13 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
298
328
|
var cls = classname.cx(prefixCls, className, prefixCls + "--" + (menuVisible ? 'open' : 'closed'));
|
299
329
|
var listRef = React.useRef(null);
|
300
330
|
React.useEffect(function () {
|
301
|
-
var _a; //
|
331
|
+
var _a; // 每次打开或数据改变时触发一次滚动条显示
|
302
332
|
|
303
333
|
|
304
|
-
if (menuVisible) {
|
334
|
+
if (menuVisible && typeAssertion.isArrayNonEmpty(showData)) {
|
305
335
|
(_a = listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(undefined);
|
306
336
|
}
|
307
|
-
}, [menuVisible]);
|
337
|
+
}, [menuVisible, showData]);
|
308
338
|
return /*#__PURE__*/React__default["default"].createElement(context.CheckSelectProvider, {
|
309
339
|
value: context$1
|
310
340
|
}, /*#__PURE__*/React__default["default"].createElement(picker.Picker, Object.assign({
|
@@ -315,12 +345,13 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
315
345
|
disabled: disabled,
|
316
346
|
onOpen: menuVisibleAction.on,
|
317
347
|
onClose: menuVisibleAction.off,
|
348
|
+
onKeyDown: domUtils.mockDefaultHandlers(handleKeyDown, onKeyDownProp),
|
318
349
|
searchable: searchable,
|
319
350
|
scrollable: !inVirtual,
|
320
351
|
onSearch: funcUtils.callAllFuncs(onSearchProp, onSearch),
|
321
352
|
loading: rest.loading !== undefined ? rest.loading : loading,
|
322
353
|
footer: renderDefaultFooter(),
|
323
|
-
trigger: customRender ? typeof customRender === 'function' ? customRender(checkedItems) : customRender : /*#__PURE__*/React__default["default"].createElement(tagInput.TagInputMock, {
|
354
|
+
trigger: customRender ? typeof customRender === 'function' ? customRender(checkedItems) : customRender : /*#__PURE__*/React__default["default"].createElement(tagInput.TagInputMock, Object.assign({}, tagInputProps, {
|
324
355
|
clearable: clearable,
|
325
356
|
placeholder: placeholder,
|
326
357
|
// @ts-ignore
|
@@ -377,19 +408,23 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
377
408
|
|
378
409
|
expandedViewRef.current = 'onlyChecked';
|
379
410
|
}
|
380
|
-
})
|
411
|
+
}))
|
381
412
|
}), typeAssertion.isArrayNonEmpty(dropdownItems) ? /*#__PURE__*/React__default["default"].createElement(VirtualList__default["default"], Object.assign({
|
382
413
|
ref: listRef,
|
383
414
|
itemKey: "id",
|
384
415
|
fullHeight: false
|
385
|
-
}, virtualListProps), function (node) {
|
416
|
+
}, virtualListProps), function (node, index) {
|
386
417
|
/* 反向 map,搜索删选数据时会对数据进行处理 */
|
387
418
|
return 'groupTitle' in node ? /*#__PURE__*/React__default["default"].createElement(CheckSelectOptionGroup, {
|
388
419
|
label: node.groupTitle
|
389
420
|
}) : /*#__PURE__*/React__default["default"].createElement(CheckSelectOption, {
|
390
421
|
option: node,
|
391
422
|
depth: node.depth,
|
392
|
-
titleRender: proxyTitleRender
|
423
|
+
titleRender: proxyTitleRender,
|
424
|
+
onMouseEnter: function onMouseEnter() {
|
425
|
+
!node.disabled && setFocusedIndex(index);
|
426
|
+
},
|
427
|
+
focused: focusedIndex === index
|
393
428
|
});
|
394
429
|
}) : null));
|
395
430
|
}); // @ts-ignore
|
@@ -401,10 +436,6 @@ if (env.__DEV__) {
|
|
401
436
|
}
|
402
437
|
|
403
438
|
var optionPrefix = classname.getPrefixCls('check-select-option');
|
404
|
-
/**
|
405
|
-
* TODO: What is CheckSelectOption
|
406
|
-
*/
|
407
|
-
|
408
439
|
var CheckSelectOption = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
409
440
|
var _a$prefixCls2 = _a.prefixCls,
|
410
441
|
prefixCls = _a$prefixCls2 === void 0 ? optionPrefix : _a$prefixCls2,
|
@@ -414,7 +445,8 @@ var CheckSelectOption = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
414
445
|
onClick = _a.onClick,
|
415
446
|
titleRender = _a.titleRender,
|
416
447
|
depth = _a.depth,
|
417
|
-
|
448
|
+
focused = _a.focused,
|
449
|
+
rest = tslib.__rest(_a, ["prefixCls", "className", "children", "option", "onClick", "titleRender", "depth", "focused"]);
|
418
450
|
|
419
451
|
var _useCheckSelectContex = context.useCheckSelectContext(),
|
420
452
|
isCheckedId = _useCheckSelectContex.isCheckedId,
|
@@ -428,7 +460,7 @@ var CheckSelectOption = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
428
460
|
disabled: disabled,
|
429
461
|
checked: checked
|
430
462
|
}));
|
431
|
-
var cls = classname.cx(prefixCls, className, checked && prefixCls + "--checked", disabled && prefixCls + "--disabled");
|
463
|
+
var cls = classname.cx(prefixCls, className, checked && prefixCls + "--checked", disabled && prefixCls + "--disabled", focused && prefixCls + "--focused");
|
432
464
|
var handleOptionCheck = React.useCallback(function (evt) {
|
433
465
|
onSelect(option, !checked);
|
434
466
|
onClick === null || onClick === void 0 ? void 0 : onClick(evt);
|
@@ -458,10 +490,6 @@ if (env.__DEV__) {
|
|
458
490
|
}
|
459
491
|
|
460
492
|
var optionGroupPrefix = classname.getPrefixCls('select-option-group');
|
461
|
-
/**
|
462
|
-
* TODO: What is CheckSelectOptionGroup
|
463
|
-
*/
|
464
|
-
|
465
493
|
var CheckSelectOptionGroup = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
466
494
|
var _a$prefixCls3 = _a.prefixCls,
|
467
495
|
prefixCls = _a$prefixCls3 === void 0 ? optionGroupPrefix : _a$prefixCls3,
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, '__esModule', {
|
|
14
14
|
});
|
15
15
|
var css_248z = ".hi-v4-check-select-option {margin-top: var(--hi-v4-spacing-2, 4px);margin-bottom: var(--hi-v4-spacing-2, 4px);-webkit-box-sizing: border-box;box-sizing: border-box;width: 100%;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;position: relative;border-radius: var(--hi-v4-border-radius-md, 4px);cursor: pointer;font-size: var(--hi-v4-text-size-md, 0.875rem);font-weight: var(--hi-v4-text-weight-normal, 400);color: var(--hi-v4-color-gray-700, #1f2733);line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }.hi-v4-check-select-option__indent {display: inline-block;width: 16px;height: 100%; }.hi-v4-check-select-option__title {display: inline-block;-webkit-box-sizing: border-box;box-sizing: border-box;width: 100%;padding: var(--hi-v4-spacing-3, 6px);font-size: inherit;font-weight: inherit;color: inherit;line-height: inherit; }.hi-v4-check-select-option:hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-check-select-option--focused {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-check-select-option--disabled {cursor: not-allowed;color: var(--hi-v4-color-gray-500, #929aa6); }.hi-v4-check-select-option-group {display: inline-block;margin-top: var(--hi-v4-spacing-6, 12px);margin-bottom: var(--hi-v4-spacing-2, 4px);padding: var(--hi-v4-spacing-3, 6px) 0 var(--hi-v4-spacing-3, 6px) var(--hi-v4-spacing-3, 6px);font-size: var(--hi-v4-text-size-md, 0.875rem);font-weight: var(--hi-v4-text-weight-normal, 400);color: var(--hi-v4-color-gray-500, #929aa6);line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }.hi-v4-check-select-option-group:first-child {margin-top: var(--hi-v4-spacing-2, 4px); }";
|
16
16
|
|
17
|
-
var __styleInject__ = require('inject
|
17
|
+
var __styleInject__ = require('style-inject')["default"];
|
18
18
|
|
19
19
|
__styleInject__(css_248z);
|
20
20
|
|
package/lib/esm/CheckSelect.js
CHANGED
@@ -8,18 +8,19 @@
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
import { __rest } from 'tslib';
|
11
|
-
import React, { forwardRef, useCallback, useMemo, useState,
|
11
|
+
import React, { forwardRef, useCallback, useMemo, useState, useEffect, useRef } from 'react';
|
12
12
|
import { getPrefixCls, cx } from '@hi-ui/classname';
|
13
13
|
import { __DEV__ } from '@hi-ui/env';
|
14
14
|
import { useCheckSelect } from './use-check-select.js';
|
15
15
|
import { UpOutlined, DownOutlined } from '@hi-ui/icons';
|
16
16
|
import { CheckSelectProvider, useCheckSelectContext } from './context.js';
|
17
|
-
import { useLatestRef } from '@hi-ui/use-latest';
|
17
|
+
import { useLatestRef, useLatestCallback } from '@hi-ui/use-latest';
|
18
18
|
import Checkbox from '@hi-ui/checkbox';
|
19
19
|
import { TagInputMock } from '@hi-ui/tag-input';
|
20
20
|
import { isUndef, isFunction, isArrayNonEmpty } from '@hi-ui/type-assertion';
|
21
21
|
import VirtualList, { useCheckInVirtual } from '@hi-ui/virtual-list';
|
22
22
|
import { Picker } from '@hi-ui/picker';
|
23
|
+
import { mockDefaultHandlers } from '@hi-ui/dom-utils';
|
23
24
|
import { uniqBy, times } from '@hi-ui/array-utils';
|
24
25
|
import { Highlighter } from '@hi-ui/highlighter';
|
25
26
|
import { useUncontrolledToggle } from '@hi-ui/use-toggle';
|
@@ -35,7 +36,7 @@ var _prefix = getPrefixCls(_role);
|
|
35
36
|
|
36
37
|
var DEFAULT_FIELD_NAMES = {};
|
37
38
|
/**
|
38
|
-
*
|
39
|
+
* 多项选择器
|
39
40
|
*/
|
40
41
|
|
41
42
|
var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
@@ -74,7 +75,9 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
74
75
|
_a$fieldNames = _a.fieldNames,
|
75
76
|
fieldNames = _a$fieldNames === void 0 ? DEFAULT_FIELD_NAMES : _a$fieldNames,
|
76
77
|
customRender = _a.customRender,
|
77
|
-
|
78
|
+
tagInputProps = _a.tagInputProps,
|
79
|
+
onKeyDownProp = _a.onKeyDown,
|
80
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "children", "disabled", "clearable", "showCheckAll", "showOnlyShowChecked", "placeholder", "displayRender", "onSelect", "height", "itemHeight", "virtual", "visible", "onOpen", "onClose", "appearance", "invalid", "dataSource", "filterOption", "searchable", "render", "renderExtraFooter", "onSearch", "fieldNames", "customRender", "tagInputProps", "onKeyDown"]);
|
78
81
|
|
79
82
|
var i18n = useLocaleContext();
|
80
83
|
var placeholder = isUndef(placeholderProp) ? i18n.get('checkSelect.placeholder') : placeholderProp; // ************************** Picker ************************* //
|
@@ -107,7 +110,9 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
107
110
|
var value = context.value,
|
108
111
|
tryChangeValue = context.tryChangeValue,
|
109
112
|
flattedData = context.flattedData,
|
110
|
-
checkedItems = context.checkedItems
|
113
|
+
checkedItems = context.checkedItems,
|
114
|
+
onSelect = context.onSelect,
|
115
|
+
isCheckedId = context.isCheckedId; // ************************** 搜索 ************************* //
|
111
116
|
|
112
117
|
var _c = useAsyncSearch({
|
113
118
|
dataSource: dataSource,
|
@@ -226,7 +231,31 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
226
231
|
|
227
232
|
tryChangeValue(_nextCheckedIds, _changedItems, shouldChecked);
|
228
233
|
}
|
229
|
-
}, [dropdownItems, mergedData, valueLatestRef, tryChangeValue]);
|
234
|
+
}, [dropdownItems, mergedData, valueLatestRef, tryChangeValue]); // ************************** 回车选中处理 ************************* //
|
235
|
+
|
236
|
+
var defaultIndex = showData.findIndex(function (item) {
|
237
|
+
return !item.disabled;
|
238
|
+
});
|
239
|
+
|
240
|
+
var _useState2 = useState(defaultIndex),
|
241
|
+
focusedIndex = _useState2[0],
|
242
|
+
setFocusedIndex = _useState2[1];
|
243
|
+
|
244
|
+
var handleKeyDown = useLatestCallback(function (evt) {
|
245
|
+
var key = evt.key;
|
246
|
+
|
247
|
+
if (key === 'Enter') {
|
248
|
+
var focusedItem = showData[focusedIndex];
|
249
|
+
|
250
|
+
if (focusedItem) {
|
251
|
+
onSelect(focusedItem, !isCheckedId(focusedItem.id));
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}); // 更新 focused 索引
|
255
|
+
|
256
|
+
useEffect(function () {
|
257
|
+
setFocusedIndex(defaultIndex);
|
258
|
+
}, [defaultIndex, menuVisible]);
|
230
259
|
|
231
260
|
var renderDefaultFooter = function renderDefaultFooter() {
|
232
261
|
var extra = renderExtraFooter ? renderExtraFooter() : null;
|
@@ -256,13 +285,13 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
256
285
|
var cls = cx(prefixCls, className, prefixCls + "--" + (menuVisible ? 'open' : 'closed'));
|
257
286
|
var listRef = useRef(null);
|
258
287
|
useEffect(function () {
|
259
|
-
var _a; //
|
288
|
+
var _a; // 每次打开或数据改变时触发一次滚动条显示
|
260
289
|
|
261
290
|
|
262
|
-
if (menuVisible) {
|
291
|
+
if (menuVisible && isArrayNonEmpty(showData)) {
|
263
292
|
(_a = listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(undefined);
|
264
293
|
}
|
265
|
-
}, [menuVisible]);
|
294
|
+
}, [menuVisible, showData]);
|
266
295
|
return /*#__PURE__*/React.createElement(CheckSelectProvider, {
|
267
296
|
value: context
|
268
297
|
}, /*#__PURE__*/React.createElement(Picker, Object.assign({
|
@@ -273,12 +302,13 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
273
302
|
disabled: disabled,
|
274
303
|
onOpen: menuVisibleAction.on,
|
275
304
|
onClose: menuVisibleAction.off,
|
305
|
+
onKeyDown: mockDefaultHandlers(handleKeyDown, onKeyDownProp),
|
276
306
|
searchable: searchable,
|
277
307
|
scrollable: !inVirtual,
|
278
308
|
onSearch: callAllFuncs(onSearchProp, onSearch),
|
279
309
|
loading: rest.loading !== undefined ? rest.loading : loading,
|
280
310
|
footer: renderDefaultFooter(),
|
281
|
-
trigger: customRender ? typeof customRender === 'function' ? customRender(checkedItems) : customRender : /*#__PURE__*/React.createElement(TagInputMock, {
|
311
|
+
trigger: customRender ? typeof customRender === 'function' ? customRender(checkedItems) : customRender : /*#__PURE__*/React.createElement(TagInputMock, Object.assign({}, tagInputProps, {
|
282
312
|
clearable: clearable,
|
283
313
|
placeholder: placeholder,
|
284
314
|
// @ts-ignore
|
@@ -335,19 +365,23 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
335
365
|
|
336
366
|
expandedViewRef.current = 'onlyChecked';
|
337
367
|
}
|
338
|
-
})
|
368
|
+
}))
|
339
369
|
}), isArrayNonEmpty(dropdownItems) ? /*#__PURE__*/React.createElement(VirtualList, Object.assign({
|
340
370
|
ref: listRef,
|
341
371
|
itemKey: "id",
|
342
372
|
fullHeight: false
|
343
|
-
}, virtualListProps), function (node) {
|
373
|
+
}, virtualListProps), function (node, index) {
|
344
374
|
/* 反向 map,搜索删选数据时会对数据进行处理 */
|
345
375
|
return 'groupTitle' in node ? /*#__PURE__*/React.createElement(CheckSelectOptionGroup, {
|
346
376
|
label: node.groupTitle
|
347
377
|
}) : /*#__PURE__*/React.createElement(CheckSelectOption, {
|
348
378
|
option: node,
|
349
379
|
depth: node.depth,
|
350
|
-
titleRender: proxyTitleRender
|
380
|
+
titleRender: proxyTitleRender,
|
381
|
+
onMouseEnter: function onMouseEnter() {
|
382
|
+
!node.disabled && setFocusedIndex(index);
|
383
|
+
},
|
384
|
+
focused: focusedIndex === index
|
351
385
|
});
|
352
386
|
}) : null));
|
353
387
|
}); // @ts-ignore
|
@@ -359,10 +393,6 @@ if (__DEV__) {
|
|
359
393
|
}
|
360
394
|
|
361
395
|
var optionPrefix = getPrefixCls('check-select-option');
|
362
|
-
/**
|
363
|
-
* TODO: What is CheckSelectOption
|
364
|
-
*/
|
365
|
-
|
366
396
|
var CheckSelectOption = /*#__PURE__*/forwardRef(function (_a, ref) {
|
367
397
|
var _a$prefixCls2 = _a.prefixCls,
|
368
398
|
prefixCls = _a$prefixCls2 === void 0 ? optionPrefix : _a$prefixCls2,
|
@@ -372,7 +402,8 @@ var CheckSelectOption = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
372
402
|
onClick = _a.onClick,
|
373
403
|
titleRender = _a.titleRender,
|
374
404
|
depth = _a.depth,
|
375
|
-
|
405
|
+
focused = _a.focused,
|
406
|
+
rest = __rest(_a, ["prefixCls", "className", "children", "option", "onClick", "titleRender", "depth", "focused"]);
|
376
407
|
|
377
408
|
var _useCheckSelectContex = useCheckSelectContext(),
|
378
409
|
isCheckedId = _useCheckSelectContex.isCheckedId,
|
@@ -386,7 +417,7 @@ var CheckSelectOption = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
386
417
|
disabled: disabled,
|
387
418
|
checked: checked
|
388
419
|
}));
|
389
|
-
var cls = cx(prefixCls, className, checked && prefixCls + "--checked", disabled && prefixCls + "--disabled");
|
420
|
+
var cls = cx(prefixCls, className, checked && prefixCls + "--checked", disabled && prefixCls + "--disabled", focused && prefixCls + "--focused");
|
390
421
|
var handleOptionCheck = useCallback(function (evt) {
|
391
422
|
onSelect(option, !checked);
|
392
423
|
onClick === null || onClick === void 0 ? void 0 : onClick(evt);
|
@@ -416,10 +447,6 @@ if (__DEV__) {
|
|
416
447
|
}
|
417
448
|
|
418
449
|
var optionGroupPrefix = getPrefixCls('select-option-group');
|
419
|
-
/**
|
420
|
-
* TODO: What is CheckSelectOptionGroup
|
421
|
-
*/
|
422
|
-
|
423
450
|
var CheckSelectOptionGroup = /*#__PURE__*/forwardRef(function (_a, ref) {
|
424
451
|
var _a$prefixCls3 = _a.prefixCls,
|
425
452
|
prefixCls = _a$prefixCls3 === void 0 ? optionGroupPrefix : _a$prefixCls3,
|
@@ -7,7 +7,7 @@
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
import __styleInject__ from 'inject
|
10
|
+
import __styleInject__ from 'style-inject';
|
11
11
|
var css_248z = ".hi-v4-check-select-option {margin-top: var(--hi-v4-spacing-2, 4px);margin-bottom: var(--hi-v4-spacing-2, 4px);-webkit-box-sizing: border-box;box-sizing: border-box;width: 100%;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;position: relative;border-radius: var(--hi-v4-border-radius-md, 4px);cursor: pointer;font-size: var(--hi-v4-text-size-md, 0.875rem);font-weight: var(--hi-v4-text-weight-normal, 400);color: var(--hi-v4-color-gray-700, #1f2733);line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }.hi-v4-check-select-option__indent {display: inline-block;width: 16px;height: 100%; }.hi-v4-check-select-option__title {display: inline-block;-webkit-box-sizing: border-box;box-sizing: border-box;width: 100%;padding: var(--hi-v4-spacing-3, 6px);font-size: inherit;font-weight: inherit;color: inherit;line-height: inherit; }.hi-v4-check-select-option:hover {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-check-select-option--focused {background-color: var(--hi-v4-color-gray-100, #f2f4f7); }.hi-v4-check-select-option--disabled {cursor: not-allowed;color: var(--hi-v4-color-gray-500, #929aa6); }.hi-v4-check-select-option-group {display: inline-block;margin-top: var(--hi-v4-spacing-6, 12px);margin-bottom: var(--hi-v4-spacing-2, 4px);padding: var(--hi-v4-spacing-3, 6px) 0 var(--hi-v4-spacing-3, 6px) var(--hi-v4-spacing-3, 6px);font-size: var(--hi-v4-text-size-md, 0.875rem);font-weight: var(--hi-v4-text-weight-normal, 400);color: var(--hi-v4-color-gray-500, #929aa6);line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }.hi-v4-check-select-option-group:first-child {margin-top: var(--hi-v4-spacing-2, 4px); }";
|
12
12
|
|
13
13
|
__styleInject__(css_248z);
|
@@ -2,10 +2,11 @@ import React from 'react';
|
|
2
2
|
import { UseCheckSelectProps } from './use-check-select';
|
3
3
|
import type { HiBaseHTMLProps } from '@hi-ui/core';
|
4
4
|
import { CheckSelectAppearanceEnum, CheckSelectDataItem, CheckSelectItemEventData, CheckSelectMergedItem } from './types';
|
5
|
+
import { TagInputMockProps } from '@hi-ui/tag-input';
|
5
6
|
import { PickerProps } from '@hi-ui/picker';
|
6
7
|
import { UseDataSource } from '@hi-ui/use-data-source';
|
7
8
|
/**
|
8
|
-
*
|
9
|
+
* 多项选择器
|
9
10
|
*/
|
10
11
|
export declare const CheckSelect: React.ForwardRefExoticComponent<CheckSelectProps & React.RefAttributes<HTMLDivElement | null>>;
|
11
12
|
export interface CheckSelectProps extends Omit<PickerProps, 'trigger' | 'scrollable'>, UseCheckSelectProps {
|
@@ -101,16 +102,14 @@ export interface CheckSelectProps extends Omit<PickerProps, 'trigger' | 'scrolla
|
|
101
102
|
* 自定义渲染选中的内容
|
102
103
|
*/
|
103
104
|
customRender?: React.ReactNode | ((option: CheckSelectItemEventData[]) => React.ReactNode);
|
105
|
+
/**
|
106
|
+
* TagInput 参数设置
|
107
|
+
*/
|
108
|
+
tagInputProps?: TagInputMockProps;
|
104
109
|
}
|
105
|
-
/**
|
106
|
-
* TODO: What is CheckSelectOption
|
107
|
-
*/
|
108
110
|
export declare const CheckSelectOption: React.ForwardRefExoticComponent<Pick<CheckSelectOptionProps, string | number> & React.RefAttributes<HTMLDivElement | null>>;
|
109
111
|
export interface CheckSelectOptionProps extends HiBaseHTMLProps {
|
110
112
|
}
|
111
|
-
/**
|
112
|
-
* TODO: What is CheckSelectOptionGroup
|
113
|
-
*/
|
114
113
|
export declare const CheckSelectOptionGroup: React.ForwardRefExoticComponent<Pick<CheckSelectOptionGroupProps, string | number> & React.RefAttributes<HTMLDivElement | null>>;
|
115
114
|
export interface CheckSelectOptionGroupProps extends HiBaseHTMLProps {
|
116
115
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/check-select",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.2.0",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
@@ -46,14 +46,15 @@
|
|
46
46
|
"@hi-ui/array-utils": "^4.0.1",
|
47
47
|
"@hi-ui/checkbox": "^4.0.5",
|
48
48
|
"@hi-ui/classname": "^4.0.1",
|
49
|
+
"@hi-ui/dom-utils": "^4.0.4",
|
49
50
|
"@hi-ui/env": "^4.0.1",
|
50
51
|
"@hi-ui/func-utils": "^4.0.1",
|
51
52
|
"@hi-ui/highlighter": "^4.0.5",
|
52
53
|
"@hi-ui/icons": "^4.0.6",
|
53
|
-
"@hi-ui/input": "^4.0.
|
54
|
-
"@hi-ui/picker": "^4.
|
55
|
-
"@hi-ui/popper": "^4.0.
|
56
|
-
"@hi-ui/tag-input": "^4.0.
|
54
|
+
"@hi-ui/input": "^4.0.9",
|
55
|
+
"@hi-ui/picker": "^4.1.1",
|
56
|
+
"@hi-ui/popper": "^4.0.5",
|
57
|
+
"@hi-ui/tag-input": "^4.0.6",
|
57
58
|
"@hi-ui/times": "^4.0.1",
|
58
59
|
"@hi-ui/tree-utils": "^4.0.2",
|
59
60
|
"@hi-ui/type-assertion": "^4.0.1",
|
@@ -74,7 +75,6 @@
|
|
74
75
|
"devDependencies": {
|
75
76
|
"@hi-ui/core": "^4.0.4",
|
76
77
|
"@hi-ui/core-css": "^4.0.1",
|
77
|
-
"@hi-ui/hi-build": "^4.0.1",
|
78
78
|
"react": "^17.0.1",
|
79
79
|
"react-dom": "^17.0.1"
|
80
80
|
}
|