@capillarytech/blaze-ui 0.1.6-alpha.4 → 0.1.6-alpha.40
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/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 +249 -59
- package/CapUnifiedSelect/index.js +1 -4
- package/CapUnifiedSelect/styles.js +272 -26
- 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/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,311 @@
|
|
|
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 } 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 uploadIcon from '../assets/upload.svg';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import { InfoCircleOutlined, SearchOutlined, WarningFilled, DownOutlined } from '@ant-design/icons';
|
|
10
|
+
|
|
11
|
+
import withStyles from '../utils/withStyles';
|
|
12
|
+
import { SelectWrapper, HeaderWrapper, selectStyles } from './styles';
|
|
13
|
+
|
|
14
|
+
const StyledTreeSelect = styled(TreeSelect)`
|
|
15
|
+
${selectStyles}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const CapUnifiedSelect = ({
|
|
10
19
|
type,
|
|
11
20
|
options = [],
|
|
12
|
-
treeData,
|
|
13
21
|
value,
|
|
14
22
|
onChange,
|
|
15
23
|
placeholder = 'Select an option',
|
|
16
24
|
className,
|
|
17
25
|
style,
|
|
26
|
+
isError = false,
|
|
27
|
+
errorMessage,
|
|
28
|
+
popupClassName,
|
|
18
29
|
allowClear = false,
|
|
19
|
-
|
|
20
|
-
label,
|
|
30
|
+
headerLabel,
|
|
21
31
|
tooltip,
|
|
32
|
+
bylineText,
|
|
22
33
|
disabled = false,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
showUpload = false,
|
|
35
|
+
customPopupRender = true,
|
|
36
|
+
showSearch = true,
|
|
37
|
+
searchBasedOn = 'label',
|
|
38
|
+
onConfirm,
|
|
39
|
+
onCancel,
|
|
40
|
+
noResultText = 'No results found',
|
|
41
|
+
...rest
|
|
42
|
+
}) => {
|
|
43
|
+
|
|
44
|
+
const [searchText, setSearchText] = useState('');
|
|
45
|
+
const [tempValue, setTempValue] = useState(value);
|
|
46
|
+
const [allSelected, setAllSelected] = useState(false);
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
setTempValue(value);
|
|
51
|
+
}, [value]);
|
|
27
52
|
|
|
28
53
|
const treeSelectVirtualizationProps = {
|
|
29
54
|
listHeight: 256,
|
|
30
55
|
listItemHeight: 32,
|
|
31
56
|
};
|
|
32
57
|
|
|
58
|
+
const NoResult = ({ noResultText, className }) => (
|
|
59
|
+
<div className={classnames(className, "cap-unified-select-no-result")}>
|
|
60
|
+
<WarningFilled className="cap-unified-select-no-result-icon" />
|
|
61
|
+
<div className="cap-unified-select-no-result-text">{noResultText}</div>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const getFilteredTreeData = (data, search) => {
|
|
66
|
+
if (!search) return data;
|
|
67
|
+
|
|
68
|
+
const filterNode = node => {
|
|
69
|
+
if (searchBasedOn === 'value') {
|
|
70
|
+
const valueText = String(node.value || '').toLowerCase();
|
|
71
|
+
return valueText.includes(search.toLowerCase());
|
|
72
|
+
} else if (searchBasedOn === 'key') {
|
|
73
|
+
const keyText = String(node.key || '').toLowerCase();
|
|
74
|
+
return keyText.includes(search.toLowerCase());
|
|
75
|
+
} else {
|
|
76
|
+
// Default case, fall back to label
|
|
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
|
+
};
|
|
93
|
+
|
|
94
|
+
const flattenLeafValues = nodes =>
|
|
95
|
+
nodes?.flatMap(node => node.children ? flattenLeafValues(node.children) : [node.value]) || [];
|
|
96
|
+
|
|
97
|
+
const isMulti = type === 'multiSelect' || type === 'multiTreeSelect';
|
|
98
|
+
const isTree = type === 'treeSelect' || type === 'multiTreeSelect';
|
|
99
|
+
|
|
100
|
+
const dataSource = isTree ? options : options.map(opt => ({ title: opt.label, value: opt.value, key: opt.key || opt.value }));
|
|
101
|
+
|
|
102
|
+
const filteredTree = getFilteredTreeData(dataSource, searchText);
|
|
103
|
+
const leafValues = flattenLeafValues(filteredTree);
|
|
104
|
+
|
|
105
|
+
const handleSelectAll = () => {
|
|
106
|
+
const availableValues = leafValues;
|
|
107
|
+
if (allSelected) {
|
|
108
|
+
// If currently all selected, then unselect all
|
|
109
|
+
setTempValue([]);
|
|
110
|
+
setAllSelected(false);
|
|
111
|
+
} else {
|
|
112
|
+
// Otherwise select all available options
|
|
113
|
+
setTempValue(availableValues);
|
|
114
|
+
setAllSelected(true);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (isMulti && Array.isArray(tempValue)) {
|
|
120
|
+
setAllSelected(tempValue.length > 0 && tempValue.length === leafValues.length);
|
|
121
|
+
}
|
|
122
|
+
}, [tempValue, leafValues, isMulti]);
|
|
123
|
+
|
|
124
|
+
const handleConfirm = () => {
|
|
125
|
+
console.log('Confirm clicked');
|
|
126
|
+
if (onChange) onChange(tempValue);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const handleCancel = () => {
|
|
130
|
+
console.log('Cancel clicked');
|
|
131
|
+
setTempValue(value);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const handleTempChange = newValue => {
|
|
135
|
+
setTempValue(newValue);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const suffix = isMulti && Array.isArray(value) && value?.length > 1 ? (
|
|
139
|
+
<>
|
|
140
|
+
<span>+{value.length - 1} more <DownOutlined /></span>
|
|
141
|
+
</>
|
|
142
|
+
) : (
|
|
143
|
+
<DownOutlined />
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const prefix = () => {
|
|
147
|
+
if (isMulti && Array.isArray(value) && value?.length > 0) {
|
|
148
|
+
const selectedLabels = options.filter(opt => value.includes(opt.value)).map(opt => opt.label);
|
|
149
|
+
return selectedLabels[0];
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
};
|
|
153
|
+
|
|
33
154
|
const renderHeader = () => {
|
|
34
|
-
if (!
|
|
35
|
-
|
|
155
|
+
if (!headerLabel && !tooltip) return null;
|
|
36
156
|
return (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{label}
|
|
41
|
-
</CapLabel>
|
|
42
|
-
)}
|
|
157
|
+
<>
|
|
158
|
+
<HeaderWrapper className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header')}>
|
|
159
|
+
{headerLabel && <label type="label16" className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-label')}>{headerLabel}</label>}
|
|
43
160
|
{tooltip && (
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
</
|
|
161
|
+
<Tooltip title={tooltip} rootClassName="cap-unified-tooltip" className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-tooltip')}>
|
|
162
|
+
<InfoCircleOutlined />
|
|
163
|
+
</Tooltip>
|
|
47
164
|
)}
|
|
48
165
|
</HeaderWrapper>
|
|
166
|
+
<div className="cap-unified-select-header-byline-text">
|
|
167
|
+
{bylineText && <label className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-byline-text')}>{bylineText}</label>}
|
|
168
|
+
</div>
|
|
169
|
+
</>
|
|
49
170
|
);
|
|
50
171
|
};
|
|
51
172
|
|
|
52
173
|
const renderDropdown = () => {
|
|
53
|
-
|
|
174
|
+
const currentItems = filteredTree;
|
|
175
|
+
const selectedCount = Array.isArray(tempValue)
|
|
176
|
+
? isTree
|
|
177
|
+
? tempValue.filter(val => leafValues.includes(val)).length
|
|
178
|
+
: tempValue.length
|
|
179
|
+
: (tempValue ? 1 : 0);
|
|
180
|
+
|
|
181
|
+
const renderCustomDropdown = menu => {
|
|
182
|
+
if (!customPopupRender) return menu;
|
|
183
|
+
|
|
54
184
|
return (
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
185
|
+
<div className={classnames(popupClassName, `${type}-popup-container`)}>
|
|
186
|
+
{showSearch && (
|
|
187
|
+
<div style={{ borderBottom: '1px solid #f0f0f0' }}>
|
|
188
|
+
<Input
|
|
189
|
+
prefix={<SearchOutlined style={{ color: '#B3BAC5' }} />}
|
|
190
|
+
placeholder="Search"
|
|
191
|
+
variant="borderless"
|
|
192
|
+
value={searchText}
|
|
193
|
+
onChange={e => setSearchText(e.target.value)}
|
|
194
|
+
onKeyDown={e => e.stopPropagation()}
|
|
195
|
+
/>
|
|
196
|
+
</div>
|
|
197
|
+
)}
|
|
198
|
+
{isMulti && showUpload && (
|
|
199
|
+
<div style={{ cursor: 'pointer', display: 'flex', alignItems: 'center', borderBottom: '1px solid #f0f0f0' , height: '36px'}}>
|
|
200
|
+
<Button
|
|
201
|
+
type="link"
|
|
202
|
+
icon={<img src={uploadIcon} alt="upload" style={{ width: "16px", height: "20px" }} />}
|
|
203
|
+
onClick={() => {}}
|
|
204
|
+
style={{
|
|
205
|
+
color: '#2466EA', // AntD primary blue
|
|
206
|
+
display: 'flex',
|
|
207
|
+
alignItems: 'center',
|
|
208
|
+
fontSize: '14px',
|
|
209
|
+
fontWeight: '400',
|
|
210
|
+
lineHeight: '20px',
|
|
211
|
+
}}
|
|
212
|
+
>
|
|
213
|
+
Upload
|
|
214
|
+
</Button>
|
|
215
|
+
</div>
|
|
216
|
+
)}
|
|
217
|
+
{isMulti && currentItems.length > 0 && (
|
|
218
|
+
<div style={{ padding: '8px 12px', cursor: 'pointer', display: 'flex', alignItems: 'center', borderBottom: '1px solid #f0f0f0' }} onClick={e => { e.stopPropagation(); handleSelectAll(); }}>
|
|
219
|
+
<input type="checkbox" checked={allSelected} readOnly style={{ cursor: 'pointer' }} onClick={e => e.stopPropagation()} />
|
|
220
|
+
<label style={{ marginLeft: 8, cursor: 'pointer' }}>Select all</label>
|
|
221
|
+
</div>
|
|
222
|
+
)}
|
|
223
|
+
|
|
224
|
+
{currentItems.length === 0 ? <NoResult noResultText={noResultText} className={classnames(className, "cap-unified-select-no-result")}/> : menu}
|
|
225
|
+
|
|
226
|
+
{currentItems.length > 0 && isMulti && (
|
|
227
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '8px 12px', borderTop: '1px solid #f0f0f0' }}>
|
|
228
|
+
<div>
|
|
229
|
+
<Button type="primary" size="small" style={{ marginRight: 8 }} onClick={e => { e.stopPropagation(); handleConfirm(); }}>Confirm</Button>
|
|
230
|
+
<Button type="text" size="small" onClick={e => { e.stopPropagation(); handleCancel(); }}>Cancel</Button>
|
|
231
|
+
</div>
|
|
232
|
+
{selectedCount > 0 && <span style={{ color: '#8c8c8c', fontSize: '14px' }}>{selectedCount} selected</span>}
|
|
233
|
+
</div>
|
|
234
|
+
)}
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<>
|
|
241
|
+
<StyledTreeSelect
|
|
242
|
+
{...rest}
|
|
243
|
+
type={type}
|
|
244
|
+
treeData={filteredTree}
|
|
245
|
+
value={customPopupRender ? tempValue : value}
|
|
246
|
+
onChange={customPopupRender ? handleTempChange : onChange}
|
|
59
247
|
placeholder={placeholder}
|
|
60
|
-
|
|
248
|
+
maxTagCount={0}
|
|
249
|
+
maxTagPlaceholder={() => null}
|
|
250
|
+
prefix={isMulti && value.length > 0 && prefix()}
|
|
251
|
+
suffixIcon={suffix}
|
|
252
|
+
className={classnames(`cap-unified-tree-select ${className || ''}`)}
|
|
61
253
|
style={style}
|
|
254
|
+
status={isError ? 'error' : ''}
|
|
62
255
|
allowClear={allowClear}
|
|
63
|
-
|
|
64
|
-
|
|
256
|
+
multiple={isMulti}
|
|
257
|
+
treeCheckable={isMulti}
|
|
258
|
+
showCheckedStrategy={TreeSelect.SHOW_PARENT}
|
|
65
259
|
virtual
|
|
66
|
-
treeDefaultExpandAll
|
|
67
260
|
disabled={disabled}
|
|
261
|
+
filterTreeNode={false}
|
|
68
262
|
{...treeSelectVirtualizationProps}
|
|
263
|
+
popupRender={renderCustomDropdown}
|
|
69
264
|
/>
|
|
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
|
-
/>
|
|
265
|
+
{isError && <div style={{ color: '#E83135' }} className="cap-unified-select-status">{errorMessage}</div>}
|
|
266
|
+
</>
|
|
88
267
|
);
|
|
89
268
|
};
|
|
90
269
|
|
|
91
270
|
return (
|
|
92
|
-
<SelectWrapper>
|
|
271
|
+
<SelectWrapper className={classnames(className, 'cap-unified-select-container')}>
|
|
93
272
|
{renderHeader()}
|
|
94
273
|
{renderDropdown()}
|
|
95
274
|
</SelectWrapper>
|
|
96
275
|
);
|
|
97
|
-
}
|
|
276
|
+
};
|
|
98
277
|
|
|
99
278
|
CapUnifiedSelect.propTypes = {
|
|
100
279
|
type: PropTypes.oneOf(['select', 'multiSelect', 'treeSelect', 'multiTreeSelect']),
|
|
101
280
|
options: PropTypes.array,
|
|
102
|
-
treeData: PropTypes.array,
|
|
103
281
|
value: PropTypes.any,
|
|
104
282
|
onChange: PropTypes.func,
|
|
105
283
|
placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
106
284
|
className: PropTypes.string,
|
|
107
285
|
style: PropTypes.object,
|
|
108
286
|
allowClear: PropTypes.bool,
|
|
109
|
-
|
|
110
|
-
label: PropTypes.string,
|
|
287
|
+
headerLabel: PropTypes.string,
|
|
111
288
|
tooltip: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
112
289
|
disabled: PropTypes.bool,
|
|
290
|
+
customPopupRender: PropTypes.bool,
|
|
291
|
+
showSearch: PropTypes.bool,
|
|
292
|
+
searchBasedOn: PropTypes.oneOf(['label', 'value', 'key']),
|
|
293
|
+
onConfirm: PropTypes.func,
|
|
294
|
+
onCancel: PropTypes.func,
|
|
295
|
+
isError: PropTypes.bool,
|
|
296
|
+
errorMessage: PropTypes.string,
|
|
297
|
+
popupClassName: PropTypes.string,
|
|
298
|
+
showUpload: PropTypes.bool,
|
|
113
299
|
};
|
|
114
300
|
|
|
115
301
|
CapUnifiedSelect.defaultProps = {
|
|
116
302
|
type: 'select',
|
|
117
303
|
allowClear: false,
|
|
118
|
-
|
|
304
|
+
customPopupRender: false,
|
|
305
|
+
showSearch: true,
|
|
306
|
+
searchBasedOn: 'label',
|
|
307
|
+
className: '',
|
|
308
|
+
popupClassName: '',
|
|
119
309
|
};
|
|
120
310
|
|
|
121
|
-
export default CapUnifiedSelect;
|
|
311
|
+
export default withStyles(CapUnifiedSelect, selectStyles);
|