@capillarytech/blaze-ui 0.1.4-alpha.5 → 0.1.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.
- package/CapInput/index.js +3 -4
- package/CapInput/loadable.js +1 -1
- package/CapTable/CapTable.js +147 -0
- package/CapTable/index.js +3 -0
- package/CapTable/loadable.js +13 -0
- package/CapTable/styles.js +140 -0
- package/CapUnifiedSelect/CapUnifiedSelect.js +159 -0
- package/CapUnifiedSelect/index.js +4 -0
- package/CapUnifiedSelect/loadable.js +3 -0
- package/CapUnifiedSelect/messages.js +24 -0
- package/CapUnifiedSelect/styles.js +182 -0
- package/LocaleHoc/index.js +38 -0
- package/dist/235.index.js +2 -0
- package/dist/235.index.js.LICENSE.txt +29 -0
- package/dist/603.index.js +1 -0
- package/dist/esm/CapInput/index.js +2 -4
- package/dist/esm/CapInput/loadable.js +1 -1
- package/dist/esm/CapTable/CapTable.js +141 -0
- package/dist/esm/CapTable/index.js +2 -0
- package/dist/esm/CapTable/loadable.js +12 -0
- package/dist/esm/CapTable/styles.js +18 -0
- package/dist/esm/CapUnifiedSelect/CapUnifiedSelect.js +151 -0
- package/dist/esm/CapUnifiedSelect/index.js +3 -0
- package/dist/esm/CapUnifiedSelect/loadable.js +4 -0
- package/dist/esm/CapUnifiedSelect/messages.js +23 -0
- package/dist/esm/CapUnifiedSelect/styles.js +3 -0
- package/dist/esm/LocaleHoc/index.js +31 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/translations/en.js +329 -0
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +0 -10
- package/index.js +4 -0
- package/package.json +1 -1
- package/translations/en.js +331 -0
package/CapInput/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import CapInput from './CapInput';
|
|
2
|
+
import Number from './Number';
|
|
2
3
|
import Search from './Search';
|
|
3
4
|
import TextArea from './TextArea';
|
|
4
|
-
import Number from './Number';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
CapInput.Number = Number;
|
|
7
7
|
CapInput.Search = Search;
|
|
8
8
|
CapInput.TextArea = TextArea;
|
|
9
|
-
CapInput.Number = Number;
|
|
10
9
|
|
|
11
|
-
export default CapInput;
|
|
10
|
+
export default CapInput;
|
package/CapInput/loadable.js
CHANGED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CapTable - Migrated to Ant Design v5
|
|
3
|
+
* A table component that supports:
|
|
4
|
+
* - Infinite scrolling with virtualization
|
|
5
|
+
* - Sequential data loading
|
|
6
|
+
* - Optimized scroll performance
|
|
7
|
+
*/
|
|
8
|
+
import React, { useEffect, useCallback, useState, useRef } from 'react';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { debounce } from 'lodash';
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import { withStyles } from '@capillarytech/vulcan-react-sdk/utils';
|
|
13
|
+
import styles, { StyledTable } from './styles';
|
|
14
|
+
import LocaleHoc from '../LocaleHoc';
|
|
15
|
+
|
|
16
|
+
const SCROLL_THRESHOLD = 80; // Percentage of scroll to trigger load
|
|
17
|
+
const DEBOUNCE_DELAY = 250; // ms to wait between scroll events
|
|
18
|
+
const DEFAULT_ROW_HEIGHT = 54;
|
|
19
|
+
const DEFAULT_SCROLL_HEIGHT = 400;
|
|
20
|
+
|
|
21
|
+
const CapTable = ({
|
|
22
|
+
id,
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
infiniteScroll,
|
|
26
|
+
pagination,
|
|
27
|
+
dataSource,
|
|
28
|
+
offset_limit,
|
|
29
|
+
setPagination,
|
|
30
|
+
scroll,
|
|
31
|
+
showLoader,
|
|
32
|
+
...rest
|
|
33
|
+
}) => {
|
|
34
|
+
const scrollRef = useRef(null);
|
|
35
|
+
const [hasMore, setHasMore] = useState(true);
|
|
36
|
+
const currentOffsetRef = useRef(0);
|
|
37
|
+
|
|
38
|
+
const loadMore = useCallback(() => {
|
|
39
|
+
if (!showLoader && hasMore) {
|
|
40
|
+
const nextOffset = currentOffsetRef.current + 1;
|
|
41
|
+
const newOffsetLimit = {
|
|
42
|
+
...offset_limit,
|
|
43
|
+
offset: nextOffset
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
currentOffsetRef.current = nextOffset;
|
|
47
|
+
setPagination(newOffsetLimit);
|
|
48
|
+
}
|
|
49
|
+
}, [showLoader, hasMore, setPagination, offset_limit]);
|
|
50
|
+
|
|
51
|
+
const handleScroll = useCallback(
|
|
52
|
+
debounce((event) => {
|
|
53
|
+
const target = event.target;
|
|
54
|
+
if (!target || !infiniteScroll || !hasMore || showLoader) return;
|
|
55
|
+
|
|
56
|
+
const scrollTop = Math.ceil(target.scrollTop);
|
|
57
|
+
const visibleHeight = target.clientHeight;
|
|
58
|
+
const totalHeight = target.scrollHeight;
|
|
59
|
+
|
|
60
|
+
const scrolledPercentage = (scrollTop + visibleHeight) / totalHeight * 100;
|
|
61
|
+
|
|
62
|
+
if (scrolledPercentage >= SCROLL_THRESHOLD) {
|
|
63
|
+
loadMore();
|
|
64
|
+
}
|
|
65
|
+
}, DEBOUNCE_DELAY),
|
|
66
|
+
[infiniteScroll, showLoader, hasMore, loadMore]
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// Setup scroll listener and handle initial load
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const tableBody = document.querySelector(`#${id} .ant-table-body`);
|
|
72
|
+
if (!tableBody) return;
|
|
73
|
+
|
|
74
|
+
scrollRef.current = tableBody;
|
|
75
|
+
tableBody.addEventListener('scroll', handleScroll, { passive: true });
|
|
76
|
+
|
|
77
|
+
// Check if initial load needed
|
|
78
|
+
const shouldLoadInitially = tableBody.scrollHeight <= tableBody.clientHeight
|
|
79
|
+
&& !showLoader
|
|
80
|
+
&& hasMore;
|
|
81
|
+
|
|
82
|
+
if (shouldLoadInitially) {
|
|
83
|
+
currentOffsetRef.current = 0;
|
|
84
|
+
loadMore();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Cleanup
|
|
88
|
+
return () => {
|
|
89
|
+
scrollRef.current?.removeEventListener('scroll', handleScroll);
|
|
90
|
+
handleScroll.cancel();
|
|
91
|
+
};
|
|
92
|
+
}, [id, handleScroll, showLoader, hasMore, loadMore]);
|
|
93
|
+
|
|
94
|
+
// Handle data changes
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!dataSource?.length) {
|
|
97
|
+
currentOffsetRef.current = 0;
|
|
98
|
+
setHasMore(true);
|
|
99
|
+
} else {
|
|
100
|
+
setHasMore(true);
|
|
101
|
+
}
|
|
102
|
+
}, [dataSource]);
|
|
103
|
+
|
|
104
|
+
const tableClassName = classNames(
|
|
105
|
+
'cap-table-v2',
|
|
106
|
+
className,
|
|
107
|
+
{
|
|
108
|
+
'show-loader': showLoader,
|
|
109
|
+
'infinite-scroll': infiniteScroll,
|
|
110
|
+
'has-more': hasMore
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<StyledTable
|
|
116
|
+
id={id}
|
|
117
|
+
className={tableClassName}
|
|
118
|
+
dataSource={dataSource}
|
|
119
|
+
pagination={false}
|
|
120
|
+
scroll={{
|
|
121
|
+
x: scroll?.x,
|
|
122
|
+
y: scroll?.y || DEFAULT_SCROLL_HEIGHT,
|
|
123
|
+
scrollToFirstRowOnChange: false
|
|
124
|
+
}}
|
|
125
|
+
virtual={infiniteScroll}
|
|
126
|
+
rowHeight={DEFAULT_ROW_HEIGHT}
|
|
127
|
+
{...rest}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</StyledTable>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
CapTable.propTypes = {
|
|
135
|
+
id: PropTypes.string.isRequired,
|
|
136
|
+
className: PropTypes.string,
|
|
137
|
+
children: PropTypes.node,
|
|
138
|
+
infiniteScroll: PropTypes.bool,
|
|
139
|
+
pagination: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
|
|
140
|
+
dataSource: PropTypes.array,
|
|
141
|
+
offset_limit: PropTypes.object,
|
|
142
|
+
setPagination: PropTypes.func,
|
|
143
|
+
scroll: PropTypes.object,
|
|
144
|
+
showLoader: PropTypes.bool,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default LocaleHoc(withStyles(CapTable, styles), { key: 'CapTable' });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
2
|
+
import { loadable } from '@capillarytech/cap-ui-utils';
|
|
3
|
+
import React, { Suspense } from 'react';
|
|
4
|
+
|
|
5
|
+
const LoadableComponent = loadable(() => import('./CapTable'));
|
|
6
|
+
|
|
7
|
+
const CapTableLoadable = () => (
|
|
8
|
+
<Suspense fallback={<CapSpin />}>
|
|
9
|
+
<LoadableComponent />
|
|
10
|
+
</Suspense>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default CapTableLoadable;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Table } from 'antd';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import * as styledVars from '../styled/variables';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
CAP_G09,
|
|
8
|
+
CAP_G01,
|
|
9
|
+
CAP_G06,
|
|
10
|
+
CAP_G07,
|
|
11
|
+
CAP_G10,
|
|
12
|
+
SPACING_16,
|
|
13
|
+
SPACING_24,
|
|
14
|
+
FONT_SIZE_S,
|
|
15
|
+
} = styledVars;
|
|
16
|
+
|
|
17
|
+
export const StyledTable = styled(Table)`
|
|
18
|
+
&.cap-table-v2 {
|
|
19
|
+
.ant-table {
|
|
20
|
+
border: 1px solid ${CAP_G07};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.show-loader {
|
|
25
|
+
.ant-table-body > table > tbody::after {
|
|
26
|
+
content: '${(props) => props.loadMoreData}';
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
position: absolute;
|
|
30
|
+
width: 100%;
|
|
31
|
+
align-items: center;
|
|
32
|
+
height: 60px;
|
|
33
|
+
text-align: center;
|
|
34
|
+
font-size: 16px;
|
|
35
|
+
color: gray;
|
|
36
|
+
border-top: 1px solid ${CAP_G07};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
export default css`
|
|
41
|
+
.ant-table {
|
|
42
|
+
border: 1px solid ${CAP_G07};
|
|
43
|
+
|
|
44
|
+
.ant-table-thead > tr > th {
|
|
45
|
+
color: ${CAP_G01};
|
|
46
|
+
font-size: ${FONT_SIZE_S};
|
|
47
|
+
line-height: ${SPACING_16};
|
|
48
|
+
background-color: ${CAP_G10};
|
|
49
|
+
text-align: left;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ant-table-thead > tr > th,
|
|
53
|
+
.ant-table-tbody > tr > td {
|
|
54
|
+
padding: ${SPACING_16} ${SPACING_24};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ant-table-tbody > tr > td {
|
|
58
|
+
border-bottom: 1px solid ${CAP_G07};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ant-table-tbody > tr:last-child > td {
|
|
62
|
+
border-bottom: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.ant-table-thead > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,
|
|
66
|
+
.ant-table-tbody > tr.ant-table-row-hover:not(.ant-table-expanded-row) > td,
|
|
67
|
+
.ant-table-thead > tr:hover:not(.ant-table-expanded-row) > td,
|
|
68
|
+
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td {
|
|
69
|
+
background-color: ${CAP_G09};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ant-table-thead > tr > th .ant-table-column-sorter-up,
|
|
73
|
+
.ant-table-thead > tr > th .ant-table-column-sorter-down {
|
|
74
|
+
&.active {
|
|
75
|
+
color: ${CAP_G01};
|
|
76
|
+
}
|
|
77
|
+
&:not(.active) {
|
|
78
|
+
color: ${CAP_G06};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ant-table-thead {
|
|
83
|
+
.table-children {
|
|
84
|
+
padding: 6px ${SPACING_24} 16px;
|
|
85
|
+
position: relative;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.table-parent {
|
|
89
|
+
padding-bottom: 0;
|
|
90
|
+
padding-left: ${SPACING_24};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.table-children.show-separator:not(:last-child)::after {
|
|
94
|
+
content: '';
|
|
95
|
+
height: 8px;
|
|
96
|
+
width: 1px;
|
|
97
|
+
right: 0;
|
|
98
|
+
top: 30%;
|
|
99
|
+
background-color: ${CAP_G07};
|
|
100
|
+
position: absolute;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.ant-table-thead > tr > th .ant-table-column-sorter {
|
|
105
|
+
vertical-align: unset;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ant-table-body table {
|
|
109
|
+
table-layout: fixed;
|
|
110
|
+
width: 100%;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&.no-pagination-loader {
|
|
115
|
+
.ant-table-body > table > tbody::after {
|
|
116
|
+
content: '';
|
|
117
|
+
height: unset;
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&.hide-hover {
|
|
123
|
+
.ant-table {
|
|
124
|
+
.ant-table-thead
|
|
125
|
+
> tr.ant-table-row-hover:not(.ant-table-expanded-row)
|
|
126
|
+
> td,
|
|
127
|
+
.ant-table-tbody
|
|
128
|
+
> tr.ant-table-row-hover:not(.ant-table-expanded-row)
|
|
129
|
+
> td,
|
|
130
|
+
.ant-table-thead > tr:hover:not(.ant-table-expanded-row) > td,
|
|
131
|
+
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td {
|
|
132
|
+
background: none;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
a {
|
|
138
|
+
color: ${CAP_G01};
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React, { useMemo, useCallback } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Select, TreeSelect } from 'antd';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { selectStyles } from './styles';
|
|
6
|
+
import { useIntl } from 'react-intl';
|
|
7
|
+
import messages from './messages';
|
|
8
|
+
|
|
9
|
+
const StyledSelect = styled(Select)`${selectStyles}`;
|
|
10
|
+
const StyledTreeSelect = styled(TreeSelect)`${selectStyles}`;
|
|
11
|
+
|
|
12
|
+
const CapUnifiedSelect = ({
|
|
13
|
+
type,
|
|
14
|
+
options,
|
|
15
|
+
treeData,
|
|
16
|
+
value,
|
|
17
|
+
onChange,
|
|
18
|
+
onSearch,
|
|
19
|
+
placeholder,
|
|
20
|
+
disabled,
|
|
21
|
+
loading,
|
|
22
|
+
allowClear,
|
|
23
|
+
enableSearch,
|
|
24
|
+
maxTagCount,
|
|
25
|
+
size,
|
|
26
|
+
status,
|
|
27
|
+
className,
|
|
28
|
+
style,
|
|
29
|
+
rightSlotContent,
|
|
30
|
+
virtualized,
|
|
31
|
+
...restProps
|
|
32
|
+
}) => {
|
|
33
|
+
const intl = useIntl();
|
|
34
|
+
|
|
35
|
+
const handleChange = useCallback((newValue, option) => {
|
|
36
|
+
if (onChange) {
|
|
37
|
+
onChange(newValue, option);
|
|
38
|
+
}
|
|
39
|
+
}, [onChange]);
|
|
40
|
+
|
|
41
|
+
const handleSearch = useCallback((searchText) => {
|
|
42
|
+
if (onSearch) {
|
|
43
|
+
onSearch(searchText);
|
|
44
|
+
}
|
|
45
|
+
}, [onSearch]);
|
|
46
|
+
|
|
47
|
+
const mergedClassName = useMemo(() => {
|
|
48
|
+
const classes = ['cap-unified-select'];
|
|
49
|
+
if (className) classes.push(className);
|
|
50
|
+
return classes.join(' ');
|
|
51
|
+
}, [className]);
|
|
52
|
+
|
|
53
|
+
// Common props for both Select and TreeSelect
|
|
54
|
+
const commonProps = {
|
|
55
|
+
value,
|
|
56
|
+
onChange: handleChange,
|
|
57
|
+
onSearch: enableSearch ? handleSearch : undefined,
|
|
58
|
+
placeholder: placeholder || intl.formatMessage(messages.selectPlaceholder),
|
|
59
|
+
disabled,
|
|
60
|
+
loading,
|
|
61
|
+
allowClear,
|
|
62
|
+
showSearch: enableSearch,
|
|
63
|
+
maxTagCount,
|
|
64
|
+
size,
|
|
65
|
+
status,
|
|
66
|
+
className: mergedClassName,
|
|
67
|
+
style,
|
|
68
|
+
virtual: virtualized,
|
|
69
|
+
notFoundContent: loading
|
|
70
|
+
? intl.formatMessage(messages.loading)
|
|
71
|
+
: intl.formatMessage(messages.noData),
|
|
72
|
+
...restProps
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Render right slot content if provided
|
|
76
|
+
const suffixIcon = rightSlotContent && (
|
|
77
|
+
<div className="cap-unified-select-right-slot">
|
|
78
|
+
{rightSlotContent}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// For tree-based selects
|
|
83
|
+
if (type === 'treeSelect' || type === 'multiTreeSelect') {
|
|
84
|
+
return (
|
|
85
|
+
<StyledTreeSelect
|
|
86
|
+
{...commonProps}
|
|
87
|
+
treeData={treeData}
|
|
88
|
+
multiple={type === 'multiTreeSelect'}
|
|
89
|
+
suffixIcon={suffixIcon}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// For regular selects
|
|
95
|
+
return (
|
|
96
|
+
<StyledSelect
|
|
97
|
+
{...commonProps}
|
|
98
|
+
mode={type === 'multiSelect' ? 'multiple' : undefined}
|
|
99
|
+
options={options}
|
|
100
|
+
suffixIcon={suffixIcon}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
CapUnifiedSelect.propTypes = {
|
|
106
|
+
type: PropTypes.oneOf(['select', 'multiSelect', 'treeSelect', 'multiTreeSelect']).isRequired,
|
|
107
|
+
options: PropTypes.arrayOf(
|
|
108
|
+
PropTypes.shape({
|
|
109
|
+
label: PropTypes.node,
|
|
110
|
+
value: PropTypes.any,
|
|
111
|
+
disabled: PropTypes.bool,
|
|
112
|
+
})
|
|
113
|
+
),
|
|
114
|
+
treeData: PropTypes.arrayOf(
|
|
115
|
+
PropTypes.shape({
|
|
116
|
+
title: PropTypes.node,
|
|
117
|
+
value: PropTypes.any,
|
|
118
|
+
children: PropTypes.array,
|
|
119
|
+
disabled: PropTypes.bool,
|
|
120
|
+
})
|
|
121
|
+
),
|
|
122
|
+
value: PropTypes.any,
|
|
123
|
+
onChange: PropTypes.func,
|
|
124
|
+
onSearch: PropTypes.func,
|
|
125
|
+
placeholder: PropTypes.string,
|
|
126
|
+
disabled: PropTypes.bool,
|
|
127
|
+
loading: PropTypes.bool,
|
|
128
|
+
allowClear: PropTypes.bool,
|
|
129
|
+
enableSearch: PropTypes.bool,
|
|
130
|
+
maxTagCount: PropTypes.number,
|
|
131
|
+
size: PropTypes.oneOf(['small', 'middle', 'large']),
|
|
132
|
+
status: PropTypes.oneOf(['error', 'warning']),
|
|
133
|
+
className: PropTypes.string,
|
|
134
|
+
style: PropTypes.object,
|
|
135
|
+
rightSlotContent: PropTypes.node,
|
|
136
|
+
virtualized: PropTypes.bool,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
CapUnifiedSelect.defaultProps = {
|
|
140
|
+
options: [],
|
|
141
|
+
treeData: [],
|
|
142
|
+
value: undefined,
|
|
143
|
+
onChange: undefined,
|
|
144
|
+
onSearch: undefined,
|
|
145
|
+
placeholder: '',
|
|
146
|
+
disabled: false,
|
|
147
|
+
loading: false,
|
|
148
|
+
allowClear: true,
|
|
149
|
+
enableSearch: false,
|
|
150
|
+
maxTagCount: undefined,
|
|
151
|
+
size: 'middle',
|
|
152
|
+
status: undefined,
|
|
153
|
+
className: '',
|
|
154
|
+
style: {},
|
|
155
|
+
rightSlotContent: null,
|
|
156
|
+
virtualized: true,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default CapUnifiedSelect;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
|
|
3
|
+
export default defineMessages({
|
|
4
|
+
selectPlaceholder: {
|
|
5
|
+
id: 'cap.unified.select.placeholder',
|
|
6
|
+
defaultMessage: 'Select an option',
|
|
7
|
+
},
|
|
8
|
+
searchPlaceholder: {
|
|
9
|
+
id: 'cap.unified.select.search.placeholder',
|
|
10
|
+
defaultMessage: 'Search...',
|
|
11
|
+
},
|
|
12
|
+
noData: {
|
|
13
|
+
id: 'cap.unified.select.no.data',
|
|
14
|
+
defaultMessage: 'No data',
|
|
15
|
+
},
|
|
16
|
+
loading: {
|
|
17
|
+
id: 'cap.unified.select.loading',
|
|
18
|
+
defaultMessage: 'Loading...',
|
|
19
|
+
},
|
|
20
|
+
selected: {
|
|
21
|
+
id: 'cap.unified.select.selected',
|
|
22
|
+
defaultMessage: '{count} items selected',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
import * as styledVars from '../styled/variables';
|
|
3
|
+
|
|
4
|
+
export const selectStyles = css`
|
|
5
|
+
&.cap-unified-select {
|
|
6
|
+
width: 100%;
|
|
7
|
+
font-family: ${styledVars.FONT_FAMILY};
|
|
8
|
+
|
|
9
|
+
.ant-select-selector {
|
|
10
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
11
|
+
transition: ${styledVars.TRANSITION_ALL};
|
|
12
|
+
padding: 0 12px;
|
|
13
|
+
min-height: 32px;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
border-color: ${styledVars.CAP_G11};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Right slot content styles */
|
|
23
|
+
.cap-unified-select-right-slot {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: 8px;
|
|
27
|
+
margin-left: 8px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.ant-select-focused {
|
|
31
|
+
.ant-select-selector {
|
|
32
|
+
border-color: ${styledVars.CAP_G01} !important;
|
|
33
|
+
box-shadow: none !important;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Error state */
|
|
38
|
+
&.ant-select-status-error {
|
|
39
|
+
.ant-select-selector {
|
|
40
|
+
border-color: ${styledVars.CAP_RED};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Disabled state */
|
|
45
|
+
&.ant-select-disabled {
|
|
46
|
+
.ant-select-selector {
|
|
47
|
+
background-color: ${styledVars.CAP_G08};
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Dropdown styles */
|
|
53
|
+
.ant-select-dropdown {
|
|
54
|
+
padding: 4px;
|
|
55
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
56
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
57
|
+
|
|
58
|
+
.ant-select-item {
|
|
59
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
60
|
+
padding: 8px 12px;
|
|
61
|
+
transition: ${styledVars.TRANSITION_ALL};
|
|
62
|
+
|
|
63
|
+
&-option-selected {
|
|
64
|
+
background-color: ${styledVars.CAP_PRIMARY.light};
|
|
65
|
+
color: ${styledVars.CAP_PRIMARY.base};
|
|
66
|
+
font-weight: 500;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&-option-active {
|
|
70
|
+
background-color: ${styledVars.CAP_G08};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Search input styles */
|
|
75
|
+
.ant-select-search {
|
|
76
|
+
padding: 8px;
|
|
77
|
+
|
|
78
|
+
input {
|
|
79
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
80
|
+
transition: ${styledVars.TRANSITION_ALL};
|
|
81
|
+
|
|
82
|
+
&:focus {
|
|
83
|
+
border-color: ${styledVars.CAP_G01};
|
|
84
|
+
box-shadow: none;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Multiple selection styles */
|
|
91
|
+
&.ant-select-multiple {
|
|
92
|
+
.ant-select-selection-item {
|
|
93
|
+
background-color: ${styledVars.CAP_PRIMARY.light};
|
|
94
|
+
border-color: ${styledVars.CAP_PRIMARY.light};
|
|
95
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
96
|
+
color: ${styledVars.CAP_PRIMARY.base};
|
|
97
|
+
margin: 2px 4px 2px 0;
|
|
98
|
+
padding: 0 8px;
|
|
99
|
+
height: 24px;
|
|
100
|
+
line-height: 22px;
|
|
101
|
+
|
|
102
|
+
&-remove {
|
|
103
|
+
color: ${styledVars.CAP_PRIMARY.base};
|
|
104
|
+
|
|
105
|
+
&:hover {
|
|
106
|
+
color: ${styledVars.CAP_PRIMARY.hover};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.ant-select-selection-overflow {
|
|
112
|
+
flex-wrap: wrap;
|
|
113
|
+
gap: 4px;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Tree select styles */
|
|
118
|
+
.ant-select-tree {
|
|
119
|
+
padding: 4px 0;
|
|
120
|
+
|
|
121
|
+
.ant-select-tree-node-content-wrapper {
|
|
122
|
+
padding: 4px 8px;
|
|
123
|
+
border-radius: ${styledVars.RADIUS_04};
|
|
124
|
+
transition: ${styledVars.TRANSITION_ALL};
|
|
125
|
+
|
|
126
|
+
&:hover {
|
|
127
|
+
background-color: ${styledVars.CAP_G08};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&.ant-select-tree-node-selected {
|
|
131
|
+
background-color: ${styledVars.CAP_PRIMARY.light};
|
|
132
|
+
color: ${styledVars.CAP_PRIMARY.base};
|
|
133
|
+
font-weight: 500;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.ant-select-tree-switcher {
|
|
138
|
+
width: 24px;
|
|
139
|
+
height: 24px;
|
|
140
|
+
line-height: 24px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.ant-select-tree-checkbox {
|
|
144
|
+
margin: 4px 8px 4px 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* Size variations */
|
|
149
|
+
&.ant-select-lg {
|
|
150
|
+
.ant-select-selector {
|
|
151
|
+
height: 40px;
|
|
152
|
+
padding: 0 16px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.ant-select-selection-item {
|
|
156
|
+
height: 28px;
|
|
157
|
+
line-height: 26px;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&.ant-select-sm {
|
|
162
|
+
.ant-select-selector {
|
|
163
|
+
height: 24px;
|
|
164
|
+
padding: 0 8px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.ant-select-selection-item {
|
|
168
|
+
height: 20px;
|
|
169
|
+
line-height: 18px;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* Loading state */
|
|
174
|
+
&.ant-select-loading {
|
|
175
|
+
.ant-select-arrow {
|
|
176
|
+
.anticon-loading {
|
|
177
|
+
color: ${styledVars.CAP_PRIMARY.base};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
`;
|