@dxc-technology/halstack-react 0.0.0-3716032 → 0.0.0-381476a
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 +3 -3
- package/BackgroundColorContext.js +6 -19
- package/HalstackContext.d.ts +1356 -0
- package/HalstackContext.js +310 -0
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +117 -190
- package/accordion/Accordion.stories.tsx +103 -120
- package/accordion/Accordion.test.js +56 -0
- package/accordion/types.d.ts +11 -22
- package/accordion-group/AccordionGroup.d.ts +5 -4
- package/accordion-group/AccordionGroup.js +38 -107
- package/accordion-group/AccordionGroup.stories.tsx +95 -68
- package/accordion-group/AccordionGroup.test.js +98 -0
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/types.d.ts +17 -22
- package/alert/Alert.js +22 -55
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +75 -0
- package/alert/types.d.ts +5 -5
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +8 -19
- package/badge/types.d.ts +5 -0
- package/bleed/Bleed.d.ts +3 -0
- package/bleed/Bleed.js +43 -0
- package/bleed/Bleed.stories.tsx +342 -0
- package/bleed/types.d.ts +37 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +29 -77
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +13 -0
- package/box/types.d.ts +3 -14
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +99 -0
- package/bulleted-list/BulletedList.stories.tsx +116 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +61 -119
- package/button/Button.stories.tsx +164 -96
- package/button/Button.test.js +36 -0
- package/button/types.d.ts +12 -12
- package/card/Card.d.ts +1 -1
- package/card/Card.js +58 -102
- package/card/Card.stories.tsx +13 -43
- package/card/Card.test.js +39 -0
- package/card/types.d.ts +6 -11
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +145 -178
- package/checkbox/Checkbox.stories.tsx +166 -136
- package/checkbox/Checkbox.test.js +199 -0
- package/checkbox/types.d.ts +18 -6
- package/chip/Chip.d.ts +1 -1
- package/chip/Chip.js +46 -124
- package/chip/Chip.stories.tsx +123 -30
- package/chip/Chip.test.js +41 -0
- package/chip/types.d.ts +8 -16
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +166 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +6 -12
- package/common/variables.d.ts +1499 -0
- package/common/variables.js +1117 -1320
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +214 -0
- package/date-input/DateInput.js +173 -308
- package/date-input/DateInput.stories.tsx +203 -56
- package/date-input/DateInput.test.js +808 -0
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +115 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +58 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +100 -0
- package/date-input/types.d.ts +86 -22
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +70 -129
- package/dialog/Dialog.stories.tsx +154 -171
- package/dialog/Dialog.test.js +307 -0
- package/dialog/types.d.ts +18 -25
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +244 -327
- package/dropdown/Dropdown.stories.tsx +255 -64
- package/dropdown/Dropdown.test.js +599 -0
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +63 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +67 -0
- package/dropdown/types.d.ts +36 -27
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +224 -356
- package/file-input/FileInput.stories.tsx +123 -11
- package/file-input/FileInput.test.js +408 -0
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +50 -99
- package/file-input/types.d.ts +25 -8
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +112 -0
- package/flex/types.d.ts +97 -0
- package/flex/types.js +5 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +54 -179
- package/footer/Footer.stories.tsx +41 -19
- package/footer/Footer.test.js +85 -0
- package/footer/Icons.d.ts +2 -2
- package/footer/Icons.js +3 -8
- package/footer/types.d.ts +21 -22
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +76 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/grid/types.js +5 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +104 -197
- package/header/Header.stories.tsx +152 -63
- package/header/Header.test.js +66 -0
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +4 -9
- package/header/types.d.ts +5 -20
- package/heading/Heading.js +10 -32
- package/heading/Heading.stories.tsx +3 -2
- package/heading/Heading.test.js +169 -0
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/image/types.js +5 -0
- package/inset/Inset.d.ts +3 -0
- package/inset/Inset.js +43 -0
- package/inset/Inset.stories.tsx +230 -0
- package/inset/types.d.ts +37 -0
- package/inset/types.js +5 -0
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +83 -174
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +8 -0
- package/layout/Icons.js +51 -48
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +13 -0
- package/layout/types.d.ts +19 -35
- package/link/Link.d.ts +3 -2
- package/link/Link.js +64 -110
- package/link/Link.stories.tsx +159 -52
- package/link/Link.test.js +63 -0
- package/link/types.d.ts +15 -35
- package/main.d.ts +14 -16
- package/main.js +61 -120
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +90 -0
- package/nav-tabs/NavTabs.stories.tsx +274 -0
- package/nav-tabs/NavTabs.test.js +75 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +117 -0
- package/nav-tabs/types.d.ts +52 -0
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +27 -43
- package/number-input/NumberInput.stories.tsx +44 -28
- package/number-input/NumberInput.test.js +830 -0
- package/number-input/types.d.ts +28 -15
- package/package.json +44 -43
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +21 -47
- package/paginator/Paginator.js +33 -87
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +335 -0
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +27 -0
- package/paragraph/Paragraph.stories.tsx +27 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +35 -0
- package/password-input/PasswordInput.js +57 -123
- package/password-input/PasswordInput.stories.tsx +3 -34
- package/password-input/PasswordInput.test.js +198 -0
- package/password-input/types.d.ts +21 -17
- package/progress-bar/ProgressBar.js +67 -87
- package/progress-bar/ProgressBar.stories.tsx +93 -0
- package/progress-bar/ProgressBar.test.js +93 -0
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +94 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +4 -0
- package/radio-group/Radio.js +124 -0
- package/radio-group/RadioGroup.d.ts +4 -0
- package/radio-group/RadioGroup.js +235 -0
- package/radio-group/RadioGroup.stories.tsx +214 -0
- package/radio-group/RadioGroup.test.js +756 -0
- package/radio-group/types.d.ts +114 -0
- package/radio-group/types.js +5 -0
- package/resultset-table/Icons.d.ts +7 -0
- package/resultset-table/Icons.js +47 -0
- package/resultset-table/ResultsetTable.js +159 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +56 -32
- package/resultset-table/ResultsetTable.test.js +305 -0
- package/{resultsetTable → resultset-table}/types.d.ts +7 -7
- package/resultset-table/types.js +5 -0
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +89 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +143 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +80 -0
- package/select/Select.js +210 -491
- package/select/Select.stories.tsx +603 -204
- package/select/Select.test.js +2334 -0
- package/select/types.d.ts +64 -25
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +47 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +133 -70
- package/sidenav/Sidenav.stories.tsx +251 -134
- package/sidenav/Sidenav.test.js +37 -0
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +145 -168
- package/slider/Slider.test.js +254 -0
- package/slider/types.d.ts +11 -3
- package/spinner/Spinner.js +28 -64
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -26
- package/spinner/Spinner.test.js +55 -0
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +152 -112
- package/switch/Switch.stories.tsx +45 -68
- package/switch/Switch.test.js +180 -0
- package/switch/types.d.ts +13 -5
- package/table/Table.js +7 -26
- package/table/{Table.stories.jsx → Table.stories.tsx} +81 -1
- package/table/Table.test.js +21 -0
- package/table/types.d.ts +8 -8
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +113 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +318 -146
- package/tabs/Tabs.stories.tsx +122 -17
- package/tabs/Tabs.test.js +294 -0
- package/tabs/types.d.ts +46 -24
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +43 -85
- package/tag/Tag.stories.tsx +38 -28
- package/tag/Tag.test.js +49 -0
- package/tag/types.d.ts +25 -16
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +56 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +67 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +89 -0
- package/text-input/TextInput.js +301 -495
- package/text-input/TextInput.stories.tsx +280 -271
- package/text-input/TextInput.test.js +1739 -0
- package/text-input/types.d.ts +71 -25
- package/textarea/Textarea.js +79 -123
- package/textarea/Textarea.stories.tsx +175 -0
- package/textarea/Textarea.test.js +406 -0
- package/textarea/types.d.ts +27 -16
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +95 -105
- package/toggle-group/ToggleGroup.stories.tsx +53 -8
- package/toggle-group/ToggleGroup.test.js +137 -0
- package/toggle-group/types.d.ts +34 -17
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +23 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1251 -1
- package/useTheme.js +4 -11
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +14 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +94 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +114 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +70 -101
- package/wizard/Wizard.stories.tsx +48 -19
- package/wizard/Wizard.test.js +114 -0
- package/wizard/types.d.ts +12 -8
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -243
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/list/List.d.ts +0 -8
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -85
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/progress-bar/ProgressBar.stories.jsx +0 -58
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/resultsetTable/ResultsetTable.js +0 -251
- package/row/Row.d.ts +0 -11
- package/row/Row.js +0 -124
- package/row/Row.stories.tsx +0 -223
- package/slider/Slider.stories.tsx +0 -177
- package/stack/Stack.d.ts +0 -10
- package/stack/Stack.js +0 -94
- package/stack/Stack.stories.tsx +0 -150
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/textarea/Textarea.stories.jsx +0 -135
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- /package/{radio → badge}/types.js +0 -0
- /package/{resultsetTable → bleed}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → bulleted-list/types.js} +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _Spinner = _interopRequireDefault(require("./Spinner.tsx"));
|
|
7
|
+
describe("Spinner component tests", function () {
|
|
8
|
+
test("Spinner renders with correct label", function () {
|
|
9
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Spinner["default"], {
|
|
10
|
+
label: "test-loading"
|
|
11
|
+
})),
|
|
12
|
+
getByText = _render.getByText;
|
|
13
|
+
expect(getByText("test-loading")).toBeTruthy();
|
|
14
|
+
});
|
|
15
|
+
test("Spinner shows value correctly", function () {
|
|
16
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Spinner["default"], {
|
|
17
|
+
label: "test-loading",
|
|
18
|
+
value: 75,
|
|
19
|
+
showValue: true
|
|
20
|
+
})),
|
|
21
|
+
getByText = _render2.getByText;
|
|
22
|
+
expect(getByText("75%")).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
test("Small spinner hides value and label correctly", function () {
|
|
25
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Spinner["default"], {
|
|
26
|
+
mode: "small",
|
|
27
|
+
label: "test-loading",
|
|
28
|
+
value: 75,
|
|
29
|
+
showValue: true
|
|
30
|
+
})),
|
|
31
|
+
queryByText = _render3.queryByText;
|
|
32
|
+
expect(queryByText("test-loading")).toBeFalsy();
|
|
33
|
+
expect(queryByText("75%")).toBeFalsy();
|
|
34
|
+
});
|
|
35
|
+
test("Overlay spinner shows value and label correctly", function () {
|
|
36
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Spinner["default"], {
|
|
37
|
+
mode: "overlay",
|
|
38
|
+
label: "test-loading",
|
|
39
|
+
value: 75,
|
|
40
|
+
showValue: true
|
|
41
|
+
})),
|
|
42
|
+
getByText = _render4.getByText;
|
|
43
|
+
expect(getByText("test-loading")).toBeTruthy();
|
|
44
|
+
expect(getByText("75%")).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
test("Get spinner by role", function () {
|
|
47
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Spinner["default"], {
|
|
48
|
+
label: "test-loading",
|
|
49
|
+
value: 75,
|
|
50
|
+
showValue: true
|
|
51
|
+
})),
|
|
52
|
+
getByRole = _render5.getByRole;
|
|
53
|
+
expect(getByRole("progressbar")).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
});
|
package/spinner/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
2
|
+
type Margin = {
|
|
3
3
|
top?: Space;
|
|
4
4
|
bottom?: Space;
|
|
5
5
|
left?: Space;
|
|
6
6
|
right?: Space;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type Props = {
|
|
9
9
|
/**
|
|
10
10
|
* Text to be placed inside the spinner.
|
|
11
11
|
*/
|
package/switch/Switch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import SwitchPropsType from "./types";
|
|
3
|
-
declare const DxcSwitch:
|
|
3
|
+
declare const DxcSwitch: React.ForwardRefExoticComponent<SwitchPropsType & React.RefAttributes<HTMLDivElement>>;
|
|
4
4
|
export default DxcSwitch;
|
package/switch/Switch.js
CHANGED
|
@@ -1,122 +1,170 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var _RequiredComponent = _interopRequireDefault(require("../common/RequiredComponent"));
|
|
25
|
-
|
|
26
|
-
var _variables = require("../common/variables.js");
|
|
27
|
-
|
|
28
|
-
var _utils = require("../common/utils.js");
|
|
29
|
-
|
|
14
|
+
var _uuid = require("uuid");
|
|
15
|
+
var _variables = require("../common/variables");
|
|
16
|
+
var _utils = require("../common/utils");
|
|
30
17
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
31
|
-
|
|
18
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
32
19
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
23
|
+
var DxcSwitch = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
24
|
+
var defaultChecked = _ref.defaultChecked,
|
|
25
|
+
checked = _ref.checked,
|
|
26
|
+
value = _ref.value,
|
|
27
|
+
_ref$label = _ref.label,
|
|
28
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
29
|
+
_ref$labelPosition = _ref.labelPosition,
|
|
30
|
+
labelPosition = _ref$labelPosition === void 0 ? "before" : _ref$labelPosition,
|
|
31
|
+
_ref$name = _ref.name,
|
|
32
|
+
name = _ref$name === void 0 ? "" : _ref$name,
|
|
33
|
+
_ref$disabled = _ref.disabled,
|
|
34
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
35
|
+
_ref$optional = _ref.optional,
|
|
36
|
+
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
37
|
+
onChange = _ref.onChange,
|
|
38
|
+
margin = _ref.margin,
|
|
39
|
+
_ref$size = _ref.size,
|
|
40
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
41
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
42
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
43
|
+
var _useState = (0, _react.useState)("switch-".concat((0, _uuid.v4)())),
|
|
44
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
45
|
+
switchId = _useState2[0];
|
|
46
|
+
var labelId = "label-".concat(switchId);
|
|
47
|
+
var _useState3 = (0, _react.useState)(defaultChecked !== null && defaultChecked !== void 0 ? defaultChecked : false),
|
|
48
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
49
|
+
innerChecked = _useState4[0],
|
|
50
|
+
setInnerChecked = _useState4[1];
|
|
65
51
|
var colorsTheme = (0, _useTheme["default"])();
|
|
52
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
66
53
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
67
|
-
|
|
54
|
+
var refTrack = (0, _react.useRef)(null);
|
|
55
|
+
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
56
|
+
switch (event.key) {
|
|
57
|
+
case "Enter":
|
|
58
|
+
case " ":
|
|
59
|
+
//Space
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
refTrack.current.focus();
|
|
62
|
+
var isChecked = !(checked !== null && checked !== void 0 ? checked : innerChecked);
|
|
63
|
+
setInnerChecked(isChecked);
|
|
64
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(isChecked);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
68
|
var handlerSwitchChange = function handlerSwitchChange(event) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
setInnerChecked(isChecked);
|
|
74
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(isChecked);
|
|
75
|
-
} else onChange === null || onChange === void 0 ? void 0 : onChange(!checked);
|
|
69
|
+
checked !== null && checked !== void 0 ? checked : setInnerChecked(function (innerChecked) {
|
|
70
|
+
return !innerChecked;
|
|
71
|
+
});
|
|
72
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(checked ? !checked : !innerChecked);
|
|
76
73
|
};
|
|
77
|
-
|
|
78
74
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
79
75
|
theme: colorsTheme["switch"]
|
|
80
76
|
}, /*#__PURE__*/_react["default"].createElement(SwitchContainer, {
|
|
81
77
|
margin: margin,
|
|
78
|
+
size: size,
|
|
79
|
+
onKeyDown: handleOnKeyDown,
|
|
82
80
|
disabled: disabled,
|
|
81
|
+
onClick: !disabled ? handlerSwitchChange : undefined,
|
|
82
|
+
ref: ref
|
|
83
|
+
}, labelPosition === "before" && label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
84
|
+
id: labelId,
|
|
83
85
|
labelPosition: labelPosition,
|
|
84
|
-
|
|
85
|
-
backgroundType: backgroundType
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
onChange: handlerSwitchChange,
|
|
86
|
+
disabled: disabled,
|
|
87
|
+
backgroundType: backgroundType,
|
|
88
|
+
label: label
|
|
89
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, translatedLabels.formFields.optionalLabel)), /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
90
|
+
type: "checkbox",
|
|
91
|
+
name: name,
|
|
92
|
+
"aria-hidden": true,
|
|
93
93
|
value: value,
|
|
94
94
|
disabled: disabled,
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
96
|
+
readOnly: true
|
|
97
|
+
}), /*#__PURE__*/_react["default"].createElement(SwitchBase, null, /*#__PURE__*/_react["default"].createElement(SwitchTrack, {
|
|
98
|
+
role: "switch",
|
|
99
|
+
backgroundType: backgroundType,
|
|
100
|
+
"aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
101
|
+
"aria-disabled": disabled,
|
|
102
|
+
disabled: disabled,
|
|
103
|
+
"aria-labelledby": labelId,
|
|
104
|
+
tabIndex: !disabled ? tabIndex : -1,
|
|
105
|
+
ref: refTrack
|
|
106
|
+
})), labelPosition === "after" && label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
107
|
+
id: labelId,
|
|
97
108
|
labelPosition: labelPosition,
|
|
98
|
-
onClick: !disabled && handlerSwitchChange,
|
|
99
109
|
disabled: disabled,
|
|
100
|
-
backgroundType: backgroundType
|
|
101
|
-
|
|
102
|
-
};
|
|
103
|
-
|
|
110
|
+
backgroundType: backgroundType,
|
|
111
|
+
label: label
|
|
112
|
+
}, optional && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, translatedLabels.formFields.optionalLabel), " ", label)));
|
|
113
|
+
});
|
|
104
114
|
var sizes = {
|
|
105
115
|
small: "60px",
|
|
106
116
|
medium: "240px",
|
|
107
117
|
large: "480px",
|
|
108
118
|
fillParent: "100%",
|
|
109
|
-
fitContent: "
|
|
119
|
+
fitContent: "fit-content"
|
|
110
120
|
};
|
|
111
|
-
|
|
112
121
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
113
122
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
114
123
|
};
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
var getDisabledColor = function getDisabledColor(props, element, subelement) {
|
|
125
|
+
switch (element) {
|
|
126
|
+
case "track":
|
|
127
|
+
switch (subelement) {
|
|
128
|
+
case "check":
|
|
129
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledCheckedTrackBackgroundColorOnDark : props.theme.disabledCheckedTrackBackgroundColor;
|
|
130
|
+
case "uncheck":
|
|
131
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledUncheckedTrackBackgroundColorOnDark : props.theme.disabledUncheckedTrackBackgroundColor;
|
|
132
|
+
}
|
|
133
|
+
case "thumb":
|
|
134
|
+
switch (subelement) {
|
|
135
|
+
case "check":
|
|
136
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledCheckedThumbBackgroundColorOnDark : props.theme.disabledCheckedThumbBackgroundColor;
|
|
137
|
+
case "uncheck":
|
|
138
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledUncheckedThumbBackgroundColorOnDark : props.theme.disabledUncheckedThumbBackgroundColor;
|
|
139
|
+
}
|
|
140
|
+
case "label":
|
|
141
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var getNotDisabledColor = function getNotDisabledColor(props, element, subelement) {
|
|
145
|
+
switch (element) {
|
|
146
|
+
case "track":
|
|
147
|
+
switch (subelement) {
|
|
148
|
+
case "check":
|
|
149
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.checkedTrackBackgroundColorOnDark : props.theme.checkedTrackBackgroundColor;
|
|
150
|
+
case "uncheck":
|
|
151
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.uncheckedTrackBackgroundColorOnDark : props.theme.uncheckedTrackBackgroundColor;
|
|
152
|
+
}
|
|
153
|
+
case "thumb":
|
|
154
|
+
switch (subelement) {
|
|
155
|
+
case "check":
|
|
156
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.checkedThumbBackgroundColorOnDark : props.theme.checkedThumbBackgroundColor;
|
|
157
|
+
case "uncheck":
|
|
158
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.uncheckedThumbBackgroundColorOnDark : props.theme.uncheckedThumbBackgroundColor;
|
|
159
|
+
}
|
|
160
|
+
case "label":
|
|
161
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
var SwitchContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n width: ", ";\n height: 40px;\n cursor: ", ";\n\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
117
165
|
return calculateWidth(props.margin, props.size);
|
|
118
166
|
}, function (props) {
|
|
119
|
-
return props.
|
|
167
|
+
return props.disabled === true ? "not-allowed" : "pointer";
|
|
120
168
|
}, function (props) {
|
|
121
169
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
122
170
|
}, function (props) {
|
|
@@ -127,53 +175,45 @@ var SwitchContainer = _styledComponents["default"].div(_templateObject || (_temp
|
|
|
127
175
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
128
176
|
}, function (props) {
|
|
129
177
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
178
|
+
});
|
|
179
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: ", ";\n opacity: 1;\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n\n ", ";\n\n ", "\n"])), function (props) {
|
|
180
|
+
return props.disabled ? getDisabledColor(props, "label") : getNotDisabledColor(props, "label");
|
|
130
181
|
}, function (props) {
|
|
131
|
-
return props.
|
|
132
|
-
}, function (props) {
|
|
133
|
-
return props.theme.trackWidth;
|
|
134
|
-
}, function (props) {
|
|
135
|
-
return "".concat(props.backgroundType === "dark" ? props.theme.thumbFocusColorOnDark : props.theme.thumbFocusColor, " solid 2px");
|
|
136
|
-
}, function (props) {
|
|
137
|
-
return props.backgroundType === "dark" ? props.theme.uncheckedTrackBackgroundColorOnDark : props.theme.uncheckedTrackBackgroundColor;
|
|
138
|
-
}, function (props) {
|
|
139
|
-
return props.theme.trackHeight;
|
|
140
|
-
}, function (props) {
|
|
141
|
-
return props.theme.thumbWidth;
|
|
182
|
+
return props.theme.labelFontFamily;
|
|
142
183
|
}, function (props) {
|
|
143
|
-
return props.theme.
|
|
184
|
+
return props.theme.labelFontSize;
|
|
144
185
|
}, function (props) {
|
|
145
|
-
return props.
|
|
186
|
+
return props.disabled ? props.theme.disabledLabelFontStyle : props.theme.labelFontStyle;
|
|
146
187
|
}, function (props) {
|
|
147
|
-
return props.
|
|
188
|
+
return props.theme.labelFontWeight;
|
|
148
189
|
}, function (props) {
|
|
149
|
-
return props.
|
|
190
|
+
return !props.label ? "margin: 0px;" : props.labelPosition === "after" ? "margin-left: ".concat(props.theme.spaceBetweenLabelSwitch, ";") : "margin-right: ".concat(props.theme.spaceBetweenLabelSwitch, ";");
|
|
150
191
|
}, function (props) {
|
|
151
|
-
return props.
|
|
192
|
+
return props.labelPosition === "before" && "order: -1";
|
|
193
|
+
});
|
|
194
|
+
var SwitchBase = _styledComponents["default"].label(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n cursor: pointer;\n margin: 0px 12px;\n"])));
|
|
195
|
+
var ValueInput = _styledComponents["default"].input(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
|
|
196
|
+
var SwitchTrack = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n border-radius: 15px;\n width: ", ";\n height: ", ";\n position: relative;\n cursor: ", ";\n\n &:focus-visible {\n outline: none;\n ::before {\n outline: ", ";\n outline-offset: 6px;\n }\n }\n\n /* Thumb element */\n ::before {\n content: \"\";\n transform: initial;\n position: absolute;\n width: ", ";\n height: ", ";\n border-radius: 50%;\n box-shadow: 0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%);\n bottom: -6px;\n left: -4px;\n transform: translateX(0px);\n background-color: ", ";\n }\n\n /* Unchecked */\n background-color: ", ";\n\n /* Checked */\n &[aria-checked=\"true\"] {\n background-color: ", ";\n ::before {\n transform: translateX(", ");\n background-color: ", ";\n }\n }\n"])), function (props) {
|
|
197
|
+
return props.theme.trackWidth;
|
|
152
198
|
}, function (props) {
|
|
153
|
-
return props.
|
|
199
|
+
return props.theme.trackHeight;
|
|
154
200
|
}, function (props) {
|
|
155
|
-
return props.
|
|
201
|
+
return props.disabled ? "not-allowed" : "pointer";
|
|
156
202
|
}, function (props) {
|
|
157
|
-
return props.theme.
|
|
203
|
+
return "".concat(props.backgroundType === "dark" ? props.theme.thumbFocusColorOnDark : props.theme.thumbFocusColor, " solid 2px");
|
|
158
204
|
}, function (props) {
|
|
159
|
-
return props.
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: ", ";\n opacity: 1;\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n cursor: ", ";\n ", "\n"])), function (props) {
|
|
163
|
-
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledLabelFontColorOnDark : props.theme.disabledLabelFontColor : props.backgroundType === "dark" ? props.theme.labelFontColorOnDark : props.theme.labelFontColor;
|
|
205
|
+
return props.theme.thumbWidth;
|
|
164
206
|
}, function (props) {
|
|
165
|
-
return props.theme.
|
|
207
|
+
return props.theme.thumbHeight;
|
|
166
208
|
}, function (props) {
|
|
167
|
-
return props.
|
|
209
|
+
return props.disabled ? getDisabledColor(props, "thumb", "uncheck") : getNotDisabledColor(props, "thumb", "uncheck");
|
|
168
210
|
}, function (props) {
|
|
169
|
-
return props.disabled ? props
|
|
211
|
+
return props.disabled ? getDisabledColor(props, "track", "uncheck") : getNotDisabledColor(props, "track", "uncheck");
|
|
170
212
|
}, function (props) {
|
|
171
|
-
return props.
|
|
213
|
+
return props.disabled ? getDisabledColor(props, "track", "check") : getNotDisabledColor(props, "track", "check");
|
|
172
214
|
}, function (props) {
|
|
173
|
-
return props.
|
|
215
|
+
return props.theme.thumbShift;
|
|
174
216
|
}, function (props) {
|
|
175
|
-
return props.
|
|
217
|
+
return props.disabled ? getDisabledColor(props, "thumb", "check") : getNotDisabledColor(props, "thumb", "check");
|
|
176
218
|
});
|
|
177
|
-
|
|
178
|
-
var _default = DxcSwitch;
|
|
179
|
-
exports["default"] = _default;
|
|
219
|
+
var _default = exports["default"] = DxcSwitch;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { userEvent, within } from "@storybook/testing-library";
|
|
3
2
|
import DxcSwitch from "./Switch";
|
|
4
|
-
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
5
3
|
import Title from "../../.storybook/components/Title";
|
|
6
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
7
|
-
import
|
|
5
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
8
6
|
|
|
9
7
|
export default {
|
|
10
8
|
title: "Switch",
|
|
11
9
|
component: DxcSwitch,
|
|
12
10
|
};
|
|
13
11
|
|
|
12
|
+
const opinionatedTheme = {
|
|
13
|
+
switch: {
|
|
14
|
+
checkedBaseColor: "#5f249f",
|
|
15
|
+
fontColor: "#000000",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
export const Chromatic = () => (
|
|
15
20
|
<>
|
|
16
21
|
<ExampleContainer>
|
|
@@ -21,58 +26,34 @@ export const Chromatic = () => (
|
|
|
21
26
|
<Title title="Without label" theme="light" level={4} />
|
|
22
27
|
<DxcSwitch />
|
|
23
28
|
</ExampleContainer>
|
|
29
|
+
<ExampleContainer pseudoState="pseudo-focus-visible">
|
|
30
|
+
<Title title="Focused" theme="light" level={4} />
|
|
31
|
+
<DxcSwitch label="Switch" labelPosition="after" />
|
|
32
|
+
</ExampleContainer>
|
|
24
33
|
<ExampleContainer>
|
|
25
34
|
<Title title="Checked" theme="light" level={4} />
|
|
26
|
-
<DxcSwitch label="Switch"
|
|
35
|
+
<DxcSwitch label="Switch" defaultChecked />
|
|
27
36
|
</ExampleContainer>
|
|
28
37
|
<ExampleContainer>
|
|
29
|
-
<Title title="
|
|
30
|
-
<DxcSwitch label="Switch"
|
|
38
|
+
<Title title="Optional" theme="light" level={4} />
|
|
39
|
+
<DxcSwitch label="Switch" optional />
|
|
31
40
|
</ExampleContainer>
|
|
32
41
|
<ExampleContainer>
|
|
33
42
|
<Title title="Disabled" theme="light" level={4} />
|
|
34
43
|
<DxcSwitch label="Switch" disabled />
|
|
35
44
|
</ExampleContainer>
|
|
36
45
|
<ExampleContainer>
|
|
37
|
-
<Title title="Disabled
|
|
38
|
-
<DxcSwitch label="Switch" disabled
|
|
46
|
+
<Title title="Disabled optional" theme="light" level={4} />
|
|
47
|
+
<DxcSwitch label="Switch" disabled optional labelPosition="after" />
|
|
39
48
|
</ExampleContainer>
|
|
40
49
|
<ExampleContainer>
|
|
41
50
|
<Title title="Disabled checked" theme="light" level={4} />
|
|
42
|
-
<DxcSwitch label="Switch" disabled
|
|
43
|
-
</ExampleContainer>
|
|
44
|
-
<BackgroundColorProvider color="#333333">
|
|
45
|
-
<DarkContainer>
|
|
46
|
-
<ExampleContainer>
|
|
47
|
-
<Title title="With label" theme="dark" level={4} />
|
|
48
|
-
<DxcSwitch label="Switch" />
|
|
49
|
-
</ExampleContainer>
|
|
50
|
-
<ExampleContainer>
|
|
51
|
-
<Title title="Checked" theme="dark" level={4} />
|
|
52
|
-
<DxcSwitch label="Switch" checked />
|
|
53
|
-
</ExampleContainer>
|
|
54
|
-
<ExampleContainer>
|
|
55
|
-
<Title title="Required" theme="dark" level={4} />
|
|
56
|
-
<DxcSwitch label="Switch" required />
|
|
57
|
-
</ExampleContainer>
|
|
58
|
-
<ExampleContainer>
|
|
59
|
-
<Title title="Disabled" theme="dark" level={4} />
|
|
60
|
-
<DxcSwitch label="Switch" disabled />
|
|
61
|
-
</ExampleContainer>
|
|
62
|
-
<ExampleContainer>
|
|
63
|
-
<Title title="Disabled required" theme="dark" level={4} />
|
|
64
|
-
<DxcSwitch label="Switch" disabled required labelPosition="after" />
|
|
65
|
-
</ExampleContainer>
|
|
66
|
-
<ExampleContainer>
|
|
67
|
-
<Title title="Disabled checked" theme="dark" level={4} />
|
|
68
|
-
<DxcSwitch label="Switch" disabled checked labelPosition="after" />
|
|
69
|
-
</ExampleContainer>
|
|
70
|
-
</DarkContainer>
|
|
71
|
-
</BackgroundColorProvider>
|
|
51
|
+
<DxcSwitch label="Switch" disabled defaultChecked labelPosition="after" />
|
|
52
|
+
</ExampleContainer>
|
|
72
53
|
<Title title="Margins" theme="light" level={2} />
|
|
73
54
|
<ExampleContainer>
|
|
74
55
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
75
|
-
<DxcSwitch label="
|
|
56
|
+
<DxcSwitch label="Xxsmall" margin="xxsmall" />
|
|
76
57
|
</ExampleContainer>
|
|
77
58
|
<ExampleContainer>
|
|
78
59
|
<Title title="Xsmall margin" theme="light" level={4} />
|
|
@@ -127,34 +108,30 @@ export const Chromatic = () => (
|
|
|
127
108
|
<Title title="FitContent size" theme="light" level={4} />
|
|
128
109
|
<DxcSwitch label="FitContent" size="fitContent" />
|
|
129
110
|
</ExampleContainer>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
FocusedSwitch.play = async ({ canvasElement }) => {
|
|
141
|
-
const canvas = within(canvasElement);
|
|
142
|
-
canvas.getByRole("checkbox").focus();
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const DarkSwitch = () => (
|
|
146
|
-
<BackgroundColorProvider color="#333333">
|
|
147
|
-
<DarkContainer>
|
|
148
|
-
<ExampleContainer>
|
|
149
|
-
<Title title="Focused" theme="dark" level={4} />
|
|
111
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
112
|
+
<ExampleContainer>
|
|
113
|
+
<Title title="Checked" theme="light" level={4} />
|
|
114
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
115
|
+
<DxcSwitch label="Switch" defaultChecked />
|
|
116
|
+
</HalstackProvider>
|
|
117
|
+
</ExampleContainer>
|
|
118
|
+
<ExampleContainer>
|
|
119
|
+
<Title title="Default" theme="light" level={4} />
|
|
120
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
150
121
|
<DxcSwitch label="Switch" />
|
|
151
|
-
</
|
|
152
|
-
</
|
|
153
|
-
|
|
122
|
+
</HalstackProvider>
|
|
123
|
+
</ExampleContainer>
|
|
124
|
+
<ExampleContainer>
|
|
125
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
126
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
127
|
+
<DxcSwitch label="Switch" disabled />
|
|
128
|
+
</HalstackProvider>
|
|
129
|
+
</ExampleContainer>
|
|
130
|
+
<ExampleContainer>
|
|
131
|
+
<Title title="Disabled checked" theme="light" level={4} />
|
|
132
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
133
|
+
<DxcSwitch label="Switch" disabled defaultChecked />
|
|
134
|
+
</HalstackProvider>
|
|
135
|
+
</ExampleContainer>
|
|
136
|
+
</>
|
|
154
137
|
);
|
|
155
|
-
|
|
156
|
-
export const FocusedSwitchOnDark = DarkSwitch.bind({});
|
|
157
|
-
FocusedSwitchOnDark.play = async ({ canvasElement }) => {
|
|
158
|
-
const canvas = within(canvasElement);
|
|
159
|
-
canvas.getByRole("checkbox").focus();
|
|
160
|
-
};
|