@dxc-technology/halstack-react 0.0.0-bfdc357 → 0.0.0-c1c5f49
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/alert/types.d.ts +1 -1
- package/button/Button.d.ts +1 -1
- package/button/Button.js +4 -2
- package/button/types.d.ts +2 -2
- package/card/Card.stories.tsx +201 -0
- package/card/ice-cream.jpg +0 -0
- package/card/types.d.ts +4 -6
- package/checkbox/types.d.ts +1 -1
- package/common/variables.js +3 -2
- package/file-input/FileInput.js +22 -22
- package/file-input/FileItem.js +5 -3
- package/header/types.d.ts +4 -2
- package/heading/Heading.stories.tsx +53 -0
- package/number-input/NumberInputContext.d.ts +4 -0
- package/number-input/NumberInputContext.js +5 -2
- package/number-input/numberInputContextTypes.d.ts +19 -0
- package/number-input/numberInputContextTypes.js +5 -0
- package/package.json +1 -1
- package/password-input/PasswordInput.js +4 -2
- package/password-input/types.d.ts +17 -10
- package/radio/types.d.ts +2 -2
- package/resultsetTable/ResultsetTable.d.ts +4 -0
- package/resultsetTable/ResultsetTable.js +3 -26
- package/resultsetTable/types.d.ts +67 -0
- package/resultsetTable/types.js +5 -0
- package/select/Select.js +1 -1
- package/sidenav/Sidenav.stories.tsx +165 -0
- package/slider/Slider.js +2 -2
- package/table/Table.js +1 -1
- package/tabs/Tabs.js +3 -1
- package/tabs/Tabs.stories.tsx +121 -0
- package/tabs/types.d.ts +2 -3
- package/text-input/TextInput.d.ts +4 -0
- package/text-input/TextInput.js +18 -57
- package/text-input/TextInput.stories.tsx +456 -0
- package/text-input/types.d.ts +159 -0
- package/text-input/types.js +5 -0
- package/textarea/Textarea.js +13 -14
- package/textarea/index.d.ts +18 -8
- package/toggle-group/ToggleGroup.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +5 -31
- package/toggle-group/types.d.ts +84 -0
- package/toggle-group/types.js +5 -0
- package/resultsetTable/index.d.ts +0 -19
- package/text-input/index.d.ts +0 -135
- package/toggle-group/index.d.ts +0 -21
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
13
|
|
|
16
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -21,8 +19,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
21
19
|
|
|
22
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
23
21
|
|
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
-
|
|
26
22
|
var _variables = require("../common/variables.js");
|
|
27
23
|
|
|
28
24
|
var _Table = _interopRequireDefault(require("../table/Table"));
|
|
@@ -117,6 +113,8 @@ var BothArrows = function BothArrows() {
|
|
|
117
113
|
var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
118
114
|
var columns = _ref.columns,
|
|
119
115
|
rows = _ref.rows,
|
|
116
|
+
_ref$showGoToPage = _ref.showGoToPage,
|
|
117
|
+
showGoToPage = _ref$showGoToPage === void 0 ? true : _ref$showGoToPage,
|
|
120
118
|
_ref$itemsPerPage = _ref.itemsPerPage,
|
|
121
119
|
itemsPerPage = _ref$itemsPerPage === void 0 ? 5 : _ref$itemsPerPage,
|
|
122
120
|
itemsPerPageOptions = _ref.itemsPerPageOptions,
|
|
@@ -205,7 +203,7 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
205
203
|
itemsPerPageOptions: itemsPerPageOptions,
|
|
206
204
|
itemsPerPageFunction: itemsPerPageFunction,
|
|
207
205
|
currentPage: page,
|
|
208
|
-
showGoToPage:
|
|
206
|
+
showGoToPage: showGoToPage,
|
|
209
207
|
onPageChange: goToPage,
|
|
210
208
|
tabIndex: tabIndex
|
|
211
209
|
}))));
|
|
@@ -249,26 +247,5 @@ var DxcResultsetTableContainer = _styledComponents["default"].div(_templateObjec
|
|
|
249
247
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
250
248
|
});
|
|
251
249
|
|
|
252
|
-
DxcResultsetTable.propTypes = {
|
|
253
|
-
rows: _propTypes["default"].array,
|
|
254
|
-
columns: _propTypes["default"].array,
|
|
255
|
-
itemsPerPage: _propTypes["default"].number,
|
|
256
|
-
itemsPerPageOptions: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
257
|
-
itemsPerPageFunction: _propTypes["default"].func,
|
|
258
|
-
margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
259
|
-
top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
260
|
-
bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
261
|
-
left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
|
|
262
|
-
right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
|
|
263
|
-
}), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
|
|
264
|
-
tabIndex: _propTypes["default"].number
|
|
265
|
-
};
|
|
266
|
-
DxcResultsetTable.defaultProps = {
|
|
267
|
-
rows: [],
|
|
268
|
-
columns: [],
|
|
269
|
-
itemsPerPage: 5,
|
|
270
|
-
itemsPerPageOptions: null,
|
|
271
|
-
itemsPerPageFunction: null
|
|
272
|
-
};
|
|
273
250
|
var _default = DxcResultsetTable;
|
|
274
251
|
exports["default"] = _default;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
declare type Margin = {
|
|
4
|
+
top?: Space;
|
|
5
|
+
bottom?: Space;
|
|
6
|
+
left?: Space;
|
|
7
|
+
right?: Space;
|
|
8
|
+
};
|
|
9
|
+
declare type Column = {
|
|
10
|
+
/**
|
|
11
|
+
* Column display value.
|
|
12
|
+
*/
|
|
13
|
+
displayValue: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Boolean value to indicate whether the column is sortable or not.
|
|
16
|
+
*/
|
|
17
|
+
isSortable?: boolean;
|
|
18
|
+
};
|
|
19
|
+
declare type Row = {
|
|
20
|
+
/**
|
|
21
|
+
* Value to be displayed in the cell.
|
|
22
|
+
*/
|
|
23
|
+
displayValue: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Value to be used when sorting the table by that
|
|
26
|
+
* column. If not indicated displayValue will be used for sorting.
|
|
27
|
+
*/
|
|
28
|
+
sortValue?: string;
|
|
29
|
+
};
|
|
30
|
+
declare type Props = {
|
|
31
|
+
/**
|
|
32
|
+
* An array of objects representing the columns of the table.
|
|
33
|
+
*/
|
|
34
|
+
columns: [Column, ...Column[]];
|
|
35
|
+
/**
|
|
36
|
+
* An array of objects representing the rows of the table, you will have
|
|
37
|
+
* as many objects as columns in the table.
|
|
38
|
+
*/
|
|
39
|
+
rows: [Row, ...Row[]];
|
|
40
|
+
/**
|
|
41
|
+
* If true, a select component for navigation between pages will be displayed.
|
|
42
|
+
*/
|
|
43
|
+
showGoToPage?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Number of items per page.
|
|
46
|
+
*/
|
|
47
|
+
itemsPerPage?: number;
|
|
48
|
+
/**
|
|
49
|
+
* An array of numbers representing the items per page options.
|
|
50
|
+
*/
|
|
51
|
+
itemsPerPageOptions?: number[];
|
|
52
|
+
/**
|
|
53
|
+
* This function will be called when the user selects an item per page
|
|
54
|
+
* option. The value selected will be passed as a parameter.
|
|
55
|
+
*/
|
|
56
|
+
itemsPerPageFunction?: (newValue: number) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Size of the margin to be applied to the component. You can pass an object with 'top',
|
|
59
|
+
* 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
60
|
+
*/
|
|
61
|
+
margin?: Space | Margin;
|
|
62
|
+
/**
|
|
63
|
+
* Value of the tabindex attribute given to the sortable icon.
|
|
64
|
+
*/
|
|
65
|
+
tabIndex?: number;
|
|
66
|
+
};
|
|
67
|
+
export default Props;
|
package/select/Select.js
CHANGED
|
@@ -773,7 +773,7 @@ var ErrorIcon = _styledComponents["default"].span(_templateObject13 || (_templat
|
|
|
773
773
|
return props.theme.errorIconColor;
|
|
774
774
|
});
|
|
775
775
|
|
|
776
|
-
var Error = _styledComponents["default"].span(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n"])), function (props) {
|
|
776
|
+
var Error = _styledComponents["default"].span(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n min-height: 1.5em;\n color: ", ";\n font-family: ", ";\n font-size: 0.75rem;\n font-weight: 400;\n line-height: 1.5em;\n"])), function (props) {
|
|
777
777
|
return props.theme.errorMessageColor;
|
|
778
778
|
}, function (props) {
|
|
779
779
|
return props.theme.fontFamily;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import DxcSidenav from "./Sidenav";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Sidenav",
|
|
9
|
+
component: DxcSidenav,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const linkClick = () => {
|
|
13
|
+
console.log("click");
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const StyledContainer = styled["div"]`
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: row;
|
|
19
|
+
height: 500px;
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export const Chromatic = () => (
|
|
23
|
+
<>
|
|
24
|
+
<ExampleContainer>
|
|
25
|
+
<Title title="Deafult sidenav" theme="light" level={4} />
|
|
26
|
+
<DxcSidenav>
|
|
27
|
+
{" "}
|
|
28
|
+
<p>Lorem ipsum</p>
|
|
29
|
+
<p>Lorem ipsum</p>
|
|
30
|
+
<p>Lorem ipsum</p>
|
|
31
|
+
<p>Lorem ipsum</p>
|
|
32
|
+
<p>Lorem ipsum</p>{" "}
|
|
33
|
+
</DxcSidenav>
|
|
34
|
+
</ExampleContainer>
|
|
35
|
+
|
|
36
|
+
<ExampleContainer>
|
|
37
|
+
<Title title="Sidenav with xxsmall padding" theme="light" level={4} />
|
|
38
|
+
<DxcSidenav padding="xxsmall">
|
|
39
|
+
{" "}
|
|
40
|
+
<p>Lorem ipsum</p>
|
|
41
|
+
<p>Lorem ipsum</p>
|
|
42
|
+
<p>Lorem ipsum</p>
|
|
43
|
+
<p>Lorem ipsum</p>
|
|
44
|
+
<p>Lorem ipsum</p>{" "}
|
|
45
|
+
</DxcSidenav>
|
|
46
|
+
</ExampleContainer>
|
|
47
|
+
|
|
48
|
+
<ExampleContainer>
|
|
49
|
+
<Title title="Sidenav with xsmall padding" theme="light" level={4} />
|
|
50
|
+
<DxcSidenav padding="xsmall">
|
|
51
|
+
{" "}
|
|
52
|
+
<p>Lorem ipsum</p>
|
|
53
|
+
<p>Lorem ipsum</p>
|
|
54
|
+
<p>Lorem ipsum</p>
|
|
55
|
+
<p>Lorem ipsum</p>
|
|
56
|
+
<p>Lorem ipsum</p>{" "}
|
|
57
|
+
</DxcSidenav>
|
|
58
|
+
</ExampleContainer>
|
|
59
|
+
|
|
60
|
+
<ExampleContainer>
|
|
61
|
+
<Title title="Sidenav with small padding" theme="light" level={4} />
|
|
62
|
+
<DxcSidenav padding="small">
|
|
63
|
+
{" "}
|
|
64
|
+
<p>Lorem ipsum</p>
|
|
65
|
+
<p>Lorem ipsum</p>
|
|
66
|
+
<p>Lorem ipsum</p>
|
|
67
|
+
<p>Lorem ipsum</p>
|
|
68
|
+
<p>Lorem ipsum</p>{" "}
|
|
69
|
+
</DxcSidenav>
|
|
70
|
+
</ExampleContainer>
|
|
71
|
+
|
|
72
|
+
<ExampleContainer>
|
|
73
|
+
<Title title="Sidenav with medium padding" theme="light" level={4} />
|
|
74
|
+
<DxcSidenav padding="medium">
|
|
75
|
+
{" "}
|
|
76
|
+
<p>Lorem ipsum</p>
|
|
77
|
+
<p>Lorem ipsum</p>
|
|
78
|
+
<p>Lorem ipsum</p>
|
|
79
|
+
<p>Lorem ipsum</p>
|
|
80
|
+
<p>Lorem ipsum</p>{" "}
|
|
81
|
+
</DxcSidenav>
|
|
82
|
+
</ExampleContainer>
|
|
83
|
+
|
|
84
|
+
<ExampleContainer>
|
|
85
|
+
<Title title="Sidenav with large padding" theme="light" level={4} />
|
|
86
|
+
<DxcSidenav padding="large">
|
|
87
|
+
{" "}
|
|
88
|
+
<p>Lorem ipsum</p>
|
|
89
|
+
<p>Lorem ipsum</p>
|
|
90
|
+
<p>Lorem ipsum</p>
|
|
91
|
+
<p>Lorem ipsum</p>
|
|
92
|
+
<p>Lorem ipsum</p>{" "}
|
|
93
|
+
</DxcSidenav>
|
|
94
|
+
</ExampleContainer>
|
|
95
|
+
|
|
96
|
+
<ExampleContainer>
|
|
97
|
+
<Title title="Sidenav with xlarge padding" theme="light" level={4} />
|
|
98
|
+
<DxcSidenav padding="xlarge">
|
|
99
|
+
{" "}
|
|
100
|
+
<p>Lorem ipsum</p>
|
|
101
|
+
<p>Lorem ipsum</p>
|
|
102
|
+
<p>Lorem ipsum</p>
|
|
103
|
+
<p>Lorem ipsum</p>
|
|
104
|
+
<p>Lorem ipsum</p>{" "}
|
|
105
|
+
</DxcSidenav>
|
|
106
|
+
</ExampleContainer>
|
|
107
|
+
|
|
108
|
+
<ExampleContainer>
|
|
109
|
+
<Title title="Sidenav with xxlarge padding" theme="light" level={4} />
|
|
110
|
+
<DxcSidenav padding="xxlarge">
|
|
111
|
+
{" "}
|
|
112
|
+
<p>Lorem ipsum</p>
|
|
113
|
+
<p>Lorem ipsum</p>
|
|
114
|
+
<p>Lorem ipsum</p>
|
|
115
|
+
<p>Lorem ipsum</p>
|
|
116
|
+
<p>Lorem ipsum</p>{" "}
|
|
117
|
+
</DxcSidenav>
|
|
118
|
+
</ExampleContainer>
|
|
119
|
+
|
|
120
|
+
<ExampleContainer>
|
|
121
|
+
<Title title="Sidenav compound components" theme="light" level={4} />
|
|
122
|
+
<DxcSidenav>
|
|
123
|
+
<DxcSidenav.Title>My sidenav</DxcSidenav.Title>
|
|
124
|
+
<DxcSidenav.Subtitle>Components</DxcSidenav.Subtitle>
|
|
125
|
+
<DxcSidenav.Link href="#">Button</DxcSidenav.Link>
|
|
126
|
+
<DxcSidenav.Link href="#">Date</DxcSidenav.Link>
|
|
127
|
+
<DxcSidenav.Subtitle>Guidelines</DxcSidenav.Subtitle>
|
|
128
|
+
<DxcSidenav.Link onClick={linkClick}>Layout</DxcSidenav.Link>
|
|
129
|
+
<DxcSidenav.Link onClick={linkClick}>Footer</DxcSidenav.Link>
|
|
130
|
+
</DxcSidenav>
|
|
131
|
+
</ExampleContainer>
|
|
132
|
+
|
|
133
|
+
<ExampleContainer>
|
|
134
|
+
<Title title="Sidenav with scroll" theme="light" level={4} />
|
|
135
|
+
<StyledContainer>
|
|
136
|
+
<DxcSidenav>
|
|
137
|
+
<p>
|
|
138
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
|
|
139
|
+
placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
|
|
140
|
+
elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
|
|
141
|
+
tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
|
|
142
|
+
eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue
|
|
143
|
+
gravida enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare,
|
|
144
|
+
malesuada urna eu, fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam
|
|
145
|
+
sit amet maximus augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo.
|
|
146
|
+
Praesent quis nunc dignissim, pharetra neque molestie, molestie lectus.
|
|
147
|
+
</p>
|
|
148
|
+
</DxcSidenav>
|
|
149
|
+
</StyledContainer>
|
|
150
|
+
</ExampleContainer>
|
|
151
|
+
|
|
152
|
+
<ExampleContainer pseudoState="pseudo-focus-visible">
|
|
153
|
+
<Title title="Focused" theme="light" level={4} />
|
|
154
|
+
<DxcSidenav>
|
|
155
|
+
<DxcSidenav.Title>My sidenav</DxcSidenav.Title>
|
|
156
|
+
<DxcSidenav.Subtitle>Components</DxcSidenav.Subtitle>
|
|
157
|
+
<DxcSidenav.Link href="#">Button</DxcSidenav.Link>
|
|
158
|
+
<DxcSidenav.Link href="#">Date</DxcSidenav.Link>
|
|
159
|
+
<DxcSidenav.Subtitle>Guidelines</DxcSidenav.Subtitle>
|
|
160
|
+
<DxcSidenav.Link onClick={linkClick}>Layout</DxcSidenav.Link>
|
|
161
|
+
<DxcSidenav.Link onClick={linkClick}>Footer</DxcSidenav.Link>
|
|
162
|
+
</DxcSidenav>
|
|
163
|
+
</ExampleContainer>
|
|
164
|
+
</>
|
|
165
|
+
);
|
package/slider/Slider.js
CHANGED
|
@@ -142,7 +142,7 @@ var DxcSlider = function DxcSlider(_ref) {
|
|
|
142
142
|
step: step
|
|
143
143
|
}, maxLabel), showInput && /*#__PURE__*/_react["default"].createElement(StyledTextInput, null, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
144
144
|
name: name,
|
|
145
|
-
value: value != null && value >= 0 && value || innerValue,
|
|
145
|
+
value: value != null && value >= 0 && value.toString() || innerValue.toString(),
|
|
146
146
|
disabled: disabled,
|
|
147
147
|
onChange: handlerInputChange,
|
|
148
148
|
size: "fillParent"
|
|
@@ -187,7 +187,7 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
187
187
|
return props.theme.labelLineHeight;
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
var HelperText = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n
|
|
190
|
+
var HelperText = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
|
|
191
191
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledHelperTextFontColorOnDark : props.theme.disabledHelperTextFontColor : props.backgroundType === "dark" ? props.theme.helperTextFontColorOnDark : props.theme.helperTextFontColor;
|
|
192
192
|
}, function (props) {
|
|
193
193
|
return props.theme.fontFamily;
|
package/table/Table.js
CHANGED
|
@@ -48,7 +48,7 @@ var calculateWidth = function calculateWidth(margin) {
|
|
|
48
48
|
return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow:
|
|
51
|
+
var DxcTableContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n overflow: auto;\n &::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n }\n &::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 6px;\n }\n &::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 6px;\n }\n"])), function (props) {
|
|
52
52
|
return calculateWidth(props.margin);
|
|
53
53
|
}, function (props) {
|
|
54
54
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
package/tabs/Tabs.js
CHANGED
|
@@ -135,7 +135,7 @@ var Underline = _styledComponents["default"].div(_templateObject6 || (_templateO
|
|
|
135
135
|
return props.theme.dividerColor;
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
var DxCTabs = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n .MuiTabs-root {\n background: white;\n min-height: ", ";\n\n .MuiTabs-scroller {\n .MuiTabs-flexContainer + span {\n z-index: 4;\n }\n }\n .MuiTab-root {\n text-transform: ", " !important;\n }\n .MuiButtonBase-root {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n\n padding: ", ";\n height: ", ";\n min-width: 90px;\n max-width: 360px;\n min-height: ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n font-weight: ", ";\n }\n &:not(.Mui-selected) {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-selected {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-disabled {\n cursor: not-allowed !important;\n pointer-events: all;\n color: ", ";\n font-style: ", ";\n svg {\n color: ", ";\n }\n }\n &:focus {\n outline: ", " auto 1px;\n }\n }\n .MuiTabs-indicator {\n background-color: ", ";\n height: ", ";\n }\n .MuiTabs-scrollButtons {\n min-width: ", ";\n width: ", ";\n padding: 0;\n }\n @media (max-width: 599.95px) {\n .MuiTabs-scrollButtonsDesktop {\n display: flex;\n }\n }\n }\n"])), function (props) {
|
|
138
|
+
var DxCTabs = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n .MuiTabs-root {\n background: white;\n min-height: ", ";\n\n .MuiTabs-scroller {\n .MuiTabs-flexContainer + span {\n z-index: 4;\n }\n }\n .MuiTab-root {\n text-transform: ", " !important;\n }\n .MuiButtonBase-root {\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n\n padding: ", ";\n height: ", ";\n min-width: 90px;\n max-width: 360px;\n min-height: ", ";\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n font-weight: ", ";\n }\n &:not(.Mui-selected) {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-selected {\n background-color: ", ";\n color: ", ";\n svg {\n color: ", ";\n }\n }\n &.Mui-disabled {\n background-color: ", " !important;\n cursor: not-allowed !important;\n pointer-events: all;\n color: ", ";\n font-style: ", ";\n svg {\n color: ", ";\n }\n outline: none !important;\n }\n &:focus {\n outline: ", " auto 1px;\n }\n }\n .MuiTabs-indicator {\n background-color: ", ";\n height: ", ";\n }\n .MuiTabs-scrollButtons {\n min-width: ", ";\n width: ", ";\n padding: 0;\n }\n @media (max-width: 599.95px) {\n .MuiTabs-scrollButtonsDesktop {\n display: flex;\n }\n }\n }\n"])), function (props) {
|
|
139
139
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
140
140
|
}, function (props) {
|
|
141
141
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -181,6 +181,8 @@ var DxCTabs = _styledComponents["default"].div(_templateObject7 || (_templateObj
|
|
|
181
181
|
return props.theme.selectedFontColor;
|
|
182
182
|
}, function (props) {
|
|
183
183
|
return props.theme.selectedIconColor;
|
|
184
|
+
}, function (props) {
|
|
185
|
+
return props.theme.unselectedBackgroundColor;
|
|
184
186
|
}, function (props) {
|
|
185
187
|
return props.theme.disabledFontColor;
|
|
186
188
|
}, function (props) {
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { userEvent, within } from "@storybook/testing-library";
|
|
3
|
+
import DxcTabs from "./Tabs";
|
|
4
|
+
import Title from "../../.storybook/components/Title";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Tabs",
|
|
9
|
+
component: DxcTabs,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const iconSVG = () => {
|
|
13
|
+
return (
|
|
14
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
15
|
+
<path d="M0 0h24v24H0z" fill="none" />
|
|
16
|
+
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const tabs: any = [
|
|
22
|
+
{
|
|
23
|
+
label: "Tab 1",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: "Tab 2",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "Tab 3",
|
|
30
|
+
isDisabled: true,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Tab 4",
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const tabsNotification = tabs.map((tab, index) => ({
|
|
38
|
+
...tab,
|
|
39
|
+
notificationNumber: (index === 0 && true) || (index === 1 && 5) || (index === 2 && 200),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
const tabsIcon = tabs.map((tab) => ({ ...tab, icon: iconSVG }));
|
|
43
|
+
|
|
44
|
+
const tabsNotificationIcon = tabsNotification.map((tab) => ({ ...tab, icon: iconSVG }));
|
|
45
|
+
|
|
46
|
+
export const Chromatic = () => (
|
|
47
|
+
<>
|
|
48
|
+
<ExampleContainer>
|
|
49
|
+
<Title title="Only label" theme="light" level={4} />
|
|
50
|
+
<DxcTabs tabs={tabs} />
|
|
51
|
+
</ExampleContainer>
|
|
52
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
53
|
+
<Title title="Hovered tabs" theme="light" level={4} />
|
|
54
|
+
<DxcTabs tabs={tabs} />
|
|
55
|
+
</ExampleContainer>
|
|
56
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
57
|
+
<Title title="Focused tabs" theme="light" level={4} />
|
|
58
|
+
<DxcTabs tabs={tabs} />
|
|
59
|
+
</ExampleContainer>
|
|
60
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
61
|
+
<Title title="Actived tabs" theme="light" level={4} />
|
|
62
|
+
<DxcTabs tabs={tabs} />
|
|
63
|
+
</ExampleContainer>
|
|
64
|
+
<ExampleContainer>
|
|
65
|
+
<Title title="With notification number" theme="light" level={4} />
|
|
66
|
+
<DxcTabs tabs={tabsNotification} />
|
|
67
|
+
</ExampleContainer>
|
|
68
|
+
<ExampleContainer>
|
|
69
|
+
<Title title="With icon position top" theme="light" level={4} />
|
|
70
|
+
<DxcTabs tabs={tabsIcon} />
|
|
71
|
+
</ExampleContainer>
|
|
72
|
+
<ExampleContainer>
|
|
73
|
+
<Title title="With icon position left" theme="light" level={4} />
|
|
74
|
+
<DxcTabs tabs={tabsIcon} iconPosition="left" />
|
|
75
|
+
</ExampleContainer>
|
|
76
|
+
<ExampleContainer>
|
|
77
|
+
<Title title="With icon and notification number" theme="light" level={4} />
|
|
78
|
+
<DxcTabs tabs={tabsNotificationIcon} />
|
|
79
|
+
</ExampleContainer>
|
|
80
|
+
<ExampleContainer>
|
|
81
|
+
<Title title="With icon on the left and notification number" theme="light" level={4} />
|
|
82
|
+
<DxcTabs tabs={tabsNotificationIcon} iconPosition="left" />
|
|
83
|
+
</ExampleContainer>
|
|
84
|
+
<ExampleContainer>
|
|
85
|
+
<Title title="Scrollable" theme="light" level={4} />
|
|
86
|
+
<div style={{ width: "400px" }}>
|
|
87
|
+
<DxcTabs tabs={tabsNotificationIcon} iconPosition="left" activeTabIndex={1} />
|
|
88
|
+
</div>
|
|
89
|
+
</ExampleContainer>
|
|
90
|
+
|
|
91
|
+
<Title title="Margins" theme="light" level={2} />
|
|
92
|
+
<ExampleContainer>
|
|
93
|
+
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
94
|
+
<DxcTabs tabs={tabs} margin="xxsmall" />
|
|
95
|
+
</ExampleContainer>
|
|
96
|
+
<ExampleContainer>
|
|
97
|
+
<Title title="Xsmall margin" theme="light" level={4} />
|
|
98
|
+
<DxcTabs tabs={tabs} margin="xsmall" />
|
|
99
|
+
</ExampleContainer>
|
|
100
|
+
<ExampleContainer>
|
|
101
|
+
<Title title="Small margin" theme="light" level={4} />
|
|
102
|
+
<DxcTabs tabs={tabs} margin="small" />
|
|
103
|
+
</ExampleContainer>
|
|
104
|
+
<ExampleContainer>
|
|
105
|
+
<Title title="Medium margin" theme="light" level={4} />
|
|
106
|
+
<DxcTabs tabs={tabs} margin="medium" />
|
|
107
|
+
</ExampleContainer>
|
|
108
|
+
<ExampleContainer>
|
|
109
|
+
<Title title="Large margin" theme="light" level={4} />
|
|
110
|
+
<DxcTabs tabs={tabs} margin="large" />
|
|
111
|
+
</ExampleContainer>
|
|
112
|
+
<ExampleContainer>
|
|
113
|
+
<Title title="Xlarge margin" theme="light" level={4} />
|
|
114
|
+
<DxcTabs tabs={tabs} margin="xlarge" />
|
|
115
|
+
</ExampleContainer>
|
|
116
|
+
<ExampleContainer>
|
|
117
|
+
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
118
|
+
<DxcTabs tabs={tabs} margin="xxlarge" />
|
|
119
|
+
</ExampleContainer>
|
|
120
|
+
</>
|
|
121
|
+
);
|
package/tabs/types.d.ts
CHANGED
|
@@ -58,9 +58,8 @@ declare type Props = {
|
|
|
58
58
|
*/
|
|
59
59
|
onTabHover?: (tabIndex: number) => void;
|
|
60
60
|
/**
|
|
61
|
-
* Size of the margin to be applied to the component
|
|
62
|
-
* with 'top', 'bottom', 'left' and 'right' properties in order to specify
|
|
63
|
-
* different margin sizes.
|
|
61
|
+
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
62
|
+
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
64
63
|
*/
|
|
65
64
|
margin?: Space | Margin;
|
|
66
65
|
/**
|