@councilbox/councilbox-ui 0.0.5 → 0.0.6

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 (36) hide show
  1. package/README.md +1 -1
  2. package/dist/build-index.js +26 -2
  3. package/dist/components/Avatar/Avatar.js +42 -55
  4. package/dist/components/Avatar/Avatar.stories.js +10 -0
  5. package/dist/components/Avatar/DesignAvatar.stories.js +104 -4
  6. package/dist/components/Avatar/DesignAvatarText.stories.js +65 -4
  7. package/dist/components/AvatarGroup/AvatarGroup.css +33 -0
  8. package/dist/components/AvatarGroup/AvatarGroup.js +4 -7
  9. package/dist/components/AvatarGroup/DesignAvatarGroup.stories.js +73 -4
  10. package/dist/components/Button/Button.js +90 -16
  11. package/dist/components/Button/Button.stories.js +25 -25
  12. package/dist/components/Button/button.css +34 -0
  13. package/dist/components/Checkbox/Checkbox.css +0 -0
  14. package/dist/components/Checkbox/Checkbox.js +94 -0
  15. package/dist/components/Checkbox/Checkbox.stories.js +28 -0
  16. package/dist/components/InputPassword/InputPassword.css +26 -0
  17. package/dist/components/InputPassword/InputPassword.js +78 -107
  18. package/dist/components/InputPassword/InputPassword.stories.js +33 -2
  19. package/dist/components/InputText/InputText.css +13 -0
  20. package/dist/components/InputText/InputText.js +118 -44
  21. package/dist/components/InputText/InputText.stories.js +26 -2
  22. package/dist/components/RadioButton/Radio.css +0 -0
  23. package/dist/components/RadioButton/Radio.js +94 -0
  24. package/dist/components/RadioButton/Radio.stories.js +28 -0
  25. package/dist/components/Spacing/Spacing.css +0 -0
  26. package/dist/components/Spacing/Spacing.js +137 -0
  27. package/dist/components/Spacing/Spacing.stories.js +28 -0
  28. package/dist/components/ThemeProvider/Colors.js +102 -0
  29. package/dist/components/ThemeProvider/ThemeProvider.js +17 -8
  30. package/dist/components/Typography/Typography.js +37 -13
  31. package/dist/components/Typography/Typography.stories.js +11 -2
  32. package/dist/styles/main.css +96 -30
  33. package/dist/styles/stylesheet.js +40 -9
  34. package/dist/testing/TestComponents.js +57 -24
  35. package/package.json +3 -2
  36. package/dist/components/Button/ButtonV1.js +0 -63
@@ -13,45 +13,119 @@ var _Button = _interopRequireDefault(require("@mui/material/Button"));
13
13
 
14
14
  require("../../styles/main.css");
15
15
 
16
+ require("./button.css");
17
+
18
+ var _excluded = ["id", "text", "onClick", "disabled", "loading", "variant", "fullWidth", "icon"];
19
+
16
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
21
 
22
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
30
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
31
+
32
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
33
+
18
34
  var Button = function Button(_ref) {
19
- var text = _ref.text,
35
+ var id = _ref.id,
36
+ text = _ref.text,
20
37
  onClick = _ref.onClick,
21
38
  disabled = _ref.disabled,
22
39
  loading = _ref.loading,
23
- color = _ref.color,
24
- variant = _ref.variant;
25
- return /*#__PURE__*/_react.default.createElement(_Button.default, {
26
- variant: variant,
27
- className: "councilbox-button",
40
+ variant = _ref.variant,
41
+ fullWidth = _ref.fullWidth,
42
+ icon = _ref.icon,
43
+ props = _objectWithoutProperties(_ref, _excluded);
44
+
45
+ var buttonVariant;
46
+ var buttonColor;
47
+ var background;
48
+
49
+ if (variant === 'primary') {
50
+ buttonVariant = 'contained';
51
+ background = 'var(--primary)';
52
+ buttonColor = 'var(--neutral50)';
53
+ } else if (variant === 'secondary') {
54
+ buttonVariant = 'outlined';
55
+ buttonColor = 'var(--primary)';
56
+ } else if (variant === 'error') {
57
+ // this better as an state, not a variant
58
+ buttonVariant = 'contained';
59
+ background = 'var(--error600)';
60
+ buttonColor = 'var(--neutral50)';
61
+ } else if (variant === 'warning') {
62
+ buttonVariant = 'contained';
63
+ background = 'var(--warnig600)';
64
+ buttonColor = 'var(--neutral50)';
65
+ } else if (variant === 'success') {
66
+ buttonVariant = 'contained';
67
+ background = 'var(--success600)';
68
+ buttonColor = 'var(--neutral50)';
69
+ } else {
70
+ buttonVariant = 'text';
71
+ buttonColor = 'var(--primary)';
72
+ }
73
+
74
+ var isSecondaryOrTernary = function isSecondaryOrTernary(variantBtn) {
75
+ return variantBtn === 'secondary' || variantBtn === 'tertiary';
76
+ };
77
+
78
+ return /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
79
+ id: id,
80
+ sx: {
81
+ minWidth: !isSecondaryOrTernary(variant) ? '140px' : '100px',
82
+ height: '48px',
83
+ boxShadow: 'none'
84
+ },
85
+ className: "cbx-button ".concat(buttonVariant, " ").concat(icon ? 'cbx-button-with-icon' : '', " ").concat(!isSecondaryOrTernary(variant) && "cbx-button-hoverAndAnimation".concat(fullWidth ? '-fullWidth' : '')),
28
86
  disabled: loading || disabled,
29
- color: color // style={{
30
- // backgroundColor: `var(--${color})`
31
- // }}
32
- ,
33
- onClick: onClick
34
- }, text);
87
+ variant: buttonVariant,
88
+ style: _objectSpread({
89
+ backgroundColor: background,
90
+ color: buttonColor
91
+ }, disabled || loading ? {
92
+ opacity: '0.5'
93
+ } : {}),
94
+ disableFocusRipple: true,
95
+ fullWidth: fullWidth,
96
+ onClick: onClick,
97
+ startIcon: icon
98
+ }, props), /*#__PURE__*/_react.default.createElement("span", {
99
+ className: "button-text"
100
+ }, text), buttonVariant === 'contained' && !loading && /*#__PURE__*/_react.default.createElement("span", {
101
+ className: "containerArrow"
102
+ }, /*#__PURE__*/_react.default.createElement("i", {
103
+ className: "ri-arrow-right-s-line arrow-primary"
104
+ })), loading && /*#__PURE__*/_react.default.createElement("i", {
105
+ className: "ri-refresh-line"
106
+ }));
35
107
  };
36
108
 
37
109
  Button.displayName = "Button";
38
110
  Button.propTypes = {
39
111
  backgroundColor: _propTypes.default.string,
40
- color: _propTypes.default.string,
41
112
  text: _propTypes.default.string.isRequired,
42
113
  onClick: _propTypes.default.func,
43
114
  disabled: _propTypes.default.bool,
44
115
  loading: _propTypes.default.bool,
45
- variant: _propTypes.default.string
116
+ variant: _propTypes.default.string,
117
+ fullWidth: _propTypes.default.bool,
118
+ icon: _propTypes.default.node
46
119
  };
47
120
  Button.defaultProps = {
48
121
  backgroundColor: null,
49
122
  text: null,
50
123
  onClick: undefined,
51
- color: 'primary',
52
124
  disabled: false,
53
125
  loading: false,
54
- variant: 'contained'
126
+ variant: 'primary',
127
+ fullWidth: false,
128
+ icon: null
55
129
  };
56
130
  var _default = Button;
57
131
  exports.default = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.Secondary = exports.Primary = exports.Default = void 0;
6
+ exports.default = exports.Default = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -11,36 +11,51 @@ var _Button = _interopRequireDefault(require("./Button"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
+ var ICONS = {
15
+ none: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null),
16
+ save: /*#__PURE__*/_react.default.createElement("i", {
17
+ className: "ri-save-line"
18
+ }),
19
+ edit: /*#__PURE__*/_react.default.createElement("i", {
20
+ className: "ri-pencil-line"
21
+ }),
22
+ arrowLeft: /*#__PURE__*/_react.default.createElement("i", {
23
+ className: "ri-arrow-left-s-line"
24
+ })
25
+ };
14
26
  var _default = {
15
27
  title: 'Example/Button',
16
28
  component: _Button.default,
17
29
  argTypes: {
18
- backgroundColor: {
19
- control: 'color'
20
- },
21
- color: {
22
- options: ['primary', 'secondary'],
30
+ loading: {
31
+ options: [true, false],
23
32
  control: {
24
33
  type: 'radio'
25
34
  }
26
35
  },
27
- loading: {
36
+ disabled: {
28
37
  options: [true, false],
29
38
  control: {
30
39
  type: 'radio'
31
40
  }
32
41
  },
33
- disabled: {
42
+ fullWidth: {
34
43
  options: [true, false],
35
44
  control: {
36
45
  type: 'radio'
37
46
  }
38
47
  },
39
48
  variant: {
40
- options: ['contained', 'outlined', 'text'],
49
+ options: ['primary', 'secondary', 'tertiary', 'success', 'warning', 'error'],
41
50
  control: {
42
51
  type: 'radio'
43
52
  }
53
+ },
54
+ icon: {
55
+ control: {
56
+ type: 'select'
57
+ },
58
+ options: ICONS
44
59
  }
45
60
  }
46
61
  };
@@ -55,20 +70,5 @@ var Default = Template.bind({});
55
70
  exports.Default = Default;
56
71
  Default.args = {
57
72
  text: 'Label',
58
- color: 'primary',
59
- variant: 'contained'
60
- };
61
- var Primary = Template.bind({});
62
- exports.Primary = Primary;
63
- Primary.args = {
64
- text: 'Primary Label',
65
- color: 'primary',
66
- variant: 'outlined'
67
- };
68
- var Secondary = Template.bind({});
69
- exports.Secondary = Secondary;
70
- Secondary.args = {
71
- text: 'Secondary Label',
72
- color: 'secondary',
73
- variant: 'contained'
73
+ variant: 'primary'
74
74
  };
@@ -0,0 +1,34 @@
1
+ .cbx-button-with-icon {
2
+ padding-left: var(--spacing20) !important;
3
+ }
4
+
5
+ .cbx-button:focus-visible {
6
+ box-shadow: 0 0 0 1px white, 0 0 7px 4px rgba(56,57,140,0.75);
7
+ }
8
+
9
+ .cbx-button-hoverAndAnimation{
10
+ justify-content: start!important;
11
+ }
12
+
13
+ .cbx-button-hoverAndAnimation-fullWidth{
14
+ justify-content: center;
15
+ }
16
+
17
+ .cbx-button-hoverAndAnimation .containerArrow, .cbx-button-hoverAndAnimation-fullWidth .containerArrow {
18
+ margin-left: var(--spacing24);
19
+ margin-right: var(--spacing8);
20
+ position: relative;
21
+ transition: padding .4s ease-in-out;
22
+ width: 15px;
23
+ height: 28px;
24
+ }
25
+
26
+ .cbx-button-hoverAndAnimation span i , .cbx-button-hoverAndAnimation-fullWidth span i {
27
+ position: absolute;
28
+ transition: .4s ease-in-out;
29
+ left: 0;
30
+ }
31
+
32
+ .cbx-button-hoverAndAnimation:hover span i , .cbx-button-hoverAndAnimation-fullWidth:hover span i {
33
+ padding-left: var(--spacing8);
34
+ }
File without changes
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
13
+
14
+ require("../../styles/main.css");
15
+
16
+ var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
17
+
18
+ var _styled = _interopRequireDefault(require("@mui/material/styles/styled"));
19
+
20
+ var _excluded = ["id", "className", "disabled", "indeterminate", "label", "onChange"];
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
+
26
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
+
28
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
+
30
+ var CssFormControlLabel = (0, _styled.default)(_FormControlLabel.default)(function (_ref) {
31
+ var theme = _ref.theme;
32
+ return {
33
+ '& .MuiFormControlLabel-label': {
34
+ marginLeft: 'var(--spacing8)'
35
+ },
36
+ '& .MuiCheckbox-root.Mui-disabled': {
37
+ color: '#acadce'
38
+ },
39
+ '& .MuiCheckbox-root': {
40
+ transition: 'all .2s'
41
+ },
42
+ '& .MuiCheckbox-root:hover': {
43
+ color: theme.palette.primary700
44
+ }
45
+ };
46
+ });
47
+
48
+ var Checkbox = function Checkbox(_ref2) {
49
+ var id = _ref2.id,
50
+ className = _ref2.className,
51
+ disabled = _ref2.disabled,
52
+ indeterminate = _ref2.indeterminate,
53
+ label = _ref2.label,
54
+ onChange = _ref2.onChange,
55
+ props = _objectWithoutProperties(_ref2, _excluded);
56
+
57
+ return /*#__PURE__*/_react.default.createElement(CssFormControlLabel, _extends({
58
+ id: id,
59
+ className: className,
60
+ style: {
61
+ margin: '0px'
62
+ },
63
+ onChange: onChange,
64
+ control: /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
65
+ indeterminate: indeterminate,
66
+ style: {
67
+ padding: '0px'
68
+ },
69
+ sx: {
70
+ '& .MuiSvgIcon-root': {
71
+ fontSize: 24
72
+ }
73
+ }
74
+ }),
75
+ disabled: disabled,
76
+ label: label
77
+ }, props));
78
+ };
79
+
80
+ Checkbox.displayName = "Checkbox";
81
+ Checkbox.propTypes = {
82
+ onChange: _propTypes.default.func,
83
+ disabled: _propTypes.default.bool,
84
+ indeterminate: _propTypes.default.bool,
85
+ label: _propTypes.default.string
86
+ };
87
+ Checkbox.defaultProps = {
88
+ onChange: undefined,
89
+ disabled: false,
90
+ indeterminate: false,
91
+ label: 'Label'
92
+ };
93
+ var _default = Checkbox;
94
+ exports.default = _default;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Checkbox = _interopRequireDefault(require("./Checkbox"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var _default = {
15
+ title: 'Example/Checkbox',
16
+ component: _Checkbox.default,
17
+ argTypes: {}
18
+ };
19
+ exports.default = _default;
20
+
21
+ var Template = function Template(args) {
22
+ return /*#__PURE__*/_react.default.createElement(_Checkbox.default, args);
23
+ };
24
+
25
+ Template.displayName = "Template";
26
+ var Default = Template.bind({});
27
+ exports.Default = Default;
28
+ Default.args = {};
@@ -0,0 +1,26 @@
1
+ .cbx-inputPassword-validation {
2
+ width: 100%;
3
+ background: #DBDBDB;
4
+ height: var(--spacing8);
5
+ border-radius: 20px;
6
+ margin-top: var(--spacing4);
7
+ margin-bottom: var(--spacing4);
8
+
9
+ }
10
+ .cbx-inputPassword-validation > div {
11
+ height: var(--spacing8);
12
+ border-radius: 20px;
13
+ transition: all .5s;
14
+ }
15
+
16
+
17
+ .cbx-inputPassword-icon-button {
18
+ outline: none;
19
+ width: var(--spacing24);
20
+ height: var(--spacing24);
21
+
22
+ }
23
+ .cbx-inputPassword-icon-size {
24
+ width: var(--spacing24);
25
+ height: var(--spacing24);
26
+ }
@@ -9,26 +9,26 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
13
-
14
12
  var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
15
13
 
16
- var _InputAdornment = _interopRequireDefault(require("@mui/material/InputAdornment"));
17
-
18
14
  var _Visibility = _interopRequireDefault(require("@mui/icons-material/Visibility"));
19
15
 
20
16
  var _VisibilityOff = _interopRequireDefault(require("@mui/icons-material/VisibilityOff"));
21
17
 
22
18
  require("../../styles/main.css");
23
19
 
24
- var _styled = _interopRequireDefault(require("@mui/material/styles/styled"));
20
+ require("./InputPassword.css");
25
21
 
26
- var _info = require("../../assets/img/info.svg");
22
+ var _CouncilboxThemeContext = require("../ThemeProvider/CouncilboxThemeContext");
27
23
 
28
- var _Typography = _interopRequireDefault(require("../Typography/Typography"));
24
+ var _InputText = _interopRequireDefault(require("../InputText/InputText"));
25
+
26
+ var _excluded = ["id", "className", "onChange", "onClick", "label", "disabled", "error", "helper", "width", "validation", "percentageError", "helperText", "fullWidth"];
29
27
 
30
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
29
 
30
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
+
32
32
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
33
 
34
34
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -41,145 +41,116 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
41
41
 
42
42
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
43
 
44
- var CssTextField = (0, _styled.default)(_TextField.default)(function (_ref) {
45
- var theme = _ref.theme;
46
- return {
47
- '& label.Mui-focused': {
48
- color: 'primary',
49
- borderWidth: '2px',
50
- background: 'white',
51
- top: '1px'
52
- },
53
- '& .MuiInput-underline:after': {
54
- borderBottomColor: '#5152A5',
55
- borderWidth: '2px'
56
- },
57
- '& .MuiFormHelperText-root': {
58
- marginTop: '4px',
59
- marginLeft: '0px'
60
- },
61
- '& .MuiInputBase-input': {
62
- height: '15px'
63
- },
64
- '& .MuiFormLabel-root': {
65
- lineHeight: '18px',
66
- top: '-2px'
67
- },
68
- '& .MuiInputLabel-shrink': {
69
- top: '1px'
70
- },
71
- '& .MuiOutlinedInput-root': {
72
- '& fieldset': {
73
- borderColor: '#8C8C8C'
74
- },
75
- '&:hover fieldset': {
76
- borderColor: '#8C8C8C',
77
- borderWidth: '2px'
78
- },
79
- '&:active fieldset': {
80
- borderColor: '#5152A5',
81
- borderWidth: '2px'
82
- },
83
- '&.Mui-focused fieldset': {
84
- borderColor: '#5152A5',
85
- borderWidth: '2px',
86
- boxShadow: "0 0 0 3px white, 0 0 7px 4px ".concat(theme.palette.primary.main)
87
- }
88
- }
89
- };
90
- });
91
-
92
- var InputText = function InputText(_ref2) {
93
- var id = _ref2.id,
94
- className = _ref2.className,
95
- onClick = _ref2.onClick,
96
- label = _ref2.label,
97
- disabled = _ref2.disabled,
98
- error = _ref2.error,
99
- helper = _ref2.helper,
100
- width = _ref2.width;
44
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
45
+
46
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
47
+
48
+ var InputPassword = function InputPassword(_ref) {
49
+ var id = _ref.id,
50
+ className = _ref.className,
51
+ onChange = _ref.onChange,
52
+ onClick = _ref.onClick,
53
+ label = _ref.label,
54
+ disabled = _ref.disabled,
55
+ error = _ref.error,
56
+ helper = _ref.helper,
57
+ width = _ref.width,
58
+ validation = _ref.validation,
59
+ percentageError = _ref.percentageError,
60
+ helperText = _ref.helperText,
61
+ fullWidth = _ref.fullWidth,
62
+ props = _objectWithoutProperties(_ref, _excluded);
101
63
 
102
64
  var _React$useState = _react.default.useState(false),
103
65
  _React$useState2 = _slicedToArray(_React$useState, 2),
104
66
  showPassword = _React$useState2[0],
105
67
  setShowPassword = _React$useState2[1];
106
68
 
107
- return /*#__PURE__*/_react.default.createElement(CssTextField, {
69
+ var themeData = (0, _CouncilboxThemeContext.useCouncilboxTheme)();
70
+
71
+ var getColorPercent = function getColorPercent(percent) {
72
+ var color = themeData.theme.colors.error600;
73
+
74
+ if (percent > 30 && percent < 90) {
75
+ color = themeData.theme.colors.warnig600;
76
+ }
77
+
78
+ if (percent >= 90) {
79
+ color = themeData.theme.colors.success600;
80
+ }
81
+
82
+ return color;
83
+ };
84
+
85
+ return /*#__PURE__*/_react.default.createElement(_InputText.default, _extends({
108
86
  id: id,
87
+ fullWidth: fullWidth,
109
88
  className: className,
110
89
  sx: {
111
90
  width: width || '240px',
112
91
  height: '48px'
113
92
  },
114
93
  label: label,
115
- onClick: onClick,
94
+ onChange: onChange,
116
95
  disabled: disabled,
117
96
  error: error,
97
+ helper: helper,
118
98
  type: showPassword ? 'text' : 'password',
119
- helperText: error ? /*#__PURE__*/_react.default.createElement("div", {
99
+ helperText: validation && /*#__PURE__*/_react.default.createElement("div", {
100
+ className: "cbx-inputPassword-validation"
101
+ }, /*#__PURE__*/_react.default.createElement("div", {
120
102
  style: {
121
- display: 'flex',
122
- alignItems: 'center'
103
+ width: "".concat(percentageError, "%"),
104
+ background: getColorPercent(percentageError)
123
105
  }
124
- }, /*#__PURE__*/_react.default.createElement(_info.ReactComponent, {
125
- style: {
126
- marginRight: '4px'
127
- },
128
- fill: "#E80000"
129
- }), " ", /*#__PURE__*/_react.default.createElement(_Typography.default, {
130
- variant: "S",
131
- color: '#E80000'
132
- }, error)) : helper && /*#__PURE__*/_react.default.createElement("div", {
133
- style: {
134
- display: 'flex',
135
- alignItems: 'center'
136
- }
137
- }, /*#__PURE__*/_react.default.createElement(_info.ReactComponent, {
138
- style: {
139
- marginRight: '4px'
140
- },
141
- fill: "#767676"
142
- }), " ", /*#__PURE__*/_react.default.createElement(_Typography.default, {
143
- variant: "S"
144
- }, helper)),
106
+ })),
145
107
  InputProps: {
146
- endAdornment: /*#__PURE__*/_react.default.createElement(_InputAdornment.default, {
147
- position: "end",
108
+ endAdornment: /*#__PURE__*/_react.default.createElement(_IconButton.default, {
109
+ disabled: disabled,
110
+ "aria-label": "Toggle password visibility",
111
+ className: "cbx-inputPassword-icon-button",
148
112
  onClick: function onClick() {
149
- return setShowPassword(!showPassword);
113
+ return !disabled && setShowPassword(!showPassword);
150
114
  }
151
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
152
- "aria-label": "Toggle password visibility",
153
- style: {
154
- outline: 0
115
+ }, showPassword ? /*#__PURE__*/_react.default.createElement(_VisibilityOff.default, {
116
+ className: "cbx-inputPassword-icon-size",
117
+ sx: {
118
+ color: disabled ? 'var(--neutral400)' : 'black'
119
+ }
120
+ }) : /*#__PURE__*/_react.default.createElement(_Visibility.default, {
121
+ className: "cbx-inputPassword-icon-size",
122
+ sx: {
123
+ color: disabled ? 'var(--neutral400)' : 'black'
155
124
  }
156
- }, showPassword ? /*#__PURE__*/_react.default.createElement(_VisibilityOff.default, null) : /*#__PURE__*/_react.default.createElement(_Visibility.default, null)))
125
+ }))
157
126
  }
158
- });
127
+ }, props));
159
128
  };
160
129
 
161
- InputText.displayName = "InputText";
162
- InputText.propTypes = {
130
+ InputPassword.displayName = "InputPassword";
131
+ InputPassword.propTypes = {
163
132
  label: _propTypes.default.string,
164
133
  helper: _propTypes.default.string,
165
134
  width: _propTypes.default.string,
166
135
  id: _propTypes.default.string,
167
136
  className: _propTypes.default.string,
168
- onClick: _propTypes.default.func,
137
+ onChange: _propTypes.default.func,
169
138
  disabled: _propTypes.default.bool,
170
139
  error: _propTypes.default.string,
171
- passwordToggler: _propTypes.default.bool
140
+ validation: _propTypes.default.bool,
141
+ percentageError: _propTypes.default.number
172
142
  };
173
- InputText.defaultProps = {
143
+ InputPassword.defaultProps = {
174
144
  label: 'Caption',
175
145
  helper: '',
176
146
  width: '',
177
147
  id: '',
178
148
  className: '',
179
- onClick: undefined,
149
+ onChange: undefined,
180
150
  disabled: false,
181
151
  error: '',
182
- passwordToggler: true
152
+ validation: false,
153
+ percentageError: 0
183
154
  };
184
- var _default = InputText;
155
+ var _default = InputPassword;
185
156
  exports.default = _default;