@capillarytech/blaze-ui 0.1.6-alpha.1 → 0.1.6-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapIcon/CapIcon.js +83 -0
- package/CapIcon/index.js +1 -0
- package/CapSelect/CapSelect.js +62 -0
- package/CapSelect/index.js +1 -0
- package/CapSelect/styles.js +119 -0
- package/CapTable/CapTable.js +2 -3
- package/CapTable/styles.js +4 -10
- package/CapTreeSelect/CapTreeSelect.js +86 -0
- package/CapTreeSelect/index.js +1 -0
- package/CapTreeSelect/styles.js +122 -0
- package/CapUnifiedSelect/CapUnifiedSelect.js +24 -49
- package/CapUnifiedSelect/index.js +1 -4
- package/CapUnifiedSelect/styles.js +4 -213
- package/dist/CapHeading/CapHeading.js +48 -0
- package/dist/CapHeading/index.js +13 -0
- package/dist/CapHeading/styles.js +131 -0
- package/dist/CapIcon/CapIcon.js +88 -0
- package/dist/CapIcon/index.js +13 -0
- package/dist/CapInfoNote/CapInfoNote.js +69 -0
- package/dist/CapInfoNote/index.js +13 -0
- package/dist/CapInfoNote/styles.js +15 -0
- package/dist/CapInput/CapInput.js +66 -0
- package/dist/CapInput/Number.js +42 -0
- package/dist/CapInput/Search.js +35 -0
- package/dist/CapInput/TextArea.js +42 -0
- package/dist/CapInput/index.js +15 -0
- package/dist/CapInput/messages.js +32 -0
- package/dist/CapInput/styles.js +11 -0
- package/dist/CapLabel/CapLabel.js +57 -0
- package/dist/CapLabel/index.js +13 -0
- package/dist/CapLabel/styles.js +227 -0
- package/dist/CapRow/CapRow.js +29 -0
- package/dist/CapRow/index.js +13 -0
- package/dist/CapRow/styles.js +12 -0
- package/dist/CapSelect/CapSelect.js +72 -0
- package/dist/CapSelect/index.js +13 -0
- package/dist/CapSelect/styles.js +15 -0
- package/dist/CapTable/CapTable.js +148 -0
- package/dist/CapTable/index.js +9 -0
- package/dist/CapTable/loadable.js +23 -0
- package/dist/CapTable/styles.js +26 -0
- package/dist/CapTooltip/CapTooltip.js +41 -0
- package/dist/CapTooltip/index.js +13 -0
- package/dist/CapTooltip/styles.js +15 -0
- package/dist/CapTreeSelect/CapTreeSelect.js +81 -0
- package/dist/CapTreeSelect/index.js +13 -0
- package/dist/CapTreeSelect/styles.js +20 -0
- package/dist/CapUnifiedSelect/CapUnifiedSelect.js +93 -0
- package/dist/CapUnifiedSelect/index.js +13 -0
- package/dist/CapUnifiedSelect/messages.js +29 -0
- package/dist/CapUnifiedSelect/styles.js +23 -0
- package/dist/LocaleHoc/index.js +40 -0
- package/dist/esm/CapIcon/CapIcon.js +79 -0
- package/dist/esm/CapIcon/index.js +1 -0
- package/dist/esm/CapSelect/CapSelect.js +65 -0
- package/dist/esm/CapSelect/index.js +1 -0
- package/dist/esm/CapSelect/styles.js +6 -0
- package/dist/esm/CapTable/CapTable.js +2 -3
- package/dist/esm/CapTable/styles.js +3 -4
- package/dist/esm/CapTreeSelect/CapTreeSelect.js +74 -0
- package/dist/esm/CapTreeSelect/index.js +1 -0
- package/dist/esm/CapTreeSelect/styles.js +11 -0
- package/dist/esm/CapUnifiedSelect/CapUnifiedSelect.js +28 -42
- package/dist/esm/CapUnifiedSelect/index.js +1 -3
- package/dist/esm/CapUnifiedSelect/styles.js +4 -5
- package/dist/index.js +39 -2
- package/dist/styled/index.js +16 -0
- package/dist/styled/variables.js +129 -0
- package/dist/translations/en.js +335 -0
- package/package.json +4 -4
- package/CapInput/loadable.js +0 -9
- package/CapUnifiedSelect/loadable.js +0 -3
- package/dist/235.index.js +0 -2
- package/dist/235.index.js.LICENSE.txt +0 -29
- package/dist/603.index.js +0 -1
- package/dist/esm/CapInput/loadable.js +0 -9
- package/dist/esm/CapUnifiedSelect/loadable.js +0 -4
- package/dist/index.js.LICENSE.txt +0 -7
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as AntIcons from '@ant-design/icons';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import * as styledVars from '../styled/variables';
|
|
7
|
+
|
|
8
|
+
const getFontSizeFromProps = (size) => {
|
|
9
|
+
switch (size) {
|
|
10
|
+
case 'xs':
|
|
11
|
+
return styledVars.ICON_SIZE_XS;
|
|
12
|
+
case 's':
|
|
13
|
+
return styledVars.ICON_SIZE_S;
|
|
14
|
+
case 'm':
|
|
15
|
+
return styledVars.ICON_SIZE_M;
|
|
16
|
+
case 'l':
|
|
17
|
+
return styledVars.ICON_SIZE_L;
|
|
18
|
+
default:
|
|
19
|
+
return styledVars.ICON_SIZE_M;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const IconWrapper = styled.span`
|
|
24
|
+
font-size: ${props => getFontSizeFromProps(props.size)};
|
|
25
|
+
color: ${props => props.color || 'inherit'};
|
|
26
|
+
cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
|
|
27
|
+
opacity: ${props => props.disabled ? 0.5 : 1};
|
|
28
|
+
transition: all 0.3s;
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
opacity: ${props => props.disabled ? 0.5 : 0.8};
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const CapIcon = ({
|
|
36
|
+
type,
|
|
37
|
+
className,
|
|
38
|
+
disabled,
|
|
39
|
+
size = 'm',
|
|
40
|
+
color,
|
|
41
|
+
...rest
|
|
42
|
+
}) => {
|
|
43
|
+
// Convert type to AntD icon name (e.g., 'close' -> 'CloseOutlined')
|
|
44
|
+
const getIconComponent = (iconType) => {
|
|
45
|
+
const iconMap = {
|
|
46
|
+
'close': AntIcons.CloseOutlined,
|
|
47
|
+
'chevron-down': AntIcons.DownOutlined,
|
|
48
|
+
'tick': AntIcons.CheckOutlined,
|
|
49
|
+
'info': AntIcons.InfoCircleOutlined,
|
|
50
|
+
// Add more icon mappings as needed
|
|
51
|
+
};
|
|
52
|
+
return iconMap[iconType] || AntIcons[iconType];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const IconComponent = getIconComponent(type);
|
|
56
|
+
|
|
57
|
+
if (!IconComponent) {
|
|
58
|
+
console.warn(`Icon type "${type}" not found`);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<IconWrapper
|
|
64
|
+
className={classNames('cap-icon', className, { disabled })}
|
|
65
|
+
disabled={disabled}
|
|
66
|
+
size={size}
|
|
67
|
+
color={color}
|
|
68
|
+
{...rest}
|
|
69
|
+
>
|
|
70
|
+
<IconComponent />
|
|
71
|
+
</IconWrapper>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
CapIcon.propTypes = {
|
|
76
|
+
type: PropTypes.string.isRequired,
|
|
77
|
+
className: PropTypes.string,
|
|
78
|
+
disabled: PropTypes.bool,
|
|
79
|
+
size: PropTypes.oneOf(['xs', 's', 'm', 'l']),
|
|
80
|
+
color: PropTypes.string,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default CapIcon;
|
package/CapIcon/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CapIcon';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Select } from 'antd';
|
|
4
|
+
import { CloseOutlined, DownOutlined, CheckOutlined } from '@ant-design/icons';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import ComponentWithLabelHOC from '../hoc/ComponentWithLabelHOC';
|
|
7
|
+
import { SelectWrapper } from './styles';
|
|
8
|
+
|
|
9
|
+
const CapSelect = ({
|
|
10
|
+
componentClassName,
|
|
11
|
+
dropdownClassName,
|
|
12
|
+
options,
|
|
13
|
+
propToBeMadeLabel,
|
|
14
|
+
getMenuOptionsProps = () => ({}),
|
|
15
|
+
...rest
|
|
16
|
+
}) => {
|
|
17
|
+
const items = options.map(option => ({
|
|
18
|
+
...option,
|
|
19
|
+
key: option.value,
|
|
20
|
+
label: option.label,
|
|
21
|
+
title: option[propToBeMadeLabel] || option.label,
|
|
22
|
+
...getMenuOptionsProps(option)
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<SelectWrapper>
|
|
27
|
+
<Select
|
|
28
|
+
removeIcon={<CloseOutlined />}
|
|
29
|
+
suffixIcon={<DownOutlined />}
|
|
30
|
+
menuItemSelectedIcon={<CheckOutlined />}
|
|
31
|
+
dropdownClassName={classNames('cap-select-dropdown', dropdownClassName)}
|
|
32
|
+
className={classNames('cap-select', componentClassName)}
|
|
33
|
+
options={items}
|
|
34
|
+
{...rest}
|
|
35
|
+
/>
|
|
36
|
+
</SelectWrapper>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
CapSelect.defaultProps = {
|
|
41
|
+
size: 'large',
|
|
42
|
+
getMenuOptionsProps: () => ({}),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
CapSelect.propTypes = {
|
|
46
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
47
|
+
labelPosition: PropTypes.string,
|
|
48
|
+
errorMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
49
|
+
className: PropTypes.string,
|
|
50
|
+
componentClassName: PropTypes.string,
|
|
51
|
+
dropdownClassName: PropTypes.string,
|
|
52
|
+
isRequired: PropTypes.bool,
|
|
53
|
+
inductiveText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
54
|
+
options: PropTypes.array.isRequired,
|
|
55
|
+
size: PropTypes.string,
|
|
56
|
+
getMenuOptionsProps: PropTypes.func,
|
|
57
|
+
propToBeMadeLabel: PropTypes.string,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const CapSelectWithLabel = ComponentWithLabelHOC(CapSelect);
|
|
61
|
+
|
|
62
|
+
export default CapSelectWithLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CapSelect';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import * as styledVars from '../styled/variables';
|
|
3
|
+
|
|
4
|
+
export const SelectWrapper = styled.div`
|
|
5
|
+
.cap-select {
|
|
6
|
+
width: 100%;
|
|
7
|
+
font-family: ${styledVars.FONT_FAMILY};
|
|
8
|
+
|
|
9
|
+
.ant-select-arrow {
|
|
10
|
+
right: 4px;
|
|
11
|
+
margin-top: 0;
|
|
12
|
+
transform: translateY(-50%);
|
|
13
|
+
color: ${styledVars.CAP_G01};
|
|
14
|
+
|
|
15
|
+
.ant-select-arrow-icon {
|
|
16
|
+
line-height: 16px;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.ant-select-open .ant-select-arrow-icon svg {
|
|
21
|
+
transform: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ant-select-selector {
|
|
25
|
+
border: 1px solid ${styledVars.CAP_G06};
|
|
26
|
+
transition: all 0.3s;
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
border-color: ${styledVars.CAP_G11};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.ant-select-disabled {
|
|
34
|
+
.ant-select-selector {
|
|
35
|
+
background-color: ${styledVars.CAP_G08};
|
|
36
|
+
border-color: ${styledVars.CAP_G07};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ant-select-selection-placeholder {
|
|
41
|
+
color: ${styledVars.CAP_G04};
|
|
42
|
+
font-size: ${styledVars.FONT_SIZE_M};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&.ant-select-multiple {
|
|
46
|
+
.ant-select-selection-item {
|
|
47
|
+
background-color: ${styledVars.CAP_G08};
|
|
48
|
+
border: none;
|
|
49
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
50
|
+
padding: 0 25px 0 8px;
|
|
51
|
+
margin: 2px 4px 2px 0;
|
|
52
|
+
font-size: ${styledVars.FONT_SIZE_S};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.ant-select-selection-item-remove {
|
|
56
|
+
color: ${styledVars.CAP_G04};
|
|
57
|
+
&:hover {
|
|
58
|
+
color: ${styledVars.CAP_G01};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&.ant-select-focused:not(.ant-select-disabled) {
|
|
64
|
+
.ant-select-selector {
|
|
65
|
+
border-color: ${styledVars.CAP_G01};
|
|
66
|
+
box-shadow: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ant-select-clear {
|
|
71
|
+
right: 6px;
|
|
72
|
+
background: transparent;
|
|
73
|
+
color: ${styledVars.CAP_G04};
|
|
74
|
+
&:hover {
|
|
75
|
+
color: ${styledVars.CAP_G01};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.cap-select-dropdown {
|
|
81
|
+
.ant-select-item {
|
|
82
|
+
padding: 8px 12px;
|
|
83
|
+
color: ${styledVars.FONT_COLOR_02};
|
|
84
|
+
|
|
85
|
+
&:hover {
|
|
86
|
+
background-color: ${styledVars.CAP_G08};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&-option-selected {
|
|
90
|
+
background-color: ${styledVars.CAP_SECONDARY.light};
|
|
91
|
+
color: ${styledVars.CAP_SECONDARY.base};
|
|
92
|
+
font-weight: ${styledVars.FONT_WEIGHT_MEDIUM};
|
|
93
|
+
position: relative;
|
|
94
|
+
|
|
95
|
+
&::before {
|
|
96
|
+
content: " ";
|
|
97
|
+
width: 2px;
|
|
98
|
+
height: 100%;
|
|
99
|
+
left: 0;
|
|
100
|
+
top: 0;
|
|
101
|
+
position: absolute;
|
|
102
|
+
background-color: ${styledVars.CAP_SECONDARY.base};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&-option-active {
|
|
107
|
+
background-color: ${styledVars.CAP_G08};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&.ant-select-dropdown-multiple {
|
|
112
|
+
.ant-select-item-option-selected {
|
|
113
|
+
.ant-select-item-option-state {
|
|
114
|
+
color: ${styledVars.CAP_SECONDARY.base};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
`;
|
package/CapTable/CapTable.js
CHANGED
|
@@ -9,8 +9,7 @@ import React, { useEffect, useCallback, useState, useRef } from 'react';
|
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import { debounce } from 'lodash';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
|
-
import {
|
|
13
|
-
import styles, { StyledTable } from './styles';
|
|
12
|
+
import { StyledTable } from './styles';
|
|
14
13
|
import LocaleHoc from '../LocaleHoc';
|
|
15
14
|
|
|
16
15
|
const SCROLL_THRESHOLD = 80; // Percentage of scroll to trigger load
|
|
@@ -144,4 +143,4 @@ CapTable.propTypes = {
|
|
|
144
143
|
showLoader: PropTypes.bool,
|
|
145
144
|
};
|
|
146
145
|
|
|
147
|
-
export default LocaleHoc(
|
|
146
|
+
export default LocaleHoc(CapTable, { key: 'CapTable' });
|
package/CapTable/styles.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Table } from 'antd';
|
|
2
|
-
import styled
|
|
3
|
-
|
|
2
|
+
import styled from 'styled-components';
|
|
4
3
|
import * as styledVars from '../styled/variables';
|
|
5
4
|
|
|
6
5
|
const {
|
|
@@ -36,8 +35,7 @@ export const StyledTable = styled(Table)`
|
|
|
36
35
|
border-top: 1px solid ${CAP_G07};
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
export default css`
|
|
38
|
+
|
|
41
39
|
.ant-table {
|
|
42
40
|
border: 1px solid ${CAP_G07};
|
|
43
41
|
|
|
@@ -121,12 +119,8 @@ export default css`
|
|
|
121
119
|
|
|
122
120
|
&.hide-hover {
|
|
123
121
|
.ant-table {
|
|
124
|
-
.ant-table-thead
|
|
125
|
-
|
|
126
|
-
> td,
|
|
127
|
-
.ant-table-tbody
|
|
128
|
-
> tr.ant-table-row-hover:not(.ant-table-expanded-row)
|
|
129
|
-
> td,
|
|
122
|
+
.ant-table-thead > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,
|
|
123
|
+
.ant-table-tbody > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,
|
|
130
124
|
.ant-table-thead > tr:hover:not(.ant-table-expanded-row) > td,
|
|
131
125
|
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td {
|
|
132
126
|
background: none;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { TreeSelect } from 'antd';
|
|
4
|
+
import { DownOutlined } from '@ant-design/icons';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import CapRow from '../CapRow';
|
|
7
|
+
import CapHeading from '../CapHeading';
|
|
8
|
+
import CapLabel from '../CapLabel';
|
|
9
|
+
import CapTooltip from '../CapTooltip';
|
|
10
|
+
import CapInfoNote from '../CapInfoNote';
|
|
11
|
+
import { TreeSelectWrapper, CustomRow } from './styles';
|
|
12
|
+
|
|
13
|
+
const CapTreeSelect = ({
|
|
14
|
+
treeData,
|
|
15
|
+
className,
|
|
16
|
+
headerTitle,
|
|
17
|
+
headerDescription,
|
|
18
|
+
treeSelectSideLabel,
|
|
19
|
+
disabledTooltip,
|
|
20
|
+
infoNote,
|
|
21
|
+
noteText,
|
|
22
|
+
infoNoteWidth,
|
|
23
|
+
...rest
|
|
24
|
+
}) => {
|
|
25
|
+
const renderTreeSelect = () => (
|
|
26
|
+
<TreeSelect
|
|
27
|
+
treeData={treeData}
|
|
28
|
+
className={classNames('cap-tree-select', className)}
|
|
29
|
+
style={{ width: '100%' }}
|
|
30
|
+
switcherIcon={<DownOutlined />}
|
|
31
|
+
{...rest}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<TreeSelectWrapper className="cap-tree-select-container">
|
|
37
|
+
{headerTitle && (
|
|
38
|
+
<CapHeading type="h3">
|
|
39
|
+
{headerTitle}
|
|
40
|
+
</CapHeading>
|
|
41
|
+
)}
|
|
42
|
+
{headerDescription && (
|
|
43
|
+
<CapLabel type="label3" className="margin-t-4">
|
|
44
|
+
{headerDescription}
|
|
45
|
+
</CapLabel>
|
|
46
|
+
)}
|
|
47
|
+
{infoNote && (
|
|
48
|
+
<CapInfoNote
|
|
49
|
+
message={infoNote}
|
|
50
|
+
style={{ width: infoNoteWidth || '60%' }}
|
|
51
|
+
noteText={noteText}
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
<CustomRow className="margin-t-4">
|
|
55
|
+
{treeSelectSideLabel && (
|
|
56
|
+
<CapHeading type="h4" className="margin-r-12">
|
|
57
|
+
{treeSelectSideLabel}
|
|
58
|
+
</CapHeading>
|
|
59
|
+
)}
|
|
60
|
+
{disabledTooltip ? (
|
|
61
|
+
<CapTooltip title={disabledTooltip}>
|
|
62
|
+
<div style={{ width: '100%' }}>
|
|
63
|
+
{renderTreeSelect()}
|
|
64
|
+
</div>
|
|
65
|
+
</CapTooltip>
|
|
66
|
+
) : (
|
|
67
|
+
renderTreeSelect()
|
|
68
|
+
)}
|
|
69
|
+
</CustomRow>
|
|
70
|
+
</TreeSelectWrapper>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
CapTreeSelect.propTypes = {
|
|
75
|
+
treeData: PropTypes.array.isRequired,
|
|
76
|
+
className: PropTypes.string,
|
|
77
|
+
headerTitle: PropTypes.node,
|
|
78
|
+
headerDescription: PropTypes.node,
|
|
79
|
+
treeSelectSideLabel: PropTypes.node,
|
|
80
|
+
disabledTooltip: PropTypes.node,
|
|
81
|
+
infoNote: PropTypes.node,
|
|
82
|
+
noteText: PropTypes.string,
|
|
83
|
+
infoNoteWidth: PropTypes.string,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default CapTreeSelect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './CapTreeSelect';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import CapRow from '../CapRow';
|
|
3
|
+
import * as styledVars from '../styled/variables';
|
|
4
|
+
|
|
5
|
+
export const TreeSelectWrapper = styled.div`
|
|
6
|
+
.cap-tree-select {
|
|
7
|
+
width: 100%;
|
|
8
|
+
font-family: ${styledVars.FONT_FAMILY};
|
|
9
|
+
|
|
10
|
+
.ant-select-selector {
|
|
11
|
+
border: 1px solid ${styledVars.CAP_G06};
|
|
12
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
13
|
+
transition: all 0.3s;
|
|
14
|
+
|
|
15
|
+
&:hover {
|
|
16
|
+
border-color: ${styledVars.CAP_G11};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.ant-select-disabled {
|
|
21
|
+
.ant-select-selector {
|
|
22
|
+
background-color: ${styledVars.CAP_G08};
|
|
23
|
+
border-color: ${styledVars.CAP_G07};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ant-select-selection-placeholder {
|
|
28
|
+
color: ${styledVars.CAP_G04};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.ant-select-focused:not(.ant-select-disabled) {
|
|
32
|
+
.ant-select-selector {
|
|
33
|
+
border-color: ${styledVars.CAP_G01};
|
|
34
|
+
box-shadow: none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Tree Node Styles */
|
|
39
|
+
.ant-select-tree {
|
|
40
|
+
.ant-select-tree-node-content-wrapper {
|
|
41
|
+
padding: 4px 8px;
|
|
42
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
43
|
+
transition: all 0.3s;
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
background-color: ${styledVars.CAP_G08};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&.ant-select-tree-node-selected {
|
|
50
|
+
background-color: ${styledVars.CAP_SECONDARY.light};
|
|
51
|
+
color: ${styledVars.CAP_SECONDARY.base};
|
|
52
|
+
font-weight: ${styledVars.FONT_WEIGHT_MEDIUM};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.ant-select-tree-switcher {
|
|
57
|
+
width: 24px;
|
|
58
|
+
height: 24px;
|
|
59
|
+
line-height: 24px;
|
|
60
|
+
color: ${styledVars.CAP_G04};
|
|
61
|
+
|
|
62
|
+
&:hover {
|
|
63
|
+
color: ${styledVars.CAP_G01};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ant-select-tree-checkbox {
|
|
68
|
+
margin: 4px 8px 4px 0;
|
|
69
|
+
|
|
70
|
+
&-inner {
|
|
71
|
+
border-radius: 2px;
|
|
72
|
+
border-color: ${styledVars.CAP_G04};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&-checked .ant-select-tree-checkbox-inner {
|
|
76
|
+
background-color: ${styledVars.CAP_SECONDARY.base};
|
|
77
|
+
border-color: ${styledVars.CAP_SECONDARY.base};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&-indeterminate .ant-select-tree-checkbox-inner {
|
|
81
|
+
background-color: ${styledVars.CAP_WHITE};
|
|
82
|
+
border-color: ${styledVars.CAP_SECONDARY.base};
|
|
83
|
+
&::after {
|
|
84
|
+
background-color: ${styledVars.CAP_SECONDARY.base};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ant-select-tree-treenode {
|
|
90
|
+
padding: 0 4px;
|
|
91
|
+
|
|
92
|
+
&.ant-select-tree-treenode-disabled {
|
|
93
|
+
color: ${styledVars.CAP_G06};
|
|
94
|
+
cursor: not-allowed;
|
|
95
|
+
|
|
96
|
+
.ant-select-tree-node-content-wrapper {
|
|
97
|
+
color: ${styledVars.CAP_G06};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Spacing Classes */
|
|
105
|
+
.margin-t-4 {
|
|
106
|
+
margin-top: 4px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.margin-r-12 {
|
|
110
|
+
margin-right: 12px;
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
export const CustomRow = styled(CapRow)`
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
|
|
118
|
+
&.ant-row {
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// CapUnifiedSelect component using Ant Design v5 Select and TreeSelect directly
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import CapTooltip from '../CapTooltip';
|
|
4
|
+
import CapSelect from '../CapSelect';
|
|
5
|
+
import CapTreeSelect from '../CapTreeSelect';
|
|
6
|
+
import { SelectWrapper } from './styles';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
const CapUnifiedSelect = ({
|
|
10
9
|
type,
|
|
11
10
|
options = [],
|
|
12
11
|
treeData,
|
|
@@ -20,7 +19,8 @@ function CapUnifiedSelect({
|
|
|
20
19
|
label,
|
|
21
20
|
tooltip,
|
|
22
21
|
disabled = false,
|
|
23
|
-
|
|
22
|
+
props,
|
|
23
|
+
}) => {
|
|
24
24
|
const selectVirtualizationProps = {
|
|
25
25
|
listHeight: 256,
|
|
26
26
|
};
|
|
@@ -30,67 +30,42 @@ function CapUnifiedSelect({
|
|
|
30
30
|
listItemHeight: 32,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</CapTooltip>
|
|
47
|
-
)}
|
|
48
|
-
</HeaderWrapper>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
33
|
+
const renderDropdown = () => {
|
|
34
|
+
const commonProps = {
|
|
35
|
+
value,
|
|
36
|
+
onChange,
|
|
37
|
+
placeholder,
|
|
38
|
+
className,
|
|
39
|
+
style,
|
|
40
|
+
allowClear,
|
|
41
|
+
showSearch,
|
|
42
|
+
disabled,
|
|
43
|
+
label,
|
|
44
|
+
...props
|
|
45
|
+
};
|
|
51
46
|
|
|
52
|
-
const renderDropdown = () => {
|
|
53
47
|
if (type === 'treeSelect' || type === 'multiTreeSelect') {
|
|
54
48
|
return (
|
|
55
|
-
<
|
|
49
|
+
<CapTreeSelect
|
|
50
|
+
{...commonProps}
|
|
56
51
|
treeData={treeData || options}
|
|
57
|
-
|
|
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
|
|
52
|
+
multiple={type === 'multiTreeSelect'}
|
|
66
53
|
treeDefaultExpandAll
|
|
67
|
-
disabled={disabled}
|
|
68
|
-
{...treeSelectVirtualizationProps}
|
|
69
54
|
/>
|
|
70
55
|
);
|
|
71
56
|
}
|
|
72
57
|
|
|
73
58
|
return (
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
onChange={onChange}
|
|
77
|
-
placeholder={placeholder}
|
|
78
|
-
className={className}
|
|
79
|
-
style={style}
|
|
80
|
-
allowClear={allowClear}
|
|
81
|
-
showSearch={showSearch}
|
|
59
|
+
<CapSelect
|
|
60
|
+
{...commonProps}
|
|
82
61
|
options={options}
|
|
83
62
|
mode={type === 'multiSelect' ? 'multiple' : undefined}
|
|
84
|
-
virtual
|
|
85
|
-
disabled={disabled}
|
|
86
|
-
{...selectVirtualizationProps}
|
|
87
63
|
/>
|
|
88
64
|
);
|
|
89
65
|
};
|
|
90
66
|
|
|
91
67
|
return (
|
|
92
68
|
<SelectWrapper>
|
|
93
|
-
{renderHeader()}
|
|
94
69
|
{renderDropdown()}
|
|
95
70
|
</SelectWrapper>
|
|
96
71
|
);
|