@dxc-technology/halstack-react 0.0.0-b9523dd → 0.0.0-b98c25c

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 (315) hide show
  1. package/BackgroundColorContext.d.ts +10 -0
  2. package/BackgroundColorContext.js +1 -4
  3. package/HalstackContext.d.ts +12 -0
  4. package/HalstackContext.js +295 -0
  5. package/accordion/Accordion.d.ts +1 -1
  6. package/accordion/Accordion.js +124 -137
  7. package/accordion/Accordion.stories.tsx +306 -0
  8. package/accordion/Accordion.test.js +71 -0
  9. package/accordion/types.d.ts +12 -11
  10. package/accordion-group/AccordionGroup.d.ts +1 -1
  11. package/accordion-group/AccordionGroup.js +16 -37
  12. package/accordion-group/AccordionGroup.stories.tsx +251 -0
  13. package/accordion-group/AccordionGroup.test.js +126 -0
  14. package/accordion-group/types.d.ts +17 -10
  15. package/alert/Alert.js +7 -4
  16. package/alert/Alert.stories.tsx +170 -0
  17. package/alert/Alert.test.js +92 -0
  18. package/alert/types.d.ts +1 -1
  19. package/badge/Badge.d.ts +4 -0
  20. package/badge/Badge.js +6 -4
  21. package/badge/types.d.ts +5 -0
  22. package/{radio → badge}/types.js +0 -0
  23. package/bleed/Bleed.d.ts +3 -0
  24. package/bleed/Bleed.js +51 -0
  25. package/bleed/Bleed.stories.tsx +341 -0
  26. package/bleed/types.d.ts +37 -0
  27. package/bleed/types.js +5 -0
  28. package/box/Box.d.ts +4 -0
  29. package/box/Box.js +29 -65
  30. package/box/{Box.stories.jsx → Box.stories.tsx} +0 -0
  31. package/box/Box.test.js +18 -0
  32. package/box/types.d.ts +44 -0
  33. package/box/types.js +5 -0
  34. package/bulleted-list/BulletedList.d.ts +7 -0
  35. package/bulleted-list/BulletedList.js +123 -0
  36. package/bulleted-list/BulletedList.stories.tsx +200 -0
  37. package/bulleted-list/types.d.ts +11 -0
  38. package/bulleted-list/types.js +5 -0
  39. package/button/Button.d.ts +1 -1
  40. package/button/Button.js +62 -83
  41. package/button/Button.stories.tsx +231 -241
  42. package/button/Button.test.js +35 -0
  43. package/button/types.d.ts +10 -14
  44. package/card/Card.js +26 -30
  45. package/card/Card.stories.tsx +201 -0
  46. package/card/Card.test.js +50 -0
  47. package/card/ice-cream.jpg +0 -0
  48. package/card/types.d.ts +5 -6
  49. package/checkbox/Checkbox.d.ts +1 -1
  50. package/checkbox/Checkbox.js +104 -108
  51. package/checkbox/Checkbox.stories.tsx +124 -128
  52. package/checkbox/Checkbox.test.js +155 -0
  53. package/checkbox/types.d.ts +11 -7
  54. package/chip/Chip.d.ts +4 -0
  55. package/chip/Chip.js +16 -76
  56. package/chip/Chip.stories.tsx +119 -0
  57. package/chip/Chip.test.js +56 -0
  58. package/chip/types.d.ts +45 -0
  59. package/chip/types.js +5 -0
  60. package/common/variables.js +319 -380
  61. package/date-input/DateInput.js +66 -55
  62. package/date-input/DateInput.stories.tsx +138 -0
  63. package/date-input/DateInput.test.js +479 -0
  64. package/date-input/types.d.ts +16 -9
  65. package/dialog/Dialog.js +50 -53
  66. package/dialog/Dialog.stories.tsx +267 -0
  67. package/dialog/Dialog.test.js +70 -0
  68. package/dialog/types.d.ts +3 -2
  69. package/dropdown/Dropdown.d.ts +1 -1
  70. package/dropdown/Dropdown.js +243 -273
  71. package/dropdown/Dropdown.stories.tsx +312 -0
  72. package/dropdown/Dropdown.test.js +591 -0
  73. package/dropdown/DropdownMenu.d.ts +4 -0
  74. package/dropdown/DropdownMenu.js +80 -0
  75. package/dropdown/DropdownMenuItem.d.ts +4 -0
  76. package/dropdown/DropdownMenuItem.js +92 -0
  77. package/dropdown/types.d.ts +30 -19
  78. package/file-input/FileInput.d.ts +4 -0
  79. package/file-input/FileInput.js +172 -111
  80. package/file-input/FileInput.stories.tsx +507 -0
  81. package/file-input/FileInput.test.js +457 -0
  82. package/file-input/FileItem.d.ts +14 -0
  83. package/file-input/FileItem.js +16 -23
  84. package/file-input/types.d.ts +112 -0
  85. package/file-input/types.js +5 -0
  86. package/flex/Flex.d.ts +4 -0
  87. package/flex/Flex.js +57 -0
  88. package/flex/Flex.stories.tsx +103 -0
  89. package/flex/types.d.ts +21 -0
  90. package/flex/types.js +5 -0
  91. package/footer/Footer.d.ts +1 -1
  92. package/footer/Footer.js +32 -113
  93. package/footer/{Footer.stories.jsx → Footer.stories.tsx} +5 -19
  94. package/footer/Footer.test.js +109 -0
  95. package/footer/Icons.d.ts +2 -0
  96. package/footer/Icons.js +4 -4
  97. package/footer/types.d.ts +23 -18
  98. package/header/Header.js +97 -116
  99. package/header/Header.stories.tsx +172 -0
  100. package/header/Header.test.js +79 -0
  101. package/header/Icons.d.ts +2 -0
  102. package/header/Icons.js +2 -2
  103. package/header/types.d.ts +7 -4
  104. package/heading/Heading.d.ts +4 -0
  105. package/heading/Heading.js +7 -24
  106. package/heading/Heading.stories.tsx +54 -0
  107. package/heading/Heading.test.js +186 -0
  108. package/heading/types.d.ts +33 -0
  109. package/heading/types.js +5 -0
  110. package/inset/Inset.d.ts +3 -0
  111. package/inset/Inset.js +51 -0
  112. package/inset/Inset.stories.tsx +229 -0
  113. package/inset/types.d.ts +37 -0
  114. package/inset/types.js +5 -0
  115. package/layout/ApplicationLayout.d.ts +20 -0
  116. package/layout/ApplicationLayout.js +71 -135
  117. package/layout/ApplicationLayout.stories.tsx +162 -0
  118. package/layout/Icons.d.ts +5 -0
  119. package/layout/Icons.js +13 -2
  120. package/layout/SidenavContext.d.ts +5 -0
  121. package/layout/SidenavContext.js +19 -0
  122. package/layout/types.d.ts +42 -0
  123. package/layout/types.js +5 -0
  124. package/link/Link.d.ts +4 -0
  125. package/link/Link.js +60 -107
  126. package/link/Link.stories.tsx +193 -0
  127. package/link/Link.test.js +83 -0
  128. package/link/types.d.ts +54 -0
  129. package/link/types.js +5 -0
  130. package/main.d.ts +12 -12
  131. package/main.js +64 -58
  132. package/number-input/NumberInput.d.ts +4 -0
  133. package/number-input/NumberInput.js +16 -68
  134. package/number-input/{NumberInput.stories.jsx → NumberInput.stories.tsx} +5 -5
  135. package/number-input/NumberInput.test.js +506 -0
  136. package/number-input/NumberInputContext.d.ts +4 -0
  137. package/number-input/NumberInputContext.js +5 -2
  138. package/number-input/numberInputContextTypes.d.ts +19 -0
  139. package/number-input/numberInputContextTypes.js +5 -0
  140. package/number-input/types.d.ts +124 -0
  141. package/number-input/types.js +5 -0
  142. package/package.json +16 -12
  143. package/paginator/Paginator.js +19 -46
  144. package/paginator/Paginator.test.js +308 -0
  145. package/paragraph/Paragraph.d.ts +6 -0
  146. package/paragraph/Paragraph.js +38 -0
  147. package/paragraph/Paragraph.stories.tsx +44 -0
  148. package/password-input/PasswordInput.d.ts +4 -0
  149. package/password-input/PasswordInput.js +22 -55
  150. package/password-input/{PasswordInput.stories.jsx → PasswordInput.stories.tsx} +3 -3
  151. package/password-input/PasswordInput.test.js +180 -0
  152. package/password-input/types.d.ts +110 -0
  153. package/password-input/types.js +5 -0
  154. package/progress-bar/ProgressBar.d.ts +2 -2
  155. package/progress-bar/ProgressBar.js +59 -53
  156. package/progress-bar/ProgressBar.stories.jsx +60 -0
  157. package/progress-bar/ProgressBar.test.js +110 -0
  158. package/progress-bar/types.d.ts +3 -4
  159. package/quick-nav/QuickNav.d.ts +4 -0
  160. package/quick-nav/QuickNav.js +115 -0
  161. package/quick-nav/QuickNav.stories.tsx +300 -0
  162. package/quick-nav/types.d.ts +21 -0
  163. package/quick-nav/types.js +5 -0
  164. package/radio-group/Radio.d.ts +4 -0
  165. package/radio-group/Radio.js +156 -0
  166. package/radio-group/RadioGroup.d.ts +4 -0
  167. package/radio-group/RadioGroup.js +279 -0
  168. package/radio-group/RadioGroup.stories.tsx +101 -0
  169. package/radio-group/RadioGroup.test.js +665 -0
  170. package/radio-group/types.d.ts +114 -0
  171. package/radio-group/types.js +5 -0
  172. package/resultsetTable/ResultsetTable.d.ts +4 -0
  173. package/resultsetTable/ResultsetTable.js +9 -29
  174. package/resultsetTable/ResultsetTable.stories.tsx +275 -0
  175. package/resultsetTable/ResultsetTable.test.js +348 -0
  176. package/resultsetTable/types.d.ts +67 -0
  177. package/resultsetTable/types.js +5 -0
  178. package/select/Icons.d.ts +10 -0
  179. package/select/Icons.js +93 -0
  180. package/select/Listbox.d.ts +4 -0
  181. package/select/Listbox.js +198 -0
  182. package/select/Option.d.ts +4 -0
  183. package/select/Option.js +110 -0
  184. package/select/Select.d.ts +4 -0
  185. package/select/Select.js +158 -380
  186. package/select/Select.stories.tsx +627 -0
  187. package/select/Select.test.js +2175 -0
  188. package/select/types.d.ts +210 -0
  189. package/select/types.js +5 -0
  190. package/sidenav/Sidenav.d.ts +10 -0
  191. package/sidenav/Sidenav.js +186 -63
  192. package/sidenav/Sidenav.stories.tsx +180 -0
  193. package/sidenav/Sidenav.test.js +44 -0
  194. package/sidenav/types.d.ts +73 -0
  195. package/sidenav/types.js +5 -0
  196. package/slider/Slider.d.ts +1 -1
  197. package/slider/Slider.js +145 -109
  198. package/slider/Slider.stories.tsx +183 -0
  199. package/slider/Slider.test.js +250 -0
  200. package/slider/types.d.ts +8 -9
  201. package/spinner/Spinner.js +3 -3
  202. package/spinner/Spinner.stories.jsx +1 -0
  203. package/spinner/Spinner.test.js +64 -0
  204. package/switch/Switch.d.ts +2 -2
  205. package/switch/Switch.js +149 -67
  206. package/switch/Switch.stories.tsx +138 -0
  207. package/switch/Switch.test.js +225 -0
  208. package/switch/types.d.ts +9 -6
  209. package/table/Table.js +3 -3
  210. package/table/Table.stories.jsx +2 -1
  211. package/table/Table.test.js +26 -0
  212. package/tabs/Tab.d.ts +4 -0
  213. package/tabs/Tab.js +135 -0
  214. package/tabs/Tabs.d.ts +1 -1
  215. package/tabs/Tabs.js +364 -108
  216. package/tabs/Tabs.stories.tsx +186 -0
  217. package/tabs/Tabs.test.js +351 -0
  218. package/tabs/types.d.ts +41 -20
  219. package/tabs-nav/NavTabs.d.ts +8 -0
  220. package/tabs-nav/NavTabs.js +125 -0
  221. package/tabs-nav/NavTabs.stories.tsx +170 -0
  222. package/tabs-nav/NavTabs.test.js +82 -0
  223. package/tabs-nav/Tab.d.ts +4 -0
  224. package/tabs-nav/Tab.js +130 -0
  225. package/tabs-nav/types.d.ts +53 -0
  226. package/tabs-nav/types.js +5 -0
  227. package/tag/Tag.d.ts +4 -0
  228. package/tag/Tag.js +21 -52
  229. package/tag/{Tag.stories.jsx → Tag.stories.tsx} +26 -29
  230. package/tag/Tag.test.js +60 -0
  231. package/tag/types.d.ts +69 -0
  232. package/tag/types.js +5 -0
  233. package/text-input/Icons.d.ts +8 -0
  234. package/text-input/Icons.js +60 -0
  235. package/text-input/Suggestion.d.ts +4 -0
  236. package/text-input/Suggestion.js +57 -0
  237. package/text-input/Suggestions.d.ts +4 -0
  238. package/text-input/Suggestions.js +134 -0
  239. package/text-input/TextInput.d.ts +4 -0
  240. package/text-input/TextInput.js +166 -328
  241. package/text-input/TextInput.stories.tsx +481 -0
  242. package/text-input/TextInput.test.js +1713 -0
  243. package/text-input/types.d.ts +192 -0
  244. package/text-input/types.js +5 -0
  245. package/textarea/Textarea.d.ts +4 -0
  246. package/textarea/Textarea.js +39 -79
  247. package/textarea/Textarea.stories.jsx +37 -15
  248. package/textarea/Textarea.test.js +437 -0
  249. package/textarea/types.d.ts +137 -0
  250. package/textarea/types.js +5 -0
  251. package/toggle-group/ToggleGroup.d.ts +4 -0
  252. package/toggle-group/ToggleGroup.js +18 -46
  253. package/toggle-group/ToggleGroup.stories.tsx +173 -0
  254. package/toggle-group/ToggleGroup.test.js +156 -0
  255. package/toggle-group/types.d.ts +105 -0
  256. package/toggle-group/types.js +5 -0
  257. package/typography/Typography.d.ts +4 -0
  258. package/typography/Typography.js +131 -0
  259. package/typography/Typography.stories.tsx +198 -0
  260. package/typography/types.d.ts +18 -0
  261. package/typography/types.js +5 -0
  262. package/useTheme.d.ts +2 -0
  263. package/useTheme.js +2 -2
  264. package/useTranslatedLabels.d.ts +2 -0
  265. package/useTranslatedLabels.js +20 -0
  266. package/wizard/Wizard.d.ts +4 -0
  267. package/wizard/Wizard.js +118 -104
  268. package/wizard/Wizard.stories.tsx +233 -0
  269. package/wizard/Wizard.test.js +141 -0
  270. package/wizard/types.d.ts +65 -0
  271. package/wizard/types.js +5 -0
  272. package/ThemeContext.js +0 -246
  273. package/V3Select/V3Select.js +0 -455
  274. package/V3Select/index.d.ts +0 -27
  275. package/V3Textarea/V3Textarea.js +0 -260
  276. package/V3Textarea/index.d.ts +0 -27
  277. package/box/index.d.ts +0 -25
  278. package/chip/index.d.ts +0 -22
  279. package/date/Date.js +0 -373
  280. package/date/index.d.ts +0 -27
  281. package/file-input/index.d.ts +0 -81
  282. package/heading/index.d.ts +0 -17
  283. package/input-text/Icons.js +0 -22
  284. package/input-text/InputText.js +0 -611
  285. package/input-text/index.d.ts +0 -36
  286. package/link/index.d.ts +0 -23
  287. package/number-input/index.d.ts +0 -113
  288. package/password-input/index.d.ts +0 -94
  289. package/radio/Radio.d.ts +0 -4
  290. package/radio/Radio.js +0 -174
  291. package/radio/Radio.stories.tsx +0 -192
  292. package/radio/types.d.ts +0 -54
  293. package/resultsetTable/index.d.ts +0 -19
  294. package/select/index.d.ts +0 -131
  295. package/sidenav/index.d.ts +0 -13
  296. package/tag/index.d.ts +0 -24
  297. package/text-input/index.d.ts +0 -135
  298. package/textarea/index.d.ts +0 -117
  299. package/toggle/Toggle.js +0 -186
  300. package/toggle/index.d.ts +0 -21
  301. package/toggle-group/index.d.ts +0 -21
  302. package/upload/Upload.js +0 -201
  303. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  304. package/upload/buttons-upload/Icons.js +0 -40
  305. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  306. package/upload/dragAndDropArea/Icons.js +0 -39
  307. package/upload/file-upload/FileToUpload.js +0 -115
  308. package/upload/file-upload/Icons.js +0 -66
  309. package/upload/files-upload/FilesToUpload.js +0 -109
  310. package/upload/index.d.ts +0 -15
  311. package/upload/transaction/Icons.js +0 -160
  312. package/upload/transaction/Transaction.js +0 -104
  313. package/upload/transactions/Transactions.js +0 -94
  314. package/wizard/Icons.js +0 -65
  315. package/wizard/index.d.ts +0 -18
@@ -19,26 +19,37 @@ var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
21
 
22
- var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
23
-
24
- var _RequiredComponent = _interopRequireDefault(require("../common/RequiredComponent"));
25
-
26
22
  var _variables = require("../common/variables.js");
27
23
 
28
24
  var _utils = require("../common/utils.js");
29
25
 
30
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
26
+ var _uuid = require("uuid");
27
+
28
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
29
+
30
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
31
31
 
32
- var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
32
+ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
33
33
 
34
- var _templateObject, _templateObject2, _templateObject3;
34
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
35
35
 
36
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
37
 
38
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
39
 
40
+ var checkedIcon = /*#__PURE__*/_react["default"].createElement("svg", {
41
+ fill: "currentColor",
42
+ focusable: "false",
43
+ "aria-hidden": "true",
44
+ viewBox: "0 0 24 24"
45
+ }, /*#__PURE__*/_react["default"].createElement("path", {
46
+ 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 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
47
+ }));
48
+
40
49
  var DxcCheckbox = function DxcCheckbox(_ref) {
41
50
  var checked = _ref.checked,
51
+ _ref$defaultChecked = _ref.defaultChecked,
52
+ defaultChecked = _ref$defaultChecked === void 0 ? false : _ref$defaultChecked,
42
53
  value = _ref.value,
43
54
  _ref$label = _ref.label,
44
55
  label = _ref$label === void 0 ? "" : _ref$label,
@@ -48,87 +59,86 @@ var DxcCheckbox = function DxcCheckbox(_ref) {
48
59
  name = _ref$name === void 0 ? "" : _ref$name,
49
60
  _ref$disabled = _ref.disabled,
50
61
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
62
+ _ref$optional = _ref.optional,
63
+ optional = _ref$optional === void 0 ? false : _ref$optional,
51
64
  onChange = _ref.onChange,
52
- _ref$required = _ref.required,
53
- required = _ref$required === void 0 ? false : _ref$required,
54
65
  margin = _ref.margin,
55
66
  _ref$size = _ref.size,
56
67
  size = _ref$size === void 0 ? "fitContent" : _ref$size,
57
68
  _ref$tabIndex = _ref.tabIndex,
58
69
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
59
70
 
60
- var _useState = (0, _react.useState)(false),
61
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
62
- innerChecked = _useState2[0],
63
- setInnerChecked = _useState2[1];
71
+ var _useState = (0, _react.useState)("label-checkbox-".concat((0, _uuid.v4)())),
72
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
73
+ labelId = _useState2[0];
64
74
 
65
- var _useState3 = (0, _react.useState)(false),
75
+ var _useState3 = (0, _react.useState)(defaultChecked),
66
76
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
67
- isLabelHovered = _useState4[0],
68
- setIsLabelHovered = _useState4[1];
77
+ innerChecked = _useState4[0],
78
+ setInnerChecked = _useState4[1];
69
79
 
80
+ var checkboxRef = (0, _react.useRef)(null);
70
81
  var colorsTheme = (0, _useTheme["default"])();
71
82
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
83
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
72
84
 
73
- var handlerCheckboxChange = function handlerCheckboxChange(checkboxValue) {
74
- if (checked === undefined) {
75
- var isChecked = checkboxValue.target.checked === undefined ? !innerChecked : checkboxValue.target.checked;
76
- setInnerChecked(isChecked);
77
-
78
- if (typeof onChange === "function") {
79
- onChange(isChecked);
80
- }
81
- } else {
82
- if (typeof onChange === "function") {
83
- onChange(!checked);
84
- }
85
- }
85
+ var handleCheckboxChange = function handleCheckboxChange() {
86
+ var _checkboxRef$current;
87
+
88
+ document.activeElement !== (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) && (checkboxRef === null || checkboxRef === void 0 ? void 0 : (_checkboxRef$current = checkboxRef.current) === null || _checkboxRef$current === void 0 ? void 0 : _checkboxRef$current.focus());
89
+ var newChecked = checked !== null && checked !== void 0 ? checked : innerChecked;
90
+ checked !== null && checked !== void 0 ? checked : setInnerChecked(function (innerChecked) {
91
+ return !innerChecked;
92
+ });
93
+ onChange === null || onChange === void 0 ? void 0 : onChange(!newChecked);
86
94
  };
87
95
 
88
- var handleLabelHover = function handleLabelHover() {
89
- setIsLabelHovered(!isLabelHovered);
96
+ var handleKeyboard = function handleKeyboard(event) {
97
+ switch (event.key) {
98
+ case " ":
99
+ event.preventDefault();
100
+ handleCheckboxChange();
101
+ }
90
102
  };
91
103
 
92
104
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
93
105
  theme: colorsTheme.checkbox
94
- }, /*#__PURE__*/_react["default"].createElement(CheckboxContainer, {
95
- id: name,
96
- brightness: _variables.componentTokens,
97
- label: label,
98
- labelPosition: labelPosition,
106
+ }, /*#__PURE__*/_react["default"].createElement(MainContainer, {
99
107
  disabled: disabled,
108
+ onClick: disabled ? undefined : handleCheckboxChange,
100
109
  margin: margin,
101
110
  size: size,
102
- backgroundType: backgroundType,
103
- isLabelHovered: isLabelHovered
104
- }, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
105
- checked: checked != undefined ? checked : innerChecked,
106
- inputProps: {
107
- name: name,
108
- "aria-label": label,
109
- role: "checkbox",
110
- "aria-checked": checked != undefined ? checked : innerChecked
111
- },
112
- onChange: handlerCheckboxChange,
113
- value: value,
114
- disabled: disabled,
115
- disableRipple: true,
116
- className: "test",
117
- tabIndex: tabIndex
118
- }), /*#__PURE__*/_react["default"].createElement(CheckboxBlackBack, {
119
- labelPosition: labelPosition,
111
+ checked: checked !== null && checked !== void 0 ? checked : innerChecked,
112
+ backgroundType: backgroundType
113
+ }, label && labelPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
114
+ id: labelId,
120
115
  disabled: disabled,
121
- checked: checked != undefined ? checked : innerChecked,
122
116
  backgroundType: backgroundType
123
- }), required && /*#__PURE__*/_react["default"].createElement(_RequiredComponent["default"], null), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
124
- labelPosition: labelPosition,
125
- onClick: disabled === true ? function (e) {} : handlerCheckboxChange,
117
+ }, label, optional && " ".concat(translatedLabels.formFields.optionalLabel)), /*#__PURE__*/_react["default"].createElement(ValueInput, {
118
+ type: "checkbox",
119
+ checked: checked !== null && checked !== void 0 ? checked : innerChecked,
120
+ name: name,
121
+ "aria-hidden": "true",
122
+ value: value,
126
123
  disabled: disabled,
127
- className: "labelContainer",
124
+ readOnly: true
125
+ }), /*#__PURE__*/_react["default"].createElement(CheckboxContainer, null, /*#__PURE__*/_react["default"].createElement(Checkbox, {
126
+ onKeyDown: handleKeyboard,
127
+ role: "checkbox",
128
+ tabIndex: disabled ? -1 : tabIndex,
129
+ "aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked,
130
+ "aria-disabled": disabled,
131
+ "aria-required": !disabled && !optional,
132
+ "aria-labelledby": labelId,
128
133
  backgroundType: backgroundType,
129
- onMouseOver: handleLabelHover,
130
- onMouseOut: handleLabelHover
131
- }, label)));
134
+ checked: checked !== null && checked !== void 0 ? checked : innerChecked,
135
+ disabled: disabled,
136
+ ref: checkboxRef
137
+ }, (checked !== null && checked !== void 0 ? checked : innerChecked) && checkedIcon)), label && labelPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
138
+ id: labelId,
139
+ disabled: disabled,
140
+ backgroundType: backgroundType
141
+ }, optional && "".concat(translatedLabels.formFields.optionalLabel, " "), label)));
132
142
  };
133
143
 
134
144
  var sizes = {
@@ -136,7 +146,7 @@ var sizes = {
136
146
  medium: "240px",
137
147
  large: "480px",
138
148
  fillParent: "100%",
139
- fitContent: "unset"
149
+ fitContent: "fit-content"
140
150
  };
141
151
 
142
152
  var calculateWidth = function calculateWidth(margin, size) {
@@ -151,19 +161,15 @@ var getDisabledColor = function getDisabledColor(props, element) {
151
161
  switch (element) {
152
162
  case "check":
153
163
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledCheckColorOnDark : props.theme.disabledCheckColor;
154
- break;
155
164
 
156
165
  case "background":
157
166
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledBackgroundColorCheckedOnDark : props.theme.disabledBackgroundColorChecked;
158
- break;
159
167
 
160
168
  case "border":
161
169
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;
162
- break;
163
170
 
164
171
  case "label":
165
172
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledFontColorOnDark : props.theme.disabledFontColor;
166
- break;
167
173
  }
168
174
  };
169
175
 
@@ -171,26 +177,26 @@ var getNotDisabledColor = function getNotDisabledColor(props, element) {
171
177
  switch (element) {
172
178
  case "check":
173
179
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.checkColorOnDark : props.theme.checkColor;
174
- break;
175
180
 
176
181
  case "background":
177
182
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.backgroundColorCheckedOnDark : props.theme.backgroundColorChecked;
178
- break;
183
+
184
+ case "hoverBackground":
185
+ return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
179
186
 
180
187
  case "border":
181
188
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.borderColorOnDark : props.theme.borderColor;
182
- break;
189
+
190
+ case "hoverBorder":
191
+ return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
183
192
 
184
193
  case "label":
185
194
  return props.backgroundType && props.backgroundType === "dark" ? props.theme.fontColorOnDark : props.theme.fontColor;
186
- break;
187
195
  }
188
196
  };
189
197
 
190
- var LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n cursor: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
198
+ var LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
191
199
  return props.disabled ? getDisabledColor(props, "label") : getNotDisabledColor(props, "label");
192
- }, function (props) {
193
- return props.disabled ? "not-allowed" : "pointer";
194
200
  }, function (props) {
195
201
  return props.theme.fontFamily;
196
202
  }, function (props) {
@@ -199,54 +205,44 @@ var LabelContainer = _styledComponents["default"].span(_templateObject || (_temp
199
205
  return props.theme.fontWeight;
200
206
  });
201
207
 
202
- var CheckboxContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n width: ", ";\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n position: relative;\n flex-direction: ", ";\n .MuiCheckbox-colorSecondary {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n }\n }\n &.Mui-disabled {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n opacity: 0.34;\n }\n }\n }\n &.Mui-checked {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n }\n }\n\n &:hover {\n background-color: transparent;\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n background-color: transparent;\n color: ", ";\n }\n }\n }\n }\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n width: 24px;\n height: 24px;\n }\n }\n }\n\n .MuiIconButton-colorSecondary {\n &:hover {\n background-color: transparent;\n }\n }\n .MuiButtonBase-root {\n &:hover {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n }\n }\n }\n\n &.Mui-focusVisible {\n .MuiIconButton-label {\n box-shadow: 0 0 0 2px\n ", ";\n }\n }\n z-index: 1;\n margin-left: ", ";\n margin-right: ", ";\n padding: 0px;\n left: ", ";\n right: ", ";\n }\n"])), function (props) {
203
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
204
- }, function (props) {
205
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
206
- }, function (props) {
207
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
208
- }, function (props) {
209
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
210
- }, function (props) {
211
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
212
- }, function (props) {
213
- return calculateWidth(props.margin, props.size);
214
- }, function (props) {
215
- return props.disabled ? "not-allowed" : "pointer";
216
- }, function (props) {
217
- return props.labelPosition === "before" ? "row-reverse" : "row";
218
- }, function (props) {
219
- return props.isLabelHovered ? props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor : getNotDisabledColor(props, "border");
208
+ var ValueInput = _styledComponents["default"].input(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
209
+
210
+ var CheckboxContainer = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
211
+
212
+ var Checkbox = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 18px;\n width: 18px;\n border: solid 2px\n ", ";\n border-radius: 2px;\n background-color: ", ";\n color: ", ";\n\n &:focus {\n outline: 2px solid\n ", ";\n outline-offset: 2px;\n }\n svg {\n position: absolute;\n width: 22px;\n height: 22px;\n }\n ", "\n"])), function (props) {
213
+ return props.disabled ? getDisabledColor(props, "border") : getNotDisabledColor(props, "border");
220
214
  }, function (props) {
221
- return getDisabledColor(props, "border");
215
+ return props.checked ? props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check") : "transparent";
222
216
  }, function (props) {
223
217
  return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "background");
224
218
  }, function (props) {
225
- return props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
219
+ return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
226
220
  }, function (props) {
227
- return props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
221
+ return props.disabled && "pointer-events: none;";
222
+ });
223
+
224
+ var MainContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n gap: ", ";\n\n &:hover ", " {\n border: 2px solid\n ", ";\n background-color: ", ";\n color: ", ";\n }\n"])), function (props) {
225
+ return calculateWidth(props.margin, props.size);
228
226
  }, function (props) {
229
- return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
227
+ return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
230
228
  }, function (props) {
231
- return props.labelPosition === "before" && props.label ? props.theme.checkLabelSpacing : "0";
229
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
232
230
  }, function (props) {
233
- return props.labelPosition === "after" && props.label ? props.theme.checkLabelSpacing : "0";
231
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
234
232
  }, function (props) {
235
- return props.labelPosition === "before" ? "unset" : "1px";
233
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
236
234
  }, function (props) {
237
- return props.labelPosition === "before" ? "1px" : "unset";
238
- });
239
-
240
- var CheckboxBlackBack = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n width: 16px;\n height: 16px;\n position: absolute;\n left: ", ";\n right: ", ";\n z-index: 0;\n margin-left: ", ";\n margin-right: ", ";\n"])), function (props) {
241
- return !props.checked ? "transparent" : props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check");
235
+ return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
242
236
  }, function (props) {
243
- return props.labelPosition === "before" ? "unset" : "5px";
237
+ return props.disabled ? "not-allowed" : "pointer";
244
238
  }, function (props) {
245
- return props.labelPosition === "before" ? "5px" : "unset";
239
+ return props.theme.checkLabelSpacing;
240
+ }, Checkbox, function (props) {
241
+ return props.disabled ? getDisabledColor(props, "border") : getNotDisabledColor(props, "hoverBorder");
246
242
  }, function (props) {
247
- return props.labelPosition === "after" ? "0px" : "";
243
+ return props.checked ? props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check") : "transparent";
248
244
  }, function (props) {
249
- return props.labelPosition === "before" ? "0px" : "";
245
+ return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "hoverBackground");
250
246
  });
251
247
 
252
248
  var _default = DxcCheckbox;