@capillarytech/blaze-ui 0.1.6-alpha.4 → 0.1.6-alpha.41
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/.DS_Store +0 -0
- package/CapInput/CapInput.js +1 -1
- package/CapInput/Number.js +1 -1
- package/CapInput/Search.js +1 -1
- package/CapInput/TextArea.js +1 -1
- package/CapSkeleton/CapSkeleton.js +17 -0
- package/CapSkeleton/index.js +1 -0
- package/CapSpin/CapSpin.js +23 -0
- package/CapSpin/index.js +1 -0
- package/CapTable/loadable.js +4 -4
- package/CapTable/styles.js +1 -1
- package/CapTestSelect/CapTestSelect.js +47 -0
- package/CapTestSelect/index.js +1 -0
- package/CapUnifiedSelect/CapUnifiedSelect.js +252 -61
- package/CapUnifiedSelect/index.js +1 -4
- package/CapUnifiedSelect/styles.js +170 -166
- package/assets/upload.svg +3 -0
- package/index.js +7 -1
- package/package.json +7 -11
- package/utils/index.js +1 -0
- package/utils/withStyles.js +24 -0
- package/CapHeading/CapHeading.js +0 -71
- package/CapHeading/index.js +0 -1
- package/CapHeading/styles.js +0 -125
- package/CapInfoNote/CapInfoNote.js +0 -54
- package/CapInfoNote/index.js +0 -1
- package/CapInfoNote/styles.js +0 -63
- package/CapInput/loadable.js +0 -9
- package/CapLabel/CapLabel.js +0 -106
- package/CapLabel/index.js +0 -1
- package/CapLabel/styles.js +0 -221
- package/CapRow/CapRow.js +0 -22
- package/CapRow/index.js +0 -1
- package/CapRow/styles.js +0 -9
- package/CapTooltip/CapTooltip.js +0 -36
- package/CapTooltip/index.js +0 -1
- package/CapTooltip/styles.js +0 -42
- package/CapUnifiedSelect/loadable.js +0 -3
- package/dist/235.index.js +0 -2
- package/dist/235.index.js.LICENSE.txt +0 -29
- package/dist/603.index.js +0 -1
- package/dist/CapInput/CapInput.js +0 -66
- package/dist/CapInput/Number.js +0 -42
- package/dist/CapInput/Search.js +0 -35
- package/dist/CapInput/TextArea.js +0 -42
- package/dist/CapInput/index.js +0 -15
- package/dist/CapInput/messages.js +0 -32
- package/dist/CapInput/styles.js +0 -11
- package/dist/CapTable/CapTable.js +0 -148
- package/dist/CapTable/index.js +0 -9
- package/dist/CapTable/loadable.js +0 -23
- package/dist/CapTable/styles.js +0 -26
- package/dist/LocaleHoc/index.js +0 -40
- package/dist/esm/CapHeading/CapHeading.js +0 -41
- package/dist/esm/CapHeading/index.js +0 -1
- package/dist/esm/CapHeading/styles.js +0 -123
- package/dist/esm/CapInfoNote/CapInfoNote.js +0 -62
- package/dist/esm/CapInfoNote/index.js +0 -1
- package/dist/esm/CapInfoNote/styles.js +0 -6
- package/dist/esm/CapInput/CapInput.js +0 -57
- package/dist/esm/CapInput/Number.js +0 -35
- package/dist/esm/CapInput/Search.js +0 -28
- package/dist/esm/CapInput/TextArea.js +0 -35
- package/dist/esm/CapInput/index.js +0 -8
- package/dist/esm/CapInput/loadable.js +0 -9
- package/dist/esm/CapInput/messages.js +0 -25
- package/dist/esm/CapInput/styles.js +0 -3
- package/dist/esm/CapLabel/CapLabel.js +0 -50
- package/dist/esm/CapLabel/index.js +0 -1
- package/dist/esm/CapLabel/styles.js +0 -219
- package/dist/esm/CapRow/CapRow.js +0 -22
- package/dist/esm/CapRow/index.js +0 -1
- package/dist/esm/CapRow/styles.js +0 -5
- package/dist/esm/CapTable/CapTable.js +0 -140
- package/dist/esm/CapTable/index.js +0 -2
- package/dist/esm/CapTable/loadable.js +0 -12
- package/dist/esm/CapTable/styles.js +0 -17
- package/dist/esm/CapTooltip/CapTooltip.js +0 -34
- package/dist/esm/CapTooltip/index.js +0 -1
- package/dist/esm/CapTooltip/styles.js +0 -6
- package/dist/esm/CapUnifiedSelect/CapUnifiedSelect.js +0 -101
- package/dist/esm/CapUnifiedSelect/index.js +0 -3
- package/dist/esm/CapUnifiedSelect/loadable.js +0 -4
- package/dist/esm/CapUnifiedSelect/messages.js +0 -23
- package/dist/esm/CapUnifiedSelect/styles.js +0 -15
- package/dist/esm/LocaleHoc/index.js +0 -31
- package/dist/esm/index.js +0 -11
- package/dist/esm/styled/index.js +0 -5
- package/dist/esm/styled/variables.js +0 -88
- package/dist/esm/translations/en.js +0 -329
- package/dist/index.js +0 -39
- package/dist/index.js.LICENSE.txt +0 -7
- package/dist/styled/index.js +0 -22
- package/dist/styled/variables.js +0 -94
- package/dist/translations/en.js +0 -335
package/.DS_Store
ADDED
|
Binary file
|
package/CapInput/CapInput.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { Input } from 'antd';
|
|
3
|
+
import { Input } from 'antd-v5';
|
|
4
4
|
import { WarningOutlined, CheckCircleOutlined } from '@ant-design/icons';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import * as styledVars from '../styled/variables';
|
package/CapInput/Number.js
CHANGED
package/CapInput/Search.js
CHANGED
package/CapInput/TextArea.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CapSkeleton - Migrated to Ant Design v5
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { Skeleton } from 'antd-v5';
|
|
7
|
+
|
|
8
|
+
const CapSkeleton = ({ className, ...rest }) => {
|
|
9
|
+
const combinedClassName = `cap-skeleton-v2 ${className || ''}`.trim();
|
|
10
|
+
return <Skeleton className={combinedClassName} {...rest} />;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
CapSkeleton.propTypes = {
|
|
14
|
+
className: PropTypes.string
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default CapSkeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CapSkeleton';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CapSpin - Migrated to Ant Design v5
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { Spin } from 'antd-v5';
|
|
7
|
+
|
|
8
|
+
const CapSpin = ({ className, ...rest }) => (
|
|
9
|
+
<Spin className={className} {...rest} />
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CapSpin.propTypes = {
|
|
13
|
+
className: PropTypes.string,
|
|
14
|
+
size: PropTypes.oneOf(['small', 'default', 'large']),
|
|
15
|
+
spinning: PropTypes.bool,
|
|
16
|
+
tip: PropTypes.string,
|
|
17
|
+
delay: PropTypes.number,
|
|
18
|
+
indicator: PropTypes.node,
|
|
19
|
+
fullscreen: PropTypes.bool,
|
|
20
|
+
wrapperClassName: PropTypes.string
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default CapSpin;
|
package/CapSpin/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CapSpin';
|
package/CapTable/loadable.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CapSkeleton from '../CapSkeleton';
|
|
2
2
|
import { loadable } from '@capillarytech/cap-ui-utils';
|
|
3
3
|
import React, { Suspense } from 'react';
|
|
4
4
|
|
|
5
5
|
const LoadableComponent = loadable(() => import('./CapTable'));
|
|
6
6
|
|
|
7
|
-
const CapTableLoadable = () => (
|
|
8
|
-
<Suspense fallback={<
|
|
9
|
-
<LoadableComponent />
|
|
7
|
+
const CapTableLoadable = (props) => (
|
|
8
|
+
<Suspense fallback={<CapSkeleton />}>
|
|
9
|
+
<LoadableComponent {...props} />
|
|
10
10
|
</Suspense>
|
|
11
11
|
);
|
|
12
12
|
|
package/CapTable/styles.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Select } from 'antd-v5';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Test component to verify Ant Design v5 Select integration
|
|
7
|
+
* This is a simple wrapper for testing purposes only
|
|
8
|
+
*/
|
|
9
|
+
const CapTestSelect = (props) => {
|
|
10
|
+
return <Select {...props} />;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
CapTestSelect.propTypes = {
|
|
14
|
+
// Common Select props from antd
|
|
15
|
+
allowClear: PropTypes.bool,
|
|
16
|
+
defaultValue: PropTypes.oneOfType([
|
|
17
|
+
PropTypes.string,
|
|
18
|
+
PropTypes.number,
|
|
19
|
+
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))
|
|
20
|
+
]),
|
|
21
|
+
disabled: PropTypes.bool,
|
|
22
|
+
loading: PropTypes.bool,
|
|
23
|
+
mode: PropTypes.oneOf(['multiple', 'tags']),
|
|
24
|
+
placeholder: PropTypes.string,
|
|
25
|
+
showSearch: PropTypes.bool,
|
|
26
|
+
value: PropTypes.oneOfType([
|
|
27
|
+
PropTypes.string,
|
|
28
|
+
PropTypes.number,
|
|
29
|
+
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))
|
|
30
|
+
]),
|
|
31
|
+
options: PropTypes.arrayOf(
|
|
32
|
+
PropTypes.shape({
|
|
33
|
+
label: PropTypes.node,
|
|
34
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
35
|
+
disabled: PropTypes.bool
|
|
36
|
+
})
|
|
37
|
+
)
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
CapTestSelect.defaultProps = {
|
|
41
|
+
allowClear: false,
|
|
42
|
+
disabled: false,
|
|
43
|
+
loading: false,
|
|
44
|
+
showSearch: false
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default CapTestSelect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CapTestSelect';
|
|
@@ -1,121 +1,312 @@
|
|
|
1
|
-
// CapUnifiedSelect
|
|
2
|
-
import React from 'react';
|
|
1
|
+
// Enhanced CapUnifiedSelect supporting 4 scenarios with advanced features in a single TreeSelect
|
|
2
|
+
import React, { useState, useEffect, useMemo, useCallback, memo } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { TreeSelect, Tooltip, Input, Button } from 'antd-v5';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import * as styledVars from '../styled/variables';
|
|
8
|
+
import uploadIcon from '../assets/upload.svg';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
import { InfoCircleOutlined, SearchOutlined, WarningFilled, DownOutlined } from '@ant-design/icons';
|
|
11
|
+
|
|
12
|
+
import withStyles from '../utils/withStyles';
|
|
13
|
+
import { SelectWrapper, HeaderWrapper, selectStyles } from './styles';
|
|
14
|
+
|
|
15
|
+
const StyledTreeSelect = styled(TreeSelect)`
|
|
16
|
+
${selectStyles}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const CapUnifiedSelect = ({
|
|
10
20
|
type,
|
|
11
21
|
options = [],
|
|
12
|
-
treeData,
|
|
13
22
|
value,
|
|
14
23
|
onChange,
|
|
15
24
|
placeholder = 'Select an option',
|
|
16
25
|
className,
|
|
17
26
|
style,
|
|
27
|
+
isError = false,
|
|
28
|
+
errorMessage,
|
|
29
|
+
popupClassName,
|
|
18
30
|
allowClear = false,
|
|
19
|
-
|
|
20
|
-
label,
|
|
31
|
+
headerLabel,
|
|
21
32
|
tooltip,
|
|
33
|
+
bylineText,
|
|
22
34
|
disabled = false,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
showUpload = false,
|
|
36
|
+
customPopupRender = true,
|
|
37
|
+
showSearch = true,
|
|
38
|
+
searchBasedOn = 'label',
|
|
39
|
+
onConfirm,
|
|
40
|
+
onCancel,
|
|
41
|
+
noResultText = 'No results found',
|
|
42
|
+
...rest
|
|
43
|
+
}) => {
|
|
44
|
+
|
|
45
|
+
const [searchText, setSearchText] = useState('');
|
|
46
|
+
const [tempValue, setTempValue] = useState(value);
|
|
47
|
+
const [allSelected, setAllSelected] = useState(false);
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setTempValue(value);
|
|
52
|
+
}, [value]);
|
|
27
53
|
|
|
28
54
|
const treeSelectVirtualizationProps = {
|
|
29
55
|
listHeight: 256,
|
|
30
56
|
listItemHeight: 32,
|
|
31
57
|
};
|
|
32
58
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
59
|
+
const NoResult = memo(({ noResultText, className }) => (
|
|
60
|
+
<div className={classnames(className, "cap-unified-select-no-result")}>
|
|
61
|
+
<WarningFilled className="cap-unified-select-no-result-icon" />
|
|
62
|
+
<div className="cap-unified-select-no-result-text">{noResultText}</div>
|
|
63
|
+
</div>
|
|
64
|
+
));
|
|
65
|
+
|
|
66
|
+
const getFilteredTreeData = useCallback((data, search) => {
|
|
67
|
+
if (!search) return data;
|
|
68
|
+
|
|
69
|
+
const filterNode = node => {
|
|
70
|
+
if (searchBasedOn === 'value') {
|
|
71
|
+
const valueText = String(node.value || '').toLowerCase();
|
|
72
|
+
return valueText.includes(search.toLowerCase());
|
|
73
|
+
} else if (searchBasedOn === 'key') {
|
|
74
|
+
const keyText = String(node.key || '').toLowerCase();
|
|
75
|
+
return keyText.includes(search.toLowerCase());
|
|
76
|
+
} else {
|
|
77
|
+
const labelText = node.label?.toLowerCase() || '';
|
|
78
|
+
return labelText.includes(search.toLowerCase());
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const loop = data =>
|
|
83
|
+
data.map(item => {
|
|
84
|
+
const children = item.children ? loop(item.children) : [];
|
|
85
|
+
if (filterNode(item) || children.length) {
|
|
86
|
+
return { ...item, children };
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}).filter(Boolean);
|
|
90
|
+
|
|
91
|
+
return loop(data);
|
|
92
|
+
}, [searchBasedOn]);
|
|
93
|
+
|
|
94
|
+
const flattenLeafValues = useCallback(nodes =>
|
|
95
|
+
nodes?.flatMap(node => node.children ? flattenLeafValues(node.children) : [node.value]) || [], []);
|
|
96
|
+
|
|
97
|
+
const isMulti = useMemo(() => type === 'multiSelect' || type === 'multiTreeSelect', [type]);
|
|
98
|
+
const isTree = useMemo(() => type === 'treeSelect' || type === 'multiTreeSelect', [type]);
|
|
99
|
+
|
|
100
|
+
const dataSource = useMemo(() => {
|
|
101
|
+
return isTree ? options : options.map(opt => ({ title: opt.label, value: opt.value, key: opt.key || opt.value }));
|
|
102
|
+
}, [isTree, options]);
|
|
103
|
+
|
|
104
|
+
const filteredTree = useMemo(() => getFilteredTreeData(dataSource, searchText), [dataSource, searchText]);
|
|
105
|
+
const leafValues = useMemo(() => flattenLeafValues(filteredTree), [filteredTree]);
|
|
106
|
+
|
|
107
|
+
const handleSelectAll = useCallback(() => {
|
|
108
|
+
const availableValues = leafValues;
|
|
109
|
+
if (allSelected) {
|
|
110
|
+
setTempValue([]);
|
|
111
|
+
setAllSelected(false);
|
|
112
|
+
} else {
|
|
113
|
+
setTempValue(availableValues);
|
|
114
|
+
setAllSelected(true);
|
|
115
|
+
}
|
|
116
|
+
}, [allSelected, leafValues]);
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (isMulti && Array.isArray(tempValue)) {
|
|
120
|
+
const allItemsSelected = tempValue.length > 0 && leafValues.length > 0 && tempValue.length === leafValues.length;
|
|
121
|
+
setAllSelected(allItemsSelected);
|
|
122
|
+
}
|
|
123
|
+
}, [tempValue, leafValues, isMulti]);
|
|
124
|
+
|
|
125
|
+
const handleConfirm = useCallback(() => {
|
|
126
|
+
if (onChange) onChange(tempValue);
|
|
127
|
+
}, [onChange, tempValue]);
|
|
128
|
+
|
|
129
|
+
const handleCancel = useCallback(() => {
|
|
130
|
+
setTempValue(value);
|
|
131
|
+
}, [value]);
|
|
132
|
+
|
|
133
|
+
const handleTempChange = useCallback(newValue => {
|
|
134
|
+
setTempValue(newValue);
|
|
135
|
+
}, []);
|
|
136
|
+
|
|
137
|
+
const suffix = useMemo(() => {
|
|
138
|
+
return isMulti && Array.isArray(value) && value?.length > 1 ? (
|
|
139
|
+
<>
|
|
140
|
+
<span>+{value.length - 1} more <DownOutlined /></span>
|
|
141
|
+
</>
|
|
142
|
+
) : (
|
|
143
|
+
<DownOutlined />
|
|
144
|
+
);
|
|
145
|
+
}, [isMulti, value]);
|
|
146
|
+
|
|
147
|
+
const prefix = useMemo(() => {
|
|
148
|
+
if (isMulti && Array.isArray(value) && value?.length > 0) {
|
|
149
|
+
const selectedLabels = options.filter(opt => value.includes(opt.value)).map(opt => opt.label);
|
|
150
|
+
return selectedLabels[0];
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
}, [isMulti, value, options]);
|
|
154
|
+
|
|
155
|
+
const renderHeader = useCallback(() => {
|
|
156
|
+
if (!headerLabel && !tooltip) return null;
|
|
36
157
|
return (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{label}
|
|
41
|
-
</CapLabel>
|
|
42
|
-
)}
|
|
158
|
+
<>
|
|
159
|
+
<HeaderWrapper className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header')}>
|
|
160
|
+
{headerLabel && <label type="label16" className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-label')}>{headerLabel}</label>}
|
|
43
161
|
{tooltip && (
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
</
|
|
162
|
+
<Tooltip title={tooltip} rootClassName="cap-unified-tooltip" className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-tooltip')}>
|
|
163
|
+
<InfoCircleOutlined />
|
|
164
|
+
</Tooltip>
|
|
47
165
|
)}
|
|
48
166
|
</HeaderWrapper>
|
|
167
|
+
<div className="cap-unified-select-header-byline-text">
|
|
168
|
+
{bylineText && <label className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-byline-text')}>{bylineText}</label>}
|
|
169
|
+
</div>
|
|
170
|
+
</>
|
|
49
171
|
);
|
|
50
|
-
};
|
|
172
|
+
}, [headerLabel, tooltip, bylineText, disabled]);
|
|
51
173
|
|
|
52
174
|
const renderDropdown = () => {
|
|
53
|
-
|
|
175
|
+
const currentItems = filteredTree;
|
|
176
|
+
const selectedCount = Array.isArray(tempValue)
|
|
177
|
+
? isTree
|
|
178
|
+
? tempValue.filter(val => leafValues.includes(val)).length
|
|
179
|
+
: tempValue.length
|
|
180
|
+
: (tempValue ? 1 : 0);
|
|
181
|
+
|
|
182
|
+
const renderCustomDropdown = menu => {
|
|
183
|
+
if (!customPopupRender) return menu;
|
|
184
|
+
|
|
54
185
|
return (
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
186
|
+
<div className={classnames(popupClassName, `${type}-popup-container`)}>
|
|
187
|
+
{showSearch && (
|
|
188
|
+
<div className={classnames("cap-unified-select-search-container")}>
|
|
189
|
+
<Input
|
|
190
|
+
prefix={<SearchOutlined style={{ color: styledVars.CAP_G06 }} />}
|
|
191
|
+
placeholder="Search"
|
|
192
|
+
variant="borderless"
|
|
193
|
+
value={searchText}
|
|
194
|
+
onChange={e => setSearchText(e.target.value)}
|
|
195
|
+
onKeyDown={e => e.stopPropagation()}
|
|
196
|
+
/>
|
|
197
|
+
</div>
|
|
198
|
+
)}
|
|
199
|
+
{isMulti && showUpload && (
|
|
200
|
+
<div className={classnames("cap-unified-select-upload-container")}>
|
|
201
|
+
<Button
|
|
202
|
+
type="link"
|
|
203
|
+
icon={<img src={uploadIcon} alt="upload" />}
|
|
204
|
+
onClick={() => {}}
|
|
205
|
+
className={classnames("cap-unified-select-upload-button")}
|
|
206
|
+
>
|
|
207
|
+
Upload
|
|
208
|
+
</Button>
|
|
209
|
+
</div>
|
|
210
|
+
)}
|
|
211
|
+
{isMulti && currentItems.length > 0 && (
|
|
212
|
+
<div className={classnames("cap-unified-select-select-all-container")} onClick={e => { e.stopPropagation(); handleSelectAll(); }}>
|
|
213
|
+
<input type="checkbox" checked={allSelected} className={classnames("cap-unified-select-select-all-checkbox")} onClick={e => e.stopPropagation()} />
|
|
214
|
+
<label className={classnames("cap-unified-select-select-all-label")}>Select all</label>
|
|
215
|
+
</div>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
{currentItems.length === 0 ? <NoResult noResultText={noResultText} className={classnames(className, "cap-unified-select-no-result")}/> : menu}
|
|
219
|
+
|
|
220
|
+
{currentItems.length > 0 && isMulti && (
|
|
221
|
+
<div className={classnames("cap-unified-select-confirm-container")}>
|
|
222
|
+
<div>
|
|
223
|
+
<Button type="primary" size="small" className={classnames("cap-unified-select-confirm-button")} onClick={e => { e.stopPropagation(); handleConfirm(); }}>Confirm</Button>
|
|
224
|
+
<Button type="text" size="small" onClick={e => { e.stopPropagation(); handleCancel(); }}>Cancel</Button>
|
|
225
|
+
</div>
|
|
226
|
+
{selectedCount > 0 && <span className={classnames("cap-unified-select-selected-count")}>{selectedCount} selected</span>}
|
|
227
|
+
</div>
|
|
228
|
+
)}
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<>
|
|
235
|
+
<StyledTreeSelect
|
|
236
|
+
{...rest}
|
|
237
|
+
type={type}
|
|
238
|
+
treeData={filteredTree}
|
|
239
|
+
value={customPopupRender ? tempValue : value}
|
|
240
|
+
onChange={customPopupRender ? handleTempChange : onChange}
|
|
59
241
|
placeholder={placeholder}
|
|
60
|
-
|
|
242
|
+
showSearch={false}
|
|
243
|
+
maxTagCount={0}
|
|
244
|
+
maxTagPlaceholder={() => null}
|
|
245
|
+
prefix={isMulti && value.length > 0 && prefix}
|
|
246
|
+
suffixIcon={suffix}
|
|
247
|
+
className={classnames(`cap-unified-tree-select ${className || ''}`)}
|
|
61
248
|
style={style}
|
|
249
|
+
status={isError ? 'error' : ''}
|
|
62
250
|
allowClear={allowClear}
|
|
63
|
-
|
|
64
|
-
|
|
251
|
+
multiple={isMulti}
|
|
252
|
+
treeCheckable={isMulti}
|
|
253
|
+
showCheckedStrategy={TreeSelect.SHOW_PARENT}
|
|
65
254
|
virtual
|
|
66
|
-
treeDefaultExpandAll
|
|
67
255
|
disabled={disabled}
|
|
256
|
+
filterTreeNode={false}
|
|
68
257
|
{...treeSelectVirtualizationProps}
|
|
258
|
+
popupRender={renderCustomDropdown}
|
|
69
259
|
/>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<Select
|
|
75
|
-
value={value}
|
|
76
|
-
onChange={onChange}
|
|
77
|
-
placeholder={placeholder}
|
|
78
|
-
className={className}
|
|
79
|
-
style={style}
|
|
80
|
-
allowClear={allowClear}
|
|
81
|
-
showSearch={showSearch}
|
|
82
|
-
options={options}
|
|
83
|
-
mode={type === 'multiSelect' ? 'multiple' : undefined}
|
|
84
|
-
virtual
|
|
85
|
-
disabled={disabled}
|
|
86
|
-
{...selectVirtualizationProps}
|
|
87
|
-
/>
|
|
260
|
+
{isError && <div className={classnames("cap-unified-select-status")}>{errorMessage}</div>}
|
|
261
|
+
</>
|
|
88
262
|
);
|
|
89
263
|
};
|
|
90
264
|
|
|
91
265
|
return (
|
|
92
|
-
<SelectWrapper>
|
|
266
|
+
<SelectWrapper className={classnames(className, 'cap-unified-select-container')}>
|
|
93
267
|
{renderHeader()}
|
|
94
268
|
{renderDropdown()}
|
|
95
269
|
</SelectWrapper>
|
|
96
270
|
);
|
|
97
|
-
}
|
|
271
|
+
};
|
|
98
272
|
|
|
99
273
|
CapUnifiedSelect.propTypes = {
|
|
100
274
|
type: PropTypes.oneOf(['select', 'multiSelect', 'treeSelect', 'multiTreeSelect']),
|
|
101
275
|
options: PropTypes.array,
|
|
102
|
-
treeData: PropTypes.array,
|
|
103
276
|
value: PropTypes.any,
|
|
104
277
|
onChange: PropTypes.func,
|
|
105
278
|
placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
106
279
|
className: PropTypes.string,
|
|
107
280
|
style: PropTypes.object,
|
|
108
281
|
allowClear: PropTypes.bool,
|
|
109
|
-
|
|
110
|
-
label: PropTypes.string,
|
|
282
|
+
headerLabel: PropTypes.string,
|
|
111
283
|
tooltip: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
112
284
|
disabled: PropTypes.bool,
|
|
285
|
+
customPopupRender: PropTypes.bool,
|
|
286
|
+
showSearch: PropTypes.bool,
|
|
287
|
+
searchBasedOn: PropTypes.oneOf(['label', 'value', 'key']),
|
|
288
|
+
onConfirm: PropTypes.func,
|
|
289
|
+
onCancel: PropTypes.func,
|
|
290
|
+
isError: PropTypes.bool,
|
|
291
|
+
errorMessage: PropTypes.string,
|
|
292
|
+
popupClassName: PropTypes.string,
|
|
293
|
+
showUpload: PropTypes.bool,
|
|
113
294
|
};
|
|
114
295
|
|
|
115
296
|
CapUnifiedSelect.defaultProps = {
|
|
116
297
|
type: 'select',
|
|
298
|
+
options: [],
|
|
299
|
+
placeholder: 'Select an option',
|
|
117
300
|
allowClear: false,
|
|
118
|
-
|
|
301
|
+
customPopupRender: true,
|
|
302
|
+
showSearch: true,
|
|
303
|
+
searchBasedOn: 'label',
|
|
304
|
+
className: '',
|
|
305
|
+
popupClassName: '',
|
|
306
|
+
disabled: false,
|
|
307
|
+
showUpload: false,
|
|
308
|
+
isError: false,
|
|
309
|
+
noResultText: 'No results found'
|
|
119
310
|
};
|
|
120
311
|
|
|
121
|
-
export default CapUnifiedSelect;
|
|
312
|
+
export default withStyles(CapUnifiedSelect, selectStyles);
|