@dxc-technology/halstack-react 0.0.0-49006fa → 0.0.0-49081f0
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 +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +121 -123
- package/accordion/Accordion.stories.tsx +13 -14
- package/accordion/Accordion.test.js +25 -11
- package/accordion/types.d.ts +9 -4
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +15 -36
- package/accordion-group/AccordionGroup.stories.tsx +28 -2
- package/accordion-group/AccordionGroup.test.js +30 -37
- package/accordion-group/types.d.ts +14 -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 +53 -68
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +24 -27
- package/card/types.d.ts +1 -0
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +99 -97
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +93 -16
- package/checkbox/types.d.ts +5 -5
- package/chip/types.d.ts +1 -1
- package/common/variables.js +236 -100
- package/date-input/DateInput.js +41 -23
- package/date-input/DateInput.test.js +9 -22
- package/date-input/types.d.ts +12 -9
- package/dialog/Dialog.js +46 -50
- 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 -251
- 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 +174 -193
- package/file-input/FileInput.stories.tsx +38 -6
- package/file-input/FileInput.test.js +41 -0
- package/file-input/FileItem.d.ts +4 -4
- package/file-input/FileItem.js +29 -39
- 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/{radio → flex}/types.js +0 -0
- package/footer/Footer.js +15 -88
- package/footer/Footer.stories.tsx +8 -1
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +2 -1
- package/header/Header.js +95 -114
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- 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 +25 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -131
- 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 -74
- 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 -10
- package/main.js +46 -56
- package/number-input/NumberInput.test.js +40 -5
- package/number-input/types.d.ts +13 -10
- package/package.json +14 -12
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +43 -1
- 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 +7 -4
- package/password-input/PasswordInput.test.js +16 -18
- package/password-input/types.d.ts +14 -11
- 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.d.ts +4 -0
- package/quick-nav/QuickNav.js +117 -0
- package/quick-nav/QuickNav.stories.tsx +342 -0
- package/quick-nav/types.d.ts +21 -0
- package/{row → quick-nav}/types.js +0 -0
- 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.js +1 -3
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +198 -0
- package/select/Option.js +1 -1
- package/select/Select.js +104 -199
- package/select/Select.stories.tsx +145 -100
- package/select/Select.test.js +503 -286
- package/select/types.d.ts +31 -12
- 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.d.ts +1 -1
- package/slider/Slider.js +118 -93
- package/slider/Slider.stories.tsx +15 -9
- package/slider/Slider.test.js +142 -21
- package/slider/types.d.ts +6 -2
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +133 -64
- package/switch/Switch.stories.tsx +16 -38
- package/switch/Switch.test.js +144 -17
- package/switch/types.d.ts +5 -6
- package/table/Table.js +1 -1
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +135 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +362 -108
- package/tabs/Tabs.stories.tsx +74 -8
- package/tabs/Tabs.test.js +241 -13
- package/tabs/types.d.ts +19 -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/{stack → tabs-nav}/types.js +0 -0
- package/tag/Tag.js +6 -9
- 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 +213 -334
- package/text-input/TextInput.stories.tsx +189 -182
- package/text-input/TextInput.test.js +244 -198
- package/text-input/types.d.ts +46 -12
- package/textarea/Textarea.js +10 -19
- package/textarea/types.d.ts +10 -7
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +35 -4
- package/toggle-group/types.d.ts +9 -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/typography/types.js +5 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +43 -44
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/types.d.ts +5 -4
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- 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/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- 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/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
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
|
|
|
@@ -56,22 +56,13 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
56
56
|
isHovered = _useState2[0],
|
|
57
57
|
changeIsHovered = _useState2[1];
|
|
58
58
|
|
|
59
|
-
var
|
|
60
|
-
shadowDepth: !outlined ? 0 : isHovered && (onClick || linkHref) ? 2 : 1
|
|
61
|
-
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
62
|
-
theme: colorsTheme.card
|
|
63
|
-
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
64
|
-
hasAction: onClick || linkHref,
|
|
65
|
-
imagePosition: imagePosition
|
|
66
|
-
}, imageSrc && /*#__PURE__*/_react["default"].createElement(ImageContainer, {
|
|
59
|
+
var imageComponent = /*#__PURE__*/_react["default"].createElement(ImageContainer, {
|
|
67
60
|
imageBgColor: imageBgColor
|
|
68
61
|
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
69
62
|
imagePadding: imagePadding,
|
|
70
63
|
cover: imageCover,
|
|
71
64
|
src: imageSrc
|
|
72
|
-
}))
|
|
73
|
-
contentPadding: contentPadding
|
|
74
|
-
}, children))));
|
|
65
|
+
}));
|
|
75
66
|
|
|
76
67
|
return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
|
|
77
68
|
margin: margin,
|
|
@@ -82,15 +73,23 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
82
73
|
return changeIsHovered(false);
|
|
83
74
|
},
|
|
84
75
|
onClick: onClick,
|
|
85
|
-
hasAction: onClick,
|
|
86
|
-
tabIndex:
|
|
87
|
-
|
|
88
|
-
tabIndex: tabIndex,
|
|
76
|
+
hasAction: onClick || linkHref,
|
|
77
|
+
tabIndex: onClick || linkHref ? tabIndex : -1,
|
|
78
|
+
as: linkHref && "a",
|
|
89
79
|
href: linkHref
|
|
90
|
-
},
|
|
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))));
|
|
91
90
|
};
|
|
92
91
|
|
|
93
|
-
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) {
|
|
94
93
|
var hasAction = _ref2.hasAction;
|
|
95
94
|
return hasAction && "pointer" || "unset";
|
|
96
95
|
}, function (_ref3) {
|
|
@@ -111,12 +110,12 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
111
110
|
}, function (_ref8) {
|
|
112
111
|
var margin = _ref8.margin;
|
|
113
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 }";
|
|
114
116
|
});
|
|
115
117
|
|
|
116
|
-
var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n
|
|
117
|
-
var imagePosition = _ref9.imagePosition;
|
|
118
|
-
return imagePosition === "before" && "row" || "row-reverse";
|
|
119
|
-
}, function (props) {
|
|
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) {
|
|
120
119
|
return props.theme.height;
|
|
121
120
|
}, function (props) {
|
|
122
121
|
return props.theme.width;
|
|
@@ -125,9 +124,7 @@ var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templ
|
|
|
125
124
|
return hasAction ? "" : "unset";
|
|
126
125
|
});
|
|
127
126
|
|
|
128
|
-
var
|
|
129
|
-
|
|
130
|
-
var TagImage = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
|
|
127
|
+
var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
|
|
131
128
|
var imagePadding = _ref11.imagePadding;
|
|
132
129
|
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
133
130
|
}, function (_ref12) {
|
|
@@ -138,12 +135,12 @@ var TagImage = _styledComponents["default"].img(_templateObject4 || (_templateOb
|
|
|
138
135
|
return cover ? "cover" : "contain";
|
|
139
136
|
});
|
|
140
137
|
|
|
141
|
-
var ImageContainer = _styledComponents["default"].div(
|
|
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) {
|
|
142
139
|
var imageBgColor = _ref14.imageBgColor;
|
|
143
140
|
return imageBgColor;
|
|
144
141
|
});
|
|
145
142
|
|
|
146
|
-
var CardContent = _styledComponents["default"].div(
|
|
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) {
|
|
147
144
|
var contentPadding = _ref15.contentPadding;
|
|
148
145
|
return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
|
|
149
146
|
}, function (_ref16) {
|
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.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import CheckboxPropsType from "./types";
|
|
3
|
-
declare const DxcCheckbox: ({ checked, defaultChecked, value, label, labelPosition, name, disabled,
|
|
3
|
+
declare const DxcCheckbox: ({ checked, defaultChecked, value, label, labelPosition, name, disabled, optional, onChange, margin, size, tabIndex, }: CheckboxPropsType) => JSX.Element;
|
|
4
4
|
export default DxcCheckbox;
|
package/checkbox/Checkbox.js
CHANGED
|
@@ -19,24 +19,33 @@ 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
|
-
var _RequiredComponent = _interopRequireDefault(require("../common/RequiredComponent"));
|
|
25
|
-
|
|
26
22
|
var _variables = require("../common/variables.js");
|
|
27
23
|
|
|
28
24
|
var _utils = require("../common/utils.js");
|
|
29
25
|
|
|
26
|
+
var _uuid = require("uuid");
|
|
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,
|
|
@@ -50,87 +59,86 @@ var DxcCheckbox = function DxcCheckbox(_ref) {
|
|
|
50
59
|
name = _ref$name === void 0 ? "" : _ref$name,
|
|
51
60
|
_ref$disabled = _ref.disabled,
|
|
52
61
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
62
|
+
_ref$optional = _ref.optional,
|
|
63
|
+
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
53
64
|
onChange = _ref.onChange,
|
|
54
|
-
_ref$required = _ref.required,
|
|
55
|
-
required = _ref$required === void 0 ? false : _ref$required,
|
|
56
65
|
margin = _ref.margin,
|
|
57
66
|
_ref$size = _ref.size,
|
|
58
67
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
59
68
|
_ref$tabIndex = _ref.tabIndex,
|
|
60
69
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
61
70
|
|
|
62
|
-
var _useState = (0, _react.useState)(
|
|
63
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState,
|
|
64
|
-
|
|
65
|
-
setInnerChecked = _useState2[1];
|
|
71
|
+
var _useState = (0, _react.useState)("label-checkbox-".concat((0, _uuid.v4)())),
|
|
72
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
73
|
+
labelId = _useState2[0];
|
|
66
74
|
|
|
67
|
-
var _useState3 = (0, _react.useState)(
|
|
75
|
+
var _useState3 = (0, _react.useState)(defaultChecked),
|
|
68
76
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
innerChecked = _useState4[0],
|
|
78
|
+
setInnerChecked = _useState4[1];
|
|
71
79
|
|
|
80
|
+
var checkboxRef = (0, _react.useRef)(null);
|
|
72
81
|
var colorsTheme = (0, _useTheme["default"])();
|
|
73
82
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
83
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
74
84
|
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (typeof onChange === "function") {
|
|
85
|
-
onChange(!checked);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
85
|
+
var handleCheckboxChange = function handleCheckboxChange() {
|
|
86
|
+
var _checkboxRef$current;
|
|
87
|
+
|
|
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);
|
|
88
94
|
};
|
|
89
95
|
|
|
90
|
-
var
|
|
91
|
-
|
|
96
|
+
var handleKeyboard = function handleKeyboard(event) {
|
|
97
|
+
switch (event.key) {
|
|
98
|
+
case " ":
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
handleCheckboxChange();
|
|
101
|
+
}
|
|
92
102
|
};
|
|
93
103
|
|
|
94
104
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
95
105
|
theme: colorsTheme.checkbox
|
|
96
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
97
|
-
id: name,
|
|
98
|
-
brightness: _variables.componentTokens,
|
|
99
|
-
label: label,
|
|
100
|
-
labelPosition: labelPosition,
|
|
106
|
+
}, /*#__PURE__*/_react["default"].createElement(MainContainer, {
|
|
101
107
|
disabled: disabled,
|
|
108
|
+
onClick: disabled ? undefined : handleCheckboxChange,
|
|
102
109
|
margin: margin,
|
|
103
110
|
size: size,
|
|
104
|
-
backgroundType: backgroundType,
|
|
105
|
-
isLabelHovered: isLabelHovered
|
|
106
|
-
}, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
107
111
|
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
role: "checkbox",
|
|
112
|
-
"aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked
|
|
113
|
-
},
|
|
114
|
-
onChange: handlerCheckboxChange,
|
|
115
|
-
value: value,
|
|
116
|
-
disabled: disabled,
|
|
117
|
-
disableRipple: true,
|
|
118
|
-
className: "test",
|
|
119
|
-
tabIndex: tabIndex
|
|
120
|
-
}), /*#__PURE__*/_react["default"].createElement(CheckboxBlackBack, {
|
|
121
|
-
labelPosition: labelPosition,
|
|
112
|
+
backgroundType: backgroundType
|
|
113
|
+
}, label && labelPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
114
|
+
id: labelId,
|
|
122
115
|
disabled: disabled,
|
|
123
|
-
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
124
116
|
backgroundType: backgroundType
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
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,
|
|
128
123
|
disabled: disabled,
|
|
129
|
-
|
|
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,
|
|
130
133
|
backgroundType: backgroundType,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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,
|
|
140
|
+
backgroundType: backgroundType
|
|
141
|
+
}, optional && "".concat(translatedLabels.formFields.optionalLabel, " "), label)));
|
|
134
142
|
};
|
|
135
143
|
|
|
136
144
|
var sizes = {
|
|
@@ -138,7 +146,7 @@ var sizes = {
|
|
|
138
146
|
medium: "240px",
|
|
139
147
|
large: "480px",
|
|
140
148
|
fillParent: "100%",
|
|
141
|
-
fitContent: "
|
|
149
|
+
fitContent: "fit-content"
|
|
142
150
|
};
|
|
143
151
|
|
|
144
152
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
@@ -173,18 +181,22 @@ var getNotDisabledColor = function getNotDisabledColor(props, element) {
|
|
|
173
181
|
case "background":
|
|
174
182
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.backgroundColorCheckedOnDark : props.theme.backgroundColorChecked;
|
|
175
183
|
|
|
184
|
+
case "hoverBackground":
|
|
185
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
|
|
186
|
+
|
|
176
187
|
case "border":
|
|
177
188
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.borderColorOnDark : props.theme.borderColor;
|
|
178
189
|
|
|
190
|
+
case "hoverBorder":
|
|
191
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
|
|
192
|
+
|
|
179
193
|
case "label":
|
|
180
194
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.fontColorOnDark : props.theme.fontColor;
|
|
181
195
|
}
|
|
182
196
|
};
|
|
183
197
|
|
|
184
|
-
var LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\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) {
|
|
185
199
|
return props.disabled ? getDisabledColor(props, "label") : getNotDisabledColor(props, "label");
|
|
186
|
-
}, function (props) {
|
|
187
|
-
return props.disabled ? "not-allowed" : "pointer";
|
|
188
200
|
}, function (props) {
|
|
189
201
|
return props.theme.fontFamily;
|
|
190
202
|
}, function (props) {
|
|
@@ -193,54 +205,44 @@ var LabelContainer = _styledComponents["default"].span(_templateObject || (_temp
|
|
|
193
205
|
return props.theme.fontWeight;
|
|
194
206
|
});
|
|
195
207
|
|
|
196
|
-
var
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}, function (props) {
|
|
201
|
-
return props.
|
|
202
|
-
}, function (props) {
|
|
203
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
204
|
-
}, function (props) {
|
|
205
|
-
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
206
|
-
}, function (props) {
|
|
207
|
-
return calculateWidth(props.margin, props.size);
|
|
208
|
-
}, function (props) {
|
|
209
|
-
return props.disabled ? "not-allowed" : "pointer";
|
|
210
|
-
}, function (props) {
|
|
211
|
-
return props.labelPosition === "before" ? "row-reverse" : "row";
|
|
212
|
-
}, function (props) {
|
|
213
|
-
return props.isLabelHovered ? props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor : getNotDisabledColor(props, "border");
|
|
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");
|
|
214
214
|
}, function (props) {
|
|
215
|
-
return getDisabledColor(props, "
|
|
215
|
+
return props.checked ? props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check") : "transparent";
|
|
216
216
|
}, function (props) {
|
|
217
217
|
return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "background");
|
|
218
218
|
}, function (props) {
|
|
219
|
-
return props.backgroundType === "dark" ? props.theme.
|
|
219
|
+
return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
|
|
220
220
|
}, function (props) {
|
|
221
|
-
return props.
|
|
221
|
+
return props.disabled && "pointer-events: none;";
|
|
222
|
+
});
|
|
223
|
+
|
|
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);
|
|
222
226
|
}, function (props) {
|
|
223
|
-
return props.
|
|
227
|
+
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
224
228
|
}, function (props) {
|
|
225
|
-
return props.
|
|
229
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
226
230
|
}, function (props) {
|
|
227
|
-
return props.
|
|
231
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
|
|
228
232
|
}, function (props) {
|
|
229
|
-
return props.
|
|
233
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
230
234
|
}, function (props) {
|
|
231
|
-
return props.
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
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) {
|
|
235
|
-
return !props.checked ? "transparent" : props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check");
|
|
235
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
236
236
|
}, function (props) {
|
|
237
|
-
return props.
|
|
237
|
+
return props.disabled ? "not-allowed" : "pointer";
|
|
238
238
|
}, function (props) {
|
|
239
|
-
return props.
|
|
239
|
+
return props.theme.checkLabelSpacing;
|
|
240
|
+
}, Checkbox, function (props) {
|
|
241
|
+
return props.disabled ? getDisabledColor(props, "border") : getNotDisabledColor(props, "hoverBorder");
|
|
240
242
|
}, function (props) {
|
|
241
|
-
return props.
|
|
243
|
+
return props.checked ? props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check") : "transparent";
|
|
242
244
|
}, function (props) {
|
|
243
|
-
return props.
|
|
245
|
+
return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "hoverBackground");
|
|
244
246
|
});
|
|
245
247
|
|
|
246
248
|
var _default = DxcCheckbox;
|