@capillarytech/blaze-ui 0.1.6-alpha.50 → 0.1.6-alpha.52
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/CapUnifiedSelect/CapUnifiedSelect.js +32 -18
- package/CapUnifiedSelect/styles.js +108 -44
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { useState, useEffect, useMemo, useCallback, memo } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { TreeSelect, Input, Button } from 'antd-v5';
|
|
5
|
+
import { TreeSelect, Input, Button, Checkbox } from 'antd-v5';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import * as styledVars from '../styled/variables';
|
|
8
8
|
import { CapLabel, CapTooltipWithInfo, CapRow, CapIcon } from '../';
|
|
@@ -23,7 +23,7 @@ const CapUnifiedSelect = ({
|
|
|
23
23
|
style,
|
|
24
24
|
isError = false,
|
|
25
25
|
errorMessage,
|
|
26
|
-
|
|
26
|
+
popoverClassName,
|
|
27
27
|
allowClear = false,
|
|
28
28
|
headerLabel,
|
|
29
29
|
onUpload,
|
|
@@ -153,10 +153,11 @@ const CapUnifiedSelect = ({
|
|
|
153
153
|
const displayValue = dropdownOpen ? tempValue : value;
|
|
154
154
|
return isMulti && Array.isArray(displayValue) && displayValue?.length > 1 ? (
|
|
155
155
|
<>
|
|
156
|
-
<span>+{displayValue.length - 1} more
|
|
156
|
+
<span>+{displayValue.length - 1} more </span>
|
|
157
|
+
<CapIcon type={`${dropdownOpen ? 'up' : 'down'}`} size="s" />
|
|
157
158
|
</>
|
|
158
159
|
) : (
|
|
159
|
-
<CapIcon type=
|
|
160
|
+
<CapIcon type={`${dropdownOpen ? 'up' : 'down'}`} size="s" />
|
|
160
161
|
);
|
|
161
162
|
}, [isMulti, value, tempValue, dropdownOpen]);
|
|
162
163
|
|
|
@@ -209,7 +210,7 @@ const CapUnifiedSelect = ({
|
|
|
209
210
|
if (!customPopupRender) return menu;
|
|
210
211
|
|
|
211
212
|
return (
|
|
212
|
-
<div className={classnames(
|
|
213
|
+
<div className={classnames(popoverClassName, `${type}-popup-container`)}>
|
|
213
214
|
{showSearch && (
|
|
214
215
|
<CapRow className={classnames("cap-unified-select-search-container")} align="middle">
|
|
215
216
|
<Input
|
|
@@ -227,17 +228,30 @@ const CapUnifiedSelect = ({
|
|
|
227
228
|
<CapLabel type="label14" className={classnames("cap-unified-select-upload-label")}>Upload</CapLabel>
|
|
228
229
|
</CapRow>
|
|
229
230
|
)}
|
|
230
|
-
{isMulti && currentItems.length > 0 && (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
231
|
+
{isMulti && currentItems.length > 0 && (() => {
|
|
232
|
+
const totalAvailable = leafValues.length;
|
|
233
|
+
const selectedInScope = Array.isArray(tempValue)
|
|
234
|
+
? tempValue.filter(val => leafValues.includes(val)).length
|
|
235
|
+
: 0;
|
|
236
|
+
return (
|
|
237
|
+
<CapRow
|
|
238
|
+
className={classnames("cap-unified-select-select-all-container")}
|
|
239
|
+
align="middle"
|
|
240
|
+
gap={6}
|
|
241
|
+
>
|
|
242
|
+
<Checkbox
|
|
243
|
+
className={classnames("cap-unified-select-select-all-checkbox")}
|
|
244
|
+
checked={totalAvailable > 0 && selectedInScope === totalAvailable}
|
|
245
|
+
indeterminate={selectedInScope > 0 && selectedInScope < totalAvailable}
|
|
246
|
+
onChange={e => {
|
|
247
|
+
setTempValue(e.target.checked ? leafValues : []);
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
<CapLabel type="label14" className={classnames("cap-unified-select-select-all-label")}>Select all</CapLabel>
|
|
251
|
+
</Checkbox>
|
|
252
|
+
</CapRow>
|
|
253
|
+
);
|
|
254
|
+
})()}
|
|
241
255
|
|
|
242
256
|
{currentItems.length === 0 ? <NoResult noResultCustomText={noResultCustomText} className={classnames(className, "cap-unified-select-no-result")} showUpload={showUpload} options={options}/> : menu}
|
|
243
257
|
|
|
@@ -269,7 +283,7 @@ const CapUnifiedSelect = ({
|
|
|
269
283
|
)}
|
|
270
284
|
</div>
|
|
271
285
|
);
|
|
272
|
-
}, [customPopupRender,
|
|
286
|
+
}, [customPopupRender, popoverClassName, type, showSearch, searchText, isMulti, showUpload, currentItems?.length, allSelected, className, noResultCustomText, onUpload, handleSelectAll, handleConfirm, handleCancel]);
|
|
273
287
|
|
|
274
288
|
return (
|
|
275
289
|
<>
|
|
@@ -278,7 +292,7 @@ const CapUnifiedSelect = ({
|
|
|
278
292
|
type={type}
|
|
279
293
|
treeData={filteredTree}
|
|
280
294
|
value={customPopupRender ? tempValue : value}
|
|
281
|
-
onChange={
|
|
295
|
+
onChange={onChange}
|
|
282
296
|
placeholder={placeholder}
|
|
283
297
|
showSearch={false}
|
|
284
298
|
maxTagCount={0}
|
|
@@ -96,11 +96,75 @@ export const StyledInfoIcon = styled.span`
|
|
|
96
96
|
export const selectStyles = css`
|
|
97
97
|
&.cap-unified-select-container {
|
|
98
98
|
text-align: justify;
|
|
99
|
-
.ant-btn-variant-solid:not(:disabled):not(.ant-btn-disabled):hover{
|
|
100
|
-
background-color: #42b040;
|
|
101
|
-
}
|
|
102
99
|
.ant-tree-select-dropdown{
|
|
103
100
|
padding: 0px;
|
|
101
|
+
.ant-select-tree{
|
|
102
|
+
.ant-select-tree-node-content-wrapper{
|
|
103
|
+
background-color: transparent;
|
|
104
|
+
}
|
|
105
|
+
.ant-select-tree-node-content-wrapper:hover {
|
|
106
|
+
background-color: transparent;
|
|
107
|
+
}
|
|
108
|
+
.ant-select-tree-treenode{
|
|
109
|
+
line-height: 40px;
|
|
110
|
+
margin-bottom: 0px;
|
|
111
|
+
.ant-select-tree-checkbox .ant-select-tree-checkbox-inner{
|
|
112
|
+
height: 18px;
|
|
113
|
+
width: 18px;
|
|
114
|
+
border: 2px solid #B3BAC5;
|
|
115
|
+
border-radius: 4px;
|
|
116
|
+
}
|
|
117
|
+
&:hover{
|
|
118
|
+
background-color: #FFFBE6;
|
|
119
|
+
}
|
|
120
|
+
&:not(.ant-select-tree-treenode-disabled) .ant-select-tree-node-content-wrapper:hover{
|
|
121
|
+
background-color: none;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
.ant-select-tree-node-content-wrapper{
|
|
125
|
+
border-radius: 0px;
|
|
126
|
+
padding-left: 3px;
|
|
127
|
+
}
|
|
128
|
+
.ant-select-tree-indent{
|
|
129
|
+
margin-left: 11px;
|
|
130
|
+
}
|
|
131
|
+
.ant-select-tree-switcher:not(.ant-select-tree-switcher-noop):hover:before{
|
|
132
|
+
background-color: transparent;
|
|
133
|
+
}
|
|
134
|
+
.ant-select-tree-checkbox-checked .ant-select-tree-checkbox-inner{
|
|
135
|
+
background-color: #42B040;
|
|
136
|
+
border: 2px solid #42B040 !important;
|
|
137
|
+
&:hover{
|
|
138
|
+
background-color: #42B040;
|
|
139
|
+
border: 2px solid #42B040 !important;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
.ant-select-tree-switcher .ant-select-tree-switcher-icon{
|
|
143
|
+
font-size: 12px;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
.ant-checkbox-wrapper:not(.ant-checkbox-wrapper-disabled):hover .ant-checkbox-checked:not(.ant-checkbox-disabled) .ant-checkbox-inner{
|
|
148
|
+
background-color: #42B040;
|
|
149
|
+
border: 2px solid #42B040 !important;
|
|
150
|
+
}
|
|
151
|
+
.ant-select-tree-checkbox.ant-select-tree-checkbox-indeterminate
|
|
152
|
+
.ant-select-tree-checkbox-inner {
|
|
153
|
+
background-color: #42b040 !important;
|
|
154
|
+
border-color: #42b040 !important;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.ant-select-tree-checkbox.ant-select-tree-checkbox-indeterminate
|
|
158
|
+
.ant-select-tree-checkbox-inner::after {
|
|
159
|
+
content: "";
|
|
160
|
+
position: absolute;
|
|
161
|
+
top: 50%;
|
|
162
|
+
left: 50%;
|
|
163
|
+
width: 10px;
|
|
164
|
+
height: 2px;
|
|
165
|
+
background-color: #fff;
|
|
166
|
+
transform: translate(-50%, -50%);
|
|
167
|
+
border-radius: 1px;
|
|
104
168
|
}
|
|
105
169
|
.cap-unified-tree-select-s{
|
|
106
170
|
height: 40px;
|
|
@@ -124,7 +188,7 @@ export const selectStyles = css`
|
|
|
124
188
|
align-items: center;
|
|
125
189
|
border-bottom: 1px solid #f0f0f0;
|
|
126
190
|
height: 40px;
|
|
127
|
-
padding-left:
|
|
191
|
+
padding-left: 16px;
|
|
128
192
|
|
|
129
193
|
.cap-unified-select-upload-label{
|
|
130
194
|
margin-left: 12px;
|
|
@@ -132,15 +196,51 @@ export const selectStyles = css`
|
|
|
132
196
|
}
|
|
133
197
|
}
|
|
134
198
|
.cap-unified-select-select-all-container{
|
|
135
|
-
padding: 9px
|
|
199
|
+
padding: 9px 15px;
|
|
136
200
|
cursor: pointer;
|
|
137
201
|
display: flex;
|
|
138
202
|
align-items: center;
|
|
139
203
|
border-bottom: 1px solid #f0f0f0;
|
|
140
204
|
height: 40px;
|
|
205
|
+
.cap-unified-select-select-all-checkbox{
|
|
206
|
+
display: contents !important;
|
|
207
|
+
.ant-checkbox-inner{
|
|
208
|
+
height: 18px;
|
|
209
|
+
width: 18px;
|
|
210
|
+
border: 2px solid #B3BAC5;
|
|
211
|
+
border-radius: 4px;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
.ant-checkbox-indeterminate .ant-checkbox-inner {
|
|
215
|
+
background-color: #42b040 !important;
|
|
216
|
+
border-color: #42b040 !important;
|
|
217
|
+
}
|
|
218
|
+
.ant-checkbox-indeterminate .ant-checkbox-inner::after {
|
|
219
|
+
content: "";
|
|
220
|
+
position: absolute;
|
|
221
|
+
top: 50%;
|
|
222
|
+
left: 50%;
|
|
223
|
+
width: 10px;
|
|
224
|
+
height: 2px;
|
|
225
|
+
background-color: #fff;
|
|
226
|
+
transform: translate(-50%, -50%);
|
|
227
|
+
border-radius: 1px;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
.ant-select-outlined:not(.ant-select-disabled):not(.ant-select-customize-input):not(.ant-pagination-size-changer):hover .ant-select-selector {
|
|
231
|
+
border-color: #7A869A !important;
|
|
232
|
+
}
|
|
233
|
+
.ant-select.ant-select-focused.ant-select-outlined:not(.ant-select-disabled) .ant-select-selector {
|
|
234
|
+
border-color: #7A869A !important;
|
|
235
|
+
box-shadow: 0 0 0 2px #7a869a23;
|
|
236
|
+
outline: 0;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.ant-btn-variant-solid:not(:disabled):not(.ant-btn-disabled):hover{
|
|
240
|
+
background-color: #42b040;
|
|
141
241
|
}
|
|
142
242
|
.ant-select-dropdown{
|
|
143
|
-
margin-top: -
|
|
243
|
+
margin-top: -8px !important;
|
|
144
244
|
border-radius: 4px;
|
|
145
245
|
box-shadow: 0px 4px 8px -2px #091E4240, 0px 0px 1px 0px #091E424F;
|
|
146
246
|
max-height: 368px;
|
|
@@ -169,17 +269,6 @@ export const selectStyles = css`
|
|
|
169
269
|
.ant-input-affix-wrapper .ant-input-prefix{
|
|
170
270
|
left: 13px;
|
|
171
271
|
}
|
|
172
|
-
.ant-select-tree {
|
|
173
|
-
.ant-select-tree-node-content-wrapper{
|
|
174
|
-
background-color: transparent;
|
|
175
|
-
}
|
|
176
|
-
.ant-select-tree-node-content-wrapper:hover {
|
|
177
|
-
background-color: transparent;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
.ant-select-tree .ant-select-tree-switcher:not(.ant-select-tree-switcher-noop):hover:before{
|
|
181
|
-
background-color: transparent;
|
|
182
|
-
}
|
|
183
272
|
.ant-select-selection-item{
|
|
184
273
|
background: transparent;
|
|
185
274
|
}
|
|
@@ -192,38 +281,13 @@ export const selectStyles = css`
|
|
|
192
281
|
.cap-unified-tree-select .ant-select-selector:focus{
|
|
193
282
|
border: 1px solid #7A869A;
|
|
194
283
|
}
|
|
195
|
-
|
|
196
|
-
height: 18px;
|
|
197
|
-
width: 18px;
|
|
198
|
-
border-color: #B3BAC5;
|
|
199
|
-
border-radius: 2px;
|
|
200
|
-
}
|
|
284
|
+
|
|
201
285
|
.cap-unified-tree-select .select-popup-container .ant-select-tree-switcher-noop,
|
|
202
286
|
.cap-unified-tree-select .multiSelect-popup-container .ant-select-tree-switcher-noop {
|
|
203
287
|
display: none;
|
|
204
288
|
}
|
|
205
289
|
.cap-unified-tree-select .multiSelect-popup-container .ant-select-tree-treenode{
|
|
206
|
-
padding-left:
|
|
207
|
-
}
|
|
208
|
-
.ant-tree-select-dropdown .ant-select-tree .ant-select-tree-treenode{
|
|
209
|
-
line-height: 40px;
|
|
210
|
-
margin-bottom: 0px;
|
|
211
|
-
.ant-select-tree-checkbox .ant-select-tree-checkbox-inner{
|
|
212
|
-
height: 18px;
|
|
213
|
-
width: 18px;
|
|
214
|
-
border: 2px solid #B3BAC5;
|
|
215
|
-
}
|
|
216
|
-
&:hover{
|
|
217
|
-
background-color: #FFFBE6;
|
|
218
|
-
border-radius: 4px;
|
|
219
|
-
}
|
|
220
|
-
&:not(.ant-select-tree-treenode-disabled) .ant-select-tree-node-content-wrapper:hover{
|
|
221
|
-
background-color: none;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
.ant-tree-select-dropdown .ant-select-tree .ant-select-tree-node-content-wrapper{
|
|
225
|
-
border-radius: 0px;
|
|
226
|
-
padding-left: 12px;
|
|
290
|
+
padding-left: 4px;
|
|
227
291
|
}
|
|
228
292
|
.ant-select-tree-treenode.ant-select-tree-treenode-selected{
|
|
229
293
|
background-color: #E9F0FE;
|
package/package.json
CHANGED