@dxc-technology/halstack-react 11.0.0 → 12.0.1
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 +1 -10
- package/BackgroundColorContext.js +3 -8
- package/HalstackContext.d.ts +32 -145
- package/HalstackContext.js +3 -7
- package/accordion/Accordion.accessibility.test.d.ts +1 -0
- package/accordion/Accordion.accessibility.test.js +71 -0
- package/accordion/Accordion.js +18 -35
- package/accordion/Accordion.stories.tsx +7 -49
- package/accordion/Accordion.test.d.ts +1 -0
- package/accordion/Accordion.test.js +3 -3
- package/accordion/types.d.ts +1 -1
- package/accordion-group/AccordionGroup.accessibility.test.d.ts +1 -0
- package/accordion-group/AccordionGroup.accessibility.test.js +82 -0
- package/accordion-group/AccordionGroup.d.ts +2 -3
- package/accordion-group/AccordionGroup.js +4 -4
- package/accordion-group/AccordionGroup.stories.tsx +23 -23
- package/accordion-group/AccordionGroup.test.d.ts +1 -0
- package/accordion-group/AccordionGroup.test.js +5 -9
- package/accordion-group/AccordionGroupAccordion.js +3 -3
- package/accordion-group/AccordionGroupContext.d.ts +3 -0
- package/accordion-group/AccordionGroupContext.js +8 -0
- package/accordion-group/types.d.ts +1 -1
- package/action-icon/ActionIcon.accessibility.test.d.ts +1 -0
- package/action-icon/ActionIcon.accessibility.test.js +63 -0
- package/action-icon/ActionIcon.d.ts +4 -0
- package/action-icon/ActionIcon.js +48 -0
- package/action-icon/ActionIcon.stories.tsx +41 -0
- package/action-icon/ActionIcon.test.d.ts +1 -0
- package/action-icon/ActionIcon.test.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/action-icon/types.js +5 -0
- package/alert/Alert.accessibility.test.d.ts +1 -0
- package/alert/Alert.accessibility.test.js +95 -0
- package/alert/Alert.js +21 -75
- package/alert/Alert.test.d.ts +1 -0
- package/alert/Alert.test.js +1 -1
- package/badge/Badge.accessibility.test.d.ts +1 -0
- package/badge/Badge.accessibility.test.js +129 -0
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +141 -28
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.d.ts +1 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -3
- package/box/Box.accessibility.test.d.ts +1 -0
- package/box/Box.accessibility.test.js +33 -0
- package/box/Box.js +2 -5
- package/box/Box.test.d.ts +1 -0
- package/box/Box.test.js +1 -1
- package/breadcrumbs/Breadcrumbs.accessibility.test.d.ts +1 -0
- package/breadcrumbs/Breadcrumbs.accessibility.test.js +96 -0
- package/breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/breadcrumbs/Breadcrumbs.js +79 -0
- package/breadcrumbs/Breadcrumbs.stories.tsx +194 -0
- package/breadcrumbs/Breadcrumbs.test.d.ts +1 -0
- package/breadcrumbs/Breadcrumbs.test.js +169 -0
- package/breadcrumbs/Item.d.ts +4 -0
- package/breadcrumbs/Item.js +52 -0
- package/breadcrumbs/dropdownTheme.d.ts +53 -0
- package/breadcrumbs/dropdownTheme.js +62 -0
- package/breadcrumbs/types.d.ts +16 -0
- package/breadcrumbs/types.js +5 -0
- package/bulleted-list/BulletedList.accessibility.test.d.ts +1 -0
- package/bulleted-list/BulletedList.accessibility.test.js +119 -0
- package/bulleted-list/BulletedList.js +16 -23
- package/bulleted-list/BulletedList.stories.tsx +1 -2
- package/button/Button.accessibility.test.d.ts +1 -0
- package/button/Button.accessibility.test.js +127 -0
- package/button/Button.js +16 -16
- package/button/Button.stories.tsx +34 -53
- package/button/Button.test.d.ts +1 -0
- package/button/Button.test.js +4 -2
- package/button/types.d.ts +1 -1
- package/card/Card.accessibility.test.d.ts +1 -0
- package/card/Card.accessibility.test.js +36 -0
- package/card/Card.js +3 -2
- package/card/Card.test.d.ts +1 -0
- package/card/Card.test.js +1 -1
- package/checkbox/Checkbox.accessibility.test.d.ts +1 -0
- package/checkbox/Checkbox.accessibility.test.js +87 -0
- package/checkbox/Checkbox.js +36 -44
- package/checkbox/Checkbox.test.d.ts +1 -0
- package/checkbox/Checkbox.test.js +1 -1
- package/chip/Chip.accessibility.test.d.ts +1 -0
- package/chip/Chip.accessibility.test.js +69 -0
- package/chip/Chip.js +20 -26
- package/chip/Chip.stories.tsx +67 -50
- package/chip/Chip.test.d.ts +1 -0
- package/chip/Chip.test.js +5 -5
- package/chip/types.d.ts +35 -12
- package/common/coreTokens.d.ts +105 -14
- package/common/coreTokens.js +40 -22
- package/common/fonts.css +2 -0
- package/common/variables.d.ts +31 -141
- package/common/variables.js +104 -214
- package/container/Container.d.ts +4 -0
- package/container/Container.js +194 -0
- package/container/Container.stories.tsx +214 -0
- package/container/types.d.ts +74 -0
- package/container/types.js +5 -0
- package/contextual-menu/ContextualMenu.accessibility.test.d.ts +1 -0
- package/contextual-menu/ContextualMenu.accessibility.test.js +98 -0
- package/contextual-menu/ContextualMenu.d.ts +5 -0
- package/contextual-menu/ContextualMenu.js +88 -0
- package/contextual-menu/ContextualMenu.stories.tsx +232 -0
- package/contextual-menu/ContextualMenu.test.d.ts +1 -0
- package/contextual-menu/ContextualMenu.test.js +205 -0
- package/contextual-menu/GroupItem.d.ts +4 -0
- package/contextual-menu/GroupItem.js +67 -0
- package/contextual-menu/ItemAction.d.ts +4 -0
- package/contextual-menu/ItemAction.js +51 -0
- package/contextual-menu/MenuItem.d.ts +4 -0
- package/contextual-menu/MenuItem.js +29 -0
- package/contextual-menu/SingleItem.d.ts +4 -0
- package/contextual-menu/SingleItem.js +38 -0
- package/contextual-menu/types.d.ts +58 -0
- package/contextual-menu/types.js +5 -0
- package/date-input/Calendar.js +1 -1
- package/date-input/DateInput.accessibility.test.d.ts +1 -0
- package/date-input/DateInput.accessibility.test.js +230 -0
- package/date-input/DateInput.js +19 -20
- package/date-input/DateInput.stories.tsx +15 -8
- package/date-input/DateInput.test.d.ts +1 -0
- package/date-input/DateInput.test.js +9 -8
- package/date-input/DatePicker.js +13 -7
- package/date-input/YearPicker.js +1 -1
- package/date-input/types.d.ts +2 -2
- package/dialog/Dialog.accessibility.test.d.ts +1 -0
- package/dialog/Dialog.accessibility.test.js +69 -0
- package/dialog/Dialog.js +11 -25
- package/dialog/Dialog.stories.tsx +175 -0
- package/dialog/Dialog.test.d.ts +1 -0
- package/dialog/Dialog.test.js +113 -49
- package/divider/Divider.accessibility.test.d.ts +1 -0
- package/divider/Divider.accessibility.test.js +33 -0
- package/divider/Divider.d.ts +4 -0
- package/divider/Divider.js +36 -0
- package/divider/Divider.stories.tsx +223 -0
- package/divider/Divider.test.d.ts +1 -0
- package/divider/Divider.test.js +38 -0
- package/divider/types.d.ts +21 -0
- package/divider/types.js +5 -0
- package/dropdown/Dropdown.accessibility.test.d.ts +1 -0
- package/dropdown/Dropdown.accessibility.test.js +184 -0
- package/dropdown/Dropdown.js +37 -51
- package/dropdown/Dropdown.stories.tsx +15 -26
- package/dropdown/Dropdown.test.d.ts +1 -0
- package/dropdown/Dropdown.test.js +100 -70
- package/dropdown/DropdownMenu.js +4 -4
- package/dropdown/DropdownMenuItem.js +8 -4
- package/dropdown/types.d.ts +3 -5
- package/file-input/FileInput.accessibility.test.d.ts +1 -0
- package/file-input/FileInput.accessibility.test.js +167 -0
- package/file-input/FileInput.js +127 -145
- package/file-input/FileInput.test.d.ts +1 -0
- package/file-input/FileInput.test.js +125 -129
- package/file-input/FileItem.js +18 -28
- package/file-input/types.d.ts +1 -1
- package/footer/Footer.accessibility.test.d.ts +1 -0
- package/footer/Footer.accessibility.test.js +125 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +36 -31
- package/footer/Footer.stories.tsx +58 -2
- package/footer/Footer.test.d.ts +1 -0
- package/footer/Footer.test.js +1 -1
- package/footer/Icons.d.ts +1 -0
- package/footer/Icons.js +52 -16
- package/footer/types.d.ts +8 -8
- package/header/Header.accessibility.test.d.ts +1 -0
- package/header/Header.accessibility.test.js +94 -0
- package/header/Header.js +20 -41
- package/header/Header.stories.tsx +16 -0
- package/header/Header.test.d.ts +1 -0
- package/header/Header.test.js +1 -1
- package/header/Icons.js +1 -6
- package/header/types.d.ts +4 -3
- package/heading/Heading.accessibility.test.d.ts +1 -0
- package/heading/Heading.accessibility.test.js +33 -0
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.d.ts +1 -0
- package/heading/Heading.test.js +1 -14
- package/icon/Icon.accessibility.test.d.ts +1 -0
- package/icon/Icon.accessibility.test.js +30 -0
- package/icon/Icon.d.ts +4 -0
- package/icon/Icon.js +33 -0
- package/icon/Icon.stories.tsx +28 -0
- package/icon/types.d.ts +4 -0
- package/icon/types.js +5 -0
- package/image/Image.accessibility.test.d.ts +1 -0
- package/image/Image.accessibility.test.js +56 -0
- package/image/Image.js +1 -1
- package/image/Image.stories.tsx +3 -1
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +10 -7
- package/layout/Icons.d.ts +0 -1
- package/layout/Icons.js +1 -11
- package/link/Link.accessibility.test.d.ts +1 -0
- package/link/Link.accessibility.test.js +108 -0
- package/link/Link.js +8 -6
- package/link/Link.stories.tsx +4 -4
- package/link/Link.test.d.ts +1 -0
- package/link/Link.test.js +1 -1
- package/link/types.d.ts +1 -1
- package/main.d.ts +8 -3
- package/main.js +38 -9
- package/nav-tabs/NavTabs.accessibility.test.d.ts +1 -0
- package/nav-tabs/NavTabs.accessibility.test.js +44 -0
- package/nav-tabs/NavTabs.d.ts +1 -2
- package/nav-tabs/NavTabs.js +25 -7
- package/nav-tabs/NavTabs.stories.tsx +44 -24
- package/nav-tabs/NavTabs.test.d.ts +1 -0
- package/nav-tabs/NavTabs.test.js +12 -10
- package/nav-tabs/NavTabsContext.d.ts +3 -0
- package/nav-tabs/NavTabsContext.js +8 -0
- package/nav-tabs/Tab.js +23 -23
- package/nav-tabs/types.d.ts +1 -1
- package/number-input/NumberInput.accessibility.test.d.ts +1 -0
- package/number-input/NumberInput.accessibility.test.js +228 -0
- package/number-input/NumberInput.d.ts +0 -7
- package/number-input/NumberInput.js +24 -5
- package/number-input/NumberInput.test.d.ts +1 -0
- package/number-input/NumberInput.test.js +166 -7
- package/number-input/NumberInputContext.d.ts +3 -0
- package/number-input/NumberInputContext.js +8 -0
- package/number-input/types.d.ts +6 -0
- package/package.json +20 -18
- package/paginator/Paginator.accessibility.test.d.ts +1 -0
- package/paginator/Paginator.accessibility.test.js +79 -0
- package/paginator/Paginator.js +14 -14
- package/paginator/Paginator.test.d.ts +1 -0
- package/paginator/Paginator.test.js +1 -1
- package/paragraph/Paragraph.accessibility.test.d.ts +1 -0
- package/paragraph/Paragraph.accessibility.test.js +28 -0
- package/paragraph/Paragraph.js +2 -7
- package/password-input/PasswordInput.accessibility.test.d.ts +1 -0
- package/password-input/PasswordInput.accessibility.test.js +153 -0
- package/password-input/PasswordInput.js +7 -7
- package/password-input/PasswordInput.stories.tsx +0 -1
- package/password-input/PasswordInput.test.d.ts +1 -0
- package/password-input/PasswordInput.test.js +5 -5
- package/progress-bar/ProgressBar.accessibility.test.d.ts +1 -0
- package/progress-bar/ProgressBar.accessibility.test.js +35 -0
- package/progress-bar/ProgressBar.js +11 -15
- package/progress-bar/ProgressBar.test.d.ts +1 -0
- package/progress-bar/ProgressBar.test.js +1 -1
- package/quick-nav/QuickNav.accessibility.test.d.ts +1 -0
- package/quick-nav/QuickNav.accessibility.test.js +57 -0
- package/quick-nav/QuickNav.js +1 -1
- package/radio-group/Radio.js +6 -9
- package/radio-group/RadioGroup.accessibility.test.d.ts +1 -0
- package/radio-group/RadioGroup.accessibility.test.js +97 -0
- package/radio-group/RadioGroup.js +15 -17
- package/radio-group/RadioGroup.test.d.ts +1 -0
- package/radio-group/RadioGroup.test.js +3 -5
- package/resultset-table/ResultsetTable.accessibility.test.d.ts +1 -0
- package/resultset-table/ResultsetTable.accessibility.test.js +285 -0
- package/resultset-table/ResultsetTable.d.ts +4 -1
- package/resultset-table/ResultsetTable.js +25 -13
- package/resultset-table/ResultsetTable.stories.tsx +118 -5
- package/resultset-table/ResultsetTable.test.d.ts +1 -0
- package/resultset-table/ResultsetTable.test.js +76 -1
- package/resultset-table/types.d.ts +40 -7
- package/select/Listbox.js +24 -16
- package/select/Option.js +19 -10
- package/select/Select.accessibility.test.d.ts +1 -0
- package/select/Select.accessibility.test.js +228 -0
- package/select/Select.js +72 -54
- package/select/Select.stories.tsx +59 -111
- package/select/Select.test.d.ts +1 -0
- package/select/Select.test.js +393 -459
- package/select/types.d.ts +3 -3
- package/sidenav/Sidenav.accessibility.test.d.ts +1 -0
- package/sidenav/Sidenav.accessibility.test.js +59 -0
- package/sidenav/Sidenav.js +21 -19
- package/sidenav/Sidenav.stories.tsx +4 -9
- package/sidenav/Sidenav.test.d.ts +1 -0
- package/sidenav/Sidenav.test.js +1 -1
- package/sidenav/types.d.ts +2 -2
- package/slider/Slider.accessibility.test.d.ts +1 -0
- package/slider/Slider.accessibility.test.js +104 -0
- package/slider/Slider.js +31 -42
- package/slider/Slider.stories.tsx +180 -0
- package/slider/Slider.test.d.ts +1 -0
- package/slider/Slider.test.js +12 -9
- package/spinner/Spinner.accessibility.test.d.ts +1 -0
- package/spinner/Spinner.accessibility.test.js +96 -0
- package/spinner/Spinner.js +12 -16
- package/spinner/Spinner.test.d.ts +1 -0
- package/spinner/Spinner.test.js +1 -1
- package/status-light/StatusLight.accessibility.test.d.ts +1 -0
- package/status-light/StatusLight.accessibility.test.js +157 -0
- package/status-light/StatusLight.d.ts +4 -0
- package/status-light/StatusLight.js +51 -0
- package/status-light/StatusLight.stories.tsx +74 -0
- package/status-light/StatusLight.test.d.ts +1 -0
- package/status-light/StatusLight.test.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/switch/Switch.accessibility.test.d.ts +1 -0
- package/switch/Switch.accessibility.test.js +98 -0
- package/switch/Switch.js +29 -37
- package/switch/Switch.stories.tsx +12 -0
- package/switch/Switch.test.d.ts +1 -0
- package/switch/Switch.test.js +1 -1
- package/table/DropdownTheme.js +62 -0
- package/table/Table.accessibility.test.d.ts +1 -0
- package/table/Table.accessibility.test.js +93 -0
- package/table/Table.d.ts +6 -2
- package/table/Table.js +74 -12
- package/table/Table.stories.tsx +309 -2
- package/table/Table.test.d.ts +1 -0
- package/table/Table.test.js +92 -1
- package/table/types.d.ts +28 -0
- package/tabs/Tab.js +13 -9
- package/tabs/Tabs.accessibility.test.d.ts +1 -0
- package/tabs/Tabs.accessibility.test.js +56 -0
- package/tabs/Tabs.js +12 -24
- package/tabs/Tabs.stories.tsx +8 -4
- package/tabs/Tabs.test.d.ts +1 -0
- package/tabs/Tabs.test.js +20 -38
- package/tabs/types.d.ts +2 -2
- package/tag/Tag.accessibility.test.d.ts +1 -0
- package/tag/Tag.accessibility.test.js +69 -0
- package/tag/Tag.js +7 -7
- package/tag/Tag.stories.tsx +4 -7
- package/tag/Tag.test.d.ts +1 -0
- package/tag/Tag.test.js +5 -13
- package/tag/types.d.ts +2 -2
- package/text-input/Suggestion.js +1 -1
- package/text-input/Suggestions.js +19 -14
- package/text-input/TextInput.accessibility.test.d.ts +1 -0
- package/text-input/TextInput.accessibility.test.js +321 -0
- package/text-input/TextInput.js +103 -126
- package/text-input/TextInput.stories.tsx +17 -8
- package/text-input/TextInput.test.d.ts +1 -0
- package/text-input/TextInput.test.js +97 -80
- package/textarea/Textarea.accessibility.test.d.ts +1 -0
- package/textarea/Textarea.accessibility.test.js +155 -0
- package/textarea/Textarea.js +13 -21
- package/textarea/Textarea.stories.tsx +0 -1
- package/textarea/Textarea.test.d.ts +1 -0
- package/textarea/Textarea.test.js +1 -1
- package/toggle-group/ToggleGroup.accessibility.test.d.ts +1 -0
- package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
- package/toggle-group/ToggleGroup.js +11 -16
- package/toggle-group/ToggleGroup.stories.tsx +3 -3
- package/toggle-group/ToggleGroup.test.d.ts +1 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/toggle-group/types.d.ts +2 -2
- package/typography/Typography.accessibility.test.d.ts +1 -0
- package/typography/Typography.accessibility.test.js +339 -0
- package/useTheme.d.ts +31 -141
- package/utils/BaseTypography.js +1 -1
- package/utils/FocusLock.js +16 -6
- package/wizard/Wizard.accessibility.test.d.ts +1 -0
- package/wizard/Wizard.accessibility.test.js +55 -0
- package/wizard/Wizard.js +14 -25
- package/wizard/Wizard.stories.tsx +19 -0
- package/wizard/Wizard.test.d.ts +1 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +2 -2
- package/common/OpenSans.css +0 -69
- package/common/fonts/OpenSans-Bold.ttf +0 -0
- package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
- package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- package/common/fonts/OpenSans-Italic.ttf +0 -0
- package/common/fonts/OpenSans-Light.ttf +0 -0
- package/common/fonts/OpenSans-LightItalic.ttf +0 -0
- package/common/fonts/OpenSans-Regular.ttf +0 -0
- package/common/fonts/OpenSans-SemiBold.ttf +0 -0
- package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
- package/date-input/Icons.d.ts +0 -6
- package/date-input/Icons.js +0 -58
- package/paginator/Icons.d.ts +0 -5
- package/paginator/Icons.js +0 -40
- package/password-input/Icons.d.ts +0 -6
- package/password-input/Icons.js +0 -35
- package/select/Icons.d.ts +0 -10
- package/select/Icons.js +0 -89
- package/sidenav/Icons.d.ts +0 -7
- package/sidenav/Icons.js +0 -47
- package/text-input/Icons.d.ts +0 -8
- package/text-input/Icons.js +0 -56
- /package/{layout → sidenav}/SidenavContext.d.ts +0 -0
- /package/{layout → sidenav}/SidenavContext.js +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
var _coreTokens = _interopRequireDefault(require("../common/coreTokens"));
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
13
|
+
var DxcStatusLight = function DxcStatusLight(_ref) {
|
|
14
|
+
var _ref$mode = _ref.mode,
|
|
15
|
+
mode = _ref$mode === void 0 ? "default" : _ref$mode,
|
|
16
|
+
label = _ref.label,
|
|
17
|
+
_ref$size = _ref.size,
|
|
18
|
+
size = _ref$size === void 0 ? "medium" : _ref$size;
|
|
19
|
+
return /*#__PURE__*/_react["default"].createElement(StatusLightContainer, {
|
|
20
|
+
size: size,
|
|
21
|
+
"aria-label": "".concat(mode, ": ").concat(label),
|
|
22
|
+
"data-testid": "status_light-container"
|
|
23
|
+
}, /*#__PURE__*/_react["default"].createElement(StatusDot, {
|
|
24
|
+
mode: mode,
|
|
25
|
+
size: size,
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
"data-testid": "status-dot"
|
|
28
|
+
}), /*#__PURE__*/_react["default"].createElement(StatusLabel, {
|
|
29
|
+
mode: mode,
|
|
30
|
+
size: size
|
|
31
|
+
}, label));
|
|
32
|
+
};
|
|
33
|
+
var StatusLightContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n gap: ", ";\n"])), _coreTokens["default"].spacing_8);
|
|
34
|
+
var StatusDot = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n border-radius: 50%;\n background-color: ", ";\n"])), function (_ref2) {
|
|
35
|
+
var size = _ref2.size;
|
|
36
|
+
return size === "small" && _coreTokens["default"].type_scale_01 || size === "medium" && _coreTokens["default"].type_scale_02 || size === "large" && _coreTokens["default"].type_scale_03 || _coreTokens["default"].type_scale_02;
|
|
37
|
+
}, function (_ref3) {
|
|
38
|
+
var size = _ref3.size;
|
|
39
|
+
return size === "small" && _coreTokens["default"].type_scale_01 || size === "medium" && _coreTokens["default"].type_scale_02 || size === "large" && _coreTokens["default"].type_scale_03 || _coreTokens["default"].type_scale_02;
|
|
40
|
+
}, function (_ref4) {
|
|
41
|
+
var mode = _ref4.mode;
|
|
42
|
+
return mode === "default" && _coreTokens["default"].color_grey_700 || mode === "error" && _coreTokens["default"].color_red_700 || mode === "info" && _coreTokens["default"].color_blue_700 || mode === "success" && _coreTokens["default"].color_green_700 || mode === "warning" && _coreTokens["default"].color_orange_700 || _coreTokens["default"].color_grey_700;
|
|
43
|
+
});
|
|
44
|
+
var StatusLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n color: ", ";\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n"])), function (_ref5) {
|
|
45
|
+
var size = _ref5.size;
|
|
46
|
+
return size === "small" && _coreTokens["default"].type_scale_01 || size === "medium" && _coreTokens["default"].type_scale_02 || size === "large" && _coreTokens["default"].type_scale_03 || _coreTokens["default"].type_scale_02;
|
|
47
|
+
}, _coreTokens["default"].type_sans, _coreTokens["default"].type_normal, _coreTokens["default"].type_semibold, function (_ref6) {
|
|
48
|
+
var mode = _ref6.mode;
|
|
49
|
+
return mode === "default" && _coreTokens["default"].color_grey_700 || mode === "error" && _coreTokens["default"].color_red_700 || mode === "info" && _coreTokens["default"].color_blue_700 || mode === "success" && _coreTokens["default"].color_green_700 || mode === "warning" && _coreTokens["default"].color_orange_700 || _coreTokens["default"].color_grey_700;
|
|
50
|
+
});
|
|
51
|
+
var _default = exports["default"] = DxcStatusLight;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
4
|
+
import DxcStatusLight from "./StatusLight";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "Status Light",
|
|
8
|
+
component: DxcStatusLight,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const Chromatic = () => (
|
|
12
|
+
<>
|
|
13
|
+
<ExampleContainer>
|
|
14
|
+
<Title title="Default light small" theme="light" level={4} />
|
|
15
|
+
<DxcStatusLight label="StatusLight" size="small" />
|
|
16
|
+
</ExampleContainer>
|
|
17
|
+
<ExampleContainer>
|
|
18
|
+
<Title title="Default light medium" theme="light" level={4} />
|
|
19
|
+
<DxcStatusLight label="StatusLight" />
|
|
20
|
+
</ExampleContainer>
|
|
21
|
+
<ExampleContainer>
|
|
22
|
+
<Title title="Default light large" theme="light" level={4} />
|
|
23
|
+
<DxcStatusLight label="StatusLight" size="large" />
|
|
24
|
+
</ExampleContainer>
|
|
25
|
+
<ExampleContainer>
|
|
26
|
+
<Title title="Info light small" theme="light" level={4} />
|
|
27
|
+
<DxcStatusLight label="StatusLight" mode="info" size="small" />
|
|
28
|
+
</ExampleContainer>
|
|
29
|
+
<ExampleContainer>
|
|
30
|
+
<Title title="Info light medium" theme="light" level={4} />
|
|
31
|
+
<DxcStatusLight label="StatusLight" mode="info" />
|
|
32
|
+
</ExampleContainer>
|
|
33
|
+
<ExampleContainer>
|
|
34
|
+
<Title title="Info light large" theme="light" level={4} />
|
|
35
|
+
<DxcStatusLight label="StatusLight" mode="info" size="large" />
|
|
36
|
+
</ExampleContainer>
|
|
37
|
+
<ExampleContainer>
|
|
38
|
+
<Title title="Success light small" theme="light" level={4} />
|
|
39
|
+
<DxcStatusLight label="StatusLight" mode="success" size="small" />
|
|
40
|
+
</ExampleContainer>
|
|
41
|
+
<ExampleContainer>
|
|
42
|
+
<Title title="Success lights medium" theme="light" level={4} />
|
|
43
|
+
<DxcStatusLight label="StatusLight" mode="success" />
|
|
44
|
+
</ExampleContainer>
|
|
45
|
+
<ExampleContainer>
|
|
46
|
+
<Title title="Success lights large" theme="light" level={4} />
|
|
47
|
+
<DxcStatusLight label="StatusLight" mode="success" size="large" />
|
|
48
|
+
</ExampleContainer>
|
|
49
|
+
<ExampleContainer>
|
|
50
|
+
<Title title="Warning light small" theme="light" level={4} />
|
|
51
|
+
<DxcStatusLight label="StatusLight" mode="warning" size="small" />
|
|
52
|
+
</ExampleContainer>
|
|
53
|
+
<ExampleContainer>
|
|
54
|
+
<Title title="Warning light medium" theme="light" level={4} />
|
|
55
|
+
<DxcStatusLight label="StatusLight" mode="warning" />
|
|
56
|
+
</ExampleContainer>
|
|
57
|
+
<ExampleContainer>
|
|
58
|
+
<Title title="Warning light large" theme="light" level={4} />
|
|
59
|
+
<DxcStatusLight label="StatusLight" mode="warning" size="large" />
|
|
60
|
+
</ExampleContainer>
|
|
61
|
+
<ExampleContainer>
|
|
62
|
+
<Title title="Error light small" theme="light" level={4} />
|
|
63
|
+
<DxcStatusLight label="StatusLight" mode="error" size="small" />
|
|
64
|
+
</ExampleContainer>
|
|
65
|
+
<ExampleContainer>
|
|
66
|
+
<Title title="Error lights medium" theme="light" level={4} />
|
|
67
|
+
<DxcStatusLight label="StatusLight" mode="error" />
|
|
68
|
+
</ExampleContainer>
|
|
69
|
+
<ExampleContainer>
|
|
70
|
+
<Title title="Error lights large" theme="light" level={4} />
|
|
71
|
+
<DxcStatusLight label="StatusLight" mode="error" size="large" />
|
|
72
|
+
</ExampleContainer>
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 _StatusLight = _interopRequireDefault(require("./StatusLight"));
|
|
7
|
+
describe("StatusLight component tests", function () {
|
|
8
|
+
test("StatusLight renders with correct label", function () {
|
|
9
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_StatusLight["default"], {
|
|
10
|
+
label: "Status Light Test"
|
|
11
|
+
})),
|
|
12
|
+
getByText = _render.getByText;
|
|
13
|
+
expect(getByText("Status Light Test")).toBeTruthy();
|
|
14
|
+
});
|
|
15
|
+
test("StatusLight applies accessibility attributes", function () {
|
|
16
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_StatusLight["default"], {
|
|
17
|
+
label: "Status Light Test"
|
|
18
|
+
})),
|
|
19
|
+
getByTestId = _render2.getByTestId;
|
|
20
|
+
var statusLightContainer = getByTestId("status_light-container");
|
|
21
|
+
var statusDot = getByTestId("status-dot");
|
|
22
|
+
expect(statusLightContainer.getAttribute("aria-label")).toBe("default: Status Light Test");
|
|
23
|
+
expect(statusDot.getAttribute("aria-hidden")).toBe("true");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type Mode = "default" | "info" | "success" | "warning" | "error";
|
|
2
|
+
type Size = "small" | "medium" | "large";
|
|
3
|
+
type Props = {
|
|
4
|
+
/**
|
|
5
|
+
* It will define the color of the light based on its semantic meaning.
|
|
6
|
+
*/
|
|
7
|
+
mode?: Mode;
|
|
8
|
+
/**
|
|
9
|
+
* An auxiliar text that will add some context to the status.
|
|
10
|
+
*/
|
|
11
|
+
label: string;
|
|
12
|
+
/**
|
|
13
|
+
* Size of the component. Should be defined based on its importance and/or available space.
|
|
14
|
+
*/
|
|
15
|
+
size?: Size;
|
|
16
|
+
};
|
|
17
|
+
export default Props;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
5
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
var _axeHelper = require("../../test/accessibility/axe-helper.js");
|
|
9
|
+
var _Switch = _interopRequireDefault(require("./Switch"));
|
|
10
|
+
var _disabledRules = require("../../test/accessibility/rules/specific/switch/disabledRules.js");
|
|
11
|
+
var disabledRules = {
|
|
12
|
+
rules: _disabledRules.disabledRules.reduce(function (rulesObj, rule) {
|
|
13
|
+
rulesObj[rule] = {
|
|
14
|
+
enabled: false
|
|
15
|
+
};
|
|
16
|
+
return rulesObj;
|
|
17
|
+
}, {})
|
|
18
|
+
};
|
|
19
|
+
describe("Switch component accessibility tests", function () {
|
|
20
|
+
it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
21
|
+
var _render, container, results;
|
|
22
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
|
|
26
|
+
label: "Default label",
|
|
27
|
+
defaultChecked: true,
|
|
28
|
+
value: "test-defaultChecked",
|
|
29
|
+
name: "test",
|
|
30
|
+
labelPosition: "after",
|
|
31
|
+
margin: "medium",
|
|
32
|
+
size: "medium",
|
|
33
|
+
checked: true
|
|
34
|
+
})), container = _render.container;
|
|
35
|
+
_context.next = 3;
|
|
36
|
+
return (0, _axeHelper.axe)(container, disabledRules);
|
|
37
|
+
case 3:
|
|
38
|
+
results = _context.sent;
|
|
39
|
+
expect(results).toHaveNoViolations();
|
|
40
|
+
case 5:
|
|
41
|
+
case "end":
|
|
42
|
+
return _context.stop();
|
|
43
|
+
}
|
|
44
|
+
}, _callee);
|
|
45
|
+
})));
|
|
46
|
+
it("Should not have basic accessibility issues for optional mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
47
|
+
var _render2, container, results;
|
|
48
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
49
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
|
|
52
|
+
label: "Default label",
|
|
53
|
+
defaultChecked: true,
|
|
54
|
+
value: "test-defaultChecked",
|
|
55
|
+
name: "test",
|
|
56
|
+
labelPosition: "after",
|
|
57
|
+
margin: "medium",
|
|
58
|
+
size: "medium",
|
|
59
|
+
optional: true
|
|
60
|
+
})), container = _render2.container;
|
|
61
|
+
_context2.next = 3;
|
|
62
|
+
return (0, _axeHelper.axe)(container, disabledRules);
|
|
63
|
+
case 3:
|
|
64
|
+
results = _context2.sent;
|
|
65
|
+
expect(results).toHaveNoViolations();
|
|
66
|
+
case 5:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context2.stop();
|
|
69
|
+
}
|
|
70
|
+
}, _callee2);
|
|
71
|
+
})));
|
|
72
|
+
it("Should not have basic accessibility issues for disabled mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
73
|
+
var _render3, container, results;
|
|
74
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
75
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
_render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
|
|
78
|
+
label: "Default label",
|
|
79
|
+
defaultChecked: true,
|
|
80
|
+
value: "test-defaultChecked",
|
|
81
|
+
name: "test",
|
|
82
|
+
labelPosition: "after",
|
|
83
|
+
margin: "medium",
|
|
84
|
+
size: "medium",
|
|
85
|
+
disabled: true
|
|
86
|
+
})), container = _render3.container;
|
|
87
|
+
_context3.next = 3;
|
|
88
|
+
return (0, _axeHelper.axe)(container, disabledRules);
|
|
89
|
+
case 3:
|
|
90
|
+
results = _context3.sent;
|
|
91
|
+
expect(results).toHaveNoViolations();
|
|
92
|
+
case 5:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context3.stop();
|
|
95
|
+
}
|
|
96
|
+
}, _callee3);
|
|
97
|
+
})));
|
|
98
|
+
});
|
package/switch/Switch.js
CHANGED
|
@@ -11,15 +11,13 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
14
|
-
var _uuid = require("uuid");
|
|
15
14
|
var _variables = require("../common/variables");
|
|
16
15
|
var _utils = require("../common/utils");
|
|
17
16
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
18
17
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
19
|
-
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
20
18
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
21
19
|
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 &&
|
|
20
|
+
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 && {}.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
21
|
var DxcSwitch = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
24
22
|
var defaultChecked = _ref.defaultChecked,
|
|
25
23
|
checked = _ref.checked,
|
|
@@ -40,23 +38,20 @@ var DxcSwitch = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
40
38
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
41
39
|
_ref$tabIndex = _ref.tabIndex,
|
|
42
40
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
43
|
-
var
|
|
44
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
45
|
-
switchId = _useState2[0];
|
|
41
|
+
var switchId = "switch-".concat((0, _react.useId)());
|
|
46
42
|
var labelId = "label-".concat(switchId);
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
innerChecked =
|
|
50
|
-
setInnerChecked =
|
|
43
|
+
var _useState = (0, _react.useState)(defaultChecked !== null && defaultChecked !== void 0 ? defaultChecked : false),
|
|
44
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
45
|
+
innerChecked = _useState2[0],
|
|
46
|
+
setInnerChecked = _useState2[1];
|
|
51
47
|
var colorsTheme = (0, _useTheme["default"])();
|
|
52
48
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
53
|
-
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
54
49
|
var refTrack = (0, _react.useRef)(null);
|
|
55
50
|
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
56
51
|
switch (event.key) {
|
|
57
52
|
case "Enter":
|
|
58
53
|
case " ":
|
|
59
|
-
//Space
|
|
54
|
+
// Space
|
|
60
55
|
event.preventDefault();
|
|
61
56
|
refTrack.current.focus();
|
|
62
57
|
var isChecked = !(checked !== null && checked !== void 0 ? checked : innerChecked);
|
|
@@ -84,7 +79,6 @@ var DxcSwitch = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
84
79
|
id: labelId,
|
|
85
80
|
labelPosition: labelPosition,
|
|
86
81
|
disabled: disabled,
|
|
87
|
-
backgroundType: backgroundType,
|
|
88
82
|
label: label
|
|
89
83
|
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, translatedLabels.formFields.optionalLabel)), /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
90
84
|
type: "checkbox",
|
|
@@ -96,7 +90,6 @@ var DxcSwitch = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
96
90
|
readOnly: true
|
|
97
91
|
}), /*#__PURE__*/_react["default"].createElement(SwitchBase, null, /*#__PURE__*/_react["default"].createElement(SwitchTrack, {
|
|
98
92
|
role: "switch",
|
|
99
|
-
backgroundType: backgroundType,
|
|
100
93
|
"aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
101
94
|
"aria-disabled": disabled,
|
|
102
95
|
disabled: disabled,
|
|
@@ -107,7 +100,6 @@ var DxcSwitch = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
107
100
|
id: labelId,
|
|
108
101
|
labelPosition: labelPosition,
|
|
109
102
|
disabled: disabled,
|
|
110
|
-
backgroundType: backgroundType,
|
|
111
103
|
label: label
|
|
112
104
|
}, optional && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, translatedLabels.formFields.optionalLabel), " ", label)));
|
|
113
105
|
});
|
|
@@ -121,44 +113,44 @@ var sizes = {
|
|
|
121
113
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
122
114
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
123
115
|
};
|
|
124
|
-
var getDisabledColor = function getDisabledColor(
|
|
116
|
+
var getDisabledColor = function getDisabledColor(theme, element, subElement) {
|
|
125
117
|
switch (element) {
|
|
126
118
|
case "track":
|
|
127
|
-
switch (
|
|
119
|
+
switch (subElement) {
|
|
128
120
|
case "check":
|
|
129
|
-
return
|
|
121
|
+
return theme.disabledCheckedTrackBackgroundColor;
|
|
130
122
|
case "uncheck":
|
|
131
|
-
return
|
|
123
|
+
return theme.disabledUncheckedTrackBackgroundColor;
|
|
132
124
|
}
|
|
133
125
|
case "thumb":
|
|
134
|
-
switch (
|
|
126
|
+
switch (subElement) {
|
|
135
127
|
case "check":
|
|
136
|
-
return
|
|
128
|
+
return theme.disabledCheckedThumbBackgroundColor;
|
|
137
129
|
case "uncheck":
|
|
138
|
-
return
|
|
130
|
+
return theme.disabledUncheckedThumbBackgroundColor;
|
|
139
131
|
}
|
|
140
132
|
case "label":
|
|
141
|
-
return
|
|
133
|
+
return theme.disabledLabelFontColor;
|
|
142
134
|
}
|
|
143
135
|
};
|
|
144
|
-
var getNotDisabledColor = function getNotDisabledColor(
|
|
136
|
+
var getNotDisabledColor = function getNotDisabledColor(theme, element, subElement) {
|
|
145
137
|
switch (element) {
|
|
146
138
|
case "track":
|
|
147
|
-
switch (
|
|
139
|
+
switch (subElement) {
|
|
148
140
|
case "check":
|
|
149
|
-
return
|
|
141
|
+
return theme.checkedTrackBackgroundColor;
|
|
150
142
|
case "uncheck":
|
|
151
|
-
return
|
|
143
|
+
return theme.uncheckedTrackBackgroundColor;
|
|
152
144
|
}
|
|
153
145
|
case "thumb":
|
|
154
|
-
switch (
|
|
146
|
+
switch (subElement) {
|
|
155
147
|
case "check":
|
|
156
|
-
return
|
|
148
|
+
return theme.checkedThumbBackgroundColor;
|
|
157
149
|
case "uncheck":
|
|
158
|
-
return
|
|
150
|
+
return theme.uncheckedThumbBackgroundColor;
|
|
159
151
|
}
|
|
160
152
|
case "label":
|
|
161
|
-
return
|
|
153
|
+
return theme.labelFontColor;
|
|
162
154
|
}
|
|
163
155
|
};
|
|
164
156
|
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) {
|
|
@@ -177,7 +169,7 @@ var SwitchContainer = _styledComponents["default"].div(_templateObject || (_temp
|
|
|
177
169
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
178
170
|
});
|
|
179
171
|
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");
|
|
172
|
+
return props.disabled ? getDisabledColor(props.theme, "label") : getNotDisabledColor(props.theme, "label");
|
|
181
173
|
}, function (props) {
|
|
182
174
|
return props.theme.labelFontFamily;
|
|
183
175
|
}, function (props) {
|
|
@@ -200,20 +192,20 @@ var SwitchTrack = _styledComponents["default"].span(_templateObject5 || (_templa
|
|
|
200
192
|
}, function (props) {
|
|
201
193
|
return props.disabled ? "not-allowed" : "pointer";
|
|
202
194
|
}, function (props) {
|
|
203
|
-
return "".concat(props.
|
|
195
|
+
return "".concat(props.theme.thumbFocusColor, " solid 2px");
|
|
204
196
|
}, function (props) {
|
|
205
197
|
return props.theme.thumbWidth;
|
|
206
198
|
}, function (props) {
|
|
207
199
|
return props.theme.thumbHeight;
|
|
208
200
|
}, function (props) {
|
|
209
|
-
return props.disabled ? getDisabledColor(props, "thumb", "uncheck") : getNotDisabledColor(props, "thumb", "uncheck");
|
|
201
|
+
return props.disabled ? getDisabledColor(props.theme, "thumb", "uncheck") : getNotDisabledColor(props.theme, "thumb", "uncheck");
|
|
210
202
|
}, function (props) {
|
|
211
|
-
return props.disabled ? getDisabledColor(props, "track", "uncheck") : getNotDisabledColor(props, "track", "uncheck");
|
|
203
|
+
return props.disabled ? getDisabledColor(props.theme, "track", "uncheck") : getNotDisabledColor(props.theme, "track", "uncheck");
|
|
212
204
|
}, function (props) {
|
|
213
|
-
return props.disabled ? getDisabledColor(props, "track", "check") : getNotDisabledColor(props, "track", "check");
|
|
205
|
+
return props.disabled ? getDisabledColor(props.theme, "track", "check") : getNotDisabledColor(props.theme, "track", "check");
|
|
214
206
|
}, function (props) {
|
|
215
207
|
return props.theme.thumbShift;
|
|
216
208
|
}, function (props) {
|
|
217
|
-
return props.disabled ? getDisabledColor(props, "thumb", "check") : getNotDisabledColor(props, "thumb", "check");
|
|
209
|
+
return props.disabled ? getDisabledColor(props.theme, "thumb", "check") : getNotDisabledColor(props.theme, "thumb", "check");
|
|
218
210
|
});
|
|
219
211
|
var _default = exports["default"] = DxcSwitch;
|
|
@@ -3,10 +3,22 @@ import DxcSwitch from "./Switch";
|
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import { HalstackProvider } from "../HalstackContext";
|
|
6
|
+
import { disabledRules } from "../../test/accessibility/rules/specific/switch/disabledRules";
|
|
7
|
+
import preview from "../../.storybook/preview";
|
|
6
8
|
|
|
7
9
|
export default {
|
|
8
10
|
title: "Switch",
|
|
9
11
|
component: DxcSwitch,
|
|
12
|
+
parameters: {
|
|
13
|
+
a11y: {
|
|
14
|
+
config: {
|
|
15
|
+
rules: [
|
|
16
|
+
...disabledRules.map((ruleId) => ({ id: ruleId, enabled: false })),
|
|
17
|
+
...preview?.parameters?.a11y?.config?.rules,
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
10
22
|
};
|
|
11
23
|
|
|
12
24
|
const opinionatedTheme = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/switch/Switch.test.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
|
-
var _Switch = _interopRequireDefault(require("./Switch
|
|
6
|
+
var _Switch = _interopRequireDefault(require("./Switch"));
|
|
7
7
|
describe("Switch component tests", function () {
|
|
8
8
|
test("Switch renders with correct text", function () {
|
|
9
9
|
var onChange = jest.fn(function (returnedValue) {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _variables = require("../common/variables");
|
|
8
|
+
var _default = exports["default"] = {
|
|
9
|
+
dropdown: {
|
|
10
|
+
// ActionIcon size tokens
|
|
11
|
+
buttonIconSize: "16px",
|
|
12
|
+
buttonPaddingTop: "4px",
|
|
13
|
+
buttonPaddingBottom: "4px",
|
|
14
|
+
buttonPaddingLeft: "4px",
|
|
15
|
+
buttonPaddingRight: "4px",
|
|
16
|
+
buttonHeight: "24px",
|
|
17
|
+
buttonBorderRadius: "2px",
|
|
18
|
+
buttonBorderStyle: "none",
|
|
19
|
+
buttonBorderThickness: "0px",
|
|
20
|
+
buttonBorderColor: "transparent",
|
|
21
|
+
optionFontSize: "14px",
|
|
22
|
+
optionPaddingTop: "0px",
|
|
23
|
+
optionPaddingBottom: "0px",
|
|
24
|
+
optionPaddingLeft: "16px",
|
|
25
|
+
optionPaddingRight: "16px",
|
|
26
|
+
// Dropdown tokens
|
|
27
|
+
buttonBackgroundColor: _variables.componentTokens.table.actionBackgroundColor,
|
|
28
|
+
hoverButtonBackgroundColor: _variables.componentTokens.table.hoverActionBackgroundColor,
|
|
29
|
+
activeButtonBackgroundColor: _variables.componentTokens.table.activeActionBackgroundColor,
|
|
30
|
+
buttonFontFamily: _variables.componentTokens.dropdown.buttonFontFamily,
|
|
31
|
+
buttonFontSize: _variables.componentTokens.dropdown.buttonFontSize,
|
|
32
|
+
buttonFontStyle: _variables.componentTokens.dropdown.buttonFontStyle,
|
|
33
|
+
buttonFontWeight: _variables.componentTokens.dropdown.buttonFontWeight,
|
|
34
|
+
buttonFontColor: _variables.componentTokens.dropdown.buttonFontColor,
|
|
35
|
+
buttonIconSpacing: _variables.componentTokens.dropdown.buttonIconSpacing,
|
|
36
|
+
buttonIconColor: _variables.componentTokens.table.actionIconColor,
|
|
37
|
+
disabledColor: _variables.componentTokens.table.disabledActionIconColor,
|
|
38
|
+
disabledButtonBorderColor: _variables.componentTokens.dropdown.disabledButtonBorderColor,
|
|
39
|
+
disabledButtonBackgroundColor: _variables.componentTokens.table.disabledActionBackgroundColor,
|
|
40
|
+
disabledBorderColor: _variables.componentTokens.dropdown.disabledBorderColor,
|
|
41
|
+
optionBackgroundColor: _variables.componentTokens.dropdown.optionBackgroundColor,
|
|
42
|
+
hoverOptionBackgroundColor: _variables.componentTokens.dropdown.hoverOptionBackgroundColor,
|
|
43
|
+
activeOptionBackgroundColor: _variables.componentTokens.dropdown.activeOptionBackgroundColor,
|
|
44
|
+
optionFontFamily: _variables.componentTokens.dropdown.optionFontFamily,
|
|
45
|
+
optionFontStyle: _variables.componentTokens.dropdown.optionFontStyle,
|
|
46
|
+
optionFontWeight: _variables.componentTokens.dropdown.optionFontWeight,
|
|
47
|
+
optionFontColor: _variables.componentTokens.dropdown.optionFontColor,
|
|
48
|
+
optionIconSize: _variables.componentTokens.dropdown.optionIconSize,
|
|
49
|
+
optionIconSpacing: _variables.componentTokens.dropdown.optionIconSpacing,
|
|
50
|
+
optionIconColor: _variables.componentTokens.dropdown.optionIconColor,
|
|
51
|
+
caretIconSize: _variables.componentTokens.dropdown.caretIconSize,
|
|
52
|
+
caretIconColor: _variables.componentTokens.dropdown.caretIconColor,
|
|
53
|
+
caretIconSpacing: _variables.componentTokens.dropdown.caretIconSpacing,
|
|
54
|
+
borderRadius: _variables.componentTokens.dropdown.borderRadius,
|
|
55
|
+
borderStyle: _variables.componentTokens.dropdown.borderStyle,
|
|
56
|
+
borderThickness: _variables.componentTokens.dropdown.borderThickness,
|
|
57
|
+
borderColor: _variables.componentTokens.dropdown.borderColor,
|
|
58
|
+
scrollBarThumbColor: _variables.componentTokens.dropdown.scrollBarThumbColor,
|
|
59
|
+
scrollBarTrackColor: _variables.componentTokens.dropdown.scrollBarTrackColor,
|
|
60
|
+
focusColor: _variables.componentTokens.table.focusActionBorderColor
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|