@dxc-technology/halstack-react 0.0.0-92f4a00 → 0.0.0-9427b76

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.
@@ -35,9 +35,29 @@ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColor
35
35
 
36
36
  var _NumberContext = _interopRequireDefault(require("../number/NumberContext.js"));
37
37
 
38
- function _templateObject15() {
38
+ function _templateObject17() {
39
39
  var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: calc((39px - 1.75em) / 2) 0 calc((39px - 1.75em) / 2) 1em;\n align-items: center;\n font-size: 0.875rem;\n line-height: 1.75em;\n"]);
40
40
 
41
+ _templateObject17 = function _templateObject17() {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ function _templateObject16() {
49
+ var data = (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\n svg {\n line-height: 1.75em;\n font-size: 0.875rem;\n }\n"]);
50
+
51
+ _templateObject16 = function _templateObject16() {
52
+ return data;
53
+ };
54
+
55
+ return data;
56
+ }
57
+
58
+ function _templateObject15() {
59
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: calc((39px - 1.75em) / 2) 0 calc((39px - 1.75em) / 2) 1em;\n color: ", ";\n font-size: 0.875rem;\n line-height: 1.75em;\n"]);
60
+
41
61
  _templateObject15 = function _templateObject15() {
42
62
  return data;
43
63
  };
@@ -46,7 +66,7 @@ function _templateObject15() {
46
66
  }
47
67
 
48
68
  function _templateObject14() {
49
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: calc((39px - 1.75em) / 2) 0 calc((39px - 1.75em) / 2) 1em;\n color: ", ";\n font-size: 0.875rem;\n line-height: 1.75em;\n"]);
69
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n padding: calc((39px - 1.75em) / 2) 0 calc((39px - 1.75em) / 2) 1em;\n line-height: 1.75em;\n list-style-type: none;\n cursor: pointer;\n\n ", "\n"]);
50
70
 
51
71
  _templateObject14 = function _templateObject14() {
52
72
  return data;
@@ -56,7 +76,7 @@ function _templateObject14() {
56
76
  }
57
77
 
58
78
  function _templateObject13() {
59
- var data = (0, _taggedTemplateLiteral2["default"])(["\n padding: calc((39px - 1.75em) / 2) 0 calc((39px - 1.75em) / 2) 1em;\n line-height: 1.75em;\n list-style-type: none;\n cursor: pointer;\n\n ", "\n"]);
79
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n position: absolute;\n z-index: 1;\n max-height: 160px;\n overflow: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 0;\n width: 100%;\n box-sizing: border-box;\n cursor: default;\n border-radius: 4px;\n border: 1px solid ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"]);
60
80
 
61
81
  _templateObject13 = function _templateObject13() {
62
82
  return data;
@@ -66,7 +86,7 @@ function _templateObject13() {
66
86
  }
67
87
 
68
88
  function _templateObject12() {
69
- var data = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n position: absolute;\n z-index: 1;\n max-height: 160px;\n overflow: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 0;\n width: 100%;\n box-sizing: border-box;\n cursor: default;\n border-radius: 4px;\n border: 1px solid ", ";\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"]);
89
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n"]);
70
90
 
71
91
  _templateObject12 = function _templateObject12() {
72
92
  return data;
@@ -76,7 +96,7 @@ function _templateObject12() {
76
96
  }
77
97
 
78
98
  function _templateObject11() {
79
- var data = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n"]);
99
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n padding: 3px;\n height: 18px;\n width: 18px;\n margin-left: calc(1rem * 0.25);\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"]);
80
100
 
81
101
  _templateObject11 = function _templateObject11() {
82
102
  return data;
@@ -86,7 +106,7 @@ function _templateObject11() {
86
106
  }
87
107
 
88
108
  function _templateObject10() {
89
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n padding: 3px;\n height: 18px;\n width: 18px;\n margin-left: calc(1rem * 0.25);\n pointer-events: none;\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"]);
109
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n height: calc(1rem * 1.5);\n line-height: calc(1rem * 1.5);\n margin: 0 calc(1rem * 0.25);\n padding: 0 0 0 calc(1rem * 0.5);\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"]);
90
110
 
91
111
  _templateObject10 = function _templateObject10() {
92
112
  return data;
@@ -96,7 +116,7 @@ function _templateObject10() {
96
116
  }
97
117
 
98
118
  function _templateObject9() {
99
- var data = (0, _taggedTemplateLiteral2["default"])(["\n height: calc(1rem * 1.5);\n line-height: calc(1rem * 1.5);\n margin: 0 calc(1rem * 0.25);\n padding: 0 0 0 calc(1rem * 0.5);\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"]);
119
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n height: calc(1rem * 1.5);\n line-height: calc(1rem * 1.5);\n margin-left: calc(1rem * 0.25);\n padding: 0 calc(1rem * 0.5) 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"]);
100
120
 
101
121
  _templateObject9 = function _templateObject9() {
102
122
  return data;
@@ -106,7 +126,7 @@ function _templateObject9() {
106
126
  }
107
127
 
108
128
  function _templateObject8() {
109
- var data = (0, _taggedTemplateLiteral2["default"])(["\n height: calc(1rem * 1.5);\n line-height: calc(1rem * 1.5);\n margin-left: calc(1rem * 0.25);\n padding: 0 calc(1rem * 0.5) 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"]);
129
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n border-radius: 4px;\n padding: 3px;\n margin-left: calc(1rem * 0.25);\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n background-color: ", ";\n\n color: ", ";\n\n ", "\n\n svg {\n line-height: 18px;\n }\n"]);
110
130
 
111
131
  _templateObject8 = function _templateObject8() {
112
132
  return data;
@@ -116,7 +136,7 @@ function _templateObject8() {
116
136
  }
117
137
 
118
138
  function _templateObject7() {
119
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 24px;\n width: 24px;\n font-size: 1rem;\n font-family: ", ";\n border: 1px solid transparent;\n border-radius: 4px;\n padding: 3px;\n margin-left: calc(1rem * 0.25);\n ", "\n\n background-color: ", ";\n\n color: ", ";\n\n ", "\n\n svg {\n line-height: 18px;\n }\n"]);
139
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n width: 16px;\n height: 16px;\n"]);
120
140
 
121
141
  _templateObject7 = function _templateObject7() {
122
142
  return data;
@@ -136,7 +156,7 @@ function _templateObject6() {
136
156
  }
137
157
 
138
158
  function _templateObject5() {
139
- var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n position: relative;\n align-items: center;\n height: calc(calc(1rem * 2.5) - calc(1px * 2));\n margin: calc(1rem * 0.25) 0;\n padding: 0 calc(1rem * 0.5);\n\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n\n ", ";\n ", ";\n"]);
159
+ var data = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n position: relative;\n align-items: center;\n height: calc(calc(1rem * 2.5) - calc(1px * 2));\n margin: calc(1rem * 0.25) 0;\n padding: 0 calc(1rem * 0.5);\n\n ", "\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n ", ";\n\n ", ";\n"]);
140
160
 
141
161
  _templateObject5 = function _templateObject5() {
142
162
  return data;
@@ -206,18 +226,22 @@ var makeCancelable = function makeCancelable(promise) {
206
226
  };
207
227
  };
208
228
 
209
- var getLengthErrorMessage = function getLengthErrorMessage(length) {
210
- return "Min length ".concat(length.min, ", max length ").concat(length.max, ".");
229
+ var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
230
+ return "This field is required. Please, enter a value.";
211
231
  };
212
232
 
213
- var patternMatch = function patternMatch(pattern, value) {
214
- return new RegExp(pattern).test(value);
233
+ var getLengthErrorMessage = function getLengthErrorMessage(length) {
234
+ return "Min length ".concat(length.min, ", max length ").concat(length.max, ".");
215
235
  };
216
236
 
217
237
  var getPatternErrorMessage = function getPatternErrorMessage() {
218
238
  return "Please match the format requested.";
219
239
  };
220
240
 
241
+ var patternMatch = function patternMatch(pattern, value) {
242
+ return new RegExp(pattern).test(value);
243
+ };
244
+
221
245
  var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
222
246
  var _ref$label = _ref.label,
223
247
  label = _ref$label === void 0 ? "" : _ref$label,
@@ -243,14 +267,14 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
243
267
  onBlur = _ref.onBlur,
244
268
  _ref$error = _ref.error,
245
269
  error = _ref$error === void 0 ? "" : _ref$error,
246
- margin = _ref.margin,
247
- _ref$size = _ref.size,
248
- size = _ref$size === void 0 ? "medium" : _ref$size,
249
270
  suggestions = _ref.suggestions,
250
271
  pattern = _ref.pattern,
251
272
  length = _ref.length,
252
273
  _ref$autocomplete = _ref.autocomplete,
253
274
  autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
275
+ margin = _ref.margin,
276
+ _ref$size = _ref.size,
277
+ size = _ref$size === void 0 ? "medium" : _ref$size,
254
278
  _ref$tabIndex = _ref.tabIndex,
255
279
  tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
256
280
 
@@ -271,53 +295,28 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
271
295
 
272
296
  var _useState7 = (0, _react.useState)(false),
273
297
  _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
274
- isError = _useState8[0],
275
- changeIsError = _useState8[1];
298
+ isScrollable = _useState8[0],
299
+ changeIsScrollable = _useState8[1];
276
300
 
277
301
  var _useState9 = (0, _react.useState)(false),
278
302
  _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
279
- isScrollable = _useState10[0],
280
- changeIsScrollable = _useState10[1];
303
+ isActiveSuggestion = _useState10[0],
304
+ changeIsActiveSuggestion = _useState10[1];
281
305
 
282
306
  var _useState11 = (0, _react.useState)(false),
283
307
  _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
284
- isActiveSuggestion = _useState12[0],
285
- changeIsActiveSuggestion = _useState12[1];
308
+ isAutosuggestError = _useState12[0],
309
+ changeIsAutosuggestError = _useState12[1];
286
310
 
287
- var _useState13 = (0, _react.useState)(false),
311
+ var _useState13 = (0, _react.useState)([]),
288
312
  _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
289
- isAutosuggestError = _useState14[0],
290
- changeIsAutosuggestError = _useState14[1];
313
+ filteredSuggestions = _useState14[0],
314
+ changeFilteredSuggestions = _useState14[1];
291
315
 
292
- var _useState15 = (0, _react.useState)(""),
316
+ var _useState15 = (0, _react.useState)(-1),
293
317
  _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
294
- validationError = _useState16[0],
295
- changeValidationError = _useState16[1];
296
-
297
- var _useState17 = (0, _react.useState)([]),
298
- _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
299
- filteredSuggestions = _useState18[0],
300
- changeFilteredSuggestions = _useState18[1];
301
-
302
- var _useState19 = (0, _react.useState)(-1),
303
- _useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
304
- visualFocusedSuggIndex = _useState20[0],
305
- changeVisualFocusedSuggIndex = _useState20[1];
306
-
307
- var _useState21 = (0, _react.useState)(null),
308
- _useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
309
- minNumber = _useState22[0],
310
- setMinNumber = _useState22[1];
311
-
312
- var _useState23 = (0, _react.useState)(null),
313
- _useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
314
- maxNumber = _useState24[0],
315
- setMaxNumber = _useState24[1];
316
-
317
- var _useState25 = (0, _react.useState)(null),
318
- _useState26 = (0, _slicedToArray2["default"])(_useState25, 2),
319
- stepNumber = _useState26[0],
320
- setStepNumber = _useState26[1];
318
+ visualFocusedSuggIndex = _useState16[0],
319
+ changeVisualFocusedSuggIndex = _useState16[1];
321
320
 
322
321
  var suggestionsRef = (0, _react.useRef)(null);
323
322
  var inputRef = (0, _react.useRef)(null);
@@ -326,12 +325,11 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
326
325
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
327
326
  var inputId = "input-".concat((0, _uuid.v4)());
328
327
  var autosuggestId = "".concat(inputId, "-listBox");
328
+ var errorId = "error-message-".concat(inputId);
329
329
  var numberContext = (0, _react.useContext)(_NumberContext["default"]);
330
330
 
331
- var changeValue = function changeValue(newValue) {
332
- var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
333
- value !== null && value !== void 0 ? value : setInnerValue(newValue);
334
- typeof onChange === "function" && onChange(changedValue);
331
+ var isNotOptional = function isNotOptional(value) {
332
+ return value === "" && !optional;
335
333
  };
336
334
 
337
335
  var isLengthIncorrect = function isLengthIncorrect(value) {
@@ -339,15 +337,17 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
339
337
  };
340
338
 
341
339
  var isNumberIncorrect = function isNumberIncorrect(value) {
342
- return minNumber && parseInt(value) < minNumber || maxNumber && parseInt(value) > maxNumber;
340
+ return (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber) && parseInt(value) < (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber) || (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber) && parseInt(value) > (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber);
341
+ };
342
+
343
+ var isTextInputType = function isTextInputType() {
344
+ var _inputRef$current, _inputRef$current2;
345
+
346
+ 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";
343
347
  };
344
348
 
345
349
  var getNumberErrorMessage = function getNumberErrorMessage(value) {
346
- if (minNumber && parseInt(value) < minNumber) {
347
- return "Value must be greater than or equal to ".concat(minNumber, ".");
348
- } else if (maxNumber && parseInt(value) > maxNumber) {
349
- return "Value must be less than or equal to ".concat(maxNumber, ".");
350
- }
350
+ if (numberContext !== null && numberContext !== void 0 && numberContext.minNumber && parseInt(value) < (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber)) return "Value must be greater than or equal to ".concat(numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber, ".");else if (numberContext !== null && numberContext !== void 0 && numberContext.maxNumber && parseInt(value) > (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber)) return "Value must be less than or equal to ".concat(numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber, ".");
351
351
  };
352
352
 
353
353
  var hasInputSuggestions = function hasInputSuggestions() {
@@ -363,6 +363,27 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
363
363
  changeVisualFocusedSuggIndex(-1);
364
364
  };
365
365
 
366
+ var changeValue = function changeValue(newValue) {
367
+ value !== null && value !== void 0 ? value : setInnerValue(newValue);
368
+ var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
369
+ if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
370
+ value: changedValue,
371
+ error: getNotOptionalErrorMessage()
372
+ });else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
373
+ value: changedValue,
374
+ error: getLengthErrorMessage(length)
375
+ });else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
376
+ value: changedValue,
377
+ error: getPatternErrorMessage()
378
+ });else if (newValue && isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
379
+ value: changedValue,
380
+ error: getNumberErrorMessage(newValue)
381
+ });else onChange === null || onChange === void 0 ? void 0 : onChange({
382
+ value: changedValue,
383
+ error: null
384
+ });
385
+ };
386
+
366
387
  var handleInputContainerOnClick = function handleInputContainerOnClick() {
367
388
  document.activeElement !== actionRef.current && inputRef.current.focus();
368
389
  };
@@ -378,36 +399,22 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
378
399
 
379
400
  var handleIOnBlur = function handleIOnBlur(event) {
380
401
  suggestions && closeSuggestions();
381
-
382
- if (isLengthIncorrect(event.target.value)) {
383
- changeIsError(true);
384
- changeValidationError(getLengthErrorMessage(length, event));
385
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({
386
- value: event.target.value,
387
- error: getLengthErrorMessage(length)
388
- });
389
- } else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) {
390
- changeIsError(true);
391
- changeValidationError(getPatternErrorMessage());
392
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({
393
- value: event.target.value,
394
- error: getPatternErrorMessage()
395
- });
396
- } else if (event.target.value && isNumberIncorrect(event.target.value)) {
397
- changeIsError(true);
398
- changeValidationError(getNumberErrorMessage(event.target.value));
399
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({
400
- value: event.target.value,
401
- error: getNumberErrorMessage(event.target.value)
402
- });
403
- } else {
404
- changeIsError(false);
405
- changeValidationError("");
406
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({
407
- value: event.target.value,
408
- error: null
409
- });
410
- }
402
+ if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
403
+ value: event.target.value,
404
+ error: getNotOptionalErrorMessage()
405
+ });else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
406
+ value: event.target.value,
407
+ error: getLengthErrorMessage(length)
408
+ });else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
409
+ value: event.target.value,
410
+ error: getPatternErrorMessage()
411
+ });else if (event.target.value && isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
412
+ value: event.target.value,
413
+ error: getNumberErrorMessage(event.target.value)
414
+ });else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
415
+ value: event.target.value,
416
+ error: null
417
+ });
411
418
  };
412
419
 
413
420
  var handleIOnFocus = function handleIOnFocus() {
@@ -480,15 +487,12 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
480
487
  };
481
488
 
482
489
  var setNumberProps = function setNumberProps(type, min, max, step) {
483
- var _inputRef$current, _inputRef$current2, _inputRef$current3, _inputRef$current4;
490
+ var _inputRef$current3, _inputRef$current4, _inputRef$current5, _inputRef$current6;
484
491
 
485
- type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.setAttribute("type", type));
486
- min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("min", min));
487
- max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("max", max));
488
- step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("step", step));
489
- setMinNumber(min);
490
- setMaxNumber(max);
491
- setStepNumber(step);
492
+ type && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("type", type));
493
+ min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("min", min));
494
+ max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("max", max));
495
+ step && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : _inputRef$current6.setAttribute("step", step));
492
496
  };
493
497
 
494
498
  (0, _react.useLayoutEffect)(function () {
@@ -500,8 +504,6 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
500
504
  return changeIsScrollable(false);
501
505
  }, [isScrollable, visualFocusedSuggIndex]);
502
506
  (0, _react.useEffect)(function () {
503
- var _inputRef$current5;
504
-
505
507
  if (typeof suggestions === "function") {
506
508
  changeIsSearching(true);
507
509
  changeIsAutosuggestError(false);
@@ -528,9 +530,6 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
528
530
  }
529
531
 
530
532
  numberContext && setNumberProps(numberContext.typeNumber, numberContext.minNumber, numberContext.maxNumber, numberContext.stepNumber);
531
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.addEventListener("wheel", function (event) {
532
- return event.preventDefault();
533
- });
534
533
  }, [value, innerValue, suggestions]);
535
534
  var defaultClearAction = {
536
535
  onClick: function onClick() {
@@ -563,18 +562,18 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
563
562
  }));
564
563
 
565
564
  var decrementNumber = function decrementNumber() {
566
- var numberValue = value || innerValue;
565
+ var numberValue = value !== null && value !== void 0 ? value : innerValue;
567
566
 
568
- if (minNumber && parseInt(numberValue) < minNumber) {
567
+ if (numberContext !== null && numberContext !== void 0 && numberContext.minNumber && parseInt(numberValue) < (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber)) {
569
568
  changeValue(parseInt(numberValue));
570
- } else if (maxNumber && parseInt(numberValue) > maxNumber) {
571
- changeValue(maxNumber);
572
- } else if (minNumber && (parseInt(numberValue) === minNumber || numberValue === "" || stepNumber && parseInt(numberValue) - stepNumber < minNumber)) {
573
- changeValue(minNumber);
574
- } else if (stepNumber && minNumber && parseInt(numberValue) - stepNumber >= minNumber || stepNumber && numberValue !== "") {
575
- changeValue(parseInt(numberValue) - stepNumber);
576
- } else if (stepNumber && numberValue == "") {
577
- changeValue(-stepNumber);
569
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.maxNumber && parseInt(numberValue) > (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber)) {
570
+ changeValue(numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber);
571
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.minNumber && (parseInt(numberValue) === (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber) || numberValue === "" || numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && parseInt(numberValue) - (numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber) < (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber))) {
572
+ changeValue(numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber);
573
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && numberContext !== null && numberContext !== void 0 && numberContext.minNumber && parseInt(numberValue) - (numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber) >= (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber) || numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && numberValue !== "") {
574
+ changeValue(parseInt(numberValue) - (numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber));
575
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && numberValue == "") {
576
+ changeValue(-(numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber));
578
577
  } else if (numberValue === "") {
579
578
  changeValue(-1);
580
579
  } else {
@@ -583,18 +582,18 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
583
582
  };
584
583
 
585
584
  var incrementNumber = function incrementNumber() {
586
- var numberValue = value || innerValue;
585
+ var numberValue = value !== null && value !== void 0 ? value : innerValue;
587
586
 
588
- if (maxNumber && parseInt(numberValue) > maxNumber) {
587
+ if (numberContext !== null && numberContext !== void 0 && numberContext.maxNumber && parseInt(numberValue) > (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber)) {
589
588
  changeValue(parseInt(numberValue));
590
- } else if (minNumber && (parseInt(numberValue) < minNumber || numberValue === "")) {
591
- changeValue(minNumber);
592
- } else if (maxNumber && (parseInt(numberValue) === maxNumber || stepNumber && parseInt(numberValue) + stepNumber > maxNumber)) {
593
- changeValue(maxNumber);
594
- } else if (stepNumber && maxNumber && parseInt(numberValue) + stepNumber <= maxNumber || stepNumber && numberValue !== "") {
595
- changeValue(parseInt(numberValue) + stepNumber);
596
- } else if (stepNumber && numberValue == "") {
597
- changeValue(stepNumber);
589
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.minNumber && (parseInt(numberValue) < (numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber) || numberValue === "")) {
590
+ changeValue(numberContext === null || numberContext === void 0 ? void 0 : numberContext.minNumber);
591
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.maxNumber && (parseInt(numberValue) === (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber) || numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && parseInt(numberValue) + (numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber) > (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber))) {
592
+ changeValue(numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber);
593
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && numberContext !== null && numberContext !== void 0 && numberContext.maxNumber && parseInt(numberValue) + (numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber) <= (numberContext === null || numberContext === void 0 ? void 0 : numberContext.maxNumber) || numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && numberValue !== "") {
594
+ changeValue(parseInt(numberValue) + (numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber));
595
+ } else if (numberContext !== null && numberContext !== void 0 && numberContext.stepNumber && numberValue == "") {
596
+ changeValue(numberContext === null || numberContext === void 0 ? void 0 : numberContext.stepNumber);
598
597
  } else if (numberValue === "") {
599
598
  changeValue(1);
600
599
  } else {
@@ -639,12 +638,6 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
639
638
  }))
640
639
  };
641
640
 
642
- var isTextInputType = function isTextInputType() {
643
- var _inputRef$current6, _inputRef$current7;
644
-
645
- return !(inputRef !== null && inputRef !== void 0 && (_inputRef$current6 = inputRef.current) !== null && _inputRef$current6 !== void 0 && _inputRef$current6.getAttribute("type")) || (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : _inputRef$current7.getAttribute("type")) === "text";
646
- };
647
-
648
641
  var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
649
642
  var suggestion = _ref2.suggestion,
650
643
  index = _ref2.index;
@@ -690,7 +683,7 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
690
683
  disabled: disabled,
691
684
  backgroundType: backgroundType
692
685
  }, helperText), _react["default"].createElement(InputContainer, {
693
- error: error || validationError,
686
+ error: error,
694
687
  disabled: disabled,
695
688
  backgroundType: backgroundType,
696
689
  onClick: handleInputContainerOnClick
@@ -711,14 +704,19 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
711
704
  ref: inputRef,
712
705
  backgroundType: backgroundType,
713
706
  pattern: pattern,
707
+ minLength: length === null || length === void 0 ? void 0 : length.min,
708
+ maxLength: length === null || length === void 0 ? void 0 : length.max,
714
709
  autoComplete: autocomplete,
715
710
  tabIndex: tabIndex,
716
711
  role: isTextInputType() && hasInputSuggestions() ? "combobox" : "textbox",
717
712
  "aria-autocomplete": isTextInputType() && hasInputSuggestions() ? "list" : undefined,
718
713
  "aria-controls": isTextInputType() && hasInputSuggestions() ? inputId : undefined,
719
714
  "aria-expanded": isTextInputType() && hasInputSuggestions() ? isOpen ? "true" : "false" : undefined,
720
- "aria-activedescendant": isTextInputType() && hasInputSuggestions() && isOpen && visualFocusedSuggIndex !== -1 ? "suggestion-".concat(visualFocusedSuggIndex) : undefined
721
- }), (error || isError) && _react["default"].createElement(ErrorIcon, {
715
+ "aria-activedescendant": isTextInputType() && hasInputSuggestions() && isOpen && visualFocusedSuggIndex !== -1 ? "suggestion-".concat(visualFocusedSuggIndex) : undefined,
716
+ "aria-invalid": error ? "true" : "false",
717
+ "aria-describedby": error ? errorId : undefined,
718
+ "aria-required": optional ? "false" : "true"
719
+ }), !disabled && error && _react["default"].createElement(ErrorIcon, {
722
720
  backgroundType: backgroundType,
723
721
  "aria-label": "Error"
724
722
  }, errorIcon), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && _react["default"].createElement(Action, {
@@ -746,7 +744,9 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
746
744
  onClick: action.onClick,
747
745
  backgroundType: backgroundType,
748
746
  tabIndex: tabIndex
749
- }, action.icon), suffix && _react["default"].createElement(Suffix, {
747
+ }, typeof action.icon === "string" ? _react["default"].createElement(ActionIcon, {
748
+ src: action.icon
749
+ }) : action.icon), suffix && _react["default"].createElement(Suffix, {
750
750
  disabled: disabled,
751
751
  backgroundType: backgroundType
752
752
  }, suffix), isOpen && _react["default"].createElement(Suggestions, {
@@ -767,11 +767,12 @@ var DxcNewInputText = _react["default"].forwardRef(function (_ref, ref) {
767
767
  suggestion: suggestion,
768
768
  index: index
769
769
  });
770
- }), isSearching && _react["default"].createElement(SuggestionsSystemMessage, null, "Searching..."), isAutosuggestError && _react["default"].createElement(SuggestionsError, null, _react["default"].createElement(ErrorIcon, {
770
+ }), isSearching && _react["default"].createElement(SuggestionsSystemMessage, null, "Searching..."), isAutosuggestError && _react["default"].createElement(SuggestionsError, null, _react["default"].createElement(SuggestionsErrorIcon, {
771
771
  backgroundType: backgroundType
772
- }, errorIcon), "Error fetching data"))), _react["default"].createElement(Error, {
772
+ }, errorIcon), "Error fetching data"))), !disabled && _react["default"].createElement(Error, {
773
+ id: errorId,
773
774
  backgroundType: backgroundType
774
- }, error || validationError)));
775
+ }, error)));
775
776
  });
776
777
 
777
778
  var sizes = {
@@ -855,7 +856,9 @@ var Input = _styledComponents["default"].input(_templateObject6(), function (pro
855
856
  return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPlaceholderFontColorOnDark : props.theme.disabledPlaceholderFontColor : props.backgroundType === "dark" ? props.theme.placeholderFontColorOnDark : props.theme.placeholderFontColor;
856
857
  });
857
858
 
858
- var Action = _styledComponents["default"].button(_templateObject7(), function (props) {
859
+ var ActionIcon = _styledComponents["default"].img(_templateObject7());
860
+
861
+ var Action = _styledComponents["default"].button(_templateObject8(), function (props) {
859
862
  return props.theme.fontFamily;
860
863
  }, function (props) {
861
864
  return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
@@ -867,31 +870,31 @@ var Action = _styledComponents["default"].button(_templateObject7(), function (p
867
870
  return !props.disabled && "\n &:hover {\n background-color: ".concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
868
871
  });
869
872
 
870
- var Prefix = _styledComponents["default"].span(_templateObject8(), function (props) {
873
+ var Prefix = _styledComponents["default"].span(_templateObject9(), function (props) {
871
874
  var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPrefixColorOnDark : props.theme.disabledPrefixColor : props.backgroundType === "dark" ? props.theme.prefixColorOnDark : props.theme.prefixColor;
872
875
  return "color: ".concat(color, "; border-right: 1px solid ").concat(color, ";");
873
876
  }, function (props) {
874
877
  return props.theme.fontFamily;
875
878
  });
876
879
 
877
- var Suffix = _styledComponents["default"].span(_templateObject9(), function (props) {
880
+ var Suffix = _styledComponents["default"].span(_templateObject10(), function (props) {
878
881
  var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledSuffixColorOnDark : props.theme.disabledSuffixColor : props.backgroundType === "dark" ? props.theme.suffixColorOnDark : props.theme.suffixColor;
879
882
  return "color: ".concat(color, "; border-left: 1px solid ").concat(color, ";");
880
883
  }, function (props) {
881
884
  return props.theme.fontFamily;
882
885
  });
883
886
 
884
- var ErrorIcon = _styledComponents["default"].span(_templateObject10(), function (props) {
887
+ var ErrorIcon = _styledComponents["default"].span(_templateObject11(), function (props) {
885
888
  return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
886
889
  });
887
890
 
888
- var Error = _styledComponents["default"].span(_templateObject11(), function (props) {
891
+ var Error = _styledComponents["default"].span(_templateObject12(), function (props) {
889
892
  return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
890
893
  }, function (props) {
891
894
  return props.theme.fontFamily;
892
895
  });
893
896
 
894
- var Suggestions = _styledComponents["default"].ul(_templateObject12(), function (props) {
897
+ var Suggestions = _styledComponents["default"].ul(_templateObject13(), function (props) {
895
898
  return props.isError ? props.theme.errorMessageBackgroundColor : "#ffffff";
896
899
  }, function (props) {
897
900
  return props.isError ? props.theme.errorMessageBorderColor : props.theme.enabledBorderColor;
@@ -907,15 +910,19 @@ var Suggestions = _styledComponents["default"].ul(_templateObject12(), function
907
910
  return props.theme.listOptionFontWeight;
908
911
  });
909
912
 
910
- var Suggestion = _styledComponents["default"].li(_templateObject13(), function (props) {
913
+ var Suggestion = _styledComponents["default"].li(_templateObject14(), function (props) {
911
914
  return props.active ? "background-color: ".concat(props.theme.activeListOptionBackgroundColor, ";") : props.visualFocused && "background-color: ".concat(props.theme.hoverListOptionBackgroundColor, ";");
912
915
  });
913
916
 
914
- var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject14(), function (props) {
917
+ var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject15(), function (props) {
915
918
  return props.theme.systemMessageFontColor;
916
919
  });
917
920
 
918
- var SuggestionsError = _styledComponents["default"].span(_templateObject15());
921
+ var SuggestionsErrorIcon = _styledComponents["default"].span(_templateObject16(), function (props) {
922
+ return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
923
+ });
924
+
925
+ var SuggestionsError = _styledComponents["default"].span(_templateObject17());
919
926
 
920
927
  DxcNewInputText.propTypes = {
921
928
  label: _propTypes["default"].string,
@@ -925,19 +932,15 @@ DxcNewInputText.propTypes = {
925
932
  placeholder: _propTypes["default"].string,
926
933
  action: _propTypes["default"].shape({
927
934
  onClick: _propTypes["default"].func.isRequired,
928
- icon: _propTypes["default"].shape({
935
+ icon: _propTypes["default"].oneOfType([_propTypes["default"].shape({
929
936
  type: _propTypes["default"].oneOf(["svg"])
930
- }).isRequired
937
+ }), _propTypes["default"].string]).isRequired
931
938
  }),
932
939
  clearable: _propTypes["default"].bool,
933
940
  disabled: _propTypes["default"].bool,
934
941
  optional: _propTypes["default"].bool,
935
- prefix: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape({
936
- type: _propTypes["default"].oneOf(["svg"])
937
- })]),
938
- suffix: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape({
939
- type: _propTypes["default"].oneOf(["svg"])
940
- })]),
942
+ prefix: _propTypes["default"].string,
943
+ suffix: _propTypes["default"].string,
941
944
  onChange: _propTypes["default"].func,
942
945
  onBlur: _propTypes["default"].func,
943
946
  error: _propTypes["default"].string,