@dxc-technology/halstack-react 0.0.0-a7970fd → 0.0.0-a7fec42
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/HalstackContext.d.ts +4 -2
- package/HalstackContext.js +110 -58
- package/accordion/Accordion.js +122 -103
- package/accordion/Accordion.stories.tsx +2 -3
- package/accordion/Accordion.test.js +9 -10
- package/accordion/types.d.ts +5 -4
- package/accordion-group/AccordionGroup.js +2 -21
- package/accordion-group/AccordionGroup.stories.tsx +27 -1
- package/accordion-group/AccordionGroup.test.js +20 -45
- package/accordion-group/types.d.ts +10 -3
- package/alert/Alert.js +5 -2
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +23 -33
- package/box/types.d.ts +1 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +43 -61
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +34 -36
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.js +90 -95
- package/checkbox/Checkbox.test.js +93 -16
- package/checkbox/types.d.ts +2 -2
- package/chip/types.d.ts +1 -1
- package/common/variables.js +232 -96
- package/date-input/DateInput.js +8 -5
- package/dialog/Dialog.js +52 -28
- package/dialog/Dialog.stories.tsx +57 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +3 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +244 -247
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +509 -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/file-input/FileInput.js +9 -6
- package/file-input/FileItem.js +7 -5
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +69 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/{quick-nav-container → flex}/types.js +0 -0
- package/footer/Footer.js +7 -5
- package/footer/Footer.stories.tsx +8 -1
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +2 -1
- package/header/Header.js +80 -75
- package/header/Header.stories.tsx +4 -4
- package/header/Icons.js +2 -2
- package/header/types.d.ts +3 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +70 -117
- package/layout/ApplicationLayout.stories.tsx +84 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +57 -70
- package/link/Link.stories.tsx +95 -53
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +8 -11
- package/main.js +40 -58
- package/number-input/NumberInput.test.js +1 -1
- package/number-input/types.d.ts +1 -1
- package/package.json +10 -9
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +42 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +11 -6
- package/password-input/PasswordInput.test.js +14 -14
- package/password-input/types.d.ts +1 -1
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +57 -51
- package/progress-bar/ProgressBar.stories.jsx +13 -11
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.js +75 -22
- package/quick-nav/QuickNav.stories.tsx +131 -26
- package/quick-nav/types.d.ts +1 -1
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +43 -28
- package/radio-group/RadioGroup.js +30 -27
- package/radio-group/RadioGroup.stories.tsx +1 -0
- package/radio-group/RadioGroup.test.js +123 -96
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +58 -8
- package/select/Select.js +80 -90
- package/select/Select.stories.tsx +145 -100
- package/select/Select.test.js +425 -249
- package/select/types.d.ts +2 -5
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.js +116 -92
- package/slider/Slider.stories.tsx +7 -1
- package/slider/Slider.test.js +121 -21
- package/slider/types.d.ts +2 -2
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +135 -66
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +144 -17
- package/switch/types.d.ts +3 -4
- package/table/Table.js +1 -1
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +135 -0
- package/tabs/Tabs.js +360 -104
- package/tabs/Tabs.stories.tsx +74 -0
- package/tabs/Tabs.test.js +217 -6
- package/tabs/types.d.ts +15 -5
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +130 -0
- package/tabs-nav/types.d.ts +53 -0
- package/{radio → tabs-nav}/types.js +0 -0
- package/tag/Tag.js +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +57 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +206 -329
- package/text-input/TextInput.stories.tsx +189 -182
- package/text-input/TextInput.test.js +166 -164
- package/text-input/types.d.ts +35 -4
- package/textarea/Textarea.js +10 -19
- package/textarea/types.d.ts +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/{row → typography}/types.js +0 -0
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +36 -41
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/types.d.ts +5 -4
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/quick-nav-container/HeadingLink.d.ts +0 -8
- package/quick-nav-container/HeadingLink.js +0 -58
- package/quick-nav-container/QuickNavContainer.d.ts +0 -4
- package/quick-nav-container/QuickNavContainer.js +0 -69
- package/quick-nav-container/Section.d.ts +0 -9
- package/quick-nav-container/Section.js +0 -37
- package/quick-nav-container/types.d.ts +0 -34
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -173
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -24
- package/stack/types.js +0 -5
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
|
@@ -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/card/Card.js
CHANGED
|
@@ -25,7 +25,7 @@ var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
|
25
25
|
|
|
26
26
|
var _Box = _interopRequireDefault(require("../box/Box"));
|
|
27
27
|
|
|
28
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5
|
|
28
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
29
29
|
|
|
30
30
|
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
31
|
|
|
@@ -64,17 +64,6 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
64
64
|
src: imageSrc
|
|
65
65
|
}));
|
|
66
66
|
|
|
67
|
-
var tagContent = /*#__PURE__*/_react["default"].createElement(_Box["default"], {
|
|
68
|
-
shadowDepth: !outlined ? 0 : isHovered && (onClick || linkHref) ? 2 : 1
|
|
69
|
-
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
70
|
-
theme: colorsTheme.card
|
|
71
|
-
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
72
|
-
hasAction: onClick || linkHref,
|
|
73
|
-
imagePosition: imagePosition
|
|
74
|
-
}, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
|
|
75
|
-
contentPadding: contentPadding
|
|
76
|
-
}, children), imageSrc && imagePosition === "after" && imageComponent)));
|
|
77
|
-
|
|
78
67
|
return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
|
|
79
68
|
margin: margin,
|
|
80
69
|
onMouseEnter: function onMouseEnter() {
|
|
@@ -84,15 +73,23 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
84
73
|
return changeIsHovered(false);
|
|
85
74
|
},
|
|
86
75
|
onClick: onClick,
|
|
87
|
-
hasAction: onClick,
|
|
88
|
-
tabIndex:
|
|
89
|
-
|
|
90
|
-
tabIndex: tabIndex,
|
|
76
|
+
hasAction: onClick || linkHref,
|
|
77
|
+
tabIndex: onClick || linkHref ? tabIndex : -1,
|
|
78
|
+
as: linkHref && "a",
|
|
91
79
|
href: linkHref
|
|
92
|
-
},
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(_Box["default"], {
|
|
81
|
+
shadowDepth: !outlined ? 0 : isHovered && (onClick || linkHref) ? 2 : 1
|
|
82
|
+
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
83
|
+
theme: colorsTheme.card
|
|
84
|
+
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
85
|
+
hasAction: onClick || linkHref,
|
|
86
|
+
imagePosition: imagePosition
|
|
87
|
+
}, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
|
|
88
|
+
contentPadding: contentPadding
|
|
89
|
+
}, children), imageSrc && imagePosition === "after" && imageComponent))));
|
|
93
90
|
};
|
|
94
91
|
|
|
95
|
-
var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n outline: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n
|
|
92
|
+
var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n cursor: ", ";\n outline: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n text-decoration: none;\n\n ", "\n"])), function (_ref2) {
|
|
96
93
|
var hasAction = _ref2.hasAction;
|
|
97
94
|
return hasAction && "pointer" || "unset";
|
|
98
95
|
}, function (_ref3) {
|
|
@@ -113,49 +110,50 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
113
110
|
}, function (_ref8) {
|
|
114
111
|
var margin = _ref8.margin;
|
|
115
112
|
return margin && margin.left ? _variables.spaces[margin.left] : "";
|
|
113
|
+
}, function (_ref9) {
|
|
114
|
+
var hasAction = _ref9.hasAction;
|
|
115
|
+
return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n height: ", ";\n width: ", ";\n &:hover {\n border-color: ", ";\n }\n"])), function (props) {
|
|
119
119
|
return props.theme.height;
|
|
120
120
|
}, function (props) {
|
|
121
121
|
return props.theme.width;
|
|
122
|
-
}, function (
|
|
123
|
-
var hasAction =
|
|
122
|
+
}, function (_ref10) {
|
|
123
|
+
var hasAction = _ref10.hasAction;
|
|
124
124
|
return hasAction ? "" : "unset";
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
var TagImage = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref10) {
|
|
130
|
-
var imagePadding = _ref10.imagePadding;
|
|
131
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
132
|
-
}, function (_ref11) {
|
|
127
|
+
var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
|
|
133
128
|
var imagePadding = _ref11.imagePadding;
|
|
134
129
|
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
135
130
|
}, function (_ref12) {
|
|
136
|
-
var
|
|
131
|
+
var imagePadding = _ref12.imagePadding;
|
|
132
|
+
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
133
|
+
}, function (_ref13) {
|
|
134
|
+
var cover = _ref13.cover;
|
|
137
135
|
return cover ? "cover" : "contain";
|
|
138
136
|
});
|
|
139
137
|
|
|
140
|
-
var ImageContainer = _styledComponents["default"].div(
|
|
141
|
-
var imageBgColor =
|
|
138
|
+
var ImageContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n width: 35%;\n height: 100%;\n flex-shrink: 0;\n background: ", ";\n justify-content: center;\n align-items: center;\n display: inline-flex;\n"])), function (_ref14) {
|
|
139
|
+
var imageBgColor = _ref14.imageBgColor;
|
|
142
140
|
return imageBgColor;
|
|
143
141
|
});
|
|
144
142
|
|
|
145
|
-
var CardContent = _styledComponents["default"].div(
|
|
146
|
-
var contentPadding = _ref14.contentPadding;
|
|
147
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
|
|
148
|
-
}, function (_ref15) {
|
|
143
|
+
var CardContent = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n flex-grow: 1;\n padding: ", ";\n padding-top: ", ";\n padding-right: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n overflow: hidden;\n"])), function (_ref15) {
|
|
149
144
|
var contentPadding = _ref15.contentPadding;
|
|
150
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding)
|
|
145
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
|
|
151
146
|
}, function (_ref16) {
|
|
152
147
|
var contentPadding = _ref16.contentPadding;
|
|
153
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.
|
|
148
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
|
|
154
149
|
}, function (_ref17) {
|
|
155
150
|
var contentPadding = _ref17.contentPadding;
|
|
156
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.
|
|
151
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
|
|
157
152
|
}, function (_ref18) {
|
|
158
153
|
var contentPadding = _ref18.contentPadding;
|
|
154
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
155
|
+
}, function (_ref19) {
|
|
156
|
+
var contentPadding = _ref19.contentPadding;
|
|
159
157
|
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
|
|
160
158
|
});
|
|
161
159
|
|
package/card/types.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ declare type Props = {
|
|
|
47
47
|
*/
|
|
48
48
|
margin?: Space | Size;
|
|
49
49
|
/**
|
|
50
|
+
* @deprecated This prop will be removed shortly, consider using the Inset component for this purpose.
|
|
50
51
|
* Size of the padding to be applied to the content area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
51
52
|
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
|
|
52
53
|
*/
|
package/checkbox/Checkbox.js
CHANGED
|
@@ -19,8 +19,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
|
|
23
|
-
|
|
24
22
|
var _variables = require("../common/variables.js");
|
|
25
23
|
|
|
26
24
|
var _utils = require("../common/utils.js");
|
|
@@ -29,14 +27,25 @@ var _uuid = require("uuid");
|
|
|
29
27
|
|
|
30
28
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
31
29
|
|
|
30
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
31
|
+
|
|
32
32
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
33
33
|
|
|
34
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
34
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
35
35
|
|
|
36
36
|
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); }
|
|
37
37
|
|
|
38
38
|
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; }
|
|
39
39
|
|
|
40
|
+
var checkedIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
41
|
+
fill: "currentColor",
|
|
42
|
+
focusable: "false",
|
|
43
|
+
"aria-hidden": "true",
|
|
44
|
+
viewBox: "0 0 24 24"
|
|
45
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
46
|
+
d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
|
|
47
|
+
}));
|
|
48
|
+
|
|
40
49
|
var DxcCheckbox = function DxcCheckbox(_ref) {
|
|
41
50
|
var checked = _ref.checked,
|
|
42
51
|
_ref$defaultChecked = _ref.defaultChecked,
|
|
@@ -59,87 +68,77 @@ var DxcCheckbox = function DxcCheckbox(_ref) {
|
|
|
59
68
|
_ref$tabIndex = _ref.tabIndex,
|
|
60
69
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
61
70
|
|
|
62
|
-
var _useState = (0, _react.useState)("checkbox-".concat((0, _uuid.v4)())),
|
|
71
|
+
var _useState = (0, _react.useState)("label-checkbox-".concat((0, _uuid.v4)())),
|
|
63
72
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var labelId = "label-".concat(switchId);
|
|
73
|
+
labelId = _useState2[0];
|
|
67
74
|
|
|
68
75
|
var _useState3 = (0, _react.useState)(defaultChecked),
|
|
69
76
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
70
77
|
innerChecked = _useState4[0],
|
|
71
78
|
setInnerChecked = _useState4[1];
|
|
72
79
|
|
|
73
|
-
var
|
|
74
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
75
|
-
isLabelHovered = _useState6[0],
|
|
76
|
-
setIsLabelHovered = _useState6[1];
|
|
77
|
-
|
|
80
|
+
var checkboxRef = (0, _react.useRef)(null);
|
|
78
81
|
var colorsTheme = (0, _useTheme["default"])();
|
|
79
82
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
83
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
80
84
|
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
var isChecked = checkboxValue.target.checked === undefined ? !innerChecked : checkboxValue.target.checked;
|
|
84
|
-
setInnerChecked(isChecked);
|
|
85
|
-
|
|
86
|
-
if (typeof onChange === "function") {
|
|
87
|
-
onChange(isChecked);
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
if (typeof onChange === "function") {
|
|
91
|
-
onChange(!checked);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
85
|
+
var handleCheckboxChange = function handleCheckboxChange() {
|
|
86
|
+
var _checkboxRef$current;
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
document.activeElement !== (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) && (checkboxRef === null || checkboxRef === void 0 ? void 0 : (_checkboxRef$current = checkboxRef.current) === null || _checkboxRef$current === void 0 ? void 0 : _checkboxRef$current.focus());
|
|
89
|
+
var newChecked = checked !== null && checked !== void 0 ? checked : innerChecked;
|
|
90
|
+
checked !== null && checked !== void 0 ? checked : setInnerChecked(function (innerChecked) {
|
|
91
|
+
return !innerChecked;
|
|
92
|
+
});
|
|
93
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(!newChecked);
|
|
98
94
|
};
|
|
99
95
|
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
onMouseOver: handleLabelHover,
|
|
108
|
-
onMouseOut: handleLabelHover
|
|
109
|
-
}, labelPosition === "before" ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, label, " ", optional && /*#__PURE__*/_react["default"].createElement("span", null, "(Optional)")) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, optional && /*#__PURE__*/_react["default"].createElement("span", null, "(Optional)"), " ", label));
|
|
96
|
+
var handleKeyboard = function handleKeyboard(event) {
|
|
97
|
+
switch (event.key) {
|
|
98
|
+
case " ":
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
handleCheckboxChange();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
110
103
|
|
|
111
104
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
112
105
|
theme: colorsTheme.checkbox
|
|
113
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
114
|
-
id: name,
|
|
115
|
-
brightness: _variables.componentTokens,
|
|
116
|
-
label: label,
|
|
117
|
-
labelPosition: labelPosition,
|
|
106
|
+
}, /*#__PURE__*/_react["default"].createElement(MainContainer, {
|
|
118
107
|
disabled: disabled,
|
|
108
|
+
onClick: disabled ? undefined : handleCheckboxChange,
|
|
119
109
|
margin: margin,
|
|
120
110
|
size: size,
|
|
121
|
-
backgroundType: backgroundType,
|
|
122
|
-
isLabelHovered: isLabelHovered
|
|
123
|
-
}, label && labelPosition === "before" && labelComponent, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
124
111
|
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
role: "checkbox",
|
|
129
|
-
"aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked
|
|
130
|
-
},
|
|
131
|
-
onChange: handlerCheckboxChange,
|
|
132
|
-
value: value,
|
|
112
|
+
backgroundType: backgroundType
|
|
113
|
+
}, label && labelPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
114
|
+
id: labelId,
|
|
133
115
|
disabled: disabled,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
116
|
+
backgroundType: backgroundType
|
|
117
|
+
}, label, optional && " ".concat(translatedLabels.formFields.optionalLabel)), /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
118
|
+
type: "checkbox",
|
|
119
|
+
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
120
|
+
name: name,
|
|
121
|
+
"aria-hidden": "true",
|
|
122
|
+
value: value,
|
|
139
123
|
disabled: disabled,
|
|
124
|
+
readOnly: true
|
|
125
|
+
}), /*#__PURE__*/_react["default"].createElement(CheckboxContainer, null, /*#__PURE__*/_react["default"].createElement(Checkbox, {
|
|
126
|
+
onKeyDown: handleKeyboard,
|
|
127
|
+
role: "checkbox",
|
|
128
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
129
|
+
"aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
130
|
+
"aria-disabled": disabled,
|
|
131
|
+
"aria-required": !disabled && !optional,
|
|
132
|
+
"aria-labelledby": labelId,
|
|
133
|
+
backgroundType: backgroundType,
|
|
140
134
|
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
135
|
+
disabled: disabled,
|
|
136
|
+
ref: checkboxRef
|
|
137
|
+
}, (checked !== null && checked !== void 0 ? checked : innerChecked) && checkedIcon)), label && labelPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
138
|
+
id: labelId,
|
|
139
|
+
disabled: disabled,
|
|
141
140
|
backgroundType: backgroundType
|
|
142
|
-
}
|
|
141
|
+
}, optional && "".concat(translatedLabels.formFields.optionalLabel, " "), label)));
|
|
143
142
|
};
|
|
144
143
|
|
|
145
144
|
var sizes = {
|
|
@@ -147,7 +146,7 @@ var sizes = {
|
|
|
147
146
|
medium: "240px",
|
|
148
147
|
large: "480px",
|
|
149
148
|
fillParent: "100%",
|
|
150
|
-
fitContent: "
|
|
149
|
+
fitContent: "fit-content"
|
|
151
150
|
};
|
|
152
151
|
|
|
153
152
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
@@ -182,15 +181,21 @@ var getNotDisabledColor = function getNotDisabledColor(props, element) {
|
|
|
182
181
|
case "background":
|
|
183
182
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.backgroundColorCheckedOnDark : props.theme.backgroundColorChecked;
|
|
184
183
|
|
|
184
|
+
case "hoverBackground":
|
|
185
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
|
|
186
|
+
|
|
185
187
|
case "border":
|
|
186
188
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.borderColorOnDark : props.theme.borderColor;
|
|
187
189
|
|
|
190
|
+
case "hoverBorder":
|
|
191
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
|
|
192
|
+
|
|
188
193
|
case "label":
|
|
189
194
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.fontColorOnDark : props.theme.fontColor;
|
|
190
195
|
}
|
|
191
196
|
};
|
|
192
197
|
|
|
193
|
-
var LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n
|
|
198
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
194
199
|
return props.disabled ? getDisabledColor(props, "label") : getNotDisabledColor(props, "label");
|
|
195
200
|
}, function (props) {
|
|
196
201
|
return props.theme.fontFamily;
|
|
@@ -198,11 +203,27 @@ var LabelContainer = _styledComponents["default"].span(_templateObject || (_temp
|
|
|
198
203
|
return props.theme.fontSize;
|
|
199
204
|
}, function (props) {
|
|
200
205
|
return props.theme.fontWeight;
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
var ValueInput = _styledComponents["default"].input(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
|
|
209
|
+
|
|
210
|
+
var CheckboxContainer = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
|
|
211
|
+
|
|
212
|
+
var Checkbox = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 18px;\n width: 18px;\n border: solid 2px\n ", ";\n border-radius: 2px;\n background-color: ", ";\n color: ", ";\n\n &:focus {\n outline: 2px solid\n ", ";\n outline-offset: 2px;\n }\n svg {\n position: absolute;\n width: 22px;\n height: 22px;\n }\n ", "\n"])), function (props) {
|
|
213
|
+
return props.disabled ? getDisabledColor(props, "border") : getNotDisabledColor(props, "border");
|
|
201
214
|
}, function (props) {
|
|
202
|
-
return props.disabled ? "
|
|
215
|
+
return props.checked ? props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check") : "transparent";
|
|
216
|
+
}, function (props) {
|
|
217
|
+
return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "background");
|
|
218
|
+
}, function (props) {
|
|
219
|
+
return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
|
|
220
|
+
}, function (props) {
|
|
221
|
+
return props.disabled && "pointer-events: none;";
|
|
203
222
|
});
|
|
204
223
|
|
|
205
|
-
var
|
|
224
|
+
var MainContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n gap: ", ";\n\n &:hover ", " {\n border: 2px solid\n ", ";\n background-color: ", ";\n color: ", ";\n }\n"])), function (props) {
|
|
225
|
+
return calculateWidth(props.margin, props.size);
|
|
226
|
+
}, function (props) {
|
|
206
227
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
207
228
|
}, function (props) {
|
|
208
229
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -212,42 +233,16 @@ var CheckboxContainer = _styledComponents["default"].span(_templateObject2 || (_
|
|
|
212
233
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
213
234
|
}, function (props) {
|
|
214
235
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
215
|
-
}, function (props) {
|
|
216
|
-
return calculateWidth(props.margin, props.size);
|
|
217
236
|
}, function (props) {
|
|
218
237
|
return props.disabled ? "not-allowed" : "pointer";
|
|
219
238
|
}, function (props) {
|
|
220
|
-
return props.
|
|
221
|
-
}, function (props) {
|
|
222
|
-
return getDisabledColor(props, "border");
|
|
223
|
-
}, function (props) {
|
|
224
|
-
return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "background");
|
|
225
|
-
}, function (props) {
|
|
226
|
-
return props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
|
|
227
|
-
}, function (props) {
|
|
228
|
-
return props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
|
|
229
|
-
}, function (props) {
|
|
230
|
-
return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
|
|
231
|
-
}, function (props) {
|
|
232
|
-
return props.labelPosition === "before" && props.label ? props.theme.checkLabelSpacing : "0";
|
|
233
|
-
}, function (props) {
|
|
234
|
-
return props.labelPosition === "after" && props.label ? props.theme.checkLabelSpacing : "0";
|
|
235
|
-
}, function (props) {
|
|
236
|
-
return props.labelPosition === "before" ? "unset" : "1px";
|
|
237
|
-
}, function (props) {
|
|
238
|
-
return props.labelPosition === "before" ? "1px" : "unset";
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
var CheckboxBlackBack = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n width: 16px;\n height: 16px;\n position: absolute;\n left: ", ";\n right: ", ";\n z-index: 0;\n margin-left: ", ";\n margin-right: ", ";\n"])), function (props) {
|
|
242
|
-
return !props.checked ? "transparent" : props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check");
|
|
243
|
-
}, function (props) {
|
|
244
|
-
return props.labelPosition === "before" ? "unset" : "5px";
|
|
245
|
-
}, function (props) {
|
|
246
|
-
return props.labelPosition === "before" ? "5px" : "unset";
|
|
239
|
+
return props.theme.checkLabelSpacing;
|
|
240
|
+
}, Checkbox, function (props) {
|
|
241
|
+
return props.disabled ? getDisabledColor(props, "border") : getNotDisabledColor(props, "hoverBorder");
|
|
247
242
|
}, function (props) {
|
|
248
|
-
return props.
|
|
243
|
+
return props.checked ? props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check") : "transparent";
|
|
249
244
|
}, function (props) {
|
|
250
|
-
return props.
|
|
245
|
+
return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "hoverBackground");
|
|
251
246
|
});
|
|
252
247
|
|
|
253
248
|
var _default = DxcCheckbox;
|