@dxc-technology/halstack-react 6.2.2 → 8.0.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 (66) hide show
  1. package/HalstackContext.js +7 -8
  2. package/accordion/types.d.ts +1 -0
  3. package/accordion-group/types.d.ts +1 -0
  4. package/box/types.d.ts +1 -0
  5. package/card/types.d.ts +1 -0
  6. package/checkbox/Checkbox.d.ts +2 -2
  7. package/checkbox/Checkbox.js +16 -15
  8. package/checkbox/Checkbox.stories.tsx +79 -59
  9. package/checkbox/types.d.ts +4 -0
  10. package/common/variables.js +19 -15
  11. package/date-input/Calendar.d.ts +4 -0
  12. package/date-input/Calendar.js +258 -0
  13. package/date-input/DateInput.js +77 -222
  14. package/date-input/DateInput.stories.tsx +30 -17
  15. package/date-input/DateInput.test.js +411 -138
  16. package/date-input/DatePicker.d.ts +4 -0
  17. package/date-input/DatePicker.js +160 -0
  18. package/date-input/YearPicker.d.ts +4 -0
  19. package/date-input/YearPicker.js +115 -0
  20. package/date-input/types.d.ts +53 -0
  21. package/dialog/types.d.ts +1 -0
  22. package/dropdown/Dropdown.js +35 -31
  23. package/dropdown/Dropdown.test.js +18 -24
  24. package/file-input/FileInput.d.ts +2 -2
  25. package/file-input/FileInput.js +177 -219
  26. package/file-input/FileInput.stories.tsx +38 -10
  27. package/file-input/FileInput.test.js +53 -12
  28. package/file-input/FileItem.d.ts +4 -14
  29. package/file-input/FileItem.js +38 -63
  30. package/file-input/types.d.ts +17 -0
  31. package/flex/Flex.d.ts +1 -1
  32. package/flex/Flex.js +31 -19
  33. package/flex/types.d.ts +14 -3
  34. package/footer/types.d.ts +1 -0
  35. package/header/types.d.ts +1 -0
  36. package/link/Link.js +1 -1
  37. package/number-input/NumberInput.test.js +43 -7
  38. package/package.json +7 -12
  39. package/paginator/Paginator.js +2 -2
  40. package/paginator/Paginator.test.js +1 -1
  41. package/password-input/PasswordInput.test.js +13 -12
  42. package/quick-nav/QuickNav.js +11 -12
  43. package/quick-nav/QuickNav.stories.tsx +97 -19
  44. package/radio-group/RadioGroup.js +9 -5
  45. package/radio-group/RadioGroup.test.js +116 -59
  46. package/resultsetTable/Icons.d.ts +7 -0
  47. package/resultsetTable/Icons.js +51 -0
  48. package/resultsetTable/ResultsetTable.js +48 -107
  49. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  50. package/resultsetTable/ResultsetTable.test.js +23 -41
  51. package/resultsetTable/types.d.ts +2 -2
  52. package/select/Select.js +3 -1
  53. package/select/Select.stories.tsx +2 -5
  54. package/select/Select.test.js +267 -209
  55. package/slider/Slider.d.ts +2 -2
  56. package/slider/Slider.js +5 -4
  57. package/slider/types.d.ts +4 -0
  58. package/switch/Switch.d.ts +3 -3
  59. package/switch/Switch.js +4 -3
  60. package/switch/types.d.ts +6 -1
  61. package/table/Table.js +1 -1
  62. package/table/Table.test.js +1 -1
  63. package/text-input/TextInput.js +165 -151
  64. package/text-input/TextInput.test.js +560 -649
  65. package/text-input/types.d.ts +5 -0
  66. package/common/RequiredComponent.js +0 -32
@@ -52,6 +52,13 @@ var sizes = {
52
52
  fillParent: "100%"
53
53
  };
54
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
+
55
62
  var calculateWidth = function calculateWidth(margin, size) {
56
63
  return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
57
64
  };
@@ -77,81 +84,99 @@ var makeCancelable = function makeCancelable(promise) {
77
84
  };
78
85
  };
79
86
 
87
+ var hasSuggestions = function hasSuggestions(suggestions) {
88
+ return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
89
+ };
90
+
91
+ var isNotOptional = function isNotOptional(value, optional) {
92
+ return value === "" && !optional;
93
+ };
94
+
95
+ var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
96
+ return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
97
+ };
98
+
99
+ var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
100
+ return minNumber && parseInt(value) < minNumber || maxNumber && parseInt(value) > maxNumber;
101
+ };
102
+
80
103
  var patternMissmatch = function patternMissmatch(pattern, value) {
81
104
  return pattern && !new RegExp(pattern).test(value);
82
105
  };
83
106
 
84
- var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
85
- var label = _ref.label,
86
- _ref$name = _ref.name,
87
- name = _ref$name === void 0 ? "" : _ref$name,
88
- _ref$defaultValue = _ref.defaultValue,
89
- defaultValue = _ref$defaultValue === void 0 ? "" : _ref$defaultValue,
90
- value = _ref.value,
91
- helperText = _ref.helperText,
92
- _ref$placeholder = _ref.placeholder,
93
- placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
94
- action = _ref.action,
95
- _ref$clearable = _ref.clearable,
96
- clearable = _ref$clearable === void 0 ? false : _ref$clearable,
97
- _ref$disabled = _ref.disabled,
98
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
99
- _ref$optional = _ref.optional,
100
- optional = _ref$optional === void 0 ? false : _ref$optional,
101
- _ref$prefix = _ref.prefix,
102
- prefix = _ref$prefix === void 0 ? "" : _ref$prefix,
103
- _ref$suffix = _ref.suffix,
104
- suffix = _ref$suffix === void 0 ? "" : _ref$suffix,
105
- onChange = _ref.onChange,
106
- onBlur = _ref.onBlur,
107
- error = _ref.error,
108
- suggestions = _ref.suggestions,
109
- pattern = _ref.pattern,
110
- minLength = _ref.minLength,
111
- maxLength = _ref.maxLength,
112
- _ref$autocomplete = _ref.autocomplete,
113
- autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
114
- margin = _ref.margin,
115
- _ref$size = _ref.size,
116
- size = _ref$size === void 0 ? "medium" : _ref$size,
117
- _ref$tabIndex = _ref.tabIndex,
118
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
119
- var id = (0, _react.useState)((0, _uuid.v4)());
120
- var inputId = "input-".concat(id);
121
- var autosuggestId = "suggestions-".concat(id);
122
- var errorId = "error-".concat(id);
123
-
124
- var _useState = (0, _react.useState)(defaultValue),
125
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
126
- innerValue = _useState2[0],
127
- setInnerValue = _useState2[1];
128
-
129
- var _useState3 = (0, _react.useState)(false),
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;
142
+
143
+ var _useState = (0, _react.useState)("input-".concat((0, _uuid.v4)())),
144
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
145
+ inputId = _useState2[0];
146
+
147
+ var autosuggestId = "suggestions-".concat(inputId);
148
+ var errorId = "error-".concat(inputId);
149
+
150
+ var _useState3 = (0, _react.useState)(defaultValue),
130
151
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
131
- isOpen = _useState4[0],
132
- changeIsOpen = _useState4[1];
152
+ innerValue = _useState4[0],
153
+ setInnerValue = _useState4[1];
133
154
 
134
155
  var _useState5 = (0, _react.useState)(false),
135
156
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
136
- isSearching = _useState6[0],
137
- changeIsSearching = _useState6[1];
157
+ isOpen = _useState6[0],
158
+ changeIsOpen = _useState6[1];
138
159
 
139
160
  var _useState7 = (0, _react.useState)(false),
140
161
  _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
141
- isAutosuggestError = _useState8[0],
142
- changeIsAutosuggestError = _useState8[1];
162
+ isSearching = _useState8[0],
163
+ changeIsSearching = _useState8[1];
143
164
 
144
- var _useState9 = (0, _react.useState)([]),
165
+ var _useState9 = (0, _react.useState)(false),
145
166
  _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
146
- filteredSuggestions = _useState10[0],
147
- changeFilteredSuggestions = _useState10[1];
167
+ isAutosuggestError = _useState10[0],
168
+ changeIsAutosuggestError = _useState10[1];
148
169
 
149
- var _useState11 = (0, _react.useState)(-1),
170
+ var _useState11 = (0, _react.useState)([]),
150
171
  _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
151
- visualFocusIndex = _useState12[0],
152
- changeVisualFocusIndex = _useState12[1];
172
+ filteredSuggestions = _useState12[0],
173
+ changeFilteredSuggestions = _useState12[1];
174
+
175
+ var _useState13 = (0, _react.useState)(-1),
176
+ _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
177
+ visualFocusIndex = _useState14[0],
178
+ changeVisualFocusIndex = _useState14[1];
153
179
 
154
- var inputContainerRef = (0, _react.useRef)(null);
155
180
  var inputRef = (0, _react.useRef)(null);
156
181
  var actionRef = (0, _react.useRef)(null);
157
182
  var colorsTheme = (0, _useTheme["default"])();
@@ -159,38 +184,23 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
159
184
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
160
185
  var numberInputContext = (0, _react.useContext)(_NumberInputContext["default"]);
161
186
 
162
- var isNotOptional = function isNotOptional(value) {
163
- return value === "" && !optional;
164
- };
165
-
166
- var isLengthIncorrect = function isLengthIncorrect(value) {
167
- return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
168
- };
169
-
170
- var isNumberIncorrect = function isNumberIncorrect(value) {
171
- 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);
172
- };
173
-
174
- var isTextInputType = function isTextInputType() {
175
- var _inputRef$current, _inputRef$current2;
176
-
177
- 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";
178
- };
179
-
180
187
  var getNumberErrorMessage = function getNumberErrorMessage(value) {
181
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);
182
189
  };
183
190
 
184
- var hasSuggestions = function hasSuggestions() {
185
- return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
186
- };
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
+ }, []);
187
197
 
188
198
  var openSuggestions = function openSuggestions() {
189
- hasSuggestions() && changeIsOpen(true);
199
+ hasSuggestions(suggestions) && changeIsOpen(true);
190
200
  };
191
201
 
192
202
  var closeSuggestions = function closeSuggestions() {
193
- if (hasSuggestions()) {
203
+ if (hasSuggestions(suggestions)) {
194
204
  changeIsOpen(false);
195
205
  changeVisualFocusIndex(-1);
196
206
  }
@@ -199,16 +209,16 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
199
209
  var changeValue = function changeValue(newValue) {
200
210
  value !== null && value !== void 0 ? value : setInnerValue(newValue);
201
211
  var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
202
- if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
212
+ if (isNotOptional(newValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
203
213
  value: changedValue,
204
214
  error: translatedLabels.formFields.requiredValueErrorMessage
205
- });else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
215
+ });else if (isLengthIncorrect(newValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
206
216
  value: changedValue,
207
217
  error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
208
218
  });else if (patternMissmatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
209
219
  value: changedValue,
210
220
  error: translatedLabels.formFields.formatRequestedErrorMessage
211
- });else if (isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
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({
212
222
  value: changedValue,
213
223
  error: getNumberErrorMessage(newValue)
214
224
  });else onChange === null || onChange === void 0 ? void 0 : onChange({
@@ -225,23 +235,23 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
225
235
  document.activeElement === inputRef.current && event.preventDefault();
226
236
  };
227
237
 
228
- var handleIOnChange = function handleIOnChange(event) {
238
+ var handleInputOnChange = function handleInputOnChange(event) {
229
239
  openSuggestions();
230
240
  changeValue(event.target.value);
231
241
  };
232
242
 
233
- var handleIOnBlur = function handleIOnBlur(event) {
243
+ var handleInputOnBlur = function handleInputOnBlur(event) {
234
244
  closeSuggestions();
235
- if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
245
+ if (isNotOptional(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
236
246
  value: event.target.value,
237
247
  error: translatedLabels.formFields.requiredValueErrorMessage
238
- });else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
248
+ });else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
239
249
  value: event.target.value,
240
250
  error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
241
251
  });else if (patternMissmatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
242
252
  value: event.target.value,
243
253
  error: translatedLabels.formFields.formatRequestedErrorMessage
244
- });else if (isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
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({
245
255
  value: event.target.value,
246
256
  error: getNumberErrorMessage(event.target.value)
247
257
  });else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
@@ -249,7 +259,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
249
259
  });
250
260
  };
251
261
 
252
- var handleIOnKeyDown = function handleIOnKeyDown(event) {
262
+ var handleInputOnKeyDown = function handleInputOnKeyDown(event) {
253
263
  switch (event.key) {
254
264
  case "Down":
255
265
  case "ArrowDown":
@@ -291,7 +301,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
291
301
  case "Escape":
292
302
  event.preventDefault();
293
303
 
294
- if (hasSuggestions()) {
304
+ if (hasSuggestions(suggestions)) {
295
305
  changeValue("");
296
306
  isOpen && closeSuggestions();
297
307
  }
@@ -299,7 +309,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
299
309
  break;
300
310
 
301
311
  case "Enter":
302
- if (hasSuggestions() && !isSearching) {
312
+ if (hasSuggestions(suggestions) && !isSearching) {
303
313
  var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusIndex >= 0 && visualFocusIndex < filteredSuggestions.length;
304
314
  validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusIndex]);
305
315
  isOpen && closeSuggestions();
@@ -326,12 +336,12 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
326
336
  };
327
337
 
328
338
  var setNumberProps = function setNumberProps(type, min, max, step) {
329
- var _inputRef$current3, _inputRef$current4, _inputRef$current5, _inputRef$current6;
339
+ var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
330
340
 
331
- type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("type", type));
332
- min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("min", min));
333
- max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("max", max));
334
- 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));
335
345
  };
336
346
 
337
347
  var decrementNumber = function decrementNumber() {
@@ -374,12 +384,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
374
384
  }
375
385
  };
376
386
 
377
- var getTextInputWidth = (0, _react.useCallback)(function () {
378
- var _inputContainerRef$cu;
379
-
380
- var rect = inputContainerRef === null || inputContainerRef === void 0 ? void 0 : (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 ? void 0 : _inputContainerRef$cu.getBoundingClientRect();
381
- return rect === null || rect === void 0 ? void 0 : rect.width;
382
- }, []);
383
387
  (0, _react.useEffect)(function () {
384
388
  if (typeof suggestions === "function") {
385
389
  changeIsSearching(true);
@@ -422,29 +426,57 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
422
426
  }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
423
427
  disabled: disabled,
424
428
  backgroundType: backgroundType
425
- }, helperText), /*#__PURE__*/_react["default"].createElement(Popover.Root, {
426
- open: isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError)
427
- }, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
428
- asChild: true
429
- }, /*#__PURE__*/_react["default"].createElement(InputContainer, {
429
+ }, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
430
430
  error: error ? true : false,
431
431
  disabled: disabled,
432
432
  backgroundType: backgroundType,
433
433
  onClick: handleInputContainerOnClick,
434
- onMouseDown: handleInputContainerOnMouseDown,
435
- ref: inputContainerRef
434
+ onMouseDown: handleInputContainerOnMouseDown
436
435
  }, prefix && /*#__PURE__*/_react["default"].createElement(Prefix, {
437
436
  disabled: disabled,
438
437
  backgroundType: backgroundType
439
- }, 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, {
440
472
  id: inputId,
441
473
  name: name,
442
474
  value: value !== null && value !== void 0 ? value : innerValue,
443
475
  placeholder: placeholder,
444
- onBlur: handleIOnBlur,
445
- onChange: handleIOnChange,
476
+ onBlur: handleInputOnBlur,
477
+ onChange: handleInputOnChange,
446
478
  onFocus: openSuggestions,
447
- onKeyDown: handleIOnKeyDown,
479
+ onKeyDown: handleInputOnKeyDown,
448
480
  onMouseDown: function onMouseDown(event) {
449
481
  event.stopPropagation();
450
482
  },
@@ -456,16 +488,17 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
456
488
  maxLength: maxLength,
457
489
  autoComplete: autocomplete === "off" ? "nope" : autocomplete,
458
490
  tabIndex: tabIndex,
459
- role: isTextInputType() && hasSuggestions() ? "combobox" : "textbox",
460
- "aria-autocomplete": isTextInputType() && hasSuggestions() ? "list" : undefined,
461
- "aria-controls": isTextInputType() && hasSuggestions() ? autosuggestId : undefined,
462
- "aria-disabled": disabled,
463
- "aria-expanded": isTextInputType() && hasSuggestions() ? isOpen : undefined,
464
- "aria-activedescendant": isTextInputType() && hasSuggestions() && isOpen && visualFocusIndex !== -1 ? "suggestion-".concat(visualFocusIndex) : undefined,
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,
465
498
  "aria-invalid": error ? true : false,
466
499
  "aria-errormessage": error ? errorId : undefined,
467
500
  "aria-required": optional ? false : true
468
- }), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
501
+ })), !disabled && error && /*#__PURE__*/_react["default"].createElement(ErrorIcon, {
469
502
  backgroundType: backgroundType,
470
503
  "aria-label": "Error"
471
504
  }, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
@@ -476,7 +509,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
476
509
  backgroundType: backgroundType,
477
510
  tabIndex: tabIndex,
478
511
  title: translatedLabels.textInput.clearFieldActionTitle,
479
- "aria-label": translatedLabels.textInput.clearFieldActionTitle
512
+ "aria-label": translatedLabels.textInput.clearFieldActionTitle,
513
+ type: "button"
480
514
  }, _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, {
481
515
  ref: actionRef,
482
516
  disabled: disabled,
@@ -487,7 +521,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
487
521
  backgroundType: backgroundType,
488
522
  tabIndex: tabIndex,
489
523
  title: translatedLabels.numberInput.decrementValueTitle,
490
- "aria-label": translatedLabels.numberInput.decrementValueTitle
524
+ "aria-label": translatedLabels.numberInput.decrementValueTitle,
525
+ type: "button"
491
526
  }, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
492
527
  ref: actionRef,
493
528
  disabled: disabled,
@@ -498,7 +533,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
498
533
  backgroundType: backgroundType,
499
534
  tabIndex: tabIndex,
500
535
  title: translatedLabels.numberInput.incrementValueTitle,
501
- "aria-label": translatedLabels.numberInput.incrementValueTitle
536
+ "aria-label": translatedLabels.numberInput.incrementValueTitle,
537
+ type: "button"
502
538
  }, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
503
539
  ref: actionRef,
504
540
  disabled: disabled,
@@ -509,36 +545,14 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
509
545
  title: action.title,
510
546
  "aria-label": action.title,
511
547
  backgroundType: backgroundType,
512
- tabIndex: tabIndex
548
+ tabIndex: tabIndex,
549
+ type: "button"
513
550
  }, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
514
551
  src: action.icon
515
552
  }) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
516
553
  disabled: disabled,
517
554
  backgroundType: backgroundType
518
- }, suffix))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
519
- sideOffset: 4,
520
- onOpenAutoFocus: function onOpenAutoFocus(event) {
521
- // Avoid select to lose focus when the list is opened
522
- event.preventDefault();
523
- },
524
- onCloseAutoFocus: function onCloseAutoFocus(event) {
525
- // Avoid select to lose focus when the list is closed
526
- event.preventDefault();
527
- }
528
- }, /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], {
529
- id: autosuggestId,
530
- value: value !== null && value !== void 0 ? value : innerValue,
531
- suggestions: filteredSuggestions,
532
- visualFocusIndex: visualFocusIndex,
533
- highlightedSuggestions: typeof suggestions !== "function",
534
- searchHasErrors: isAutosuggestError,
535
- isSearching: isSearching,
536
- suggestionOnClick: function suggestionOnClick(suggestion) {
537
- changeValue(suggestion);
538
- closeSuggestions();
539
- },
540
- getTextInputWidth: getTextInputWidth
541
- }))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
555
+ }, suffix)), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
542
556
  id: errorId,
543
557
  backgroundType: backgroundType,
544
558
  "aria-live": error ? "assertive" : "off"
@@ -602,7 +616,7 @@ var InputContainer = _styledComponents["default"].div(_templateObject5 || (_temp
602
616
  }, function (props) {
603
617
  return props.disabled && "cursor: not-allowed;";
604
618
  }, function (props) {
605
- 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 ");
619
+ 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 ");
606
620
  });
607
621
 
608
622
  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) {