@dxc-technology/halstack-react 9.1.0 → 10.1.0

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 (109) hide show
  1. package/HalstackContext.d.ts +11 -6
  2. package/HalstackContext.js +1 -1
  3. package/README.md +47 -0
  4. package/accordion/Accordion.d.ts +1 -1
  5. package/accordion/Accordion.js +2 -14
  6. package/accordion/Accordion.stories.tsx +2 -100
  7. package/accordion/types.d.ts +0 -12
  8. package/accordion-group/AccordionGroup.d.ts +4 -3
  9. package/accordion-group/AccordionGroup.js +21 -42
  10. package/accordion-group/AccordionGroup.stories.tsx +77 -76
  11. package/accordion-group/AccordionGroup.test.js +6 -16
  12. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  13. package/accordion-group/AccordionGroupAccordion.js +43 -0
  14. package/accordion-group/types.d.ts +0 -12
  15. package/alert/Alert.js +1 -3
  16. package/box/Box.d.ts +1 -1
  17. package/box/Box.js +5 -22
  18. package/box/Box.stories.tsx +25 -53
  19. package/box/types.d.ts +0 -12
  20. package/bulleted-list/BulletedList.js +4 -2
  21. package/bulleted-list/BulletedList.stories.tsx +7 -1
  22. package/bulleted-list/types.d.ts +31 -4
  23. package/button/Button.d.ts +1 -1
  24. package/button/Button.js +45 -54
  25. package/button/Button.stories.tsx +3 -3
  26. package/button/Button.test.js +11 -0
  27. package/button/types.d.ts +4 -0
  28. package/card/Card.d.ts +1 -1
  29. package/card/Card.js +18 -35
  30. package/card/Card.stories.tsx +0 -29
  31. package/card/types.d.ts +1 -7
  32. package/chip/Chip.js +23 -36
  33. package/chip/Chip.stories.tsx +25 -17
  34. package/common/OpenSans.css +68 -80
  35. package/common/coreTokens.d.ts +146 -0
  36. package/common/coreTokens.js +167 -0
  37. package/common/variables.d.ts +9 -144
  38. package/common/variables.js +960 -1095
  39. package/date-input/Calendar.js +2 -2
  40. package/dialog/Dialog.d.ts +1 -1
  41. package/dialog/Dialog.js +4 -22
  42. package/dialog/Dialog.stories.tsx +52 -176
  43. package/dialog/types.d.ts +0 -13
  44. package/dropdown/DropdownMenu.js +5 -1
  45. package/file-input/FileItem.js +2 -2
  46. package/file-input/types.d.ts +1 -1
  47. package/flex/Flex.js +4 -2
  48. package/flex/Flex.stories.tsx +24 -10
  49. package/flex/types.d.ts +70 -5
  50. package/footer/Footer.d.ts +1 -1
  51. package/footer/Footer.js +43 -61
  52. package/footer/Footer.stories.tsx +19 -95
  53. package/footer/Footer.test.js +3 -1
  54. package/footer/types.d.ts +10 -12
  55. package/grid/Grid.d.ts +1 -1
  56. package/grid/Grid.js +1 -1
  57. package/grid/Grid.stories.tsx +38 -38
  58. package/header/Header.d.ts +1 -1
  59. package/header/Header.js +3 -30
  60. package/header/Header.stories.tsx +7 -71
  61. package/header/types.d.ts +0 -14
  62. package/image/Image.d.ts +4 -0
  63. package/image/Image.js +85 -0
  64. package/image/Image.stories.tsx +127 -0
  65. package/image/types.d.ts +72 -0
  66. package/inset/Inset.stories.tsx +1 -1
  67. package/layout/ApplicationLayout.d.ts +2 -2
  68. package/layout/ApplicationLayout.js +14 -11
  69. package/layout/ApplicationLayout.stories.tsx +1 -1
  70. package/layout/Icons.d.ts +7 -4
  71. package/layout/Icons.js +52 -56
  72. package/link/Link.js +1 -1
  73. package/main.d.ts +2 -1
  74. package/main.js +8 -0
  75. package/nav-tabs/NavTabs.d.ts +2 -2
  76. package/nav-tabs/NavTabs.js +7 -10
  77. package/nav-tabs/NavTabs.stories.tsx +14 -0
  78. package/nav-tabs/Tab.js +22 -26
  79. package/nav-tabs/types.d.ts +8 -9
  80. package/number-input/NumberInput.d.ts +7 -0
  81. package/number-input/NumberInput.js +6 -4
  82. package/number-input/NumberInput.test.js +278 -95
  83. package/package.json +2 -2
  84. package/paginator/Paginator.js +1 -1
  85. package/paginator/Paginator.test.js +13 -0
  86. package/password-input/Icons.d.ts +6 -0
  87. package/password-input/Icons.js +39 -0
  88. package/password-input/PasswordInput.js +35 -82
  89. package/password-input/PasswordInput.stories.tsx +1 -0
  90. package/password-input/PasswordInput.test.js +27 -34
  91. package/radio-group/Radio.js +10 -10
  92. package/radio-group/RadioGroup.js +8 -10
  93. package/select/Select.stories.tsx +3 -3
  94. package/select/Select.test.js +4 -4
  95. package/sidenav/Sidenav.js +21 -23
  96. package/text-input/TextInput.js +62 -78
  97. package/text-input/TextInput.stories.tsx +1 -1
  98. package/toggle-group/ToggleGroup.d.ts +2 -2
  99. package/toggle-group/ToggleGroup.js +79 -56
  100. package/toggle-group/ToggleGroup.stories.tsx +6 -3
  101. package/toggle-group/ToggleGroup.test.js +37 -23
  102. package/toggle-group/types.d.ts +22 -13
  103. package/useTheme.d.ts +9 -1
  104. package/utils/FocusLock.js +2 -3
  105. package/card/ice-cream.jpg +0 -0
  106. package/number-input/NumberInputContext.d.ts +0 -4
  107. package/number-input/NumberInputContext.js +0 -19
  108. package/number-input/numberInputContextTypes.d.ts +0 -19
  109. /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
@@ -46,7 +46,7 @@ var DxcPaginator = function DxcPaginator(_ref) {
46
46
  itemsPerPageFunction = _ref.itemsPerPageFunction,
47
47
  _ref$tabIndex = _ref.tabIndex,
48
48
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
49
- var totalPages = Math.ceil(totalItems / itemsPerPage);
49
+ var totalPages = itemsPerPage > 0 && Math.ceil(totalItems / itemsPerPage);
50
50
  var currentPageInternal = currentPage === -1 ? totalPages : currentPage;
51
51
  var minItemsPerPage = currentPageInternal === 1 || currentPageInternal === 0 ? currentPageInternal : (currentPageInternal - 1) * itemsPerPage + 1;
52
52
  var maxItemsPerPage = minItemsPerPage - 1 + itemsPerPage > totalItems ? totalItems : minItemsPerPage - 1 + itemsPerPage;
@@ -302,4 +302,17 @@ describe("Paginator component tests", function () {
302
302
  expect(nextButton.hasAttribute("disabled")).toBeFalsy();
303
303
  expect(lastButton.hasAttribute("disabled")).toBeFalsy();
304
304
  });
305
+ test("itemsPerPage is 0 and showGoToPage is true", function () {
306
+ var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
307
+ itemsPerPage: 0,
308
+ itemsPerPageOptions: [5, 10, 15],
309
+ totalItems: 27,
310
+ showGoToPage: true
311
+ })),
312
+ getByText = _render16.getByText,
313
+ getAllByRole = _render16.getAllByRole;
314
+
315
+ expect(getByText("Items per page:")).toBeTruthy();
316
+ expect(getAllByRole("combobox")).toBeTruthy();
317
+ });
305
318
  });
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare const icons: {
3
+ showPassword: JSX.Element;
4
+ hidePassword: JSX.Element;
5
+ };
6
+ export default icons;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var icons = {
13
+ showPassword: /*#__PURE__*/_react["default"].createElement("svg", {
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ height: "24px",
16
+ viewBox: "0 0 24 24",
17
+ width: "24px",
18
+ fill: "currentColor"
19
+ }, /*#__PURE__*/_react["default"].createElement("path", {
20
+ d: "M0 0h24v24H0V0z",
21
+ fill: "none"
22
+ }), /*#__PURE__*/_react["default"].createElement("path", {
23
+ d: "M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z"
24
+ })),
25
+ hidePassword: /*#__PURE__*/_react["default"].createElement("svg", {
26
+ xmlns: "http://www.w3.org/2000/svg",
27
+ height: "24px",
28
+ viewBox: "0 0 24 24",
29
+ width: "24px",
30
+ fill: "currentColor"
31
+ }, /*#__PURE__*/_react["default"].createElement("path", {
32
+ d: "M0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0z",
33
+ fill: "none"
34
+ }), /*#__PURE__*/_react["default"].createElement("path", {
35
+ d: "M12 6c3.79 0 7.17 2.13 8.82 5.5-.59 1.22-1.42 2.27-2.41 3.12l1.41 1.41c1.39-1.23 2.49-2.77 3.18-4.53C21.27 7.11 17 4 12 4c-1.27 0-2.49.2-3.64.57l1.65 1.65C10.66 6.09 11.32 6 12 6zm-1.07 1.14L13 9.21c.57.25 1.03.71 1.28 1.28l2.07 2.07c.08-.34.14-.7.14-1.07C16.5 9.01 14.48 7 12 7c-.37 0-.72.05-1.07.14zM2.01 3.87l2.68 2.68C3.06 7.83 1.77 9.53 1 11.5 2.73 15.89 7 19 12 19c1.52 0 2.98-.29 4.32-.82l3.42 3.42 1.41-1.41L3.42 2.45 2.01 3.87zm7.5 7.5l2.61 2.61c-.04.01-.08.02-.12.02-1.38 0-2.5-1.12-2.5-2.5 0-.05.01-.08.01-.13zm-3.4-3.4l1.75 1.75c-.23.55-.36 1.15-.36 1.78 0 2.48 2.02 4.5 4.5 4.5.63 0 1.23-.13 1.77-.36l.98.98c-.88.24-1.8.38-2.75.38-3.79 0-7.17-2.13-8.82-5.5.7-1.43 1.72-2.61 2.93-3.53z"
36
+ }))
37
+ };
38
+ var _default = icons;
39
+ exports["default"] = _default;
@@ -19,7 +19,9 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
19
19
 
20
20
  var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
21
21
 
22
- var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
22
+ var _useTranslatedLabels2 = _interopRequireDefault(require("../useTranslatedLabels"));
23
+
24
+ var _Icons = _interopRequireDefault(require("./Icons"));
23
25
 
24
26
  var _templateObject;
25
27
 
@@ -27,6 +29,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
27
29
 
28
30
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
29
31
 
32
+ var setInputType = function setInputType(type, element) {
33
+ element === null || element === void 0 ? void 0 : element.getElementsByTagName("input")[0].setAttribute("type", type);
34
+ };
35
+
36
+ var setAriaAttributes = function setAriaAttributes(ariaExpanded, ariaLabel, element) {
37
+ var inputElement = element === null || element === void 0 ? void 0 : element.getElementsByTagName("input")[0];
38
+ inputElement === null || inputElement === void 0 ? void 0 : inputElement.setAttribute("aria-expanded", ariaExpanded);
39
+ inputElement === null || inputElement === void 0 ? void 0 : inputElement.setAttribute("aria-label", ariaLabel);
40
+ };
41
+
30
42
  var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
31
43
  var label = _ref.label,
32
44
  _ref$name = _ref.name,
@@ -55,97 +67,37 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
55
67
  setIsPasswordVisible = _useState2[1];
56
68
 
57
69
  var inputRef = (0, _react.useRef)(null);
58
- var translatedLabels = (0, _useTranslatedLabels["default"])();
59
-
60
- var setInputType = function setInputType(type) {
61
- var _inputRef$current, _inputRef$current$chi;
62
-
63
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : (_inputRef$current$chi = _inputRef$current.children[label && helperText ? 2 : label || helperText ? 1 : 0]) === null || _inputRef$current$chi === void 0 ? void 0 : _inputRef$current$chi.children[0].setAttribute("type", type);
64
- };
65
-
66
- var setAriaAttributes = function setAriaAttributes(ariaExpanded, ariaLabel) {
67
- var inputIndex = label && helperText ? 2 : label || helperText ? 1 : 0;
68
70
 
69
- if (error && clearable && value) {
70
- var _inputRef$current2, _inputRef$current2$ch, _inputRef$current2$ch2, _inputRef$current3, _inputRef$current3$ch, _inputRef$current3$ch2;
71
-
72
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : (_inputRef$current2$ch = _inputRef$current2.children[inputIndex]) === null || _inputRef$current2$ch === void 0 ? void 0 : (_inputRef$current2$ch2 = _inputRef$current2$ch.children[3]) === null || _inputRef$current2$ch2 === void 0 ? void 0 : _inputRef$current2$ch2.setAttribute("aria-expanded", ariaExpanded);
73
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : (_inputRef$current3$ch = _inputRef$current3.children[inputIndex]) === null || _inputRef$current3$ch === void 0 ? void 0 : (_inputRef$current3$ch2 = _inputRef$current3$ch.children[3]) === null || _inputRef$current3$ch2 === void 0 ? void 0 : _inputRef$current3$ch2.setAttribute("aria-label", ariaLabel);
74
- } else if (error || clearable && !value) {
75
- var _inputRef$current4, _inputRef$current4$ch, _inputRef$current4$ch2, _inputRef$current5, _inputRef$current5$ch, _inputRef$current5$ch2;
76
-
77
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : (_inputRef$current4$ch = _inputRef$current4.children[inputIndex]) === null || _inputRef$current4$ch === void 0 ? void 0 : (_inputRef$current4$ch2 = _inputRef$current4$ch.children[2]) === null || _inputRef$current4$ch2 === void 0 ? void 0 : _inputRef$current4$ch2.setAttribute("aria-expanded", ariaExpanded);
78
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : (_inputRef$current5$ch = _inputRef$current5.children[inputIndex]) === null || _inputRef$current5$ch === void 0 ? void 0 : (_inputRef$current5$ch2 = _inputRef$current5$ch.children[2]) === null || _inputRef$current5$ch2 === void 0 ? void 0 : _inputRef$current5$ch2.setAttribute("aria-label", ariaLabel);
79
- } else {
80
- var _inputRef$current6, _inputRef$current6$ch, _inputRef$current6$ch2, _inputRef$current7, _inputRef$current7$ch, _inputRef$current7$ch2;
81
-
82
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : (_inputRef$current6$ch = _inputRef$current6.children[inputIndex]) === null || _inputRef$current6$ch === void 0 ? void 0 : (_inputRef$current6$ch2 = _inputRef$current6$ch.children[1]) === null || _inputRef$current6$ch2 === void 0 ? void 0 : _inputRef$current6$ch2.setAttribute("aria-expanded", ariaExpanded);
83
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : (_inputRef$current7$ch = _inputRef$current7.children[inputIndex]) === null || _inputRef$current7$ch === void 0 ? void 0 : (_inputRef$current7$ch2 = _inputRef$current7$ch.children[1]) === null || _inputRef$current7$ch2 === void 0 ? void 0 : _inputRef$current7$ch2.setAttribute("aria-label", ariaLabel);
84
- }
85
- };
86
-
87
- var getIconTitle = function getIconTitle() {
88
- return isPasswordVisible ? translatedLabels.passwordInput.inputHidePasswordTitle : translatedLabels.passwordInput.inputShowPasswordTitle;
89
- };
71
+ var _useTranslatedLabels = (0, _useTranslatedLabels2["default"])(),
72
+ passwordInput = _useTranslatedLabels.passwordInput;
90
73
 
91
74
  (0, _react.useEffect)(function () {
92
- setAriaAttributes(false, translatedLabels.passwordInput.inputShowPasswordTitle);
93
-
94
- if (isPasswordVisible) {
95
- setInputType("text");
96
- setAriaAttributes(true, translatedLabels.passwordInput.inputHidePasswordTitle);
97
- } else {
98
- setInputType("password");
99
- setAriaAttributes(false, translatedLabels.passwordInput.inputShowPasswordTitle);
100
- }
101
- }, [isPasswordVisible]);
102
-
103
- var viewPassword = function viewPassword() {
104
- setInputType("text");
105
- setIsPasswordVisible(true);
106
- };
107
-
108
- var hidePassword = function hidePassword() {
109
- setInputType("password");
110
- setIsPasswordVisible(false);
111
- };
112
-
113
- var action = {
114
- onClick: isPasswordVisible ? hidePassword : viewPassword,
115
- icon: isPasswordVisible ? /*#__PURE__*/_react["default"].createElement("svg", {
116
- xmlns: "http://www.w3.org/2000/svg",
117
- height: "24px",
118
- viewBox: "0 0 24 24",
119
- width: "24px",
120
- fill: "currentColor"
121
- }, /*#__PURE__*/_react["default"].createElement("path", {
122
- d: "M0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0z",
123
- fill: "none"
124
- }), /*#__PURE__*/_react["default"].createElement("path", {
125
- d: "M12 6c3.79 0 7.17 2.13 8.82 5.5-.59 1.22-1.42 2.27-2.41 3.12l1.41 1.41c1.39-1.23 2.49-2.77 3.18-4.53C21.27 7.11 17 4 12 4c-1.27 0-2.49.2-3.64.57l1.65 1.65C10.66 6.09 11.32 6 12 6zm-1.07 1.14L13 9.21c.57.25 1.03.71 1.28 1.28l2.07 2.07c.08-.34.14-.7.14-1.07C16.5 9.01 14.48 7 12 7c-.37 0-.72.05-1.07.14zM2.01 3.87l2.68 2.68C3.06 7.83 1.77 9.53 1 11.5 2.73 15.89 7 19 12 19c1.52 0 2.98-.29 4.32-.82l3.42 3.42 1.41-1.41L3.42 2.45 2.01 3.87zm7.5 7.5l2.61 2.61c-.04.01-.08.02-.12.02-1.38 0-2.5-1.12-2.5-2.5 0-.05.01-.08.01-.13zm-3.4-3.4l1.75 1.75c-.23.55-.36 1.15-.36 1.78 0 2.48 2.02 4.5 4.5 4.5.63 0 1.23-.13 1.77-.36l.98.98c-.88.24-1.8.38-2.75.38-3.79 0-7.17-2.13-8.82-5.5.7-1.43 1.72-2.61 2.93-3.53z"
126
- })) : /*#__PURE__*/_react["default"].createElement("svg", {
127
- xmlns: "http://www.w3.org/2000/svg",
128
- height: "24px",
129
- viewBox: "0 0 24 24",
130
- width: "24px",
131
- fill: "currentColor"
132
- }, /*#__PURE__*/_react["default"].createElement("path", {
133
- d: "M0 0h24v24H0V0z",
134
- fill: "none"
135
- }), /*#__PURE__*/_react["default"].createElement("path", {
136
- d: "M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z"
137
- })),
138
- title: getIconTitle()
139
- };
75
+ (function () {
76
+ if (isPasswordVisible) {
77
+ setInputType("text", inputRef.current);
78
+ setAriaAttributes("true", passwordInput.inputHidePasswordTitle, inputRef.current);
79
+ } else {
80
+ setInputType("password", inputRef.current);
81
+ setAriaAttributes("false", passwordInput.inputShowPasswordTitle, inputRef.current);
82
+ }
83
+ })();
84
+ }, [isPasswordVisible, passwordInput]);
140
85
  return /*#__PURE__*/_react["default"].createElement(PasswordInput, {
141
86
  ref: ref
142
87
  }, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
143
- ref: inputRef,
144
88
  label: label,
145
89
  name: name,
146
90
  value: value,
147
91
  helperText: helperText,
148
- action: action,
92
+ action: {
93
+ onClick: function onClick() {
94
+ setIsPasswordVisible(function (isPasswordVisible) {
95
+ return !isPasswordVisible;
96
+ });
97
+ },
98
+ icon: isPasswordVisible ? _Icons["default"].hidePassword : _Icons["default"].showPassword,
99
+ title: isPasswordVisible ? passwordInput.inputHidePasswordTitle : passwordInput.inputShowPasswordTitle
100
+ },
149
101
  error: error,
150
102
  clearable: clearable,
151
103
  onChange: onChange,
@@ -156,6 +108,7 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
156
108
  minLength: minLength,
157
109
  maxLength: maxLength,
158
110
  autocomplete: autocomplete,
111
+ ref: inputRef,
159
112
  tabIndex: tabIndex
160
113
  }));
161
114
  });
@@ -105,6 +105,7 @@ const Password = () => (
105
105
  <DxcPasswordInput label="Password input" value="Password" />
106
106
  </ExampleContainer>
107
107
  );
108
+
108
109
  const PasswordDark = () => (
109
110
  <BackgroundColorProvider color="#333333">
110
111
  <DarkContainer>
@@ -15,38 +15,32 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
15
15
  var _PasswordInput = _interopRequireDefault(require("./PasswordInput.tsx"));
16
16
 
17
17
  describe("Password input component tests", function () {
18
- test("Password input renders with label", function () {
18
+ test("Password input renders with label and helper text", function () {
19
19
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
20
- label: "Password input label"
20
+ label: "Password input label",
21
+ helperText: "Helper text"
21
22
  })),
22
23
  getByText = _render.getByText;
23
24
 
24
25
  expect(getByText("Password input label")).toBeTruthy();
25
- });
26
- test("Password input renders with helper text", function () {
27
- var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
28
- helperText: "Helper text"
29
- })),
30
- getByText = _render2.getByText;
31
-
32
26
  expect(getByText("Helper text")).toBeTruthy();
33
27
  });
34
28
  test("Password input renders error", function () {
35
- var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
29
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
36
30
  error: "Error message."
37
31
  })),
38
- getByText = _render3.getByText;
32
+ getByText = _render2.getByText;
39
33
 
40
34
  expect(getByText("Error message.")).toBeTruthy();
41
35
  });
42
36
  test("onChange function is called correctly", function () {
43
37
  var onChange = jest.fn();
44
38
 
45
- var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
39
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
46
40
  label: "Password input",
47
41
  onChange: onChange
48
42
  })),
49
- getByLabelText = _render4.getByLabelText;
43
+ getByLabelText = _render3.getByLabelText;
50
44
 
51
45
  var passwordInput = getByLabelText("Password input");
52
46
 
@@ -60,11 +54,11 @@ describe("Password input component tests", function () {
60
54
  test("onBlur function is called correctly", function () {
61
55
  var onBlur = jest.fn();
62
56
 
63
- var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
57
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
64
58
  label: "Password input",
65
59
  onBlur: onBlur
66
60
  })),
67
- getByLabelText = _render5.getByLabelText;
61
+ getByLabelText = _render4.getByLabelText;
68
62
 
69
63
  var passwordInput = getByLabelText("Password input");
70
64
 
@@ -78,12 +72,12 @@ describe("Password input component tests", function () {
78
72
  expect(passwordInput.value).toBe("Pa$$w0rd");
79
73
  });
80
74
  test("Clear password input value", function () {
81
- var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
75
+ var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
82
76
  label: "Password input",
83
77
  clearable: true
84
78
  })),
85
- getAllByRole = _render6.getAllByRole,
86
- getByLabelText = _render6.getByLabelText;
79
+ getAllByRole = _render5.getAllByRole,
80
+ getByLabelText = _render5.getByLabelText;
87
81
 
88
82
  var passwordInput = getByLabelText("Password input");
89
83
 
@@ -97,11 +91,11 @@ describe("Password input component tests", function () {
97
91
  expect(passwordInput.value).toBe("");
98
92
  });
99
93
  test("Non clearable password input has no clear icon", function () {
100
- var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
94
+ var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
101
95
  label: "Password input"
102
96
  })),
103
- getAllByRole = _render7.getAllByRole,
104
- getByLabelText = _render7.getByLabelText;
97
+ getAllByRole = _render6.getAllByRole,
98
+ getByLabelText = _render6.getByLabelText;
105
99
 
106
100
  var passwordInput = getByLabelText("Password input");
107
101
 
@@ -112,12 +106,12 @@ describe("Password input component tests", function () {
112
106
  expect(buttons.length).toBe(1);
113
107
  });
114
108
  test("Show/hide password input button works correctly", function () {
115
- var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
109
+ var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
116
110
  label: "Password input",
117
111
  clearable: true
118
112
  })),
119
- getAllByRole = _render8.getAllByRole,
120
- getByLabelText = _render8.getByLabelText;
113
+ getAllByRole = _render7.getAllByRole,
114
+ getByLabelText = _render7.getByLabelText;
121
115
 
122
116
  var passwordInput = getByLabelText("Password input");
123
117
 
@@ -132,17 +126,17 @@ describe("Password input component tests", function () {
132
126
  expect(passwordInput.type).toBe("text");
133
127
  });
134
128
  test("Password tooltip is correct", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
135
- var _render9, getAllByRole, getByTitle, queryByTitle, showButton;
129
+ var _render8, getAllByRole, getByTitle, queryByTitle, showButton;
136
130
 
137
131
  return _regenerator["default"].wrap(function _callee$(_context) {
138
132
  while (1) {
139
133
  switch (_context.prev = _context.next) {
140
134
  case 0:
141
- _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
135
+ _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
142
136
  label: "Password input",
143
137
  clearable: true,
144
138
  value: "Password"
145
- })), getAllByRole = _render9.getAllByRole, getByTitle = _render9.getByTitle, queryByTitle = _render9.queryByTitle;
139
+ })), getAllByRole = _render8.getAllByRole, getByTitle = _render8.getByTitle, queryByTitle = _render8.queryByTitle;
146
140
  showButton = getAllByRole("button")[1];
147
141
 
148
142
  _userEvent["default"].hover(showButton);
@@ -160,22 +154,21 @@ describe("Password input component tests", function () {
160
154
  }
161
155
  }, _callee);
162
156
  })));
163
- test("Password input has correct accesibility attributes", function () {
164
- var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
157
+ test("Password input has correct accessibility attributes", function () {
158
+ var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
165
159
  label: "Password input"
166
160
  })),
167
- getByRole = _render10.getByRole,
168
- getByLabelText = _render10.getByLabelText;
161
+ getByRole = _render9.getByRole,
162
+ getByLabelText = _render9.getByLabelText;
169
163
 
170
164
  var passwordInput = getByLabelText("Password input");
171
- expect(passwordInput.getAttribute("aria-autocomplete")).toBeNull();
172
- expect(passwordInput.getAttribute("aria-controls")).toBeNull();
173
- expect(passwordInput.getAttribute("aria-expanded")).toBeNull();
174
165
  var showButton = getByRole("button");
166
+ expect(passwordInput.getAttribute("aria-expanded")).toBe("false");
175
167
  expect(showButton.getAttribute("aria-label")).toBe("Show password");
176
168
 
177
169
  _userEvent["default"].click(showButton);
178
170
 
171
+ expect(passwordInput.getAttribute("aria-expanded")).toBe("true");
179
172
  expect(showButton.getAttribute("aria-label")).toBe("Hide password");
180
173
  });
181
174
  });
@@ -21,7 +21,9 @@ var _uuid = require("uuid");
21
21
 
22
22
  var _useTheme = _interopRequireDefault(require("../useTheme"));
23
23
 
24
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
24
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
25
+
26
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
25
27
 
26
28
  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); }
27
29
 
@@ -56,7 +58,7 @@ var DxcRadio = function DxcRadio(_ref) {
56
58
  firstUpdate = _useState4[0],
57
59
  setFirstUpdate = _useState4[1];
58
60
 
59
- (0, _react.useLayoutEffect)(function () {
61
+ (0, _react.useEffect)(function () {
60
62
  var _ref$current2;
61
63
 
62
64
  // Don't apply in the first render
@@ -69,7 +71,7 @@ var DxcRadio = function DxcRadio(_ref) {
69
71
  }, [focused]);
70
72
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
71
73
  theme: colorsTheme.radioGroup
72
- }, /*#__PURE__*/_react["default"].createElement(RadioMainContainer, null, /*#__PURE__*/_react["default"].createElement(RadioContainer, {
74
+ }, /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, /*#__PURE__*/_react["default"].createElement(RadioContainer, {
73
75
  error: error,
74
76
  disabled: disabled,
75
77
  readonly: readonly,
@@ -107,11 +109,9 @@ var getRadioInputStateColor = function getRadioInputStateColor(props, state) {
107
109
  }
108
110
  };
109
111
 
110
- var RadioMainContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n"])));
111
-
112
- var RadioInputContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
112
+ var RadioInputContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
113
113
 
114
- var RadioInput = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n border: 2px solid ", ";\n border-radius: 50%;\n\n &:focus {\n outline: 2px solid ", ";\n outline-offset: 1px;\n }\n ", "\n"])), function (props) {
114
+ var RadioInput = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n border: 2px solid ", ";\n border-radius: 50%;\n\n &:focus {\n outline: 2px solid ", ";\n outline-offset: 1px;\n }\n ", "\n"])), function (props) {
115
115
  return getRadioInputStateColor(props, "enabled");
116
116
  }, function (props) {
117
117
  return props.theme.focusBorderColor;
@@ -119,11 +119,11 @@ var RadioInput = _styledComponents["default"].span(_templateObject3 || (_templat
119
119
  return props.disabled && "pointer-events: none;";
120
120
  });
121
121
 
122
- var Dot = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background-color: ", ";\n"])), function (props) {
122
+ var Dot = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: 10px;\n width: 10px;\n border-radius: 50%;\n background-color: ", ";\n"])), function (props) {
123
123
  return getRadioInputStateColor(props, "enabled");
124
124
  });
125
125
 
126
- var Label = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
126
+ var Label = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
127
127
  return props.theme.radioInputLabelMargin;
128
128
  }, function (props) {
129
129
  return props.theme.fontFamily;
@@ -139,7 +139,7 @@ var Label = _styledComponents["default"].span(_templateObject5 || (_templateObje
139
139
  return props.disabled ? "color: ".concat(props.theme.disabledRadioInputLabelFontColor, ";") : "color: ".concat(props.theme.radioInputLabelFontColor);
140
140
  });
141
141
 
142
- var RadioContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n\n &:hover {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n &:active {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n"])), function (props) {
142
+ var RadioContainer = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n\n &:hover {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n &:active {\n ", " {\n border-color: ", ";\n }\n ", " {\n background-color: ", ";\n }\n }\n"])), function (props) {
143
143
  return props.disabled ? "not-allowed" : props.readonly ? "default" : "pointer";
144
144
  }, RadioInput, function (props) {
145
145
  return !props.disabled && getRadioInputStateColor(props, "hover");
@@ -83,14 +83,13 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
83
83
 
84
84
  var colorsTheme = (0, _useTheme["default"])();
85
85
  var translatedLabels = (0, _useTranslatedLabels["default"])();
86
- var optionalItem = {
87
- label: optionalItemLabel || translatedLabels.radioGroup.optionalItemLabelDefault,
88
- value: "",
89
- disabled: disabled
90
- };
91
86
  var innerOptions = (0, _react.useMemo)(function () {
92
- return optional ? [].concat((0, _toConsumableArray2["default"])(options), [optionalItem]) : options;
93
- }, [optional, options]);
87
+ return optional ? [].concat((0, _toConsumableArray2["default"])(options), [{
88
+ label: optionalItemLabel !== null && optionalItemLabel !== void 0 ? optionalItemLabel : translatedLabels.radioGroup.optionalItemLabelDefault,
89
+ value: "",
90
+ disabled: disabled
91
+ }]) : options;
92
+ }, [optional, options, optionalItemLabel, translatedLabels]);
94
93
 
95
94
  var _useState7 = (0, _react.useState)(getInitialFocusIndex(innerOptions, value !== null && value !== void 0 ? value : innerValue)),
96
95
  _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
@@ -202,8 +201,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
202
201
  name: name,
203
202
  disabled: disabled,
204
203
  value: (_ref2 = value !== null && value !== void 0 ? value : innerValue) !== null && _ref2 !== void 0 ? _ref2 : "",
205
- readOnly: true,
206
- "aria-hidden": "true"
204
+ readOnly: true
207
205
  }), innerOptions.map(function (option, index) {
208
206
  return /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
209
207
  key: "radio-".concat(index),
@@ -225,7 +223,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
225
223
  }, error)));
226
224
  });
227
225
 
228
- var RadioGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n box-sizing: border-box;\n"])));
226
+ var RadioGroupContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n flex-direction: column;\n"])));
229
227
 
230
228
  var Label = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n ", "\n"])), function (props) {
231
229
  return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
@@ -188,9 +188,9 @@ const url_options = [
188
188
  icon: "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Instagram_logo_2016.svg/800px-Instagram_logo_2016.svg.png",
189
189
  },
190
190
  {
191
- label: "Twitter",
192
- value: "twitter",
193
- icon: "https://cdn.computerhoy.com/sites/navi.axelspringer.es/public/styles/480/public/media/image/2013/08/17981-logo-twitter.png?itok=dElA6iAV",
191
+ label: "X",
192
+ value: "x",
193
+ icon: "https://static.dezeen.com/uploads/2023/07/x-logo-twitter-elon-musk_dezeen_2364_col_0.jpg",
194
194
  },
195
195
  {
196
196
  label: "Facebook",
@@ -177,9 +177,9 @@ var urlIconOptions = [{
177
177
  value: "1",
178
178
  icon: "https://cdn.icon-icons.com/icons2/2518/PNG/512/brand_instagram_icon_151534.png"
179
179
  }, {
180
- label: "Twitter",
180
+ label: "X",
181
181
  value: "2",
182
- icon: "https://cdn-icons-png.flaticon.com/512/81/81609.png"
182
+ icon: "https://static.dezeen.com/uploads/2023/07/x-logo-twitter-elon-musk_dezeen_2364_col_0.jpg"
183
183
  }, {
184
184
  label: "Snapchat",
185
185
  value: "3"
@@ -263,9 +263,9 @@ var groupedIconOptions = [{
263
263
  value: "1",
264
264
  icon: "https://cdn.icon-icons.com/icons2/2518/PNG/512/brand_instagram_icon_151534.png"
265
265
  }, {
266
- label: "Twitter",
266
+ label: "X",
267
267
  value: "2",
268
- icon: "https://cdn-icons-png.flaticon.com/512/81/81609.png"
268
+ icon: "https://static.dezeen.com/uploads/2023/07/x-logo-twitter-elon-musk_dezeen_2364_col_0.jpg"
269
269
  }, {
270
270
  label: "Facebook",
271
271
  value: "3",