@dxc-technology/halstack-react 0.0.0-0271b6e → 0.0.0-0276e5a

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 (276) hide show
  1. package/BackgroundColorContext.d.ts +2 -2
  2. package/BackgroundColorContext.js +1 -1
  3. package/HalstackContext.d.ts +1336 -0
  4. package/HalstackContext.js +335 -0
  5. package/accordion/Accordion.d.ts +1 -1
  6. package/accordion/Accordion.js +108 -134
  7. package/accordion/Accordion.stories.tsx +108 -118
  8. package/accordion/Accordion.test.js +10 -11
  9. package/accordion/types.d.ts +1 -12
  10. package/accordion-group/AccordionGroup.d.ts +5 -4
  11. package/accordion-group/AccordionGroup.js +34 -76
  12. package/accordion-group/AccordionGroup.stories.tsx +94 -67
  13. package/accordion-group/AccordionGroup.test.js +33 -50
  14. package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
  15. package/accordion-group/AccordionGroupAccordion.js +43 -0
  16. package/accordion-group/types.d.ts +11 -12
  17. package/alert/Alert.js +9 -10
  18. package/alert/Alert.stories.tsx +28 -0
  19. package/alert/Alert.test.js +1 -1
  20. package/badge/Badge.d.ts +1 -1
  21. package/badge/Badge.js +5 -3
  22. package/badge/types.d.ts +1 -0
  23. package/bleed/Bleed.js +1 -34
  24. package/bleed/Bleed.stories.tsx +95 -95
  25. package/bleed/types.d.ts +1 -1
  26. package/box/Box.d.ts +1 -1
  27. package/box/Box.js +19 -48
  28. package/box/Box.stories.tsx +38 -51
  29. package/box/Box.test.js +1 -1
  30. package/box/types.d.ts +0 -11
  31. package/bulleted-list/BulletedList.d.ts +7 -0
  32. package/bulleted-list/BulletedList.js +125 -0
  33. package/bulleted-list/BulletedList.stories.tsx +206 -0
  34. package/bulleted-list/types.d.ts +38 -0
  35. package/button/Button.js +52 -70
  36. package/button/Button.stories.tsx +159 -8
  37. package/button/Button.test.js +1 -1
  38. package/button/types.d.ts +5 -5
  39. package/card/Card.d.ts +1 -1
  40. package/card/Card.js +37 -58
  41. package/card/Card.stories.tsx +12 -42
  42. package/card/Card.test.js +1 -1
  43. package/card/types.d.ts +1 -6
  44. package/checkbox/Checkbox.d.ts +2 -2
  45. package/checkbox/Checkbox.js +104 -101
  46. package/checkbox/Checkbox.stories.tsx +198 -130
  47. package/checkbox/Checkbox.test.js +94 -17
  48. package/checkbox/types.d.ts +7 -3
  49. package/chip/Chip.js +28 -49
  50. package/chip/Chip.stories.tsx +121 -26
  51. package/chip/Chip.test.js +3 -5
  52. package/chip/types.d.ts +1 -1
  53. package/common/OpenSans.css +68 -80
  54. package/common/coreTokens.d.ts +146 -0
  55. package/common/coreTokens.js +167 -0
  56. package/common/utils.d.ts +1 -0
  57. package/common/utils.js +4 -4
  58. package/common/variables.d.ts +1482 -0
  59. package/common/variables.js +1100 -1112
  60. package/date-input/Calendar.d.ts +4 -0
  61. package/date-input/Calendar.js +258 -0
  62. package/date-input/DateInput.js +155 -240
  63. package/date-input/DateInput.stories.tsx +199 -33
  64. package/date-input/DateInput.test.js +502 -159
  65. package/date-input/DatePicker.d.ts +4 -0
  66. package/date-input/DatePicker.js +146 -0
  67. package/date-input/Icons.d.ts +6 -0
  68. package/date-input/Icons.js +75 -0
  69. package/date-input/YearPicker.d.ts +4 -0
  70. package/date-input/YearPicker.js +126 -0
  71. package/date-input/types.d.ts +63 -9
  72. package/dialog/Dialog.d.ts +1 -1
  73. package/dialog/Dialog.js +68 -103
  74. package/dialog/Dialog.stories.tsx +154 -171
  75. package/dialog/Dialog.test.js +334 -5
  76. package/dialog/types.d.ts +0 -12
  77. package/dropdown/Dropdown.d.ts +1 -1
  78. package/dropdown/Dropdown.js +246 -253
  79. package/dropdown/Dropdown.stories.tsx +245 -56
  80. package/dropdown/Dropdown.test.js +507 -110
  81. package/dropdown/DropdownMenu.d.ts +4 -0
  82. package/dropdown/DropdownMenu.js +74 -0
  83. package/dropdown/DropdownMenuItem.d.ts +4 -0
  84. package/dropdown/DropdownMenuItem.js +79 -0
  85. package/dropdown/types.d.ts +23 -3
  86. package/file-input/FileInput.d.ts +2 -2
  87. package/file-input/FileInput.js +180 -223
  88. package/file-input/FileInput.stories.tsx +122 -11
  89. package/file-input/FileInput.test.js +14 -14
  90. package/file-input/FileItem.d.ts +4 -14
  91. package/file-input/FileItem.js +44 -66
  92. package/file-input/types.d.ts +18 -1
  93. package/flex/Flex.d.ts +4 -0
  94. package/flex/Flex.js +71 -0
  95. package/flex/Flex.stories.tsx +112 -0
  96. package/flex/types.d.ts +97 -0
  97. package/footer/Footer.d.ts +1 -1
  98. package/footer/Footer.js +49 -142
  99. package/footer/Footer.stories.tsx +37 -16
  100. package/footer/Footer.test.js +16 -26
  101. package/footer/Icons.js +1 -1
  102. package/footer/types.d.ts +11 -12
  103. package/grid/Grid.d.ts +7 -0
  104. package/grid/Grid.js +91 -0
  105. package/grid/Grid.stories.tsx +219 -0
  106. package/grid/types.d.ts +115 -0
  107. package/header/Header.d.ts +4 -3
  108. package/header/Header.js +102 -150
  109. package/header/Header.stories.tsx +152 -63
  110. package/header/Header.test.js +20 -4
  111. package/header/Icons.js +2 -2
  112. package/header/types.d.ts +0 -13
  113. package/heading/Heading.js +1 -1
  114. package/heading/Heading.test.js +1 -1
  115. package/inset/Inset.js +1 -34
  116. package/inset/Inset.stories.tsx +37 -36
  117. package/inset/types.d.ts +25 -1
  118. package/layout/ApplicationLayout.d.ts +16 -6
  119. package/layout/ApplicationLayout.js +78 -135
  120. package/layout/ApplicationLayout.stories.tsx +84 -93
  121. package/layout/Icons.d.ts +5 -0
  122. package/layout/Icons.js +13 -2
  123. package/layout/SidenavContext.d.ts +5 -0
  124. package/layout/SidenavContext.js +19 -0
  125. package/layout/types.d.ts +19 -35
  126. package/link/Link.d.ts +3 -2
  127. package/link/Link.js +60 -77
  128. package/link/Link.stories.tsx +155 -53
  129. package/link/Link.test.js +9 -19
  130. package/link/types.d.ts +5 -21
  131. package/main.d.ts +8 -10
  132. package/main.js +47 -57
  133. package/nav-tabs/NavTabs.d.ts +8 -0
  134. package/nav-tabs/NavTabs.js +122 -0
  135. package/nav-tabs/NavTabs.stories.tsx +274 -0
  136. package/nav-tabs/NavTabs.test.js +82 -0
  137. package/nav-tabs/Tab.d.ts +4 -0
  138. package/nav-tabs/Tab.js +146 -0
  139. package/nav-tabs/types.d.ts +52 -0
  140. package/number-input/NumberInput.test.js +46 -12
  141. package/number-input/types.d.ts +13 -10
  142. package/package.json +19 -23
  143. package/paginator/Icons.d.ts +5 -0
  144. package/paginator/Icons.js +16 -28
  145. package/paginator/Paginator.js +20 -49
  146. package/paginator/Paginator.stories.tsx +24 -0
  147. package/paginator/Paginator.test.js +91 -39
  148. package/paragraph/Paragraph.d.ts +5 -0
  149. package/paragraph/Paragraph.js +38 -0
  150. package/paragraph/Paragraph.stories.tsx +44 -0
  151. package/password-input/PasswordInput.js +7 -4
  152. package/password-input/PasswordInput.test.js +17 -19
  153. package/password-input/types.d.ts +14 -11
  154. package/progress-bar/ProgressBar.js +61 -55
  155. package/progress-bar/ProgressBar.stories.jsx +47 -12
  156. package/progress-bar/ProgressBar.test.js +68 -23
  157. package/quick-nav/QuickNav.js +77 -26
  158. package/quick-nav/QuickNav.stories.tsx +145 -26
  159. package/quick-nav/types.d.ts +4 -4
  160. package/radio-group/Radio.d.ts +1 -1
  161. package/radio-group/Radio.js +46 -31
  162. package/radio-group/RadioGroup.js +37 -36
  163. package/radio-group/RadioGroup.stories.tsx +132 -18
  164. package/radio-group/RadioGroup.test.js +124 -97
  165. package/radio-group/types.d.ts +2 -2
  166. package/resultsetTable/Icons.d.ts +7 -0
  167. package/resultsetTable/Icons.js +51 -0
  168. package/resultsetTable/ResultsetTable.js +49 -108
  169. package/resultsetTable/ResultsetTable.stories.tsx +50 -25
  170. package/resultsetTable/ResultsetTable.test.js +61 -42
  171. package/resultsetTable/types.d.ts +1 -1
  172. package/select/Listbox.d.ts +4 -0
  173. package/select/Listbox.js +169 -0
  174. package/select/Option.js +11 -24
  175. package/select/Select.js +150 -224
  176. package/select/Select.stories.tsx +522 -133
  177. package/select/Select.test.js +551 -339
  178. package/select/types.d.ts +32 -13
  179. package/sidenav/Icons.d.ts +7 -0
  180. package/sidenav/Icons.js +51 -0
  181. package/sidenav/Sidenav.d.ts +6 -5
  182. package/sidenav/Sidenav.js +146 -44
  183. package/sidenav/Sidenav.stories.tsx +251 -151
  184. package/sidenav/Sidenav.test.js +25 -37
  185. package/sidenav/types.d.ts +52 -26
  186. package/slider/Slider.d.ts +2 -2
  187. package/slider/Slider.js +121 -97
  188. package/slider/Slider.stories.tsx +64 -1
  189. package/slider/Slider.test.js +122 -22
  190. package/slider/types.d.ts +4 -0
  191. package/spinner/Spinner.js +18 -24
  192. package/spinner/Spinner.stories.jsx +53 -27
  193. package/spinner/Spinner.test.js +1 -1
  194. package/switch/Switch.d.ts +2 -2
  195. package/switch/Switch.js +138 -68
  196. package/switch/Switch.stories.tsx +49 -38
  197. package/switch/Switch.test.js +145 -18
  198. package/switch/types.d.ts +6 -2
  199. package/table/Table.js +3 -3
  200. package/table/Table.stories.jsx +80 -1
  201. package/table/Table.test.js +2 -2
  202. package/tabs/Tab.d.ts +4 -0
  203. package/tabs/Tab.js +132 -0
  204. package/tabs/Tabs.d.ts +1 -1
  205. package/tabs/Tabs.js +360 -112
  206. package/tabs/Tabs.stories.tsx +119 -13
  207. package/tabs/Tabs.test.js +244 -17
  208. package/tabs/types.d.ts +17 -3
  209. package/tag/Tag.js +12 -17
  210. package/tag/Tag.stories.tsx +14 -1
  211. package/tag/Tag.test.js +1 -1
  212. package/tag/types.d.ts +1 -1
  213. package/text-input/Icons.d.ts +8 -0
  214. package/text-input/Icons.js +60 -0
  215. package/text-input/Suggestion.d.ts +4 -0
  216. package/text-input/Suggestion.js +84 -0
  217. package/text-input/Suggestions.d.ts +4 -0
  218. package/text-input/Suggestions.js +134 -0
  219. package/text-input/TextInput.js +221 -346
  220. package/text-input/TextInput.stories.tsx +280 -185
  221. package/text-input/TextInput.test.js +756 -758
  222. package/text-input/types.d.ts +46 -12
  223. package/textarea/Textarea.js +13 -23
  224. package/textarea/Textarea.stories.jsx +60 -1
  225. package/textarea/Textarea.test.js +2 -4
  226. package/textarea/types.d.ts +10 -7
  227. package/toggle-group/ToggleGroup.d.ts +2 -2
  228. package/toggle-group/ToggleGroup.js +12 -8
  229. package/toggle-group/ToggleGroup.stories.tsx +46 -4
  230. package/toggle-group/ToggleGroup.test.js +36 -5
  231. package/toggle-group/types.d.ts +10 -2
  232. package/typography/Typography.d.ts +4 -0
  233. package/typography/Typography.js +32 -0
  234. package/typography/Typography.stories.tsx +198 -0
  235. package/typography/types.d.ts +18 -0
  236. package/typography/types.js +5 -0
  237. package/useTheme.d.ts +1234 -1
  238. package/useTheme.js +3 -3
  239. package/useTranslatedLabels.d.ts +85 -0
  240. package/useTranslatedLabels.js +20 -0
  241. package/utils/BaseTypography.d.ts +21 -0
  242. package/utils/BaseTypography.js +108 -0
  243. package/utils/FocusLock.d.ts +13 -0
  244. package/utils/FocusLock.js +138 -0
  245. package/wizard/Wizard.js +44 -45
  246. package/wizard/Wizard.stories.tsx +40 -1
  247. package/wizard/Wizard.test.js +1 -1
  248. package/wizard/types.d.ts +3 -3
  249. package/ThemeContext.d.ts +0 -10
  250. package/ThemeContext.js +0 -243
  251. package/card/ice-cream.jpg +0 -0
  252. package/common/RequiredComponent.js +0 -32
  253. package/list/List.d.ts +0 -4
  254. package/list/List.js +0 -47
  255. package/list/List.stories.tsx +0 -95
  256. package/list/types.d.ts +0 -7
  257. package/radio/Radio.d.ts +0 -4
  258. package/radio/Radio.js +0 -174
  259. package/radio/Radio.stories.tsx +0 -192
  260. package/radio/Radio.test.js +0 -71
  261. package/radio/types.d.ts +0 -54
  262. package/row/Row.d.ts +0 -3
  263. package/row/Row.js +0 -127
  264. package/row/Row.stories.tsx +0 -237
  265. package/row/types.d.ts +0 -28
  266. package/stack/Stack.d.ts +0 -3
  267. package/stack/Stack.js +0 -97
  268. package/stack/Stack.stories.tsx +0 -164
  269. package/stack/types.d.ts +0 -24
  270. package/text/Text.d.ts +0 -7
  271. package/text/Text.js +0 -30
  272. package/text/Text.stories.tsx +0 -19
  273. /package/{list → bulleted-list}/types.js +0 -0
  274. /package/{radio → flex}/types.js +0 -0
  275. /package/{row → grid}/types.js +0 -0
  276. /package/{stack → nav-tabs}/types.js +0 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _react2 = require("@testing-library/react");
8
+
9
+ var _NavTabs = _interopRequireDefault(require("./NavTabs.tsx"));
10
+
11
+ describe("Tabs component tests", function () {
12
+ test("Tabs render with correct labels and attributes", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NavTabs["default"], null, /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
14
+ href: "/test1",
15
+ active: true
16
+ }, "Tab 1"), /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
17
+ href: "/test2",
18
+ disabled: true
19
+ }, "Tab 2"), /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
20
+ href: "/test3"
21
+ }, "Tab 3"))),
22
+ getByText = _render.getByText,
23
+ getAllByRole = _render.getAllByRole,
24
+ getByRole = _render.getByRole;
25
+
26
+ expect(getByRole("tablist")).toBeTruthy();
27
+ expect(getByRole("tablist").getAttribute("aria-label")).toBe("Navigation tabs");
28
+ expect(getByText("Tab 1")).toBeTruthy();
29
+ expect(getByText("Tab 2")).toBeTruthy();
30
+ expect(getByText("Tab 3")).toBeTruthy();
31
+ var tabs = getAllByRole("tab");
32
+ tabs.forEach(function (tab, index) {
33
+ expect(tab.getAttribute("aria-selected")).toBe((index === 0).toString());
34
+ });
35
+ var anchors = getAllByRole("link");
36
+ expect(anchors.length).toBe(2);
37
+ expect(anchors[0].getAttribute("href")).toBe("/test1");
38
+ expect(anchors[1].getAttribute("href")).toBe("/test3");
39
+ expect(anchors[0].getAttribute("tabindex")).toBe("0");
40
+ expect(anchors[1].getAttribute("tabindex")).toBe("-1");
41
+ });
42
+ test("Tabs render with correct labels, badges and icons", function () {
43
+ var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NavTabs["default"], null, /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
44
+ href: "/test1",
45
+ active: true,
46
+ notificationNumber: 10
47
+ }, "Tab 1"), /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
48
+ href: "/test2",
49
+ disabled: true,
50
+ notificationNumber: 20
51
+ }, "Tab 2"), /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
52
+ href: "/test3",
53
+ notificationNumber: 1000,
54
+ icon: "/testIcon.png"
55
+ }, "Tab 3"))),
56
+ getByText = _render2.getByText,
57
+ getByRole = _render2.getByRole;
58
+
59
+ expect(getByText("10")).toBeTruthy();
60
+ expect(getByText("20")).toBeTruthy();
61
+ expect(getByText("+99")).toBeTruthy();
62
+ expect(getByRole("img")).toBeTruthy();
63
+ });
64
+ test("Tabs render with correct tab index", function () {
65
+ var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NavTabs["default"], {
66
+ tabIndex: 3
67
+ }, /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
68
+ href: "/test1"
69
+ }, "Tab 1"), /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
70
+ href: "/test2",
71
+ disabled: true
72
+ }, "Tab 2"), /*#__PURE__*/_react["default"].createElement(_NavTabs["default"].Tab, {
73
+ href: "/test3",
74
+ active: true
75
+ }, "Tab 3"))),
76
+ getAllByRole = _render3.getAllByRole;
77
+
78
+ var tabs = getAllByRole("link");
79
+ expect(tabs[0].getAttribute("tabindex")).toBe("-1");
80
+ expect(tabs[1].getAttribute("tabindex")).toBe("3");
81
+ });
82
+ });
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { TabProps } from "./types";
3
+ declare const DxcTab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLAnchorElement>>;
4
+ export default DxcTab;
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
+
14
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
+
16
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
+
18
+ var _react = _interopRequireWildcard(require("react"));
19
+
20
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
21
+
22
+ var _Badge = _interopRequireDefault(require("../badge/Badge"));
23
+
24
+ var _Flex = _interopRequireDefault(require("../flex/Flex"));
25
+
26
+ var _NavTabs = require("./NavTabs");
27
+
28
+ var _BaseTypography = _interopRequireDefault(require("../utils/BaseTypography"));
29
+
30
+ var _useTheme = _interopRequireDefault(require("../useTheme"));
31
+
32
+ var _templateObject, _templateObject2, _templateObject3;
33
+
34
+ var _excluded = ["href", "active", "icon", "disabled", "notificationNumber", "children"];
35
+
36
+ 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
+
38
+ 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; }
39
+
40
+ var DxcTab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, _ref2) {
41
+ var href = _ref.href,
42
+ _ref$active = _ref.active,
43
+ active = _ref$active === void 0 ? false : _ref$active,
44
+ icon = _ref.icon,
45
+ _ref$disabled = _ref.disabled,
46
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
47
+ _ref$notificationNumb = _ref.notificationNumber,
48
+ notificationNumber = _ref$notificationNumb === void 0 ? false : _ref$notificationNumb,
49
+ children = _ref.children,
50
+ otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
51
+ var tabRef = (0, _react.useRef)();
52
+ var colorsTheme = (0, _useTheme["default"])();
53
+
54
+ var _useContext = (0, _react.useContext)(_NavTabs.NavTabsContext),
55
+ iconPosition = _useContext.iconPosition,
56
+ tabIndex = _useContext.tabIndex,
57
+ focusedLabel = _useContext.focusedLabel;
58
+
59
+ (0, _react.useEffect)(function () {
60
+ var _tabRef$current;
61
+
62
+ focusedLabel === children.toString() && (tabRef === null || tabRef === void 0 ? void 0 : (_tabRef$current = tabRef.current) === null || _tabRef$current === void 0 ? void 0 : _tabRef$current.focus());
63
+ }, [focusedLabel]);
64
+
65
+ var handleOnKeyDown = function handleOnKeyDown(event) {
66
+ var _tabRef$current2;
67
+
68
+ switch (event.key) {
69
+ case " ":
70
+ case "Enter":
71
+ event.preventDefault();
72
+ tabRef === null || tabRef === void 0 ? void 0 : (_tabRef$current2 = tabRef.current) === null || _tabRef$current2 === void 0 ? void 0 : _tabRef$current2.click();
73
+ break;
74
+ }
75
+ };
76
+
77
+ return /*#__PURE__*/_react["default"].createElement(TabContainer, {
78
+ active: active,
79
+ role: "tab",
80
+ "aria-selected": active,
81
+ "aria-disabled": disabled
82
+ }, /*#__PURE__*/_react["default"].createElement(Tab, (0, _extends2["default"])({
83
+ href: !disabled ? href : undefined,
84
+ disabled: disabled,
85
+ active: active,
86
+ iconPosition: iconPosition,
87
+ hasIcon: icon != null ? true : false,
88
+ ref: function ref(anchorRef) {
89
+ tabRef.current = anchorRef;
90
+
91
+ if (_ref2) {
92
+ if (typeof _ref2 === "function") _ref2(anchorRef);else _ref2.current = anchorRef;
93
+ }
94
+ },
95
+ onKeyDown: handleOnKeyDown,
96
+ tabIndex: active ? tabIndex : -1
97
+ }, otherProps), icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
98
+ iconPosition: iconPosition
99
+ }, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
100
+ src: icon
101
+ }) : icon), /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
102
+ alignItems: "center",
103
+ gap: "0.5rem"
104
+ }, /*#__PURE__*/_react["default"].createElement(_BaseTypography["default"], {
105
+ color: disabled ? colorsTheme.navTabs.disabledFontColor : active ? colorsTheme.navTabs.selectedFontColor : colorsTheme.navTabs.unselectedFontColor,
106
+ fontFamily: colorsTheme.navTabs.fontFamily,
107
+ fontSize: colorsTheme.navTabs.fontSize,
108
+ fontStyle: colorsTheme.navTabs.fontStyle,
109
+ fontWeight: colorsTheme.navTabs.fontWeight,
110
+ textAlign: "center",
111
+ letterSpacing: "0.025em",
112
+ lineHeight: "1.715em"
113
+ }, children), notificationNumber && /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
114
+ notificationText: typeof notificationNumber === "number" && notificationNumber > 99 ? "+99" : notificationNumber,
115
+ disabled: disabled
116
+ }))));
117
+ });
118
+
119
+ var TabContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n align-items: stretch;\n border-bottom: 2px solid ", ";\n padding: 0.5rem;\n\n svg {\n color: ", ";\n }\n &[aria-selected=\"true\"] {\n svg {\n color: ", ";\n }\n }\n &[aria-disabled=\"true\"] {\n svg {\n color: ", ";\n }\n }\n"])), function (props) {
120
+ return props.active ? props.theme.selectedUnderlineColor : props.theme.dividerColor;
121
+ }, function (props) {
122
+ return props.theme.unselectedIconColor;
123
+ }, function (props) {
124
+ return props.theme.selectedIconColor;
125
+ }, function (props) {
126
+ return props.theme.disabledIconColor;
127
+ });
128
+
129
+ var Tab = _styledComponents["default"].a(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: ", ";\n justify-content: center;\n align-items: center;\n gap: ", ";\n height: ", ";\n min-width: 176px;\n min-height: 44px;\n padding: 0.375rem;\n border-radius: 4px;\n background: ", ";\n text-decoration-color: transparent;\n cursor: ", ";\n\n ", "\n"])), function (props) {
130
+ return props.hasIcon && props.iconPosition === "top" ? "column" : "row";
131
+ }, function (props) {
132
+ return props.hasIcon && props.iconPosition === "top" ? "0.375rem" : "0.625rem";
133
+ }, function (props) {
134
+ return props.hasIcon && props.iconPosition === "top" ? "78px" : "100%";
135
+ }, function (props) {
136
+ return props.active ? props.theme.selectedBackgroundColor : props.theme.unselectedBackgroundColor;
137
+ }, function (props) {
138
+ return props.disabled ? "not-allowed" : "pointer";
139
+ }, function (props) {
140
+ return !props.disabled && "\n :hover {\n background: ".concat(props.theme.hoverBackgroundColor, ";\n }\n :focus {\n outline: 2px solid ").concat(props.theme.focusOutline, ";\n }\n :active {\n background: ").concat(props.theme.pressedBackgroundColor, ";\n outline: 2px solid #33aaff};\n }\n ");
141
+ });
142
+
143
+ var TabIconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n\n img,\n svg {\n height: 24px;\n width: 24px;\n }\n"])));
144
+
145
+ var _default = DxcTab;
146
+ exports["default"] = _default;
@@ -0,0 +1,52 @@
1
+ /// <reference types="react" />
2
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
3
+ export declare type NavTabsContextProps = {
4
+ iconPosition: "top" | "left";
5
+ tabIndex: number;
6
+ focusedLabel: string;
7
+ };
8
+ export declare type TabProps = {
9
+ /**
10
+ * Whether the tab is active or not.
11
+ */
12
+ active?: boolean;
13
+ /**
14
+ * Whether the tab is disabled or not.
15
+ */
16
+ disabled?: boolean;
17
+ /**
18
+ * Page to be opened when the user clicks on the tab.
19
+ */
20
+ href?: string;
21
+ /**
22
+ * Element or path used as the icon that will be displayed in the tab.
23
+ */
24
+ icon?: string | SVG;
25
+ /**
26
+ * If the value is 'true', an empty badge will appear.
27
+ * If it is 'false', no badge will appear.
28
+ * If a number is put it will be shown as the label of the notification
29
+ * in the tab, taking into account that if that number is greater than 99,
30
+ * it will appear as '+99' in the badge.
31
+ */
32
+ notificationNumber?: boolean | number;
33
+ /**
34
+ * Contains one or more DxcNavTabs.Tab.
35
+ */
36
+ children: string;
37
+ };
38
+ declare type Props = {
39
+ /**
40
+ * Whether the icon should appear above or to the left of the label.
41
+ */
42
+ iconPosition?: "top" | "left";
43
+ /**
44
+ * Value of the tabindex for each tab.
45
+ */
46
+ tabIndex?: number;
47
+ /**
48
+ * Content of the tabs nav.
49
+ */
50
+ children: React.ReactNode;
51
+ };
52
+ export default Props;
@@ -8,7 +8,7 @@ var _react2 = require("@testing-library/react");
8
8
 
9
9
  var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
10
10
 
11
- var _NumberInput = _interopRequireDefault(require("./NumberInput"));
11
+ var _NumberInput = _interopRequireDefault(require("./NumberInput.tsx"));
12
12
 
13
13
  describe("Number input component tests", function () {
14
14
  test("Number input renders with label", function () {
@@ -83,7 +83,7 @@ describe("Number input component tests", function () {
83
83
  })),
84
84
  getByRole = _render8.getByRole;
85
85
 
86
- var input = getByRole("textbox");
86
+ var input = getByRole("spinbutton");
87
87
 
88
88
  _userEvent["default"].type(input, "1");
89
89
 
@@ -135,16 +135,14 @@ describe("Number input component tests", function () {
135
135
  _userEvent["default"].type(number, "t");
136
136
 
137
137
  expect(onChange).not.toHaveBeenCalledWith({
138
- value: "t",
139
- error: null
138
+ value: "t"
140
139
  });
141
140
  expect(number.value).toBe("");
142
141
 
143
142
  _userEvent["default"].type(number, "1");
144
143
 
145
144
  expect(onChange).toHaveBeenCalledWith({
146
- value: "1",
147
- error: null
145
+ value: "1"
148
146
  });
149
147
  expect(number.value).toBe("1");
150
148
  });
@@ -368,12 +366,7 @@ describe("Number input component tests", function () {
368
366
  expect(number.value).toBe("10");
369
367
  });
370
368
  test("Increment and decrement the value with min, max and step", function () {
371
- var onBlur = jest.fn(function (_ref3) {
372
- var value = _ref3.value,
373
- error = _ref3.error;
374
- expect(value).toBe("1");
375
- expect(error).toBe("Value must be greater than or equal to 5.");
376
- });
369
+ var onBlur = jest.fn();
377
370
 
378
371
  var _render20 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
379
372
  label: "Number input label",
@@ -391,6 +384,10 @@ describe("Number input component tests", function () {
391
384
 
392
385
  _react2.fireEvent.blur(number);
393
386
 
387
+ expect(onBlur).toHaveBeenCalledWith({
388
+ value: "1",
389
+ error: "Value must be greater than or equal to 5."
390
+ });
394
391
  var increment = getAllByRole("button")[1];
395
392
 
396
393
  _userEvent["default"].click(increment);
@@ -505,4 +502,41 @@ describe("Number input component tests", function () {
505
502
  var increment = getAllByRole("button")[1];
506
503
  expect(increment.getAttribute("aria-label")).toBe("Increment value");
507
504
  });
505
+ test("Number input submits correct values in a form", function () {
506
+ var handlerOnSubmit = jest.fn(function (e) {
507
+ e.preventDefault();
508
+ var formData = new FormData(e.target);
509
+ var formProps = Object.fromEntries(formData);
510
+ expect(formProps).toStrictEqual({
511
+ data: "0"
512
+ });
513
+ });
514
+
515
+ var _render23 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement("form", {
516
+ onSubmit: handlerOnSubmit
517
+ }, /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
518
+ label: "Number input label",
519
+ name: "data"
520
+ }), /*#__PURE__*/_react["default"].createElement("button", {
521
+ type: "submit"
522
+ }, "Submit"))),
523
+ getByText = _render23.getByText,
524
+ getAllByRole = _render23.getAllByRole;
525
+
526
+ var less = getAllByRole("button")[0];
527
+ var more = getAllByRole("button")[1];
528
+ var submit = getByText("Submit");
529
+
530
+ _userEvent["default"].click(more);
531
+
532
+ expect(handlerOnSubmit).not.toHaveBeenCalled();
533
+
534
+ _userEvent["default"].click(less);
535
+
536
+ expect(handlerOnSubmit).not.toHaveBeenCalled();
537
+
538
+ _userEvent["default"].click(submit);
539
+
540
+ expect(handlerOnSubmit).toHaveBeenCalled();
541
+ });
508
542
  });
@@ -54,7 +54,7 @@ declare type Props = {
54
54
  * lower than min, the onBlur and onChange functions will be called with
55
55
  * the current value and an internal error informing that the current
56
56
  * value is not correct. If a valid state is reached, the error parameter
57
- * will be null in both events.
57
+ * will not be defined in both events.
58
58
  */
59
59
  min?: number;
60
60
  /**
@@ -62,7 +62,7 @@ declare type Props = {
62
62
  * surpasses max, the onBlur and onChange functions will be called with
63
63
  * the current value and an internal error informing that the current
64
64
  * value is not correct. If a valid state is reached, the error parameter
65
- * will be null in both events.
65
+ * will not be defined in both events.
66
66
  */
67
67
  max?: number;
68
68
  /**
@@ -73,26 +73,29 @@ declare type Props = {
73
73
  * This function will be called when the user types within the input
74
74
  * element of the component. An object including the current value and
75
75
  * the error (if the value entered is not valid) will be passed to this
76
- * function. If there is no error, error will be null.
76
+ * function. If there is no error, error will not be defined.
77
77
  */
78
78
  onChange?: (val: {
79
79
  value: string;
80
- error: string | null;
80
+ error?: string;
81
81
  }) => void;
82
82
  /**
83
83
  * This function will be called when the input element loses the focus.
84
84
  * An object including the input value and the error (if the value
85
85
  * entered is not valid) will be passed to this function. If there is no error,
86
- * error will be null.
86
+ * error will not be defined.
87
87
  */
88
88
  onBlur?: (val: {
89
89
  value: string;
90
- error: string | null;
90
+ error?: string;
91
91
  }) => void;
92
92
  /**
93
- * If it is defined, the component will change its appearance, showing
94
- * the error below the input component. If it is not defined, the error
95
- * messages will be managed internally, but never displayed on its own.
93
+ * If it is a defined value and also a truthy string, the component will
94
+ * change its appearance, showing the error below the input component. If
95
+ * the defined value is an empty string, it will reserve a space below
96
+ * the component for a future error, but it would not change its look. In
97
+ * case of being undefined or null, both the appearance and the space for
98
+ * the error message would not be modified.
96
99
  */
97
100
  error?: string;
98
101
  /**
@@ -106,7 +109,7 @@ declare type Props = {
106
109
  */
107
110
  margin?: Space | Margin;
108
111
  /**
109
- * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
112
+ * Size of the component.
110
113
  */
111
114
  size?: "small" | "medium" | "large" | "fillParent";
112
115
  /**
package/package.json CHANGED
@@ -1,44 +1,36 @@
1
1
  {
2
2
  "name": "@dxc-technology/halstack-react",
3
- "version": "0.0.0-0271b6e",
3
+ "version": "0.0.0-0276e5a",
4
4
  "description": "DXC Halstack React components library",
5
5
  "repository": "dxc-technology/halstack-react",
6
- "homepage": "http://developer.dxc.com/tools/react",
6
+ "homepage": "https://developer.dxc.com/halstack",
7
7
  "license": "Apache-2.0",
8
8
  "author": {
9
9
  "name": "DXC Technology",
10
10
  "email": "DigitalInsurance@dxc.com",
11
- "url": "https://dxc.com"
11
+ "url": "https://developer.dxc.com"
12
12
  },
13
13
  "main": "./main.js",
14
14
  "types": "./main.d.ts",
15
15
  "peerDependencies": {
16
- "react": "^17.0.1",
17
- "react-dom": "^17.0.1",
16
+ "react": "^18.x",
17
+ "react-dom": "^18.x",
18
18
  "styled-components": "^5.0.1"
19
19
  },
20
20
  "dependencies": {
21
- "@date-io/date-fns": "^1.3.9",
22
- "@material-ui/core": "4.11.1",
23
- "@material-ui/icons": "4.4.3",
24
- "@material-ui/lab": "4.0.0-alpha.17",
25
- "@material-ui/pickers": "3.2.2",
26
- "@material-ui/styles": "4.0.2",
21
+ "@radix-ui/react-popover": "0.1.6",
27
22
  "@types/styled-components": "^5.1.24",
28
23
  "@types/uuid": "^8.3.4",
29
24
  "color": "^3.1.3",
30
- "date-fns": "^2.0.0-beta.4",
31
- "moment": "2.24.0",
32
- "prop-types": "^15.7.2",
33
- "rgb-hex": "^3.0.0",
25
+ "dayjs": "^1.11.1",
34
26
  "slugify": "^1.6.5",
35
27
  "uuid": "^8.3.2"
36
28
  },
37
29
  "scripts": {
38
- "test": "jest",
30
+ "test": "jest --env=jsdom",
39
31
  "test:watch": "npm test -- --watch --coverage",
40
32
  "build": "babel src --extensions .js,.jsx,.ts,.tsx --out-dir ../dist --copy-files --verbose && node ../scripts/build/copy-package.js && tsc ",
41
- "build:watch": "babel src --watch --out-dir ../dist --copy-files --verbose",
33
+ "build:watch": "babel src --watch --extensions .js,.jsx,.ts,.tsx --out-dir ../dist --copy-files --verbose",
42
34
  "storybook": "start-storybook -p 6006",
43
35
  "build-storybook": "build-storybook"
44
36
  },
@@ -56,8 +48,10 @@
56
48
  "@storybook/addon-links": "^6.4.9",
57
49
  "@storybook/react": "^6.4.9",
58
50
  "@storybook/testing-library": "0.0.7",
59
- "@testing-library/react": "^11.2.5",
60
- "@testing-library/user-event": "^12.6.3",
51
+ "@testing-library/react": "^13.0.0",
52
+ "@testing-library/user-event": "^13.0.0",
53
+ "@types/color": "^3.0.3",
54
+ "@types/react": "^18.0.18",
61
55
  "babel-jest": "^24.8.0",
62
56
  "babel-loader": "^8.0.6",
63
57
  "chromatic": "^6.3.3",
@@ -71,9 +65,10 @@
71
65
  "eslint-plugin-react-hooks": "^4.2.0",
72
66
  "eslint-plugin-storybook": "^0.5.5",
73
67
  "identity-obj-proxy": "^3.0.0",
74
- "jest": "^25.5.4",
75
- "react": "^17.0.1",
76
- "react-dom": "^17.0.1",
68
+ "jest": "^29.2.2",
69
+ "jest-environment-jsdom": "^29.3.1",
70
+ "react": "^18.x",
71
+ "react-dom": "^18.x",
77
72
  "react-test-renderer": "^16.8.6",
78
73
  "storybook-addon-pseudo-states": "^1.0.0",
79
74
  "styled-components": "^5.0.1",
@@ -83,7 +78,8 @@
83
78
  "moduleNameMapper": {
84
79
  "\\.(css|less|scss|sass)$": "identity-obj-proxy",
85
80
  "\\.(svg)$": "<rootDir>/test/mocks/svgMock.js",
86
- "\\.(png)$": "<rootDir>/test/mocks/pngMock.js"
81
+ "\\.(png)$": "<rootDir>/test/mocks/pngMock.js",
82
+ "^uuid$": "uuid"
87
83
  }
88
84
  }
89
85
  }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare const firstIcon: JSX.Element;
3
+ export declare const previousIcon: JSX.Element;
4
+ export declare const nextIcon: JSX.Element;
5
+ export declare const lastIcon: JSX.Element;
@@ -11,56 +11,44 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var firstIcon = /*#__PURE__*/_react["default"].createElement("svg", {
13
13
  xmlns: "http://www.w3.org/2000/svg",
14
- width: "12.41",
15
- height: "12",
16
- viewBox: "0 0 12.41 12"
14
+ height: "24",
15
+ width: "24",
16
+ fill: "currentColor"
17
17
  }, /*#__PURE__*/_react["default"].createElement("path", {
18
- id: "Path_2463",
19
- "data-name": "Path 2463",
20
- d: "M18.41,16.59,13.82,12l4.59-4.59L17,6l-6,6,6,6ZM6,6H8V18H6Z",
21
- transform: "translate(-6 -6)"
18
+ d: "M6 18V6h2v12Zm11 0-6-6 6-6 1.4 1.4-4.6 4.6 4.6 4.6Z"
22
19
  }));
23
20
 
24
21
  exports.firstIcon = firstIcon;
25
22
 
26
23
  var previousIcon = /*#__PURE__*/_react["default"].createElement("svg", {
27
24
  xmlns: "http://www.w3.org/2000/svg",
28
- width: "7.41",
29
- height: "12",
30
- viewBox: "0 0 7.41 12"
25
+ height: "24",
26
+ width: "24",
27
+ fill: "currentColor"
31
28
  }, /*#__PURE__*/_react["default"].createElement("path", {
32
- id: "Path_2459",
33
- "data-name": "Path 2459",
34
- d: "M15.41,7.41,14,6,8,12l6,6,1.41-1.41L10.83,12Z",
35
- transform: "translate(-8 -6)"
29
+ d: "m14 18-6-6 6-6 1.4 1.4-4.6 4.6 4.6 4.6Z"
36
30
  }));
37
31
 
38
32
  exports.previousIcon = previousIcon;
39
33
 
40
34
  var nextIcon = /*#__PURE__*/_react["default"].createElement("svg", {
41
35
  xmlns: "http://www.w3.org/2000/svg",
42
- width: "7.41",
43
- height: "12",
44
- viewBox: "0 0 7.41 12"
36
+ height: "24",
37
+ width: "24",
38
+ fill: "currentColor"
45
39
  }, /*#__PURE__*/_react["default"].createElement("path", {
46
- id: "Path_2461",
47
- "data-name": "Path 2461",
48
- d: "M10,6,8.59,7.41,13.17,12,8.59,16.59,10,18l6-6Z",
49
- transform: "translate(-8.59 -6)"
40
+ d: "M9.4 18 8 16.6l4.6-4.6L8 7.4 9.4 6l6 6Z"
50
41
  }));
51
42
 
52
43
  exports.nextIcon = nextIcon;
53
44
 
54
45
  var lastIcon = /*#__PURE__*/_react["default"].createElement("svg", {
55
46
  xmlns: "http://www.w3.org/2000/svg",
56
- width: "12.41",
57
- height: "12",
58
- viewBox: "0 0 12.41 12"
47
+ height: "24",
48
+ width: "24",
49
+ fill: "currentColor"
59
50
  }, /*#__PURE__*/_react["default"].createElement("path", {
60
- id: "Path_2465",
61
- "data-name": "Path 2465",
62
- d: "M5.59,7.41,10.18,12,5.59,16.59,7,18l6-6L7,6ZM16,6h2V18H16Z",
63
- transform: "translate(-5.59 -6)"
51
+ d: "m7 18-1.4-1.4 4.6-4.6-4.6-4.6L7 6l6 6Zm9 0V6h2v12Z"
64
52
  }));
65
53
 
66
54
  exports.lastIcon = lastIcon;