@dxc-technology/halstack-react 7.0.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/HalstackContext.js +98 -50
  2. package/accordion/Accordion.js +7 -13
  3. package/accordion/Accordion.stories.tsx +102 -13
  4. package/alert/Alert.stories.tsx +28 -0
  5. package/box/Box.js +1 -3
  6. package/box/Box.stories.tsx +15 -0
  7. package/button/Button.js +11 -13
  8. package/button/Button.stories.tsx +150 -8
  9. package/checkbox/Checkbox.d.ts +2 -2
  10. package/checkbox/Checkbox.js +16 -15
  11. package/checkbox/Checkbox.stories.tsx +131 -59
  12. package/checkbox/types.d.ts +4 -0
  13. package/chip/Chip.js +16 -22
  14. package/chip/Chip.stories.tsx +96 -9
  15. package/common/variables.js +286 -290
  16. package/date-input/Calendar.d.ts +4 -0
  17. package/date-input/Calendar.js +258 -0
  18. package/date-input/DateInput.js +134 -237
  19. package/date-input/DateInput.stories.tsx +199 -33
  20. package/date-input/DateInput.test.js +494 -138
  21. package/date-input/DatePicker.d.ts +4 -0
  22. package/date-input/DatePicker.js +146 -0
  23. package/date-input/Icons.d.ts +6 -0
  24. package/date-input/Icons.js +75 -0
  25. package/date-input/YearPicker.d.ts +4 -0
  26. package/date-input/YearPicker.js +126 -0
  27. package/date-input/types.d.ts +51 -0
  28. package/dialog/Dialog.js +60 -73
  29. package/dialog/Dialog.stories.tsx +211 -159
  30. package/dialog/Dialog.test.js +301 -2
  31. package/dropdown/Dropdown.js +35 -35
  32. package/dropdown/Dropdown.stories.tsx +210 -84
  33. package/dropdown/Dropdown.test.js +17 -22
  34. package/dropdown/DropdownMenu.js +8 -18
  35. package/dropdown/DropdownMenuItem.js +4 -15
  36. package/file-input/FileInput.d.ts +2 -2
  37. package/file-input/FileInput.js +169 -222
  38. package/file-input/FileInput.stories.tsx +122 -11
  39. package/file-input/FileInput.test.js +12 -53
  40. package/file-input/FileItem.d.ts +4 -14
  41. package/file-input/FileItem.js +39 -63
  42. package/file-input/types.d.ts +17 -0
  43. package/footer/Footer.stories.tsx +91 -0
  44. package/header/Header.js +18 -20
  45. package/header/Header.stories.tsx +149 -6
  46. package/link/Link.js +1 -1
  47. package/link/Link.stories.tsx +60 -0
  48. package/main.d.ts +1 -1
  49. package/main.js +1 -1
  50. package/{tabs-nav → nav-tabs}/NavTabs.js +1 -1
  51. package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +96 -6
  52. package/{tabs-nav → nav-tabs}/Tab.js +35 -15
  53. package/number-input/NumberInput.test.js +5 -6
  54. package/package.json +7 -12
  55. package/paginator/Icons.d.ts +5 -0
  56. package/paginator/Icons.js +16 -28
  57. package/paginator/Paginator.js +5 -11
  58. package/paginator/Paginator.stories.tsx +24 -0
  59. package/paginator/Paginator.test.js +17 -10
  60. package/progress-bar/ProgressBar.js +4 -4
  61. package/progress-bar/ProgressBar.stories.jsx +35 -2
  62. package/quick-nav/QuickNav.stories.tsx +14 -0
  63. package/radio-group/RadioGroup.stories.tsx +131 -18
  64. package/resultsetTable/Icons.d.ts +7 -0
  65. package/resultsetTable/Icons.js +51 -0
  66. package/resultsetTable/ResultsetTable.js +48 -105
  67. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  68. package/resultsetTable/ResultsetTable.test.js +40 -63
  69. package/resultsetTable/types.d.ts +2 -2
  70. package/select/Listbox.d.ts +1 -1
  71. package/select/Listbox.js +5 -34
  72. package/select/Option.js +11 -24
  73. package/select/Select.js +43 -24
  74. package/select/Select.stories.tsx +494 -150
  75. package/select/Select.test.js +17 -22
  76. package/select/types.d.ts +2 -2
  77. package/sidenav/Sidenav.js +8 -10
  78. package/sidenav/Sidenav.stories.tsx +148 -46
  79. package/slider/Slider.d.ts +2 -2
  80. package/slider/Slider.js +9 -8
  81. package/slider/Slider.stories.tsx +57 -0
  82. package/slider/types.d.ts +4 -0
  83. package/spinner/Spinner.js +2 -2
  84. package/spinner/Spinner.stories.jsx +27 -1
  85. package/switch/Switch.d.ts +3 -3
  86. package/switch/Switch.js +5 -4
  87. package/switch/Switch.stories.tsx +33 -0
  88. package/switch/types.d.ts +6 -1
  89. package/table/Table.stories.jsx +80 -1
  90. package/table/Table.test.js +1 -1
  91. package/tabs/Tab.js +3 -5
  92. package/tabs/Tabs.js +3 -3
  93. package/tabs/Tabs.stories.tsx +45 -5
  94. package/tag/Tag.stories.tsx +14 -1
  95. package/text-input/Suggestion.js +32 -5
  96. package/text-input/TextInput.js +7 -11
  97. package/text-input/TextInput.stories.tsx +92 -4
  98. package/text-input/TextInput.test.js +587 -634
  99. package/textarea/Textarea.stories.jsx +60 -1
  100. package/toggle-group/ToggleGroup.stories.tsx +42 -0
  101. package/utils/FocusLock.d.ts +13 -0
  102. package/utils/FocusLock.js +139 -0
  103. package/wizard/Wizard.stories.tsx +20 -0
  104. package/common/RequiredComponent.js +0 -32
  105. /package/{tabs-nav → nav-tabs}/NavTabs.d.ts +0 -0
  106. /package/{tabs-nav → nav-tabs}/NavTabs.test.js +0 -0
  107. /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
  108. /package/{tabs-nav → nav-tabs}/types.d.ts +0 -0
  109. /package/{tabs-nav → nav-tabs}/types.js +0 -0
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
2
- import { SwitchPropsType } from "./types";
3
- declare const DxcSwitch: ({ defaultChecked, checked, value, label, labelPosition, name, disabled, optional, onChange, margin, size, tabIndex, }: SwitchPropsType) => JSX.Element;
1
+ import React from "react";
2
+ import SwitchPropsType from "./types";
3
+ declare const DxcSwitch: React.ForwardRefExoticComponent<SwitchPropsType & React.RefAttributes<HTMLDivElement>>;
4
4
  export default DxcSwitch;
package/switch/Switch.js CHANGED
@@ -37,7 +37,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
37
37
 
38
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
39
 
40
- var DxcSwitch = function DxcSwitch(_ref) {
40
+ var DxcSwitch = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
41
41
  var defaultChecked = _ref.defaultChecked,
42
42
  checked = _ref.checked,
43
43
  value = _ref.value,
@@ -102,7 +102,8 @@ var DxcSwitch = function DxcSwitch(_ref) {
102
102
  size: size,
103
103
  onKeyDown: handleOnKeyDown,
104
104
  disabled: disabled,
105
- onClick: !disabled ? handlerSwitchChange : undefined
105
+ onClick: !disabled ? handlerSwitchChange : undefined,
106
+ ref: ref
106
107
  }, labelPosition === "before" && label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
107
108
  id: labelId,
108
109
  labelPosition: labelPosition,
@@ -133,7 +134,7 @@ var DxcSwitch = function DxcSwitch(_ref) {
133
134
  backgroundType: backgroundType,
134
135
  label: label
135
136
  }, optional && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, translatedLabels.formFields.optionalLabel), " ", label)));
136
- };
137
+ });
137
138
 
138
139
  var sizes = {
139
140
  small: "60px",
@@ -233,7 +234,7 @@ var SwitchBase = _styledComponents["default"].label(_templateObject3 || (_templa
233
234
 
234
235
  var ValueInput = _styledComponents["default"].input(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
235
236
 
236
- var SwitchTrack = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n border-radius: 15px;\n width: ", ";\n height: ", ";\n position: relative;\n cursor: ", ";\n\n &:focus-visible {\n outline: none;\n ::before {\n outline: ", ";\n outline-offset: 6px;\n }\n }\n\n /* Thumb element */\n ::before {\n content: \"\";\n transform: initial;\n position: absolute;\n width: ", ";\n height: ", ";\n border-radius: 50%;\n z-index: 1;\n box-shadow: 0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%);\n bottom: -6px;\n left: -4px;\n transform: translateX(0px);\n background-color: ", ";\n }\n\n /* Unchecked */\n background-color: ", ";\n\n /* Checked */\n &[aria-checked=\"true\"] {\n background-color: ", ";\n ::before {\n transform: translateX(", ");\n background-color: ", ";\n }\n }\n"])), function (props) {
237
+ var SwitchTrack = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n border-radius: 15px;\n width: ", ";\n height: ", ";\n position: relative;\n cursor: ", ";\n\n &:focus-visible {\n outline: none;\n ::before {\n outline: ", ";\n outline-offset: 6px;\n }\n }\n\n /* Thumb element */\n ::before {\n content: \"\";\n transform: initial;\n position: absolute;\n width: ", ";\n height: ", ";\n border-radius: 50%;\n box-shadow: 0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%);\n bottom: -6px;\n left: -4px;\n transform: translateX(0px);\n background-color: ", ";\n }\n\n /* Unchecked */\n background-color: ", ";\n\n /* Checked */\n &[aria-checked=\"true\"] {\n background-color: ", ";\n ::before {\n transform: translateX(", ");\n background-color: ", ";\n }\n }\n"])), function (props) {
237
238
  return props.theme.trackWidth;
238
239
  }, function (props) {
239
240
  return props.theme.trackHeight;
@@ -4,12 +4,20 @@ import { BackgroundColorProvider } from "../BackgroundColorContext";
4
4
  import Title from "../../.storybook/components/Title";
5
5
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
6
  import DarkContainer from "../../.storybook/components/DarkSection";
7
+ import { HalstackProvider } from "../HalstackContext";
7
8
 
8
9
  export default {
9
10
  title: "Switch",
10
11
  component: DxcSwitch,
11
12
  };
12
13
 
14
+ const opinionatedTheme = {
15
+ switch: {
16
+ checkedBaseColor: "#5f249f",
17
+ fontColor: "#000000",
18
+ },
19
+ };
20
+
13
21
  export const Chromatic = () => (
14
22
  <>
15
23
  <ExampleContainer>
@@ -134,5 +142,30 @@ export const Chromatic = () => (
134
142
  <Title title="FitContent size" theme="light" level={4} />
135
143
  <DxcSwitch label="FitContent" size="fitContent" />
136
144
  </ExampleContainer>
145
+ <Title title="Opinionated theme" theme="light" level={2} />
146
+ <ExampleContainer>
147
+ <Title title="Checked" theme="light" level={4} />
148
+ <HalstackProvider theme={opinionatedTheme}>
149
+ <DxcSwitch label="Switch" defaultChecked />
150
+ </HalstackProvider>
151
+ </ExampleContainer>
152
+ <ExampleContainer>
153
+ <Title title="Default" theme="light" level={4} />
154
+ <HalstackProvider theme={opinionatedTheme}>
155
+ <DxcSwitch label="Switch" />
156
+ </HalstackProvider>
157
+ </ExampleContainer>
158
+ <ExampleContainer>
159
+ <Title title="Disabled" theme="light" level={4} />
160
+ <HalstackProvider theme={opinionatedTheme}>
161
+ <DxcSwitch label="Switch" disabled />
162
+ </HalstackProvider>
163
+ </ExampleContainer>
164
+ <ExampleContainer>
165
+ <Title title="Disabled checked" theme="light" level={4} />
166
+ <HalstackProvider theme={opinionatedTheme}>
167
+ <DxcSwitch label="Switch" disabled defaultChecked />
168
+ </HalstackProvider>
169
+ </ExampleContainer>
137
170
  </>
138
171
  );
package/switch/types.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare type Margin = {
5
5
  left?: Space;
6
6
  right?: Space;
7
7
  };
8
- export declare type SwitchPropsType = {
8
+ declare type Props = {
9
9
  /**
10
10
  * Initial state of the switch, only when it is uncontrolled.
11
11
  */
@@ -59,3 +59,8 @@ export declare type SwitchPropsType = {
59
59
  */
60
60
  tabIndex?: number;
61
61
  };
62
+ /**
63
+ * Reference to the component.
64
+ */
65
+ export declare type RefType = HTMLDivElement;
66
+ export default Props;
@@ -2,12 +2,21 @@ import React from "react";
2
2
  import DxcTable from "./Table";
3
3
  import Title from "../../.storybook/components/Title";
4
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
+ import { HalstackProvider } from "../HalstackContext";
5
6
 
6
7
  export default {
7
8
  title: "Table",
8
9
  component: DxcTable,
9
10
  };
10
11
 
12
+ const opinionatedTheme = {
13
+ table: {
14
+ baseColor: "#5f249f",
15
+ headerFontColor: "#ffffff",
16
+ cellFontColor: "#000000",
17
+ },
18
+ };
19
+
11
20
  export const Chromatic = () => (
12
21
  <>
13
22
  <ExampleContainer>
@@ -271,7 +280,77 @@ export const Chromatic = () => (
271
280
  <td>Cell 9</td>
272
281
  </tr>
273
282
  </DxcTable>
274
- <hr />
283
+ </ExampleContainer>
284
+ <Title title="Opinionated theme" theme="light" level={2} />
285
+ <ExampleContainer>
286
+ <HalstackProvider theme={opinionatedTheme}>
287
+ <DxcTable>
288
+ <tr>
289
+ <th>
290
+ header<br></br>subheader
291
+ </th>
292
+ <th>
293
+ header<br></br>subheader
294
+ </th>
295
+ <th>
296
+ header<br></br>subheader
297
+ </th>
298
+ </tr>
299
+ <tr>
300
+ <td>
301
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
302
+ dolore magna aliqua.
303
+ </td>
304
+ <td>
305
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
306
+ consequat.
307
+ </td>
308
+ <td>
309
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
310
+ </td>
311
+ </tr>
312
+ <tr>
313
+ <td>cell data</td>
314
+ <td>cell data</td>
315
+ <td>cell data</td>
316
+ </tr>
317
+ <tr>
318
+ <td>cell data</td>
319
+ <td>cell data</td>
320
+ <td>cell data</td>
321
+ </tr>
322
+ <tr>
323
+ <td>cell data</td>
324
+ <td>cell data</td>
325
+ <td>cell data</td>
326
+ </tr>
327
+ <tr>
328
+ <td>cell data</td>
329
+ <td>cell data</td>
330
+ <td>cell data</td>
331
+ </tr>
332
+ <tr>
333
+ <td>cell data</td>
334
+ <td>cell data</td>
335
+ <td>cell data</td>
336
+ </tr>
337
+ <tr>
338
+ <td>cell data</td>
339
+ <td>cell data</td>
340
+ <td>cell data</td>
341
+ </tr>
342
+ <tr>
343
+ <td>cell data</td>
344
+ <td>cell data</td>
345
+ <td>cell data</td>
346
+ </tr>
347
+ <tr>
348
+ <td>cell data</td>
349
+ <td>cell data</td>
350
+ <td>cell data</td>
351
+ </tr>
352
+ </DxcTable>
353
+ </HalstackProvider>
275
354
  </ExampleContainer>
276
355
  </>
277
356
  );
@@ -10,7 +10,7 @@ var _Table = _interopRequireDefault(require("./Table"));
10
10
 
11
11
  describe("Table component tests", function () {
12
12
  test("Table renders with correct content", function () {
13
- var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-6")))),
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Table["default"], null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("th", null, "header-1"), /*#__PURE__*/_react["default"].createElement("th", null, "header-2"), /*#__PURE__*/_react["default"].createElement("th", null, "header-3"))), /*#__PURE__*/_react["default"].createElement("tbody", null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-1"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-2"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-3")), /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", null, "cell-4"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-5"), /*#__PURE__*/_react["default"].createElement("td", null, "cell-6"))))),
14
14
  getByText = _render.getByText;
15
15
 
16
16
  expect(getByText("header-1")).toBeTruthy();
package/tabs/Tab.js CHANGED
@@ -21,7 +21,7 @@ var _Typography = _interopRequireDefault(require("../typography/Typography"));
21
21
 
22
22
  var _useTheme = _interopRequireDefault(require("../useTheme"));
23
23
 
24
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
24
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
25
25
 
26
26
  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); }
27
27
 
@@ -63,7 +63,7 @@ var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
63
63
  }, tab.icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
64
64
  hasLabelAndIcon: hasLabelAndIcon,
65
65
  iconPosition: iconPosition
66
- }, typeof tab.icon === "string" ? /*#__PURE__*/_react["default"].createElement(TabIcon, {
66
+ }, typeof tab.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
67
67
  src: tab.icon
68
68
  }) : tab.icon), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
69
69
  color: tab.isDisabled ? colorsTheme.tabs.disabledFontColor : active ? colorsTheme.tabs.selectedFontColor : colorsTheme.tabs.unselectedFontColor,
@@ -122,14 +122,12 @@ var MainLabelContainer = _styledComponents["default"].div(_templateObject3 || (_
122
122
  return props.hasBadge ? typeof props.hasBadge === "number" ? "calc(".concat(props.theme.badgeWidthWithNotificationNumber, " + 12px)") : "calc(".concat(props.theme.badgeWidth, " + 12px)") : "unset";
123
123
  });
124
124
 
125
- var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 22px;\n max-width: 22px;\n margin-bottom: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n align-items: center;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
125
+ var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n margin-bottom: ", ";\n margin-right: ", ";\n\n img,\n svg {\n height: 22px;\n width: 22px;\n }\n"])), function (props) {
126
126
  return props.hasLabelAndIcon && props.iconPosition === "top" && "8px" || "";
127
127
  }, function (props) {
128
128
  return props.hasLabelAndIcon && props.iconPosition === "left" && "12px" || "";
129
129
  });
130
130
 
131
- var TabIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n display: inline-flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n"])));
132
-
133
131
  var _default = /*#__PURE__*/_react["default"].memo(Tab);
134
132
 
135
133
  exports["default"] = _default;
package/tabs/Tabs.js CHANGED
@@ -395,7 +395,7 @@ var DxcTabs = function DxcTabs(_ref) {
395
395
  }, arrowIcons.right))));
396
396
  };
397
397
 
398
- var Underline = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n left: 0;\n bottom: 0;\n width: 100%;\n position: absolute;\n height: ", ";\n background-color: ", ";\n z-index: 1;\n"])), function (props) {
398
+ var Underline = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n left: 0;\n bottom: 0;\n width: 100%;\n position: absolute;\n height: ", ";\n background-color: ", ";\n"])), function (props) {
399
399
  return props.theme.dividerThickness;
400
400
  }, function (props) {
401
401
  return props.theme.dividerColor;
@@ -441,7 +441,7 @@ var ScrollIndicator = _styledComponents["default"].button(_templateObject4 || (_
441
441
  return props.theme.unselectedFontColor;
442
442
  });
443
443
 
444
- var ActiveIndicator = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n left: ", ";\n width: ", ";\n z-index: 2;\n background-color: ", ";\n bottom: 0;\n height: ", ";\n position: absolute;\n &[aria-disabled=\"true\"] {\n background-color: ", ";\n display: none;\n }\n"])), function (props) {
444
+ var ActiveIndicator = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n left: ", ";\n width: ", ";\n background-color: ", ";\n bottom: 0;\n height: ", ";\n position: absolute;\n &[aria-disabled=\"true\"] {\n background-color: ", ";\n display: none;\n }\n"])), function (props) {
445
445
  return "".concat(props.tabLeft, "px");
446
446
  }, function (props) {
447
447
  return "".concat(props.tabWidth, "px");
@@ -453,7 +453,7 @@ var ActiveIndicator = _styledComponents["default"].span(_templateObject5 || (_te
453
453
  return props.theme.disabledFontColor;
454
454
  });
455
455
 
456
- var TabsContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n z-index: 1;\n flex: 1 1 auto;\n display: inline-block;\n position: relative;\n white-space: nowrap;\n overflow-x: scroll;\n ::-webkit-scrollbar {\n display: none;\n }\n"])));
456
+ var TabsContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex: 1 1 auto;\n display: inline-block;\n position: relative;\n white-space: nowrap;\n overflow-x: scroll;\n ::-webkit-scrollbar {\n display: none;\n }\n"])));
457
457
 
458
458
  var TabList = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n min-height: ", "px;\n"])), function (props) {
459
459
  return props.minHeightTabs;
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import DxcTabs from "./Tabs";
3
3
  import Title from "../../.storybook/components/Title";
4
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
+ import { HalstackProvider } from "../HalstackContext";
5
6
 
6
7
  export default {
7
8
  title: "Tabs",
@@ -9,9 +10,8 @@ export default {
9
10
  };
10
11
 
11
12
  const iconSVG = (
12
- <svg viewBox="0 0 24 24" fill="currentColor">
13
- <path d="M0 0h24v24H0z" fill="none" />
14
- <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
13
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20" fill="currentColor">
14
+ <path d="m10 17-1.042-.938q-2.083-1.854-3.437-3.177-1.354-1.323-2.136-2.354Q2.604 9.5 2.302 8.646 2 7.792 2 6.896q0-1.854 1.271-3.125T6.396 2.5q1.021 0 1.979.438.958.437 1.625 1.229.667-.792 1.625-1.229.958-.438 1.979-.438 1.854 0 3.125 1.271T18 6.896q0 .896-.292 1.729-.291.833-1.073 1.854-.781 1.021-2.145 2.365-1.365 1.344-3.49 3.26Zm0-2.021q1.938-1.729 3.188-2.948 1.25-1.219 1.989-2.125.74-.906 1.031-1.614.292-.709.292-1.396 0-1.229-.833-2.063Q14.833 4 13.604 4q-.729 0-1.364.302-.636.302-1.094.844L10.417 6h-.834l-.729-.854q-.458-.542-1.114-.844Q7.083 4 6.396 4q-1.229 0-2.063.833-.833.834-.833 2.063 0 .687.271 1.364.271.678.989 1.573.719.896 1.98 2.125Q8 13.188 10 14.979Zm0-5.5Z" />
15
15
  </svg>
16
16
  );
17
17
 
@@ -74,10 +74,20 @@ const tabsNotification = tabs.map((tab, index) => ({
74
74
  notificationNumber: (index === 0 && true) || (index === 1 && 5) || (index === 2 && 200),
75
75
  }));
76
76
 
77
- const tabsIcon = tabs.map((tab) => ({ ...tab, icon: iconSVG }));
77
+ const tabsIcon = tabs.map((tab, index) =>
78
+ index <= tabs.length / 2
79
+ ? { ...tab, icon: "https://cdn-icons-png.flaticon.com/512/5039/5039041.png" }
80
+ : { ...tab, icon: iconSVG }
81
+ );
78
82
 
79
83
  const tabsNotificationIcon = tabsNotification.map((tab) => ({ ...tab, icon: iconSVG }));
80
84
 
85
+ const opinionatedTheme = {
86
+ tabs: {
87
+ baseColor: "#5f249f",
88
+ },
89
+ };
90
+
81
91
  export const Chromatic = () => (
82
92
  <>
83
93
  <ExampleContainer>
@@ -152,7 +162,37 @@ export const Chromatic = () => (
152
162
  <ExampleContainer>
153
163
  <Title title="Xxlarge margin" theme="light" level={4} />
154
164
  <DxcTabs tabs={tabs} margin="xxlarge" />
155
- <hr />
165
+ </ExampleContainer>
166
+ <Title title="Opinionated theme" theme="light" level={2} />
167
+ <ExampleContainer>
168
+ <Title title="With icon and notification" theme="light" level={4} />
169
+ <HalstackProvider theme={opinionatedTheme}>
170
+ <DxcTabs tabs={tabsNotificationIcon} />
171
+ </HalstackProvider>
172
+ </ExampleContainer>
173
+ <ExampleContainer>
174
+ <Title title="Disabled" theme="light" level={4} />
175
+ <HalstackProvider theme={opinionatedTheme}>
176
+ <DxcTabs activeTabIndex={0} tabs={disabledTabs} />
177
+ </HalstackProvider>
178
+ </ExampleContainer>
179
+ <ExampleContainer pseudoState="pseudo-hover">
180
+ <Title title="Hovered" theme="light" level={4} />
181
+ <HalstackProvider theme={opinionatedTheme}>
182
+ <DxcTabs tabs={tabs} />
183
+ </HalstackProvider>
184
+ </ExampleContainer>
185
+ <ExampleContainer pseudoState="pseudo-focus">
186
+ <Title title="Focused" theme="light" level={4} />
187
+ <HalstackProvider theme={opinionatedTheme}>
188
+ <DxcTabs tabs={tabs} />
189
+ </HalstackProvider>
190
+ </ExampleContainer>
191
+ <ExampleContainer pseudoState="pseudo-active">
192
+ <Title title="Actived" theme="light" level={4} />
193
+ <HalstackProvider theme={opinionatedTheme}>
194
+ <DxcTabs tabs={tabs} />
195
+ </HalstackProvider>
156
196
  </ExampleContainer>
157
197
  </>
158
198
  );
@@ -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
 
@@ -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() {
@@ -37,7 +64,7 @@ var Suggestion = function Suggestion(_ref) {
37
64
  }, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
38
65
  last: 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) {
@@ -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,
@@ -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;