@dxc-technology/halstack-react 8.0.0 → 9.0.1

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 (163) hide show
  1. package/BackgroundColorContext.d.ts +2 -2
  2. package/BackgroundColorContext.js +1 -1
  3. package/HalstackContext.d.ts +1329 -5
  4. package/HalstackContext.js +114 -73
  5. package/accordion/Accordion.js +13 -24
  6. package/accordion/Accordion.stories.tsx +102 -13
  7. package/accordion/Accordion.test.js +1 -1
  8. package/accordion/types.d.ts +3 -3
  9. package/accordion-group/AccordionGroup.js +2 -2
  10. package/accordion-group/AccordionGroup.test.js +1 -1
  11. package/accordion-group/types.d.ts +2 -2
  12. package/alert/Alert.js +3 -5
  13. package/alert/Alert.stories.tsx +28 -0
  14. package/alert/Alert.test.js +1 -1
  15. package/box/Box.js +3 -5
  16. package/box/Box.stories.tsx +15 -0
  17. package/box/Box.test.js +1 -1
  18. package/button/Button.js +13 -15
  19. package/button/Button.stories.tsx +150 -8
  20. package/button/Button.test.js +1 -1
  21. package/button/types.d.ts +3 -3
  22. package/card/Card.js +12 -13
  23. package/card/Card.stories.tsx +12 -13
  24. package/card/Card.test.js +1 -1
  25. package/checkbox/Checkbox.js +3 -3
  26. package/checkbox/Checkbox.stories.tsx +52 -0
  27. package/checkbox/Checkbox.test.js +1 -1
  28. package/checkbox/types.d.ts +2 -2
  29. package/chip/Chip.js +18 -26
  30. package/chip/Chip.stories.tsx +96 -9
  31. package/chip/Chip.test.js +3 -5
  32. package/common/utils.d.ts +1 -0
  33. package/common/utils.js +4 -4
  34. package/common/variables.d.ts +1625 -0
  35. package/common/variables.js +280 -288
  36. package/date-input/Calendar.d.ts +1 -1
  37. package/date-input/Calendar.js +43 -43
  38. package/date-input/DateInput.js +74 -32
  39. package/date-input/DateInput.stories.tsx +183 -30
  40. package/date-input/DateInput.test.js +120 -37
  41. package/date-input/DatePicker.js +38 -52
  42. package/date-input/Icons.d.ts +6 -0
  43. package/date-input/Icons.js +75 -0
  44. package/date-input/YearPicker.d.ts +1 -1
  45. package/date-input/YearPicker.js +23 -12
  46. package/date-input/types.d.ts +6 -8
  47. package/dialog/Dialog.js +61 -74
  48. package/dialog/Dialog.stories.tsx +211 -159
  49. package/dialog/Dialog.test.js +302 -3
  50. package/dialog/types.d.ts +2 -2
  51. package/dropdown/Dropdown.js +5 -8
  52. package/dropdown/Dropdown.stories.tsx +210 -84
  53. package/dropdown/Dropdown.test.js +3 -2
  54. package/dropdown/DropdownMenu.js +8 -18
  55. package/dropdown/DropdownMenuItem.js +4 -17
  56. package/dropdown/types.d.ts +3 -3
  57. package/file-input/FileInput.js +4 -8
  58. package/file-input/FileInput.stories.tsx +85 -2
  59. package/file-input/FileInput.test.js +1 -42
  60. package/file-input/FileItem.js +1 -0
  61. package/footer/Footer.js +6 -8
  62. package/footer/Footer.stories.tsx +91 -0
  63. package/footer/Footer.test.js +14 -26
  64. package/header/Header.d.ts +3 -2
  65. package/header/Header.js +21 -23
  66. package/header/Header.stories.tsx +149 -6
  67. package/header/Header.test.js +2 -2
  68. package/header/types.d.ts +2 -2
  69. package/heading/Heading.js +1 -1
  70. package/heading/Heading.test.js +1 -1
  71. package/layout/ApplicationLayout.d.ts +1 -1
  72. package/layout/ApplicationLayout.js +1 -1
  73. package/link/Link.js +2 -2
  74. package/link/Link.stories.tsx +60 -0
  75. package/link/Link.test.js +2 -4
  76. package/link/types.d.ts +2 -2
  77. package/main.d.ts +1 -1
  78. package/main.js +1 -1
  79. package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
  80. package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
  81. package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
  82. package/{tabs-nav → nav-tabs}/Tab.js +37 -17
  83. package/number-input/NumberInput.test.js +1 -1
  84. package/package.json +2 -2
  85. package/paginator/Icons.d.ts +5 -0
  86. package/paginator/Icons.js +16 -28
  87. package/paginator/Paginator.js +6 -14
  88. package/paginator/Paginator.stories.tsx +24 -0
  89. package/paginator/Paginator.test.js +44 -47
  90. package/paragraph/Paragraph.d.ts +3 -4
  91. package/paragraph/Paragraph.js +5 -5
  92. package/password-input/PasswordInput.test.js +1 -1
  93. package/progress-bar/ProgressBar.d.ts +2 -2
  94. package/progress-bar/ProgressBar.js +5 -5
  95. package/progress-bar/ProgressBar.stories.jsx +35 -2
  96. package/progress-bar/ProgressBar.test.js +1 -1
  97. package/progress-bar/types.d.ts +4 -3
  98. package/quick-nav/QuickNav.stories.tsx +14 -0
  99. package/radio-group/RadioGroup.stories.tsx +131 -18
  100. package/radio-group/RadioGroup.test.js +1 -1
  101. package/resultsetTable/ResultsetTable.js +2 -2
  102. package/resultsetTable/ResultsetTable.test.js +18 -23
  103. package/resultsetTable/types.d.ts +3 -3
  104. package/select/Listbox.d.ts +1 -1
  105. package/select/Listbox.js +5 -34
  106. package/select/Option.js +11 -24
  107. package/select/Select.js +56 -35
  108. package/select/Select.stories.tsx +492 -145
  109. package/select/Select.test.js +76 -81
  110. package/select/types.d.ts +2 -2
  111. package/sidenav/Sidenav.js +9 -11
  112. package/sidenav/Sidenav.stories.tsx +148 -46
  113. package/slider/Slider.js +6 -7
  114. package/slider/Slider.stories.tsx +57 -0
  115. package/slider/Slider.test.js +1 -1
  116. package/slider/types.d.ts +2 -2
  117. package/spinner/Spinner.js +17 -23
  118. package/spinner/Spinner.stories.jsx +53 -27
  119. package/spinner/Spinner.test.js +1 -1
  120. package/switch/Switch.js +3 -3
  121. package/switch/Switch.stories.tsx +33 -0
  122. package/switch/Switch.test.js +1 -1
  123. package/switch/types.d.ts +2 -2
  124. package/table/Table.js +2 -2
  125. package/table/Table.stories.jsx +80 -1
  126. package/table/Table.test.js +1 -1
  127. package/tabs/Tab.js +12 -14
  128. package/tabs/Tabs.js +4 -6
  129. package/tabs/Tabs.stories.tsx +45 -5
  130. package/tabs/Tabs.test.js +4 -5
  131. package/tabs/types.d.ts +2 -2
  132. package/tag/Tag.js +7 -9
  133. package/tag/Tag.stories.tsx +14 -1
  134. package/tag/Tag.test.js +1 -1
  135. package/text-input/Suggestion.js +34 -7
  136. package/text-input/TextInput.js +10 -14
  137. package/text-input/TextInput.stories.tsx +92 -4
  138. package/text-input/TextInput.test.js +125 -26
  139. package/textarea/Textarea.js +3 -3
  140. package/textarea/Textarea.stories.jsx +60 -1
  141. package/textarea/Textarea.test.js +1 -1
  142. package/toggle-group/ToggleGroup.js +7 -4
  143. package/toggle-group/ToggleGroup.stories.tsx +42 -0
  144. package/toggle-group/ToggleGroup.test.js +1 -1
  145. package/toggle-group/types.d.ts +1 -1
  146. package/typography/Typography.d.ts +2 -2
  147. package/typography/Typography.js +14 -113
  148. package/typography/Typography.stories.tsx +1 -1
  149. package/useTheme.d.ts +1234 -1
  150. package/useTheme.js +1 -1
  151. package/useTranslatedLabels.d.ts +84 -1
  152. package/utils/BaseTypography.d.ts +21 -0
  153. package/utils/BaseTypography.js +108 -0
  154. package/utils/FocusLock.d.ts +13 -0
  155. package/utils/FocusLock.js +139 -0
  156. package/wizard/Wizard.js +2 -2
  157. package/wizard/Wizard.stories.tsx +20 -0
  158. package/wizard/Wizard.test.js +1 -1
  159. package/wizard/types.d.ts +5 -6
  160. /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
  161. /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
  162. /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
  163. /package/{tabs-nav → nav-tabs}/types.js +0 -0
package/tabs/Tabs.test.js CHANGED
@@ -6,7 +6,7 @@ var _react = _interopRequireDefault(require("react"));
6
6
 
7
7
  var _react2 = require("@testing-library/react");
8
8
 
9
- var _Tabs = _interopRequireDefault(require("./Tabs"));
9
+ var _Tabs = _interopRequireDefault(require("./Tabs.tsx"));
10
10
 
11
11
  var sampleTabs = [{
12
12
  label: "Tab-1"
@@ -17,13 +17,13 @@ var sampleTabs = [{
17
17
  }];
18
18
  var sampleTabsWithBadge = [{
19
19
  label: "Tab-1",
20
- notificationNumber: "10"
20
+ notificationNumber: 10
21
21
  }, {
22
22
  label: "Tab-2",
23
- notificationNumber: "20"
23
+ notificationNumber: 20
24
24
  }, {
25
25
  label: "Tab-3",
26
- notificationNumber: "101"
26
+ notificationNumber: 101
27
27
  }];
28
28
  var sampleTabsMiddleDisabled = [{
29
29
  label: "Tab-1"
@@ -149,7 +149,6 @@ describe("Tabs component tests", function () {
149
149
  onTabClick: onTabClick,
150
150
  activeTabIndex: 0
151
151
  })),
152
- getByText = _render7.getByText,
153
152
  getAllByRole = _render7.getAllByRole;
154
153
 
155
154
  var tabs = getAllByRole("tab");
package/tabs/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- export declare type Margin = {
2
+ declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ declare type Margin = {
4
4
  top?: Space;
5
5
  bottom?: Space;
6
6
  left?: Space;
package/tag/Tag.js CHANGED
@@ -19,11 +19,11 @@ var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
21
21
 
22
- var _variables = require("../common/variables.js");
22
+ var _variables = require("../common/variables");
23
23
 
24
24
  var _useTheme = _interopRequireDefault(require("../useTheme"));
25
25
 
26
- var _utils = require("../common/utils.js");
26
+ var _utils = require("../common/utils");
27
27
 
28
28
  var _Box = _interopRequireDefault(require("../box/Box"));
29
29
 
@@ -64,9 +64,7 @@ var DxcTag = function DxcTag(_ref) {
64
64
  var tagContent = /*#__PURE__*/_react["default"].createElement(_Box["default"], {
65
65
  size: size,
66
66
  shadowDepth: isHovered && (onClick || linkHref) && 2 || 1
67
- }, /*#__PURE__*/_react["default"].createElement(TagContent, {
68
- labelPosition: labelPosition
69
- }, labelPosition === "before" && size !== "small" && label && /*#__PURE__*/_react["default"].createElement(TagLabel, null, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
67
+ }, /*#__PURE__*/_react["default"].createElement(TagContent, null, labelPosition === "before" && size !== "small" && label && /*#__PURE__*/_react["default"].createElement(TagLabel, null, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
70
68
  iconBgColor: iconBgColor
71
69
  }, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(TagIcon, {
72
70
  src: icon
@@ -114,16 +112,16 @@ var StyledDxcTag = _styledComponents["default"].div(_templateObject || (_templat
114
112
  return margin && (0, _typeof2["default"])(margin) !== "object" ? _variables.spaces[margin] : "0px";
115
113
  }, function (_ref4) {
116
114
  var margin = _ref4.margin;
117
- return margin && margin.top ? _variables.spaces[margin.top] : "";
115
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.top ? _variables.spaces[margin.top] : "";
118
116
  }, function (_ref5) {
119
117
  var margin = _ref5.margin;
120
- return margin && margin.right ? _variables.spaces[margin.right] : "";
118
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.right ? _variables.spaces[margin.right] : "";
121
119
  }, function (_ref6) {
122
120
  var margin = _ref6.margin;
123
- return margin && margin.bottom ? _variables.spaces[margin.bottom] : "";
121
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.bottom ? _variables.spaces[margin.bottom] : "";
124
122
  }, function (_ref7) {
125
123
  var margin = _ref7.margin;
126
- return margin && margin.left ? _variables.spaces[margin.left] : "";
124
+ return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
127
125
  }, function (props) {
128
126
  return calculateWidth(props.margin, props.size);
129
127
  }, function (props) {
@@ -3,6 +3,7 @@ import { userEvent, within } from "@storybook/testing-library";
3
3
  import Title from "../../.storybook/components/Title";
4
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
5
  import DxcTag from "./Tag";
6
+ import { HalstackProvider } from "../HalstackContext";
6
7
 
7
8
  export default {
8
9
  title: "Tag",
@@ -23,6 +24,13 @@ const largeIcon = (
23
24
  </svg>
24
25
  );
25
26
 
27
+ const opinionatedTheme = {
28
+ tag: {
29
+ fontColor: "#000000",
30
+ iconColor: "#ffffff",
31
+ },
32
+ };
33
+
26
34
  export const Chromatic = () => (
27
35
  <>
28
36
  <ExampleContainer>
@@ -124,7 +132,12 @@ export const Chromatic = () => (
124
132
  <Title title="FitContent size" theme="light" level={4} />
125
133
  <DxcTag label="FitContent" size="fitContent" icon={icon} />
126
134
  </ExampleContainer>
127
- <hr />
135
+ <Title title="Opinionated theme" theme="light" level={2} />
136
+ <ExampleContainer>
137
+ <HalstackProvider theme={opinionatedTheme}>
138
+ <DxcTag label="Tag" icon={icon} />
139
+ </HalstackProvider>
140
+ </ExampleContainer>
128
141
  </>
129
142
  );
130
143
 
package/tag/Tag.test.js CHANGED
@@ -6,7 +6,7 @@ var _react = _interopRequireDefault(require("react"));
6
6
 
7
7
  var _react2 = require("@testing-library/react");
8
8
 
9
- var _Tag = _interopRequireDefault(require("./Tag"));
9
+ var _Tag = _interopRequireDefault(require("./Tag.tsx"));
10
10
 
11
11
  describe("Tag component tests", function () {
12
12
  test("Tag renders with correct label", function () {
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -9,12 +11,33 @@ exports["default"] = void 0;
9
11
 
10
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
13
 
12
- var _react = _interopRequireDefault(require("react"));
14
+ var _react = _interopRequireWildcard(require("react"));
13
15
 
14
16
  var _styledComponents = _interopRequireDefault(require("styled-components"));
15
17
 
16
18
  var _templateObject, _templateObject2;
17
19
 
20
+ 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); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ var transformSpecialChars = function transformSpecialChars(str) {
25
+ var specialCharsRegex = /[\\*()\[\]{}+?/]/;
26
+ var value = str;
27
+
28
+ if (specialCharsRegex.test(value)) {
29
+ var regexAsString = specialCharsRegex.toString().split("");
30
+ var uniqueSpecialChars = regexAsString.filter(function (item, index) {
31
+ return regexAsString.indexOf(item) === index;
32
+ });
33
+ uniqueSpecialChars.forEach(function (specialChar) {
34
+ if (str.includes(specialChar)) value = value.replace(specialChar, "\\" + specialChar);
35
+ });
36
+ }
37
+
38
+ return value;
39
+ };
40
+
18
41
  var Suggestion = function Suggestion(_ref) {
19
42
  var id = _ref.id,
20
43
  value = _ref.value,
@@ -23,9 +46,13 @@ var Suggestion = function Suggestion(_ref) {
23
46
  isLast = _ref.isLast,
24
47
  visuallyFocused = _ref.visuallyFocused,
25
48
  highlighted = _ref.highlighted;
26
- var regEx = new RegExp(value, "i");
27
- var matchedWords = suggestion.match(regEx);
28
- var noMatchedWords = suggestion.replace(regEx, "");
49
+ var matchedSuggestion = (0, _react.useMemo)(function () {
50
+ var regEx = new RegExp(transformSpecialChars(value), "i");
51
+ return {
52
+ matchedWords: suggestion.match(regEx),
53
+ noMatchedWords: suggestion.replace(regEx, "")
54
+ };
55
+ }, [value, suggestion]);
29
56
  return /*#__PURE__*/_react["default"].createElement(SuggestionContainer, {
30
57
  id: id,
31
58
  onClick: function onClick() {
@@ -35,9 +62,9 @@ var Suggestion = function Suggestion(_ref) {
35
62
  role: "option",
36
63
  "aria-selected": visuallyFocused ? true : undefined
37
64
  }, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
38
- last: isLast,
65
+ isLast: isLast,
39
66
  visuallyFocused: visuallyFocused
40
- }, highlighted ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords) : suggestion));
67
+ }, highlighted ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedSuggestion.matchedWords), matchedSuggestion.noMatchedWords) : suggestion));
41
68
  };
42
69
 
43
70
  var SuggestionContainer = _styledComponents["default"].li(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0 0.5rem;\n line-height: 1.715em;\n cursor: pointer;\n box-shadow: inset 0 0 0 2px\n ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), function (props) {
@@ -49,7 +76,7 @@ var SuggestionContainer = _styledComponents["default"].li(_templateObject || (_t
49
76
  });
50
77
 
51
78
  var StyledSuggestion = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (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) {
52
- return props.last || props.visuallyFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
79
+ return props.isLast || props.visuallyFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
53
80
  });
54
81
 
55
82
  var _default = /*#__PURE__*/_react["default"].memo(Suggestion);
@@ -23,9 +23,9 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
23
23
 
24
24
  var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
25
25
 
26
- var _variables = require("../common/variables.js");
26
+ var _variables = require("../common/variables");
27
27
 
28
- var _utils = require("../common/utils.js");
28
+ var _utils = require("../common/utils");
29
29
 
30
30
  var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
31
31
 
@@ -39,7 +39,7 @@ var _Icons = _interopRequireDefault(require("./Icons"));
39
39
 
40
40
  var _uuid = require("uuid");
41
41
 
42
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
42
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
43
43
 
44
44
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
45
 
@@ -547,7 +547,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
547
547
  backgroundType: backgroundType,
548
548
  tabIndex: tabIndex,
549
549
  type: "button"
550
- }, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ActionIcon, {
550
+ }, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
551
551
  src: action.icon
552
552
  }) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
553
553
  disabled: disabled,
@@ -559,7 +559,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
559
559
  }, error)));
560
560
  });
561
561
 
562
- 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) {
562
+ var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
563
563
  return calculateWidth(props.margin, props.size);
564
564
  }, function (props) {
565
565
  return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
@@ -635,11 +635,7 @@ var Input = _styledComponents["default"].input(_templateObject6 || (_templateObj
635
635
  return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPlaceholderFontColorOnDark : props.theme.disabledPlaceholderFontColor : props.backgroundType === "dark" ? props.theme.placeholderFontColorOnDark : props.theme.placeholderFontColor;
636
636
  });
637
637
 
638
- var ActionIcon = _styledComponents["default"].img(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n width: 16px;\n height: 16px;\n"])));
639
-
640
- var Action = _styledComponents["default"].button(_templateObject8 || (_templateObject8 = (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: 2px;\n padding: 3px;\n margin-left: 0.25rem;\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"])), function (props) {
641
- return props.theme.fontFamily;
642
- }, function (props) {
638
+ var Action = _styledComponents["default"].button(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n border: 1px solid transparent;\n border-radius: 2px;\n width: 24px;\n height: 24px;\n padding: 3px;\n margin-left: 0.25rem;\n ", "\n\n box-shadow: 0 0 0 2px transparent;\n background-color: ", ";\n\n color: ", ";\n\n ", "\n\n img, svg {\n width: 16px;\n height: 16px;\n }\n"])), function (props) {
643
639
  return props.disabled ? "cursor: not-allowed;" : "cursor: pointer;";
644
640
  }, function (props) {
645
641
  return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionBackgroundColorOnDark : props.theme.disabledActionBackgroundColor : props.backgroundType === "dark" ? props.theme.actionBackgroundColorOnDark : props.theme.actionBackgroundColor;
@@ -649,25 +645,25 @@ var Action = _styledComponents["default"].button(_templateObject8 || (_templateO
649
645
  return !props.disabled && "\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 &: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 &: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 ");
650
646
  });
651
647
 
652
- var Prefix = _styledComponents["default"].span(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin-left: 0.25rem;\n padding: 0 0.5rem 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
648
+ var Prefix = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin-left: 0.25rem;\n padding: 0 0.5rem 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
653
649
  var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledPrefixColorOnDark : props.theme.disabledPrefixColor : props.backgroundType === "dark" ? props.theme.prefixColorOnDark : props.theme.prefixColor;
654
650
  return "color: ".concat(color, "; border-right: 1px solid ").concat(color, ";");
655
651
  }, function (props) {
656
652
  return props.theme.fontFamily;
657
653
  });
658
654
 
659
- var Suffix = _styledComponents["default"].span(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin: 0 0.25rem;\n padding: 0 0 0 0.5rem;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
655
+ var Suffix = _styledComponents["default"].span(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin: 0 0.25rem;\n padding: 0 0 0 0.5rem;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
660
656
  var color = props.disabled ? props.backgroundType === "dark" ? props.theme.disabledSuffixColorOnDark : props.theme.disabledSuffixColor : props.backgroundType === "dark" ? props.theme.suffixColorOnDark : props.theme.suffixColor;
661
657
  return "color: ".concat(color, "; border-left: 1px solid ").concat(color, ";");
662
658
  }, function (props) {
663
659
  return props.theme.fontFamily;
664
660
  });
665
661
 
666
- var ErrorIcon = _styledComponents["default"].span(_templateObject11 || (_templateObject11 = (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: 0.25rem;\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"])), function (props) {
662
+ var ErrorIcon = _styledComponents["default"].span(_templateObject10 || (_templateObject10 = (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: 0.25rem;\n color: ", ";\n\n svg {\n line-height: 18px;\n font-size: 1.25rem;\n }\n"])), function (props) {
667
663
  return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
668
664
  });
669
665
 
670
- var Error = _styledComponents["default"].span(_templateObject12 || (_templateObject12 = (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 margin-top: 0.25rem;\n"])), function (props) {
666
+ var Error = _styledComponents["default"].span(_templateObject11 || (_templateObject11 = (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 margin-top: 0.25rem;\n"])), function (props) {
671
667
  return props.backgroundType === "dark" ? props.theme.errorMessageColorOnDark : props.theme.errorMessageColor;
672
668
  }, function (props) {
673
669
  return props.theme.fontFamily;
@@ -11,6 +11,7 @@ import DxcFlex from "../flex/Flex";
11
11
  import Suggestions from "./Suggestions";
12
12
  import { ThemeProvider } from "styled-components";
13
13
  import useTheme from "../useTheme";
14
+ import { HalstackProvider } from "../HalstackContext";
14
15
 
15
16
  export default {
16
17
  title: "Text input",
@@ -27,7 +28,7 @@ const action = {
27
28
  ),
28
29
  };
29
30
 
30
- const actionLargeIcon = {
31
+ const actionLargeIconSVG = {
31
32
  onClick: () => {},
32
33
  icon: (
33
34
  <svg xmlns="http://www.w3.org/2000/svg" height="48px" viewBox="0 0 24 24" width="48px" fill="currentColor">
@@ -37,6 +38,11 @@ const actionLargeIcon = {
37
38
  ),
38
39
  };
39
40
 
41
+ const actionLargeIconURL = {
42
+ onClick: () => {},
43
+ icon: "https://iconape.com/wp-content/files/yd/367773/svg/logo-linkedin-logo-icon-png-svg.png",
44
+ };
45
+
40
46
  const country = ["Afghanistan"];
41
47
  const countries = [
42
48
  "Afghanistan",
@@ -61,8 +67,16 @@ const countries = [
61
67
  "Dominica",
62
68
  "Denmark",
63
69
  "Djibouti",
70
+ "*",
64
71
  ];
65
72
 
73
+ const opinionatedTheme = {
74
+ textInput: {
75
+ fontColor: "#000000",
76
+ hoverBorderColor: "#a46ede",
77
+ },
78
+ };
79
+
66
80
  export const Chromatic = () => (
67
81
  <>
68
82
  <ExampleContainer pseudoState="pseudo-hover">
@@ -98,12 +112,21 @@ export const Chromatic = () => (
98
112
  <DxcTextInput label="Text input" clearable defaultValue="Text" helperText="Help message" optional />
99
113
  </ExampleContainer>
100
114
  <ExampleContainer>
101
- <Title title="Clearable and large icon action" theme="light" level={4} />
115
+ <Title title="Clearable and large icon action (SVG)" theme="light" level={4} />
102
116
  <DxcTextInput
103
117
  label="Text input"
104
118
  defaultValue="Text text text text text text text text text text"
105
119
  clearable
106
- action={actionLargeIcon}
120
+ action={actionLargeIconSVG}
121
+ />
122
+ </ExampleContainer>
123
+ <ExampleContainer>
124
+ <Title title="Clearable and large icon action (URL)" theme="light" level={4} />
125
+ <DxcTextInput
126
+ label="Text input"
127
+ defaultValue="Text text text text text text text text text text"
128
+ clearable
129
+ action={actionLargeIconURL}
107
130
  />
108
131
  </ExampleContainer>
109
132
  <ExampleContainer>
@@ -297,6 +320,66 @@ export const Chromatic = () => (
297
320
  <Title title="FillParent size" theme="light" level={4} />
298
321
  <DxcTextInput label="FillParent" size="fillParent" />
299
322
  </ExampleContainer>
323
+ <Title title="Opinionated theme" theme="light" level={2} />
324
+ <ExampleContainer>
325
+ <HalstackProvider theme={opinionatedTheme}>
326
+ <ExampleContainer pseudoState="pseudo-hover">
327
+ <Title title="Hovered input" theme="light" level={4} />
328
+ <DxcTextInput label="Text input" helperText="Help message" />
329
+ </ExampleContainer>
330
+ <ExampleContainer pseudoState="pseudo-focus-within">
331
+ <Title title="Focused input" theme="light" level={4} />
332
+ <DxcTextInput label="Text input" helperText="Help message" />
333
+ </ExampleContainer>
334
+ <ExampleContainer pseudoState="pseudo-hover">
335
+ <Title title="Hovered action" theme="light" level={4} />
336
+ <DxcTextInput label="Text input" helperText="Help message" defaultValue="Text" clearable />
337
+ </ExampleContainer>
338
+ <ExampleContainer pseudoState="pseudo-active">
339
+ <Title title="Actived action" theme="light" level={4} />
340
+ <DxcTextInput label="Text input" helperText="Help message" action={action} clearable />
341
+ </ExampleContainer>
342
+ <ExampleContainer pseudoState="pseudo-focus">
343
+ <Title title="Focused action" theme="light" level={4} />
344
+ <DxcTextInput label="Text input" helperText="Help message" action={action} clearable />
345
+ </ExampleContainer>
346
+ <ExampleContainer>
347
+ <Title title="Prefix" theme="light" level={4} />
348
+ <DxcTextInput label="With prefix" prefix="+34" helperText="Help message" />
349
+ </ExampleContainer>
350
+ <ExampleContainer>
351
+ <Title title="Suffix and action" theme="light" level={4} />
352
+ <DxcTextInput label="With suffix" helperText="Help message" suffix="USD" action={action} />
353
+ </ExampleContainer>
354
+ <ExampleContainer>
355
+ <Title title="Invalid" theme="light" level={4} />
356
+ <DxcTextInput
357
+ label="Error text input"
358
+ helperText="Help message"
359
+ error="Error message."
360
+ defaultValue="Text"
361
+ clearable
362
+ optional
363
+ action={action}
364
+ />
365
+ </ExampleContainer>
366
+ <ExampleContainer>
367
+ <Title title="Disabled and placeholder" theme="light" level={4} />
368
+ <DxcTextInput label="Disabled text input" disabled placeholder="Placeholder" prefix="+34" suffix="USD" />
369
+ </ExampleContainer>
370
+ <ExampleContainer>
371
+ <Title title="Disabled, helper text, optional, value and action" theme="light" level={4} />
372
+ <DxcTextInput
373
+ label="Disabled text input"
374
+ helperText="Help message"
375
+ disabled
376
+ optional
377
+ defaultValue="Text"
378
+ action={action}
379
+ />
380
+ </ExampleContainer>
381
+ </HalstackProvider>
382
+ </ExampleContainer>
300
383
  </>
301
384
  );
302
385
 
@@ -308,7 +391,11 @@ const AutosuggestListbox = () => {
308
391
  <ExampleContainer>
309
392
  <Title title="Autosuggest listbox" theme="light" level={2} />
310
393
  <ExampleContainer>
311
- <Title title="List dialog uses a Radix Popover to appear over elements with a certain z-index" theme="light" level={3} />
394
+ <Title
395
+ title="List dialog uses a Radix Popover to appear over elements with a certain z-index"
396
+ theme="light"
397
+ level={3}
398
+ />
312
399
  <div
313
400
  style={{
314
401
  display: "flex",
@@ -322,6 +409,7 @@ const AutosuggestListbox = () => {
322
409
  borderRadius: "4px",
323
410
  overflow: "auto",
324
411
  zIndex: "1300",
412
+ position: "relative",
325
413
  }}
326
414
  >
327
415
  <DxcTextInput