@capillarytech/blaze-ui 0.1.6-alpha.67 → 0.1.6-alpha.8

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.
Files changed (104) hide show
  1. package/CapHeading/CapHeading.js +71 -0
  2. package/CapHeading/index.js +1 -0
  3. package/CapHeading/styles.js +125 -0
  4. package/CapInfoNote/CapInfoNote.js +54 -0
  5. package/CapInfoNote/index.js +1 -0
  6. package/CapInfoNote/styles.js +63 -0
  7. package/CapInput/CapInput.js +2 -2
  8. package/CapInput/Number.js +1 -1
  9. package/CapInput/Search.js +1 -1
  10. package/CapInput/TextArea.js +1 -1
  11. package/CapInput/loadable.js +9 -0
  12. package/CapInput/styles.js +2 -2
  13. package/CapLabel/CapLabel.js +81 -58
  14. package/CapLabel/index.js +1 -3
  15. package/CapLabel/styles.js +212 -250
  16. package/CapRow/CapRow.js +10 -111
  17. package/CapRow/index.js +1 -3
  18. package/CapRow/styles.js +6 -47
  19. package/CapTable/loadable.js +4 -4
  20. package/CapTable/styles.js +6 -6
  21. package/CapTooltip/CapTooltip.js +25 -87
  22. package/CapTooltip/index.js +1 -3
  23. package/CapTooltip/styles.js +27 -19
  24. package/CapUnifiedSelect/CapUnifiedSelect.js +77 -495
  25. package/CapUnifiedSelect/index.js +4 -1
  26. package/CapUnifiedSelect/loadable.js +3 -0
  27. package/CapUnifiedSelect/styles.js +165 -376
  28. package/dist/235.index.js +2 -0
  29. package/dist/235.index.js.LICENSE.txt +29 -0
  30. package/dist/603.index.js +1 -0
  31. package/dist/CapInput/CapInput.js +66 -0
  32. package/dist/CapInput/Number.js +42 -0
  33. package/dist/CapInput/Search.js +35 -0
  34. package/dist/CapInput/TextArea.js +42 -0
  35. package/dist/CapInput/index.js +15 -0
  36. package/dist/CapInput/messages.js +32 -0
  37. package/dist/CapInput/styles.js +11 -0
  38. package/dist/CapTable/CapTable.js +148 -0
  39. package/dist/CapTable/index.js +9 -0
  40. package/dist/CapTable/loadable.js +23 -0
  41. package/dist/CapTable/styles.js +26 -0
  42. package/dist/LocaleHoc/index.js +40 -0
  43. package/dist/esm/CapHeading/CapHeading.js +41 -0
  44. package/dist/esm/CapHeading/index.js +1 -0
  45. package/dist/esm/CapHeading/styles.js +123 -0
  46. package/dist/esm/CapInfoNote/CapInfoNote.js +62 -0
  47. package/dist/esm/CapInfoNote/index.js +1 -0
  48. package/dist/esm/CapInfoNote/styles.js +6 -0
  49. package/dist/esm/CapInput/CapInput.js +57 -0
  50. package/dist/esm/CapInput/Number.js +35 -0
  51. package/dist/esm/CapInput/Search.js +28 -0
  52. package/dist/esm/CapInput/TextArea.js +35 -0
  53. package/dist/esm/CapInput/index.js +8 -0
  54. package/dist/esm/CapInput/loadable.js +9 -0
  55. package/dist/esm/CapInput/messages.js +25 -0
  56. package/dist/esm/CapInput/styles.js +3 -0
  57. package/dist/esm/CapLabel/CapLabel.js +50 -0
  58. package/dist/esm/CapLabel/index.js +1 -0
  59. package/dist/esm/CapLabel/styles.js +219 -0
  60. package/dist/esm/CapRow/CapRow.js +22 -0
  61. package/dist/esm/CapRow/index.js +1 -0
  62. package/dist/esm/CapRow/styles.js +5 -0
  63. package/dist/esm/CapTable/CapTable.js +140 -0
  64. package/dist/esm/CapTable/index.js +2 -0
  65. package/dist/esm/CapTable/loadable.js +12 -0
  66. package/dist/esm/CapTable/styles.js +17 -0
  67. package/dist/esm/CapTooltip/CapTooltip.js +34 -0
  68. package/dist/esm/CapTooltip/index.js +1 -0
  69. package/dist/esm/CapTooltip/styles.js +6 -0
  70. package/dist/esm/CapUnifiedSelect/CapUnifiedSelect.js +101 -0
  71. package/dist/esm/CapUnifiedSelect/index.js +3 -0
  72. package/dist/esm/CapUnifiedSelect/loadable.js +4 -0
  73. package/dist/esm/CapUnifiedSelect/messages.js +23 -0
  74. package/dist/esm/CapUnifiedSelect/styles.js +15 -0
  75. package/dist/esm/LocaleHoc/index.js +31 -0
  76. package/dist/esm/index.js +11 -0
  77. package/dist/esm/styled/index.js +5 -0
  78. package/dist/esm/styled/variables.js +88 -0
  79. package/dist/esm/translations/en.js +329 -0
  80. package/dist/index.js +39 -0
  81. package/dist/index.js.LICENSE.txt +7 -0
  82. package/dist/styled/index.js +22 -0
  83. package/dist/styled/variables.js +94 -0
  84. package/dist/translations/en.js +335 -0
  85. package/index.js +1 -12
  86. package/package.json +12 -6
  87. package/styled/variables.js +0 -2
  88. package/.DS_Store +0 -0
  89. package/CapIcon/CapIcon.js +0 -183
  90. package/CapIcon/index.js +0 -3
  91. package/CapIcon/styles.js +0 -76
  92. package/CapSkeleton/CapSkeleton.js +0 -17
  93. package/CapSkeleton/index.js +0 -1
  94. package/CapSpin/CapSpin.js +0 -23
  95. package/CapSpin/index.js +0 -1
  96. package/CapTestSelect/CapTestSelect.js +0 -47
  97. package/CapTestSelect/index.js +0 -1
  98. package/CapTooltipWithInfo/CapTooltipWithInfo.js +0 -74
  99. package/CapTooltipWithInfo/index.js +0 -3
  100. package/CapTooltipWithInfo/styles.js +0 -22
  101. package/assets/upload.svg +0 -3
  102. package/utils/index.js +0 -1
  103. package/utils/withMemo.js +0 -33
  104. package/utils/withStyles.js +0 -24
@@ -1,539 +1,121 @@
1
- import React, { useState, useEffect, useMemo, useCallback, memo } from 'react';
1
+ // CapUnifiedSelect component using Ant Design v5 Select and TreeSelect directly
2
+ import React from 'react';
2
3
  import PropTypes from 'prop-types';
3
- import classnames from 'classnames';
4
- import { TreeSelect, Input, Button, Checkbox } from 'antd-v5';
5
- import styled from 'styled-components';
6
- import * as styledVars from '../styled/variables';
7
- import { CapLabel, CapTooltipWithInfo, CapRow, CapIcon, CapTooltip } from '../';
8
- import withStyles from '../utils/withStyles';
9
- import withMemo from '../utils/withMemo';
10
- import { HeaderWrapper, selectStyles } from './styles';
4
+ import { Select, TreeSelect } from 'antd';
5
+ import { SelectWrapper, HeaderWrapper, StyledInfoIcon } from './styles';
6
+ import CapLabel from '../CapLabel';
7
+ import CapTooltip from '../CapTooltip';
11
8
 
12
- const SELECT_TYPES = {
13
- SELECT: 'select',
14
- MULTI_SELECT: 'multiSelect',
15
- TREE_SELECT: 'treeSelect',
16
- MULTI_TREE_SELECT: 'multiTreeSelect'
17
- };
18
-
19
- const StyledTreeSelect = styled(TreeSelect)`
20
- ${selectStyles}
21
- `;
22
-
23
- const NoResult = memo(({ noResultCustomText, className, showUpload, options, noResultCustomIcon }) => (
24
- <CapRow
25
- className={classnames(className, 'cap-unified-select-no-result')}
26
- align="middle"
27
- gap={8}
28
- >
29
- <CapIcon type={noResultCustomIcon} size="m" />
30
- <CapLabel className="cap-unified-select-no-result-text">
31
- {showUpload && options?.length === 0
32
- ? noResultCustomText
33
- : 'No results found'}
34
- </CapLabel>
35
- </CapRow>
36
- ));
37
-
38
- const SelectAllCheckbox = memo(({ currentItems, tempValue, setTempValue, processTreeData }) => {
39
- const { leafValues = [] } = processTreeData ? processTreeData(currentItems) : {};
40
- const totalAvailable = leafValues.length;
41
- const leafSet = new Set(leafValues);
42
- const selectedInScope = Array.isArray(tempValue)
43
- ? tempValue.filter((v) => leafSet.has(v)).length
44
- : 0;
45
-
46
- const allChecked = totalAvailable > 0 && selectedInScope === totalAvailable;
47
- const indeterminate = selectedInScope > 0 && selectedInScope < totalAvailable;
48
-
49
- const handleChange = (e) => {
50
- if (e.target.checked) {
51
- const merged = new Set(Array.isArray(tempValue) ? tempValue : []);
52
- leafValues.forEach((v) => merged.add(v));
53
- setTempValue(Array.from(merged));
54
- } else {
55
- const toRemove = new Set(leafValues);
56
- const next = (Array.isArray(tempValue) ? tempValue : []).filter(
57
- (v) => !toRemove.has(v)
58
- );
59
- setTempValue(next);
60
- }
61
- };
62
-
63
- return (
64
- <CapRow className="cap-unified-select-select-all-container" align="middle">
65
- <Checkbox
66
- className="cap-unified-select-select-all-checkbox"
67
- checked={allChecked}
68
- indeterminate={indeterminate}
69
- onChange={handleChange}
70
- >
71
- <CapLabel type="label14" className="cap-unified-select-select-all-label">Select all</CapLabel>
72
- </Checkbox>
73
- </CapRow>
74
- );
75
- });
76
-
77
- const buildTreeMaps = (nodes) => {
78
- const result = {
79
- leafValues: [],
80
- parentChildMap: {},
81
- nodeMap: {},
82
- };
83
- if (!nodes) return result;
84
-
85
- const traverse = (items) => {
86
- items?.forEach((item) => {
87
- result.nodeMap[item.value] = item;
88
- if (item?.children && item.children.length > 0) {
89
- result.parentChildMap[item.value] = item.children.map(child => child?.value);
90
- traverse(item.children);
91
- } else {
92
- result.leafValues.push(item.value);
93
- }
94
- });
95
- };
96
- traverse(nodes);
97
- return result;
98
- };
99
-
100
- const countSelectedLeaves = (treeMaps, selectedValues) => {
101
- if (!Array.isArray(selectedValues) || !selectedValues?.length) return 0;
102
- const expandedSet = new Set(selectedValues);
103
- const processNode = (value) => {
104
- const children = treeMaps?.parentChildMap?.[value];
105
- if (!children) return;
106
- children?.forEach(childValue => {
107
- expandedSet.add(childValue);
108
- processNode(childValue);
109
- });
110
- };
111
- selectedValues?.forEach(processNode);
112
- return treeMaps?.leafValues?.reduce((count, leaf) => expandedSet.has(leaf) ? count + 1 : count, 0) || 0;
113
- };
114
-
115
- const filterTreeData = (data, search, searchBasedOn) => {
116
- if (!data?.length || !search) return data;
117
- const searchLower = search.toLowerCase();
118
- const nodeMatchesSearch = (node) => {
119
- const target = searchBasedOn === 'value'
120
- ? String(node?.value ?? '')
121
- : searchBasedOn === 'key'
122
- ? String(node?.key ?? '')
123
- : String(node?.label ?? node?.title ?? '');
124
- return target.toLowerCase().includes(searchLower);
125
- };
126
- const loop = (items) =>
127
- items.reduce((acc, item) => {
128
- if (!item) return acc;
129
- const children = item?.children?.length ? loop(item.children) : [];
130
- if (nodeMatchesSearch(item) || children.length) {
131
- acc.push({ ...item, children });
132
- }
133
- return acc;
134
- }, []);
135
- return loop(data);
136
- };
137
-
138
- const CapUnifiedSelect = ({
9
+ function CapUnifiedSelect({
139
10
  type,
140
11
  options = [],
12
+ treeData,
141
13
  value,
142
14
  onChange,
143
- placeholder,
15
+ placeholder = 'Select an option',
144
16
  className,
145
17
  style,
146
- isError,
147
- errorMessage,
148
- containerClassName,
149
- popoverClassName,
150
- allowClear,
151
- headerLabel,
152
- onUpload,
18
+ allowClear = false,
19
+ showSearch = false,
20
+ label,
153
21
  tooltip,
154
- bylineText,
155
- disabled,
156
- showUpload,
157
- customPopupRender,
158
- showSearch,
159
- readOnly,
160
- searchBasedOn,
161
- onConfirm,
162
- clearText,
163
- noResultCustomText,
164
- noResultCustomIcon,
165
- ...rest
166
- }) => {
167
- const [searchText, setSearchText] = useState('');
168
- const [tempValue, setTempValue] = useState(value);
169
- const [dropdownOpen, setDropdownOpen] = useState(false);
170
-
171
- useEffect(() => {
172
- const isEqual = Array.isArray(value) && Array.isArray(tempValue)
173
- ? value?.length === tempValue?.length && value.every((v) => tempValue.includes(v))
174
- : value === tempValue;
175
- if (!isEqual) setTempValue(value);
176
- }, [value]);
177
-
178
- const isMulti = useMemo(() => type === SELECT_TYPES.MULTI_SELECT || type === SELECT_TYPES.MULTI_TREE_SELECT, [type]);
179
- const isTree = useMemo(() => type === SELECT_TYPES.TREE_SELECT || type === SELECT_TYPES.MULTI_TREE_SELECT, [type]);
180
-
181
- const dataSource = useMemo(() => {
182
- if (!options?.length) return [];
183
- const enhanceOptions = (opts) =>
184
- opts.map((opt) => {
185
- const decoratedTitle = (
186
- <CapRow className="cap-unified-select-option-with-suffix">
187
- <CapLabel type="label14" className="cap-unified-select-option-label">{opt?.label}</CapLabel>
188
- {opt?.optionSuffix && <div className="cap-unified-select-option-suffix">
189
- {opt?.optionSuffix} {opt?.optionSuffixInfo && <CapTooltipWithInfo title={opt?.optionSuffixInfo} />}
190
- </div>}
191
- {opt?.optionTooltipInfo && <CapTooltipWithInfo title={opt?.optionTooltipInfo} />}
192
- </CapRow>
193
- );
194
-
195
- return {
196
- ...opt,
197
- title: decoratedTitle,
198
- label: opt?.label,
199
- children: opt?.children ? enhanceOptions(opt.children) : [],
200
- };
201
- });
202
-
203
- return isTree ? enhanceOptions(options) : options.map((opt) => ({
204
- ...opt,
205
- title: (
206
- <CapRow className="cap-unified-select-option-with-suffix">
207
- <CapLabel type="label14" className="cap-unified-select-option-label">{opt?.label}</CapLabel>
208
- {opt?.optionSuffix && <div className="cap-unified-select-option-suffix">
209
- {opt?.optionSuffix} {opt?.optionSuffixInfo && <CapTooltipWithInfo title={opt?.optionSuffixInfo} />}
210
- </div>}
211
- {opt?.optionTooltipInfo && <CapTooltipWithInfo title={opt?.optionTooltipInfo} />}
212
- </CapRow>
213
- ),
214
- label: opt?.label,
215
- }));
216
- }, [isTree, options]);
217
-
218
- const filteredTree = useMemo(
219
- () => filterTreeData(dataSource, searchText, searchBasedOn),
220
- [dataSource, searchText, searchBasedOn]
221
- );
222
-
223
- const treeMaps = useMemo(() => buildTreeMaps(options), [options]);
224
- const selectedLeafCount = useMemo(() => countSelectedLeaves(treeMaps, tempValue), [treeMaps, tempValue]);
22
+ disabled = false,
23
+ }) {
24
+ const selectVirtualizationProps = {
25
+ listHeight: 256,
26
+ };
225
27
 
226
- const displayValue = dropdownOpen ? tempValue : value;
28
+ const treeSelectVirtualizationProps = {
29
+ listHeight: 256,
30
+ listItemHeight: 32,
31
+ };
227
32
 
228
- const suffix = useMemo(() => {
229
- const count = Array.isArray(displayValue) ? displayValue?.length : (displayValue ? 1 : 0);
230
- const renderTooltipTitle = (values) => {
231
- return (
232
- <div className="cap-unified-select-more-tooltip-content">
233
- {values.map((val, idx) => (
234
- <div key={idx}>{val}</div>
235
- ))}
236
- </div>
237
- );
238
- };
33
+ const renderHeader = () => {
34
+ if (!label && !tooltip) return null;
239
35
 
240
36
  return (
241
- <>
242
- {isMulti && count > 1 && (
243
- <span className="cap-unified-select-more-text">
244
- <CapTooltip
245
- title={renderTooltipTitle(displayValue.slice(1))}
246
- placement="bottom"
247
- overlayClassName="cap-unified-select-more-tooltip"
248
- arrowPointAtCenter={true}
249
- >
250
- <span>+{count - 1} more</span>
251
- </CapTooltip>
252
- </span>
37
+ <HeaderWrapper className={disabled ? 'disabled' : ''}>
38
+ {label && (
39
+ <CapLabel type="label16" className={disabled ? 'disabled' : ''}>
40
+ {label}
41
+ </CapLabel>
253
42
  )}
254
- <CapIcon
255
- className="cap-unified-select-suffix-icon"
256
- type={dropdownOpen ? 'up' : 'down'}
257
- size="s"
258
- />
259
- </>
260
- );
261
- }, [isMulti, displayValue, dropdownOpen]);
262
-
263
- const prefix = useMemo(() => {
264
- if (isMulti && Array.isArray(displayValue) && displayValue?.length > 0) {
265
- const firstLeafValue = displayValue.find(val => treeMaps?.leafValues?.includes(val));
266
- return treeMaps?.nodeMap?.[firstLeafValue]?.label || null;
267
- }
268
- return null;
269
- }, [isMulti, displayValue, treeMaps]);
270
-
271
- const handleConfirm = useCallback(() => {
272
- onChange?.(tempValue);
273
- setDropdownOpen(false);
274
- setSearchText('');
275
- onConfirm?.(tempValue);
276
- }, [onChange, onConfirm, tempValue]);
277
-
278
- const handleClearAll = useCallback(() => {
279
- const cleared = isMulti ? [] : undefined;
280
- setTempValue(cleared);
281
- onChange?.(cleared);
282
- setDropdownOpen(false);
283
- }, [isMulti, onChange]);
284
-
285
-
286
- const handleDropdownVisibilityChange = useCallback((open) => {
287
- if (readOnly) {
288
- return;
289
- }
290
- if (!open && !customPopupRender) {
291
- onChange?.(tempValue);
292
- } else if (!open) {
293
- setTempValue(value);
294
- }
295
- setDropdownOpen(open);
296
- }, [customPopupRender, value, onChange, tempValue, readOnly]);
297
-
298
- const renderHeader = useMemo(() => {
299
- if (!headerLabel && !tooltip) return null;
300
- return (
301
- <>
302
- <HeaderWrapper className={classnames(disabled && 'disabled', 'cap-unified-select-header')}>
303
- {headerLabel && (
304
- <CapLabel
305
- type="label16"
306
- className={classnames(disabled && 'disabled', 'cap-unified-select-header-label')}
307
- >
308
- {headerLabel}
309
- </CapLabel>
310
- )}
311
- {tooltip && (
312
- <CapTooltipWithInfo
313
- title={tooltip}
314
- className={classnames(disabled && 'disabled', 'cap-unified-select-header-tooltip')}
315
- iconProps={{ disabled }}
316
- />
317
- )}
318
- </HeaderWrapper>
319
- {bylineText && (
320
- <div className="cap-unified-select-header-byline-text">
321
- <CapLabel
322
- className={classnames(disabled && 'disabled', 'cap-unified-select-header-byline-text')}
323
- >
324
- {bylineText}
325
- </CapLabel>
326
- </div>
43
+ {tooltip && (
44
+ <CapTooltip title={tooltip}>
45
+ <StyledInfoIcon className={disabled ? 'disabled' : ''} />
46
+ </CapTooltip>
327
47
  )}
328
- </>
48
+ </HeaderWrapper>
329
49
  );
330
- }, [headerLabel, tooltip, bylineText, disabled]);
331
-
332
- const renderCustomDropdown = useCallback(
333
- (menu) => {
334
- if (!customPopupRender) return menu;
335
- const currentItems = filteredTree;
50
+ };
336
51
 
52
+ const renderDropdown = () => {
53
+ if (type === 'treeSelect' || type === 'multiTreeSelect') {
337
54
  return (
338
- <div className={classnames(popoverClassName, `${type}-popup-container`)}>
339
- {showSearch && (
340
- <CapRow className="cap-unified-select-search-container" align="middle">
341
- <Input
342
- prefix={<CapIcon type="search" size="s" style={{ color: styledVars.CAP_G06 }} />}
343
- placeholder="Search"
344
- variant="borderless"
345
- value={searchText}
346
- onChange={(e) => setSearchText(e.target.value)}
347
- allowClear
348
- />
349
- </CapRow>
350
- )}
351
-
352
- {isMulti && showUpload && (
353
- <CapRow className="cap-unified-select-upload-container" align="middle" onClick={onUpload}>
354
- <CapIcon type="upload" size="s" style={{ color: styledVars.CAP_SECONDARY.base }} />
355
- <CapLabel type="label14" className="cap-unified-select-upload-label">Upload</CapLabel>
356
- </CapRow>
357
- )}
358
-
359
- {isMulti && currentItems.length > 0 && (
360
- <SelectAllCheckbox
361
- currentItems={currentItems}
362
- tempValue={tempValue}
363
- setTempValue={setTempValue}
364
- processTreeData={buildTreeMaps}
365
- />
366
- )}
367
-
368
- {currentItems.length === 0 ? (
369
- <NoResult
370
- noResultCustomText={noResultCustomText}
371
- className={className}
372
- showUpload={showUpload}
373
- options={options}
374
- noResultCustomIcon={noResultCustomIcon}
375
- />
376
- ) : (
377
- menu
378
- )}
379
-
380
- {currentItems.length > 0 && isMulti && (
381
- <div className="cap-unified-select-confirm-container">
382
- <div className="cap-unified-select-confirm-button-group">
383
- <Button
384
- type="primary"
385
- size="small"
386
- className="cap-unified-select-confirm-button"
387
- onClick={handleConfirm}
388
- >
389
- Confirm
390
- </Button>
391
- <Button
392
- type="text"
393
- className="cap-unified-select-cancel-button"
394
- size="small"
395
- onClick={handleClearAll}
396
- >
397
- {clearText}
398
- </Button>
399
- <CapLabel className="cap-unified-select-selected-count">
400
- {selectedLeafCount} selected
401
- </CapLabel>
402
- </div>
403
- </div>
404
- )}
405
-
406
- {(type === SELECT_TYPES.SELECT || type === SELECT_TYPES.TREE_SELECT) && (
407
- <CapRow className="cap-unified-select-tree-clear-container" onClick={handleClearAll}>
408
- <CapLabel className="cap-unified-select-tree-clear-label">{clearText}</CapLabel>
409
- </CapRow>
410
- )}
411
- </div>
55
+ <TreeSelect
56
+ treeData={treeData || options}
57
+ value={value}
58
+ onChange={onChange}
59
+ placeholder={placeholder}
60
+ className={className}
61
+ style={style}
62
+ allowClear={allowClear}
63
+ showSearch={showSearch}
64
+ multiple={type === 'multiTreeSelect' ? true : false}
65
+ virtual
66
+ treeDefaultExpandAll
67
+ disabled={disabled}
68
+ {...treeSelectVirtualizationProps}
69
+ />
412
70
  );
413
- },
414
- [
415
- customPopupRender,
416
- filteredTree,
417
- searchText,
418
- isMulti,
419
- showUpload,
420
- onUpload,
421
- noResultCustomText,
422
- noResultCustomIcon,
423
- options,
424
- type,
425
- tempValue,
426
- handleConfirm,
427
- handleClearAll,
428
- popoverClassName,
429
- className,
430
- selectedLeafCount,
431
- ]
432
- );
433
-
434
- const combinedClassName = useMemo(
435
- () => classnames(
436
- containerClassName,
437
- 'cap-unified-tree-select',
438
- { 'cap-unified-tree-select-readonly': readOnly },
439
- className
440
- ),
441
- [containerClassName, className, readOnly]
442
- );
71
+ }
443
72
 
444
- return (
445
- <CapRow className={classnames(className, 'cap-unified-select-container')}>
446
- {renderHeader}
447
- <StyledTreeSelect
448
- type={type}
449
- treeData={filteredTree}
450
- value={customPopupRender ? tempValue : value}
451
- treeNodeLabelProp='label'
452
- onChange={isMulti ? setTempValue : onChange}
73
+ return (
74
+ <Select
75
+ value={value}
76
+ onChange={onChange}
453
77
  placeholder={placeholder}
454
- showSearch={false}
455
- maxTagCount={0}
456
- maxTagPlaceholder={() => null}
457
- prefix={prefix || undefined}
458
- suffixIcon={suffix}
459
- className={combinedClassName}
460
- classNames={{
461
- popup: { root: classnames('custom-popup-container', className) },
462
- }}
78
+ className={className}
463
79
  style={style}
464
- status={isError ? 'error' : ''}
465
80
  allowClear={allowClear}
466
- multiple={isMulti}
467
- treeCheckable={isMulti}
468
- treeCheckStrictly={false}
469
- showCheckedStrategy={TreeSelect.SHOW_CHILD}
470
- open={dropdownOpen}
471
- onOpenChange={handleDropdownVisibilityChange}
81
+ showSearch={showSearch}
82
+ options={options}
83
+ mode={type === 'multiSelect' ? 'multiple' : undefined}
472
84
  virtual
473
85
  disabled={disabled}
474
- filterTreeNode={false}
475
- listHeight={256}
476
- listItemHeight={32}
477
- popupRender={renderCustomDropdown}
478
- {...rest}
86
+ {...selectVirtualizationProps}
479
87
  />
480
- {isError && (
481
- <CapLabel className="cap-unified-select-status" style={{ color: styledVars.CAP_RED }}>
482
- {errorMessage}
483
- </CapLabel>
484
- )}
485
- </CapRow>
88
+ );
89
+ };
90
+
91
+ return (
92
+ <SelectWrapper>
93
+ {renderHeader()}
94
+ {renderDropdown()}
95
+ </SelectWrapper>
486
96
  );
487
- };
97
+ }
488
98
 
489
99
  CapUnifiedSelect.propTypes = {
490
- type: PropTypes.oneOf(Object.values(SELECT_TYPES)),
100
+ type: PropTypes.oneOf(['select', 'multiSelect', 'treeSelect', 'multiTreeSelect']),
491
101
  options: PropTypes.array,
102
+ treeData: PropTypes.array,
492
103
  value: PropTypes.any,
493
- containerClassName: PropTypes.string,
494
104
  onChange: PropTypes.func,
495
105
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
496
106
  className: PropTypes.string,
497
107
  style: PropTypes.object,
498
108
  allowClear: PropTypes.bool,
499
- headerLabel: PropTypes.string,
109
+ showSearch: PropTypes.bool,
110
+ label: PropTypes.string,
500
111
  tooltip: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
501
112
  disabled: PropTypes.bool,
502
- readOnly: PropTypes.bool,
503
- bylineText: PropTypes.string,
504
- customPopupRender: PropTypes.bool,
505
- showSearch: PropTypes.bool,
506
- searchBasedOn: PropTypes.oneOf(['label', 'value', 'key']),
507
- onConfirm: PropTypes.func,
508
- isError: PropTypes.bool,
509
- errorMessage: PropTypes.string,
510
- popoverClassName: PropTypes.string,
511
- showUpload: PropTypes.bool,
512
- onUpload: PropTypes.func,
513
- clearText: PropTypes.string,
514
- noResultCustomText: PropTypes.string,
515
- noResultCustomIcon: PropTypes.string,
516
113
  };
517
114
 
518
115
  CapUnifiedSelect.defaultProps = {
519
- type: SELECT_TYPES.SELECT,
520
- placeholder: 'Select an option',
521
- searchBasedOn: 'label',
522
- noResultCustomText: 'No results found',
523
- noResultCustomIcon: 'warning',
524
- clearText: 'Clear',
525
- options: [],
116
+ type: 'select',
526
117
  allowClear: false,
527
- customPopupRender: true,
528
- showSearch: true,
529
- className: '',
530
- disabled: false,
531
- readOnly: false,
532
- showUpload: false,
533
- isError: false,
534
- onUpload: () => {},
535
- onChange: () => {},
536
- onConfirm: () => {},
118
+ showSearch: false,
537
119
  };
538
120
 
539
- export default withMemo(withStyles(CapUnifiedSelect, selectStyles));
121
+ export default CapUnifiedSelect;
@@ -1 +1,4 @@
1
- export { default } from './CapUnifiedSelect';
1
+ import CapUnifiedSelect from './CapUnifiedSelect';
2
+ import CapUnifiedSelectLoadable from './loadable';
3
+
4
+ export default CapUnifiedSelectLoadable;
@@ -0,0 +1,3 @@
1
+ import loadable from '@loadable/component';
2
+
3
+ export default loadable(() => import('./CapUnifiedSelect'));