@laser-ui/components 0.6.3 → 0.6.5
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 +16 -0
- package/cascader/Cascader.js +5 -2
- package/package.json +2 -2
- package/select/Select.js +1 -2
- package/transfer/Transfer.js +45 -27
- package/transfer/internal/TransferPanel.d.ts +1 -1
- package/transfer/internal/TransferPanel.js +10 -13
- package/transfer/types.d.ts +1 -1
- package/transfer/vars.d.ts +1 -0
- package/transfer/vars.js +1 -0
- package/tree-select/TreeSelect.js +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.6.5](https://github.com/laser-ui/laser-ui/compare/v0.6.4...v0.6.5) (2024-06-11)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **components:** fix close tree-select ([6b0fca1](https://github.com/laser-ui/laser-ui/commit/6b0fca121cd15b5f218c0d363309e085d26291b1))
|
|
10
|
+
|
|
11
|
+
## [0.6.4](https://github.com/laser-ui/laser-ui/compare/v0.6.3...v0.6.4) (2024-05-27)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- **components:** use custom title if provide customSelected ([0dbdb2f](https://github.com/laser-ui/laser-ui/commit/0dbdb2f285900c45cccdd5fed47eb3429f238d73))
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- **components:** transfer custom item even if no option ([9706ec5](https://github.com/laser-ui/laser-ui/commit/9706ec5e4aea60329b1cf9718b05a214acae3958))
|
|
20
|
+
|
|
5
21
|
## [0.6.3](https://github.com/laser-ui/laser-ui/compare/v0.6.2...v0.6.3) (2024-05-24)
|
|
6
22
|
|
|
7
23
|
### Features
|
package/cascader/Cascader.js
CHANGED
|
@@ -383,8 +383,11 @@ function CascaderFC(props, ref) {
|
|
|
383
383
|
else {
|
|
384
384
|
if (!isNull(selected)) {
|
|
385
385
|
const node = nodesMap.get(selected);
|
|
386
|
-
|
|
387
|
-
|
|
386
|
+
selectedNode = selectedLabel = customSelected
|
|
387
|
+
? customSelected(selected, node === null || node === void 0 ? void 0 : node.origin)
|
|
388
|
+
: node
|
|
389
|
+
? getTreeNodeLabel(node)
|
|
390
|
+
: String(selected);
|
|
388
391
|
}
|
|
389
392
|
}
|
|
390
393
|
return [selectedNode, suffixNode, selectedLabel];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laser-ui/components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "React components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"access": "public",
|
|
41
41
|
"directory": "../../dist/libs/components"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "4a94e6ec5bcfa6f04633956dd74c71203bb2e00f"
|
|
44
44
|
}
|
package/select/Select.js
CHANGED
|
@@ -394,8 +394,7 @@ function SelectFC(props, ref) {
|
|
|
394
394
|
else {
|
|
395
395
|
if (!isNull(selected)) {
|
|
396
396
|
const item = itemsMap.get(selected);
|
|
397
|
-
selectedLabel = item ? item.label : String(selected);
|
|
398
|
-
selectedNode = customSelected ? customSelected(selected, item) : selectedLabel;
|
|
397
|
+
selectedNode = selectedLabel = customSelected ? customSelected(selected, item) : item ? item.label : String(selected);
|
|
399
398
|
}
|
|
400
399
|
}
|
|
401
400
|
return [selectedNode, suffixNode, selectedLabel];
|
package/transfer/Transfer.js
CHANGED
|
@@ -5,7 +5,7 @@ import KeyboardArrowRightOutlined from '@material-design-icons/svg/outlined/keyb
|
|
|
5
5
|
import { isUndefined } from 'lodash';
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
7
|
import { TransferPanel } from './internal/TransferPanel';
|
|
8
|
-
import { CLASSES, IS_SELECTED } from './vars';
|
|
8
|
+
import { CLASSES, IS_SELECTED, NO_MATCH } from './vars';
|
|
9
9
|
import { Button } from '../button';
|
|
10
10
|
import { useComponentProps, useControlled, useDesign, useNamespace, useScopedProps, useStyled } from '../hooks';
|
|
11
11
|
import { Icon } from '../icon';
|
|
@@ -41,29 +41,41 @@ export function Transfer(props) {
|
|
|
41
41
|
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
42
42
|
(item, searchValue) => customSearch.filter(searchValue, item);
|
|
43
43
|
const sortFn = customSearch === null || customSearch === void 0 ? void 0 : customSearch.sort;
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
selectedCount[index] += 1;
|
|
52
|
-
if (!item.disabled) {
|
|
53
|
-
hasSelected[index] = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
if (!item.disabled) {
|
|
58
|
-
allSelected[index] = false;
|
|
59
|
-
}
|
|
44
|
+
const handleItem = (item, index, noMatch) => {
|
|
45
|
+
const newItem = Object.assign({ [IS_SELECTED]: false, [NO_MATCH]: noMatch }, item);
|
|
46
|
+
if (selected.has(item.value)) {
|
|
47
|
+
newItem[IS_SELECTED] = true;
|
|
48
|
+
selectedCount[index] += 1;
|
|
49
|
+
if (!item.disabled) {
|
|
50
|
+
hasSelected[index] = true;
|
|
60
51
|
}
|
|
61
|
-
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
62
54
|
if (!item.disabled) {
|
|
63
|
-
|
|
55
|
+
allSelected[index] = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
list[index].push(newItem);
|
|
59
|
+
if (!item.disabled) {
|
|
60
|
+
empty[index] = false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
listProp.forEach((item) => {
|
|
64
|
+
if (!valueRight.has(item.value)) {
|
|
65
|
+
if (!searchValue[0] || filterFn(item, searchValue[0])) {
|
|
66
|
+
handleItem(item, 0, false);
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
});
|
|
70
|
+
_valueRight.forEach((value) => {
|
|
71
|
+
const item = itemsMap.get(value);
|
|
72
|
+
if (!searchValue[1]) {
|
|
73
|
+
handleItem(item !== null && item !== void 0 ? item : { label: value, value }, 1, !item);
|
|
74
|
+
}
|
|
75
|
+
else if (item && filterFn(item, searchValue[0])) {
|
|
76
|
+
handleItem(item, 1, false);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
67
79
|
if (searchValue[0] && sortFn) {
|
|
68
80
|
list[0].sort(sortFn);
|
|
69
81
|
}
|
|
@@ -103,18 +115,24 @@ export function Transfer(props) {
|
|
|
103
115
|
};
|
|
104
116
|
const handleButtonClick = (isLeft) => {
|
|
105
117
|
changeValueRight((draft) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (
|
|
118
|
+
if (isLeft) {
|
|
119
|
+
const newValueRight = new Set();
|
|
120
|
+
list[0].forEach((item) => {
|
|
121
|
+
if (item[IS_SELECTED]) {
|
|
110
122
|
newValueRight.add(item.value);
|
|
111
123
|
}
|
|
112
|
-
|
|
124
|
+
});
|
|
125
|
+
return Array.from(newValueRight).concat(draft);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const newValueRight = new Set(draft);
|
|
129
|
+
list[1].forEach((item) => {
|
|
130
|
+
if (item[IS_SELECTED]) {
|
|
113
131
|
newValueRight.delete(item.value);
|
|
114
132
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
});
|
|
134
|
+
return Array.from(newValueRight);
|
|
135
|
+
}
|
|
118
136
|
});
|
|
119
137
|
changeSelected((draft) => {
|
|
120
138
|
const newSelected = new Set(draft);
|
|
@@ -12,7 +12,7 @@ export interface TransferPanelProps<V extends React.Key, T extends TransferItem<
|
|
|
12
12
|
loading: boolean;
|
|
13
13
|
searchable: boolean;
|
|
14
14
|
virtual: boolean | number;
|
|
15
|
-
customItem
|
|
15
|
+
customItem?: (value: V, item?: T) => React.ReactNode;
|
|
16
16
|
onSelectedChange: (value: V) => void;
|
|
17
17
|
onAllSelectedChange: (selected: boolean) => void;
|
|
18
18
|
onSearch: (value: string) => void;
|
|
@@ -11,7 +11,7 @@ import { Icon } from '../../icon';
|
|
|
11
11
|
import { Input } from '../../input';
|
|
12
12
|
import { CircularProgress } from '../../internal/circular-progress';
|
|
13
13
|
import { VirtualScroll } from '../../virtual-scroll';
|
|
14
|
-
import { IS_SELECTED } from '../vars';
|
|
14
|
+
import { IS_SELECTED, NO_MATCH } from '../vars';
|
|
15
15
|
export function TransferPanel(props) {
|
|
16
16
|
const { namespace, styled, list, selectedCount, state, title, loading, searchable, virtual, customItem, onSelectedChange, onAllSelectedChange, onSearch, onScrollBottom, } = props;
|
|
17
17
|
const { t } = useTranslation();
|
|
@@ -27,16 +27,13 @@ export function TransferPanel(props) {
|
|
|
27
27
|
}), [canSelectedItem, list, virtual]);
|
|
28
28
|
return (_jsxs("div", Object.assign({}, styled('transfer__panel'), { children: [_jsxs("div", Object.assign({}, styled('transfer__header'), { children: [_jsxs(Checkbox, { model: state === true, indeterminate: state === 'mixed', disabled: list.length === 0, onModelChange: (checked) => {
|
|
29
29
|
onAllSelectedChange(checked);
|
|
30
|
-
}, children: [selectedCount, "/", list.length] }), checkNodeExist(title) && _jsx("div", Object.assign({}, styled('transfer__header-title'), { children: title }))] })), searchable && (_jsx("div", Object.assign({}, styled('transfer__search'), { children: _jsx(Input, { style: { display: 'flex' }, placeholder: t('Search'), prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), clearable: true, onModelChange: onSearch }) }))), _jsxs("div", Object.assign({}, styled('transfer__list-container'), { children: [loading && (_jsx("div", Object.assign({}, styled('transfer__loading'), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), _jsx(VirtualScroll, Object.assign({}, vsProps, { ref: vsRef, enable: virtual !== false, listSize: 192, listPadding: 0, itemRender: (item, index, props) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
_jsx("div", Object.assign({}, styled('transfer__option-prefix'), { children: _jsx(Checkbox, { model: item[IS_SELECTED], disabled: itemDisabled }) })),
|
|
40
|
-
_jsx("div", Object.assign({}, styled('transfer__option-content'), { children: customItem ? customItem(item) : itemLabel }))));
|
|
41
|
-
}, placeholder: "li", onScrollEnd: onScrollBottom, children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('transfer__list'), { onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { marginTop: 32 }, image: Empty.SIMPLE_IMG }) : vsList }))) }))] }))] })));
|
|
30
|
+
}, children: [selectedCount, "/", list.length] }), checkNodeExist(title) && _jsx("div", Object.assign({}, styled('transfer__header-title'), { children: title }))] })), searchable && (_jsx("div", Object.assign({}, styled('transfer__search'), { children: _jsx(Input, { style: { display: 'flex' }, placeholder: t('Search'), prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), clearable: true, onModelChange: onSearch }) }))), _jsxs("div", Object.assign({}, styled('transfer__list-container'), { children: [loading && (_jsx("div", Object.assign({}, styled('transfer__loading'), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), _jsx(VirtualScroll, Object.assign({}, vsProps, { ref: vsRef, enable: virtual !== false, listSize: 192, listPadding: 0, itemRender: (item, index, props) => (_createElement("li", Object.assign({}, styled('transfer__option', {
|
|
31
|
+
'transfer__option.is-disabled': item.disabled,
|
|
32
|
+
}), props, { key: item.value, id: getItemId(item.value), title: item.label, onClick: () => {
|
|
33
|
+
if (!item.disabled) {
|
|
34
|
+
onSelectedChange === null || onSelectedChange === void 0 ? void 0 : onSelectedChange(item.value);
|
|
35
|
+
}
|
|
36
|
+
} }),
|
|
37
|
+
_jsx("div", Object.assign({}, styled('transfer__option-prefix'), { children: _jsx(Checkbox, { model: item[IS_SELECTED], disabled: item.disabled }) })),
|
|
38
|
+
_jsx("div", Object.assign({}, styled('transfer__option-content'), { children: customItem ? customItem(item.value, item[NO_MATCH] ? undefined : item) : item.label })))), placeholder: "li", onScrollEnd: onScrollBottom, children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('transfer__list'), { onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { marginTop: 32 }, image: Empty.SIMPLE_IMG }) : vsList }))) }))] }))] })));
|
|
42
39
|
}
|
package/transfer/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface TransferProps<V extends React.Key, T extends TransferItem<V>> e
|
|
|
22
22
|
loading?: [boolean?, boolean?];
|
|
23
23
|
disabled?: boolean;
|
|
24
24
|
virtual?: boolean | number;
|
|
25
|
-
customItem?: (
|
|
25
|
+
customItem?: (value: V, item?: T) => React.ReactNode;
|
|
26
26
|
customSearch?: {
|
|
27
27
|
filter?: (value: string, item: T) => boolean;
|
|
28
28
|
sort?: (a: T, b: T) => number;
|
package/transfer/vars.d.ts
CHANGED
package/transfer/vars.js
CHANGED
|
@@ -88,8 +88,6 @@ function TreeSelectFC(props, ref) {
|
|
|
88
88
|
else {
|
|
89
89
|
if (node.isLeaf || !onlyLeafSelectable) {
|
|
90
90
|
changeSelected(node.id);
|
|
91
|
-
}
|
|
92
|
-
if (node.isLeaf) {
|
|
93
91
|
changeVisible(false);
|
|
94
92
|
}
|
|
95
93
|
}
|
|
@@ -405,8 +403,11 @@ function TreeSelectFC(props, ref) {
|
|
|
405
403
|
else {
|
|
406
404
|
if (!isNull(selected)) {
|
|
407
405
|
const node = nodesMap.get(selected);
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
selectedNode = selectedLabel = customSelected
|
|
407
|
+
? customSelected(selected, node === null || node === void 0 ? void 0 : node.origin)
|
|
408
|
+
: node
|
|
409
|
+
? getTreeNodeLabel(node)
|
|
410
|
+
: String(selected);
|
|
410
411
|
}
|
|
411
412
|
}
|
|
412
413
|
return [selectedNode, suffixNode, selectedLabel];
|