@capillarytech/blaze-ui 0.1.6-alpha.65 → 0.1.6-alpha.67

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.
@@ -6,7 +6,7 @@ export const StyledLabelDiv = styled.div`
6
6
  font-size: ${({ typeStyles }) => typeStyles?.fontSize || '0.857rem'};
7
7
  font-weight: ${({ typeStyles, fontWeight }) => fontWeight || typeStyles?.fontWeight || styledVars.FONT_WEIGHT_REGULAR};
8
8
  color: ${({ typeStyles }) => typeStyles?.color || styledVars.CAP_G04};
9
- line-height: ${({ typeStyles, lineHeight }) => lineHeight || typeStyles?.lineHeight || 'normal'};
9
+ line-height: ${({ typeStyles, lineHeight }) => lineHeight || typeStyles?.lineHeight || styledVars.NORMAL_LINE_HEIGHT};
10
10
  margin: 0;
11
11
  padding: 0;
12
12
  `;
@@ -16,7 +16,7 @@ export const StyledLabelSpan = styled.span`
16
16
  font-size: ${({ typeStyles }) => typeStyles?.fontSize || '0.857rem'};
17
17
  font-weight: ${({ typeStyles, fontWeight }) => fontWeight || typeStyles?.fontWeight || styledVars.FONT_WEIGHT_REGULAR};
18
18
  color: ${({ typeStyles }) => typeStyles?.color || styledVars.CAP_G04};
19
- line-height: ${({ typeStyles, lineHeight }) => lineHeight || typeStyles?.lineHeight || 'normal'};
19
+ line-height: ${({ typeStyles, lineHeight }) => lineHeight || typeStyles?.lineHeight || styledVars.NORMAL_LINE_HEIGHT};
20
20
  margin: 0;
21
21
  padding: 0;
22
22
  `;
@@ -44,28 +44,20 @@ const CapTooltipWithInfo = ({
44
44
  };
45
45
 
46
46
  CapTooltipWithInfo.propTypes = {
47
- /** Content to display in the tooltip */
48
47
  title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
49
- /** Size of the info icon */
50
48
  iconSize: PropTypes.oneOf(['xs', 's', 'm', 'l']),
51
- /** Type of icon to display */
52
49
  iconType: PropTypes.string,
53
- /** Placement of the tooltip relative to the icon */
54
50
  placement: PropTypes.oneOf([
55
51
  'top', 'left', 'right', 'bottom',
56
52
  'topLeft', 'topRight', 'bottomLeft', 'bottomRight',
57
53
  'leftTop', 'leftBottom', 'rightTop', 'rightBottom',
58
54
  ]),
59
- /** How the tooltip is triggered */
60
55
  trigger: PropTypes.oneOfType([
61
56
  PropTypes.string,
62
57
  PropTypes.arrayOf(PropTypes.string),
63
58
  ]),
64
- /** Additional class name */
65
59
  className: PropTypes.string,
66
- /** Additional props passed to the CapTooltip component */
67
60
  tooltipProps: PropTypes.object,
68
- /** Additional props passed to the CapIcon component */
69
61
  iconProps: PropTypes.object,
70
62
  };
71
63
 
@@ -4,11 +4,18 @@ import classnames from 'classnames';
4
4
  import { TreeSelect, Input, Button, Checkbox } from 'antd-v5';
5
5
  import styled from 'styled-components';
6
6
  import * as styledVars from '../styled/variables';
7
- import { CapLabel, CapTooltipWithInfo, CapRow, CapIcon } from '../';
7
+ import { CapLabel, CapTooltipWithInfo, CapRow, CapIcon, CapTooltip } from '../';
8
8
  import withStyles from '../utils/withStyles';
9
9
  import withMemo from '../utils/withMemo';
10
10
  import { HeaderWrapper, selectStyles } from './styles';
11
11
 
12
+ const SELECT_TYPES = {
13
+ SELECT: 'select',
14
+ MULTI_SELECT: 'multiSelect',
15
+ TREE_SELECT: 'treeSelect',
16
+ MULTI_TREE_SELECT: 'multiTreeSelect'
17
+ };
18
+
12
19
  const StyledTreeSelect = styled(TreeSelect)`
13
20
  ${selectStyles}
14
21
  `;
@@ -149,6 +156,7 @@ const CapUnifiedSelect = ({
149
156
  showUpload,
150
157
  customPopupRender,
151
158
  showSearch,
159
+ readOnly,
152
160
  searchBasedOn,
153
161
  onConfirm,
154
162
  clearText,
@@ -167,8 +175,8 @@ const CapUnifiedSelect = ({
167
175
  if (!isEqual) setTempValue(value);
168
176
  }, [value]);
169
177
 
170
- const isMulti = useMemo(() => type === 'multiSelect' || type === 'multiTreeSelect', [type]);
171
- const isTree = useMemo(() => type === 'treeSelect' || type === 'multiTreeSelect', [type]);
178
+ const isMulti = useMemo(() => type === SELECT_TYPES.MULTI_SELECT || type === SELECT_TYPES.MULTI_TREE_SELECT, [type]);
179
+ const isTree = useMemo(() => type === SELECT_TYPES.TREE_SELECT || type === SELECT_TYPES.MULTI_TREE_SELECT, [type]);
172
180
 
173
181
  const dataSource = useMemo(() => {
174
182
  if (!options?.length) return [];
@@ -219,9 +227,30 @@ const CapUnifiedSelect = ({
219
227
 
220
228
  const suffix = useMemo(() => {
221
229
  const count = Array.isArray(displayValue) ? displayValue?.length : (displayValue ? 1 : 0);
230
+ const renderTooltipTitle = (values) => {
231
+ return (
232
+ <div className="cap-unified-select-more-tooltip-content">
233
+ {values.map((val, idx) => (
234
+ <div key={idx}>{val}</div>
235
+ ))}
236
+ </div>
237
+ );
238
+ };
239
+
222
240
  return (
223
241
  <>
224
- {isMulti && count > 1 && <span>+{count - 1} more </span>}
242
+ {isMulti && count > 1 && (
243
+ <span className="cap-unified-select-more-text">
244
+ <CapTooltip
245
+ title={renderTooltipTitle(displayValue.slice(1))}
246
+ placement="bottom"
247
+ overlayClassName="cap-unified-select-more-tooltip"
248
+ arrowPointAtCenter={true}
249
+ >
250
+ <span>+{count - 1} more</span>
251
+ </CapTooltip>
252
+ </span>
253
+ )}
225
254
  <CapIcon
226
255
  className="cap-unified-select-suffix-icon"
227
256
  type={dropdownOpen ? 'up' : 'down'}
@@ -255,13 +284,16 @@ const CapUnifiedSelect = ({
255
284
 
256
285
 
257
286
  const handleDropdownVisibilityChange = useCallback((open) => {
287
+ if (readOnly) {
288
+ return;
289
+ }
258
290
  if (!open && !customPopupRender) {
259
291
  onChange?.(tempValue);
260
292
  } else if (!open) {
261
293
  setTempValue(value);
262
294
  }
263
295
  setDropdownOpen(open);
264
- }, [customPopupRender, value, onChange, tempValue]);
296
+ }, [customPopupRender, value, onChange, tempValue, readOnly]);
265
297
 
266
298
  const renderHeader = useMemo(() => {
267
299
  if (!headerLabel && !tooltip) return null;
@@ -371,7 +403,7 @@ const CapUnifiedSelect = ({
371
403
  </div>
372
404
  )}
373
405
 
374
- {(type === 'select' || type === 'treeSelect') && (
406
+ {(type === SELECT_TYPES.SELECT || type === SELECT_TYPES.TREE_SELECT) && (
375
407
  <CapRow className="cap-unified-select-tree-clear-container" onClick={handleClearAll}>
376
408
  <CapLabel className="cap-unified-select-tree-clear-label">{clearText}</CapLabel>
377
409
  </CapRow>
@@ -400,8 +432,13 @@ const CapUnifiedSelect = ({
400
432
  );
401
433
 
402
434
  const combinedClassName = useMemo(
403
- () => classnames(containerClassName, 'cap-unified-tree-select', className),
404
- [containerClassName, className]
435
+ () => classnames(
436
+ containerClassName,
437
+ 'cap-unified-tree-select',
438
+ { 'cap-unified-tree-select-readonly': readOnly },
439
+ className
440
+ ),
441
+ [containerClassName, className, readOnly]
405
442
  );
406
443
 
407
444
  return (
@@ -441,7 +478,7 @@ const CapUnifiedSelect = ({
441
478
  {...rest}
442
479
  />
443
480
  {isError && (
444
- <CapLabel className="cap-unified-select-status" style={{ color: 'red' }}>
481
+ <CapLabel className="cap-unified-select-status" style={{ color: styledVars.CAP_RED }}>
445
482
  {errorMessage}
446
483
  </CapLabel>
447
484
  )}
@@ -450,7 +487,7 @@ const CapUnifiedSelect = ({
450
487
  };
451
488
 
452
489
  CapUnifiedSelect.propTypes = {
453
- type: PropTypes.oneOf(['select', 'multiSelect', 'treeSelect', 'multiTreeSelect']),
490
+ type: PropTypes.oneOf(Object.values(SELECT_TYPES)),
454
491
  options: PropTypes.array,
455
492
  value: PropTypes.any,
456
493
  containerClassName: PropTypes.string,
@@ -462,6 +499,7 @@ CapUnifiedSelect.propTypes = {
462
499
  headerLabel: PropTypes.string,
463
500
  tooltip: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
464
501
  disabled: PropTypes.bool,
502
+ readOnly: PropTypes.bool,
465
503
  bylineText: PropTypes.string,
466
504
  customPopupRender: PropTypes.bool,
467
505
  showSearch: PropTypes.bool,
@@ -478,7 +516,7 @@ CapUnifiedSelect.propTypes = {
478
516
  };
479
517
 
480
518
  CapUnifiedSelect.defaultProps = {
481
- type: 'select',
519
+ type: SELECT_TYPES.SELECT,
482
520
  placeholder: 'Select an option',
483
521
  searchBasedOn: 'label',
484
522
  noResultCustomText: 'No results found',
@@ -490,6 +528,7 @@ CapUnifiedSelect.defaultProps = {
490
528
  showSearch: true,
491
529
  className: '',
492
530
  disabled: false,
531
+ readOnly: false,
493
532
  showUpload: false,
494
533
  isError: false,
495
534
  onUpload: () => {},
@@ -4,7 +4,6 @@ import * as styledVars from '../styled/variables';
4
4
  export const HeaderWrapper = styled.div`
5
5
  display: flex;
6
6
  align-items: center;
7
- gap: ${styledVars.SPACING_04};
8
7
 
9
8
  &.disabled {
10
9
  opacity: 0.5;
@@ -18,6 +17,12 @@ export const selectStyles = css`
18
17
  &.disabled {
19
18
  cursor: not-allowed;
20
19
  }
20
+ .cap-unified-select-more-text {
21
+ cursor: pointer;
22
+ color: ${styledVars.CAP_G01};
23
+ margin-right: ${styledVars.SPACING_04};
24
+ position: relative;
25
+ }
21
26
  .cap-unified-select-suffix-icon {
22
27
  color: ${styledVars.CAP_G01};
23
28
  }
@@ -30,6 +35,14 @@ export const selectStyles = css`
30
35
  }
31
36
  }
32
37
  }
38
+
39
+ .cap-unified-tree-select-readonly.ant-select-outlined {
40
+ &:hover .ant-select-selector,
41
+ &:active .ant-select-selector,
42
+ &:focus .ant-select-selector {
43
+ border-color: ${styledVars.CAP_G08} !important;
44
+ }
45
+ }
33
46
  .ant-select-selector .ant-select-selection-placeholder{
34
47
  pointer-events: unset;
35
48
  }
@@ -62,6 +75,25 @@ export const selectStyles = css`
62
75
 
63
76
  .cap-unified-tree-select {
64
77
  min-width: 14.286rem;
78
+
79
+ &.cap-unified-tree-select-readonly {
80
+ pointer-events: none;
81
+ .ant-select-selector {
82
+ background-color: ${styledVars.CAP_WHITE};
83
+ border-color: ${styledVars.CAP_G08} !important;
84
+ cursor: default;
85
+ }
86
+ .ant-select-arrow {
87
+ pointer-events: auto;
88
+ color: ${styledVars.CAP_G06};
89
+ }
90
+ &:hover .ant-select-selector {
91
+ border-color: ${styledVars.CAP_G08} !important;
92
+ }
93
+ .cap-unified-select-more-text {
94
+ pointer-events: auto;
95
+ }
96
+ }
65
97
  }
66
98
 
67
99
  .ant-select.ant-select-focused.ant-select-outlined:not(.ant-select-disabled)
@@ -91,7 +123,7 @@ export const selectStyles = css`
91
123
  align-self: center;
92
124
  }
93
125
  .cap-unified-tree-select .ant-select-selector:focus {
94
- border: 1px solid ${styledVars.CAP_G11};
126
+ border: 0.071rem solid ${styledVars.CAP_G11};
95
127
  }
96
128
  .cap-unified-tree-select .ant-select-tree-treenode {
97
129
  padding-left: ${styledVars.SPACING_04};
@@ -103,7 +135,7 @@ export const selectStyles = css`
103
135
 
104
136
  /* Common styles for all types */
105
137
  &.custom-popup-container {
106
- width: max-content !important;
138
+ width: max-content;
107
139
 
108
140
  .ant-select-tree {
109
141
  .ant-select-tree-node-content-wrapper {
@@ -158,7 +190,7 @@ export const selectStyles = css`
158
190
  }
159
191
  .ant-select-tree-node-content-wrapper {
160
192
  border-radius: 0;
161
- padding-left: 3px;
193
+ padding-left: 0.214rem;
162
194
  }
163
195
  .ant-select-tree-indent {
164
196
  margin-left: ${styledVars.SPACING_12};
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.65",
4
+ "version": "0.1.6-alpha.67",
5
5
  "description": "Capillary UI component library with Ant Design v5",
6
6
  "main": "./index.js",
7
7
  "sideEffects": [
@@ -14,6 +14,8 @@ export const CAP_SECONDARY = {
14
14
  light: 'rgba("#2466ea", 0.1)',
15
15
  };
16
16
 
17
+ export const NORMAL_LINE_HEIGHT = "normal";
18
+
17
19
  // Custom colors
18
20
  export const CAP_ORANGE = "#f87d23";
19
21
  export const CAP_ORANGE01 = "#ffe5d2";