@dxc-technology/halstack-react 0.0.0-b41d935 → 0.0.0-b4fde6b
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/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +1329 -5
- package/HalstackContext.js +117 -77
- package/accordion/Accordion.js +13 -24
- package/accordion/Accordion.stories.tsx +102 -13
- package/accordion/Accordion.test.js +1 -1
- package/accordion/types.d.ts +3 -3
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +23 -44
- package/accordion-group/AccordionGroup.test.js +1 -1
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +2 -2
- package/alert/Alert.js +4 -8
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/bleed/Bleed.stories.tsx +1 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +7 -26
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +0 -12
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.js +13 -16
- package/button/Button.stories.tsx +151 -9
- package/button/Button.test.js +1 -1
- package/button/types.d.ts +3 -3
- package/card/Card.js +12 -13
- package/card/Card.stories.tsx +12 -13
- package/card/Card.test.js +1 -1
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +7 -6
- package/checkbox/Checkbox.stories.tsx +52 -0
- package/checkbox/Checkbox.test.js +1 -1
- package/checkbox/types.d.ts +6 -2
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1482 -0
- package/common/variables.js +981 -1129
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +134 -237
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +494 -138
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +51 -0
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +55 -86
- package/dialog/Dialog.stories.tsx +145 -217
- package/dialog/Dialog.test.js +302 -3
- package/dialog/types.d.ts +0 -13
- package/dropdown/Dropdown.js +37 -37
- package/dropdown/Dropdown.stories.tsx +210 -84
- package/dropdown/Dropdown.test.js +20 -24
- package/dropdown/DropdownMenu.js +12 -18
- package/dropdown/DropdownMenuItem.js +4 -17
- package/dropdown/types.d.ts +3 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +14 -15
- package/file-input/FileInput.stories.tsx +85 -2
- package/file-input/FileInput.test.js +1 -42
- package/file-input/FileItem.js +1 -0
- package/file-input/types.d.ts +4 -0
- package/flex/Flex.js +4 -2
- package/flex/Flex.stories.tsx +35 -26
- package/flex/types.d.ts +70 -5
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +8 -23
- package/footer/Footer.stories.tsx +18 -15
- package/footer/Footer.test.js +14 -26
- package/footer/types.d.ts +0 -6
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +3 -2
- package/header/Header.js +21 -23
- package/header/Header.stories.tsx +149 -6
- package/header/Header.test.js +2 -2
- package/header/types.d.ts +2 -2
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- package/inset/Inset.stories.tsx +2 -1
- package/layout/ApplicationLayout.d.ts +4 -4
- package/layout/ApplicationLayout.js +1 -1
- package/layout/types.d.ts +2 -3
- package/link/Link.js +4 -4
- package/link/Link.stories.tsx +60 -0
- package/link/Link.test.js +2 -4
- package/link/types.d.ts +2 -2
- package/main.d.ts +3 -2
- package/main.js +9 -1
- package/{tabs-nav → nav-tabs}/NavTabs.d.ts +2 -2
- package/{tabs-nav → nav-tabs}/NavTabs.js +8 -11
- package/{tabs-nav → nav-tabs}/NavTabs.stories.tsx +110 -6
- package/{tabs-nav → nav-tabs}/NavTabs.test.js +1 -1
- package/{tabs-nav → nav-tabs}/Tab.js +48 -32
- package/{tabs-nav → nav-tabs}/types.d.ts +8 -9
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.test.js +6 -7
- package/package.json +8 -13
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +7 -15
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +57 -47
- package/paragraph/Paragraph.d.ts +3 -4
- package/paragraph/Paragraph.js +5 -5
- package/password-input/PasswordInput.test.js +1 -1
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +5 -5
- package/progress-bar/ProgressBar.stories.jsx +35 -2
- package/progress-bar/ProgressBar.test.js +1 -1
- package/progress-bar/types.d.ts +4 -3
- package/quick-nav/QuickNav.stories.tsx +14 -0
- package/radio-group/Radio.js +10 -10
- package/radio-group/RadioGroup.js +8 -10
- package/radio-group/RadioGroup.stories.tsx +131 -18
- package/radio-group/RadioGroup.test.js +1 -1
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -106
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +41 -64
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +5 -34
- package/select/Option.js +11 -24
- package/select/Select.js +56 -35
- package/select/Select.stories.tsx +494 -150
- package/select/Select.test.js +76 -81
- package/select/types.d.ts +2 -2
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +2 -2
- package/sidenav/Sidenav.js +66 -96
- package/sidenav/Sidenav.stories.tsx +165 -63
- package/sidenav/types.d.ts +21 -18
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +11 -11
- package/slider/Slider.stories.tsx +57 -0
- package/slider/Slider.test.js +1 -1
- package/slider/types.d.ts +6 -2
- package/spinner/Spinner.js +17 -23
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +3 -3
- package/switch/Switch.js +7 -6
- package/switch/Switch.stories.tsx +33 -0
- package/switch/Switch.test.js +1 -1
- package/switch/types.d.ts +8 -3
- package/table/Table.js +2 -2
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.js +12 -15
- package/tabs/Tabs.js +11 -17
- package/tabs/Tabs.stories.tsx +45 -5
- package/tabs/Tabs.test.js +4 -5
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.js +7 -9
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/text-input/Suggestion.js +34 -7
- package/text-input/TextInput.js +11 -15
- package/text-input/TextInput.stories.tsx +93 -5
- package/text-input/TextInput.test.js +587 -635
- package/textarea/Textarea.js +3 -4
- package/textarea/Textarea.stories.jsx +60 -1
- package/textarea/Textarea.test.js +2 -4
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +7 -4
- package/toggle-group/ToggleGroup.stories.tsx +42 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/typography/Typography.d.ts +2 -2
- package/typography/Typography.js +14 -113
- package/typography/Typography.stories.tsx +1 -1
- package/useTheme.d.ts +1234 -1
- package/useTheme.js +1 -1
- package/useTranslatedLabels.d.ts +84 -1
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +2 -2
- package/wizard/Wizard.stories.tsx +20 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +5 -6
- package/common/RequiredComponent.js +0 -32
- /package/{tabs-nav → grid}/types.js +0 -0
- /package/{tabs-nav → nav-tabs}/Tab.d.ts +0 -0
package/card/Card.js
CHANGED
|
@@ -19,7 +19,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _variables = require("../common/variables
|
|
22
|
+
var _variables = require("../common/variables");
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
@@ -60,7 +60,7 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
60
60
|
imageBgColor: imageBgColor
|
|
61
61
|
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
62
62
|
imagePadding: imagePadding,
|
|
63
|
-
|
|
63
|
+
imageCover: imageCover,
|
|
64
64
|
src: imageSrc
|
|
65
65
|
}));
|
|
66
66
|
|
|
@@ -82,14 +82,13 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
82
82
|
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
83
83
|
theme: colorsTheme.card
|
|
84
84
|
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
85
|
-
hasAction: onClick || linkHref
|
|
86
|
-
imagePosition: imagePosition
|
|
85
|
+
hasAction: onClick || linkHref
|
|
87
86
|
}, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
|
|
88
87
|
contentPadding: contentPadding
|
|
89
88
|
}, children), imageSrc && imagePosition === "after" && imageComponent))));
|
|
90
89
|
};
|
|
91
90
|
|
|
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
|
|
91
|
+
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"])), function (_ref2) {
|
|
93
92
|
var hasAction = _ref2.hasAction;
|
|
94
93
|
return hasAction && "pointer" || "unset";
|
|
95
94
|
}, function (_ref3) {
|
|
@@ -100,16 +99,16 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
100
99
|
return margin && (0, _typeof2["default"])(margin) !== "object" ? _variables.spaces[margin] : "0px";
|
|
101
100
|
}, function (_ref5) {
|
|
102
101
|
var margin = _ref5.margin;
|
|
103
|
-
return margin && margin.top ? _variables.spaces[margin.top] : "";
|
|
102
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.top ? _variables.spaces[margin.top] : "";
|
|
104
103
|
}, function (_ref6) {
|
|
105
104
|
var margin = _ref6.margin;
|
|
106
|
-
return margin && margin.right ? _variables.spaces[margin.right] : "";
|
|
105
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.right ? _variables.spaces[margin.right] : "";
|
|
107
106
|
}, function (_ref7) {
|
|
108
107
|
var margin = _ref7.margin;
|
|
109
|
-
return margin && margin.bottom ? _variables.spaces[margin.bottom] : "";
|
|
108
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.bottom ? _variables.spaces[margin.bottom] : "";
|
|
110
109
|
}, function (_ref8) {
|
|
111
110
|
var margin = _ref8.margin;
|
|
112
|
-
return margin && margin.left ? _variables.spaces[margin.left] : "";
|
|
111
|
+
return margin && (0, _typeof2["default"])(margin) === "object" && margin.left ? _variables.spaces[margin.left] : "";
|
|
113
112
|
}, function (_ref9) {
|
|
114
113
|
var hasAction = _ref9.hasAction;
|
|
115
114
|
return hasAction && ":focus {\n outline: #0095ff auto 1px;\n }";
|
|
@@ -126,13 +125,13 @@ var CardContainer = _styledComponents["default"].div(_templateObject2 || (_templ
|
|
|
126
125
|
|
|
127
126
|
var TagImage = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (_ref11) {
|
|
128
127
|
var imagePadding = _ref11.imagePadding;
|
|
129
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
128
|
+
return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
130
129
|
}, function (_ref12) {
|
|
131
130
|
var imagePadding = _ref12.imagePadding;
|
|
132
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
131
|
+
return !imagePadding ? "100%" : (0, _typeof2["default"])(imagePadding) !== "object" && "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
133
132
|
}, function (_ref13) {
|
|
134
|
-
var
|
|
135
|
-
return
|
|
133
|
+
var imageCover = _ref13.imageCover;
|
|
134
|
+
return imageCover ? "cover" : "contain";
|
|
136
135
|
});
|
|
137
136
|
|
|
138
137
|
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) {
|
package/card/Card.stories.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
import Title from "../../.storybook/components/Title";
|
|
3
3
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
4
|
import DxcCard from "./Card";
|
|
5
|
-
import imagePath from "./ice-cream.jpg";
|
|
6
5
|
import { userEvent, within } from "@storybook/testing-library";
|
|
7
6
|
|
|
8
7
|
export default {
|
|
@@ -38,72 +37,72 @@ const Card = () => (
|
|
|
38
37
|
</ExampleContainer>
|
|
39
38
|
<Title title="Default with image" theme="light" level={4} />
|
|
40
39
|
<ExampleContainer>
|
|
41
|
-
<DxcCard imageSrc=
|
|
40
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300">Default</DxcCard>
|
|
42
41
|
</ExampleContainer>
|
|
43
42
|
<Title title="Default image with background color" theme="light" level={4} />
|
|
44
43
|
<ExampleContainer>
|
|
45
|
-
<DxcCard imageSrc=
|
|
44
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageBgColor="yellow">
|
|
46
45
|
Background color
|
|
47
46
|
</DxcCard>
|
|
48
47
|
</ExampleContainer>
|
|
49
48
|
<Title title="Default image with position after" theme="light" level={4} />
|
|
50
49
|
<ExampleContainer>
|
|
51
|
-
<DxcCard imageSrc=
|
|
50
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePosition="after">
|
|
52
51
|
Position after
|
|
53
52
|
</DxcCard>
|
|
54
53
|
</ExampleContainer>
|
|
55
54
|
<Title title="Image cover" theme="light" level={4} />
|
|
56
55
|
<ExampleContainer>
|
|
57
|
-
<DxcCard imageSrc=
|
|
56
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageCover>
|
|
58
57
|
Image cover
|
|
59
58
|
</DxcCard>
|
|
60
59
|
</ExampleContainer>
|
|
61
60
|
<Title title="Image cover with position after" theme="light" level={4} />
|
|
62
61
|
<ExampleContainer>
|
|
63
|
-
<DxcCard imageSrc=
|
|
62
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imageCover imagePosition="after">
|
|
64
63
|
Image cover with position after
|
|
65
64
|
</DxcCard>
|
|
66
65
|
</ExampleContainer>
|
|
67
66
|
<Title title="Image padding" theme="light" level={2} />
|
|
68
67
|
<ExampleContainer>
|
|
69
68
|
<Title title="Xxsmall" theme="light" level={4} />
|
|
70
|
-
<DxcCard imageSrc=
|
|
69
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xxsmall" imageCover>
|
|
71
70
|
Xxsmall
|
|
72
71
|
</DxcCard>
|
|
73
72
|
</ExampleContainer>
|
|
74
73
|
<ExampleContainer>
|
|
75
74
|
<Title title="Xsmall" theme="light" level={4} />
|
|
76
|
-
<DxcCard imageSrc=
|
|
75
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xsmall" imageCover>
|
|
77
76
|
Xsmall
|
|
78
77
|
</DxcCard>
|
|
79
78
|
</ExampleContainer>
|
|
80
79
|
<ExampleContainer>
|
|
81
80
|
<Title title="Small" theme="light" level={4} />
|
|
82
|
-
<DxcCard imageSrc=
|
|
81
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="small" imageCover>
|
|
83
82
|
Small
|
|
84
83
|
</DxcCard>
|
|
85
84
|
</ExampleContainer>
|
|
86
85
|
<ExampleContainer>
|
|
87
86
|
<Title title="Medium" theme="light" level={4} />
|
|
88
|
-
<DxcCard imageSrc=
|
|
87
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="medium" imageCover>
|
|
89
88
|
Medium
|
|
90
89
|
</DxcCard>
|
|
91
90
|
</ExampleContainer>
|
|
92
91
|
<ExampleContainer>
|
|
93
92
|
<Title title="Large" theme="light" level={4} />
|
|
94
|
-
<DxcCard imageSrc=
|
|
93
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="large" imageCover>
|
|
95
94
|
Large
|
|
96
95
|
</DxcCard>
|
|
97
96
|
</ExampleContainer>
|
|
98
97
|
<ExampleContainer>
|
|
99
98
|
<Title title="Xlarge" theme="light" level={4} />
|
|
100
|
-
<DxcCard imageSrc=
|
|
99
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xlarge" imageCover>
|
|
101
100
|
Xlarge
|
|
102
101
|
</DxcCard>
|
|
103
102
|
</ExampleContainer>
|
|
104
103
|
<ExampleContainer>
|
|
105
104
|
<Title title="Xxlarge" theme="light" level={4} />
|
|
106
|
-
<DxcCard imageSrc=
|
|
105
|
+
<DxcCard imageSrc="https://picsum.photos/id/1022/200/300" imagePadding="xxlarge" imageCover>
|
|
107
106
|
Xxlarge
|
|
108
107
|
</DxcCard>
|
|
109
108
|
</ExampleContainer>
|
package/card/Card.test.js
CHANGED
|
@@ -6,7 +6,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
6
6
|
|
|
7
7
|
var _react2 = require("@testing-library/react");
|
|
8
8
|
|
|
9
|
-
var _Card = _interopRequireDefault(require("./Card"));
|
|
9
|
+
var _Card = _interopRequireDefault(require("./Card.tsx"));
|
|
10
10
|
|
|
11
11
|
describe("Card component tests", function () {
|
|
12
12
|
test("Card renders with correct content", function () {
|
package/checkbox/Checkbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import CheckboxPropsType from "./types";
|
|
3
|
-
declare const DxcCheckbox:
|
|
3
|
+
declare const DxcCheckbox: React.ForwardRefExoticComponent<CheckboxPropsType & React.RefAttributes<HTMLDivElement>>;
|
|
4
4
|
export default DxcCheckbox;
|
package/checkbox/Checkbox.js
CHANGED
|
@@ -19,9 +19,9 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _variables = require("../common/variables
|
|
22
|
+
var _variables = require("../common/variables");
|
|
23
23
|
|
|
24
|
-
var _utils = require("../common/utils
|
|
24
|
+
var _utils = require("../common/utils");
|
|
25
25
|
|
|
26
26
|
var _uuid = require("uuid");
|
|
27
27
|
|
|
@@ -46,7 +46,7 @@ var checkedIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
|
46
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
47
|
}));
|
|
48
48
|
|
|
49
|
-
var DxcCheckbox = function
|
|
49
|
+
var DxcCheckbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
50
50
|
var checked = _ref.checked,
|
|
51
51
|
_ref$defaultChecked = _ref.defaultChecked,
|
|
52
52
|
defaultChecked = _ref$defaultChecked === void 0 ? false : _ref$defaultChecked,
|
|
@@ -109,7 +109,8 @@ var DxcCheckbox = function DxcCheckbox(_ref) {
|
|
|
109
109
|
margin: margin,
|
|
110
110
|
size: size,
|
|
111
111
|
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
112
|
-
backgroundType: backgroundType
|
|
112
|
+
backgroundType: backgroundType,
|
|
113
|
+
ref: ref
|
|
113
114
|
}, label && labelPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
114
115
|
id: labelId,
|
|
115
116
|
disabled: disabled,
|
|
@@ -139,7 +140,7 @@ var DxcCheckbox = function DxcCheckbox(_ref) {
|
|
|
139
140
|
disabled: disabled,
|
|
140
141
|
backgroundType: backgroundType
|
|
141
142
|
}, optional && "".concat(translatedLabels.formFields.optionalLabel, " "), label)));
|
|
142
|
-
};
|
|
143
|
+
});
|
|
143
144
|
|
|
144
145
|
var sizes = {
|
|
145
146
|
small: "120px",
|
|
@@ -221,7 +222,7 @@ var Checkbox = _styledComponents["default"].span(_templateObject4 || (_templateO
|
|
|
221
222
|
return props.disabled && "pointer-events: none;";
|
|
222
223
|
});
|
|
223
224
|
|
|
224
|
-
var MainContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n gap: ", ";\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n
|
|
225
|
+
var MainContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n gap: ", ";\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n\n &:hover ", " {\n border: 2px solid\n ", ";\n background-color: ", ";\n color: ", ";\n }\n"])), function (props) {
|
|
225
226
|
return props.theme.checkLabelSpacing;
|
|
226
227
|
}, function (props) {
|
|
227
228
|
return calculateWidth(props.margin, props.size);
|
|
@@ -5,12 +5,21 @@ import Title from "../../.storybook/components/Title";
|
|
|
5
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
6
|
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
7
|
import styled from "styled-components";
|
|
8
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
title: "Checkbox",
|
|
11
12
|
component: DxcCheckbox,
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
const opinionatedTheme = {
|
|
16
|
+
checkbox: {
|
|
17
|
+
baseColor: "#0067b3",
|
|
18
|
+
checkColor: "#ffffff",
|
|
19
|
+
fontColor: "#000000",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
14
23
|
const Checkbox = () => (
|
|
15
24
|
<>
|
|
16
25
|
<ExampleContainer>
|
|
@@ -178,6 +187,49 @@ const Checkbox = () => (
|
|
|
178
187
|
<DxcCheckbox label="Very long label to check its overflowing" labelPosition="after" />
|
|
179
188
|
</SmallContainer>
|
|
180
189
|
</ExampleContainer>
|
|
190
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
191
|
+
<ExampleContainer>
|
|
192
|
+
<Title title="Default" theme="light" level={4} />
|
|
193
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
194
|
+
<DxcCheckbox label="Checkbox" />
|
|
195
|
+
</HalstackProvider>
|
|
196
|
+
</ExampleContainer>
|
|
197
|
+
<ExampleContainer>
|
|
198
|
+
<Title title="Checked" theme="light" level={4} />
|
|
199
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
200
|
+
<DxcCheckbox label="Checkbox" defaultChecked />
|
|
201
|
+
</HalstackProvider>
|
|
202
|
+
</ExampleContainer>
|
|
203
|
+
<ExampleContainer>
|
|
204
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
205
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
206
|
+
<DxcCheckbox label="Checkbox" disabled />
|
|
207
|
+
</HalstackProvider>
|
|
208
|
+
</ExampleContainer>
|
|
209
|
+
<ExampleContainer>
|
|
210
|
+
<Title title="Disabled checked" theme="light" level={4} />
|
|
211
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
212
|
+
<DxcCheckbox label="Checkbox" defaultChecked disabled />
|
|
213
|
+
</HalstackProvider>
|
|
214
|
+
</ExampleContainer>
|
|
215
|
+
<ExampleContainer pseudoState="pseudo-focus">
|
|
216
|
+
<Title title="Focused" theme="light" level={4} />
|
|
217
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
218
|
+
<DxcCheckbox label="Focused" />
|
|
219
|
+
</HalstackProvider>
|
|
220
|
+
</ExampleContainer>
|
|
221
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
222
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
223
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
224
|
+
<DxcCheckbox label="Hovered" />
|
|
225
|
+
</HalstackProvider>
|
|
226
|
+
</ExampleContainer>
|
|
227
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
228
|
+
<Title title="Hovered and checked" theme="light" level={4} />
|
|
229
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
230
|
+
<DxcCheckbox label="Hovered" defaultChecked />
|
|
231
|
+
</HalstackProvider>
|
|
232
|
+
</ExampleContainer>
|
|
181
233
|
</>
|
|
182
234
|
);
|
|
183
235
|
|
|
@@ -8,7 +8,7 @@ var _react2 = require("@testing-library/react");
|
|
|
8
8
|
|
|
9
9
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
10
|
|
|
11
|
-
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
|
|
11
|
+
var _Checkbox = _interopRequireDefault(require("./Checkbox.tsx"));
|
|
12
12
|
|
|
13
13
|
describe("Checkbox component tests", function () {
|
|
14
14
|
test("Checkbox renders with correct aria-labelledby and aria-required", function () {
|
package/checkbox/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
2
|
+
declare type Margin = {
|
|
3
3
|
top?: Space;
|
|
4
4
|
bottom?: Space;
|
|
5
5
|
left?: Space;
|
|
@@ -61,4 +61,8 @@ declare type Props = {
|
|
|
61
61
|
*/
|
|
62
62
|
tabIndex?: number;
|
|
63
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Reference to the component.
|
|
66
|
+
*/
|
|
67
|
+
export declare type RefType = HTMLDivElement;
|
|
64
68
|
export default Props;
|
package/chip/Chip.js
CHANGED
|
@@ -17,13 +17,13 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
17
17
|
|
|
18
18
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
19
19
|
|
|
20
|
-
var _variables = require("../common/variables
|
|
20
|
+
var _variables = require("../common/variables");
|
|
21
21
|
|
|
22
|
-
var _utils = require("../common/utils
|
|
22
|
+
var _utils = require("../common/utils");
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
-
var _templateObject, _templateObject2, _templateObject3
|
|
26
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
27
27
|
|
|
28
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); }
|
|
29
29
|
|
|
@@ -42,53 +42,42 @@ var DxcChip = function DxcChip(_ref) {
|
|
|
42
42
|
var colorsTheme = (0, _useTheme["default"])();
|
|
43
43
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
44
44
|
theme: colorsTheme.chip
|
|
45
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
45
|
+
}, /*#__PURE__*/_react["default"].createElement(Chip, {
|
|
46
46
|
disabled: disabled,
|
|
47
47
|
margin: margin
|
|
48
48
|
}, prefixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
49
|
+
role: typeof onClickPrefix === "function" ? "button" : undefined,
|
|
49
50
|
disabled: disabled,
|
|
50
|
-
|
|
51
|
-
label: label,
|
|
52
|
-
mode: "prefix",
|
|
51
|
+
interactuable: typeof onClickPrefix === "function" && !disabled,
|
|
53
52
|
tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
|
|
54
53
|
onClick: function onClick() {
|
|
55
54
|
return onClickPrefix && !disabled && onClickPrefix();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
}, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(PrefixIconContainer, {
|
|
55
|
+
}
|
|
56
|
+
}, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
59
57
|
src: prefixIcon
|
|
60
|
-
}) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(
|
|
58
|
+
}) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
61
59
|
disabled: disabled
|
|
62
60
|
}, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
61
|
+
role: typeof onClickSuffix === "function" ? "button" : undefined,
|
|
63
62
|
disabled: disabled,
|
|
64
|
-
|
|
65
|
-
mode: "suffix",
|
|
66
|
-
label: label,
|
|
63
|
+
interactuable: typeof onClickSuffix === "function" && !disabled,
|
|
67
64
|
tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
|
|
68
65
|
onClick: function onClick() {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(SuffixIconContainer, {
|
|
66
|
+
return !disabled && (onClickSuffix === null || onClickSuffix === void 0 ? void 0 : onClickSuffix());
|
|
67
|
+
}
|
|
68
|
+
}, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
73
69
|
src: suffixIcon
|
|
74
70
|
}) : suffixIcon)));
|
|
75
71
|
};
|
|
76
72
|
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
return "cursor:not-allowed;";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (interactuable) {
|
|
83
|
-
return "cursor:pointer;";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return "cursor:default; outline:none;";
|
|
73
|
+
var calculateWidth = function calculateWidth(margin) {
|
|
74
|
+
return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
87
75
|
};
|
|
88
76
|
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n cursor: ", ";\n"])), function (props) {
|
|
78
|
+
return props.theme.iconSpacing;
|
|
79
|
+
}, function (props) {
|
|
80
|
+
return calculateWidth(props.margin);
|
|
92
81
|
}, function (props) {
|
|
93
82
|
return props.disabled && props.theme.disabledBackgroundColor || props.theme.backgroundColor;
|
|
94
83
|
}, function (props) {
|
|
@@ -117,12 +106,12 @@ var StyledDxcChip = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
117
106
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
118
107
|
}, function (props) {
|
|
119
108
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
120
|
-
}, function (
|
|
121
|
-
var disabled =
|
|
109
|
+
}, function (_ref2) {
|
|
110
|
+
var disabled = _ref2.disabled;
|
|
122
111
|
return disabled && "not-allowed";
|
|
123
112
|
});
|
|
124
113
|
|
|
125
|
-
var
|
|
114
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-weight: ", ";\n font-style: ", ";\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n"])), function (props) {
|
|
126
115
|
return props.theme.fontSize;
|
|
127
116
|
}, function (props) {
|
|
128
117
|
return props.theme.fontFamily;
|
|
@@ -132,29 +121,19 @@ var ChipTextContainer = _styledComponents["default"].span(_templateObject2 || (_
|
|
|
132
121
|
return props.theme.fontStyle;
|
|
133
122
|
}, function (props) {
|
|
134
123
|
return props.disabled ? props.theme.disabledFontColor : props.theme.fontColor;
|
|
135
|
-
}, function (_ref4) {
|
|
136
|
-
var disabled = _ref4.disabled;
|
|
137
|
-
return disabled && "not-allowed" || "default";
|
|
138
124
|
});
|
|
139
125
|
|
|
140
|
-
var
|
|
141
|
-
|
|
142
|
-
var PrefixIconContainer = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
143
|
-
|
|
144
|
-
var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n ", "\n ", "\n width: ", ";\n height: ", ";\n overflow: hidden;\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n &:focus {\n outline-color: ", ";\n outline-width: 2px;\n ", "\n }\n"])), function (props) {
|
|
126
|
+
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n ", "\n\n ", "\n\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
145
127
|
return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
128
|
+
}, function (_ref3) {
|
|
129
|
+
var interactuable = _ref3.interactuable;
|
|
130
|
+
return interactuable && "cursor: pointer;";
|
|
146
131
|
}, function (props) {
|
|
147
|
-
return props.
|
|
148
|
-
}, function (props) {
|
|
149
|
-
return getCursor(props.interactuable, props.disabled);
|
|
132
|
+
return props.interactuable && "\n &:hover {\n color: ".concat(props.theme.hoverIconColor, ";\n }\n &:focus,\n &:focus-visible {\n outline: ").concat(props.theme.focusBorderThickness, " solid ").concat(props.theme.focusColor, ";\n }\n &:active {\n color: ").concat(props.theme.activeIconColor, ";\n }\n ");
|
|
150
133
|
}, function (props) {
|
|
151
134
|
return props.theme.iconSize;
|
|
152
135
|
}, function (props) {
|
|
153
136
|
return props.theme.iconSize;
|
|
154
|
-
}, function (props) {
|
|
155
|
-
return props.theme.focusColor;
|
|
156
|
-
}, function (props) {
|
|
157
|
-
return props.disabled && "outline: none;";
|
|
158
137
|
});
|
|
159
138
|
|
|
160
139
|
var _default = DxcChip;
|