@dxc-technology/halstack-react 0.0.0-a7970fd → 0.0.0-a7fec42

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 (196) hide show
  1. package/HalstackContext.d.ts +4 -2
  2. package/HalstackContext.js +110 -58
  3. package/accordion/Accordion.js +122 -103
  4. package/accordion/Accordion.stories.tsx +2 -3
  5. package/accordion/Accordion.test.js +9 -10
  6. package/accordion/types.d.ts +5 -4
  7. package/accordion-group/AccordionGroup.js +2 -21
  8. package/accordion-group/AccordionGroup.stories.tsx +27 -1
  9. package/accordion-group/AccordionGroup.test.js +20 -45
  10. package/accordion-group/types.d.ts +10 -3
  11. package/alert/Alert.js +5 -2
  12. package/badge/Badge.d.ts +1 -1
  13. package/badge/Badge.js +5 -3
  14. package/badge/types.d.ts +1 -0
  15. package/bleed/Bleed.js +1 -34
  16. package/bleed/Bleed.stories.tsx +94 -95
  17. package/bleed/types.d.ts +1 -1
  18. package/box/Box.js +23 -33
  19. package/box/types.d.ts +1 -0
  20. package/bulleted-list/BulletedList.d.ts +7 -0
  21. package/bulleted-list/BulletedList.js +123 -0
  22. package/bulleted-list/BulletedList.stories.tsx +200 -0
  23. package/bulleted-list/types.d.ts +11 -0
  24. package/{list → bulleted-list}/types.js +0 -0
  25. package/button/Button.js +43 -61
  26. package/button/Button.stories.tsx +9 -0
  27. package/button/types.d.ts +7 -7
  28. package/card/Card.js +34 -36
  29. package/card/types.d.ts +1 -0
  30. package/checkbox/Checkbox.js +90 -95
  31. package/checkbox/Checkbox.test.js +93 -16
  32. package/checkbox/types.d.ts +2 -2
  33. package/chip/types.d.ts +1 -1
  34. package/common/variables.js +232 -96
  35. package/date-input/DateInput.js +8 -5
  36. package/dialog/Dialog.js +52 -28
  37. package/dialog/Dialog.stories.tsx +57 -2
  38. package/dialog/Dialog.test.js +34 -4
  39. package/dialog/types.d.ts +3 -2
  40. package/dropdown/Dropdown.d.ts +1 -1
  41. package/dropdown/Dropdown.js +244 -247
  42. package/dropdown/Dropdown.stories.tsx +126 -63
  43. package/dropdown/Dropdown.test.js +509 -108
  44. package/dropdown/DropdownMenu.d.ts +4 -0
  45. package/dropdown/DropdownMenu.js +80 -0
  46. package/dropdown/DropdownMenuItem.d.ts +4 -0
  47. package/dropdown/DropdownMenuItem.js +92 -0
  48. package/dropdown/types.d.ts +25 -5
  49. package/file-input/FileInput.js +9 -6
  50. package/file-input/FileItem.js +7 -5
  51. package/flex/Flex.d.ts +4 -0
  52. package/flex/Flex.js +69 -0
  53. package/flex/Flex.stories.tsx +103 -0
  54. package/flex/types.d.ts +32 -0
  55. package/{quick-nav-container → flex}/types.js +0 -0
  56. package/footer/Footer.js +7 -5
  57. package/footer/Footer.stories.tsx +8 -1
  58. package/footer/Icons.js +1 -1
  59. package/footer/types.d.ts +2 -1
  60. package/header/Header.js +80 -75
  61. package/header/Header.stories.tsx +4 -4
  62. package/header/Icons.js +2 -2
  63. package/header/types.d.ts +3 -2
  64. package/inset/Inset.js +1 -34
  65. package/inset/Inset.stories.tsx +36 -36
  66. package/inset/types.d.ts +1 -1
  67. package/layout/ApplicationLayout.d.ts +16 -6
  68. package/layout/ApplicationLayout.js +70 -117
  69. package/layout/ApplicationLayout.stories.tsx +84 -93
  70. package/layout/Icons.d.ts +5 -0
  71. package/layout/Icons.js +13 -2
  72. package/layout/SidenavContext.d.ts +5 -0
  73. package/layout/SidenavContext.js +19 -0
  74. package/layout/types.d.ts +18 -33
  75. package/link/Link.d.ts +3 -2
  76. package/link/Link.js +57 -70
  77. package/link/Link.stories.tsx +95 -53
  78. package/link/Link.test.js +7 -15
  79. package/link/types.d.ts +7 -23
  80. package/main.d.ts +8 -11
  81. package/main.js +40 -58
  82. package/number-input/NumberInput.test.js +1 -1
  83. package/number-input/types.d.ts +1 -1
  84. package/package.json +10 -9
  85. package/paginator/Paginator.js +17 -38
  86. package/paginator/Paginator.test.js +42 -0
  87. package/paragraph/Paragraph.d.ts +6 -0
  88. package/paragraph/Paragraph.js +38 -0
  89. package/paragraph/Paragraph.stories.tsx +44 -0
  90. package/password-input/PasswordInput.js +11 -6
  91. package/password-input/PasswordInput.test.js +14 -14
  92. package/password-input/types.d.ts +1 -1
  93. package/progress-bar/ProgressBar.d.ts +2 -2
  94. package/progress-bar/ProgressBar.js +57 -51
  95. package/progress-bar/ProgressBar.stories.jsx +13 -11
  96. package/progress-bar/ProgressBar.test.js +67 -22
  97. package/progress-bar/types.d.ts +3 -4
  98. package/quick-nav/QuickNav.js +75 -22
  99. package/quick-nav/QuickNav.stories.tsx +131 -26
  100. package/quick-nav/types.d.ts +1 -1
  101. package/radio-group/Radio.d.ts +1 -1
  102. package/radio-group/Radio.js +43 -28
  103. package/radio-group/RadioGroup.js +30 -27
  104. package/radio-group/RadioGroup.stories.tsx +1 -0
  105. package/radio-group/RadioGroup.test.js +123 -96
  106. package/radio-group/types.d.ts +2 -2
  107. package/resultsetTable/ResultsetTable.test.js +42 -0
  108. package/select/Listbox.d.ts +1 -1
  109. package/select/Listbox.js +58 -8
  110. package/select/Select.js +80 -90
  111. package/select/Select.stories.tsx +145 -100
  112. package/select/Select.test.js +425 -249
  113. package/select/types.d.ts +2 -5
  114. package/sidenav/Sidenav.d.ts +6 -5
  115. package/sidenav/Sidenav.js +184 -52
  116. package/sidenav/Sidenav.stories.tsx +154 -156
  117. package/sidenav/Sidenav.test.js +25 -37
  118. package/sidenav/types.d.ts +50 -27
  119. package/slider/Slider.js +116 -92
  120. package/slider/Slider.stories.tsx +7 -1
  121. package/slider/Slider.test.js +121 -21
  122. package/slider/types.d.ts +2 -2
  123. package/spinner/Spinner.js +1 -1
  124. package/switch/Switch.d.ts +1 -1
  125. package/switch/Switch.js +135 -66
  126. package/switch/Switch.stories.tsx +8 -30
  127. package/switch/Switch.test.js +144 -17
  128. package/switch/types.d.ts +3 -4
  129. package/table/Table.js +1 -1
  130. package/tabs/Tab.d.ts +4 -0
  131. package/tabs/Tab.js +135 -0
  132. package/tabs/Tabs.js +360 -104
  133. package/tabs/Tabs.stories.tsx +74 -0
  134. package/tabs/Tabs.test.js +217 -6
  135. package/tabs/types.d.ts +15 -5
  136. package/tabs-nav/NavTabs.d.ts +8 -0
  137. package/tabs-nav/NavTabs.js +125 -0
  138. package/tabs-nav/NavTabs.stories.tsx +170 -0
  139. package/tabs-nav/NavTabs.test.js +82 -0
  140. package/tabs-nav/Tab.d.ts +4 -0
  141. package/tabs-nav/Tab.js +130 -0
  142. package/tabs-nav/types.d.ts +53 -0
  143. package/{radio → tabs-nav}/types.js +0 -0
  144. package/tag/Tag.js +1 -1
  145. package/tag/types.d.ts +1 -1
  146. package/text-input/Icons.d.ts +8 -0
  147. package/text-input/Icons.js +60 -0
  148. package/text-input/Suggestion.d.ts +4 -0
  149. package/text-input/Suggestion.js +57 -0
  150. package/text-input/Suggestions.d.ts +4 -0
  151. package/text-input/Suggestions.js +134 -0
  152. package/text-input/TextInput.js +206 -329
  153. package/text-input/TextInput.stories.tsx +189 -182
  154. package/text-input/TextInput.test.js +166 -164
  155. package/text-input/types.d.ts +35 -4
  156. package/textarea/Textarea.js +10 -19
  157. package/textarea/types.d.ts +1 -1
  158. package/toggle-group/types.d.ts +1 -1
  159. package/typography/Typography.d.ts +4 -0
  160. package/typography/Typography.js +131 -0
  161. package/typography/Typography.stories.tsx +198 -0
  162. package/typography/types.d.ts +18 -0
  163. package/{row → typography}/types.js +0 -0
  164. package/useTranslatedLabels.d.ts +2 -0
  165. package/useTranslatedLabels.js +20 -0
  166. package/wizard/Wizard.js +36 -41
  167. package/wizard/Wizard.stories.tsx +20 -1
  168. package/wizard/types.d.ts +5 -4
  169. package/list/List.d.ts +0 -4
  170. package/list/List.js +0 -47
  171. package/list/List.stories.tsx +0 -95
  172. package/list/types.d.ts +0 -7
  173. package/quick-nav-container/HeadingLink.d.ts +0 -8
  174. package/quick-nav-container/HeadingLink.js +0 -58
  175. package/quick-nav-container/QuickNavContainer.d.ts +0 -4
  176. package/quick-nav-container/QuickNavContainer.js +0 -69
  177. package/quick-nav-container/Section.d.ts +0 -9
  178. package/quick-nav-container/Section.js +0 -37
  179. package/quick-nav-container/types.d.ts +0 -34
  180. package/radio/Radio.d.ts +0 -4
  181. package/radio/Radio.js +0 -173
  182. package/radio/Radio.stories.tsx +0 -192
  183. package/radio/Radio.test.js +0 -71
  184. package/radio/types.d.ts +0 -54
  185. package/row/Row.d.ts +0 -3
  186. package/row/Row.js +0 -127
  187. package/row/Row.stories.tsx +0 -237
  188. package/row/types.d.ts +0 -28
  189. package/stack/Stack.d.ts +0 -3
  190. package/stack/Stack.js +0 -97
  191. package/stack/Stack.stories.tsx +0 -164
  192. package/stack/types.d.ts +0 -24
  193. package/stack/types.js +0 -5
  194. package/text/Text.d.ts +0 -7
  195. package/text/Text.js +0 -30
  196. package/text/Text.stories.tsx +0 -19
@@ -21,68 +21,46 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
21
 
22
22
  var _useTheme = _interopRequireDefault(require("../useTheme"));
23
23
 
24
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
25
+
24
26
  var _variables = require("../common/variables.js");
25
27
 
26
28
  var _utils = require("../common/utils.js");
27
29
 
28
- var _uuid = require("uuid");
29
-
30
30
  var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
31
31
 
32
32
  var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext"));
33
33
 
34
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
34
+ var _Suggestions = _interopRequireDefault(require("./Suggestions"));
35
+
36
+ var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
37
+
38
+ var _Icons = _interopRequireDefault(require("./Icons"));
39
+
40
+ var _uuid = require("uuid");
41
+
42
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
35
43
 
36
44
  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
45
 
38
46
  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
47
 
40
- var textInputIcons = {
41
- error: /*#__PURE__*/_react["default"].createElement("svg", {
42
- xmlns: "http://www.w3.org/2000/svg",
43
- height: "24px",
44
- viewBox: "0 0 24 24",
45
- width: "24px",
46
- fill: "currentColor"
47
- }, /*#__PURE__*/_react["default"].createElement("path", {
48
- d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
49
- })),
50
- clear: /*#__PURE__*/_react["default"].createElement("svg", {
51
- xmlns: "http://www.w3.org/2000/svg",
52
- width: "24",
53
- height: "24",
54
- viewBox: "0 0 24 24",
55
- fill: "currentColor"
56
- }, /*#__PURE__*/_react["default"].createElement("path", {
57
- d: "M0 0h24v24H0V0z",
58
- fill: "none"
59
- }), /*#__PURE__*/_react["default"].createElement("path", {
60
- d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
61
- })),
62
- increment: /*#__PURE__*/_react["default"].createElement("svg", {
63
- xmlns: "http://www.w3.org/2000/svg",
64
- height: "24px",
65
- viewBox: "0 0 24 24",
66
- width: "24px",
67
- fill: "currentColor"
68
- }, /*#__PURE__*/_react["default"].createElement("path", {
69
- d: "M0 0h24v24H0z",
70
- fill: "none"
71
- }), /*#__PURE__*/_react["default"].createElement("path", {
72
- d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"
73
- })),
74
- decrement: /*#__PURE__*/_react["default"].createElement("svg", {
75
- xmlns: "http://www.w3.org/2000/svg",
76
- height: "24px",
77
- viewBox: "0 0 24 24",
78
- width: "24px",
79
- fill: "currentColor"
80
- }, /*#__PURE__*/_react["default"].createElement("path", {
81
- d: "M0 0h24v24H0z",
82
- fill: "none"
83
- }), /*#__PURE__*/_react["default"].createElement("path", {
84
- d: "M19 13H5v-2h14v2z"
85
- }))
48
+ var sizes = {
49
+ small: "240px",
50
+ medium: "360px",
51
+ large: "480px",
52
+ fillParent: "100%"
53
+ };
54
+
55
+ var AutosuggestWrapper = function AutosuggestWrapper(_ref) {
56
+ var condition = _ref.condition,
57
+ wrapper = _ref.wrapper,
58
+ children = _ref.children;
59
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, condition ? wrapper(children) : children);
60
+ };
61
+
62
+ var calculateWidth = function calculateWidth(margin, size) {
63
+ return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
86
64
  };
87
65
 
88
66
  var makeCancelable = function makeCancelable(promise) {
@@ -106,71 +84,69 @@ var makeCancelable = function makeCancelable(promise) {
106
84
  };
107
85
  };
108
86
 
109
- var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
110
- return "This field is required. Please, enter a value.";
87
+ var hasSuggestions = function hasSuggestions(suggestions) {
88
+ return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
111
89
  };
112
90
 
113
- var getPatternErrorMessage = function getPatternErrorMessage() {
114
- return "Please match the format requested.";
91
+ var isNotOptional = function isNotOptional(value, optional) {
92
+ return value === "" && !optional;
115
93
  };
116
94
 
117
- var patternMatch = function patternMatch(pattern, value) {
118
- return new RegExp(pattern).test(value);
95
+ var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
96
+ return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
119
97
  };
120
98
 
121
- var getLastOptionIndex = function getLastOptionIndex(filteredSuggestions) {
122
- var last = 0;
123
-
124
- var reducer = function reducer(acc, current) {
125
- var _current$options;
126
-
127
- return acc + ((_current$options = current.options) === null || _current$options === void 0 ? void 0 : _current$options.length);
128
- };
99
+ var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
100
+ return minNumber && parseInt(value) < minNumber || maxNumber && parseInt(value) > maxNumber;
101
+ };
129
102
 
130
- if (filteredSuggestions.length > 0) filteredSuggestions[0].options ? last = filteredSuggestions.reduce(reducer, 0) - 1 : last = filteredSuggestions.length - 1;
131
- return last;
103
+ var patternMissmatch = function patternMissmatch(pattern, value) {
104
+ return pattern && !new RegExp(pattern).test(value);
132
105
  };
133
106
 
134
- var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
135
- var label = _ref.label,
136
- _ref$name = _ref.name,
137
- name = _ref$name === void 0 ? "" : _ref$name,
138
- _ref$defaultValue = _ref.defaultValue,
139
- defaultValue = _ref$defaultValue === void 0 ? "" : _ref$defaultValue,
140
- value = _ref.value,
141
- helperText = _ref.helperText,
142
- _ref$placeholder = _ref.placeholder,
143
- placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
144
- action = _ref.action,
145
- _ref$clearable = _ref.clearable,
146
- clearable = _ref$clearable === void 0 ? false : _ref$clearable,
147
- _ref$disabled = _ref.disabled,
148
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
149
- _ref$optional = _ref.optional,
150
- optional = _ref$optional === void 0 ? false : _ref$optional,
151
- _ref$prefix = _ref.prefix,
152
- prefix = _ref$prefix === void 0 ? "" : _ref$prefix,
153
- _ref$suffix = _ref.suffix,
154
- suffix = _ref$suffix === void 0 ? "" : _ref$suffix,
155
- onChange = _ref.onChange,
156
- onBlur = _ref.onBlur,
157
- error = _ref.error,
158
- suggestions = _ref.suggestions,
159
- pattern = _ref.pattern,
160
- minLength = _ref.minLength,
161
- maxLength = _ref.maxLength,
162
- _ref$autocomplete = _ref.autocomplete,
163
- autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
164
- margin = _ref.margin,
165
- _ref$size = _ref.size,
166
- size = _ref$size === void 0 ? "medium" : _ref$size,
167
- _ref$tabIndex = _ref.tabIndex,
168
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
107
+ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
108
+ var label = _ref2.label,
109
+ _ref2$name = _ref2.name,
110
+ name = _ref2$name === void 0 ? "" : _ref2$name,
111
+ _ref2$defaultValue = _ref2.defaultValue,
112
+ defaultValue = _ref2$defaultValue === void 0 ? "" : _ref2$defaultValue,
113
+ value = _ref2.value,
114
+ helperText = _ref2.helperText,
115
+ _ref2$placeholder = _ref2.placeholder,
116
+ placeholder = _ref2$placeholder === void 0 ? "" : _ref2$placeholder,
117
+ action = _ref2.action,
118
+ _ref2$clearable = _ref2.clearable,
119
+ clearable = _ref2$clearable === void 0 ? false : _ref2$clearable,
120
+ _ref2$disabled = _ref2.disabled,
121
+ disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
122
+ _ref2$optional = _ref2.optional,
123
+ optional = _ref2$optional === void 0 ? false : _ref2$optional,
124
+ _ref2$prefix = _ref2.prefix,
125
+ prefix = _ref2$prefix === void 0 ? "" : _ref2$prefix,
126
+ _ref2$suffix = _ref2.suffix,
127
+ suffix = _ref2$suffix === void 0 ? "" : _ref2$suffix,
128
+ onChange = _ref2.onChange,
129
+ onBlur = _ref2.onBlur,
130
+ error = _ref2.error,
131
+ suggestions = _ref2.suggestions,
132
+ pattern = _ref2.pattern,
133
+ minLength = _ref2.minLength,
134
+ maxLength = _ref2.maxLength,
135
+ _ref2$autocomplete = _ref2.autocomplete,
136
+ autocomplete = _ref2$autocomplete === void 0 ? "off" : _ref2$autocomplete,
137
+ margin = _ref2.margin,
138
+ _ref2$size = _ref2.size,
139
+ size = _ref2$size === void 0 ? "medium" : _ref2$size,
140
+ _ref2$tabIndex = _ref2.tabIndex,
141
+ tabIndex = _ref2$tabIndex === void 0 ? 0 : _ref2$tabIndex;
169
142
 
170
143
  var _useState = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
171
144
  _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
172
145
  inputId = _useState2[0];
173
146
 
147
+ var autosuggestId = "suggestions-".concat(inputId);
148
+ var errorId = "error-".concat(inputId);
149
+
174
150
  var _useState3 = (0, _react.useState)(defaultValue),
175
151
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
176
152
  innerValue = _useState4[0],
@@ -198,73 +174,51 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
198
174
 
199
175
  var _useState13 = (0, _react.useState)(-1),
200
176
  _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
201
- visualFocusedSuggIndex = _useState14[0],
202
- changeVisualFocusedSuggIndex = _useState14[1];
177
+ visualFocusIndex = _useState14[0],
178
+ changeVisualFocusIndex = _useState14[1];
203
179
 
204
- var suggestionsRef = (0, _react.useRef)(null);
205
180
  var inputRef = (0, _react.useRef)(null);
206
181
  var actionRef = (0, _react.useRef)(null);
207
182
  var colorsTheme = (0, _useTheme["default"])();
183
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
208
184
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
209
- var autosuggestId = "".concat(inputId, "-listBox");
210
- var errorId = "error-".concat(inputId);
211
185
  var numberInputContext = (0, _react.useContext)(_NumberInputContext["default"]);
212
- var lastOptionIndex = (0, _react.useMemo)(function () {
213
- return getLastOptionIndex(filteredSuggestions);
214
- }, [filteredSuggestions]);
215
-
216
- var isNotOptional = function isNotOptional(value) {
217
- return value === "" && !optional;
218
- };
219
-
220
- var isLengthIncorrect = function isLengthIncorrect(value) {
221
- return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
222
- };
223
-
224
- var getLengthErrorMessage = function getLengthErrorMessage() {
225
- return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
226
- };
227
-
228
- var isNumberIncorrect = function isNumberIncorrect(value) {
229
- return (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
230
- };
231
-
232
- var isTextInputType = function isTextInputType() {
233
- var _inputRef$current, _inputRef$current2;
234
-
235
- return !(inputRef !== null && inputRef !== void 0 && (_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.getAttribute("type")) || (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.getAttribute("type")) === "text";
236
- };
237
186
 
238
187
  var getNumberErrorMessage = function getNumberErrorMessage(value) {
239
- if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return "Value must be greater than or equal to ".concat(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, ".");else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return "Value must be less than or equal to ".concat(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber, ".");
188
+ if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
240
189
  };
241
190
 
242
- var hasSuggestions = function hasSuggestions() {
243
- return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
244
- };
191
+ var getTextInputWidth = (0, _react.useCallback)(function () {
192
+ var _inputRef$current, _inputRef$current$par;
193
+
194
+ var rect = inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : (_inputRef$current$par = _inputRef$current.parentElement) === null || _inputRef$current$par === void 0 ? void 0 : _inputRef$current$par.getBoundingClientRect();
195
+ return rect === null || rect === void 0 ? void 0 : rect.width;
196
+ }, []);
245
197
 
246
198
  var openSuggestions = function openSuggestions() {
247
- hasSuggestions() && changeIsOpen(true);
199
+ hasSuggestions(suggestions) && changeIsOpen(true);
248
200
  };
249
201
 
250
202
  var closeSuggestions = function closeSuggestions() {
251
- changeIsOpen(false);
252
- changeVisualFocusedSuggIndex(-1);
203
+ if (hasSuggestions(suggestions)) {
204
+ changeIsOpen(false);
205
+ changeVisualFocusIndex(-1);
206
+ }
253
207
  };
254
208
 
255
209
  var changeValue = function changeValue(newValue) {
256
210
  value !== null && value !== void 0 ? value : setInnerValue(newValue);
257
211
  var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
258
- if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
212
+ if (isNotOptional(newValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
259
213
  value: changedValue,
260
- error: getNotOptionalErrorMessage()
261
- });else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
214
+ error: translatedLabels.formFields.requiredValueErrorMessage
215
+ });else if (isLengthIncorrect(newValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
262
216
  value: changedValue,
263
- error: getLengthErrorMessage()
264
- });else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
217
+ error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
218
+ });else if (patternMissmatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
265
219
  value: changedValue,
266
- error: getPatternErrorMessage()
267
- });else if (newValue && isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
220
+ error: translatedLabels.formFields.formatRequestedErrorMessage
221
+ });else if (isNumberIncorrect(newValue, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
268
222
  value: changedValue,
269
223
  error: getNumberErrorMessage(newValue)
270
224
  });else onChange === null || onChange === void 0 ? void 0 : onChange({
@@ -281,23 +235,23 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
281
235
  document.activeElement === inputRef.current && event.preventDefault();
282
236
  };
283
237
 
284
- var handleIOnChange = function handleIOnChange(event) {
238
+ var handleInputOnChange = function handleInputOnChange(event) {
285
239
  openSuggestions();
286
240
  changeValue(event.target.value);
287
241
  };
288
242
 
289
- var handleIOnBlur = function handleIOnBlur(event) {
290
- suggestions && closeSuggestions();
291
- if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
243
+ var handleInputOnBlur = function handleInputOnBlur(event) {
244
+ closeSuggestions();
245
+ if (isNotOptional(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
292
246
  value: event.target.value,
293
- error: getNotOptionalErrorMessage()
294
- });else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
247
+ error: translatedLabels.formFields.requiredValueErrorMessage
248
+ });else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
295
249
  value: event.target.value,
296
- error: getLengthErrorMessage()
297
- });else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
250
+ error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
251
+ });else if (patternMissmatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
298
252
  value: event.target.value,
299
- error: getPatternErrorMessage()
300
- });else if (event.target.value && isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
253
+ error: translatedLabels.formFields.formatRequestedErrorMessage
254
+ });else if (isNumberIncorrect(event.target.value, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
301
255
  value: event.target.value,
302
256
  error: getNumberErrorMessage(event.target.value)
303
257
  });else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
@@ -305,19 +259,19 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
305
259
  });
306
260
  };
307
261
 
308
- var handleIOnKeyDown = function handleIOnKeyDown(event) {
309
- switch (event.keyCode) {
310
- case 40:
311
- // Arrow Down
262
+ var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
263
+ switch (event.key) {
264
+ case "Down":
265
+ case "ArrowDown":
266
+ event.preventDefault();
267
+
312
268
  if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
313
269
  decrementNumber();
314
- event.preventDefault();
315
270
  } else {
316
- event.preventDefault();
317
271
  openSuggestions();
318
272
 
319
273
  if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
320
- changeVisualFocusedSuggIndex(function (visualFocusedSuggIndex) {
274
+ changeVisualFocusIndex(function (visualFocusedSuggIndex) {
321
275
  if (visualFocusedSuggIndex < filteredSuggestions.length - 1) return visualFocusedSuggIndex + 1;else if (visualFocusedSuggIndex === filteredSuggestions.length - 1) return 0;
322
276
  });
323
277
  }
@@ -325,17 +279,17 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
325
279
 
326
280
  break;
327
281
 
328
- case 38:
329
- // Arrow Up
282
+ case "Up":
283
+ case "ArrowUp":
284
+ event.preventDefault();
285
+
330
286
  if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
331
287
  incrementNumber();
332
- event.preventDefault();
333
288
  } else {
334
- event.preventDefault();
335
289
  openSuggestions();
336
290
 
337
291
  if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
338
- changeVisualFocusedSuggIndex(function (visualFocusedSuggIndex) {
292
+ changeVisualFocusIndex(function (visualFocusedSuggIndex) {
339
293
  if (visualFocusedSuggIndex === 0 || visualFocusedSuggIndex === -1) return filteredSuggestions.length > 0 ? filteredSuggestions.length - 1 : suggestions.length - 1;else return visualFocusedSuggIndex - 1;
340
294
  });
341
295
  }
@@ -343,22 +297,21 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
343
297
 
344
298
  break;
345
299
 
346
- case 27:
347
- // Esc
300
+ case "Esc":
301
+ case "Escape":
348
302
  event.preventDefault();
349
303
 
350
- if (hasSuggestions()) {
304
+ if (hasSuggestions(suggestions)) {
351
305
  changeValue("");
352
306
  isOpen && closeSuggestions();
353
307
  }
354
308
 
355
309
  break;
356
310
 
357
- case 13:
358
- // Enter
359
- if (hasSuggestions() && !isSearching) {
360
- var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusedSuggIndex >= 0 && visualFocusedSuggIndex < filteredSuggestions.length;
361
- validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusedSuggIndex]);
311
+ case "Enter":
312
+ if (hasSuggestions(suggestions) && !isSearching) {
313
+ var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
314
+ validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
362
315
  isOpen && closeSuggestions();
363
316
  }
364
317
 
@@ -383,12 +336,12 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
383
336
  };
384
337
 
385
338
  var setNumberProps = function setNumberProps(type, min, max, step) {
386
- var _inputRef$current3, _inputRef$current4, _inputRef$current5, _inputRef$current6;
339
+ var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
387
340
 
388
- type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("type", type));
389
- min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("min", min));
390
- max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("max", max));
391
- step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : _inputRef$current6.setAttribute("step", step));
341
+ type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("type", type));
342
+ min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("min", min));
343
+ max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("max", max));
344
+ step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("step", step));
392
345
  };
393
346
 
394
347
  var decrementNumber = function decrementNumber() {
@@ -431,15 +384,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
431
384
  }
432
385
  };
433
386
 
434
- (0, _react.useLayoutEffect)(function () {
435
- var _suggestionsRef$curre, _visualFocusedOptionE;
436
-
437
- var visualFocusedOptionEl = suggestionsRef === null || suggestionsRef === void 0 ? void 0 : (_suggestionsRef$curre = suggestionsRef.current) === null || _suggestionsRef$curre === void 0 ? void 0 : _suggestionsRef$curre.querySelectorAll("[role='option']")[visualFocusedSuggIndex];
438
- visualFocusedOptionEl === null || visualFocusedOptionEl === void 0 ? void 0 : (_visualFocusedOptionE = visualFocusedOptionEl.scrollIntoView) === null || _visualFocusedOptionE === void 0 ? void 0 : _visualFocusedOptionE.call(visualFocusedOptionEl, {
439
- block: "nearest",
440
- inline: "start"
441
- });
442
- }, [visualFocusedSuggIndex]);
443
387
  (0, _react.useEffect)(function () {
444
388
  if (typeof suggestions === "function") {
445
389
  changeIsSearching(true);
@@ -463,50 +407,27 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
463
407
  changeFilteredSuggestions(suggestions.filter(function (suggestion) {
464
408
  return suggestion.toUpperCase().startsWith((value !== null && value !== void 0 ? value : innerValue).toUpperCase());
465
409
  }));
466
- changeVisualFocusedSuggIndex(-1);
410
+ changeVisualFocusIndex(-1);
467
411
  }
468
412
 
469
413
  (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
470
414
  }, [value, innerValue, suggestions, numberInputContext]);
471
-
472
- var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
473
- var suggestion = _ref2.suggestion,
474
- index = _ref2.index;
475
- var regEx = new RegExp(value !== null && value !== void 0 ? value : innerValue, "i");
476
- var matchedWords = suggestion.match(regEx);
477
- var noMatchedWords = suggestion.replace(regEx, "");
478
- var isLastOption = index === lastOptionIndex;
479
- return /*#__PURE__*/_react["default"].createElement(Suggestion, {
480
- id: "suggestion-".concat(index),
481
- onClick: function onClick() {
482
- changeValue(suggestion);
483
- closeSuggestions();
484
- },
485
- visualFocused: visualFocusedSuggIndex === index,
486
- role: "option",
487
- "aria-selected": visualFocusedSuggIndex === index && "true"
488
- }, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
489
- last: isLastOption,
490
- visualFocused: visualFocusedSuggIndex === index
491
- }, typeof suggestions === "function" ? suggestion : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords)));
492
- };
493
-
494
415
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
495
416
  theme: colorsTheme.textInput
496
- }, /*#__PURE__*/_react["default"].createElement(DxcInput, {
417
+ }, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
497
418
  margin: margin,
498
- ref: ref,
499
- size: size
419
+ size: size,
420
+ ref: ref
500
421
  }, label && /*#__PURE__*/_react["default"].createElement(Label, {
501
422
  htmlFor: inputId,
502
423
  disabled: disabled,
503
424
  backgroundType: backgroundType,
504
- helperText: helperText
505
- }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, "(Optional)")), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
425
+ hasHelperText: helperText ? true : false
426
+ }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
506
427
  disabled: disabled,
507
428
  backgroundType: backgroundType
508
429
  }, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
509
- error: error,
430
+ error: error ? true : false,
510
431
  disabled: disabled,
511
432
  backgroundType: backgroundType,
512
433
  onClick: handleInputContainerOnClick,
@@ -514,17 +435,48 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
514
435
  }, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
515
436
  disabled: disabled,
516
437
  backgroundType: backgroundType
517
- }, prefix), /*#__PURE__*/_react["default"].createElement(Input, {
438
+ }, prefix), /*#__PURE__*/_react["default"].createElement(AutosuggestWrapper, {
439
+ condition: hasSuggestions(suggestions),
440
+ wrapper: function wrapper(children) {
441
+ return /*#__PURE__*/_react["default"].createElement(Popover.Root, {
442
+ open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
443
+ }, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
444
+ asChild: true,
445
+ "aria-controls": undefined
446
+ }, children), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
447
+ sideOffset: 5,
448
+ onOpenAutoFocus: function onOpenAutoFocus(event) {
449
+ // Avoid select to lose focus when the list is opened
450
+ event.preventDefault();
451
+ },
452
+ onCloseAutoFocus: function onCloseAutoFocus(event) {
453
+ // Avoid select to lose focus when the list is closed
454
+ event.preventDefault();
455
+ }
456
+ }, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
457
+ id: autosuggestId,
458
+ value: value !== null && value !== void 0 ? value : innerValue,
459
+ suggestions: filteredSuggestions,
460
+ visualFocusIndex: visualFocusIndex,
461
+ highlightedSuggestions: typeof suggestions !== "function",
462
+ searchHasErrors: isAutosuggestError,
463
+ isSearching: isSearching,
464
+ suggestionOnClick: function suggestionOnClick(suggestion) {
465
+ changeValue(suggestion);
466
+ closeSuggestions();
467
+ },
468
+ getTextInputWidth: getTextInputWidth
469
+ })));
470
+ }
471
+ }, /*#__PURE__*/_react["default"].createElement(Input, {
518
472
  id: inputId,
519
473
  name: name,
520
474
  value: value !== null && value !== void 0 ? value : innerValue,
521
475
  placeholder: placeholder,
522
- onBlur: handleIOnBlur,
523
- onChange: handleIOnChange,
524
- onFocus: function onFocus() {
525
- openSuggestions();
526
- },
527
- onKeyDown: handleIOnKeyDown,
476
+ onBlur: handleInputOnBlur,
477
+ onChange: handleInputOnChange,
478
+ onFocus: openSuggestions,
479
+ onKeyDown: handleInputOnKeyDown,
528
480
  onMouseDown: function onMouseDown(event) {
529
481
  event.stopPropagation();
530
482
  },
@@ -534,63 +486,56 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
534
486
  pattern: pattern,
535
487
  minLength: minLength,
536
488
  maxLength: maxLength,
537
- autoComplete: autocomplete,
489
+ autoComplete: autocomplete === "off" ? "nope" : autocomplete,
538
490
  tabIndex: tabIndex,
539
- role: isTextInputType() && hasSuggestions() ? "combobox" : "textbox",
540
- "aria-autocomplete": isTextInputType() && hasSuggestions() ? "list" : undefined,
541
- "aria-controls": isTextInputType() && hasSuggestions() ? autosuggestId : undefined,
542
- "aria-disabled": disabled,
543
- "aria-expanded": isTextInputType() && hasSuggestions() ? isOpen ? "true" : "false" : undefined,
544
- "aria-activedescendant": isTextInputType() && hasSuggestions() && isOpen && visualFocusedSuggIndex !== -1 ? "suggestion-".concat(visualFocusedSuggIndex) : undefined,
545
- "aria-invalid": error ? "true" : "false",
491
+ type: "text",
492
+ role: hasSuggestions(suggestions) ? "combobox" : undefined,
493
+ "aria-autocomplete": hasSuggestions(suggestions) ? "list" : undefined,
494
+ "aria-controls": hasSuggestions(suggestions) ? autosuggestId : undefined,
495
+ "aria-expanded": hasSuggestions(suggestions) ? isOpen : undefined,
496
+ "aria-haspopup": hasSuggestions(suggestions) ? "listbox" : undefined,
497
+ "aria-activedescendant": hasSuggestions(suggestions) && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
498
+ "aria-invalid": error ? true : false,
546
499
  "aria-errormessage": error ? errorId : undefined,
547
- "aria-required": optional ? "false" : "true"
548
- }), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
500
+ "aria-required": optional ? false : true
501
+ })), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
549
502
  backgroundType: backgroundType,
550
503
  "aria-label": "Error"
551
- }, textInputIcons.error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
552
- onClick: function onClick() {
553
- return handleClearActionOnClick();
554
- },
504
+ }, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
505
+ onClick: handleClearActionOnClick,
555
506
  onMouseDown: function onMouseDown(event) {
556
507
  event.stopPropagation();
557
508
  },
558
509
  backgroundType: backgroundType,
559
510
  tabIndex: tabIndex,
560
- title: "Clear field",
561
- "aria-label": "Clear field"
562
- }, textInputIcons.clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
511
+ title: translatedLabels.textInput.clearFieldActionTitle,
512
+ "aria-label": translatedLabels.textInput.clearFieldActionTitle
513
+ }, _Icons["default"].clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
563
514
  ref: actionRef,
564
515
  disabled: disabled,
565
- onClick: function onClick() {
566
- return handleDecrementActionOnClick();
567
- },
516
+ onClick: handleDecrementActionOnClick,
568
517
  onMouseDown: function onMouseDown(event) {
569
518
  event.stopPropagation();
570
519
  },
571
520
  backgroundType: backgroundType,
572
521
  tabIndex: tabIndex,
573
- title: "Decrement value",
574
- "aria-label": "Decrement value"
575
- }, textInputIcons.decrement), /*#__PURE__*/_react["default"].createElement(Action, {
522
+ title: translatedLabels.numberInput.decrementValueTitle,
523
+ "aria-label": translatedLabels.numberInput.decrementValueTitle
524
+ }, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
576
525
  ref: actionRef,
577
526
  disabled: disabled,
578
- onClick: function onClick() {
579
- return handleIncrementActionOnClick();
580
- },
527
+ onClick: handleIncrementActionOnClick,
581
528
  onMouseDown: function onMouseDown(event) {
582
529
  event.stopPropagation();
583
530
  },
584
531
  backgroundType: backgroundType,
585
532
  tabIndex: tabIndex,
586
- title: "Increment value",
587
- "aria-label": "Increment value"
588
- }, textInputIcons.increment)) : action && /*#__PURE__*/_react["default"].createElement(Action, {
533
+ title: translatedLabels.numberInput.incrementValueTitle,
534
+ "aria-label": translatedLabels.numberInput.incrementValueTitle
535
+ }, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
589
536
  ref: actionRef,
590
537
  disabled: disabled,
591
- onClick: function onClick() {
592
- return action.onClick();
593
- },
538
+ onClick: action.onClick,
594
539
  onMouseDown: function onMouseDown(event) {
595
540
  event.stopPropagation();
596
541
  },
@@ -603,42 +548,14 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
603
548
  }) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
604
549
  disabled: disabled,
605
550
  backgroundType: backgroundType
606
- }, suffix), isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError) && /*#__PURE__*/_react["default"].createElement(Suggestions, {
607
- id: autosuggestId,
608
- isError: isAutosuggestError,
609
- onMouseDown: function onMouseDown(event) {
610
- event.preventDefault();
611
- },
612
- ref: suggestionsRef,
613
- role: "listbox",
614
- "aria-label": label
615
- }, !isSearching && !isAutosuggestError && filteredSuggestions.length > 0 && filteredSuggestions.map(function (suggestion, index) {
616
- return /*#__PURE__*/_react["default"].createElement(HighlightedSuggestion, {
617
- key: "suggestion-".concat((0, _uuid.v4)()),
618
- suggestion: suggestion,
619
- index: index
620
- });
621
- }), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, "Searching..."), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
622
- backgroundType: backgroundType
623
- }, textInputIcons.error), "Error fetching data"))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
551
+ }, suffix)), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
624
552
  id: errorId,
625
553
  backgroundType: backgroundType,
626
554
  "aria-live": error ? "assertive" : "off"
627
555
  }, error)));
628
556
  });
629
557
 
630
- var sizes = {
631
- small: "240px",
632
- medium: "360px",
633
- large: "480px",
634
- fillParent: "100%"
635
- };
636
-
637
- var calculateWidth = function calculateWidth(margin, size) {
638
- return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
639
- };
640
-
641
- var DxcInput = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
558
+ var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
642
559
  return calculateWidth(props.margin, props.size);
643
560
  }, function (props) {
644
561
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
@@ -665,7 +582,7 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
665
582
  }, function (props) {
666
583
  return props.theme.labelLineHeight;
667
584
  }, function (props) {
668
- return !props.helperText && "margin-bottom: 0.25rem";
585
+ return !props.hasHelperText && "margin-bottom: 0.25rem";
669
586
  });
670
587
 
671
588
  var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
@@ -695,7 +612,7 @@ var InputContainer = _styledComponents["default"].div(_templateObject5 || (_temp
695
612
  }, function (props) {
696
613
  return props.disabled && "cursor: not-allowed;";
697
614
  }, function (props) {
698
- return !props.disabled && "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error && "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.hoverErrorBorderColorOnDark : props.theme.hoverErrorBorderColor, ";"), "\n }\n &:focus-within {\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n ");
615
+ return !props.disabled && "\n &:hover {\n border-color: ".concat(props.error ? "transparent" : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error ? "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.hoverErrorBorderColorOnDark : props.theme.hoverErrorBorderColor, ";") : "", "\n }\n &:focus-within {\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n ");
699
616
  });
700
617
 
701
618
  var Input = _styledComponents["default"].input(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n height: calc(2.5rem - 2px);\n width: 100%;\n background: none;\n border: none;\n outline: none;\n padding: 0 0.5rem;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n color: ", ";\n\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n ", "\n\n ::placeholder {\n color: ", ";\n }\n"])), function (props) {
@@ -752,45 +669,5 @@ var Error = _styledComponents["default"].span(_templateObject12 || (_templateObj
752
669
  return props.theme.fontFamily;
753
670
  });
754
671
 
755
- var Suggestions = _styledComponents["default"].ul(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n z-index: 1;\n max-height: 304px;\n overflow-y: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 0.25rem 0;\n width: 100%;\n background-color: ", ";\n border: 1px solid\n ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
756
- return props.isError ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
757
- }, function (props) {
758
- return props.isError ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
759
- }, function (props) {
760
- return props.theme.listOptionFontColor;
761
- }, function (props) {
762
- return props.theme.fontFamily;
763
- }, function (props) {
764
- return props.theme.listOptionFontSize;
765
- }, function (props) {
766
- return props.theme.listOptionFontStyle;
767
- }, function (props) {
768
- return props.theme.listOptionFontWeight;
769
- });
770
-
771
- var Suggestion = _styledComponents["default"].li(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0 0.5rem;\n line-height: 1.715em;\n cursor: pointer;\n\n box-shadow: inset 0 0 0 2px\n ", ";\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
772
- return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
773
- }, function (props) {
774
- return props.theme.hoverListOptionBackgroundColor;
775
- }, function (props) {
776
- return props.theme.activeListOptionBackgroundColor;
777
- });
778
-
779
- var StyledSuggestion = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n padding: 0.25rem 0.5rem 0.188rem 0.5rem;\n ", ";\n"])), function (props) {
780
- return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
781
- });
782
-
783
- var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n color: ", ";\n line-height: 1.715em;\n"])), function (props) {
784
- return props.theme.systemMessageFontColor;
785
- });
786
-
787
- var SuggestionsErrorIcon = _styledComponents["default"].span(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n margin-right: 0.5rem;\n height: 18px;\n width: 18px;\n color: ", ";\n"])), function (props) {
788
- return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
789
- });
790
-
791
- var SuggestionsError = _styledComponents["default"].span(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n align-items: center;\n line-height: 1.715em;\n color: ", ";\n"])), function (props) {
792
- return props.theme.errorListDialogFontColor;
793
- });
794
-
795
672
  var _default = DxcTextInput;
796
673
  exports["default"] = _default;