@capillarytech/blaze-ui 0.1.6-alpha.53 → 0.1.6-alpha.54
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.
|
@@ -41,117 +41,194 @@ const CapUnifiedSelect = ({
|
|
|
41
41
|
noResultCustomIcon = 'warning',
|
|
42
42
|
...rest
|
|
43
43
|
}) => {
|
|
44
|
-
|
|
45
44
|
const [searchText, setSearchText] = useState('');
|
|
46
45
|
const [tempValue, setTempValue] = useState(value);
|
|
47
|
-
const [allSelected, setAllSelected] = useState(false);
|
|
48
46
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
49
47
|
|
|
50
|
-
|
|
51
48
|
useEffect(() => {
|
|
52
49
|
setTempValue(value);
|
|
53
50
|
}, [value]);
|
|
54
51
|
|
|
55
|
-
const treeSelectVirtualizationProps =
|
|
56
|
-
|
|
52
|
+
const treeSelectVirtualizationProps = {
|
|
53
|
+
listHeight: 256,
|
|
57
54
|
listItemHeight: 32,
|
|
58
|
-
}
|
|
55
|
+
};
|
|
59
56
|
|
|
60
|
-
const NoResult =
|
|
61
|
-
<CapRow
|
|
62
|
-
className={classnames(className,
|
|
63
|
-
align="middle"
|
|
57
|
+
const NoResult = ({ noResultCustomText, className, showUpload, options }) => (
|
|
58
|
+
<CapRow
|
|
59
|
+
className={classnames(className, 'cap-unified-select-no-result')}
|
|
60
|
+
align="middle"
|
|
64
61
|
gap={8}
|
|
65
62
|
>
|
|
66
63
|
<CapIcon type={noResultCustomIcon} size="m" />
|
|
67
|
-
<CapLabel className="cap-unified-select-no-result-text">
|
|
64
|
+
<CapLabel className="cap-unified-select-no-result-text">
|
|
65
|
+
{showUpload && options?.length === 0
|
|
66
|
+
? noResultCustomText
|
|
67
|
+
: 'No results found'}
|
|
68
|
+
</CapLabel>
|
|
68
69
|
</CapRow>
|
|
69
|
-
)
|
|
70
|
+
);
|
|
70
71
|
|
|
71
|
-
const getFilteredTreeData = useCallback(
|
|
72
|
-
|
|
72
|
+
const getFilteredTreeData = useCallback(
|
|
73
|
+
(data, search) => {
|
|
74
|
+
if (!search || !data || data.length === 0) return data;
|
|
75
|
+
const searchLower = search.toLowerCase();
|
|
76
|
+
|
|
77
|
+
const filterNode = (node) => {
|
|
78
|
+
if (!node) return false;
|
|
79
|
+
|
|
80
|
+
let textToSearch = '';
|
|
81
|
+
|
|
82
|
+
if (searchBasedOn === 'value') {
|
|
83
|
+
textToSearch = String(node.value || '').toLowerCase();
|
|
84
|
+
} else if (searchBasedOn === 'key') {
|
|
85
|
+
textToSearch = String(node.key || '').toLowerCase();
|
|
86
|
+
} else {
|
|
87
|
+
textToSearch = String(node.label || node.title || '').toLowerCase();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return textToSearch.includes(searchLower);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const loop = (data) => {
|
|
94
|
+
if (!data) return [];
|
|
95
|
+
|
|
96
|
+
return data
|
|
97
|
+
.map((item) => {
|
|
98
|
+
if (!item) return null;
|
|
99
|
+
|
|
100
|
+
const children = item.children && item.children.length > 0
|
|
101
|
+
? loop(item.children)
|
|
102
|
+
: [];
|
|
103
|
+
|
|
104
|
+
if (filterNode(item) || children.length > 0) {
|
|
105
|
+
return { ...item, children };
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
})
|
|
109
|
+
.filter(Boolean);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return loop(data);
|
|
113
|
+
},
|
|
114
|
+
[searchBasedOn],
|
|
115
|
+
);
|
|
73
116
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const keyText = String(node?.key || '').toLowerCase();
|
|
81
|
-
return keyText.includes(search.toLowerCase());
|
|
82
|
-
} else {
|
|
83
|
-
const labelText = node?.label?.toLowerCase() || '';
|
|
84
|
-
return labelText.includes(search.toLowerCase());
|
|
85
|
-
}
|
|
117
|
+
const processTreeData = useCallback((nodes, selectedValues = null) => {
|
|
118
|
+
const result = {
|
|
119
|
+
leafValues: [],
|
|
120
|
+
parentChildMap: {},
|
|
121
|
+
nodeMap: {},
|
|
122
|
+
selectedCount: 0
|
|
86
123
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
|
|
125
|
+
if (!nodes) return result;
|
|
126
|
+
|
|
127
|
+
const traverse = (items) => {
|
|
128
|
+
items.forEach((item) => {
|
|
129
|
+
result.nodeMap[item.value] = item;
|
|
130
|
+
|
|
131
|
+
if (item.children && item.children.length > 0) {
|
|
132
|
+
result.parentChildMap[item.value] = item.children.map(
|
|
133
|
+
(child) => child.value
|
|
134
|
+
);
|
|
135
|
+
traverse(item.children);
|
|
136
|
+
} else {
|
|
137
|
+
result.leafValues.push(item.value);
|
|
93
138
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
traverse(nodes);
|
|
142
|
+
|
|
143
|
+
if (selectedValues && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
144
|
+
const expandedSet = new Set(selectedValues);
|
|
145
|
+
|
|
146
|
+
const processNode = (value) => {
|
|
147
|
+
const children = result.parentChildMap[value];
|
|
148
|
+
if (!children) return;
|
|
149
|
+
|
|
150
|
+
children.forEach((childValue) => {
|
|
151
|
+
expandedSet.add(childValue);
|
|
152
|
+
processNode(childValue);
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
selectedValues.forEach(processNode);
|
|
157
|
+
|
|
158
|
+
result.leafValues.forEach((value) => {
|
|
159
|
+
if (expandedSet.has(value)) result.selectedCount++;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return result;
|
|
164
|
+
}, []);
|
|
99
165
|
|
|
100
|
-
const
|
|
101
|
-
|
|
166
|
+
const isMulti = useMemo(
|
|
167
|
+
() => type === 'multiSelect' || type === 'multiTreeSelect',
|
|
168
|
+
[type],
|
|
169
|
+
);
|
|
170
|
+
const isTree = useMemo(
|
|
171
|
+
() => type === 'treeSelect' || type === 'multiTreeSelect',
|
|
172
|
+
[type],
|
|
173
|
+
);
|
|
102
174
|
|
|
103
|
-
const isMulti = useMemo(() => type === 'multiSelect' || type === 'multiTreeSelect', [type]);
|
|
104
|
-
const isTree = useMemo(() => type === 'treeSelect' || type === 'multiTreeSelect', [type]);
|
|
105
|
-
|
|
106
175
|
const dataSource = useMemo(() => {
|
|
107
|
-
|
|
176
|
+
// Skip transformation if options is empty or undefined
|
|
177
|
+
if (!options || options.length === 0) return [];
|
|
178
|
+
|
|
179
|
+
// Only transform if not a tree select
|
|
180
|
+
return isTree
|
|
181
|
+
? options
|
|
182
|
+
: options.map((opt) => ({
|
|
183
|
+
title: opt?.label,
|
|
184
|
+
value: opt?.value,
|
|
185
|
+
key: opt?.key || opt?.value,
|
|
186
|
+
}));
|
|
108
187
|
}, [isTree, options]);
|
|
109
188
|
|
|
110
|
-
const filteredTree = useMemo(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
setTempValue(availableValues);
|
|
120
|
-
setAllSelected(true);
|
|
121
|
-
}
|
|
122
|
-
}, [allSelected, leafValues]);
|
|
123
|
-
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
if (isMulti && Array.isArray(tempValue)) {
|
|
126
|
-
const allItemsSelected = tempValue.length > 0 && leafValues.length > 0 && tempValue.length === leafValues.length;
|
|
127
|
-
setAllSelected(allItemsSelected);
|
|
128
|
-
}
|
|
129
|
-
}, [tempValue, leafValues, isMulti]);
|
|
189
|
+
const filteredTree = useMemo(
|
|
190
|
+
() => {
|
|
191
|
+
// Skip filtering if search text is empty
|
|
192
|
+
if (!searchText) return dataSource;
|
|
193
|
+
|
|
194
|
+
return getFilteredTreeData(dataSource, searchText);
|
|
195
|
+
},
|
|
196
|
+
[dataSource, searchText, getFilteredTreeData],
|
|
197
|
+
);
|
|
130
198
|
|
|
131
199
|
const handleConfirm = useCallback(() => {
|
|
132
200
|
if (onChange) onChange(tempValue);
|
|
133
201
|
setDropdownOpen(false);
|
|
134
|
-
|
|
202
|
+
if (onConfirm) onConfirm(tempValue);
|
|
203
|
+
}, [onChange, onConfirm, tempValue]);
|
|
135
204
|
|
|
136
205
|
const handleCancel = useCallback(() => {
|
|
137
206
|
setTempValue(value);
|
|
138
207
|
setDropdownOpen(false);
|
|
139
|
-
|
|
208
|
+
if (onCancel) onCancel();
|
|
209
|
+
}, [value, onCancel]);
|
|
140
210
|
|
|
141
|
-
const handleTempChange = useCallback(newValue => {
|
|
211
|
+
const handleTempChange = useCallback((newValue) => {
|
|
142
212
|
setTempValue(newValue);
|
|
143
213
|
}, []);
|
|
144
214
|
|
|
145
|
-
const handleDropdownVisibilityChange = useCallback(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
215
|
+
const handleDropdownVisibilityChange = useCallback(
|
|
216
|
+
(open) => {
|
|
217
|
+
if (open === false && !customPopupRender) {
|
|
218
|
+
if (onChange) onChange(tempValue);
|
|
219
|
+
} else if (open === false) {
|
|
220
|
+
setTempValue(value);
|
|
221
|
+
}
|
|
222
|
+
setDropdownOpen(open);
|
|
223
|
+
},
|
|
224
|
+
[value, onChange, tempValue, customPopupRender],
|
|
225
|
+
);
|
|
151
226
|
|
|
152
227
|
const suffix = useMemo(() => {
|
|
153
228
|
const displayValue = dropdownOpen ? tempValue : value;
|
|
154
|
-
return isMulti &&
|
|
229
|
+
return isMulti &&
|
|
230
|
+
Array.isArray(displayValue) &&
|
|
231
|
+
displayValue?.length > 1 ? (
|
|
155
232
|
<>
|
|
156
233
|
<span>+{displayValue.length - 1} more </span>
|
|
157
234
|
<CapIcon type={`${dropdownOpen ? 'up' : 'down'}`} size="s" />
|
|
@@ -165,12 +242,15 @@ const CapUnifiedSelect = ({
|
|
|
165
242
|
if (isMulti) {
|
|
166
243
|
if (Array.isArray(tempValue) && tempValue?.length > 0) {
|
|
167
244
|
const firstSelectedValue = tempValue[0];
|
|
168
|
-
const firstSelectedOption = options?.find(
|
|
245
|
+
const firstSelectedOption = options?.find(
|
|
246
|
+
(opt) => opt?.value === firstSelectedValue,
|
|
247
|
+
);
|
|
169
248
|
return firstSelectedOption?.label || null;
|
|
170
|
-
}
|
|
171
|
-
else if (Array.isArray(value) && value?.length > 0) {
|
|
249
|
+
} else if (Array.isArray(value) && value?.length > 0) {
|
|
172
250
|
const firstSelectedValue = value[0];
|
|
173
|
-
const firstSelectedOption = options?.find(
|
|
251
|
+
const firstSelectedOption = options?.find(
|
|
252
|
+
(opt) => opt?.value === firstSelectedValue,
|
|
253
|
+
);
|
|
174
254
|
return firstSelectedOption?.label || null;
|
|
175
255
|
}
|
|
176
256
|
}
|
|
@@ -181,110 +261,208 @@ const CapUnifiedSelect = ({
|
|
|
181
261
|
if (!headerLabel && !tooltip) return null;
|
|
182
262
|
return (
|
|
183
263
|
<>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
264
|
+
<HeaderWrapper
|
|
265
|
+
className={classnames(
|
|
266
|
+
disabled ? 'disabled' : '',
|
|
267
|
+
'cap-unified-select-header',
|
|
268
|
+
)}
|
|
269
|
+
>
|
|
270
|
+
{headerLabel && (
|
|
271
|
+
<CapLabel
|
|
272
|
+
type="label16"
|
|
273
|
+
className={classnames(
|
|
274
|
+
disabled ? 'disabled' : '',
|
|
275
|
+
'cap-unified-select-header-label',
|
|
276
|
+
)}
|
|
277
|
+
>
|
|
278
|
+
{headerLabel}
|
|
279
|
+
</CapLabel>
|
|
280
|
+
)}
|
|
281
|
+
{tooltip && (
|
|
282
|
+
<CapTooltipWithInfo
|
|
283
|
+
title={tooltip}
|
|
284
|
+
className={classnames(
|
|
285
|
+
disabled ? 'disabled' : '',
|
|
286
|
+
'cap-unified-select-header-tooltip',
|
|
287
|
+
)}
|
|
288
|
+
iconProps={{ disabled }}
|
|
289
|
+
/>
|
|
290
|
+
)}
|
|
291
|
+
</HeaderWrapper>
|
|
292
|
+
{bylineText && (
|
|
293
|
+
<div className="cap-unified-select-header-byline-text">
|
|
294
|
+
<CapLabel
|
|
295
|
+
className={classnames(
|
|
296
|
+
disabled ? 'disabled' : '',
|
|
297
|
+
'cap-unified-select-header-byline-text',
|
|
298
|
+
)}
|
|
299
|
+
>
|
|
300
|
+
{bylineText}
|
|
301
|
+
</CapLabel>
|
|
302
|
+
</div>
|
|
192
303
|
)}
|
|
193
|
-
</HeaderWrapper>
|
|
194
|
-
{bylineText &&
|
|
195
|
-
<div className="cap-unified-select-header-byline-text">
|
|
196
|
-
<CapLabel className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-byline-text')}>{bylineText}</CapLabel>
|
|
197
|
-
</div>
|
|
198
|
-
}
|
|
199
304
|
</>
|
|
200
305
|
);
|
|
201
306
|
}, [headerLabel, tooltip, bylineText, disabled]);
|
|
202
307
|
|
|
203
308
|
const renderDropdown = useCallback(() => {
|
|
204
309
|
const currentItems = filteredTree;
|
|
205
|
-
const selectedCount = Array.isArray(tempValue)
|
|
206
|
-
? isTree
|
|
207
|
-
?
|
|
208
|
-
: tempValue?.length || 0
|
|
209
|
-
:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
310
|
+
const selectedCount = Array.isArray(tempValue)
|
|
311
|
+
? isTree
|
|
312
|
+
? processTreeData(dataSource, tempValue).selectedCount
|
|
313
|
+
: tempValue?.length || 0
|
|
314
|
+
: tempValue
|
|
315
|
+
? 1
|
|
316
|
+
: 0;
|
|
317
|
+
|
|
318
|
+
const renderCustomDropdown = useCallback(
|
|
319
|
+
(menu) => {
|
|
320
|
+
if (!customPopupRender) return menu;
|
|
321
|
+
|
|
322
|
+
return (
|
|
323
|
+
<div
|
|
324
|
+
className={classnames(popoverClassName, `${type}-popup-container`)}
|
|
325
|
+
>
|
|
326
|
+
{showSearch && (
|
|
327
|
+
<CapRow
|
|
328
|
+
className={classnames('cap-unified-select-search-container')}
|
|
329
|
+
align="middle"
|
|
330
|
+
>
|
|
331
|
+
<Input
|
|
332
|
+
prefix={
|
|
333
|
+
<CapIcon
|
|
334
|
+
type="search"
|
|
335
|
+
size="s"
|
|
336
|
+
style={{ color: styledVars.CAP_G06 }}
|
|
337
|
+
/>
|
|
338
|
+
}
|
|
339
|
+
placeholder="Search"
|
|
340
|
+
variant="borderless"
|
|
341
|
+
value={searchText}
|
|
342
|
+
onChange={(e) => setSearchText(e.target.value)}
|
|
343
|
+
/>
|
|
344
|
+
</CapRow>
|
|
226
345
|
)}
|
|
227
|
-
|
|
228
|
-
<CapRow className={classnames("cap-unified-select-upload-container")} align="middle" onClick={onUpload}>
|
|
229
|
-
<CapIcon type="upload" size="s" style={{ color: styledVars.CAP_SECONDARY.base }}/>
|
|
230
|
-
<CapLabel type="label14" className={classnames("cap-unified-select-upload-label")}>Upload</CapLabel>
|
|
231
|
-
</CapRow>
|
|
232
|
-
)}
|
|
233
|
-
{isMulti && currentItems.length > 0 && (() => {
|
|
234
|
-
const totalAvailable = leafValues.length;
|
|
235
|
-
const selectedInScope = Array.isArray(tempValue)
|
|
236
|
-
? tempValue.filter(val => leafValues.includes(val)).length
|
|
237
|
-
: 0;
|
|
238
|
-
return (
|
|
346
|
+
{isMulti && showUpload && (
|
|
239
347
|
<CapRow
|
|
240
|
-
className={classnames(
|
|
348
|
+
className={classnames('cap-unified-select-upload-container')}
|
|
241
349
|
align="middle"
|
|
350
|
+
onClick={onUpload}
|
|
242
351
|
>
|
|
243
|
-
<
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
352
|
+
<CapIcon
|
|
353
|
+
type="upload"
|
|
354
|
+
size="s"
|
|
355
|
+
style={{ color: styledVars.CAP_SECONDARY.base }}
|
|
356
|
+
/>
|
|
357
|
+
<CapLabel
|
|
358
|
+
type="label14"
|
|
359
|
+
className={classnames('cap-unified-select-upload-label')}
|
|
250
360
|
>
|
|
251
|
-
|
|
252
|
-
</
|
|
361
|
+
Upload
|
|
362
|
+
</CapLabel>
|
|
253
363
|
</CapRow>
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
364
|
+
)}
|
|
365
|
+
{isMulti &&
|
|
366
|
+
currentItems.length > 0 &&
|
|
367
|
+
(() => {
|
|
368
|
+
const { leafValues } = processTreeData(currentItems);
|
|
369
|
+
const totalAvailable = leafValues.length;
|
|
370
|
+
const selectedInScope = processTreeData(currentItems, tempValue).selectedCount;
|
|
371
|
+
|
|
372
|
+
return (
|
|
373
|
+
<CapRow
|
|
374
|
+
className={classnames(
|
|
375
|
+
'cap-unified-select-select-all-container',
|
|
376
|
+
)}
|
|
377
|
+
align="middle"
|
|
378
|
+
>
|
|
379
|
+
<Checkbox
|
|
380
|
+
className={classnames(
|
|
381
|
+
'cap-unified-select-select-all-checkbox',
|
|
382
|
+
)}
|
|
383
|
+
checked={
|
|
384
|
+
totalAvailable > 0 && selectedInScope === totalAvailable
|
|
385
|
+
}
|
|
386
|
+
indeterminate={
|
|
387
|
+
selectedInScope > 0 && selectedInScope < totalAvailable
|
|
388
|
+
}
|
|
389
|
+
onChange={(e) => {
|
|
390
|
+
setTempValue(e.target.checked ? leafValues : []);
|
|
391
|
+
}}
|
|
392
|
+
>
|
|
393
|
+
<CapLabel
|
|
394
|
+
type="label14"
|
|
395
|
+
className={classnames(
|
|
396
|
+
'cap-unified-select-select-all-label',
|
|
397
|
+
)}
|
|
398
|
+
>
|
|
399
|
+
Select all
|
|
400
|
+
</CapLabel>
|
|
401
|
+
</Checkbox>
|
|
402
|
+
</CapRow>
|
|
403
|
+
);
|
|
404
|
+
})()}
|
|
405
|
+
|
|
406
|
+
{currentItems.length === 0 ? (
|
|
407
|
+
<NoResult
|
|
408
|
+
noResultCustomText={noResultCustomText}
|
|
409
|
+
className={classnames(
|
|
410
|
+
className,
|
|
411
|
+
'cap-unified-select-no-result',
|
|
412
|
+
)}
|
|
413
|
+
showUpload={showUpload}
|
|
414
|
+
options={options}
|
|
415
|
+
/>
|
|
416
|
+
) : (
|
|
417
|
+
menu
|
|
418
|
+
)}
|
|
258
419
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
420
|
+
{currentItems.length > 0 && isMulti && (
|
|
421
|
+
<div className="cap-unified-select-confirm-container">
|
|
422
|
+
<div className="cap-unified-select-confirm-button-group">
|
|
423
|
+
<Button
|
|
424
|
+
type="primary"
|
|
425
|
+
size="small"
|
|
426
|
+
className="cap-unified-select-confirm-button"
|
|
427
|
+
onClick={handleConfirm}
|
|
428
|
+
>
|
|
429
|
+
Confirm
|
|
430
|
+
</Button>
|
|
431
|
+
<Button
|
|
432
|
+
type="text"
|
|
433
|
+
className="cap-unified-select-cancel-button"
|
|
434
|
+
size="small"
|
|
435
|
+
onClick={handleCancel}
|
|
436
|
+
>
|
|
437
|
+
Cancel
|
|
438
|
+
</Button>
|
|
439
|
+
<CapLabel className="cap-unified-select-selected-count">
|
|
440
|
+
{selectedCount} selected
|
|
441
|
+
</CapLabel>
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
)}
|
|
445
|
+
</div>
|
|
446
|
+
);
|
|
447
|
+
},
|
|
448
|
+
[
|
|
449
|
+
customPopupRender,
|
|
450
|
+
popoverClassName,
|
|
451
|
+
type,
|
|
452
|
+
showSearch,
|
|
453
|
+
searchText,
|
|
454
|
+
isMulti,
|
|
455
|
+
showUpload,
|
|
456
|
+
currentItems,
|
|
457
|
+
tempValue,
|
|
458
|
+
className,
|
|
459
|
+
noResultCustomText,
|
|
460
|
+
onUpload,
|
|
461
|
+
handleConfirm,
|
|
462
|
+
handleCancel,
|
|
463
|
+
processTreeData,
|
|
464
|
+
],
|
|
465
|
+
);
|
|
288
466
|
|
|
289
467
|
return (
|
|
290
468
|
<>
|
|
@@ -293,14 +471,17 @@ const CapUnifiedSelect = ({
|
|
|
293
471
|
type={type}
|
|
294
472
|
treeData={filteredTree}
|
|
295
473
|
value={customPopupRender ? tempValue : value}
|
|
296
|
-
onChange={onChange}
|
|
474
|
+
onChange={customPopupRender ? handleTempChange : onChange}
|
|
297
475
|
placeholder={placeholder}
|
|
298
476
|
showSearch={false}
|
|
299
477
|
maxTagCount={0}
|
|
300
478
|
maxTagPlaceholder={() => null}
|
|
301
479
|
prefix={tempValue?.length > 0 ? prefix : undefined}
|
|
302
480
|
suffixIcon={suffix}
|
|
303
|
-
className={classnames(
|
|
481
|
+
className={classnames(
|
|
482
|
+
`cap-unified-tree-select cap-unified-tree-select-${size}`,
|
|
483
|
+
className,
|
|
484
|
+
)}
|
|
304
485
|
style={style}
|
|
305
486
|
status={isError ? 'error' : ''}
|
|
306
487
|
allowClear={allowClear}
|
|
@@ -315,13 +496,44 @@ const CapUnifiedSelect = ({
|
|
|
315
496
|
{...treeSelectVirtualizationProps}
|
|
316
497
|
popupRender={renderCustomDropdown}
|
|
317
498
|
/>
|
|
318
|
-
{isError &&
|
|
499
|
+
{isError && (
|
|
500
|
+
<CapLabel
|
|
501
|
+
className={classnames('cap-unified-select-status')}
|
|
502
|
+
style={{ color: 'red' }}
|
|
503
|
+
>
|
|
504
|
+
{errorMessage}
|
|
505
|
+
</CapLabel>
|
|
506
|
+
)}
|
|
319
507
|
</>
|
|
320
508
|
);
|
|
321
|
-
}, [
|
|
509
|
+
}, [
|
|
510
|
+
filteredTree,
|
|
511
|
+
tempValue,
|
|
512
|
+
value,
|
|
513
|
+
prefix,
|
|
514
|
+
suffix,
|
|
515
|
+
className,
|
|
516
|
+
style,
|
|
517
|
+
isError,
|
|
518
|
+
errorMessage,
|
|
519
|
+
allowClear,
|
|
520
|
+
isMulti,
|
|
521
|
+
isTree,
|
|
522
|
+
dropdownOpen,
|
|
523
|
+
customPopupRender,
|
|
524
|
+
handleTempChange,
|
|
525
|
+
onChange,
|
|
526
|
+
disabled,
|
|
527
|
+
handleDropdownVisibilityChange,
|
|
528
|
+
treeSelectVirtualizationProps,
|
|
529
|
+
dataSource,
|
|
530
|
+
processTreeData,
|
|
531
|
+
]);
|
|
322
532
|
|
|
323
533
|
return (
|
|
324
|
-
<SelectWrapper
|
|
534
|
+
<SelectWrapper
|
|
535
|
+
className={classnames(className, 'cap-unified-select-container')}
|
|
536
|
+
>
|
|
325
537
|
{renderHeader()}
|
|
326
538
|
{renderDropdown()}
|
|
327
539
|
</SelectWrapper>
|
|
@@ -329,7 +541,12 @@ const CapUnifiedSelect = ({
|
|
|
329
541
|
};
|
|
330
542
|
|
|
331
543
|
CapUnifiedSelect.propTypes = {
|
|
332
|
-
type: PropTypes.oneOf([
|
|
544
|
+
type: PropTypes.oneOf([
|
|
545
|
+
'select',
|
|
546
|
+
'multiSelect',
|
|
547
|
+
'treeSelect',
|
|
548
|
+
'multiTreeSelect',
|
|
549
|
+
]),
|
|
333
550
|
options: PropTypes.array,
|
|
334
551
|
value: PropTypes.any,
|
|
335
552
|
onChange: PropTypes.func,
|
|
@@ -372,7 +589,7 @@ CapUnifiedSelect.defaultProps = {
|
|
|
372
589
|
onUpload: () => {},
|
|
373
590
|
onChange: () => {},
|
|
374
591
|
onConfirm: () => {},
|
|
375
|
-
onCancel: () => {}
|
|
592
|
+
onCancel: () => {},
|
|
376
593
|
};
|
|
377
594
|
|
|
378
595
|
export default withStyles(CapUnifiedSelect, selectStyles);
|
|
@@ -243,7 +243,7 @@ export const selectStyles = css`
|
|
|
243
243
|
margin-top: -8px !important;
|
|
244
244
|
border-radius: 4px;
|
|
245
245
|
box-shadow: 0px 4px 8px -2px #091E4240, 0px 0px 1px 0px #091E424F;
|
|
246
|
-
max-height:
|
|
246
|
+
max-height: 360px;
|
|
247
247
|
}
|
|
248
248
|
.ant-select-prefix{
|
|
249
249
|
font-size: 14px;
|
package/package.json
CHANGED