@capillarytech/blaze-ui 0.1.6-alpha.37 → 0.1.6-alpha.39

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/.DS_Store ADDED
Binary file
@@ -11,6 +11,10 @@ import { InfoCircleOutlined, SearchOutlined, WarningFilled, DownOutlined } from
11
11
  import withStyles from '../utils/withStyles';
12
12
  import { SelectWrapper, HeaderWrapper, selectStyles } from './styles';
13
13
 
14
+ const StyledTreeSelect = styled(TreeSelect)`
15
+ ${selectStyles}
16
+ `;
17
+
14
18
  const CapUnifiedSelect = ({
15
19
  type,
16
20
  options = [],
@@ -33,16 +37,15 @@ const CapUnifiedSelect = ({
33
37
  searchBasedOn = 'label',
34
38
  onConfirm,
35
39
  onCancel,
40
+ noResultText = 'No results found',
36
41
  ...rest
37
42
  }) => {
38
- const StyledTreeSelect = styled(TreeSelect)`
39
- ${selectStyles}
40
- `;
41
43
 
42
44
  const [searchText, setSearchText] = useState('');
43
45
  const [tempValue, setTempValue] = useState(value);
44
46
  const [allSelected, setAllSelected] = useState(false);
45
47
 
48
+
46
49
  useEffect(() => {
47
50
  setTempValue(value);
48
51
  }, [value]);
@@ -52,10 +55,10 @@ const CapUnifiedSelect = ({
52
55
  listItemHeight: 32,
53
56
  };
54
57
 
55
- const NoResult = () => (
56
- <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: 200, color: '#8c8c8c', fontSize: 14 }}>
57
- <WarningFilled style={{ fontSize: 36, marginBottom: 8, color: '#bfbfbf' }} />
58
- <div style={{ fontWeight: 500 }}>No results found</div>
58
+ const NoResult = ({ noResultText, className }) => (
59
+ <div className={classnames(className, "cap-unified-select-no-result")}>
60
+ <WarningFilled className="cap-unified-select-no-result-icon" />
61
+ <div className="cap-unified-select-no-result-text">{noResultText}</div>
59
62
  </div>
60
63
  );
61
64
 
@@ -101,8 +104,15 @@ const CapUnifiedSelect = ({
101
104
 
102
105
  const handleSelectAll = () => {
103
106
  const availableValues = leafValues;
104
- setTempValue(allSelected ? [] : availableValues);
105
- setAllSelected(!allSelected);
107
+ if (allSelected) {
108
+ // If currently all selected, then unselect all
109
+ setTempValue([]);
110
+ setAllSelected(false);
111
+ } else {
112
+ // Otherwise select all available options
113
+ setTempValue(availableValues);
114
+ setAllSelected(true);
115
+ }
106
116
  };
107
117
 
108
118
  useEffect(() => {
@@ -112,15 +122,13 @@ const CapUnifiedSelect = ({
112
122
  }, [tempValue, leafValues, isMulti]);
113
123
 
114
124
  const handleConfirm = () => {
115
- if (onConfirm) onConfirm(tempValue);
116
- else onChange(tempValue);
117
- setSearchText('');
125
+ console.log('Confirm clicked');
126
+ if (onChange) onChange(tempValue);
118
127
  };
119
128
 
120
129
  const handleCancel = () => {
121
- if (onCancel) onCancel();
130
+ console.log('Cancel clicked');
122
131
  setTempValue(value);
123
- setSearchText('');
124
132
  };
125
133
 
126
134
  const handleTempChange = newValue => {
@@ -164,7 +172,11 @@ const CapUnifiedSelect = ({
164
172
 
165
173
  const renderDropdown = () => {
166
174
  const currentItems = filteredTree;
167
- const selectedCount = Array.isArray(tempValue) ? tempValue.length : (tempValue ? 1 : 0);
175
+ const selectedCount = Array.isArray(tempValue)
176
+ ? isTree
177
+ ? tempValue.filter(val => leafValues.includes(val)).length
178
+ : tempValue.length
179
+ : (tempValue ? 1 : 0);
168
180
 
169
181
  const renderCustomDropdown = menu => {
170
182
  if (!customPopupRender) return menu;
@@ -180,7 +192,7 @@ const CapUnifiedSelect = ({
180
192
  value={searchText}
181
193
  onChange={e => setSearchText(e.target.value)}
182
194
  onKeyDown={e => e.stopPropagation()}
183
- />
195
+ />
184
196
  </div>
185
197
  )}
186
198
  {isMulti && showUpload && (
@@ -204,12 +216,12 @@ const CapUnifiedSelect = ({
204
216
  )}
205
217
  {isMulti && currentItems.length > 0 && (
206
218
  <div style={{ padding: '8px 12px', cursor: 'pointer', display: 'flex', alignItems: 'center', borderBottom: '1px solid #f0f0f0' }} onClick={e => { e.stopPropagation(); handleSelectAll(); }}>
207
- <input type="checkbox" checked={allSelected} readOnly style={{ cursor: 'pointer' }} onClick={e => e.stopPropagation()} />
219
+ <input type="checkbox" checked={allSelected} readOnly style={{ cursor: 'pointer' }} onClick={e => e.stopPropagation()} />
208
220
  <label style={{ marginLeft: 8, cursor: 'pointer' }}>Select all</label>
209
221
  </div>
210
222
  )}
211
223
 
212
- {currentItems.length === 0 ? <NoResult /> : menu}
224
+ {currentItems.length === 0 ? <NoResult noResultText={noResultText} className={classnames(className, "cap-unified-select-no-result")}/> : menu}
213
225
 
214
226
  {currentItems.length > 0 && isMulti && (
215
227
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '8px 12px', borderTop: '1px solid #f0f0f0' }}>
@@ -256,7 +268,7 @@ const CapUnifiedSelect = ({
256
268
  };
257
269
 
258
270
  return (
259
- <SelectWrapper className={classnames(`cap-unified-select-container ${className || ''}`)}>
271
+ <SelectWrapper className={classnames(className, 'cap-unified-select-container')}>
260
272
  {renderHeader()}
261
273
  {renderDropdown()}
262
274
  </SelectWrapper>
@@ -141,6 +141,23 @@ export const selectStyles = css`
141
141
  .multiSelect-popup-container .ant-select-tree-treenode{
142
142
  margin-left: 10px !important;
143
143
  }
144
+ .cap-unified-select-no-result{
145
+ display: flex;
146
+ flex-direction: column;
147
+ align-items: center;
148
+ justify-content: center;
149
+ height: 200px;
150
+ color: #8c8c8c;
151
+ font-size: 14px;
152
+ }
153
+ .cap-unified-select-no-result-icon{
154
+ font-size: 36px;
155
+ margin-bottom: 8px;
156
+ color: #bfbfbf;
157
+ }
158
+ .cap-unified-select-no-result-text{
159
+ font-weight: 500;
160
+ }
144
161
  }
145
162
  &.cap-unified-select {
146
163
  width: 100%;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/blaze-ui",
3
3
  "author": "Capillary Technologies",
4
- "version": "0.1.6-alpha.37",
4
+ "version": "0.1.6-alpha.39",
5
5
  "description": "Capillary UI component library with Ant Design v5",
6
6
  "main": "./index.js",
7
7
  "sideEffects": [