@dxc-technology/halstack-react 0.0.0-c25d3b6 → 0.0.0-c2834c3

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 (104) hide show
  1. package/HalstackContext.d.ts +12 -0
  2. package/HalstackContext.js +298 -0
  3. package/accordion/Accordion.d.ts +1 -1
  4. package/accordion/Accordion.js +7 -28
  5. package/accordion/Accordion.stories.tsx +11 -11
  6. package/accordion/Accordion.test.js +19 -4
  7. package/accordion/types.d.ts +4 -0
  8. package/accordion-group/AccordionGroup.d.ts +1 -1
  9. package/accordion-group/AccordionGroup.js +13 -15
  10. package/accordion-group/AccordionGroup.stories.tsx +1 -1
  11. package/accordion-group/AccordionGroup.test.js +24 -6
  12. package/accordion-group/types.d.ts +4 -0
  13. package/alert/Alert.js +4 -1
  14. package/button/Button.js +14 -11
  15. package/card/Card.js +27 -28
  16. package/checkbox/Checkbox.d.ts +1 -1
  17. package/checkbox/Checkbox.js +43 -39
  18. package/checkbox/Checkbox.stories.tsx +124 -128
  19. package/checkbox/Checkbox.test.js +13 -0
  20. package/checkbox/types.d.ts +7 -3
  21. package/common/variables.js +181 -70
  22. package/date-input/DateInput.js +38 -20
  23. package/date-input/DateInput.test.js +9 -22
  24. package/date-input/types.d.ts +12 -9
  25. package/dialog/Dialog.js +4 -32
  26. package/dropdown/Dropdown.js +13 -17
  27. package/file-input/FileInput.js +9 -6
  28. package/file-input/FileItem.js +7 -5
  29. package/footer/Footer.js +15 -88
  30. package/header/Header.js +27 -48
  31. package/header/Header.stories.tsx +46 -36
  32. package/header/Header.test.js +18 -2
  33. package/inset/types.d.ts +24 -0
  34. package/layout/ApplicationLayout.js +5 -18
  35. package/link/Link.d.ts +3 -2
  36. package/link/Link.js +65 -56
  37. package/link/Link.stories.tsx +87 -52
  38. package/link/Link.test.js +7 -15
  39. package/link/types.d.ts +8 -23
  40. package/main.d.ts +3 -2
  41. package/main.js +19 -5
  42. package/number-input/NumberInput.test.js +2 -4
  43. package/number-input/types.d.ts +13 -10
  44. package/package.json +6 -5
  45. package/paginator/Paginator.js +17 -38
  46. package/password-input/PasswordInput.js +7 -4
  47. package/password-input/PasswordInput.test.js +3 -6
  48. package/password-input/types.d.ts +14 -11
  49. package/quick-nav/QuickNav.d.ts +4 -0
  50. package/quick-nav/QuickNav.js +116 -0
  51. package/quick-nav/QuickNav.stories.tsx +237 -0
  52. package/quick-nav/types.d.ts +21 -0
  53. package/quick-nav/types.js +5 -0
  54. package/radio/Radio.js +10 -11
  55. package/radio-group/Radio.js +1 -1
  56. package/radio-group/RadioGroup.js +8 -6
  57. package/row/types.d.ts +18 -0
  58. package/select/Listbox.d.ts +4 -0
  59. package/select/Listbox.js +152 -0
  60. package/select/Option.js +1 -1
  61. package/select/Select.js +53 -139
  62. package/select/Select.stories.tsx +14 -2
  63. package/select/Select.test.js +83 -42
  64. package/select/types.d.ts +33 -11
  65. package/slider/Slider.d.ts +1 -1
  66. package/slider/Slider.js +2 -1
  67. package/slider/Slider.stories.tsx +8 -8
  68. package/slider/Slider.test.js +31 -10
  69. package/slider/types.d.ts +4 -0
  70. package/spinner/Spinner.js +1 -1
  71. package/switch/Switch.d.ts +1 -1
  72. package/switch/Switch.js +35 -19
  73. package/switch/Switch.stories.tsx +14 -14
  74. package/switch/Switch.test.js +25 -0
  75. package/switch/types.d.ts +6 -2
  76. package/tabs/Tabs.d.ts +1 -1
  77. package/tabs/Tabs.js +9 -11
  78. package/tabs/Tabs.stories.tsx +0 -8
  79. package/tabs/Tabs.test.js +26 -9
  80. package/tabs/types.d.ts +4 -0
  81. package/tag/Tag.js +5 -8
  82. package/text-input/Suggestion.d.ts +4 -0
  83. package/text-input/Suggestion.js +55 -0
  84. package/text-input/TextInput.js +48 -76
  85. package/text-input/TextInput.test.js +22 -35
  86. package/text-input/types.d.ts +27 -12
  87. package/textarea/Textarea.js +12 -23
  88. package/textarea/Textarea.test.js +10 -20
  89. package/textarea/types.d.ts +14 -11
  90. package/toggle-group/ToggleGroup.d.ts +1 -1
  91. package/toggle-group/ToggleGroup.js +5 -4
  92. package/toggle-group/ToggleGroup.stories.tsx +4 -4
  93. package/toggle-group/ToggleGroup.test.js +35 -4
  94. package/toggle-group/types.d.ts +8 -0
  95. package/useTheme.js +2 -2
  96. package/useTranslatedLabels.d.ts +2 -0
  97. package/useTranslatedLabels.js +20 -0
  98. package/wizard/Wizard.d.ts +1 -1
  99. package/wizard/Wizard.js +55 -44
  100. package/wizard/Wizard.stories.tsx +13 -23
  101. package/wizard/Wizard.test.js +36 -23
  102. package/wizard/types.d.ts +6 -2
  103. package/ThemeContext.d.ts +0 -10
  104. package/ThemeContext.js +0 -243
@@ -21,6 +21,8 @@ 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");
@@ -31,7 +33,9 @@ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColor
31
33
 
32
34
  var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext"));
33
35
 
34
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
36
+ var _Suggestion = _interopRequireDefault(require("./Suggestion"));
37
+
38
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;
35
39
 
36
40
  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
41
 
@@ -205,6 +209,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
205
209
  var inputRef = (0, _react.useRef)(null);
206
210
  var actionRef = (0, _react.useRef)(null);
207
211
  var colorsTheme = (0, _useTheme["default"])();
212
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
208
213
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
209
214
  var autosuggestId = "".concat(inputId, "-listBox");
210
215
  var errorId = "error-".concat(inputId);
@@ -221,10 +226,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
221
226
  return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
222
227
  };
223
228
 
224
- var getLengthErrorMessage = function getLengthErrorMessage() {
225
- return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
226
- };
227
-
228
229
  var isNumberIncorrect = function isNumberIncorrect(value) {
229
230
  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
  };
@@ -236,7 +237,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
236
237
  };
237
238
 
238
239
  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, ".");
240
+ 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
241
  };
241
242
 
242
243
  var hasSuggestions = function hasSuggestions() {
@@ -257,19 +258,18 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
257
258
  var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
258
259
  if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
259
260
  value: changedValue,
260
- error: getNotOptionalErrorMessage()
261
+ error: translatedLabels.formFields.requiredValueErrorMessage
261
262
  });else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
262
263
  value: changedValue,
263
- error: getLengthErrorMessage()
264
+ error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
264
265
  });else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
265
266
  value: changedValue,
266
- error: getPatternErrorMessage()
267
+ error: translatedLabels.formFields.formatRequestedErrorMessage
267
268
  });else if (newValue && isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
268
269
  value: changedValue,
269
270
  error: getNumberErrorMessage(newValue)
270
271
  });else onChange === null || onChange === void 0 ? void 0 : onChange({
271
- value: changedValue,
272
- error: null
272
+ value: changedValue
273
273
  });
274
274
  };
275
275
 
@@ -291,19 +291,18 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
291
291
  suggestions && closeSuggestions();
292
292
  if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
293
293
  value: event.target.value,
294
- error: getNotOptionalErrorMessage()
294
+ error: translatedLabels.formFields.requiredValueErrorMessage
295
295
  });else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
296
296
  value: event.target.value,
297
- error: getLengthErrorMessage()
297
+ error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
298
298
  });else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
299
299
  value: event.target.value,
300
- error: getPatternErrorMessage()
300
+ error: translatedLabels.formFields.formatRequestedErrorMessage
301
301
  });else if (event.target.value && isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
302
302
  value: event.target.value,
303
303
  error: getNumberErrorMessage(event.target.value)
304
304
  });else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
305
- value: event.target.value,
306
- error: null
305
+ value: event.target.value
307
306
  });
308
307
  };
309
308
 
@@ -470,45 +469,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
470
469
 
471
470
  (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
472
471
  }, [value, innerValue, suggestions, numberInputContext]);
473
-
474
- var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
475
- var suggestion = _ref2.suggestion,
476
- index = _ref2.index;
477
- var regEx = new RegExp(value !== null && value !== void 0 ? value : innerValue, "i");
478
- var matchedWords = suggestion.match(regEx);
479
- var noMatchedWords = suggestion.replace(regEx, "");
480
- var isLastOption = index === lastOptionIndex;
481
- return /*#__PURE__*/_react["default"].createElement(Suggestion, {
482
- id: "suggestion-".concat(index),
483
- onClick: function onClick() {
484
- changeValue(suggestion);
485
- closeSuggestions();
486
- },
487
- visualFocused: visualFocusedSuggIndex === index,
488
- role: "option",
489
- "aria-selected": visualFocusedSuggIndex === index && "true"
490
- }, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
491
- last: isLastOption,
492
- visualFocused: visualFocusedSuggIndex === index
493
- }, typeof suggestions === "function" ? suggestion : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords)));
494
- };
495
-
496
472
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
497
473
  theme: colorsTheme.textInput
498
- }, /*#__PURE__*/_react["default"].createElement(DxcInput, {
474
+ }, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
499
475
  margin: margin,
500
- ref: ref,
501
- size: size
476
+ size: size,
477
+ ref: ref
502
478
  }, label && /*#__PURE__*/_react["default"].createElement(Label, {
503
479
  htmlFor: inputId,
504
480
  disabled: disabled,
505
481
  backgroundType: backgroundType,
506
- helperText: helperText
507
- }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, "(Optional)")), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
482
+ hasHelperText: helperText ? true : false
483
+ }, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
508
484
  disabled: disabled,
509
485
  backgroundType: backgroundType
510
486
  }, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
511
- error: error,
487
+ error: error ? true : false,
512
488
  disabled: disabled,
513
489
  backgroundType: backgroundType,
514
490
  onClick: handleInputContainerOnClick,
@@ -559,8 +535,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
559
535
  },
560
536
  backgroundType: backgroundType,
561
537
  tabIndex: tabIndex,
562
- title: "Clear field",
563
- "aria-label": "Clear field"
538
+ title: translatedLabels.textInput.clearFieldActionTitle,
539
+ "aria-label": translatedLabels.textInput.clearFieldActionTitle
564
540
  }, 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, {
565
541
  ref: actionRef,
566
542
  disabled: disabled,
@@ -572,8 +548,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
572
548
  },
573
549
  backgroundType: backgroundType,
574
550
  tabIndex: tabIndex,
575
- title: "Decrement value",
576
- "aria-label": "Decrement value"
551
+ title: translatedLabels.numberInput.decrementValueTitle,
552
+ "aria-label": translatedLabels.numberInput.decrementValueTitle
577
553
  }, textInputIcons.decrement), /*#__PURE__*/_react["default"].createElement(Action, {
578
554
  ref: actionRef,
579
555
  disabled: disabled,
@@ -585,8 +561,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
585
561
  },
586
562
  backgroundType: backgroundType,
587
563
  tabIndex: tabIndex,
588
- title: "Increment value",
589
- "aria-label": "Increment value"
564
+ title: translatedLabels.numberInput.incrementValueTitle,
565
+ "aria-label": translatedLabels.numberInput.incrementValueTitle
590
566
  }, textInputIcons.increment)) : action && /*#__PURE__*/_react["default"].createElement(Action, {
591
567
  ref: actionRef,
592
568
  disabled: disabled,
@@ -607,7 +583,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
607
583
  backgroundType: backgroundType
608
584
  }, suffix), isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError) && /*#__PURE__*/_react["default"].createElement(Suggestions, {
609
585
  id: autosuggestId,
610
- isError: isAutosuggestError,
586
+ error: isAutosuggestError ? true : false,
611
587
  onMouseDown: function onMouseDown(event) {
612
588
  event.preventDefault();
613
589
  },
@@ -615,14 +591,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
615
591
  role: "listbox",
616
592
  "aria-label": label
617
593
  }, !isSearching && !isAutosuggestError && filteredSuggestions.length > 0 && filteredSuggestions.map(function (suggestion, index) {
618
- return /*#__PURE__*/_react["default"].createElement(HighlightedSuggestion, {
619
- key: "suggestion-".concat((0, _uuid.v4)()),
594
+ return /*#__PURE__*/_react["default"].createElement(_Suggestion["default"], {
595
+ key: "suggestion-".concat(index),
596
+ id: "suggestion-".concat(index),
597
+ value: value !== null && value !== void 0 ? value : innerValue,
598
+ onClick: function onClick() {
599
+ changeValue(suggestion);
600
+ closeSuggestions();
601
+ },
620
602
  suggestion: suggestion,
621
- index: index
603
+ isLast: index === lastOptionIndex,
604
+ visuallyFocused: visualFocusedSuggIndex === index,
605
+ highlighted: typeof suggestions === "function"
622
606
  });
623
- }), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, "Searching..."), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
607
+ }), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, translatedLabels.textInput.searchingMessage), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
624
608
  backgroundType: backgroundType
625
- }, textInputIcons.error), "Error fetching data"))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
609
+ }, textInputIcons.error), translatedLabels.textInput.fetchingDataErrorMessage))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
626
610
  id: errorId,
627
611
  backgroundType: backgroundType,
628
612
  "aria-live": error ? "assertive" : "off"
@@ -640,7 +624,7 @@ var calculateWidth = function calculateWidth(margin, size) {
640
624
  return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
641
625
  };
642
626
 
643
- 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) {
627
+ 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) {
644
628
  return calculateWidth(props.margin, props.size);
645
629
  }, function (props) {
646
630
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
@@ -667,7 +651,7 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
667
651
  }, function (props) {
668
652
  return props.theme.labelLineHeight;
669
653
  }, function (props) {
670
- return !props.helperText && "margin-bottom: 0.25rem";
654
+ return !props.hasHelperText && "margin-bottom: 0.25rem";
671
655
  });
672
656
 
673
657
  var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
@@ -755,9 +739,9 @@ var Error = _styledComponents["default"].span(_templateObject12 || (_templateObj
755
739
  });
756
740
 
757
741
  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) {
758
- return props.isError ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
742
+ return props.error ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
759
743
  }, function (props) {
760
- return props.isError ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
744
+ return props.error ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
761
745
  }, function (props) {
762
746
  return props.theme.listOptionFontColor;
763
747
  }, function (props) {
@@ -770,27 +754,15 @@ var Suggestions = _styledComponents["default"].ul(_templateObject13 || (_templat
770
754
  return props.theme.listOptionFontWeight;
771
755
  });
772
756
 
773
- 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) {
774
- return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
775
- }, function (props) {
776
- return props.theme.hoverListOptionBackgroundColor;
777
- }, function (props) {
778
- return props.theme.activeListOptionBackgroundColor;
779
- });
780
-
781
- 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) {
782
- return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
783
- });
784
-
785
- 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) {
757
+ var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n color: ", ";\n line-height: 1.715em;\n"])), function (props) {
786
758
  return props.theme.systemMessageFontColor;
787
759
  });
788
760
 
789
- 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) {
761
+ var SuggestionsErrorIcon = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (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) {
790
762
  return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
791
763
  });
792
764
 
793
- 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) {
765
+ var SuggestionsError = _styledComponents["default"].span(_templateObject16 || (_templateObject16 = (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) {
794
766
  return props.theme.errorListDialogFontColor;
795
767
  });
796
768
 
@@ -118,8 +118,7 @@ describe("TextInput component tests", function () {
118
118
 
119
119
  expect(onBlur).toHaveBeenCalled();
120
120
  expect(onBlur).toHaveBeenCalledWith({
121
- value: "Test",
122
- error: null
121
+ value: "Test"
123
122
  });
124
123
  });
125
124
  test("Not optional constraint (onChange)", function () {
@@ -143,8 +142,7 @@ describe("TextInput component tests", function () {
143
142
 
144
143
  expect(onChange).toHaveBeenCalled();
145
144
  expect(onChange).toHaveBeenCalledWith({
146
- value: "Test",
147
- error: null
145
+ value: "Test"
148
146
  });
149
147
 
150
148
  _userEvent["default"].clear(input);
@@ -205,16 +203,14 @@ describe("TextInput component tests", function () {
205
203
 
206
204
  expect(onChange).toHaveBeenCalled();
207
205
  expect(onChange).toHaveBeenCalledWith({
208
- value: "pattern4&",
209
- error: null
206
+ value: "pattern4&"
210
207
  });
211
208
 
212
209
  _react2.fireEvent.blur(input);
213
210
 
214
211
  expect(onBlur).toHaveBeenCalled();
215
212
  expect(onBlur).toHaveBeenCalledWith({
216
- value: "pattern4&",
217
- error: null
213
+ value: "pattern4&"
218
214
  });
219
215
  });
220
216
  test("Length constraint", function () {
@@ -268,16 +264,14 @@ describe("TextInput component tests", function () {
268
264
 
269
265
  expect(onChange).toHaveBeenCalled();
270
266
  expect(onChange).toHaveBeenCalledWith({
271
- value: "length",
272
- error: null
267
+ value: "length"
273
268
  });
274
269
 
275
270
  _react2.fireEvent.blur(input);
276
271
 
277
272
  expect(onBlur).toHaveBeenCalled();
278
273
  expect(onBlur).toHaveBeenCalledWith({
279
- value: "length",
280
- error: null
274
+ value: "length"
281
275
  });
282
276
  });
283
277
  test("Pattern and length constraints", function () {
@@ -350,16 +344,14 @@ describe("TextInput component tests", function () {
350
344
 
351
345
  expect(onChange).toHaveBeenCalled();
352
346
  expect(onChange).toHaveBeenCalledWith({
353
- value: "tests4&",
354
- error: null
347
+ value: "tests4&"
355
348
  });
356
349
 
357
350
  _react2.fireEvent.blur(input);
358
351
 
359
352
  expect(onBlur).toHaveBeenCalled();
360
353
  expect(onBlur).toHaveBeenCalledWith({
361
- value: "tests4&",
362
- error: null
354
+ value: "tests4&"
363
355
  });
364
356
  });
365
357
  test("onChange function is called correctly", function () {
@@ -378,8 +370,7 @@ describe("TextInput component tests", function () {
378
370
  expect(input.value).toBe("onchange event test");
379
371
  expect(onChange).toHaveBeenCalled();
380
372
  expect(onChange).toHaveBeenCalledWith({
381
- value: "onchange event test",
382
- error: null
373
+ value: "onchange event test"
383
374
  });
384
375
  });
385
376
  test("onBlur function is called correctly", function () {
@@ -405,8 +396,7 @@ describe("TextInput component tests", function () {
405
396
 
406
397
  expect(onBlur).toHaveBeenCalled();
407
398
  expect(onBlur).toHaveBeenCalledWith({
408
- value: "Blur test",
409
- error: null
399
+ value: "Blur test"
410
400
  });
411
401
  });
412
402
  test("Clear action's tooltip is correct", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
@@ -638,7 +628,7 @@ describe("TextInput component tests", function () {
638
628
  expect(input.getAttribute("aria-expanded")).toBe("true");
639
629
  expect(list.getAttribute("aria-label")).toBe("Autocomplete Countries");
640
630
  var options = getAllByRole("option");
641
- expect(options[0].getAttribute("aria-selected")).toBe("false");
631
+ expect(options[0].getAttribute("aria-selected")).toBeNull();
642
632
  });
643
633
  });
644
634
  describe("TextInput component synchronous autosuggest tests", function () {
@@ -944,8 +934,7 @@ describe("TextInput component synchronous autosuggest tests", function () {
944
934
  _userEvent["default"].click(getByRole("option"));
945
935
 
946
936
  expect(onChange).toHaveBeenCalledWith({
947
- value: "Andorra",
948
- error: null
937
+ value: "Andorra"
949
938
  });
950
939
  expect(queryByRole("listbox")).toBeFalsy();
951
940
 
@@ -1291,7 +1280,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1291
1280
  resolve(newValue ? countries.filter(function (option) {
1292
1281
  return option.toUpperCase().includes(newValue.toUpperCase());
1293
1282
  }) : countries);
1294
- }, 1000);
1283
+ }, 100);
1295
1284
  });
1296
1285
  return result;
1297
1286
  });
@@ -1363,7 +1352,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1363
1352
  resolve(newValue ? countries.filter(function (option) {
1364
1353
  return option.toUpperCase().includes(newValue.toUpperCase());
1365
1354
  }) : countries);
1366
- }, 1000);
1355
+ }, 100);
1367
1356
  });
1368
1357
  return result;
1369
1358
  });
@@ -1412,7 +1401,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1412
1401
  resolve(newValue ? countries.filter(function (option) {
1413
1402
  return option.toUpperCase().includes(newValue.toUpperCase());
1414
1403
  }) : countries);
1415
- }, 1000);
1404
+ }, 100);
1416
1405
  });
1417
1406
  return result;
1418
1407
  });
@@ -1481,7 +1470,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1481
1470
  resolve(newValue ? countries.filter(function (option) {
1482
1471
  return option.toUpperCase().includes(newValue.toUpperCase());
1483
1472
  }) : countries);
1484
- }, 1000);
1473
+ }, 100);
1485
1474
  });
1486
1475
  return result;
1487
1476
  });
@@ -1508,8 +1497,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1508
1497
  _userEvent["default"].click(getByRole("option"));
1509
1498
 
1510
1499
  expect(onChange).toHaveBeenCalledWith({
1511
- value: "Denmark",
1512
- error: null
1500
+ value: "Denmark"
1513
1501
  });
1514
1502
  expect(input.value).toBe("Denmark");
1515
1503
 
@@ -1533,7 +1521,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1533
1521
  resolve(newValue ? countries.filter(function (option) {
1534
1522
  return option.toUpperCase().includes(newValue.toUpperCase());
1535
1523
  }) : countries);
1536
- }, 1000);
1524
+ }, 100);
1537
1525
  });
1538
1526
  return result;
1539
1527
  });
@@ -1560,8 +1548,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1560
1548
  _userEvent["default"].click(getByRole("option"));
1561
1549
 
1562
1550
  expect(onChange).toHaveBeenCalledWith({
1563
- value: "Denmark",
1564
- error: null
1551
+ value: "Denmark"
1565
1552
  });
1566
1553
  expect(queryByRole("listbox")).toBeFalsy();
1567
1554
 
@@ -1585,7 +1572,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1585
1572
  resolve(newValue ? countries.filter(function (option) {
1586
1573
  return option.toUpperCase().includes(newValue.toUpperCase());
1587
1574
  }) : countries);
1588
- }, 1000);
1575
+ }, 100);
1589
1576
  });
1590
1577
  return result;
1591
1578
  });
@@ -1629,7 +1616,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1629
1616
  resolve(newValue ? countries.filter(function (option) {
1630
1617
  return option.toUpperCase().includes(newValue.toUpperCase());
1631
1618
  }) : countries);
1632
- }, 1000);
1619
+ }, 100);
1633
1620
  });
1634
1621
  return result;
1635
1622
  });
@@ -1693,7 +1680,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
1693
1680
  var result = new Promise(function (resolve, reject) {
1694
1681
  return setTimeout(function () {
1695
1682
  reject("err");
1696
- }, 1000);
1683
+ }, 100);
1697
1684
  });
1698
1685
  return result;
1699
1686
  });
@@ -6,7 +6,7 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
9
+ declare type SVG = React.SVGProps<SVGSVGElement>;
10
10
  declare type Action = {
11
11
  /**
12
12
  * This function will be called when the user clicks the action.
@@ -78,26 +78,29 @@ declare type Props = {
78
78
  * This function will be called when the user types within the input
79
79
  * element of the component. An object including the current value and
80
80
  * the error (if the value entered is not valid) will be passed to this
81
- * function. If there is no error, error will be null.
81
+ * function. If there is no error, error will not be defined.
82
82
  */
83
83
  onChange?: (val: {
84
84
  value: string;
85
- error: string | null;
85
+ error?: string;
86
86
  }) => void;
87
87
  /**
88
88
  * This function will be called when the input element loses the focus.
89
89
  * An object including the input value and the error (if the value
90
90
  * entered is not valid) will be passed to this function. If there is no error,
91
- * error will be null.
91
+ * error will not be defined.
92
92
  */
93
93
  onBlur?: (val: {
94
94
  value: string;
95
- error: string | null;
95
+ error?: string;
96
96
  }) => void;
97
97
  /**
98
- * If it is defined, the component will change its appearance, showing
99
- * the error below the input component. If it is not defined, the error
100
- * messages will be managed internally, but never displayed on its own.
98
+ * If it is a defined value and also a truthy string, the component will
99
+ * change its appearance, showing the error below the input component. If
100
+ * the defined value is an empty string, it will reserve a space below
101
+ * the component for a future error, but it would not change its look. In
102
+ * case of being undefined or null, both the appearance and the space for
103
+ * the error message would not be modified.
101
104
  */
102
105
  error?: string;
103
106
  /**
@@ -114,7 +117,7 @@ declare type Props = {
114
117
  * pattern, the onBlur and onChange functions will be called with the
115
118
  * current value and an internal error informing that this value does not
116
119
  * match the pattern. If the pattern is met, the error parameter of both
117
- * events will be null.
120
+ * events will not be defined.
118
121
  */
119
122
  pattern?: string;
120
123
  /**
@@ -124,7 +127,7 @@ declare type Props = {
124
127
  * comply the minimum length, the onBlur and onChange functions will be called
125
128
  * with the current value and an internal error informing that the value
126
129
  * length does not comply the specified range. If a valid length is
127
- * reached, the error parameter of both events will be null.
130
+ * reached, the error parameter of both events will not be defined.
128
131
  */
129
132
  minLength?: number;
130
133
  /**
@@ -134,7 +137,7 @@ declare type Props = {
134
137
  * comply the maximum length, the onBlur and onChange functions will be called
135
138
  * with the current value and an internal error informing that the value
136
139
  * length does not comply the specified range. If a valid length is
137
- * reached, the error parameter of both events will be null.
140
+ * reached, the error parameter of both events will not be defined.
138
141
  */
139
142
  maxLength?: number;
140
143
  /**
@@ -148,7 +151,7 @@ declare type Props = {
148
151
  */
149
152
  margin?: Space | Margin;
150
153
  /**
151
- * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
154
+ * Size of the component.
152
155
  */
153
156
  size?: "small" | "medium" | "large" | "fillParent";
154
157
  /**
@@ -160,4 +163,16 @@ declare type Props = {
160
163
  * Reference to the component.
161
164
  */
162
165
  export declare type RefType = HTMLDivElement;
166
+ /**
167
+ * Single suggestion of the Autosuggest Text Input component.
168
+ */
169
+ export declare type SuggestionProps = {
170
+ id: string;
171
+ value: string;
172
+ onClick: () => void;
173
+ suggestion: string;
174
+ isLast: boolean;
175
+ visuallyFocused: boolean;
176
+ highlighted: boolean;
177
+ };
163
178
  export default Props;