@dxc-technology/halstack-react 6.0.0 → 6.1.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/accordion/types.d.ts +1 -1
- package/accordion-group/types.d.ts +1 -1
- package/bulleted-list/types.d.ts +1 -1
- package/button/Button.js +43 -61
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/chip/types.d.ts +1 -1
- package/common/variables.js +15 -6
- package/date-input/DateInput.js +3 -3
- package/dialog/Dialog.js +52 -28
- package/dialog/Dialog.stories.tsx +1 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +242 -246
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +510 -108
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +25 -5
- package/flex/Flex.js +1 -1
- package/flex/types.d.ts +1 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +74 -72
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/layout/ApplicationLayout.js +3 -3
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +12 -5
- package/link/types.d.ts +1 -1
- package/package.json +7 -7
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +56 -50
- package/progress-bar/ProgressBar.stories.jsx +3 -1
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/radio-group/RadioGroup.js +11 -13
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +25 -1
- package/select/Select.js +14 -31
- package/select/Select.stories.tsx +6 -5
- package/select/Select.test.js +63 -50
- package/select/types.d.ts +2 -4
- package/sidenav/Sidenav.js +15 -3
- package/sidenav/types.d.ts +1 -1
- package/slider/Slider.js +3 -3
- package/slider/Slider.test.js +37 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +110 -54
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +122 -8
- package/switch/types.d.ts +3 -4
- package/tabs/types.d.ts +1 -1
- package/tabs-nav/NavTabs.js +5 -5
- package/tabs-nav/Tab.js +3 -5
- package/tabs-nav/types.d.ts +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/TextInput.js +12 -21
- package/text-input/TextInput.stories.tsx +1 -2
- package/text-input/types.d.ts +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/wizard/types.d.ts +1 -1
package/accordion/types.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare type Padding = {
|
|
|
12
12
|
left?: Space;
|
|
13
13
|
right?: Space;
|
|
14
14
|
};
|
|
15
|
-
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
15
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
16
16
|
export declare type AccordionPropsType = {
|
|
17
17
|
/**
|
|
18
18
|
* The panel label.
|
package/bulleted-list/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type SVG = React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement
|
|
2
|
+
declare type SVG = React.ReactNode & (React.SVGProps<SVGSVGElement> | React.FunctionComponent<React.SVGProps<SVGSVGElement>>);
|
|
3
3
|
declare type Props = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
type?: "disc" | "circle" | "square" | "number" | "icon";
|
package/button/Button.js
CHANGED
|
@@ -15,8 +15,6 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
15
15
|
|
|
16
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
17
|
|
|
18
|
-
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
19
|
-
|
|
20
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
19
|
|
|
22
20
|
var _variables = require("../common/variables.js");
|
|
@@ -33,6 +31,22 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
33
31
|
|
|
34
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
33
|
|
|
34
|
+
var sizes = {
|
|
35
|
+
small: "42px",
|
|
36
|
+
medium: "120px",
|
|
37
|
+
large: "240px",
|
|
38
|
+
fillParent: "100%",
|
|
39
|
+
fitContent: "fit-content"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var calculateWidth = function calculateWidth(margin, size) {
|
|
43
|
+
if (size === "fillParent") {
|
|
44
|
+
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return sizes[size];
|
|
48
|
+
};
|
|
49
|
+
|
|
36
50
|
var DxcButton = function DxcButton(_ref) {
|
|
37
51
|
var _ref$label = _ref.label,
|
|
38
52
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
@@ -63,21 +77,15 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
63
77
|
|
|
64
78
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
65
79
|
theme: colorsTheme.button
|
|
66
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(Button, {
|
|
67
81
|
type: type,
|
|
68
|
-
margin: margin,
|
|
69
82
|
mode: mode !== "primary" && mode !== "secondary" && mode !== "text" ? "primary" : mode,
|
|
70
83
|
disabled: disabled,
|
|
71
|
-
iconPosition: iconPosition,
|
|
72
|
-
size: size,
|
|
73
|
-
backgroundType: backgroundType,
|
|
74
|
-
icon: icon
|
|
75
|
-
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
76
|
-
type: type,
|
|
77
|
-
disabled: disabled,
|
|
78
|
-
disableRipple: true,
|
|
79
84
|
"aria-disabled": disabled,
|
|
80
85
|
tabIndex: disabled ? -1 : tabIndex,
|
|
86
|
+
backgroundType: backgroundType,
|
|
87
|
+
size: size,
|
|
88
|
+
margin: margin,
|
|
81
89
|
onClick: function onClick() {
|
|
82
90
|
_onClick();
|
|
83
91
|
}
|
|
@@ -86,44 +94,10 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
86
94
|
iconPosition: iconPosition
|
|
87
95
|
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(ButtonIcon, {
|
|
88
96
|
src: icon
|
|
89
|
-
}) : icon), label && iconPosition === "before" && labelComponent))
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
var sizes = {
|
|
93
|
-
small: "42px",
|
|
94
|
-
medium: "120px",
|
|
95
|
-
large: "240px",
|
|
96
|
-
fillParent: "100%",
|
|
97
|
-
fitContent: "unset"
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
var calculateWidth = function calculateWidth(margin, size) {
|
|
101
|
-
if (size === "fillParent") {
|
|
102
|
-
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return sizes[size];
|
|
97
|
+
}) : icon), label && iconPosition === "before" && labelComponent));
|
|
106
98
|
};
|
|
107
99
|
|
|
108
|
-
var
|
|
109
|
-
return props.theme.labelFontLineHeight;
|
|
110
|
-
}, function (props) {
|
|
111
|
-
return props.theme.fontSize;
|
|
112
|
-
}, function (props) {
|
|
113
|
-
return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
|
|
114
|
-
}, function (props) {
|
|
115
|
-
return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
var IconContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 24px;\n max-width: 24px;\n margin-left: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
119
|
-
return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
|
|
120
|
-
}, function (props) {
|
|
121
|
-
return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
var ButtonIcon = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
125
|
-
|
|
126
|
-
var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-block;\n width: ", ";\n cursor: ", ";\n\n .MuiButtonBase-root {\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n\n .MuiButton-label {\n display: flex;\n align-items: center;\n }\n\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n min-width: ", ";\n width: 100%;\n height: 40px;\n transition: none !important;\n\n &:focus {\n border-color: transparent;\n box-shadow: 0 0 0 2px\n ", ";\n }\n\n ", "\n }\n"])), function (props) {
|
|
100
|
+
var Button = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n display: inline-flex;\n width: ", ";\n height: 40px;\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n align-items: center;\n justify-content: center;\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n cursor: pointer;\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px\n ", ";\n }\n ", "\n"])), function (props) {
|
|
127
101
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
128
102
|
}, function (props) {
|
|
129
103
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -135,8 +109,6 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
|
|
|
135
109
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
136
110
|
}, function (props) {
|
|
137
111
|
return calculateWidth(props.margin, props.size);
|
|
138
|
-
}, function (props) {
|
|
139
|
-
return props.disabled && "not-allowed" || "pointer";
|
|
140
112
|
}, function (props) {
|
|
141
113
|
return props.theme.paddingLeft;
|
|
142
114
|
}, function (props) {
|
|
@@ -153,22 +125,32 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
|
|
|
153
125
|
return props.theme.fontWeight;
|
|
154
126
|
}, function (props) {
|
|
155
127
|
return props.theme.labelLetterSpacing;
|
|
156
|
-
}, function (props) {
|
|
157
|
-
return props.size === "small" && "calc(100% - 22px)" || "unset";
|
|
158
128
|
}, function (props) {
|
|
159
129
|
return props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor;
|
|
160
130
|
}, function (props) {
|
|
161
131
|
var mode = props.mode,
|
|
162
|
-
backgroundType = props.backgroundType
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
132
|
+
backgroundType = props.backgroundType,
|
|
133
|
+
disabled = props.disabled;
|
|
134
|
+
return "\n border-radius: ".concat(props.mode === "primary" ? props.theme.primaryBorderRadius : props.mode === "secondary" ? props.theme.secondaryBorderRadius : props.theme.textBorderRadius, ";\n border-width: ").concat(props.mode === "primary" ? props.theme.primaryBorderThickness : props.mode === "secondary" ? props.theme.secondaryBorderThickness : props.theme.textBorderThickness, ";\n border-style: ").concat(mode === "primary" ? props.theme.primaryBorderStyle : mode === "secondary" ? props.theme.secondaryBorderStyle : props.theme.textBorderStyle, ";\n font-family: ").concat(mode === "primary" ? props.theme.primaryFontFamily : mode === "secondary" ? props.theme.secondaryFontFamily : props.theme.textFontFamily, ";\n font-size: ").concat(mode === "primary" ? props.theme.primaryFontSize : mode === "secondary" ? props.theme.secondaryFontSize : props.theme.textFontSize, ";\n font-weight: ").concat(mode === "primary" ? props.theme.primaryFontWeight : mode === "secondary" ? props.theme.secondaryFontWeight : props.theme.textFontWeight, ";\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor : backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor : backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor : "", ";\n &:hover {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor : backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n }\n &:focus {\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n }\n &:active {\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor : backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, ";\n color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor : "", ";\n border-color: ").concat(mode === "secondary" ? "transparent" : "", ";\n outline: none;\n box-shadow: ").concat(!disabled ? "0 0 0 2px ".concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor) : "", ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor : backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n color: ").concat(mode === "primary" ? backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor : mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor : backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, ";\n border-color: ").concat(mode === "secondary" ? backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor : "", ";\n }\n ");
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: ", ";\n font-size: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n text-transform: none;\n white-space: nowrap;\n margin-right: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
138
|
+
return props.theme.labelFontLineHeight;
|
|
139
|
+
}, function (props) {
|
|
140
|
+
return props.theme.fontSize;
|
|
141
|
+
}, function (props) {
|
|
142
|
+
return !props.icon || props.iconPosition === "before" ? "8px" : "0px";
|
|
143
|
+
}, function (props) {
|
|
144
|
+
return !props.icon || props.iconPosition === "after" ? "8px" : "0px";
|
|
171
145
|
});
|
|
172
146
|
|
|
147
|
+
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 24px;\n max-width: 24px;\n margin-left: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
148
|
+
return !props.label ? "0px" : props.iconPosition === "after" && props.label !== "" && "8px" || "8px";
|
|
149
|
+
}, function (props) {
|
|
150
|
+
return !props.label ? "0px" : props.iconPosition === "before" && props.label !== "" && "8px" || "8px";
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
var ButtonIcon = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])));
|
|
154
|
+
|
|
173
155
|
var _default = DxcButton;
|
|
174
156
|
exports["default"] = _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import DxcButton from "./Button";
|
|
3
|
+
import DxcFlex from "./../flex/Flex";
|
|
3
4
|
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
4
5
|
import Title from "../../.storybook/components/Title";
|
|
5
6
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
@@ -270,5 +271,13 @@ export const Chromatic = () => (
|
|
|
270
271
|
<Title title="Xxlarge margin" theme="light" level={4} />
|
|
271
272
|
<DxcButton label="Xxlarge margin" margin="xxlarge" />
|
|
272
273
|
</ExampleContainer>
|
|
274
|
+
<Title title="Inside a flex" theme="light" level={2} />
|
|
275
|
+
<ExampleContainer>
|
|
276
|
+
<DxcFlex direction="column" gap="0.75rem">
|
|
277
|
+
<DxcButton label="Button" />
|
|
278
|
+
<DxcButton label="Button" />
|
|
279
|
+
<DxcButton label="Button" />
|
|
280
|
+
</DxcFlex>
|
|
281
|
+
</ExampleContainer>
|
|
273
282
|
</>
|
|
274
283
|
);
|
package/button/types.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
-
declare type Margin = {
|
|
2
|
+
export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
export declare 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.SVGProps<SVGSVGElement>;
|
|
9
|
+
export declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
10
|
declare type Props = {
|
|
11
11
|
/**
|
|
12
|
-
* Text to be placed
|
|
12
|
+
* Text to be placed in the button.
|
|
13
13
|
*/
|
|
14
14
|
label?: string;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* The available button modes.
|
|
17
17
|
*/
|
|
18
18
|
mode?: "primary" | "secondary" | "text";
|
|
19
19
|
/**
|
|
@@ -25,11 +25,11 @@ declare type Props = {
|
|
|
25
25
|
*/
|
|
26
26
|
iconPosition?: "before" | "after";
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 'type' html prop of the button.
|
|
29
29
|
*/
|
|
30
30
|
type?: "button" | "reset" | "submit";
|
|
31
31
|
/**
|
|
32
|
-
* Element or path used as the icon that will be placed next to the
|
|
32
|
+
* Element or path used as the icon that will be placed next to the label.
|
|
33
33
|
*/
|
|
34
34
|
icon?: string | SVG;
|
|
35
35
|
/**
|
package/chip/types.d.ts
CHANGED
package/common/variables.js
CHANGED
|
@@ -435,7 +435,10 @@ var componentTokens = {
|
|
|
435
435
|
boxShadowOffsetY: "1px",
|
|
436
436
|
boxShadowBlur: "3px",
|
|
437
437
|
boxShadowColor: "rgba(0, 0, 0, 0.2)",
|
|
438
|
-
overlayOpacity: "0.7"
|
|
438
|
+
overlayOpacity: "0.7",
|
|
439
|
+
fontFamily: globalTokens.type_sans,
|
|
440
|
+
fontSize: globalTokens.type_scale_03,
|
|
441
|
+
fontWeight: globalTokens.type_regular
|
|
439
442
|
},
|
|
440
443
|
dropdown: {
|
|
441
444
|
buttonBackgroundColor: globalTokens.hal_white,
|
|
@@ -936,11 +939,13 @@ var componentTokens = {
|
|
|
936
939
|
groupTitleFontSize: globalTokens.type_scale_02,
|
|
937
940
|
groupTitleFontStyle: globalTokens.type_normal,
|
|
938
941
|
groupTitleFontWeight: globalTokens.type_semibold,
|
|
939
|
-
groupTitleFontColor: globalTokens.
|
|
942
|
+
groupTitleFontColor: globalTokens.black,
|
|
940
943
|
groupTitleHoverBackgroundColor: globalTokens.hal_grey_l_90,
|
|
941
944
|
groupTitleActiveBackgroundColor: globalTokens.hal_grey_l_80,
|
|
942
945
|
groupTitleSelectedFontColor: globalTokens.white,
|
|
943
|
-
groupTitleSelectedBackgroundColor: globalTokens.
|
|
946
|
+
groupTitleSelectedBackgroundColor: globalTokens.color_grey_800,
|
|
947
|
+
groupTitleSelectedHoverFontColor: globalTokens.white,
|
|
948
|
+
groupTitleSelectedHoverBackgroundColor: globalTokens.color_grey_600,
|
|
944
949
|
groupTitleFontTextTransform: globalTokens.type_uppercase,
|
|
945
950
|
groupTitleFontLetterSpacing: globalTokens.type_spacing_wide_02,
|
|
946
951
|
linkFontFamily: globalTokens.type_sans,
|
|
@@ -1101,10 +1106,10 @@ var componentTokens = {
|
|
|
1101
1106
|
thumbFocusColorOnDark: "#1682FF",
|
|
1102
1107
|
thumbHeight: "24px",
|
|
1103
1108
|
thumbWidth: "24px",
|
|
1104
|
-
thumbShift: "
|
|
1109
|
+
thumbShift: "1.25rem",
|
|
1105
1110
|
trackHeight: "12px",
|
|
1106
|
-
trackWidth: "
|
|
1107
|
-
spaceBetweenLabelSwitch: "
|
|
1111
|
+
trackWidth: "36px",
|
|
1112
|
+
spaceBetweenLabelSwitch: "8px"
|
|
1108
1113
|
},
|
|
1109
1114
|
tag: {
|
|
1110
1115
|
fontFamily: globalTokens.type_sans,
|
|
@@ -1442,6 +1447,10 @@ var defaultTranslatedComponentLabels = {
|
|
|
1442
1447
|
return "\xA9 DXC Technology ".concat(year, ". All rights reserved.");
|
|
1443
1448
|
}
|
|
1444
1449
|
},
|
|
1450
|
+
header: {
|
|
1451
|
+
closeIcon: "Close menu",
|
|
1452
|
+
hamburguerTitle: "Menu"
|
|
1453
|
+
},
|
|
1445
1454
|
numberInput: {
|
|
1446
1455
|
valueGreaterThanOrEqualToErrorMessage: function valueGreaterThanOrEqualToErrorMessage(value) {
|
|
1447
1456
|
return "Value must be greater than or equal to ".concat(value, ".");
|
package/date-input/DateInput.js
CHANGED
|
@@ -93,9 +93,9 @@ var DxcDateInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
93
93
|
var refDate = ref || (0, _react.useRef)(null);
|
|
94
94
|
|
|
95
95
|
var handleCalendarOnKeyDown = function handleCalendarOnKeyDown(event) {
|
|
96
|
-
switch (event.
|
|
97
|
-
case
|
|
98
|
-
|
|
96
|
+
switch (event.key) {
|
|
97
|
+
case "Esc":
|
|
98
|
+
case "Escape":
|
|
99
99
|
event.preventDefault();
|
|
100
100
|
setIsOpen(false);
|
|
101
101
|
break;
|
package/dialog/Dialog.js
CHANGED
|
@@ -13,19 +13,17 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
13
13
|
|
|
14
14
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
15
|
|
|
16
|
-
var _react =
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
17
|
|
|
18
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
19
|
|
|
20
|
-
var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
|
|
21
|
-
|
|
22
20
|
var _variables = require("../common/variables.js");
|
|
23
21
|
|
|
24
22
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
23
|
|
|
26
24
|
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
27
25
|
|
|
28
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
26
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
29
27
|
|
|
30
28
|
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); }
|
|
31
29
|
|
|
@@ -53,15 +51,37 @@ var DxcDialog = function DxcDialog(_ref) {
|
|
|
53
51
|
onBackgroundClick === null || onBackgroundClick === void 0 ? void 0 : onBackgroundClick();
|
|
54
52
|
};
|
|
55
53
|
|
|
54
|
+
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
55
|
+
if (event.key === "Escape") {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
handleClose();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
(0, _react.useEffect)(function () {
|
|
62
|
+
if (isCloseVisible) {
|
|
63
|
+
window.addEventListener("keydown", handleOnKeyDown);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return function () {
|
|
67
|
+
window.removeEventListener("keydown", handleOnKeyDown);
|
|
68
|
+
};
|
|
69
|
+
}, [isCloseVisible]);
|
|
56
70
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
57
71
|
theme: colorsTheme.dialog
|
|
58
|
-
}, /*#__PURE__*/_react["default"].createElement(DialogContainer, {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
}, /*#__PURE__*/_react["default"].createElement(BodyStyle, null), /*#__PURE__*/_react["default"].createElement(DialogContainer, {
|
|
73
|
+
role: "presentation"
|
|
74
|
+
}, overlay && /*#__PURE__*/_react["default"].createElement(Overlay, {
|
|
75
|
+
onClick: handleOverlayClick
|
|
76
|
+
}), /*#__PURE__*/_react["default"].createElement(Dialog, {
|
|
77
|
+
role: "dialog",
|
|
78
|
+
"aria-modal": overlay,
|
|
79
|
+
isCloseVisible: isCloseVisible
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(Children, {
|
|
63
81
|
padding: padding
|
|
64
|
-
},
|
|
82
|
+
}, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
|
|
83
|
+
color: colorsTheme.dialog.backgroundColor
|
|
84
|
+
}, children)), isCloseVisible && /*#__PURE__*/_react["default"].createElement(CloseIconContainer, {
|
|
65
85
|
onClick: handleClose,
|
|
66
86
|
tabIndex: tabIndex
|
|
67
87
|
}, /*#__PURE__*/_react["default"].createElement(CloseIcon, {
|
|
@@ -75,24 +95,34 @@ var DxcDialog = function DxcDialog(_ref) {
|
|
|
75
95
|
fill: "none"
|
|
76
96
|
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
77
97
|
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
|
|
78
|
-
})))
|
|
79
|
-
color: colorsTheme.dialog.backgroundColor
|
|
80
|
-
}, children))));
|
|
98
|
+
}))))));
|
|
81
99
|
};
|
|
82
100
|
|
|
83
|
-
var
|
|
101
|
+
var BodyStyle = (0, _styledComponents.createGlobalStyle)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n body {\n overflow: hidden;\n }\n"])));
|
|
102
|
+
|
|
103
|
+
var DialogContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n inset: 0px;\n height: 100%;\n z-index: 1300;\n"])));
|
|
104
|
+
|
|
105
|
+
var Overlay = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n position: fixed;\n inset: 0px;\n height: 100%;\n background-color: ", ";\n opacity: ", ";\n"])), function (props) {
|
|
106
|
+
return props.theme.overlayColor;
|
|
107
|
+
}, function (props) {
|
|
108
|
+
return props.theme.overlayOpacity;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
var Dialog = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n z-index: 1300;\n background-color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n ", "\n box-sizing: border-box;\n box-shadow: ", ";\n border-radius: 4px;\n\n @media (min-width: ", "rem) {\n max-width: 80%;\n min-width: 800px;\n }\n\n @media (max-width: ", "rem) {\n //mobile phones\n max-width: 92%;\n min-width: 92%;\n }\n"])), function (props) {
|
|
112
|
+
return props.theme.backgroundColor;
|
|
113
|
+
}, function (props) {
|
|
84
114
|
return props.theme.fontFamily;
|
|
85
115
|
}, function (props) {
|
|
86
|
-
return props.
|
|
116
|
+
return props.theme.fontSize;
|
|
87
117
|
}, function (props) {
|
|
88
|
-
return props.
|
|
118
|
+
return props.theme.fontWeight;
|
|
89
119
|
}, function (props) {
|
|
90
|
-
return props.
|
|
91
|
-
}, _variables.responsiveSizes.medium, _variables.responsiveSizes.medium, function (props) {
|
|
92
|
-
return props.isCloseVisible ? "72px" : "";
|
|
120
|
+
return props.isCloseVisible && "min-height: 72px;";
|
|
93
121
|
}, function (props) {
|
|
94
122
|
return "".concat(props.theme.boxShadowOffsetX, " ").concat(props.theme.boxShadowOffsetY, " ").concat(props.theme.boxShadowBlur, " ").concat(props.theme.boxShadowColor);
|
|
95
|
-
},
|
|
123
|
+
}, _variables.responsiveSizes.medium, _variables.responsiveSizes.medium);
|
|
124
|
+
|
|
125
|
+
var Children = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n"])), function (props) {
|
|
96
126
|
return props.padding && (0, _typeof2["default"])(props.padding) !== "object" ? _variables.spaces[props.padding] : _variables.spaces["small"];
|
|
97
127
|
}, function (props) {
|
|
98
128
|
return props.padding && (0, _typeof2["default"])(props.padding) === "object" && props.padding.top ? _variables.spaces[props.padding.top] : "";
|
|
@@ -104,13 +134,7 @@ var DialogContainer = (0, _styledComponents["default"])(_Dialog["default"])(_tem
|
|
|
104
134
|
return props.padding && (0, _typeof2["default"])(props.padding) === "object" && props.padding.left ? _variables.spaces[props.padding.left] : "";
|
|
105
135
|
});
|
|
106
136
|
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
var CloseIconContainer = _styledComponents["default"].button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: flex-end;\n position: absolute;\n top: ", ";\n right: ", ";\n cursor: pointer;\n padding: 0;\n margin: 0;\n background: none;\n color: ", ";\n width: ", ";\n height: ", ";\n border: none;\n"])), function (props) {
|
|
110
|
-
return props.theme.closeIconTopPosition;
|
|
111
|
-
}, function (props) {
|
|
112
|
-
return props.theme.closeIconRightPosition;
|
|
113
|
-
}, function (props) {
|
|
137
|
+
var CloseIconContainer = _styledComponents["default"].button(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n cursor: pointer;\n padding: 0;\n margin: 0;\n background: none;\n border: none;\n position: relative;\n top: 20px;\n right: 20px;\n color: ", ";\n width: ", ";\n height: ", ";\n"])), function (props) {
|
|
114
138
|
return props.theme.closeIconColor;
|
|
115
139
|
}, function (props) {
|
|
116
140
|
return props.theme.closeIconWidth;
|
|
@@ -118,7 +142,7 @@ var CloseIconContainer = _styledComponents["default"].button(_templateObject3 ||
|
|
|
118
142
|
return props.theme.closeIconHeight;
|
|
119
143
|
});
|
|
120
144
|
|
|
121
|
-
var CloseIcon = _styledComponents["default"].svg(
|
|
145
|
+
var CloseIcon = _styledComponents["default"].svg(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n width: ", ";\n height: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n"])), function (props) {
|
|
122
146
|
return props.theme.closeIconBackgroundColor;
|
|
123
147
|
}, function (props) {
|
|
124
148
|
return props.theme.closeIconWidth;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { userEvent, within } from "@storybook/testing-library";
|
|
3
2
|
import DxcDialog from "./Dialog";
|
|
4
3
|
import Title from "../../.storybook/components/Title";
|
|
5
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
@@ -209,4 +208,4 @@ export const DialogWithXxlargePadding = () => (
|
|
|
209
208
|
</p>{" "}
|
|
210
209
|
</DxcDialog>
|
|
211
210
|
</ExampleContainer>
|
|
212
|
-
);
|
|
211
|
+
);
|
package/dialog/Dialog.test.js
CHANGED
|
@@ -9,10 +9,13 @@ var _react2 = require("@testing-library/react");
|
|
|
9
9
|
var _Dialog = _interopRequireDefault(require("./Dialog"));
|
|
10
10
|
|
|
11
11
|
describe("Dialog component tests", function () {
|
|
12
|
-
test("Dialog renders with correct text", function () {
|
|
12
|
+
test("Dialog renders with correct text and accesibility attributes", function () {
|
|
13
13
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], null, "dialog-text")),
|
|
14
|
-
getByText = _render.getByText
|
|
14
|
+
getByText = _render.getByText,
|
|
15
|
+
getByRole = _render.getByRole;
|
|
15
16
|
|
|
17
|
+
expect(getByRole("dialog")).toBeTruthy();
|
|
18
|
+
expect(getByRole("dialog").getAttribute("aria-modal")).toBe("true");
|
|
16
19
|
expect(getByText("dialog-text")).toBeTruthy();
|
|
17
20
|
});
|
|
18
21
|
test("Dialog renders without close button", function () {
|
|
@@ -23,18 +26,45 @@ describe("Dialog component tests", function () {
|
|
|
23
26
|
|
|
24
27
|
expect(queryByRole("button")).toBeFalsy();
|
|
25
28
|
});
|
|
29
|
+
test("Dialog renders with aria-modal false when overlay is not used", function () {
|
|
30
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
31
|
+
isCloseVisible: false,
|
|
32
|
+
overlay: false
|
|
33
|
+
}, "dialog-text")),
|
|
34
|
+
getByRole = _render3.getByRole;
|
|
35
|
+
|
|
36
|
+
expect(getByRole("dialog")).toBeTruthy();
|
|
37
|
+
expect(getByRole("dialog").getAttribute("aria-modal")).toBe("false");
|
|
38
|
+
});
|
|
26
39
|
test("Calls correct function onCloseClick", function () {
|
|
27
40
|
var onCloseClick = jest.fn();
|
|
28
41
|
|
|
29
|
-
var
|
|
42
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
30
43
|
onCloseClick: onCloseClick
|
|
31
44
|
}, "dialog-text")),
|
|
32
|
-
getByRole =
|
|
45
|
+
getByRole = _render4.getByRole;
|
|
33
46
|
|
|
34
47
|
var closeButton = getByRole("button");
|
|
35
48
|
|
|
36
49
|
_react2.fireEvent.click(closeButton);
|
|
37
50
|
|
|
51
|
+
expect(onCloseClick).toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
test("Calls correct function onCloseClick when 'escape' key is pressed", function () {
|
|
54
|
+
var onCloseClick = jest.fn();
|
|
55
|
+
|
|
56
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
|
|
57
|
+
onCloseClick: onCloseClick
|
|
58
|
+
}, "dialog-text")),
|
|
59
|
+
getByRole = _render5.getByRole;
|
|
60
|
+
|
|
61
|
+
_react2.fireEvent.keyDown(getByRole("button"), {
|
|
62
|
+
key: "Escape",
|
|
63
|
+
code: "Escape",
|
|
64
|
+
keyCode: 27,
|
|
65
|
+
charCode: 27
|
|
66
|
+
});
|
|
67
|
+
|
|
38
68
|
expect(onCloseClick).toHaveBeenCalled();
|
|
39
69
|
});
|
|
40
70
|
});
|
package/dialog/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
-
declare type Padding = {
|
|
2
|
+
export declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
export declare type Padding = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
package/dropdown/Dropdown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import DropdownPropsType from "./types";
|
|
3
|
-
declare const DxcDropdown: ({ options, optionsIconPosition, icon, iconPosition, label, caretHidden,
|
|
3
|
+
declare const DxcDropdown: ({ options, optionsIconPosition, icon, iconPosition, label, caretHidden, disabled, expandOnHover, onSelectOption, margin, size, tabIndex, }: DropdownPropsType) => JSX.Element;
|
|
4
4
|
export default DxcDropdown;
|