@dxc-technology/halstack-react 10.0.0 → 11.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.
- package/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +5 -17
- package/HalstackContext.d.ts +26 -6
- package/HalstackContext.js +9 -34
- package/README.md +47 -0
- package/accordion/Accordion.js +21 -58
- package/accordion/Accordion.stories.tsx +1 -15
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +5 -5
- package/accordion-group/AccordionGroup.js +15 -42
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +42 -60
- package/accordion-group/AccordionGroupAccordion.js +9 -21
- package/accordion-group/types.d.ts +6 -6
- package/alert/Alert.js +14 -46
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.js +4 -17
- package/badge/types.d.ts +1 -1
- package/bleed/Bleed.js +13 -21
- package/bleed/types.d.ts +2 -2
- package/box/Box.js +10 -29
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -3
- package/bulleted-list/BulletedList.js +7 -33
- package/bulleted-list/BulletedList.stories.tsx +1 -91
- package/bulleted-list/types.d.ts +5 -5
- package/button/Button.js +23 -46
- package/button/Button.stories.tsx +5 -86
- package/button/Button.test.js +11 -21
- package/button/types.d.ts +4 -4
- package/card/Card.js +21 -44
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +5 -5
- package/checkbox/Checkbox.js +81 -111
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +12 -31
- package/chip/Chip.test.js +15 -28
- package/chip/types.d.ts +4 -4
- package/common/coreTokens.js +1 -2
- package/common/utils.js +2 -8
- package/common/variables.d.ts +23 -6
- package/common/variables.js +25 -15
- package/date-input/Calendar.js +13 -57
- package/date-input/DateInput.js +50 -96
- package/date-input/DateInput.stories.tsx +11 -30
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +11 -42
- package/date-input/Icons.d.ts +6 -6
- package/date-input/Icons.js +6 -23
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +27 -21
- package/dialog/Dialog.js +11 -35
- package/dialog/Dialog.test.js +125 -187
- package/dialog/types.d.ts +18 -13
- package/dropdown/Dropdown.js +39 -93
- package/dropdown/Dropdown.test.js +391 -378
- package/dropdown/DropdownMenu.js +8 -19
- package/dropdown/DropdownMenuItem.js +5 -17
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.js +131 -220
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +293 -342
- package/file-input/FileItem.js +12 -39
- package/file-input/types.d.ts +9 -9
- package/flex/Flex.js +25 -39
- package/flex/types.d.ts +6 -6
- package/footer/Footer.js +9 -39
- package/footer/Footer.stories.tsx +8 -7
- package/footer/Footer.test.js +18 -32
- package/footer/Icons.d.ts +2 -2
- package/footer/Icons.js +2 -7
- package/footer/types.d.ts +13 -13
- package/grid/Grid.js +1 -16
- package/grid/types.d.ts +10 -10
- package/header/Header.d.ts +1 -1
- package/header/Header.js +19 -64
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +5 -7
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/inset/Inset.js +13 -21
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +25 -65
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +8 -5
- package/layout/Icons.js +51 -59
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +3 -3
- package/link/Link.js +21 -42
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +3 -2
- package/main.js +10 -51
- package/nav-tabs/NavTabs.js +11 -43
- package/nav-tabs/NavTabs.stories.tsx +1 -1
- package/nav-tabs/NavTabs.test.js +36 -43
- package/nav-tabs/Tab.js +16 -45
- package/nav-tabs/types.d.ts +9 -9
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +26 -35
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +700 -412
- package/number-input/types.d.ts +11 -5
- package/package.json +28 -26
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +14 -39
- package/paginator/Paginator.test.js +224 -207
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.js +3 -14
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -126
- package/password-input/PasswordInput.stories.tsx +1 -32
- package/password-input/PasswordInput.test.js +157 -140
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.js +16 -42
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +22 -54
- package/radio-group/RadioGroup.js +37 -83
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.js +22 -58
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +72 -92
- package/{resultsetTable → resultset-table}/types.d.ts +7 -7
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +13 -39
- package/select/Option.js +9 -26
- package/select/Select.js +54 -138
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +1906 -1800
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +4 -4
- package/sidenav/Icons.js +1 -5
- package/sidenav/Sidenav.js +24 -63
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +18 -18
- package/slider/Slider.js +38 -86
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +10 -40
- package/spinner/Spinner.test.js +25 -34
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.js +26 -69
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- package/table/Table.js +4 -23
- package/table/Table.test.js +1 -6
- package/table/types.d.ts +8 -8
- package/tabs/Tab.js +10 -29
- package/tabs/Tabs.js +48 -124
- package/tabs/Tabs.test.js +62 -118
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +21 -51
- package/tag/Tag.test.js +19 -30
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +5 -5
- package/text-input/Icons.js +1 -5
- package/text-input/Suggestion.js +9 -26
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +12 -57
- package/text-input/TextInput.js +182 -263
- package/text-input/TextInput.stories.tsx +48 -152
- package/text-input/TextInput.test.js +1210 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +60 -96
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -99
- package/textarea/Textarea.test.js +150 -179
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.js +91 -105
- package/toggle-group/ToggleGroup.stories.tsx +7 -4
- package/toggle-group/ToggleGroup.test.js +68 -87
- package/toggle-group/types.d.ts +26 -17
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +20 -3
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +12 -36
- package/wizard/Wizard.js +14 -49
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +6 -6
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/resultsetTable/Icons.d.ts +0 -7
- package/slider/Slider.stories.tsx +0 -240
- /package/{resultsetTable → image}/types.js +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +0 -0
- /package/{number-input/numberInputContextTypes.js → resultset-table/types.js} +0 -0
- /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
- /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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
10
|
-
|
|
9
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
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
|
-
|
|
20
|
+
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
|
-
|
|
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,
|
|
49
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
175
|
+
type Props = SingleSelect | MultipleSelect;
|
|
177
176
|
/**
|
|
178
177
|
* Single option of the select component.
|
|
179
178
|
*/
|
|
180
|
-
export
|
|
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
|
|
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
|
|
208
|
+
export type RefType = HTMLDivElement;
|
|
210
209
|
export default Props;
|
package/sidenav/Icons.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
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;
|
package/sidenav/Sidenav.js
CHANGED
|
@@ -1,51 +1,31 @@
|
|
|
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
18
|
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
31
|
-
|
|
32
19
|
var _Flex = _interopRequireDefault(require("../flex/Flex"));
|
|
33
|
-
|
|
34
20
|
var _Bleed = _interopRequireDefault(require("../bleed/Bleed"));
|
|
35
|
-
|
|
36
21
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
37
|
-
|
|
38
22
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
39
|
-
|
|
40
23
|
var _excluded = ["href", "newWindow", "selected", "icon", "onClick", "tabIndex", "children"];
|
|
41
|
-
|
|
42
|
-
function
|
|
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
|
-
|
|
24
|
+
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); }
|
|
25
|
+
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
26
|
var DxcSidenav = function DxcSidenav(_ref) {
|
|
47
27
|
var title = _ref.title,
|
|
48
|
-
|
|
28
|
+
children = _ref.children;
|
|
49
29
|
var colorsTheme = (0, _useTheme["default"])();
|
|
50
30
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
51
31
|
theme: colorsTheme.sidenav
|
|
@@ -56,14 +36,12 @@ var DxcSidenav = function DxcSidenav(_ref) {
|
|
|
56
36
|
gap: "1rem"
|
|
57
37
|
}, children))));
|
|
58
38
|
};
|
|
59
|
-
|
|
60
39
|
var Title = function Title(_ref2) {
|
|
61
40
|
var children = _ref2.children;
|
|
62
41
|
return /*#__PURE__*/_react["default"].createElement(_Bleed["default"], {
|
|
63
42
|
horizontal: "1rem"
|
|
64
43
|
}, /*#__PURE__*/_react["default"].createElement(SidenavTitle, null, children));
|
|
65
44
|
};
|
|
66
|
-
|
|
67
45
|
var Section = function Section(_ref3) {
|
|
68
46
|
var children = _ref3.children;
|
|
69
47
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Bleed["default"], {
|
|
@@ -72,26 +50,21 @@ var Section = function Section(_ref3) {
|
|
|
72
50
|
direction: "column"
|
|
73
51
|
}, children)), /*#__PURE__*/_react["default"].createElement(Divider, null));
|
|
74
52
|
};
|
|
75
|
-
|
|
76
53
|
var GroupContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
77
|
-
|
|
78
54
|
var Group = function Group(_ref4) {
|
|
79
55
|
var title = _ref4.title,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
56
|
+
_ref4$collapsable = _ref4.collapsable,
|
|
57
|
+
collapsable = _ref4$collapsable === void 0 ? false : _ref4$collapsable,
|
|
58
|
+
icon = _ref4.icon,
|
|
59
|
+
children = _ref4.children;
|
|
85
60
|
var _useState = (0, _react.useState)(false),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
61
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
62
|
+
collapsed = _useState2[0],
|
|
63
|
+
setCollapsed = _useState2[1];
|
|
90
64
|
var _useState3 = (0, _react.useState)(false),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
65
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
66
|
+
isSelected = _useState4[0],
|
|
67
|
+
changeIsSelected = _useState4[1];
|
|
95
68
|
return /*#__PURE__*/_react["default"].createElement(GroupContext.Provider, {
|
|
96
69
|
value: changeIsSelected
|
|
97
70
|
}, /*#__PURE__*/_react["default"].createElement(SidenavGroup, null, collapsable && title ? /*#__PURE__*/_react["default"].createElement(SidenavGroupTitleButton, {
|
|
@@ -109,27 +82,24 @@ var Group = function Group(_ref4) {
|
|
|
109
82
|
src: icon
|
|
110
83
|
}) : icon, title), !collapsed && children));
|
|
111
84
|
};
|
|
112
|
-
|
|
113
85
|
var Link = /*#__PURE__*/(0, _react.forwardRef)(function (_ref5, ref) {
|
|
114
86
|
var href = _ref5.href,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
87
|
+
_ref5$newWindow = _ref5.newWindow,
|
|
88
|
+
newWindow = _ref5$newWindow === void 0 ? false : _ref5$newWindow,
|
|
89
|
+
_ref5$selected = _ref5.selected,
|
|
90
|
+
selected = _ref5$selected === void 0 ? false : _ref5$selected,
|
|
91
|
+
icon = _ref5.icon,
|
|
92
|
+
onClick = _ref5.onClick,
|
|
93
|
+
_ref5$tabIndex = _ref5.tabIndex,
|
|
94
|
+
tabIndex = _ref5$tabIndex === void 0 ? 0 : _ref5$tabIndex,
|
|
95
|
+
children = _ref5.children,
|
|
96
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_ref5, _excluded);
|
|
125
97
|
var changeIsGroupSelected = (0, _react.useContext)(GroupContext);
|
|
126
98
|
var setIsSidenavVisibleResponsive = (0, _SidenavContext.useResponsiveSidenavVisibility)();
|
|
127
|
-
|
|
128
99
|
var handleClick = function handleClick($event) {
|
|
129
100
|
onClick === null || onClick === void 0 ? void 0 : onClick($event);
|
|
130
101
|
setIsSidenavVisibleResponsive === null || setIsSidenavVisibleResponsive === void 0 ? void 0 : setIsSidenavVisibleResponsive(false);
|
|
131
102
|
};
|
|
132
|
-
|
|
133
103
|
(0, _react.useEffect)(function () {
|
|
134
104
|
changeIsGroupSelected === null || changeIsGroupSelected === void 0 ? void 0 : changeIsGroupSelected(function (isGroupSelected) {
|
|
135
105
|
return !isGroupSelected ? selected : isGroupSelected;
|
|
@@ -149,7 +119,6 @@ var Link = /*#__PURE__*/(0, _react.forwardRef)(function (_ref5, ref) {
|
|
|
149
119
|
src: icon
|
|
150
120
|
}) : icon, children), newWindow && _Icons["default"].externalLinkIcon);
|
|
151
121
|
});
|
|
152
|
-
|
|
153
122
|
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
123
|
return props.theme.backgroundColor;
|
|
155
124
|
}, function (props) {
|
|
@@ -157,7 +126,6 @@ var SidenavContainer = _styledComponents["default"].div(_templateObject || (_tem
|
|
|
157
126
|
}, function (props) {
|
|
158
127
|
return props.theme.scrollBarThumbColor;
|
|
159
128
|
});
|
|
160
|
-
|
|
161
129
|
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
130
|
return props.theme.titleFontFamily;
|
|
163
131
|
}, function (props) {
|
|
@@ -173,11 +141,8 @@ var SidenavTitle = _styledComponents["default"].div(_templateObject2 || (_templa
|
|
|
173
141
|
}, function (props) {
|
|
174
142
|
return props.theme.titleFontTextTransform;
|
|
175
143
|
});
|
|
176
|
-
|
|
177
144
|
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
145
|
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
146
|
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
147
|
return props.theme.groupTitleFontFamily;
|
|
183
148
|
}, function (props) {
|
|
@@ -187,7 +152,6 @@ var SidenavGroupTitle = _styledComponents["default"].span(_templateObject5 || (_
|
|
|
187
152
|
}, function (props) {
|
|
188
153
|
return props.theme.groupTitleFontSize;
|
|
189
154
|
});
|
|
190
|
-
|
|
191
155
|
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
156
|
return props.theme.groupTitleFontFamily;
|
|
193
157
|
}, function (props) {
|
|
@@ -205,7 +169,6 @@ var SidenavGroupTitleButton = _styledComponents["default"].button(_templateObjec
|
|
|
205
169
|
}, function (props) {
|
|
206
170
|
return props.selectedGroup ? "#333" : props.theme.groupTitleActiveBackgroundColor;
|
|
207
171
|
});
|
|
208
|
-
|
|
209
172
|
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
173
|
return props.theme.linkFontFamily;
|
|
211
174
|
}, function (props) {
|
|
@@ -229,10 +192,8 @@ var SidenavLink = _styledComponents["default"].a(_templateObject7 || (_templateO
|
|
|
229
192
|
}, function (props) {
|
|
230
193
|
return props.selected ? "#333" : "#4d4d4d";
|
|
231
194
|
});
|
|
232
|
-
|
|
233
195
|
DxcSidenav.Section = Section;
|
|
234
196
|
DxcSidenav.Group = Group;
|
|
235
197
|
DxcSidenav.Link = Link;
|
|
236
198
|
DxcSidenav.Title = Title;
|
|
237
|
-
var _default = DxcSidenav;
|
|
238
|
-
exports["default"] = _default;
|
|
199
|
+
var _default = exports["default"] = DxcSidenav;
|
package/sidenav/Sidenav.test.js
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
});
|
package/sidenav/types.d.ts
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
|
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
|
|
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?: (
|
|
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
|
|
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
|
|
76
|
+
export default Props;
|