@councilbox/councilbox-ui 1.0.1 → 2.0.1

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 (137) hide show
  1. package/dist/HOCs/useDynamicStyles.js +99 -0
  2. package/dist/HOCs/useRipple.js +91 -0
  3. package/dist/build-index.js +8 -0
  4. package/dist/components/1.Introduction.stories.mdx +2 -1
  5. package/dist/components/2.Changelog.stories.mdx +3 -0
  6. package/dist/components/3.Guide.stories.mdx +56 -0
  7. package/dist/components/Accordion/Accordion.css +39 -1
  8. package/dist/components/Accordion/Accordion.js +84 -45
  9. package/dist/components/Accordion/Accordion.stories.js +4 -2
  10. package/dist/components/Accordion/AccordionOld.css +16 -0
  11. package/dist/components/Accordion/AccordionOld.js +115 -0
  12. package/dist/components/Accordion/DesignAccordion.stories.js +38 -0
  13. package/dist/components/Alert/Alert.css +5 -0
  14. package/dist/components/Alert/Alert.js +17 -6
  15. package/dist/components/Avatar/Avatar.css +3 -3
  16. package/dist/components/Avatar/Avatar.js +36 -20
  17. package/dist/components/Avatar/AvatarOld.js +138 -0
  18. package/dist/components/Avatar/DesignAvatar.stories.js +1 -1
  19. package/dist/components/Block/Block.js +17 -2
  20. package/dist/components/ButtonBasic/ButtonBasic.css +264 -20
  21. package/dist/components/ButtonBasic/ButtonBasic.js +85 -110
  22. package/dist/components/ButtonBasic/ButtonBasicOld.css +41 -0
  23. package/dist/components/ButtonBasic/ButtonBasicOld.js +231 -0
  24. package/dist/components/Checkbox/Checkbox.css +101 -22
  25. package/dist/components/Checkbox/Checkbox.js +119 -63
  26. package/dist/components/Checkbox/CheckboxOld.css +31 -0
  27. package/dist/components/Checkbox/CheckboxOld.js +112 -0
  28. package/dist/components/DragDrop/DragDrop.js +24 -9
  29. package/dist/components/DrawerPanel/DesignDrawerPanel.js +4 -2
  30. package/dist/components/DrawerPanel/DrawerPanel.css +76 -36
  31. package/dist/components/DrawerPanel/DrawerPanel.js +137 -115
  32. package/dist/components/DrawerPanel/DrawerPanelOld.css +56 -0
  33. package/dist/components/DrawerPanel/DrawerPanelOld.js +233 -0
  34. package/dist/components/DropDown/DesignDropDown.stories.js +146 -17
  35. package/dist/components/DropDown/DropDown.css +96 -1
  36. package/dist/components/DropDown/DropDown.js +308 -82
  37. package/dist/components/DropDown/DropDown.stories.js +1 -0
  38. package/dist/components/DropDown/DropDownOld.css +3 -0
  39. package/dist/components/DropDown/DropDownOld.js +186 -0
  40. package/dist/components/DropDown/PopoverPlayground.css +22 -0
  41. package/dist/components/DropDown/PopoverPlayground.js +235 -0
  42. package/dist/components/EnhancedTable/EnhancedTable.js +5 -6
  43. package/dist/components/FabButton/DesignFabButton.stories.js +3 -1
  44. package/dist/components/FabButton/FabButton.js +25 -5
  45. package/dist/components/Grid/DesignGrid.stories.js +9 -3
  46. package/dist/components/Grid/Grid.css +325 -0
  47. package/dist/components/Grid/Grid.js +57 -16
  48. package/dist/components/Grid/GridItem.js +31 -13
  49. package/dist/components/Grid/GridItemOld.js +43 -0
  50. package/dist/components/Grid/GridOld.css +0 -0
  51. package/dist/components/Grid/GridOld.js +53 -0
  52. package/dist/components/Header/Header.js +95 -116
  53. package/dist/components/IconButton/DesignIconButton.stories.js +22 -2
  54. package/dist/components/IconButton/IconButton.css +121 -1
  55. package/dist/components/IconButton/IconButton.js +98 -53
  56. package/dist/components/IconButton/IconButtonOld.css +0 -0
  57. package/dist/components/IconButton/IconButtonOld.js +138 -0
  58. package/dist/components/IconButtonSquare/IconButtonSquare.js +20 -90
  59. package/dist/components/IconButtonSquare/IconButtonSquareOld.css +43 -0
  60. package/dist/components/IconButtonSquare/IconButtonSquareOld.js +133 -0
  61. package/dist/components/InputAutocomplete/InputAutocomplete.css +109 -0
  62. package/dist/components/InputAutocomplete/InputAutocomplete.js +382 -76
  63. package/dist/components/InputAutocomplete/InputAutocomplete.stories.js +118 -6
  64. package/dist/components/InputAutocomplete/InputAutocompleteOld.css +5 -0
  65. package/dist/components/InputAutocomplete/InputAutocompleteOld.js +178 -0
  66. package/dist/components/InputPassword/InputPassword.js +10 -20
  67. package/dist/components/InputText/InputText.css +442 -1
  68. package/dist/components/InputText/InputText.js +298 -239
  69. package/dist/components/InputText/InputText.stories.js +12 -3
  70. package/dist/components/InputText/InputTextOld.css +10 -0
  71. package/dist/components/InputText/InputTextOld.js +340 -0
  72. package/dist/components/InputTextArea/DesignInputTextArea.stories.js +30 -4
  73. package/dist/components/InputTextArea/InputTextArea.js +13 -6
  74. package/dist/components/LoadingSection/LoadingSection.css +44 -2
  75. package/dist/components/LoadingSection/LoadingSection.js +63 -9
  76. package/dist/components/MenuItem/DesignMenuItem.stories.js +1 -0
  77. package/dist/components/MenuItem/MenuItem.css +35 -6
  78. package/dist/components/MenuItem/MenuItem.js +99 -50
  79. package/dist/components/MenuItem/MenuItemOld.js +139 -0
  80. package/dist/components/MenuLateralLeft/MenuLateralLeft.js +60 -40
  81. package/dist/components/MenuLateralRight/MenuLateralRight.js +23 -8
  82. package/dist/components/Modal/DesignModal.stories.js +54 -0
  83. package/dist/components/Modal/Modal.css +81 -2
  84. package/dist/components/Modal/Modal.js +112 -80
  85. package/dist/components/Modal/Modal.stories.js +13 -2
  86. package/dist/components/Modal/ModalOld.css +3 -0
  87. package/dist/components/Modal/ModalOld.js +230 -0
  88. package/dist/components/PaginationFooter/DesignPaginationFooter.stories.js +9 -1
  89. package/dist/components/PaginationFooter/PaginationFooter.css +73 -0
  90. package/dist/components/PaginationFooter/PaginationFooter.js +45 -87
  91. package/dist/components/RadioButton/Radio.css +115 -16
  92. package/dist/components/RadioButton/Radio.js +70 -94
  93. package/dist/components/RadioButton/Radio.stories.js +42 -18
  94. package/dist/components/RadioButton/RadioOld.css +31 -0
  95. package/dist/components/RadioButton/RadioOld.js +142 -0
  96. package/dist/components/Ripple/DesignRipple.js +77 -0
  97. package/dist/components/Ripple/Ripple.stories.js +45 -0
  98. package/dist/components/Scrollbar/Scrollbar.js +21 -6
  99. package/dist/components/SelectInput/DesignSelectInput.js +62 -23
  100. package/dist/components/SelectInput/SelectInput.css +128 -10
  101. package/dist/components/SelectInput/SelectInput.js +265 -244
  102. package/dist/components/SelectInput/SelectInputOld.css +17 -0
  103. package/dist/components/SelectInput/SelectInputOld.js +325 -0
  104. package/dist/components/Stars/Stars.css +28 -28
  105. package/dist/components/Stars/Stars.js +22 -12
  106. package/dist/components/Stepper/Stepper.css +1 -0
  107. package/dist/components/Stepper/Stepper.js +81 -24
  108. package/dist/components/Table/DesignTable.stories.js +1 -0
  109. package/dist/components/Table/Table.css +56 -53
  110. package/dist/components/Table/Table.js +55 -75
  111. package/dist/components/Table/TableOld.css +79 -0
  112. package/dist/components/Table/TableOld.js +165 -0
  113. package/dist/components/Tabs/DesignTabs.js +37 -12
  114. package/dist/components/Tabs/Tabs.css +39 -4
  115. package/dist/components/Tabs/Tabs.js +194 -30
  116. package/dist/components/Tabs/Tabs.stories.js +8 -1
  117. package/dist/components/Tabs/TabsOld.js +92 -0
  118. package/dist/components/Tag/Tag.js +19 -9
  119. package/dist/components/Toggle/Toggle.css +122 -3
  120. package/dist/components/Toggle/Toggle.js +95 -68
  121. package/dist/components/Tooltip/DesignTooltip.stories.js +48 -0
  122. package/dist/components/Tooltip/Tooltip.css +75 -0
  123. package/dist/components/Tooltip/Tooltip.js +126 -0
  124. package/dist/components/Tooltip/Tooltip.stories.js +40 -0
  125. package/dist/components/Typography/Typography.css +9 -0
  126. package/dist/components/Typography/Typography.js +30 -21
  127. package/dist/components/Typography/TypographyOld.js +132 -0
  128. package/dist/styles/colorConsts.css +24 -0
  129. package/dist/styles/main.css +41 -49
  130. package/dist/styles/scpacingConsts.css +26 -0
  131. package/dist/styles/zIndexConsts.css +9 -0
  132. package/dist/testing/TestAutocomplete.js +369 -0
  133. package/dist/testing/TestComponents.js +3 -114
  134. package/dist/testing/TestDropdown.js +225 -0
  135. package/dist/utils/autoDetectScroll.js +127 -0
  136. package/dist/utils/index.js +141 -0
  137. package/package.json +2 -1
@@ -0,0 +1,231 @@
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 _Button = _interopRequireDefault(require("@mui/material/Button"));
13
+
14
+ require("../../styles/main.css");
15
+
16
+ require("./ButtonBasicOld.css");
17
+
18
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
19
+
20
+ var _Typography = _interopRequireDefault(require("../Typography/Typography"));
21
+
22
+ var _excluded = ["id", "text", "onClick", "disabled", "loading", "variant", "fullWidth", "icon", "variantText", "stylesButton", "sx", "badge", "resetDelay", "reset", "error", "success", "startIcon", "endIcon", "className"];
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ 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); }
27
+
28
+ 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; }
29
+
30
+ 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; }
31
+
32
+ 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; }
33
+
34
+ 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; }
35
+
36
+ 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; }
37
+
38
+ var ButtonBasicOld = function ButtonBasicOld(_ref) {
39
+ var id = _ref.id,
40
+ text = _ref.text,
41
+ onClick = _ref.onClick,
42
+ disabled = _ref.disabled,
43
+ loading = _ref.loading,
44
+ variant = _ref.variant,
45
+ fullWidth = _ref.fullWidth,
46
+ icon = _ref.icon,
47
+ variantText = _ref.variantText,
48
+ stylesButton = _ref.stylesButton,
49
+ sx = _ref.sx,
50
+ badge = _ref.badge,
51
+ _ref$resetDelay = _ref.resetDelay,
52
+ resetDelay = _ref$resetDelay === void 0 ? 2700 : _ref$resetDelay,
53
+ reset = _ref.reset,
54
+ error = _ref.error,
55
+ success = _ref.success,
56
+ _ref$startIcon = _ref.startIcon,
57
+ startIcon = _ref$startIcon === void 0 ? icon : _ref$startIcon,
58
+ endIcon = _ref.endIcon,
59
+ className = _ref.className,
60
+ props = _objectWithoutProperties(_ref, _excluded);
61
+
62
+ var buttonVariant;
63
+ var buttonColor;
64
+
65
+ if (variant === 'primary') {
66
+ buttonVariant = 'contained';
67
+ buttonColor = 'var(--white)';
68
+ } else if (variant === 'secondary') {
69
+ buttonVariant = 'outlined';
70
+ buttonColor = 'var(--primary)';
71
+ } else if (variant === 'secondaryDark') {
72
+ buttonVariant = 'outlined';
73
+ buttonColor = 'var(--white)';
74
+ } else {
75
+ buttonVariant = 'text';
76
+ buttonColor = 'var(--primary)';
77
+ }
78
+
79
+ _react.default.useEffect(function () {
80
+ var timeout;
81
+
82
+ if ((error || success) && !!reset) {
83
+ timeout = setTimeout(reset, resetDelay);
84
+ }
85
+
86
+ return function () {
87
+ clearTimeout(timeout);
88
+ };
89
+ }, [error, success, reset, resetDelay]);
90
+
91
+ return /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
92
+ id: id,
93
+ className: "".concat(className || '', " ").concat(variant === 'secondaryDark' ? 'secondaryDark' : ''),
94
+ sx: _objectSpread(_objectSpread({}, sx), {}, {
95
+ height: '3rem',
96
+ '&:focus': {
97
+ outline: 'none!important'
98
+ },
99
+ '&.MuiButton-contained': {
100
+ backgroundColor: success || error ? success ? 'var(--success)' : error && 'var(--error)' : 'var(--primary)'
101
+ },
102
+ '&.MuiButton-contained:hover': {
103
+ boxShadow: 'none',
104
+ backgroundColor: success || error ? success ? 'var(--success)' : error && 'var(--error)' : 'var(--primary)'
105
+ },
106
+ '&.MuiButton-contained div span, &.MuiButton-contained div div ': {
107
+ transition: 'background .3s, width .3s, color .3s'
108
+ },
109
+ '&.MuiButton-contained:hover div span, &.MuiButton-contained:hover div div': {
110
+ color: success || error ? 'white' : 'var(--accent)'
111
+ },
112
+ '&.MuiButton-contained.Mui-disabled': {
113
+ backgroundColor: 'var(--primary25)'
114
+ },
115
+ '&.MuiButton-contained.Mui-disabled div span, &.MuiButton-contained.Mui-disabled div div': {
116
+ color: 'var(--primary50)'
117
+ },
118
+ '&.MuiButton-outlined': {
119
+ border: '0.063rem solid var(--primary)',
120
+ borderColor: success ? 'var(--success)' : error && 'var(--error)'
121
+ },
122
+ '&.MuiButton-outlined.secondaryDark': {
123
+ border: "0.063rem solid ".concat(buttonColor),
124
+ background: success ? 'var(--success)' : error && 'var(--error)'
125
+ },
126
+ '&.MuiButton-outlined div span, &.MuiButton-outlined div div ': {
127
+ color: success ? 'var(--success)' : error && 'var(--error)'
128
+ },
129
+ '&.MuiButton-outlined.secondaryDark div span, &.MuiButton-outlined.secondaryDark div div ': {
130
+ color: buttonColor
131
+ },
132
+ '&.MuiButton-outlined.Mui-disabled': {
133
+ border: '0.063rem solid var(--primary25)'
134
+ },
135
+ '&.MuiButton-outlined.Mui-disabled div span, &.MuiButton-outlined.Mui-disabled div div': {
136
+ color: 'var(--primary50)'
137
+ },
138
+ '&.MuiButton-text.Mui-disabled div span, &.MuiButton-text.Mui-disabled div div': {
139
+ color: 'var(--primary50)'
140
+ },
141
+ '&.MuiButton-text div span, &.MuiButton-text div div': {
142
+ color: success ? 'var(--success)' : error && 'var(--error)'
143
+ },
144
+ '&.MuiButton-root': {
145
+ transition: 'background .3s, width .3s, color .3s'
146
+ },
147
+ '&.MuiButton-outlined:hover': {
148
+ border: '0.063rem solid var(--primary)',
149
+ backgroundColor: success || error ? 'transparent' : 'var(--accent25)',
150
+ borderColor: success ? 'var(--success)' : error && 'var(--error)'
151
+ },
152
+ '&.MuiButton-outlined.secondaryDark:hover': {
153
+ border: "0.063rem solid ".concat(buttonColor),
154
+ backgroundColor: success || error ? success ? 'var(--success)' : error && 'var(--error)' : 'var(--primary75)'
155
+ },
156
+ '&.MuiButton-root.MuiButton-text:hover': {
157
+ backgroundColor: success || error ? 'transparent' : 'var(--accent25)'
158
+ },
159
+ paddingTop: '0.75rem',
160
+ paddingBottom: '0.75rem',
161
+ paddingLeft: startIcon && endIcon ? 'var(--spacing16)' : startIcon ? 'var(--spacing16)' : 'var(--spacing24)',
162
+ paddingRight: startIcon && endIcon ? 'var(--spacing16)' : endIcon || loading ? 'var(--spacing16)' : 'var(--spacing24)',
163
+ boxShadow: 'none',
164
+ lineHeight: '1.5rem'
165
+ }),
166
+ disabled: loading || disabled,
167
+ variant: buttonVariant,
168
+ disableFocusRipple: true,
169
+ fullWidth: fullWidth,
170
+ onClick: onClick
171
+ }, props), /*#__PURE__*/_react.default.createElement("div", {
172
+ className: 'cbx-buttonBasic-container'
173
+ }, badge && /*#__PURE__*/_react.default.createElement("div", {
174
+ className: "cbx-buttonBasic-badge"
175
+ }), startIcon && /*#__PURE__*/_react.default.createElement("div", {
176
+ className: 'cbx-buttonBasic-container-start-icon'
177
+ }, startIcon), /*#__PURE__*/_react.default.createElement(_Typography.default, {
178
+ color: buttonColor,
179
+ variant: variantText || 'M',
180
+ component: 'span',
181
+ fontWeight: '700',
182
+ styles: _objectSpread({}, stylesButton)
183
+ }, text), loading ? /*#__PURE__*/_react.default.createElement("div", {
184
+ className: 'cbx-buttonBasic-container-loading'
185
+ }, /*#__PURE__*/_react.default.createElement(_CircularProgress.default, {
186
+ style: {
187
+ width: 'var(--spacing24)',
188
+ height: '1.5rem'
189
+ }
190
+ })) : success || error ? /*#__PURE__*/_react.default.createElement("div", {
191
+ className: 'cbx-buttonBasic-container-end-icon'
192
+ }, /*#__PURE__*/_react.default.createElement("i", {
193
+ className: error ? 'ri-close-line' : 'ri-check-line'
194
+ })) : endIcon && /*#__PURE__*/_react.default.createElement("div", {
195
+ className: 'cbx-buttonBasic-container-end-icon'
196
+ }, endIcon)));
197
+ };
198
+
199
+ ButtonBasicOld.displayName = "ButtonBasicOld";
200
+ ButtonBasicOld.propTypes = {
201
+ text: _propTypes.default.node,
202
+ onClick: _propTypes.default.func,
203
+ disabled: _propTypes.default.bool,
204
+ loading: _propTypes.default.bool,
205
+ variant: _propTypes.default.string,
206
+ fullWidth: _propTypes.default.bool,
207
+ startIcon: _propTypes.default.node,
208
+ endIcon: _propTypes.default.node,
209
+ variantText: _propTypes.default.string,
210
+ stylesButton: _propTypes.default.object,
211
+ badge: _propTypes.default.any,
212
+ success: _propTypes.default.bool,
213
+ error: _propTypes.default.bool
214
+ };
215
+ ButtonBasicOld.defaultProps = {
216
+ text: null,
217
+ onClick: undefined,
218
+ disabled: false,
219
+ loading: false,
220
+ variant: 'primary',
221
+ fullWidth: false,
222
+ startIcon: undefined,
223
+ endIcon: undefined,
224
+ variantText: '',
225
+ stylesButton: undefined,
226
+ badge: false,
227
+ success: false,
228
+ error: false
229
+ };
230
+ var _default = ButtonBasicOld;
231
+ exports.default = _default;
@@ -1,31 +1,110 @@
1
+ .cbx-checkbox {
2
+ display: inline-flex;
3
+ -webkit-box-align: center;
4
+ align-items: center;
5
+ cursor: pointer;
6
+ vertical-align: middle;
7
+ -webkit-tap-highlight-color: transparent;
8
+ height: auto;
9
+ margin-left: 0;
10
+ margin-bottom: 0;
11
+ }
12
+
13
+ .cbx-checkbox input {
14
+ position: absolute;
15
+ opacity: 0;
16
+ width: 100%;
17
+ height: 100%;
18
+ top: 0;
19
+ left: 0;
20
+ margin: 0;
21
+ padding: 0;
22
+ z-index: 1;
23
+ }
24
+
1
25
  .cbx-checkbox-container {
2
- position: relative;
26
+ display: flex;
27
+ justify-content: center;
28
+ position: relative;
29
+ margin: 0;
30
+ width: 1.5rem;
31
+ height: 1.5rem;
32
+ border-radius: 50%;
33
+ overflow: visible;
34
+ box-sizing: content-box;
35
+ -webkit-box-align: center;
36
+ align-items: center;
37
+ -webkit-box-pack: center;
38
+ -webkit-tap-highlight-color: transparent;
39
+ background-color: transparent;
40
+ outline: 0px;
41
+ border: 0px;
42
+ cursor: pointer;
43
+ user-select: none;
44
+ vertical-align: middle;
45
+ appearance: none;
46
+ text-decoration: none;
47
+ color: rgba(255, 255, 255, 0.7);
3
48
  }
4
49
 
5
- .cbx-checkbox-container:hover:before {
6
- animation: ripple .6s ease;
50
+ .cbx-checkbox-container:not(.cbx-checkbox-container-disabled):hover {
51
+ background-color: rgba(144, 202, 249, 0.08);
52
+ border-radius: 50%;
7
53
  }
8
54
 
9
- .cbx-checkbox-container:before {
10
- content: "";
11
- position: absolute;
12
- top: 0;
13
- left: 0;
14
- width: 100%;
15
- height: 100%;
16
- background-color: var(--accent25);
17
- border-radius: 50%;
18
- transform: scale(0);
55
+ .cbx-checkbox-container.cbx-checkbox-container-disabled{
56
+ cursor: auto;
19
57
  }
20
58
 
21
- @keyframes ripple {
22
- from {
23
- transform: scale(0);
24
- opacity: 1;
25
- }
59
+ .cbx-checkbox-container input {
60
+ position: absolute;
61
+ opacity: 0;
62
+ width: 100%;
63
+ height: 100%;
64
+ top: 0;
65
+ left: 0;
66
+ margin: 0;
67
+ padding: 0;
68
+ z-index: 1;
69
+ border-radius: 50%;
70
+ }
71
+
72
+ .cbx-checkbox-checked {
73
+ -webkit-user-select: none;
74
+ -moz-user-select: none;
75
+ -ms-user-select: none;
76
+ user-select: none;
77
+ width: 1em;
78
+ height: 1em;
79
+ display: inline-block;
80
+ fill: var(--primary);
81
+ -webkit-flex-shrink: 0;
82
+ -ms-flex-negative: 0;
83
+ flex-shrink: 0;
84
+ -webkit-transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
85
+ transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
86
+ font-size: 1.5rem;
87
+ z-index: 1;
88
+ }
89
+
90
+ .cbx-checkbox-notChecked {
91
+ -webkit-user-select: none;
92
+ -moz-user-select: none;
93
+ -ms-user-select: none;
94
+ user-select: none;
95
+ width: 1em;
96
+ height: 1em;
97
+ display: inline-block;
98
+ fill: var(--gray4);
99
+ -webkit-flex-shrink: 0;
100
+ -ms-flex-negative: 0;
101
+ flex-shrink: 0;
102
+ -webkit-transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
103
+ transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
104
+ font-size: 1.5rem;
105
+ z-index: 1;
106
+ }
26
107
 
27
- to {
28
- transform: scale(2.1);
29
- opacity: .6;
30
- }
108
+ .cbx-checkbox-container input:focus + svg {
109
+ background-color: var(--gray2);
31
110
  }
@@ -9,58 +9,44 @@ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
13
-
14
12
  require("../../styles/main.css");
15
13
 
16
14
  require("./Checkbox.css");
17
15
 
18
- var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
16
+ var _Typography = _interopRequireDefault(require("../Typography/Typography"));
17
+
18
+ var _useDynamicStyles2 = _interopRequireDefault(require("../../HOCs/useDynamicStyles"));
19
19
 
20
- var _styled = _interopRequireDefault(require("@mui/material/styles/styled"));
20
+ var _useRipple3 = _interopRequireDefault(require("../../HOCs/useRipple"));
21
21
 
22
- var _excluded = ["id", "className", "disabled", "indeterminate", "label", "onChange"];
22
+ var _excluded = ["id", "className", "disabled", "indeterminate", "label", "onChange", "checked", "sx", "style", "onClick"];
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
26
26
  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); }
27
27
 
28
+ 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; }
29
+
30
+ 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; }
31
+
32
+ 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; }
33
+
34
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
35
+
36
+ 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."); }
37
+
38
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
39
+
40
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
41
+
42
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
43
+
44
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
45
+
28
46
  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; }
29
47
 
30
48
  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; }
31
49
 
32
- var CssFormControlLabel = (0, _styled.default)(_FormControlLabel.default)(function () {
33
- return {
34
- '& .MuiFormControlLabel-label': {
35
- marginLeft: 'var(--spacing12)',
36
- transition: '0.2s'
37
- },
38
- '& .MuiCheckbox-root.Mui-disabled': {
39
- color: '#acadce'
40
- },
41
- '& .MuiCheckbox-root': {
42
- transition: 'all .2s',
43
- width: '1.188rem',
44
- height: '1.125rem'
45
- },
46
- '.MuiButtonBase-root.Mui-disabled, .MuiFormControlLabel-label.Mui-disabled': {
47
- color: 'var(--gray3)',
48
- fontWeight: '700'
49
- },
50
- '& .MuiButtonBase-root.Mui-checked + span': {
51
- color: 'var(--primary)',
52
- fontWeight: '700'
53
- },
54
- '& .Mui-checked': {
55
- color: 'var(--primary)!important'
56
- },
57
- '& .MuiCheckbox-root.Mui-disabled.Mui-checked + span': {
58
- color: 'var(--gray3)',
59
- fontWeight: '700'
60
- }
61
- };
62
- });
63
-
64
50
  var Checkbox = function Checkbox(_ref) {
65
51
  var id = _ref.id,
66
52
  className = _ref.className,
@@ -68,34 +54,102 @@ var Checkbox = function Checkbox(_ref) {
68
54
  indeterminate = _ref.indeterminate,
69
55
  label = _ref.label,
70
56
  onChange = _ref.onChange,
57
+ checkedProp = _ref.checked,
58
+ sx = _ref.sx,
59
+ style = _ref.style,
60
+ onClick = _ref.onClick,
71
61
  props = _objectWithoutProperties(_ref, _excluded);
72
62
 
73
- return /*#__PURE__*/_react.default.createElement(CssFormControlLabel, _extends({
74
- id: id,
75
- className: className,
76
- style: {
77
- margin: '0px'
63
+ var _useDynamicStyles = (0, _useDynamicStyles2.default)(sx),
64
+ stylesInLine = _useDynamicStyles.stylesInLine,
65
+ prefixClass = _useDynamicStyles.prefixClass;
66
+
67
+ var _useRipple = (0, _useRipple3.default)({
68
+ backgroundColor: 'var(--accent25)'
69
+ }, 'center'),
70
+ _useRipple2 = _slicedToArray(_useRipple, 2),
71
+ addRipple = _useRipple2[0],
72
+ ripples = _useRipple2[1];
73
+
74
+ var _React$useState = _react.default.useState(checkedProp),
75
+ _React$useState2 = _slicedToArray(_React$useState, 2),
76
+ internalState = _React$useState2[0],
77
+ setInternalState = _React$useState2[1];
78
+
79
+ var handleChange = function handleChange(event) {
80
+ if (disabled) return;
81
+ var newChecked = event.target.checked;
82
+ setInternalState(newChecked);
83
+
84
+ if (onChange) {
85
+ onChange(event);
86
+ }
87
+ };
88
+
89
+ _react.default.useEffect(function () {
90
+ setInternalState(checkedProp);
91
+ }, [checkedProp]);
92
+
93
+ return /*#__PURE__*/_react.default.createElement("label", _extends({
94
+ className: prefixClass('cbx-checkbox'),
95
+ style: _objectSpread(_objectSpread({}, style), stylesInLine)
96
+ }, props), /*#__PURE__*/_react.default.createElement("span", {
97
+ className: prefixClass("cbx-checkbox-container ".concat(disabled ? 'cbx-checkbox-container-disabled' : '', " ").concat(!disabled ? 'cbx-ripple' : '')),
98
+ onClick: addRipple
99
+ }, /*#__PURE__*/_react.default.createElement("input", {
100
+ type: "checkbox",
101
+ checked: internalState,
102
+ onChange: handleChange,
103
+ onClick: function onClick(event) {
104
+ event.stopPropagation();
78
105
  },
79
- onChange: onChange,
80
- control: /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
81
- className: 'cbx-checkbox-container',
82
- indeterminate: indeterminate,
83
- style: {
84
- padding: '0px'
85
- },
86
- sx: {
87
- '& .MuiSvgIcon-root': {
88
- fontSize: '1.5rem',
89
- zIndex: '1'
90
- },
91
- '.MuiTouchRipple-child': {
92
- backgroundColor: 'var(--accent25)'
93
- }
106
+ onKeyDown: function onKeyDown(event) {
107
+ if (event.key === ' ') {
108
+ event.preventDefault();
109
+ handleChange({
110
+ target: {
111
+ checked: !internalState
112
+ }
113
+ });
94
114
  }
95
- }),
96
- disabled: disabled,
97
- label: label
98
- }, props));
115
+ },
116
+ tabIndex: 0
117
+ }), !disabled && ripples, internalState ? indeterminate ? /*#__PURE__*/_react.default.createElement("svg", {
118
+ focusable: "false",
119
+ "aria-hidden": "true",
120
+ viewBox: "0 0 24 24",
121
+ className: prefixClass('cbx-checkbox-checked')
122
+ }, /*#__PURE__*/_react.default.createElement("path", {
123
+ d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"
124
+ })) : /*#__PURE__*/_react.default.createElement("svg", {
125
+ className: prefixClass('cbx-checkbox-checked'),
126
+ focusable: "false",
127
+ "aria-hidden": "true",
128
+ viewBox: "0 0 24 24",
129
+ "data-testid": "CheckBoxIcon",
130
+ style: {
131
+ fill: disabled && 'var(--gray3)'
132
+ }
133
+ }, /*#__PURE__*/_react.default.createElement("path", {
134
+ d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
135
+ })) : /*#__PURE__*/_react.default.createElement("svg", {
136
+ className: prefixClass('cbx-checkbox-notChecked'),
137
+ focusable: "false",
138
+ "aria-hidden": "true",
139
+ viewBox: "0 0 24 24"
140
+ }, /*#__PURE__*/_react.default.createElement("path", {
141
+ d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
142
+ }))), /*#__PURE__*/_react.default.createElement(_Typography.default, {
143
+ component: 'span',
144
+ style: {
145
+ margin: '0',
146
+ transition: '0.2s',
147
+ marginLeft: '.5rem'
148
+ },
149
+ color: disabled ? 'var(--gray3)' : internalState ? 'var(--primary)' : 'var(--gray4)',
150
+ fontWeight: disabled ? '700' : internalState ? '700' : '400',
151
+ prefixClass: prefixClass
152
+ }, label));
99
153
  };
100
154
 
101
155
  Checkbox.displayName = "Checkbox";
@@ -103,13 +157,15 @@ Checkbox.propTypes = {
103
157
  onChange: _propTypes.default.func,
104
158
  disabled: _propTypes.default.bool,
105
159
  indeterminate: _propTypes.default.bool,
106
- label: _propTypes.default.string
160
+ label: _propTypes.default.string,
161
+ checked: _propTypes.default.bool
107
162
  };
108
163
  Checkbox.defaultProps = {
109
164
  onChange: undefined,
110
165
  disabled: false,
111
166
  indeterminate: false,
112
- label: ''
167
+ label: '',
168
+ checked: false
113
169
  };
114
170
  var _default = Checkbox;
115
171
  exports.default = _default;
@@ -0,0 +1,31 @@
1
+ .cbx-checkbox-container {
2
+ position: relative;
3
+ }
4
+
5
+ .cbx-checkbox-container:hover:before {
6
+ animation: ripple .6s ease;
7
+ }
8
+
9
+ .cbx-checkbox-container:before {
10
+ content: "";
11
+ position: absolute;
12
+ top: 0;
13
+ left: 0;
14
+ width: 100%;
15
+ height: 100%;
16
+ background-color: var(--accent25);
17
+ border-radius: 50%;
18
+ transform: scale(0);
19
+ }
20
+
21
+ @keyframes ripple {
22
+ from {
23
+ transform: scale(0);
24
+ opacity: 1;
25
+ }
26
+
27
+ to {
28
+ transform: scale(2.1);
29
+ opacity: .6;
30
+ }
31
+ }