@dxc-technology/halstack-react 0.0.0-da4b2be → 0.0.0-da9270d

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 (236) hide show
  1. package/BackgroundColorContext.d.ts +1 -10
  2. package/BackgroundColorContext.js +4 -21
  3. package/HalstackContext.d.ts +23 -124
  4. package/HalstackContext.js +10 -35
  5. package/README.md +47 -0
  6. package/accordion/Accordion.d.ts +1 -1
  7. package/accordion/Accordion.js +24 -76
  8. package/accordion/Accordion.stories.tsx +1 -113
  9. package/accordion/Accordion.test.js +18 -33
  10. package/accordion/types.d.ts +5 -17
  11. package/accordion-group/AccordionGroup.js +15 -42
  12. package/accordion-group/AccordionGroup.stories.tsx +78 -77
  13. package/accordion-group/AccordionGroup.test.js +43 -71
  14. package/accordion-group/AccordionGroupAccordion.js +9 -21
  15. package/accordion-group/types.d.ts +6 -18
  16. package/alert/Alert.js +15 -50
  17. package/alert/Alert.test.js +28 -45
  18. package/alert/types.d.ts +5 -5
  19. package/badge/Badge.js +4 -17
  20. package/badge/types.d.ts +1 -1
  21. package/bleed/Bleed.js +13 -21
  22. package/bleed/types.d.ts +2 -2
  23. package/box/Box.js +11 -33
  24. package/box/Box.test.js +1 -6
  25. package/box/types.d.ts +3 -3
  26. package/bulleted-list/BulletedList.js +18 -54
  27. package/bulleted-list/BulletedList.stories.tsx +1 -92
  28. package/bulleted-list/types.d.ts +5 -5
  29. package/button/Button.d.ts +1 -1
  30. package/button/Button.js +66 -99
  31. package/button/Button.stories.tsx +6 -87
  32. package/button/Button.test.js +17 -16
  33. package/button/types.d.ts +8 -4
  34. package/card/Card.d.ts +1 -1
  35. package/card/Card.js +39 -79
  36. package/card/Card.stories.tsx +0 -29
  37. package/card/Card.test.js +10 -21
  38. package/card/types.d.ts +6 -12
  39. package/checkbox/Checkbox.js +85 -120
  40. package/checkbox/Checkbox.stories.tsx +16 -54
  41. package/checkbox/Checkbox.test.js +107 -63
  42. package/checkbox/types.d.ts +8 -4
  43. package/chip/Chip.js +12 -31
  44. package/chip/Chip.stories.tsx +1 -1
  45. package/chip/Chip.test.js +15 -28
  46. package/chip/types.d.ts +4 -4
  47. package/common/coreTokens.d.ts +105 -14
  48. package/common/coreTokens.js +41 -24
  49. package/common/utils.js +2 -8
  50. package/common/variables.d.ts +23 -124
  51. package/common/variables.js +27 -135
  52. package/container/Container.d.ts +4 -0
  53. package/container/Container.js +194 -0
  54. package/container/Container.stories.tsx +214 -0
  55. package/container/types.d.ts +74 -0
  56. package/date-input/Calendar.js +15 -59
  57. package/date-input/DateInput.js +50 -96
  58. package/date-input/DateInput.stories.tsx +11 -30
  59. package/date-input/DateInput.test.js +674 -701
  60. package/date-input/DatePicker.js +11 -42
  61. package/date-input/Icons.d.ts +6 -6
  62. package/date-input/Icons.js +6 -23
  63. package/date-input/YearPicker.js +8 -34
  64. package/date-input/types.d.ts +27 -21
  65. package/dialog/Dialog.js +13 -40
  66. package/dialog/Dialog.stories.tsx +170 -0
  67. package/dialog/Dialog.test.js +125 -187
  68. package/dialog/types.d.ts +18 -13
  69. package/dropdown/Dropdown.js +39 -93
  70. package/dropdown/Dropdown.test.js +391 -378
  71. package/dropdown/DropdownMenu.js +8 -19
  72. package/dropdown/DropdownMenuItem.js +5 -17
  73. package/dropdown/types.d.ts +17 -19
  74. package/file-input/FileInput.js +180 -248
  75. package/file-input/FileInput.stories.tsx +1 -1
  76. package/file-input/FileInput.test.js +356 -354
  77. package/file-input/FileItem.js +14 -41
  78. package/file-input/types.d.ts +10 -10
  79. package/flex/Flex.js +25 -39
  80. package/flex/types.d.ts +6 -6
  81. package/footer/Footer.d.ts +1 -1
  82. package/footer/Footer.js +54 -112
  83. package/footer/Footer.stories.tsx +19 -95
  84. package/footer/Footer.test.js +21 -33
  85. package/footer/Icons.d.ts +2 -2
  86. package/footer/Icons.js +2 -7
  87. package/footer/types.d.ts +21 -29
  88. package/grid/Grid.d.ts +1 -1
  89. package/grid/Grid.js +2 -17
  90. package/grid/Grid.stories.tsx +38 -38
  91. package/grid/types.d.ts +10 -10
  92. package/header/Header.d.ts +2 -2
  93. package/header/Header.js +31 -114
  94. package/header/Header.stories.tsx +7 -71
  95. package/header/Header.test.js +12 -25
  96. package/header/Icons.d.ts +2 -2
  97. package/header/Icons.js +2 -7
  98. package/header/types.d.ts +5 -20
  99. package/heading/Heading.js +9 -31
  100. package/heading/Heading.test.js +70 -87
  101. package/heading/types.d.ts +7 -7
  102. package/image/Image.d.ts +4 -0
  103. package/image/Image.js +70 -0
  104. package/image/Image.stories.tsx +127 -0
  105. package/image/types.d.ts +72 -0
  106. package/inset/Inset.js +13 -21
  107. package/inset/types.d.ts +2 -2
  108. package/layout/ApplicationLayout.d.ts +3 -3
  109. package/layout/ApplicationLayout.js +28 -65
  110. package/layout/ApplicationLayout.stories.tsx +1 -1
  111. package/layout/Icons.d.ts +8 -5
  112. package/layout/Icons.js +51 -59
  113. package/layout/SidenavContext.d.ts +1 -1
  114. package/layout/SidenavContext.js +3 -9
  115. package/layout/types.d.ts +3 -3
  116. package/link/Link.js +21 -42
  117. package/link/Link.test.js +23 -41
  118. package/link/types.d.ts +14 -14
  119. package/main.d.ts +4 -3
  120. package/main.js +17 -58
  121. package/nav-tabs/NavTabs.js +11 -43
  122. package/nav-tabs/NavTabs.stories.tsx +1 -1
  123. package/nav-tabs/NavTabs.test.js +36 -43
  124. package/nav-tabs/Tab.js +16 -45
  125. package/nav-tabs/types.d.ts +9 -9
  126. package/number-input/NumberInput.d.ts +7 -0
  127. package/number-input/NumberInput.js +26 -35
  128. package/number-input/NumberInput.stories.tsx +42 -26
  129. package/number-input/NumberInput.test.js +700 -412
  130. package/number-input/types.d.ts +11 -5
  131. package/package.json +30 -28
  132. package/paginator/Icons.d.ts +5 -5
  133. package/paginator/Icons.js +5 -19
  134. package/paginator/Paginator.js +15 -43
  135. package/paginator/Paginator.test.js +224 -207
  136. package/paginator/types.d.ts +3 -3
  137. package/paragraph/Paragraph.js +3 -19
  138. package/paragraph/Paragraph.stories.tsx +0 -17
  139. package/password-input/Icons.d.ts +6 -0
  140. package/password-input/Icons.js +35 -0
  141. package/password-input/PasswordInput.js +57 -126
  142. package/password-input/PasswordInput.stories.tsx +1 -33
  143. package/password-input/PasswordInput.test.js +157 -140
  144. package/password-input/types.d.ts +8 -7
  145. package/progress-bar/ProgressBar.js +21 -53
  146. package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
  147. package/progress-bar/ProgressBar.test.js +35 -52
  148. package/progress-bar/types.d.ts +3 -3
  149. package/quick-nav/QuickNav.js +4 -27
  150. package/quick-nav/QuickNav.stories.tsx +1 -1
  151. package/quick-nav/types.d.ts +10 -10
  152. package/radio-group/Radio.d.ts +1 -1
  153. package/radio-group/Radio.js +22 -54
  154. package/radio-group/RadioGroup.js +37 -83
  155. package/radio-group/RadioGroup.stories.tsx +10 -10
  156. package/radio-group/RadioGroup.test.js +504 -470
  157. package/radio-group/types.d.ts +8 -8
  158. package/resultset-table/Icons.d.ts +7 -0
  159. package/{resultsetTable → resultset-table}/Icons.js +1 -5
  160. package/{resultsetTable → resultset-table}/ResultsetTable.js +23 -59
  161. package/{resultsetTable → resultset-table}/ResultsetTable.test.js +72 -92
  162. package/{resultsetTable → resultset-table}/types.d.ts +7 -7
  163. package/resultset-table/types.js +5 -0
  164. package/select/Icons.d.ts +7 -7
  165. package/select/Icons.js +1 -5
  166. package/select/Listbox.js +13 -39
  167. package/select/Option.js +9 -26
  168. package/select/Select.js +70 -155
  169. package/select/Select.stories.tsx +3 -3
  170. package/select/Select.test.js +1946 -1804
  171. package/select/types.d.ts +14 -15
  172. package/sidenav/Icons.d.ts +4 -4
  173. package/sidenav/Icons.js +1 -5
  174. package/sidenav/Sidenav.js +26 -68
  175. package/sidenav/Sidenav.test.js +3 -10
  176. package/sidenav/types.d.ts +18 -18
  177. package/slider/Slider.js +68 -125
  178. package/slider/Slider.test.js +107 -103
  179. package/slider/types.d.ts +4 -4
  180. package/spinner/Spinner.js +16 -54
  181. package/spinner/Spinner.test.js +25 -34
  182. package/spinner/types.d.ts +3 -3
  183. package/switch/Switch.js +49 -97
  184. package/switch/Switch.stories.tsx +0 -34
  185. package/switch/Switch.test.js +51 -96
  186. package/switch/types.d.ts +4 -4
  187. package/table/Table.js +5 -27
  188. package/table/Table.test.js +1 -6
  189. package/table/types.d.ts +8 -8
  190. package/tabs/Tab.js +10 -29
  191. package/tabs/Tabs.js +52 -129
  192. package/tabs/Tabs.test.js +62 -118
  193. package/tabs/types.d.ts +19 -19
  194. package/tag/Tag.js +21 -51
  195. package/tag/Tag.test.js +19 -30
  196. package/tag/types.d.ts +7 -7
  197. package/text-input/Icons.d.ts +5 -5
  198. package/text-input/Icons.js +1 -5
  199. package/text-input/Suggestion.js +9 -26
  200. package/text-input/Suggestions.d.ts +1 -1
  201. package/text-input/Suggestions.js +15 -65
  202. package/text-input/TextInput.js +204 -284
  203. package/text-input/TextInput.stories.tsx +48 -152
  204. package/text-input/TextInput.test.js +1210 -1194
  205. package/text-input/types.d.ts +25 -17
  206. package/textarea/Textarea.js +67 -109
  207. package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -100
  208. package/textarea/Textarea.test.js +150 -179
  209. package/textarea/types.d.ts +9 -5
  210. package/toggle-group/ToggleGroup.js +90 -107
  211. package/toggle-group/ToggleGroup.stories.tsx +7 -4
  212. package/toggle-group/ToggleGroup.test.js +68 -87
  213. package/toggle-group/types.d.ts +26 -17
  214. package/typography/Typography.js +4 -13
  215. package/typography/types.d.ts +1 -1
  216. package/useTheme.d.ts +20 -121
  217. package/useTheme.js +1 -8
  218. package/useTranslatedLabels.js +1 -7
  219. package/utils/BaseTypography.d.ts +2 -2
  220. package/utils/BaseTypography.js +16 -30
  221. package/utils/FocusLock.js +22 -39
  222. package/wizard/Wizard.js +14 -49
  223. package/wizard/Wizard.test.js +53 -80
  224. package/wizard/types.d.ts +6 -6
  225. package/card/ice-cream.jpg +0 -0
  226. package/number-input/NumberInputContext.d.ts +0 -4
  227. package/number-input/NumberInputContext.js +0 -19
  228. package/number-input/numberInputContextTypes.d.ts +0 -19
  229. package/resultsetTable/Icons.d.ts +0 -7
  230. package/slider/Slider.stories.tsx +0 -240
  231. /package/{resultsetTable → container}/types.js +0 -0
  232. /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
  233. /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
  234. /package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +0 -0
  235. /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
  236. /package/table/{Table.stories.jsx → Table.stories.tsx} +0 -0
package/select/types.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import React from "react";
2
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- declare type Margin = {
2
+ type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
+ type Margin = {
4
4
  top?: Space;
5
5
  bottom?: Space;
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
- declare type OptionGroup = {
9
+ type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
+ export type OptionGroup = {
11
11
  /**
12
12
  * Label of the group to be shown in the select's listbox.
13
13
  */
@@ -17,7 +17,7 @@ declare type OptionGroup = {
17
17
  */
18
18
  options: Option[];
19
19
  };
20
- declare type Option = {
20
+ export type Option = {
21
21
  /**
22
22
  * Element used as the icon that will be placed before the option label.
23
23
  * It can be a url of an image or an inline SVG. If the url option
@@ -36,7 +36,7 @@ declare type Option = {
36
36
  */
37
37
  value: string;
38
38
  };
39
- declare type CommonProps = {
39
+ type CommonProps = {
40
40
  /**
41
41
  * Text to be placed above the select.
42
42
  */
@@ -45,9 +45,8 @@ declare type CommonProps = {
45
45
  * Name attribute of the input element. This attribute will allow users
46
46
  * to find the component's value during the submit event. In this event,
47
47
  * the component's value will always be a regular string, for both single
48
- * and multiple selection modes, been in the first one a single option
49
- * value and in the multiple variant more than one option value,
50
- * separated by commas.
48
+ * and multiple selection modes, being a single option value in the first case
49
+ * and more than one value when multiple selection is available, separated by commas.
51
50
  */
52
51
  name?: string;
53
52
  /**
@@ -101,7 +100,7 @@ declare type CommonProps = {
101
100
  */
102
101
  tabIndex?: number;
103
102
  };
104
- declare type SingleSelect = CommonProps & {
103
+ type SingleSelect = CommonProps & {
105
104
  /**
106
105
  * If true, the select component will support multiple selected options.
107
106
  * In that case, value will be an array of strings with each selected
@@ -137,7 +136,7 @@ declare type SingleSelect = CommonProps & {
137
136
  error?: string;
138
137
  }) => void;
139
138
  };
140
- declare type MultipleSelect = CommonProps & {
139
+ type MultipleSelect = CommonProps & {
141
140
  /**
142
141
  * If true, the select component will support multiple selected options.
143
142
  * In that case, value will be an array of strings with each selected
@@ -173,11 +172,11 @@ declare type MultipleSelect = CommonProps & {
173
172
  error?: string;
174
173
  }) => void;
175
174
  };
176
- declare type Props = SingleSelect | MultipleSelect;
175
+ type Props = SingleSelect | MultipleSelect;
177
176
  /**
178
177
  * Single option of the select component.
179
178
  */
180
- export declare type OptionProps = {
179
+ export type OptionProps = {
181
180
  id: string;
182
181
  option: Option;
183
182
  onClick: (option: Option) => void;
@@ -190,7 +189,7 @@ export declare type OptionProps = {
190
189
  /**
191
190
  * Listbox from the select component.
192
191
  */
193
- export declare type ListboxProps = {
192
+ export type ListboxProps = {
194
193
  id: string;
195
194
  currentValue: string | string[];
196
195
  options: Option[] | OptionGroup[];
@@ -206,5 +205,5 @@ export declare type ListboxProps = {
206
205
  /**
207
206
  * Reference to the select component.
208
207
  */
209
- export declare type RefType = HTMLDivElement;
208
+ export type RefType = HTMLDivElement;
210
209
  export default Props;
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  declare const icons: {
3
- collapsedIcon: JSX.Element;
4
- collapsableIcon: JSX.Element;
5
- externalLinkIcon: JSX.Element;
3
+ collapsedIcon: React.JSX.Element;
4
+ collapsableIcon: React.JSX.Element;
5
+ externalLinkIcon: React.JSX.Element;
6
6
  };
7
7
  export default icons;
package/sidenav/Icons.js CHANGED
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var icons = {
13
10
  collapsedIcon: /*#__PURE__*/_react["default"].createElement("svg", {
14
11
  xmlns: "http://www.w3.org/2000/svg",
@@ -47,5 +44,4 @@ var icons = {
47
44
  d: "M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"
48
45
  }))
49
46
  };
50
- var _default = icons;
51
- exports["default"] = _default;
47
+ var _default = exports["default"] = icons;
@@ -1,69 +1,44 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports["default"] = void 0;
11
-
12
9
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
-
14
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
-
16
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
-
18
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
-
20
13
  var _react = _interopRequireWildcard(require("react"));
21
-
22
14
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
23
-
24
15
  var _variables = require("../common/variables");
25
-
26
16
  var _SidenavContext = require("../layout/SidenavContext");
27
-
28
17
  var _useTheme = _interopRequireDefault(require("../useTheme"));
29
-
30
- var _BackgroundColorContext = require("../BackgroundColorContext");
31
-
32
18
  var _Flex = _interopRequireDefault(require("../flex/Flex"));
33
-
34
19
  var _Bleed = _interopRequireDefault(require("../bleed/Bleed"));
35
-
36
20
  var _Icons = _interopRequireDefault(require("./Icons"));
37
-
38
21
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
39
-
40
22
  var _excluded = ["href", "newWindow", "selected", "icon", "onClick", "tabIndex", "children"];
41
-
42
- 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); }
43
-
44
- 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; }
45
-
23
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
24
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
46
25
  var DxcSidenav = function DxcSidenav(_ref) {
47
26
  var title = _ref.title,
48
- children = _ref.children;
27
+ children = _ref.children;
49
28
  var colorsTheme = (0, _useTheme["default"])();
50
29
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
51
30
  theme: colorsTheme.sidenav
52
- }, /*#__PURE__*/_react["default"].createElement(SidenavContainer, null, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
53
- color: colorsTheme.sidenav.backgroundColor
54
- }, title, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
31
+ }, /*#__PURE__*/_react["default"].createElement(SidenavContainer, null, title, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
55
32
  direction: "column",
56
33
  gap: "1rem"
57
- }, children))));
34
+ }, children)));
58
35
  };
59
-
60
36
  var Title = function Title(_ref2) {
61
37
  var children = _ref2.children;
62
38
  return /*#__PURE__*/_react["default"].createElement(_Bleed["default"], {
63
39
  horizontal: "1rem"
64
40
  }, /*#__PURE__*/_react["default"].createElement(SidenavTitle, null, children));
65
41
  };
66
-
67
42
  var Section = function Section(_ref3) {
68
43
  var children = _ref3.children;
69
44
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Bleed["default"], {
@@ -72,26 +47,21 @@ var Section = function Section(_ref3) {
72
47
  direction: "column"
73
48
  }, children)), /*#__PURE__*/_react["default"].createElement(Divider, null));
74
49
  };
75
-
76
50
  var GroupContext = /*#__PURE__*/_react["default"].createContext(null);
77
-
78
51
  var Group = function Group(_ref4) {
79
52
  var title = _ref4.title,
80
- _ref4$collapsable = _ref4.collapsable,
81
- collapsable = _ref4$collapsable === void 0 ? false : _ref4$collapsable,
82
- icon = _ref4.icon,
83
- children = _ref4.children;
84
-
53
+ _ref4$collapsable = _ref4.collapsable,
54
+ collapsable = _ref4$collapsable === void 0 ? false : _ref4$collapsable,
55
+ icon = _ref4.icon,
56
+ children = _ref4.children;
85
57
  var _useState = (0, _react.useState)(false),
86
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
87
- collapsed = _useState2[0],
88
- setCollapsed = _useState2[1];
89
-
58
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
59
+ collapsed = _useState2[0],
60
+ setCollapsed = _useState2[1];
90
61
  var _useState3 = (0, _react.useState)(false),
91
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
92
- isSelected = _useState4[0],
93
- changeIsSelected = _useState4[1];
94
-
62
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
63
+ isSelected = _useState4[0],
64
+ changeIsSelected = _useState4[1];
95
65
  return /*#__PURE__*/_react["default"].createElement(GroupContext.Provider, {
96
66
  value: changeIsSelected
97
67
  }, /*#__PURE__*/_react["default"].createElement(SidenavGroup, null, collapsable && title ? /*#__PURE__*/_react["default"].createElement(SidenavGroupTitleButton, {
@@ -109,27 +79,24 @@ var Group = function Group(_ref4) {
109
79
  src: icon
110
80
  }) : icon, title), !collapsed && children));
111
81
  };
112
-
113
82
  var Link = /*#__PURE__*/(0, _react.forwardRef)(function (_ref5, ref) {
114
83
  var href = _ref5.href,
115
- _ref5$newWindow = _ref5.newWindow,
116
- newWindow = _ref5$newWindow === void 0 ? false : _ref5$newWindow,
117
- _ref5$selected = _ref5.selected,
118
- selected = _ref5$selected === void 0 ? false : _ref5$selected,
119
- icon = _ref5.icon,
120
- onClick = _ref5.onClick,
121
- _ref5$tabIndex = _ref5.tabIndex,
122
- tabIndex = _ref5$tabIndex === void 0 ? 0 : _ref5$tabIndex,
123
- children = _ref5.children,
124
- otherProps = (0, _objectWithoutProperties2["default"])(_ref5, _excluded);
84
+ _ref5$newWindow = _ref5.newWindow,
85
+ newWindow = _ref5$newWindow === void 0 ? false : _ref5$newWindow,
86
+ _ref5$selected = _ref5.selected,
87
+ selected = _ref5$selected === void 0 ? false : _ref5$selected,
88
+ icon = _ref5.icon,
89
+ onClick = _ref5.onClick,
90
+ _ref5$tabIndex = _ref5.tabIndex,
91
+ tabIndex = _ref5$tabIndex === void 0 ? 0 : _ref5$tabIndex,
92
+ children = _ref5.children,
93
+ otherProps = (0, _objectWithoutProperties2["default"])(_ref5, _excluded);
125
94
  var changeIsGroupSelected = (0, _react.useContext)(GroupContext);
126
95
  var setIsSidenavVisibleResponsive = (0, _SidenavContext.useResponsiveSidenavVisibility)();
127
-
128
96
  var handleClick = function handleClick($event) {
129
97
  onClick === null || onClick === void 0 ? void 0 : onClick($event);
130
98
  setIsSidenavVisibleResponsive === null || setIsSidenavVisibleResponsive === void 0 ? void 0 : setIsSidenavVisibleResponsive(false);
131
99
  };
132
-
133
100
  (0, _react.useEffect)(function () {
134
101
  changeIsGroupSelected === null || changeIsGroupSelected === void 0 ? void 0 : changeIsGroupSelected(function (isGroupSelected) {
135
102
  return !isGroupSelected ? selected : isGroupSelected;
@@ -149,7 +116,6 @@ var Link = /*#__PURE__*/(0, _react.forwardRef)(function (_ref5, ref) {
149
116
  src: icon
150
117
  }) : icon, children), newWindow && _Icons["default"].externalLinkIcon);
151
118
  });
152
-
153
119
  var SidenavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n width: 280px;\n @media (max-width: ", "rem) {\n width: 100vw;\n }\n padding: 2rem 1rem;\n background-color: ", ";\n\n overflow-y: auto;\n overflow-x: hidden;\n ::-webkit-scrollbar {\n width: 2px;\n }\n ::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 3px;\n }\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 3px;\n }\n"])), _variables.responsiveSizes.medium, function (props) {
154
120
  return props.theme.backgroundColor;
155
121
  }, function (props) {
@@ -157,7 +123,6 @@ var SidenavContainer = _styledComponents["default"].div(_templateObject || (_tem
157
123
  }, function (props) {
158
124
  return props.theme.scrollBarThumbColor;
159
125
  });
160
-
161
126
  var SidenavTitle = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n"])), function (props) {
162
127
  return props.theme.titleFontFamily;
163
128
  }, function (props) {
@@ -173,11 +138,8 @@ var SidenavTitle = _styledComponents["default"].div(_templateObject2 || (_templa
173
138
  }, function (props) {
174
139
  return props.theme.titleFontTextTransform;
175
140
  });
176
-
177
141
  var Divider = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n height: 1px;\n background-color: #999999;\n\n &:last-child {\n display: none;\n }\n"])));
178
-
179
142
  var SidenavGroup = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n a {\n padding: 0.5rem 1.2rem 0.5rem 2.25rem;\n }\n"])));
180
-
181
143
  var SidenavGroupTitle = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n\n img,\n svg {\n height: 16px;\n width: 16px;\n }\n"])), function (props) {
182
144
  return props.theme.groupTitleFontFamily;
183
145
  }, function (props) {
@@ -187,7 +149,6 @@ var SidenavGroupTitle = _styledComponents["default"].span(_templateObject5 || (_
187
149
  }, function (props) {
188
150
  return props.theme.groupTitleFontSize;
189
151
  });
190
-
191
152
  var SidenavGroupTitleButton = _styledComponents["default"].button(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n all: unset;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n cursor: pointer;\n\n ", "\n\n &:focus, &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n &:hover {\n ", "\n }\n &:active {\n color: #fff;\n background-color: ", ";\n }\n\n img,\n svg {\n height: 16px;\n width: 16px;\n }\n"])), function (props) {
192
153
  return props.theme.groupTitleFontFamily;
193
154
  }, function (props) {
@@ -205,7 +166,6 @@ var SidenavGroupTitleButton = _styledComponents["default"].button(_templateObjec
205
166
  }, function (props) {
206
167
  return props.selectedGroup ? "#333" : props.theme.groupTitleActiveBackgroundColor;
207
168
  });
208
-
209
169
  var SidenavLink = _styledComponents["default"].a(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n padding: 0.5rem 1.2rem;\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n text-decoration: ", ";\n cursor: pointer;\n\n ", "\n\n &:focus, &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n &:hover {\n ", "\n }\n &:active {\n color: #fff;\n background-color: ", ";\n outline: 2px solid #0095ff;\n outline-offset: -2px;\n }\n\n img,\n svg {\n height: 16px;\n width: 16px;\n }\n"])), function (props) {
210
170
  return props.theme.linkFontFamily;
211
171
  }, function (props) {
@@ -229,10 +189,8 @@ var SidenavLink = _styledComponents["default"].a(_templateObject7 || (_templateO
229
189
  }, function (props) {
230
190
  return props.selected ? "#333" : "#4d4d4d";
231
191
  });
232
-
233
192
  DxcSidenav.Section = Section;
234
193
  DxcSidenav.Group = Group;
235
194
  DxcSidenav.Link = Link;
236
195
  DxcSidenav.Title = Title;
237
- var _default = DxcSidenav;
238
- exports["default"] = _default;
196
+ var _default = exports["default"] = DxcSidenav;
@@ -1,20 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _react = _interopRequireDefault(require("react"));
6
-
7
5
  var _react2 = require("@testing-library/react");
8
-
9
6
  var _Sidenav = _interopRequireDefault(require("./Sidenav.tsx"));
10
-
11
7
  describe("Sidenav component tests", function () {
12
8
  test("Sidenav renders anchors and Section correctly", function () {
13
9
  var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Sidenav["default"], null, /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Section, null, /*#__PURE__*/_react["default"].createElement("p", null, "nav-content-test"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
14
- href: "#"
15
- }, "Link")))),
16
- getByText = _render.getByText;
17
-
10
+ href: "#"
11
+ }, "Link")))),
12
+ getByText = _render.getByText;
18
13
  expect(getByText("nav-content-test")).toBeTruthy();
19
14
  var link = getByText("Link");
20
15
  expect(link.closest("a").getAttribute("href")).toBe("#");
@@ -36,9 +31,7 @@ describe("Sidenav component tests", function () {
36
31
  }, "Lorem ipsum")))));
37
32
  expect(sidenav.getByText("Collapsable")).toBeTruthy();
38
33
  expect(sidenav.getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("true");
39
-
40
34
  _react2.fireEvent.click(sidenav.getByText("Collapsable"));
41
-
42
35
  expect(sidenav.getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("false");
43
36
  });
44
37
  });
@@ -1,28 +1,18 @@
1
1
  /// <reference types="react" />
2
- declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
3
- declare type SidenavPropsType = {
4
- /**
5
- * The area assigned to render the sidenav title. It is highly recommended to use the sidenav title.
6
- */
7
- title?: React.ReactNode;
8
- /**
9
- * The area inside the sidenav. This area can be used to render the content inside the sidenav.
10
- */
11
- children: React.ReactNode;
12
- };
13
- export declare type SidenavTitlePropsType = {
2
+ type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
3
+ export type SidenavTitlePropsType = {
14
4
  /**
15
5
  * The area inside the sidenav title. This area can be used to render custom content.
16
6
  */
17
7
  children: React.ReactNode;
18
8
  };
19
- export declare type SidenavSectionPropsType = {
9
+ export type SidenavSectionPropsType = {
20
10
  /**
21
11
  * The area inside the sidenav section. This area can be used to render sidenav groups, links and custom content.
22
12
  */
23
13
  children: React.ReactNode;
24
14
  };
25
- export declare type SidenavGroupPropsType = {
15
+ export type SidenavGroupPropsType = {
26
16
  /**
27
17
  * The title of the sidenav group.
28
18
  */
@@ -41,7 +31,7 @@ export declare type SidenavGroupPropsType = {
41
31
  */
42
32
  children: React.ReactNode;
43
33
  };
44
- export declare type SidenavLinkPropsType = {
34
+ export type SidenavLinkPropsType = {
45
35
  /**
46
36
  * Page to be opened when the user clicks on the link.
47
37
  */
@@ -63,14 +53,24 @@ export declare type SidenavLinkPropsType = {
63
53
  /**
64
54
  * This function will be called when the user clicks the link and the event will be passed to this function.
65
55
  */
66
- onClick?: ($event: React.MouseEvent<HTMLAnchorElement>) => void;
56
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
57
+ /**
58
+ * The area inside the sidenav link.
59
+ */
60
+ children: React.ReactNode;
67
61
  /**
68
62
  * Value of the tabindex.
69
63
  */
70
64
  tabIndex?: number;
65
+ };
66
+ type Props = {
71
67
  /**
72
- * The area inside the sidenav link.
68
+ * The area assigned to render the sidenav title. It is highly recommended to use the sidenav title.
69
+ */
70
+ title?: React.ReactNode;
71
+ /**
72
+ * The area inside the sidenav. This area can be used to render the content inside the sidenav.
73
73
  */
74
74
  children: React.ReactNode;
75
75
  };
76
- export default SidenavPropsType;
76
+ export default Props;