@capillarytech/blaze-ui 0.1.6-alpha.52 → 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.
- package/CapUnifiedSelect/CapUnifiedSelect.js +391 -173
- package/CapUnifiedSelect/styles.js +11 -8
- package/package.json +1 -1
|
@@ -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,109 +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
|
-
<div className="cap-unified-select-header-byline-text">
|
|
195
|
-
{bylineText && <CapLabel className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-byline-text')}>{bylineText}</CapLabel>}
|
|
196
|
-
</div>
|
|
197
304
|
</>
|
|
198
305
|
);
|
|
199
306
|
}, [headerLabel, tooltip, bylineText, disabled]);
|
|
200
307
|
|
|
201
308
|
const renderDropdown = useCallback(() => {
|
|
202
309
|
const currentItems = filteredTree;
|
|
203
|
-
const selectedCount = Array.isArray(tempValue)
|
|
204
|
-
? isTree
|
|
205
|
-
?
|
|
206
|
-
: tempValue?.length || 0
|
|
207
|
-
:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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>
|
|
224
345
|
)}
|
|
225
|
-
|
|
226
|
-
<CapRow className={classnames("cap-unified-select-upload-container")} align="middle" onClick={onUpload}>
|
|
227
|
-
<CapIcon type="upload" size="s" style={{ color: styledVars.CAP_SECONDARY.base }}/>
|
|
228
|
-
<CapLabel type="label14" className={classnames("cap-unified-select-upload-label")}>Upload</CapLabel>
|
|
229
|
-
</CapRow>
|
|
230
|
-
)}
|
|
231
|
-
{isMulti && currentItems.length > 0 && (() => {
|
|
232
|
-
const totalAvailable = leafValues.length;
|
|
233
|
-
const selectedInScope = Array.isArray(tempValue)
|
|
234
|
-
? tempValue.filter(val => leafValues.includes(val)).length
|
|
235
|
-
: 0;
|
|
236
|
-
return (
|
|
346
|
+
{isMulti && showUpload && (
|
|
237
347
|
<CapRow
|
|
238
|
-
className={classnames(
|
|
348
|
+
className={classnames('cap-unified-select-upload-container')}
|
|
239
349
|
align="middle"
|
|
240
|
-
|
|
350
|
+
onClick={onUpload}
|
|
241
351
|
>
|
|
242
|
-
<
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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')}
|
|
249
360
|
>
|
|
250
|
-
|
|
251
|
-
</
|
|
361
|
+
Upload
|
|
362
|
+
</CapLabel>
|
|
252
363
|
</CapRow>
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
+
)}
|
|
257
419
|
|
|
258
|
-
|
|
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
|
-
|
|
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
|
+
);
|
|
287
466
|
|
|
288
467
|
return (
|
|
289
468
|
<>
|
|
@@ -292,14 +471,17 @@ const CapUnifiedSelect = ({
|
|
|
292
471
|
type={type}
|
|
293
472
|
treeData={filteredTree}
|
|
294
473
|
value={customPopupRender ? tempValue : value}
|
|
295
|
-
onChange={onChange}
|
|
474
|
+
onChange={customPopupRender ? handleTempChange : onChange}
|
|
296
475
|
placeholder={placeholder}
|
|
297
476
|
showSearch={false}
|
|
298
477
|
maxTagCount={0}
|
|
299
478
|
maxTagPlaceholder={() => null}
|
|
300
479
|
prefix={tempValue?.length > 0 ? prefix : undefined}
|
|
301
480
|
suffixIcon={suffix}
|
|
302
|
-
className={classnames(
|
|
481
|
+
className={classnames(
|
|
482
|
+
`cap-unified-tree-select cap-unified-tree-select-${size}`,
|
|
483
|
+
className,
|
|
484
|
+
)}
|
|
303
485
|
style={style}
|
|
304
486
|
status={isError ? 'error' : ''}
|
|
305
487
|
allowClear={allowClear}
|
|
@@ -314,13 +496,44 @@ const CapUnifiedSelect = ({
|
|
|
314
496
|
{...treeSelectVirtualizationProps}
|
|
315
497
|
popupRender={renderCustomDropdown}
|
|
316
498
|
/>
|
|
317
|
-
{isError &&
|
|
499
|
+
{isError && (
|
|
500
|
+
<CapLabel
|
|
501
|
+
className={classnames('cap-unified-select-status')}
|
|
502
|
+
style={{ color: 'red' }}
|
|
503
|
+
>
|
|
504
|
+
{errorMessage}
|
|
505
|
+
</CapLabel>
|
|
506
|
+
)}
|
|
318
507
|
</>
|
|
319
508
|
);
|
|
320
|
-
}, [
|
|
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
|
+
]);
|
|
321
532
|
|
|
322
533
|
return (
|
|
323
|
-
<SelectWrapper
|
|
534
|
+
<SelectWrapper
|
|
535
|
+
className={classnames(className, 'cap-unified-select-container')}
|
|
536
|
+
>
|
|
324
537
|
{renderHeader()}
|
|
325
538
|
{renderDropdown()}
|
|
326
539
|
</SelectWrapper>
|
|
@@ -328,7 +541,12 @@ const CapUnifiedSelect = ({
|
|
|
328
541
|
};
|
|
329
542
|
|
|
330
543
|
CapUnifiedSelect.propTypes = {
|
|
331
|
-
type: PropTypes.oneOf([
|
|
544
|
+
type: PropTypes.oneOf([
|
|
545
|
+
'select',
|
|
546
|
+
'multiSelect',
|
|
547
|
+
'treeSelect',
|
|
548
|
+
'multiTreeSelect',
|
|
549
|
+
]),
|
|
332
550
|
options: PropTypes.array,
|
|
333
551
|
value: PropTypes.any,
|
|
334
552
|
onChange: PropTypes.func,
|
|
@@ -371,7 +589,7 @@ CapUnifiedSelect.defaultProps = {
|
|
|
371
589
|
onUpload: () => {},
|
|
372
590
|
onChange: () => {},
|
|
373
591
|
onConfirm: () => {},
|
|
374
|
-
onCancel: () => {}
|
|
592
|
+
onCancel: () => {},
|
|
375
593
|
};
|
|
376
594
|
|
|
377
595
|
export default withStyles(CapUnifiedSelect, selectStyles);
|
|
@@ -232,7 +232,7 @@ export const selectStyles = css`
|
|
|
232
232
|
}
|
|
233
233
|
.ant-select.ant-select-focused.ant-select-outlined:not(.ant-select-disabled) .ant-select-selector {
|
|
234
234
|
border-color: #7A869A !important;
|
|
235
|
-
box-shadow:
|
|
235
|
+
box-shadow: none;
|
|
236
236
|
outline: 0;
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -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;
|
|
@@ -262,12 +262,12 @@ export const selectStyles = css`
|
|
|
262
262
|
font-family: ${styledVars.FONT_FAMILY};
|
|
263
263
|
font-weight: 400;
|
|
264
264
|
font-size: 12px;
|
|
265
|
-
margin-top: -
|
|
265
|
+
margin-top: -5px;
|
|
266
266
|
letter-spacing: 0px;
|
|
267
267
|
color: #97A0AF;
|
|
268
268
|
}
|
|
269
269
|
.ant-input-affix-wrapper .ant-input-prefix{
|
|
270
|
-
left:
|
|
270
|
+
left: 12px;
|
|
271
271
|
}
|
|
272
272
|
.ant-select-selection-item{
|
|
273
273
|
background: transparent;
|
|
@@ -370,18 +370,18 @@ export const selectStyles = css`
|
|
|
370
370
|
border: none;
|
|
371
371
|
box-shadow: none;
|
|
372
372
|
border-radius: 0;
|
|
373
|
+
border-bottom: 1px solid transparent;
|
|
374
|
+
transition: border-color 0.2s ease;
|
|
373
375
|
}
|
|
374
376
|
|
|
375
377
|
.ant-input-affix-wrapper:hover {
|
|
376
|
-
border:
|
|
378
|
+
border-bottom: 1px solid #7A869A !important;
|
|
377
379
|
box-shadow: none;
|
|
378
|
-
border-bottom: 1px solid #EBECF0;
|
|
379
380
|
}
|
|
380
381
|
|
|
381
382
|
.ant-input-affix-wrapper:focus-within {
|
|
382
|
-
border:
|
|
383
|
+
border-bottom: 1px solid #091E42 !important;
|
|
383
384
|
box-shadow: none;
|
|
384
|
-
border-bottom: 1px solid #091E42;
|
|
385
385
|
outline: none;
|
|
386
386
|
}
|
|
387
387
|
|
|
@@ -390,5 +390,8 @@ export const selectStyles = css`
|
|
|
390
390
|
box-shadow: none !important;
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
+
.cap-tooltip-with-info-icon{
|
|
394
|
+
margin-top: 2px;
|
|
395
|
+
}
|
|
393
396
|
}
|
|
394
397
|
`;
|
package/package.json
CHANGED