@capillarytech/blaze-ui 0.1.6-alpha.49 → 0.1.6-alpha.5

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/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 +1 -1
  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/CapLabel/CapLabel.js +81 -101
  13. package/CapLabel/index.js +1 -3
  14. package/CapLabel/styles.js +212 -250
  15. package/CapRow/CapRow.js +10 -111
  16. package/CapRow/index.js +1 -3
  17. package/CapRow/styles.js +6 -47
  18. package/CapTable/loadable.js +4 -4
  19. package/CapTable/styles.js +1 -1
  20. package/CapTooltip/CapTooltip.js +25 -87
  21. package/CapTooltip/index.js +1 -3
  22. package/CapTooltip/styles.js +27 -19
  23. package/CapUnifiedSelect/CapUnifiedSelect.js +66 -308
  24. package/CapUnifiedSelect/index.js +4 -1
  25. package/CapUnifiedSelect/loadable.js +3 -0
  26. package/CapUnifiedSelect/styles.js +151 -255
  27. package/dist/235.index.js +2 -0
  28. package/dist/235.index.js.LICENSE.txt +29 -0
  29. package/dist/603.index.js +1 -0
  30. package/dist/CapInput/CapInput.js +66 -0
  31. package/dist/CapInput/Number.js +42 -0
  32. package/dist/CapInput/Search.js +35 -0
  33. package/dist/CapInput/TextArea.js +42 -0
  34. package/dist/CapInput/index.js +15 -0
  35. package/dist/CapInput/messages.js +32 -0
  36. package/dist/CapInput/styles.js +11 -0
  37. package/dist/CapTable/CapTable.js +148 -0
  38. package/dist/CapTable/index.js +9 -0
  39. package/dist/CapTable/loadable.js +23 -0
  40. package/dist/CapTable/styles.js +26 -0
  41. package/dist/LocaleHoc/index.js +40 -0
  42. package/dist/esm/CapHeading/CapHeading.js +41 -0
  43. package/dist/esm/CapHeading/index.js +1 -0
  44. package/dist/esm/CapHeading/styles.js +123 -0
  45. package/dist/esm/CapInfoNote/CapInfoNote.js +62 -0
  46. package/dist/esm/CapInfoNote/index.js +1 -0
  47. package/dist/esm/CapInfoNote/styles.js +6 -0
  48. package/dist/esm/CapInput/CapInput.js +57 -0
  49. package/dist/esm/CapInput/Number.js +35 -0
  50. package/dist/esm/CapInput/Search.js +28 -0
  51. package/dist/esm/CapInput/TextArea.js +35 -0
  52. package/dist/esm/CapInput/index.js +8 -0
  53. package/dist/esm/CapInput/loadable.js +9 -0
  54. package/dist/esm/CapInput/messages.js +25 -0
  55. package/dist/esm/CapInput/styles.js +3 -0
  56. package/dist/esm/CapLabel/CapLabel.js +50 -0
  57. package/dist/esm/CapLabel/index.js +1 -0
  58. package/dist/esm/CapLabel/styles.js +219 -0
  59. package/dist/esm/CapRow/CapRow.js +22 -0
  60. package/dist/esm/CapRow/index.js +1 -0
  61. package/dist/esm/CapRow/styles.js +5 -0
  62. package/dist/esm/CapTable/CapTable.js +140 -0
  63. package/dist/esm/CapTable/index.js +2 -0
  64. package/dist/esm/CapTable/loadable.js +12 -0
  65. package/dist/esm/CapTable/styles.js +17 -0
  66. package/dist/esm/CapTooltip/CapTooltip.js +34 -0
  67. package/dist/esm/CapTooltip/index.js +1 -0
  68. package/dist/esm/CapTooltip/styles.js +6 -0
  69. package/dist/esm/CapUnifiedSelect/CapUnifiedSelect.js +101 -0
  70. package/dist/esm/CapUnifiedSelect/index.js +3 -0
  71. package/dist/esm/CapUnifiedSelect/loadable.js +4 -0
  72. package/dist/esm/CapUnifiedSelect/messages.js +23 -0
  73. package/dist/esm/CapUnifiedSelect/styles.js +15 -0
  74. package/dist/esm/LocaleHoc/index.js +31 -0
  75. package/dist/esm/index.js +11 -0
  76. package/dist/esm/styled/index.js +5 -0
  77. package/dist/esm/styled/variables.js +88 -0
  78. package/dist/esm/translations/en.js +329 -0
  79. package/dist/index.js +39 -0
  80. package/dist/index.js.LICENSE.txt +7 -0
  81. package/dist/styled/index.js +22 -0
  82. package/dist/styled/variables.js +94 -0
  83. package/dist/translations/en.js +335 -0
  84. package/index.js +1 -12
  85. package/package.json +11 -5
  86. package/.DS_Store +0 -0
  87. package/CapIcon/CapIcon.js +0 -183
  88. package/CapIcon/index.js +0 -3
  89. package/CapIcon/styles.js +0 -76
  90. package/CapSkeleton/CapSkeleton.js +0 -17
  91. package/CapSkeleton/index.js +0 -1
  92. package/CapSpin/CapSpin.js +0 -23
  93. package/CapSpin/index.js +0 -1
  94. package/CapTestSelect/CapTestSelect.js +0 -47
  95. package/CapTestSelect/index.js +0 -1
  96. package/CapTooltipWithInfo/CapTooltipWithInfo.js +0 -82
  97. package/CapTooltipWithInfo/index.js +0 -3
  98. package/CapTooltipWithInfo/styles.js +0 -22
  99. package/assets/upload.svg +0 -3
  100. package/utils/index.js +0 -1
  101. package/utils/withStyles.js +0 -24
@@ -1,98 +1,36 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Tooltip } from 'antd-v5';
4
- import classnames from 'classnames';
5
- import styled from 'styled-components';
6
- import { tooltipStyles } from './styles';
7
- import withStyles from '../utils/withStyles';
3
+ import { Tooltip } from 'antd';
4
+ import classNames from 'classnames';
5
+ import { TooltipWrapper } from './styles';
8
6
 
9
- const StyledTooltip = styled(Tooltip)`
10
- ${tooltipStyles}
11
- `;
12
-
13
- const CapTooltip = ({
14
- title,
15
- children,
16
- placement = 'top',
17
- visible,
18
- defaultVisible = false,
19
- trigger = 'hover',
20
- destroyTooltipOnHide = false,
21
- mouseEnterDelay = 0.1,
22
- mouseLeaveDelay = 0.1,
23
- overlayClassName = '',
24
- overlayStyle,
25
- onVisibleChange,
26
- align,
27
- arrowPointAtCenter = false,
28
- autoAdjustOverflow = true,
29
- getPopupContainer,
30
- className = '',
31
- ...rest
32
- }) => {
7
+ const CapTooltip = ({ overlayClassName, children, ...rest }) => {
33
8
  return (
34
- <StyledTooltip
35
- title={title}
36
- placement={placement}
37
- open={visible}
38
- defaultOpen={defaultVisible}
39
- trigger={trigger}
40
- destroyTooltipOnHide={destroyTooltipOnHide}
41
- mouseEnterDelay={mouseEnterDelay}
42
- mouseLeaveDelay={mouseLeaveDelay}
43
- overlayClassName={classnames('cap-tooltip-overlay-v2', overlayClassName)}
44
- overlayStyle={overlayStyle}
45
- onOpenChange={onVisibleChange}
46
- align={align}
47
- arrow={{ pointAtCenter: arrowPointAtCenter }}
48
- autoAdjustOverflow={autoAdjustOverflow}
49
- getPopupContainer={getPopupContainer}
50
- className={classnames('cap-tooltip-v2', className)}
51
- {...rest}
52
- >
53
- {children}
54
- </StyledTooltip>
9
+ <TooltipWrapper>
10
+ <Tooltip
11
+ overlayClassName={classNames('cap-tooltip', overlayClassName)}
12
+ {...rest}
13
+ >
14
+ {children}
15
+ </Tooltip>
16
+ </TooltipWrapper>
55
17
  );
56
18
  };
57
19
 
20
+ /*
21
+ NOTE:
22
+ While using a disabled button with tooltip, wrap the button with an element with className "button-disabled-tooltip-wrapper".
23
+
24
+ <CapTooltip title="disabled button with tooltip">
25
+ <span className="button-disabled-tooltip-wrapper">
26
+ <CapButton disabled>Button</CapButton>
27
+ </span>
28
+ </CapTooltip>
29
+ */
30
+
58
31
  CapTooltip.propTypes = {
59
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
60
- children: PropTypes.node,
61
- placement: PropTypes.oneOf([
62
- 'top', 'left', 'right', 'bottom',
63
- 'topLeft', 'topRight', 'bottomLeft', 'bottomRight',
64
- 'leftTop', 'leftBottom', 'rightTop', 'rightBottom',
65
- ]),
66
- visible: PropTypes.bool,
67
- defaultVisible: PropTypes.bool,
68
- trigger: PropTypes.oneOfType([
69
- PropTypes.string,
70
- PropTypes.arrayOf(PropTypes.string),
71
- ]),
72
- destroyTooltipOnHide: PropTypes.bool,
73
- mouseEnterDelay: PropTypes.number,
74
- mouseLeaveDelay: PropTypes.number,
75
32
  overlayClassName: PropTypes.string,
76
- overlayStyle: PropTypes.object,
77
- onVisibleChange: PropTypes.func,
78
- align: PropTypes.object,
79
- arrowPointAtCenter: PropTypes.bool,
80
- autoAdjustOverflow: PropTypes.bool,
81
- getPopupContainer: PropTypes.func,
82
- className: PropTypes.string,
83
- };
84
-
85
- CapTooltip.defaultProps = {
86
- placement: 'top',
87
- defaultVisible: false,
88
- trigger: 'hover',
89
- destroyTooltipOnHide: false,
90
- mouseEnterDelay: 0.1,
91
- mouseLeaveDelay: 0.1,
92
- overlayClassName: '',
93
- arrowPointAtCenter: false,
94
- autoAdjustOverflow: true,
95
- className: '',
33
+ children: PropTypes.node,
96
34
  };
97
35
 
98
- export default withStyles(CapTooltip, tooltipStyles);
36
+ export default CapTooltip;
@@ -1,3 +1 @@
1
- import CapTooltip from './CapTooltip';
2
-
3
- export default CapTooltip;
1
+ export { default } from './CapTooltip';
@@ -1,34 +1,42 @@
1
- import styled, { css } from 'styled-components';
1
+ import styled from 'styled-components';
2
2
  import * as styledVars from '../styled/variables';
3
3
 
4
- export const tooltipStyles = css`
5
- &.cap-tooltip-overlay-v2 {
4
+ export const TooltipWrapper = styled.span`
5
+ .cap-tooltip {
6
+ max-width: 324px;
7
+
6
8
  .ant-tooltip-inner {
7
- background-color: ${styledVars.CAP_G01};
8
- color: ${styledVars.CAP_WHITE};
9
- padding: 8px 12px;
10
- font-size: 14px;
11
- line-height: 20px;
9
+ background-color: ${styledVars.FONT_COLOR_01};
10
+ font-size: ${styledVars.FONT_SIZE_M};
11
+ font-weight: ${styledVars.FONT_WEIGHT_MEDIUM};
12
+ padding: 6px 8px;
13
+ min-height: 32px;
12
14
  border-radius: ${styledVars.RADIUS_04};
13
- max-width: 300px;
14
- word-wrap: break-word;
15
15
  }
16
16
 
17
- .ant-tooltip-arrow::before {
18
- background-color: ${styledVars.CAP_G01};
17
+ &.cap-bgcolor-tooltip {
18
+ .ant-tooltip-inner {
19
+ background-color: ${styledVars.FONT_COLOR_05};
20
+ }
21
+ }
22
+
23
+ &.hide-tooltip-pointer {
24
+ .ant-tooltip-arrow {
25
+ display: none;
26
+ }
19
27
  }
20
28
  }
21
29
 
22
30
  .button-disabled-tooltip-wrapper {
23
- display: inline-block;
31
+ display: inline-flex;
24
32
  cursor: not-allowed;
25
33
 
26
- .ant-btn[disabled] {
34
+ .cap-button.ant-btn[disabled] {
27
35
  pointer-events: none;
36
+ & > * {
37
+ pointer-events: auto;
38
+ cursor: not-allowed;
39
+ }
28
40
  }
29
41
  }
30
- `;
31
-
32
- export const StyledTooltipWrapper = styled.div`
33
- display: inline-block;
34
- `;
42
+ `;
@@ -1,363 +1,121 @@
1
- // Enhanced CapUnifiedSelect supporting 4 scenarios with advanced features in a single TreeSelect
2
- 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';
3
3
  import PropTypes from 'prop-types';
4
- import classnames from 'classnames';
5
- import { TreeSelect, Input, Button } 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 { SelectWrapper, 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 CapUnifiedSelect = ({
9
+ function CapUnifiedSelect({
17
10
  type,
18
11
  options = [],
12
+ treeData,
19
13
  value,
20
14
  onChange,
21
15
  placeholder = 'Select an option',
22
16
  className,
23
17
  style,
24
- isError = false,
25
- errorMessage,
26
- popOverClassName,
27
18
  allowClear = false,
28
- headerLabel,
29
- onUpload,
19
+ showSearch = false,
20
+ label,
30
21
  tooltip,
31
- bylineText,
32
22
  disabled = false,
33
- showUpload = false,
34
- customPopupRender = true,
35
- showSearch = true,
36
- searchBasedOn = 'label',
37
- onConfirm,
38
- onCancel,
39
- size = 'm',
40
- noResultCustomText = 'No results found',
41
- noResultCustomIcon = 'warning',
42
- ...rest
43
- }) => {
44
-
45
- const [searchText, setSearchText] = useState('');
46
- const [tempValue, setTempValue] = useState(value);
47
- const [allSelected, setAllSelected] = useState(false);
48
- const [dropdownOpen, setDropdownOpen] = useState(false);
49
-
23
+ }) {
24
+ const selectVirtualizationProps = {
25
+ listHeight: 256,
26
+ };
50
27
 
51
- useEffect(() => {
52
- setTempValue(value);
53
- }, [value]);
54
-
55
- const treeSelectVirtualizationProps = useMemo(() => ({
56
- listHeight: 256,
28
+ const treeSelectVirtualizationProps = {
29
+ listHeight: 256,
57
30
  listItemHeight: 32,
58
- }), []);
59
-
60
- const NoResult = memo(({ noResultCustomText, className, showUpload, options }) => (
61
- <CapRow
62
- className={classnames(className, "cap-unified-select-no-result")}
63
- align="middle"
64
- gap={8}
65
- >
66
- <CapIcon type={noResultCustomIcon} size="m" />
67
- <CapLabel className="cap-unified-select-no-result-text">{showUpload && options?.length === 0 ? noResultCustomText : 'No results found'}</CapLabel>
68
- </CapRow>
69
- ));
70
-
71
- const getFilteredTreeData = useCallback((data, search) => {
72
- if (!search) return data;
73
-
74
- const filterNode = node => {
75
- if (!node) return false;
76
- if (searchBasedOn === 'value') {
77
- const valueText = String(node?.value || '').toLowerCase();
78
- return valueText.includes(search.toLowerCase());
79
- } else if (searchBasedOn === 'key') {
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
- }
86
- };
87
-
88
- const loop = data =>
89
- data.map(item => {
90
- const children = item.children ? loop(item.children) : [];
91
- if (filterNode(item) || children.length) {
92
- return { ...item, children };
93
- }
94
- return null;
95
- }).filter(Boolean);
96
-
97
- return loop(data);
98
- }, [searchBasedOn]);
99
-
100
- const flattenLeafValues = useCallback(nodes =>
101
- nodes?.flatMap(node => node?.children ? flattenLeafValues(node.children) : [node?.value]) || [], []);
102
-
103
- const isMulti = useMemo(() => type === 'multiSelect' || type === 'multiTreeSelect', [type]);
104
- const isTree = useMemo(() => type === 'treeSelect' || type === 'multiTreeSelect', [type]);
105
-
106
- const dataSource = useMemo(() => {
107
- return isTree ? options : options?.map(opt => ({ title: opt?.label, value: opt?.value, key: opt?.key || opt?.value }));
108
- }, [isTree, options]);
109
-
110
- const filteredTree = useMemo(() => getFilteredTreeData(dataSource, searchText), [dataSource, searchText]);
111
- const leafValues = useMemo(() => flattenLeafValues(filteredTree), [filteredTree]);
112
-
113
- const handleSelectAll = useCallback(() => {
114
- const availableValues = leafValues;
115
- if (allSelected) {
116
- setTempValue([]);
117
- setAllSelected(false);
118
- } else {
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]);
130
-
131
- const handleConfirm = useCallback(() => {
132
- if (onChange) onChange(tempValue);
133
- setDropdownOpen(false);
134
- }, [onChange, tempValue]);
135
-
136
- const handleCancel = useCallback(() => {
137
- setTempValue(value);
138
- setDropdownOpen(false);
139
- }, [value]);
140
-
141
- const handleTempChange = useCallback(newValue => {
142
- setTempValue(newValue);
143
- }, []);
144
-
145
- const handleDropdownVisibilityChange = useCallback(open => {
146
- if (open === false) {
147
- setTempValue(value);
148
- }
149
- setDropdownOpen(open);
150
- }, [value]);
151
-
152
- const suffix = useMemo(() => {
153
- const displayValue = dropdownOpen ? tempValue : value;
154
- return isMulti && Array.isArray(displayValue) && displayValue?.length > 1 ? (
155
- <>
156
- <span>+{displayValue.length - 1} more <CapIcon type="down" size="s" /></span>
157
- </>
158
- ) : (
159
- <CapIcon type="down" size="s" />
160
- );
161
- }, [isMulti, value, tempValue, dropdownOpen]);
162
-
163
- const prefix = useMemo(() => {
164
- if (isMulti) {
165
- if (Array.isArray(tempValue) && tempValue?.length > 0) {
166
- const firstSelectedValue = tempValue[0];
167
- const firstSelectedOption = options?.find(opt => opt?.value === firstSelectedValue);
168
- return firstSelectedOption?.label || null;
169
- }
170
- else if (Array.isArray(value) && value?.length > 0) {
171
- const firstSelectedValue = value[0];
172
- const firstSelectedOption = options?.find(opt => opt?.value === firstSelectedValue);
173
- return firstSelectedOption?.label || null;
174
- }
175
- }
176
- return null;
177
- }, [isMulti, value, tempValue, options]);
31
+ };
178
32
 
179
- const renderHeader = useCallback(() => {
180
- if (!headerLabel && !tooltip) return null;
33
+ const renderHeader = () => {
34
+ if (!label && !tooltip) return null;
35
+
181
36
  return (
182
- <>
183
- <HeaderWrapper className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header')}>
184
- {headerLabel && <CapLabel type="label16" className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-label')}>{headerLabel}</CapLabel>}
37
+ <HeaderWrapper className={disabled ? 'disabled' : ''}>
38
+ {label && (
39
+ <CapLabel type="label16" className={disabled ? 'disabled' : ''}>
40
+ {label}
41
+ </CapLabel>
42
+ )}
185
43
  {tooltip && (
186
- <CapTooltipWithInfo
187
- title={tooltip}
188
- className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-tooltip')}
189
- iconProps={{ disabled }}
190
- />
44
+ <CapTooltip title={tooltip}>
45
+ <StyledInfoIcon className={disabled ? 'disabled' : ''} />
46
+ </CapTooltip>
191
47
  )}
192
48
  </HeaderWrapper>
193
- <div className="cap-unified-select-header-byline-text">
194
- {bylineText && <CapLabel className={classnames(disabled ? 'disabled' : '', 'cap-unified-select-header-byline-text')}>{bylineText}</CapLabel>}
195
- </div>
196
- </>
197
49
  );
198
- }, [headerLabel, tooltip, bylineText, disabled]);
199
-
200
- const renderDropdown = useCallback(() => {
201
- const currentItems = filteredTree;
202
- const selectedCount = Array.isArray(tempValue)
203
- ? isTree
204
- ? tempValue?.filter(val => leafValues?.includes(val))?.length || 0
205
- : tempValue?.length || 0
206
- : (tempValue ? 1 : 0);
207
-
208
- const renderCustomDropdown = useCallback(menu => {
209
- if (!customPopupRender) return menu;
50
+ };
210
51
 
52
+ const renderDropdown = () => {
53
+ if (type === 'treeSelect' || type === 'multiTreeSelect') {
211
54
  return (
212
- <div className={classnames(popOverClassName, `${type}-popup-container`)}>
213
- {showSearch && (
214
- <CapRow className={classnames("cap-unified-select-search-container")} align="middle">
215
- <Input
216
- prefix={<CapIcon type="search" size="s" style={{ color: styledVars.CAP_G06 }} />}
217
- placeholder="Search"
218
- variant="borderless"
219
- value={searchText}
220
- onChange={e => setSearchText(e.target.value)}
221
- />
222
- </CapRow>
223
- )}
224
- {isMulti && showUpload && (
225
- <CapRow className={classnames("cap-unified-select-upload-container")} align="middle" onClick={onUpload}>
226
- <CapIcon type="upload" size="s" style={{ color: styledVars.CAP_SECONDARY.base }}/>
227
- <CapLabel type="label14" className={classnames("cap-unified-select-upload-label")}>Upload</CapLabel>
228
- </CapRow>
229
- )}
230
- {isMulti && currentItems.length > 0 && (
231
- <CapRow
232
- className={classnames("cap-unified-select-select-all-container")}
233
- onClick={handleSelectAll}
234
- align="middle"
235
- gap={7}
236
- >
237
- <input readOnly type="checkbox" checked={allSelected} className={classnames("cap-unified-select-select-all-checkbox")} onClick={handleSelectAll} />
238
- <CapLabel type="label14" className={classnames("cap-unified-select-select-all-label")}>Select all</CapLabel>
239
- </CapRow>
240
- )}
241
-
242
- {currentItems.length === 0 ? <NoResult noResultCustomText={noResultCustomText} className={classnames(className, "cap-unified-select-no-result")} showUpload={showUpload} options={options}/> : menu}
243
-
244
- {currentItems.length > 0 && isMulti && (
245
- <div className="cap-unified-select-confirm-container">
246
- <div className="cap-unified-select-confirm-button-group">
247
- <Button
248
- type="primary"
249
- size="small"
250
- className="cap-unified-select-confirm-button"
251
- onClick={handleConfirm}
252
- >
253
- Confirm
254
- </Button>
255
- <Button
256
- type="text"
257
- className="cap-unified-select-cancel-button"
258
- size="small"
259
- onClick={handleCancel}
260
- >
261
- Cancel
262
- </Button>
263
- <CapLabel className="cap-unified-select-selected-count">
264
- {selectedCount} selected
265
- </CapLabel>
266
- </div>
267
- </div>
268
-
269
- )}
270
- </div>
271
- );
272
- }, [customPopupRender, popupClassName, type, showSearch, searchText, isMulti, showUpload, currentItems?.length, allSelected, className, noResultCustomText, onUpload, handleSelectAll, handleConfirm, handleCancel]);
273
-
274
- return (
275
- <>
276
- <StyledTreeSelect
277
- {...rest}
278
- type={type}
279
- treeData={filteredTree}
280
- value={customPopupRender ? tempValue : value}
281
- onChange={customPopupRender ? handleTempChange : onChange}
55
+ <TreeSelect
56
+ treeData={treeData || options}
57
+ value={value}
58
+ onChange={onChange}
282
59
  placeholder={placeholder}
283
- showSearch={false}
284
- maxTagCount={0}
285
- maxTagPlaceholder={() => null}
286
- prefix={tempValue?.length > 0 ? prefix : undefined}
287
- suffixIcon={suffix}
288
- className={classnames(`cap-unified-tree-select cap-unified-tree-select-${size}`, className)}
60
+ className={className}
289
61
  style={style}
290
- status={isError ? 'error' : ''}
291
62
  allowClear={allowClear}
292
- multiple={isMulti}
293
- treeCheckable={isMulti}
294
- open={dropdownOpen}
295
- onOpenChange={handleDropdownVisibilityChange}
296
- showCheckedStrategy={TreeSelect.SHOW_PARENT}
63
+ showSearch={showSearch}
64
+ multiple={type === 'multiTreeSelect' ? true : false}
297
65
  virtual
66
+ treeDefaultExpandAll
298
67
  disabled={disabled}
299
- filterTreeNode={false}
300
68
  {...treeSelectVirtualizationProps}
301
- popupRender={renderCustomDropdown}
302
69
  />
303
- {isError && <CapLabel className={classnames("cap-unified-select-status")} style={{ color: 'red' }}>{errorMessage}</CapLabel>}
304
- </>
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
+ />
305
88
  );
306
- }, [filteredTree, tempValue, value, prefix, suffix, className, style, isError, errorMessage, allowClear, isMulti, dropdownOpen, customPopupRender, handleTempChange, onChange, disabled, handleDropdownVisibilityChange, treeSelectVirtualizationProps]);
89
+ };
307
90
 
308
91
  return (
309
- <SelectWrapper className={classnames(className, 'cap-unified-select-container')}>
92
+ <SelectWrapper>
310
93
  {renderHeader()}
311
94
  {renderDropdown()}
312
95
  </SelectWrapper>
313
96
  );
314
- };
97
+ }
315
98
 
316
99
  CapUnifiedSelect.propTypes = {
317
100
  type: PropTypes.oneOf(['select', 'multiSelect', 'treeSelect', 'multiTreeSelect']),
318
101
  options: PropTypes.array,
102
+ treeData: PropTypes.array,
319
103
  value: PropTypes.any,
320
104
  onChange: PropTypes.func,
321
105
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
322
106
  className: PropTypes.string,
323
107
  style: PropTypes.object,
324
108
  allowClear: PropTypes.bool,
325
- headerLabel: PropTypes.string,
109
+ showSearch: PropTypes.bool,
110
+ label: PropTypes.string,
326
111
  tooltip: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
327
112
  disabled: PropTypes.bool,
328
- customPopupRender: PropTypes.bool,
329
- showSearch: PropTypes.bool,
330
- searchBasedOn: PropTypes.oneOf(['label', 'value', 'key']),
331
- onConfirm: PropTypes.func,
332
- onCancel: PropTypes.func,
333
- isError: PropTypes.bool,
334
- errorMessage: PropTypes.string,
335
- popupClassName: PropTypes.string,
336
- showUpload: PropTypes.bool,
337
- onUpload: PropTypes.func,
338
- size: PropTypes.oneOf(['s', 'm', 'l', 'xl']),
339
113
  };
340
114
 
341
115
  CapUnifiedSelect.defaultProps = {
342
116
  type: 'select',
343
- placeholder: 'Select an option',
344
- searchBasedOn: 'label',
345
- noResultCustomText: 'No results found',
346
- noResultCustomIcon: 'warning',
347
- options: [],
348
- size: 'm',
349
117
  allowClear: false,
350
- customPopupRender: true,
351
- showSearch: true,
352
- className: '',
353
- popupClassName: '',
354
- disabled: false,
355
- showUpload: false,
356
- isError: false,
357
- onUpload: () => {},
358
- onChange: () => {},
359
- onConfirm: () => {},
360
- onCancel: () => {}
118
+ showSearch: false,
361
119
  };
362
120
 
363
- export default 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'));