@capillarytech/blaze-ui 0.1.6-alpha.19 → 0.1.6-alpha.21

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.
Files changed (77) hide show
  1. package/CapUnifiedSelect/CapUnifiedSelect.js +19 -7
  2. package/dist/CapUnifiedSelect/CapUnifiedSelect.js +18 -8
  3. package/dist/esm/CapUnifiedSelect/CapUnifiedSelect.js +18 -8
  4. package/package.json +3 -7
  5. package/.DS_Store +0 -0
  6. package/CapHeading/CapHeading.js +0 -71
  7. package/CapHeading/index.js +0 -1
  8. package/CapHeading/styles.js +0 -125
  9. package/CapIcon/CapIcon.js +0 -83
  10. package/CapIcon/index.js +0 -1
  11. package/CapInfoNote/CapInfoNote.js +0 -54
  12. package/CapInfoNote/index.js +0 -1
  13. package/CapInfoNote/styles.js +0 -63
  14. package/CapLabel/CapLabel.js +0 -106
  15. package/CapLabel/index.js +0 -1
  16. package/CapLabel/styles.js +0 -221
  17. package/CapRow/CapRow.js +0 -22
  18. package/CapRow/index.js +0 -1
  19. package/CapRow/styles.js +0 -9
  20. package/CapSelect/CapSelect.js +0 -62
  21. package/CapSelect/index.js +0 -1
  22. package/CapSelect/styles.js +0 -119
  23. package/CapTooltip/CapTooltip.js +0 -36
  24. package/CapTooltip/index.js +0 -1
  25. package/CapTooltip/styles.js +0 -42
  26. package/CapTreeSelect/CapTreeSelect.js +0 -86
  27. package/CapTreeSelect/index.js +0 -1
  28. package/CapTreeSelect/styles.js +0 -122
  29. package/dist/CapHeading/CapHeading.js +0 -48
  30. package/dist/CapHeading/index.js +0 -13
  31. package/dist/CapHeading/styles.js +0 -131
  32. package/dist/CapIcon/CapIcon.js +0 -88
  33. package/dist/CapIcon/index.js +0 -13
  34. package/dist/CapInfoNote/CapInfoNote.js +0 -69
  35. package/dist/CapInfoNote/index.js +0 -13
  36. package/dist/CapInfoNote/styles.js +0 -15
  37. package/dist/CapLabel/CapLabel.js +0 -57
  38. package/dist/CapLabel/index.js +0 -13
  39. package/dist/CapLabel/styles.js +0 -227
  40. package/dist/CapRow/CapRow.js +0 -29
  41. package/dist/CapRow/index.js +0 -13
  42. package/dist/CapRow/styles.js +0 -12
  43. package/dist/CapSelect/CapSelect.js +0 -72
  44. package/dist/CapSelect/index.js +0 -13
  45. package/dist/CapSelect/styles.js +0 -15
  46. package/dist/CapTooltip/CapTooltip.js +0 -41
  47. package/dist/CapTooltip/index.js +0 -13
  48. package/dist/CapTooltip/styles.js +0 -15
  49. package/dist/CapTreeSelect/CapTreeSelect.js +0 -81
  50. package/dist/CapTreeSelect/index.js +0 -13
  51. package/dist/CapTreeSelect/styles.js +0 -20
  52. package/dist/esm/CapHeading/CapHeading.js +0 -41
  53. package/dist/esm/CapHeading/index.js +0 -1
  54. package/dist/esm/CapHeading/styles.js +0 -123
  55. package/dist/esm/CapIcon/CapIcon.js +0 -79
  56. package/dist/esm/CapIcon/index.js +0 -1
  57. package/dist/esm/CapInfoNote/CapInfoNote.js +0 -62
  58. package/dist/esm/CapInfoNote/index.js +0 -1
  59. package/dist/esm/CapInfoNote/styles.js +0 -6
  60. package/dist/esm/CapLabel/CapLabel.js +0 -50
  61. package/dist/esm/CapLabel/index.js +0 -1
  62. package/dist/esm/CapLabel/styles.js +0 -219
  63. package/dist/esm/CapRow/CapRow.js +0 -22
  64. package/dist/esm/CapRow/index.js +0 -1
  65. package/dist/esm/CapRow/styles.js +0 -5
  66. package/dist/esm/CapSelect/CapSelect.js +0 -65
  67. package/dist/esm/CapSelect/index.js +0 -1
  68. package/dist/esm/CapSelect/styles.js +0 -6
  69. package/dist/esm/CapTooltip/CapTooltip.js +0 -34
  70. package/dist/esm/CapTooltip/index.js +0 -1
  71. package/dist/esm/CapTooltip/styles.js +0 -6
  72. package/dist/esm/CapTreeSelect/CapTreeSelect.js +0 -74
  73. package/dist/esm/CapTreeSelect/index.js +0 -1
  74. package/dist/esm/CapTreeSelect/styles.js +0 -11
  75. package/dist/esm/hoc/ComponentWithLabelHOC.js +0 -170
  76. package/dist/hoc/ComponentWithLabelHOC.js +0 -178
  77. package/hoc/ComponentWithLabelHOC.js +0 -225
@@ -5,7 +5,7 @@ import classnames from 'classnames';
5
5
  import { Select, TreeSelect, Tooltip, Input, Button } from 'antd';
6
6
  import { InfoCircleOutlined, SearchOutlined, WarningFilled, DownOutlined } from '@ant-design/icons';
7
7
  import { SelectWrapper, HeaderWrapper, selectStyles } from './styles';
8
- import withStyles from './withStyles';
8
+ import withStyles from '../../utils/withStyles';
9
9
  import styled from 'styled-components';
10
10
 
11
11
  const CapUnifiedSelect = ({
@@ -152,10 +152,10 @@ const CapUnifiedSelect = ({
152
152
  };
153
153
 
154
154
  const suffix =
155
- (type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 0 ? (
155
+ (type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 1 ? (
156
156
  <>
157
157
  <span>
158
- +{value.length} more
158
+ +{value.length - 1} more
159
159
  <DownOutlined />
160
160
  </span>
161
161
  </>
@@ -163,6 +163,18 @@ const CapUnifiedSelect = ({
163
163
  <DownOutlined />
164
164
  );
165
165
 
166
+ const prefix = () => {
167
+ if((type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 0) {
168
+ const selectedLabels = options
169
+ .filter((opt) => value.includes(opt.value))
170
+ .map((opt) => opt.label);
171
+
172
+ return selectedLabels[0];
173
+ } else {
174
+ return null;
175
+ }
176
+ }
177
+
166
178
  const renderHeader = () => {
167
179
  if (!label && !tooltip) return null;
168
180
  return (
@@ -274,9 +286,9 @@ const CapUnifiedSelect = ({
274
286
  value={customPopupRender ? tempValue : value}
275
287
  onChange={customPopupRender ? handleTempChange : onChange}
276
288
  placeholder={placeholder}
277
- maxTagCount={0} // hides all tags
278
- maxTagPlaceholder={() => null} // hides default `+N more` placeholder
279
- prefix={type === "multiTreeSelect" && value.length > 0 ? <>{placeholder}</> : null}
289
+ maxTagCount={0}
290
+ maxTagPlaceholder={() => null}
291
+ prefix={type === "multiTreeSelect" && value.length > 0 && prefix()}
280
292
  suffixIcon={suffix}
281
293
  className={classnames(`cap-unified-tree-select ${className || ''}`)}
282
294
  style={style}
@@ -306,7 +318,7 @@ const CapUnifiedSelect = ({
306
318
  placeholder={placeholder}
307
319
  maxTagCount={0}
308
320
  maxTagPlaceholder={() => null}
309
- prefix={type === "multiSelect" && value.length > 0 ? <>{placeholder}</> : null}
321
+ prefix={type === "multiSelect" && value.length > 0 && prefix()}
310
322
  suffixIcon={suffix}
311
323
  className={classnames('cap-unified-select', className)}
312
324
  style={style}
@@ -11,7 +11,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _antd = require("antd");
12
12
  var _icons = require("@ant-design/icons");
13
13
  var _styles = require("./styles");
14
- var _withStyles = _interopRequireDefault(require("./withStyles"));
14
+ var _withStyles = _interopRequireDefault(require("../../utils/withStyles"));
15
15
  var _styledComponents = _interopRequireDefault(require("styled-components"));
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
17
17
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -196,7 +196,19 @@ var CapUnifiedSelect = function CapUnifiedSelect(_ref) {
196
196
  var handleTempChange = function handleTempChange(newValue) {
197
197
  setTempValue(newValue);
198
198
  };
199
- var suffix = (type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 0 ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", null, "+", value.length, " more", /*#__PURE__*/_react["default"].createElement(_icons.DownOutlined, null))) : /*#__PURE__*/_react["default"].createElement(_icons.DownOutlined, null);
199
+ var suffix = (type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 1 ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", null, "+", value.length - 1, " more", /*#__PURE__*/_react["default"].createElement(_icons.DownOutlined, null))) : /*#__PURE__*/_react["default"].createElement(_icons.DownOutlined, null);
200
+ var prefix = function prefix() {
201
+ if ((type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 0) {
202
+ var selectedLabels = options.filter(function (opt) {
203
+ return value.includes(opt.value);
204
+ }).map(function (opt) {
205
+ return opt.label;
206
+ });
207
+ return selectedLabels[0];
208
+ } else {
209
+ return null;
210
+ }
211
+ };
200
212
  var renderHeader = function renderHeader() {
201
213
  if (!label && !tooltip) return null;
202
214
  return /*#__PURE__*/_react["default"].createElement(_styles.HeaderWrapper, {
@@ -307,13 +319,11 @@ var CapUnifiedSelect = function CapUnifiedSelect(_ref) {
307
319
  value: customPopupRender ? tempValue : value,
308
320
  onChange: customPopupRender ? handleTempChange : onChange,
309
321
  placeholder: placeholder,
310
- maxTagCount: 0 // hides all tags
311
- ,
322
+ maxTagCount: 0,
312
323
  maxTagPlaceholder: function maxTagPlaceholder() {
313
324
  return null;
314
- } // hides default `+N more` placeholder
315
- ,
316
- prefix: type === "multiTreeSelect" && value.length > 0 ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, placeholder) : null,
325
+ },
326
+ prefix: type === "multiTreeSelect" && value.length > 0 && prefix(),
317
327
  suffixIcon: suffix,
318
328
  className: (0, _classnames["default"])("cap-unified-tree-select ".concat(className || '')),
319
329
  style: style,
@@ -344,7 +354,7 @@ var CapUnifiedSelect = function CapUnifiedSelect(_ref) {
344
354
  maxTagPlaceholder: function maxTagPlaceholder() {
345
355
  return null;
346
356
  },
347
- prefix: type === "multiSelect" && value.length > 0 ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, placeholder) : null,
357
+ prefix: type === "multiSelect" && value.length > 0 && prefix(),
348
358
  suffixIcon: suffix,
349
359
  className: (0, _classnames["default"])('cap-unified-select', className),
350
360
  style: style,
@@ -18,7 +18,7 @@ import classnames from 'classnames';
18
18
  import { Select, TreeSelect, Tooltip, Input, Button } from 'antd';
19
19
  import { InfoCircleOutlined, SearchOutlined, WarningFilled, DownOutlined } from '@ant-design/icons';
20
20
  import { SelectWrapper, HeaderWrapper, selectStyles } from './styles';
21
- import withStyles from './withStyles';
21
+ import withStyles from '../../utils/withStyles';
22
22
  import styled from 'styled-components';
23
23
  var CapUnifiedSelect = function CapUnifiedSelect(_ref) {
24
24
  var type = _ref.type,
@@ -189,7 +189,19 @@ var CapUnifiedSelect = function CapUnifiedSelect(_ref) {
189
189
  var handleTempChange = function handleTempChange(newValue) {
190
190
  setTempValue(newValue);
191
191
  };
192
- var suffix = (type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "+", value.length, " more", /*#__PURE__*/React.createElement(DownOutlined, null))) : /*#__PURE__*/React.createElement(DownOutlined, null);
192
+ var suffix = (type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "+", value.length - 1, " more", /*#__PURE__*/React.createElement(DownOutlined, null))) : /*#__PURE__*/React.createElement(DownOutlined, null);
193
+ var prefix = function prefix() {
194
+ if ((type === "multiTreeSelect" || type === "multiSelect") && Array.isArray(value) && value.length > 0) {
195
+ var selectedLabels = options.filter(function (opt) {
196
+ return value.includes(opt.value);
197
+ }).map(function (opt) {
198
+ return opt.label;
199
+ });
200
+ return selectedLabels[0];
201
+ } else {
202
+ return null;
203
+ }
204
+ };
193
205
  var renderHeader = function renderHeader() {
194
206
  if (!label && !tooltip) return null;
195
207
  return /*#__PURE__*/React.createElement(HeaderWrapper, {
@@ -300,13 +312,11 @@ var CapUnifiedSelect = function CapUnifiedSelect(_ref) {
300
312
  value: customPopupRender ? tempValue : value,
301
313
  onChange: customPopupRender ? handleTempChange : onChange,
302
314
  placeholder: placeholder,
303
- maxTagCount: 0 // hides all tags
304
- ,
315
+ maxTagCount: 0,
305
316
  maxTagPlaceholder: function maxTagPlaceholder() {
306
317
  return null;
307
- } // hides default `+N more` placeholder
308
- ,
309
- prefix: type === "multiTreeSelect" && value.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, placeholder) : null,
318
+ },
319
+ prefix: type === "multiTreeSelect" && value.length > 0 && prefix(),
310
320
  suffixIcon: suffix,
311
321
  className: classnames("cap-unified-tree-select ".concat(className || '')),
312
322
  style: style,
@@ -337,7 +347,7 @@ var CapUnifiedSelect = function CapUnifiedSelect(_ref) {
337
347
  maxTagPlaceholder: function maxTagPlaceholder() {
338
348
  return null;
339
349
  },
340
- prefix: type === "multiSelect" && value.length > 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, placeholder) : null,
350
+ prefix: type === "multiSelect" && value.length > 0 && prefix(),
341
351
  suffixIcon: suffix,
342
352
  className: classnames('cap-unified-select', className),
343
353
  style: style,
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.19",
4
+ "version": "0.1.6-alpha.21",
5
5
  "description": "Capillary UI component library with Ant Design v5",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/esm/index.js",
@@ -26,16 +26,12 @@
26
26
  "!**/tests"
27
27
  ],
28
28
  "homepage": "https://github.com/Capillary/blaze-ui",
29
- "peerDependencies": {
30
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
31
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
32
- "react-intl": "^6.5.0"
33
- },
34
29
  "dependencies": {
35
30
  "@ant-design/icons": "^5.2.6",
36
31
  "@capillarytech/cap-ui-utils": "^3.0.4",
37
32
  "antd": "^5.12.0",
38
33
  "prop-types": "^15.8.1",
39
- "styled-components": "^5.3.11"
34
+ "styled-components": "^5.3.11",
35
+ "react-intl": "2.7.2"
40
36
  }
41
37
  }
package/.DS_Store DELETED
Binary file
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { HeadingWrapper, HeadingSpan } from './styles';
4
-
5
- const CapHeading = ({ type = 'h5', children, as, ...rest }) => {
6
- return (
7
- <HeadingWrapper type={type} as={as || 'div'} {...rest}>
8
- {children}
9
- </HeadingWrapper>
10
- );
11
- };
12
-
13
- CapHeading.propTypes = {
14
- type: PropTypes.oneOf([
15
- 'h0',
16
- 'h1',
17
- 'h2',
18
- 'h3',
19
- 'h4',
20
- 'h5',
21
- 'h6',
22
- 'h7',
23
- 'h8',
24
- 'h9',
25
- 'h10',
26
- 'label1',
27
- 'label2',
28
- 'label3',
29
- 'label4',
30
- 'label5',
31
- 'label6',
32
- ]),
33
- children: PropTypes.node,
34
- as: PropTypes.string,
35
- };
36
-
37
- // Inline span version
38
- const CapHeadingSpan = ({ type = 'h5', children, ...rest }) => {
39
- return (
40
- <HeadingSpan type={type} {...rest}>
41
- {children}
42
- </HeadingSpan>
43
- );
44
- };
45
-
46
- CapHeadingSpan.propTypes = {
47
- type: PropTypes.oneOf([
48
- 'h0',
49
- 'h1',
50
- 'h2',
51
- 'h3',
52
- 'h4',
53
- 'h5',
54
- 'h6',
55
- 'h7',
56
- 'h8',
57
- 'h9',
58
- 'h10',
59
- 'label1',
60
- 'label2',
61
- 'label3',
62
- 'label4',
63
- 'label5',
64
- 'label6',
65
- ]),
66
- children: PropTypes.node,
67
- };
68
-
69
- CapHeading.Span = CapHeadingSpan;
70
-
71
- export default CapHeading;
@@ -1 +0,0 @@
1
- export { default } from './CapHeading';
@@ -1,125 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
- import * as styledVars from '../styled/variables';
3
-
4
- const headings = {
5
- h0: {
6
- fontSize: '28px',
7
- fontWeight: '500',
8
- color: styledVars.CAP_G01,
9
- lineHeight: '36px',
10
- },
11
- h1: {
12
- fontSize: '24px',
13
- fontWeight: '500',
14
- color: styledVars.CAP_G01,
15
- lineHeight: '32px',
16
- },
17
- h2: {
18
- fontSize: '20px',
19
- fontWeight: '500',
20
- color: styledVars.CAP_G01,
21
- lineHeight: '28px',
22
- },
23
- h3: {
24
- fontSize: '16px',
25
- fontWeight: '500',
26
- color: styledVars.CAP_G01,
27
- lineHeight: '24px',
28
- },
29
- h4: {
30
- fontSize: '14px',
31
- fontWeight: '500',
32
- color: styledVars.CAP_G01,
33
- lineHeight: '20px',
34
- },
35
- h5: {
36
- fontSize: '14px',
37
- fontWeight: 'normal',
38
- color: styledVars.CAP_G01,
39
- lineHeight: '20px',
40
- },
41
- h6: {
42
- color: styledVars.CAP_G04,
43
- fontSize: '14px',
44
- fontWeight: 'normal',
45
- lineHeight: '20px',
46
- },
47
- h7: {
48
- fontSize: '20px',
49
- fontWeight: '500',
50
- color: styledVars.CAP_G04,
51
- lineHeight: '28px',
52
- },
53
- h8: {
54
- fontSize: '14px',
55
- fontWeight: '400',
56
- color: styledVars.CAP_G01,
57
- lineHeight: '20px',
58
- },
59
- h9: {
60
- fontSize: '14px',
61
- fontWeight: '500',
62
- color: styledVars.CAP_WHITE,
63
- lineHeight: '20px',
64
- },
65
- h10: {
66
- fontSize: '12px',
67
- fontWeight: '500',
68
- color: styledVars.CAP_G01,
69
- lineHeight: '16px',
70
- },
71
- label1: {
72
- color: styledVars.CAP_G04,
73
- fontSize: '12px',
74
- fontWeight: 'normal',
75
- lineHeight: '20px',
76
- },
77
- label2: {
78
- color: styledVars.CAP_G01,
79
- fontSize: '12px',
80
- fontWeight: 'normal',
81
- lineHeight: '20px',
82
- },
83
- label3: {
84
- color: styledVars.CAP_G05,
85
- fontSize: '12px',
86
- fontWeight: 'normal',
87
- lineHeight: '20px',
88
- },
89
- label4: {
90
- color: styledVars.CAP_G04,
91
- fontSize: '12px',
92
- fontWeight: 'normal',
93
- lineHeight: '16px',
94
- },
95
- label5: {
96
- color: styledVars.CAP_G04,
97
- fontSize: '16px',
98
- fontWeight: 'normal',
99
- lineHeight: '24px',
100
- },
101
- label6: {
102
- color: styledVars.CAP_G01,
103
- fontSize: '16px',
104
- fontWeight: 'normal',
105
- lineHeight: '24px',
106
- },
107
- };
108
-
109
- const headingStyles = css`
110
- font-size: ${props => headings[props.type].fontSize};
111
- font-weight: ${props => headings[props.type].fontWeight};
112
- color: ${props => headings[props.type].color};
113
- line-height: ${props => headings[props.type].lineHeight};
114
- margin: 0;
115
- padding: 0;
116
- `;
117
-
118
- export const HeadingWrapper = styled.div`
119
- ${headingStyles}
120
- `;
121
-
122
- export const HeadingSpan = styled.span`
123
- ${headingStyles}
124
- display: inline-block;
125
- `;
@@ -1,83 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import * as AntIcons from '@ant-design/icons';
4
- import styled from 'styled-components';
5
- import classNames from 'classnames';
6
- import * as styledVars from '../styled/variables';
7
-
8
- const getFontSizeFromProps = (size) => {
9
- switch (size) {
10
- case 'xs':
11
- return styledVars.ICON_SIZE_XS;
12
- case 's':
13
- return styledVars.ICON_SIZE_S;
14
- case 'm':
15
- return styledVars.ICON_SIZE_M;
16
- case 'l':
17
- return styledVars.ICON_SIZE_L;
18
- default:
19
- return styledVars.ICON_SIZE_M;
20
- }
21
- };
22
-
23
- const IconWrapper = styled.span`
24
- font-size: ${props => getFontSizeFromProps(props.size)};
25
- color: ${props => props.color || 'inherit'};
26
- cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
27
- opacity: ${props => props.disabled ? 0.5 : 1};
28
- transition: all 0.3s;
29
-
30
- &:hover {
31
- opacity: ${props => props.disabled ? 0.5 : 0.8};
32
- }
33
- `;
34
-
35
- const CapIcon = ({
36
- type,
37
- className,
38
- disabled,
39
- size = 'm',
40
- color,
41
- ...rest
42
- }) => {
43
- // Convert type to AntD icon name (e.g., 'close' -> 'CloseOutlined')
44
- const getIconComponent = (iconType) => {
45
- const iconMap = {
46
- 'close': AntIcons.CloseOutlined,
47
- 'chevron-down': AntIcons.DownOutlined,
48
- 'tick': AntIcons.CheckOutlined,
49
- 'info': AntIcons.InfoCircleOutlined,
50
- // Add more icon mappings as needed
51
- };
52
- return iconMap[iconType] || AntIcons[iconType];
53
- };
54
-
55
- const IconComponent = getIconComponent(type);
56
-
57
- if (!IconComponent) {
58
- console.warn(`Icon type "${type}" not found`);
59
- return null;
60
- }
61
-
62
- return (
63
- <IconWrapper
64
- className={classNames('cap-icon', className, { disabled })}
65
- disabled={disabled}
66
- size={size}
67
- color={color}
68
- {...rest}
69
- >
70
- <IconComponent />
71
- </IconWrapper>
72
- );
73
- };
74
-
75
- CapIcon.propTypes = {
76
- type: PropTypes.string.isRequired,
77
- className: PropTypes.string,
78
- disabled: PropTypes.bool,
79
- size: PropTypes.oneOf(['xs', 's', 'm', 'l']),
80
- color: PropTypes.string,
81
- };
82
-
83
- export default CapIcon;
package/CapIcon/index.js DELETED
@@ -1 +0,0 @@
1
- export { default } from './CapIcon';
@@ -1,54 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Alert } from 'antd';
4
- import { InfoNoteWrapper } from './styles';
5
- import CapLabel from '../CapLabel';
6
- import CapRow from '../CapRow';
7
-
8
- const Note = ({ noteText }) => (
9
- <CapLabel.Inline type="label4" className="note-text">
10
- {noteText}
11
- </CapLabel.Inline>
12
- );
13
-
14
- Note.propTypes = {
15
- noteText: PropTypes.string,
16
- };
17
-
18
- const CapInfoNote = ({ message, style, noteText, type = 'info', className, ...rest }) => {
19
- return (
20
- <InfoNoteWrapper>
21
- <Alert
22
- message={(
23
- <CapRow className="note-message-container">
24
- <Note noteText={noteText} />:
25
- <CapRow className="message-text">{message}</CapRow>
26
- </CapRow>
27
- )}
28
- className={className}
29
- type={type}
30
- showIcon
31
- style={{
32
- marginTop: '0.857rem',
33
- marginBottom: '0.857rem',
34
- ...style,
35
- }}
36
- {...rest}
37
- />
38
- </InfoNoteWrapper>
39
- );
40
- };
41
-
42
- CapInfoNote.propTypes = {
43
- message: PropTypes.node,
44
- style: PropTypes.object,
45
- noteText: PropTypes.string,
46
- type: PropTypes.string,
47
- className: PropTypes.string,
48
- };
49
-
50
- CapInfoNote.defaultProps = {
51
- type: 'info',
52
- };
53
-
54
- export default CapInfoNote;
@@ -1 +0,0 @@
1
- export { default } from './CapInfoNote';
@@ -1,63 +0,0 @@
1
- import styled from 'styled-components';
2
- import * as styledVars from '../styled/variables';
3
-
4
- export const InfoNoteWrapper = styled.div`
5
- .note-text {
6
- padding-left: ${styledVars.CAP_SPACE_24};
7
- white-space: nowrap;
8
- line-height: inherit;
9
- }
10
-
11
- .note-message-container {
12
- display: flex;
13
- .message-text {
14
- margin-left: 0.22rem;
15
- }
16
- }
17
-
18
- .ant-alert {
19
- padding: 8px 12px;
20
- border-radius: ${styledVars.RADIUS_04};
21
-
22
- .ant-alert-icon {
23
- font-size: ${styledVars.ICON_SIZE_S};
24
- top: 9px;
25
- }
26
-
27
- &.ant-alert-info {
28
- background-color: ${styledVars.CAP_G09};
29
- border: 1px solid ${styledVars.CAP_G07};
30
-
31
- .ant-alert-icon {
32
- color: ${styledVars.CAP_G01};
33
- }
34
- }
35
-
36
- &.ant-alert-success {
37
- background-color: ${styledVars.CAP_COLOR_01};
38
- border: 1px solid ${styledVars.CAP_PRIMARY.base};
39
-
40
- .ant-alert-icon {
41
- color: ${styledVars.CAP_PRIMARY.base};
42
- }
43
- }
44
-
45
- &.ant-alert-warning {
46
- background-color: ${styledVars.CAP_COLOR_02};
47
- border: 1px solid ${styledVars.CAP_ORANGE};
48
-
49
- .ant-alert-icon {
50
- color: ${styledVars.CAP_ORANGE};
51
- }
52
- }
53
-
54
- &.ant-alert-error {
55
- background-color: ${styledVars.CAP_COLOR_05};
56
- border: 1px solid ${styledVars.CAP_RED};
57
-
58
- .ant-alert-icon {
59
- color: ${styledVars.CAP_RED};
60
- }
61
- }
62
- }
63
- `;