@capillarytech/blaze-ui 0.1.6-alpha.66 → 0.1.6-alpha.7

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