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

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.
@@ -4,7 +4,7 @@ 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';
@@ -149,6 +149,7 @@ const CapUnifiedSelect = ({
149
149
  showUpload,
150
150
  customPopupRender,
151
151
  showSearch,
152
+ readOnly,
152
153
  searchBasedOn,
153
154
  onConfirm,
154
155
  clearText,
@@ -219,9 +220,30 @@ const CapUnifiedSelect = ({
219
220
 
220
221
  const suffix = useMemo(() => {
221
222
  const count = Array.isArray(displayValue) ? displayValue?.length : (displayValue ? 1 : 0);
223
+ const renderTooltipTitle = (values) => {
224
+ return (
225
+ <div className="cap-unified-select-more-tooltip-content">
226
+ {values.map((val, idx) => (
227
+ <div key={idx}>{val}</div>
228
+ ))}
229
+ </div>
230
+ );
231
+ };
232
+
222
233
  return (
223
234
  <>
224
- {isMulti && count > 1 && <span>+{count - 1} more </span>}
235
+ {isMulti && count > 1 && (
236
+ <span className="cap-unified-select-more-text">
237
+ <CapTooltip
238
+ title={renderTooltipTitle(displayValue.slice(1))}
239
+ placement="bottom"
240
+ overlayClassName="cap-unified-select-more-tooltip"
241
+ arrowPointAtCenter={true}
242
+ >
243
+ <span>+{count - 1} more</span>
244
+ </CapTooltip>
245
+ </span>
246
+ )}
225
247
  <CapIcon
226
248
  className="cap-unified-select-suffix-icon"
227
249
  type={dropdownOpen ? 'up' : 'down'}
@@ -255,13 +277,16 @@ const CapUnifiedSelect = ({
255
277
 
256
278
 
257
279
  const handleDropdownVisibilityChange = useCallback((open) => {
280
+ if (readOnly) {
281
+ return;
282
+ }
258
283
  if (!open && !customPopupRender) {
259
284
  onChange?.(tempValue);
260
285
  } else if (!open) {
261
286
  setTempValue(value);
262
287
  }
263
288
  setDropdownOpen(open);
264
- }, [customPopupRender, value, onChange, tempValue]);
289
+ }, [customPopupRender, value, onChange, tempValue, readOnly]);
265
290
 
266
291
  const renderHeader = useMemo(() => {
267
292
  if (!headerLabel && !tooltip) return null;
@@ -400,8 +425,13 @@ const CapUnifiedSelect = ({
400
425
  );
401
426
 
402
427
  const combinedClassName = useMemo(
403
- () => classnames(containerClassName, 'cap-unified-tree-select', className),
404
- [containerClassName, className]
428
+ () => classnames(
429
+ containerClassName,
430
+ 'cap-unified-tree-select',
431
+ { 'cap-unified-tree-select-readonly': readOnly },
432
+ className
433
+ ),
434
+ [containerClassName, className, readOnly]
405
435
  );
406
436
 
407
437
  return (
@@ -462,6 +492,7 @@ CapUnifiedSelect.propTypes = {
462
492
  headerLabel: PropTypes.string,
463
493
  tooltip: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
464
494
  disabled: PropTypes.bool,
495
+ readOnly: PropTypes.bool,
465
496
  bylineText: PropTypes.string,
466
497
  customPopupRender: PropTypes.bool,
467
498
  showSearch: PropTypes.bool,
@@ -490,6 +521,7 @@ CapUnifiedSelect.defaultProps = {
490
521
  showSearch: true,
491
522
  className: '',
492
523
  disabled: false,
524
+ readOnly: false,
493
525
  showUpload: false,
494
526
  isError: false,
495
527
  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,26 @@ export const selectStyles = css`
62
75
 
63
76
  .cap-unified-tree-select {
64
77
  min-width: 14.286rem;
78
+ margin-top: 0.571rem;
79
+
80
+ &.cap-unified-tree-select-readonly {
81
+ pointer-events: none;
82
+ .ant-select-selector {
83
+ background-color: ${styledVars.CAP_WHITE};
84
+ border-color: ${styledVars.CAP_G08} !important;
85
+ cursor: default;
86
+ }
87
+ .ant-select-arrow {
88
+ pointer-events: auto;
89
+ color: ${styledVars.CAP_G06};
90
+ }
91
+ &:hover .ant-select-selector {
92
+ border-color: ${styledVars.CAP_G08} !important;
93
+ }
94
+ .cap-unified-select-more-text {
95
+ pointer-events: auto;
96
+ }
97
+ }
65
98
  }
66
99
 
67
100
  .ant-select.ant-select-focused.ant-select-outlined:not(.ant-select-disabled)
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.66",
5
5
  "description": "Capillary UI component library with Ant Design v5",
6
6
  "main": "./index.js",
7
7
  "sideEffects": [