@capillarytech/blaze-ui 0.1.6-alpha.6 → 0.1.6-alpha.60

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