@dxc-technology/halstack-react 0.0.0-c25d3b6 → 0.0.0-c2834c3
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 +298 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +7 -28
- package/accordion/Accordion.stories.tsx +11 -11
- package/accordion/Accordion.test.js +19 -4
- package/accordion/types.d.ts +4 -0
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +13 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +24 -6
- package/accordion-group/types.d.ts +4 -0
- package/alert/Alert.js +4 -1
- package/button/Button.js +14 -11
- package/card/Card.js +27 -28
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +43 -39
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/Checkbox.test.js +13 -0
- package/checkbox/types.d.ts +7 -3
- package/common/variables.js +181 -70
- package/date-input/DateInput.js +38 -20
- package/date-input/DateInput.test.js +9 -22
- package/date-input/types.d.ts +12 -9
- package/dialog/Dialog.js +4 -32
- package/dropdown/Dropdown.js +13 -17
- package/file-input/FileInput.js +9 -6
- package/file-input/FileItem.js +7 -5
- package/footer/Footer.js +15 -88
- package/header/Header.js +27 -48
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- package/inset/types.d.ts +24 -0
- package/layout/ApplicationLayout.js +5 -18
- package/link/Link.d.ts +3 -2
- package/link/Link.js +65 -56
- package/link/Link.stories.tsx +87 -52
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +8 -23
- package/main.d.ts +3 -2
- package/main.js +19 -5
- package/number-input/NumberInput.test.js +2 -4
- package/number-input/types.d.ts +13 -10
- package/package.json +6 -5
- package/paginator/Paginator.js +17 -38
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +3 -6
- package/password-input/types.d.ts +14 -11
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +116 -0
- package/quick-nav/QuickNav.stories.tsx +237 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio/Radio.js +10 -11
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.js +8 -6
- package/row/types.d.ts +18 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +152 -0
- package/select/Option.js +1 -1
- package/select/Select.js +53 -139
- package/select/Select.stories.tsx +14 -2
- package/select/Select.test.js +83 -42
- package/select/types.d.ts +33 -11
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +2 -1
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +31 -10
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +35 -19
- package/switch/Switch.stories.tsx +14 -14
- package/switch/Switch.test.js +25 -0
- package/switch/types.d.ts +6 -2
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +9 -11
- package/tabs/Tabs.stories.tsx +0 -8
- package/tabs/Tabs.test.js +26 -9
- package/tabs/types.d.ts +4 -0
- package/tag/Tag.js +5 -8
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +48 -76
- package/text-input/TextInput.test.js +22 -35
- package/text-input/types.d.ts +27 -12
- package/textarea/Textarea.js +12 -23
- package/textarea/Textarea.test.js +10 -20
- package/textarea/types.d.ts +14 -11
- 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 +8 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +55 -44
- package/wizard/Wizard.stories.tsx +13 -23
- package/wizard/Wizard.test.js +36 -23
- package/wizard/types.d.ts +6 -2
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
|
@@ -14,20 +14,32 @@ describe("Accordion component tests", function () {
|
|
|
14
14
|
|
|
15
15
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
16
16
|
label: "Accordion",
|
|
17
|
+
assistiveText: "Assistive text",
|
|
17
18
|
onChange: onChange
|
|
18
19
|
})),
|
|
19
20
|
getByText = _render.getByText;
|
|
20
21
|
|
|
21
22
|
expect(getByText("Accordion")).toBeTruthy();
|
|
23
|
+
expect(getByText("Assistive text")).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
test("Accordion renders expanded by default when it is uncontrolled", function () {
|
|
26
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
27
|
+
label: "Accordion",
|
|
28
|
+
defaultIsExpanded: true
|
|
29
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "test-expanded"))),
|
|
30
|
+
getByRole = _render2.getByRole;
|
|
31
|
+
|
|
32
|
+
var accordion = getByRole("button");
|
|
33
|
+
expect(accordion.getAttribute("aria-expanded")).toBe("true");
|
|
22
34
|
});
|
|
23
35
|
test("Calls correct function on click", function () {
|
|
24
36
|
var onChange = jest.fn();
|
|
25
37
|
|
|
26
|
-
var
|
|
38
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
27
39
|
label: "Accordion",
|
|
28
40
|
onChange: onChange
|
|
29
41
|
})),
|
|
30
|
-
getByText =
|
|
42
|
+
getByText = _render3.getByText;
|
|
31
43
|
|
|
32
44
|
_react2.fireEvent.click(getByText("Accordion"));
|
|
33
45
|
|
|
@@ -36,12 +48,15 @@ describe("Accordion component tests", function () {
|
|
|
36
48
|
test("Controlled accordion", function () {
|
|
37
49
|
var onChange = jest.fn();
|
|
38
50
|
|
|
39
|
-
var
|
|
51
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Accordion["default"], {
|
|
40
52
|
label: "Accordion",
|
|
41
53
|
onChange: onChange,
|
|
42
54
|
isExpanded: true
|
|
43
55
|
})),
|
|
44
|
-
getByText =
|
|
56
|
+
getByText = _render4.getByText,
|
|
57
|
+
getByRole = _render4.getByRole;
|
|
58
|
+
|
|
59
|
+
expect(getByRole("button").getAttribute("aria-expanded")).toBe("true");
|
|
45
60
|
|
|
46
61
|
_react2.fireEvent.click(getByText("Accordion"));
|
|
47
62
|
|
package/accordion/types.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ declare type Props = {
|
|
|
18
18
|
* The panel label.
|
|
19
19
|
*/
|
|
20
20
|
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* Initial state of the panel, only when it is uncontrolled.
|
|
23
|
+
*/
|
|
24
|
+
defaultIsExpanded?: boolean;
|
|
21
25
|
/**
|
|
22
26
|
* Represents the state of the panel. When true, the component will be
|
|
23
27
|
* expanded. If undefined, the component will be uncontrolled and its
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import AccordionGroupPropsType, { AccordionPropsType } from "./types";
|
|
3
3
|
declare const DxcAccordionGroup: {
|
|
4
|
-
({ indexActive, disabled, onActiveChange, margin, children, }: AccordionGroupPropsType): JSX.Element;
|
|
4
|
+
({ defaultIndexActive, indexActive, disabled, onActiveChange, margin, children, }: AccordionGroupPropsType): JSX.Element;
|
|
5
5
|
Accordion: ({ ...childProps }: AccordionPropsType) => JSX.Element;
|
|
6
6
|
};
|
|
7
7
|
export default DxcAccordionGroup;
|
|
@@ -47,13 +47,13 @@ var AccordionGroupAccordion = function AccordionGroupAccordion(_ref) {
|
|
|
47
47
|
var childProps = (0, _extends2["default"])({}, _ref);
|
|
48
48
|
|
|
49
49
|
var _useContext = (0, _react.useContext)(AccordionGroupAccordionContext),
|
|
50
|
-
|
|
50
|
+
activeIndex = _useContext.activeIndex,
|
|
51
51
|
handlerActiveChange = _useContext.handlerActiveChange,
|
|
52
52
|
disabled = _useContext.disabled,
|
|
53
53
|
index = _useContext.index;
|
|
54
54
|
|
|
55
55
|
return /*#__PURE__*/_react["default"].createElement(_Accordion["default"], (0, _extends2["default"])({
|
|
56
|
-
isExpanded:
|
|
56
|
+
isExpanded: activeIndex === index,
|
|
57
57
|
onChange: function onChange() {
|
|
58
58
|
handlerActiveChange(index);
|
|
59
59
|
},
|
|
@@ -62,7 +62,8 @@ var AccordionGroupAccordion = function AccordionGroupAccordion(_ref) {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
var DxcAccordionGroup = function DxcAccordionGroup(_ref2) {
|
|
65
|
-
var
|
|
65
|
+
var defaultIndexActive = _ref2.defaultIndexActive,
|
|
66
|
+
indexActive = _ref2.indexActive,
|
|
66
67
|
_ref2$disabled = _ref2.disabled,
|
|
67
68
|
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
68
69
|
onActiveChange = _ref2.onActiveChange,
|
|
@@ -70,27 +71,24 @@ var DxcAccordionGroup = function DxcAccordionGroup(_ref2) {
|
|
|
70
71
|
children = _ref2.children;
|
|
71
72
|
var colorsTheme = (0, _useTheme["default"])();
|
|
72
73
|
|
|
73
|
-
var _useState = (0, _react.useState)(0),
|
|
74
|
+
var _useState = (0, _react.useState)(defaultIndexActive !== null && defaultIndexActive !== void 0 ? defaultIndexActive : -1),
|
|
74
75
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
innerIndexActive = _useState2[0],
|
|
77
|
+
setInnerIndexActive = _useState2[1];
|
|
77
78
|
|
|
78
79
|
var handlerActiveChange = (0, _react.useCallback)(function (index) {
|
|
79
|
-
indexActive
|
|
80
|
+
indexActive !== null && indexActive !== void 0 ? indexActive : setInnerIndexActive(function (prev) {
|
|
80
81
|
return index === prev ? -1 : index;
|
|
81
|
-
})
|
|
82
|
+
});
|
|
82
83
|
!disabled && (onActiveChange === null || onActiveChange === void 0 ? void 0 : onActiveChange(index));
|
|
83
84
|
}, [disabled, indexActive, onActiveChange]);
|
|
84
|
-
var
|
|
85
|
+
var contextValue = (0, _react.useMemo)(function () {
|
|
85
86
|
return {
|
|
86
|
-
|
|
87
|
+
activeIndex: indexActive !== null && indexActive !== void 0 ? indexActive : innerIndexActive,
|
|
87
88
|
handlerActiveChange: handlerActiveChange,
|
|
88
89
|
disabled: disabled
|
|
89
90
|
};
|
|
90
|
-
}, [
|
|
91
|
-
(0, _react.useEffect)(function () {
|
|
92
|
-
setInnerIsExpanded(indexActive);
|
|
93
|
-
}, [indexActive]);
|
|
91
|
+
}, [indexActive, innerIndexActive, handlerActiveChange, disabled]);
|
|
94
92
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
95
93
|
theme: colorsTheme.accordion
|
|
96
94
|
}, /*#__PURE__*/_react["default"].createElement(AccordionGroupContainer, {
|
|
@@ -102,7 +100,7 @@ var DxcAccordionGroup = function DxcAccordionGroup(_ref2) {
|
|
|
102
100
|
return /*#__PURE__*/_react["default"].createElement(AccordionGroupAccordionContext.Provider, {
|
|
103
101
|
value: _objectSpread({
|
|
104
102
|
index: index
|
|
105
|
-
},
|
|
103
|
+
}, contextValue)
|
|
106
104
|
}, accordion);
|
|
107
105
|
})));
|
|
108
106
|
};
|
|
@@ -36,7 +36,7 @@ export const Chromatic = () => (
|
|
|
36
36
|
</ExampleContainer>
|
|
37
37
|
<ExampleContainer>
|
|
38
38
|
<Title title="Expanded" theme="light" level={4} />
|
|
39
|
-
<DxcAccordionGroup
|
|
39
|
+
<DxcAccordionGroup defaultIndexActive={1}>
|
|
40
40
|
<DxcAccordionGroup.Accordion label="Accordion1" padding="medium">
|
|
41
41
|
<div>
|
|
42
42
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
@@ -62,10 +62,28 @@ describe("Accordion component tests", function () {
|
|
|
62
62
|
expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("true");
|
|
63
63
|
expect(getAllByRole("button")[1].getAttribute("aria-expanded")).toBe("false");
|
|
64
64
|
});
|
|
65
|
+
test("Uncontrolled accordion group renders initially with an accordion expanded", function () {
|
|
66
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], {
|
|
67
|
+
defaultIndexActive: 1
|
|
68
|
+
}, /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
|
|
69
|
+
label: "Accordion1",
|
|
70
|
+
padding: "medium"
|
|
71
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.")), /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"].Accordion, {
|
|
72
|
+
label: "Accordion2",
|
|
73
|
+
padding: "medium"
|
|
74
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo lobortis eget.")))),
|
|
75
|
+
getByText = _render4.getByText,
|
|
76
|
+
getAllByRole = _render4.getAllByRole;
|
|
77
|
+
|
|
78
|
+
expect(getByText("Accordion1")).toBeTruthy();
|
|
79
|
+
expect(getByText("Accordion2")).toBeTruthy();
|
|
80
|
+
expect(getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("false");
|
|
81
|
+
expect(getAllByRole("button")[1].getAttribute("aria-expanded")).toBe("true");
|
|
82
|
+
});
|
|
65
83
|
test("Controlled accordion with indexActive change", function () {
|
|
66
84
|
var onActiveChange = jest.fn();
|
|
67
85
|
|
|
68
|
-
var
|
|
86
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], {
|
|
69
87
|
margin: "large",
|
|
70
88
|
indexActive: 1,
|
|
71
89
|
onActiveChange: onActiveChange
|
|
@@ -77,9 +95,9 @@ describe("Accordion component tests", function () {
|
|
|
77
95
|
label: "Accordion2",
|
|
78
96
|
padding: "medium"
|
|
79
97
|
}, /*#__PURE__*/_react["default"].createElement("div", null, "Text2")))),
|
|
80
|
-
getByText =
|
|
81
|
-
getAllByRole =
|
|
82
|
-
rerender =
|
|
98
|
+
getByText = _render5.getByText,
|
|
99
|
+
getAllByRole = _render5.getAllByRole,
|
|
100
|
+
rerender = _render5.rerender;
|
|
83
101
|
|
|
84
102
|
expect(getByText("Text1")).toBeTruthy();
|
|
85
103
|
expect(getByText("Text2")).toBeTruthy();
|
|
@@ -110,7 +128,7 @@ describe("Accordion component tests", function () {
|
|
|
110
128
|
test("Disabled uncontrolled accordion group", function () {
|
|
111
129
|
var onActiveChange = jest.fn();
|
|
112
130
|
|
|
113
|
-
var
|
|
131
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_AccordionGroup["default"], {
|
|
114
132
|
margin: "large",
|
|
115
133
|
onActiveChange: onActiveChange,
|
|
116
134
|
disabled: true
|
|
@@ -122,7 +140,7 @@ describe("Accordion component tests", function () {
|
|
|
122
140
|
label: "Accordion2",
|
|
123
141
|
padding: "medium"
|
|
124
142
|
}, /*#__PURE__*/_react["default"].createElement("div", null, "Text2")))),
|
|
125
|
-
getByText =
|
|
143
|
+
getByText = _render6.getByText;
|
|
126
144
|
|
|
127
145
|
_react2.fireEvent.click(getByText("Accordion1"));
|
|
128
146
|
|
|
@@ -42,6 +42,10 @@ export declare type AccordionPropsType = {
|
|
|
42
42
|
children: React.ReactNode;
|
|
43
43
|
};
|
|
44
44
|
declare type Props = {
|
|
45
|
+
/**
|
|
46
|
+
* Initially active accordion, only when it is uncontrolled.
|
|
47
|
+
*/
|
|
48
|
+
defaultIndexActive?: number;
|
|
45
49
|
/**
|
|
46
50
|
* The index of the active accordion. If undefined, the component will be uncontrolled and the active accordion will be managed internally by the component.
|
|
47
51
|
* If null, the component will be controlled and all accordions will be closed.
|
package/alert/Alert.js
CHANGED
|
@@ -23,6 +23,8 @@ var _utils = require("../common/utils.js");
|
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
|
+
|
|
26
28
|
var _BackgroundColorContext = require("../BackgroundColorContext");
|
|
27
29
|
|
|
28
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
|
|
@@ -109,9 +111,10 @@ var DxcAlert = function DxcAlert(_ref) {
|
|
|
109
111
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
110
112
|
tabIndex = _ref.tabIndex;
|
|
111
113
|
var colorsTheme = (0, _useTheme["default"])();
|
|
114
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
112
115
|
|
|
113
116
|
var getTypeText = function getTypeText() {
|
|
114
|
-
return type === "info" ?
|
|
117
|
+
return type === "info" ? translatedLabels.alert.infoTitleText : type === "confirm" ? translatedLabels.alert.successTitleText : type === "warning" ? translatedLabels.alert.warningTitleText : translatedLabels.alert.errorTitleText;
|
|
115
118
|
};
|
|
116
119
|
|
|
117
120
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
package/button/Button.js
CHANGED
|
@@ -45,14 +45,22 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
45
45
|
_ref$type = _ref.type,
|
|
46
46
|
type = _ref$type === void 0 ? "button" : _ref$type,
|
|
47
47
|
icon = _ref.icon,
|
|
48
|
-
|
|
48
|
+
_ref$onClick = _ref.onClick,
|
|
49
|
+
_onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
49
50
|
margin = _ref.margin,
|
|
50
51
|
_ref$size = _ref.size,
|
|
51
52
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
52
53
|
_ref$tabIndex = _ref.tabIndex,
|
|
53
54
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
55
|
+
|
|
54
56
|
var colorsTheme = (0, _useTheme["default"])();
|
|
55
57
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
58
|
+
|
|
59
|
+
var labelComponent = /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
60
|
+
icon: icon,
|
|
61
|
+
iconPosition: iconPosition
|
|
62
|
+
}, label);
|
|
63
|
+
|
|
56
64
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
57
65
|
theme: colorsTheme.button
|
|
58
66
|
}, /*#__PURE__*/_react["default"].createElement(DxCButton, {
|
|
@@ -73,15 +81,12 @@ var DxcButton = function DxcButton(_ref) {
|
|
|
73
81
|
onClick: function onClick() {
|
|
74
82
|
_onClick();
|
|
75
83
|
}
|
|
76
|
-
}, label && /*#__PURE__*/_react["default"].createElement(
|
|
77
|
-
icon: icon,
|
|
78
|
-
iconPosition: iconPosition
|
|
79
|
-
}, label), icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
84
|
+
}, label && iconPosition === "after" && labelComponent, icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
80
85
|
label: label,
|
|
81
86
|
iconPosition: iconPosition
|
|
82
87
|
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(ButtonIcon, {
|
|
83
88
|
src: icon
|
|
84
|
-
}) : icon))));
|
|
89
|
+
}) : icon), label && iconPosition === "before" && labelComponent)));
|
|
85
90
|
};
|
|
86
91
|
|
|
87
92
|
var sizes = {
|
|
@@ -118,7 +123,7 @@ var IconContainer = _styledComponents["default"].div(_templateObject2 || (_templ
|
|
|
118
123
|
|
|
119
124
|
var ButtonIcon = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
120
125
|
|
|
121
|
-
var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-block;\n width: ", ";\n cursor: ", ";\n\n .MuiButtonBase-root {\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n\n .MuiButton-label {\n display: flex;\n
|
|
126
|
+
var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n display: inline-block;\n width: ", ";\n cursor: ", ";\n\n .MuiButtonBase-root {\n padding-left: ", ";\n padding-right: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n\n .MuiButton-label {\n display: flex;\n align-items: center;\n }\n\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n min-width: ", ";\n width: 100%;\n height: 40px;\n transition: none !important;\n\n &:focus {\n border-color: transparent;\n box-shadow: 0 0 0 2px\n ", ";\n }\n\n ", "\n }\n"])), function (props) {
|
|
122
127
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
123
128
|
}, function (props) {
|
|
124
129
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
@@ -140,8 +145,6 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
|
|
|
140
145
|
return props.theme.paddingTop;
|
|
141
146
|
}, function (props) {
|
|
142
147
|
return props.theme.paddingBottom;
|
|
143
|
-
}, function (props) {
|
|
144
|
-
return props.iconPosition === "after" && "row" || "row-reverse";
|
|
145
148
|
}, function (props) {
|
|
146
149
|
return props.theme.fontFamily;
|
|
147
150
|
}, function (props) {
|
|
@@ -159,9 +162,9 @@ var DxCButton = _styledComponents["default"].div(_templateObject4 || (_templateO
|
|
|
159
162
|
backgroundType = props.backgroundType;
|
|
160
163
|
|
|
161
164
|
if (mode === "primary") {
|
|
162
|
-
return "\n border-radius: ".concat(props.theme.primaryBorderRadius, ";\n border-width: ").concat(props.theme.primaryBorderThickness, ";\n border-style: ").concat(props.theme.primaryBorderStyle, ";\n font-family: ").concat(props.theme.primaryFontFamily, ";\n font-size: ").concat(props.theme.primaryFontSize, ";\n font-weight: ").concat(props.theme.primaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor, ";\n color: ").concat(backgroundType && backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled { \n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor, "!important; \n }\n
|
|
165
|
+
return "\n border-radius: ".concat(props.theme.primaryBorderRadius, ";\n border-width: ").concat(props.theme.primaryBorderThickness, ";\n border-style: ").concat(props.theme.primaryBorderStyle, ";\n font-family: ").concat(props.theme.primaryFontFamily, ";\n font-size: ").concat(props.theme.primaryFontSize, ";\n font-weight: ").concat(props.theme.primaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryBackgroundColorOnDark : props.theme.primaryBackgroundColor, ";\n color: ").concat(backgroundType && backgroundType === "dark" ? props.theme.primaryFontColorOnDark : props.theme.primaryFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryHoverBackgroundColorOnDark : props.theme.primaryHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryActiveBackgroundColorOnDark : props.theme.primaryActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled { \n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledBackgroundColorOnDark : props.theme.primaryDisabledBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.primaryDisabledFontColorOnDark : props.theme.primaryDisabledFontColor, " !important; \n }\n ");
|
|
163
166
|
} else if (mode === "secondary") {
|
|
164
|
-
return "\n border-radius: ".concat(props.theme.secondaryBorderRadius, ";\n border-width: ").concat(props.theme.secondaryBorderThickness, ";\n border-style: ").concat(props.theme.secondaryBorderStyle, ";\n font-family: ").concat(props.theme.secondaryFontFamily, ";\n font-size: ").concat(props.theme.secondaryFontSize, ";\n font-weight: ").concat(props.theme.secondaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor, ";\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor, ";\n }\n
|
|
167
|
+
return "\n border-radius: ".concat(props.theme.secondaryBorderRadius, ";\n border-width: ").concat(props.theme.secondaryBorderThickness, ";\n border-style: ").concat(props.theme.secondaryBorderStyle, ";\n font-family: ").concat(props.theme.secondaryFontFamily, ";\n font-size: ").concat(props.theme.secondaryFontSize, ";\n font-weight: ").concat(props.theme.secondaryFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBackgroundColorOnDark : props.theme.secondaryBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryFontColorOnDark : props.theme.secondaryFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryBorderColorOnDark : props.theme.secondaryBorderColor, ";\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverBackgroundColorOnDark : props.theme.secondaryHoverBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryActiveBackgroundColorOnDark : props.theme.secondaryActiveBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryHoverFontColorOnDark : props.theme.secondaryHoverFontColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor: not-allowed;\n background-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBackgroundColorOnDark : props.theme.secondaryDisabledBackgroundColor, " !important;\n color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledFontColorOnDark : props.theme.secondaryDisabledFontColor, " !important;\n border-color: ").concat(backgroundType === "dark" ? props.theme.secondaryDisabledBorderColorOnDark : props.theme.secondaryDisabledBorderColor, ";\n }\n ");
|
|
165
168
|
} else if (mode === "text") {
|
|
166
169
|
return "\n border-radius: ".concat(props.theme.textBorderRadius, ";\n border-width: ").concat(props.theme.textBorderThickness, ";\n border-style: ").concat(props.theme.textBorderStyle, ";\n font-family: ").concat(props.theme.textFontFamily, ";\n font-size: ").concat(props.theme.textFontSize, ";\n font-weight: ").concat(props.theme.textFontWeight, ";\n background-color: ").concat(backgroundType === "dark" ? props.theme.textBackgroundColorOnDark : props.theme.textBackgroundColor, ";\n color: ").concat(backgroundType === "dark" ? props.theme.textFontColorOnDark : props.theme.textFontColor, " !important;\n\n &:hover {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textHoverBackgroundColorOnDark : props.theme.textHoverBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(backgroundType === "dark" ? props.theme.textActiveBackgroundColorOnDark : props.theme.textActiveBackgroundColor, " !important;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }\n &:disabled {\n cursor:not-allowed;\n color: ").concat(backgroundType === "dark" ? props.theme.textDisabledFontColorOnDark : props.theme.textDisabledFontColor, " !important;\n background-color: ").concat(backgroundType === "dark" ? props.theme.textDisabledBackgroundColorOnDark : props.theme.textDisabledBackgroundColor, ";\n }\n ");
|
|
167
170
|
}
|
package/card/Card.js
CHANGED
|
@@ -56,6 +56,14 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
56
56
|
isHovered = _useState2[0],
|
|
57
57
|
changeIsHovered = _useState2[1];
|
|
58
58
|
|
|
59
|
+
var imageComponent = /*#__PURE__*/_react["default"].createElement(ImageContainer, {
|
|
60
|
+
imageBgColor: imageBgColor
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
62
|
+
imagePadding: imagePadding,
|
|
63
|
+
cover: imageCover,
|
|
64
|
+
src: imageSrc
|
|
65
|
+
}));
|
|
66
|
+
|
|
59
67
|
var tagContent = /*#__PURE__*/_react["default"].createElement(_Box["default"], {
|
|
60
68
|
shadowDepth: !outlined ? 0 : isHovered && (onClick || linkHref) ? 2 : 1
|
|
61
69
|
}, /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
@@ -63,15 +71,9 @@ var DxcCard = function DxcCard(_ref) {
|
|
|
63
71
|
}, /*#__PURE__*/_react["default"].createElement(CardContainer, {
|
|
64
72
|
hasAction: onClick || linkHref,
|
|
65
73
|
imagePosition: imagePosition
|
|
66
|
-
}, imageSrc && /*#__PURE__*/_react["default"].createElement(
|
|
67
|
-
imageBgColor: imageBgColor
|
|
68
|
-
}, /*#__PURE__*/_react["default"].createElement(TagImage, {
|
|
69
|
-
imagePadding: imagePadding,
|
|
70
|
-
cover: imageCover,
|
|
71
|
-
src: imageSrc
|
|
72
|
-
})), /*#__PURE__*/_react["default"].createElement(CardContent, {
|
|
74
|
+
}, imageSrc && imagePosition === "before" && imageComponent, /*#__PURE__*/_react["default"].createElement(CardContent, {
|
|
73
75
|
contentPadding: contentPadding
|
|
74
|
-
}, children))));
|
|
76
|
+
}, children), imageSrc && imagePosition === "after" && imageComponent)));
|
|
75
77
|
|
|
76
78
|
return /*#__PURE__*/_react["default"].createElement(StyledDxcCard, {
|
|
77
79
|
margin: margin,
|
|
@@ -113,50 +115,47 @@ var StyledDxcCard = _styledComponents["default"].div(_templateObject || (_templa
|
|
|
113
115
|
return margin && margin.left ? _variables.spaces[margin.left] : "";
|
|
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;
|
|
123
|
-
}, function (
|
|
124
|
-
var hasAction =
|
|
122
|
+
}, function (_ref9) {
|
|
123
|
+
var hasAction = _ref9.hasAction;
|
|
125
124
|
return hasAction ? "" : "unset";
|
|
126
125
|
});
|
|
127
126
|
|
|
128
127
|
var StyledLink = _styledComponents["default"].a(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n cursor: pointer;\n text-decoration: none;\n\n :focus {\n outline-color: #0095ff;\n }\n"])));
|
|
129
128
|
|
|
130
|
-
var TagImage = _styledComponents["default"].img(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n height: ", ";\n width: ", ";\n object-fit: ", ";\n"])), function (
|
|
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) {
|
|
131
133
|
var imagePadding = _ref11.imagePadding;
|
|
132
134
|
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
133
135
|
}, function (_ref12) {
|
|
134
|
-
var
|
|
135
|
-
return !imagePadding ? "100%" : "calc(100% - ".concat(_variables.spaces[imagePadding], " - ").concat(_variables.spaces[imagePadding], ")");
|
|
136
|
-
}, function (_ref13) {
|
|
137
|
-
var cover = _ref13.cover;
|
|
136
|
+
var cover = _ref12.cover;
|
|
138
137
|
return cover ? "cover" : "contain";
|
|
139
138
|
});
|
|
140
139
|
|
|
141
|
-
var ImageContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (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 (
|
|
142
|
-
var imageBgColor =
|
|
140
|
+
var ImageContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (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 (_ref13) {
|
|
141
|
+
var imageBgColor = _ref13.imageBgColor;
|
|
143
142
|
return imageBgColor;
|
|
144
143
|
});
|
|
145
144
|
|
|
146
|
-
var CardContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (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 (
|
|
147
|
-
var contentPadding =
|
|
145
|
+
var CardContent = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (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 (_ref14) {
|
|
146
|
+
var contentPadding = _ref14.contentPadding;
|
|
148
147
|
return contentPadding && (0, _typeof2["default"])(contentPadding) !== "object" ? _variables.spaces[contentPadding] : "0px";
|
|
148
|
+
}, function (_ref15) {
|
|
149
|
+
var contentPadding = _ref15.contentPadding;
|
|
150
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.top ? _variables.spaces[contentPadding.top] : "";
|
|
149
151
|
}, function (_ref16) {
|
|
150
152
|
var contentPadding = _ref16.contentPadding;
|
|
151
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.
|
|
153
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.right ? _variables.spaces[contentPadding.right] : "";
|
|
152
154
|
}, function (_ref17) {
|
|
153
155
|
var contentPadding = _ref17.contentPadding;
|
|
154
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.
|
|
156
|
+
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
155
157
|
}, function (_ref18) {
|
|
156
158
|
var contentPadding = _ref18.contentPadding;
|
|
157
|
-
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.bottom ? _variables.spaces[contentPadding.bottom] : "";
|
|
158
|
-
}, function (_ref19) {
|
|
159
|
-
var contentPadding = _ref19.contentPadding;
|
|
160
159
|
return contentPadding && (0, _typeof2["default"])(contentPadding) === "object" && contentPadding.left ? _variables.spaces[contentPadding.left] : "";
|
|
161
160
|
});
|
|
162
161
|
|
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, 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;
|