@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.
Files changed (64) hide show
  1. package/accordion/types.d.ts +1 -1
  2. package/accordion-group/types.d.ts +1 -1
  3. package/bulleted-list/types.d.ts +1 -1
  4. package/button/Button.js +43 -61
  5. package/button/Button.stories.tsx +9 -0
  6. package/button/types.d.ts +7 -7
  7. package/chip/types.d.ts +1 -1
  8. package/common/variables.js +15 -6
  9. package/date-input/DateInput.js +3 -3
  10. package/dialog/Dialog.js +52 -28
  11. package/dialog/Dialog.stories.tsx +1 -2
  12. package/dialog/Dialog.test.js +34 -4
  13. package/dialog/types.d.ts +2 -2
  14. package/dropdown/Dropdown.d.ts +1 -1
  15. package/dropdown/Dropdown.js +242 -246
  16. package/dropdown/Dropdown.stories.tsx +126 -63
  17. package/dropdown/Dropdown.test.js +510 -108
  18. package/dropdown/DropdownMenu.d.ts +4 -0
  19. package/dropdown/DropdownMenu.js +80 -0
  20. package/dropdown/DropdownMenuItem.d.ts +4 -0
  21. package/dropdown/DropdownMenuItem.js +92 -0
  22. package/dropdown/types.d.ts +25 -5
  23. package/flex/Flex.js +1 -1
  24. package/flex/types.d.ts +1 -1
  25. package/footer/types.d.ts +1 -1
  26. package/header/Header.js +74 -72
  27. package/header/Icons.js +2 -2
  28. package/header/types.d.ts +2 -2
  29. package/layout/ApplicationLayout.js +3 -3
  30. package/link/Link.js +1 -1
  31. package/link/Link.stories.tsx +12 -5
  32. package/link/types.d.ts +1 -1
  33. package/package.json +7 -7
  34. package/progress-bar/ProgressBar.d.ts +2 -2
  35. package/progress-bar/ProgressBar.js +56 -50
  36. package/progress-bar/ProgressBar.stories.jsx +3 -1
  37. package/progress-bar/ProgressBar.test.js +67 -22
  38. package/progress-bar/types.d.ts +3 -4
  39. package/radio-group/RadioGroup.js +11 -13
  40. package/select/Listbox.d.ts +1 -1
  41. package/select/Listbox.js +25 -1
  42. package/select/Select.js +14 -31
  43. package/select/Select.stories.tsx +6 -5
  44. package/select/Select.test.js +63 -50
  45. package/select/types.d.ts +2 -4
  46. package/sidenav/Sidenav.js +15 -3
  47. package/sidenav/types.d.ts +1 -1
  48. package/slider/Slider.js +3 -3
  49. package/slider/Slider.test.js +37 -0
  50. package/switch/Switch.d.ts +1 -1
  51. package/switch/Switch.js +110 -54
  52. package/switch/Switch.stories.tsx +8 -30
  53. package/switch/Switch.test.js +122 -8
  54. package/switch/types.d.ts +3 -4
  55. package/tabs/types.d.ts +1 -1
  56. package/tabs-nav/NavTabs.js +5 -5
  57. package/tabs-nav/Tab.js +3 -5
  58. package/tabs-nav/types.d.ts +1 -1
  59. package/tag/types.d.ts +1 -1
  60. package/text-input/TextInput.js +12 -21
  61. package/text-input/TextInput.stories.tsx +1 -2
  62. package/text-input/types.d.ts +1 -1
  63. package/toggle-group/types.d.ts +1 -1
  64. package/wizard/types.d.ts +1 -1
@@ -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
  declare type Props = {
17
17
  /**
18
18
  * The panel label.
@@ -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.
@@ -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(DxCButton, {
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 LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (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) {
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
- if (mode === "primary") {
165
- return "\n border-radius: ".concat(props.theme.primaryBorderRadius, ";\n border-width: ").concat(props.theme.primaryBorderThickness, ";\n border-style: ").concat(props.theme.primaryBorderStyle, ";\n font-family: ").concat(props.theme.primaryFontFamily, ";\n font-size: ").concat(props.theme.primaryFontSize, ";\n font-weight: ").concat(props.theme.primaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor, ";\n color: ").concat(backgroundType && backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled { \n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor, " !important; \n }\n ");
166
- } else if (mode === "secondary") {
167
- return "\n border-radius: ".concat(props.theme.secondaryBorderRadius, ";\n border-width: ").concat(props.theme.secondaryBorderThickness, ";\n border-style: ").concat(props.theme.secondaryBorderStyle, ";\n font-family: ").concat(props.theme.secondaryFontFamily, ";\n font-size: ").concat(props.theme.secondaryFontSize, ";\n font-weight: ").concat(props.theme.secondaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor, ";\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor, ";\n }\n ");
168
- } else if (mode === "text") {
169
- return "\n border-radius: ".concat(props.theme.textBorderRadius, ";\n border-width: ").concat(props.theme.textBorderThickness, ";\n border-style: ").concat(props.theme.textBorderStyle, ";\n font-family: ").concat(props.theme.textFontFamily, ";\n font-size: ").concat(props.theme.textFontSize, ";\n font-weight: ").concat(props.theme.textFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor:not-allowed;\n color: ").concat(backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, " !important;\n background-color: ").concat(backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n }\n ");
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 next to the button.
12
+ * Text to be placed in the button.
13
13
  */
14
14
  label?: string;
15
15
  /**
16
- * Uses one of the available button modes.
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
- * This prop corresponds to the 'type' prop of the button in html.
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 button label.
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
@@ -6,7 +6,7 @@ declare type Margin = {
6
6
  left?: Space;
7
7
  right?: Space;
8
8
  };
9
- declare type SVG = React.SVGProps<SVGSVGElement>;
9
+ declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
10
10
  declare type Props = {
11
11
  /**
12
12
  * Text to be placed on the chip.
@@ -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.color_grey_800,
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.white,
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: "40%",
1109
+ thumbShift: "1.25rem",
1105
1110
  trackHeight: "12px",
1106
- trackWidth: "60px",
1107
- spaceBetweenLabelSwitch: "0px"
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, ".");
@@ -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.keyCode) {
97
- case 27:
98
- // Esc
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 = _interopRequireDefault(require("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
- open: true,
60
- isCloseVisible: isCloseVisible,
61
- onClose: handleOverlayClick,
62
- overlay: overlay,
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
- }, isCloseVisible && /*#__PURE__*/_react["default"].createElement(CloseIconContainer, {
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
- }))), /*#__PURE__*/_react["default"].createElement(Children, null, /*#__PURE__*/_react["default"].createElement(_BackgroundColorContext.BackgroundColorProvider, {
79
- color: colorsTheme.dialog.backgroundColor
80
- }, children))));
98
+ }))))));
81
99
  };
82
100
 
83
- var DialogContainer = (0, _styledComponents["default"])(_Dialog["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n overflow: unset;\n font-family: ", ";\n\n .MuiBackdrop-root {\n background-color: ", ";\n opacity: ", " !important;\n }\n .MuiDialog-paperWidthSm {\n background-color: ", ";\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\n box-sizing: border-box;\n min-height: ", ";\n box-shadow: ", ";\n\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n }\n"])), function (props) {
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.overlay === true ? props.theme.overlayColor : "transparent";
116
+ return props.theme.fontSize;
87
117
  }, function (props) {
88
- return props.overlay === true && props.theme.overlayOpacity;
118
+ return props.theme.fontWeight;
89
119
  }, function (props) {
90
- return props.theme.backgroundColor;
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
- }, function (props) {
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 Children = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])([""])));
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(_templateObject4 || (_templateObject4 = (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) {
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
+ );
@@ -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 _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
42
+ var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
30
43
  onCloseClick: onCloseClick
31
44
  }, "dialog-text")),
32
- getByRole = _render3.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;
@@ -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, onSelectOption, expandOnHover, margin, size, tabIndex, disabled, }: DropdownPropsType) => JSX.Element;
3
+ declare const DxcDropdown: ({ options, optionsIconPosition, icon, iconPosition, label, caretHidden, disabled, expandOnHover, onSelectOption, margin, size, tabIndex, }: DropdownPropsType) => JSX.Element;
4
4
  export default DxcDropdown;