@dxc-technology/halstack-react 0.0.0-d3554d7 → 0.0.0-d3624d0
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 +5 -22
- package/HalstackContext.d.ts +1246 -0
- package/HalstackContext.js +310 -0
- package/README.md +47 -0
- package/accordion/Accordion.accessibility.test.js +71 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +105 -181
- package/accordion/Accordion.stories.tsx +83 -149
- package/accordion/Accordion.test.js +32 -33
- package/accordion/types.d.ts +10 -17
- package/accordion-group/AccordionGroup.accessibility.test.js +88 -0
- package/accordion-group/AccordionGroup.d.ts +3 -3
- package/accordion-group/AccordionGroup.js +38 -107
- package/accordion-group/AccordionGroup.stories.tsx +95 -68
- package/accordion-group/AccordionGroup.test.js +55 -90
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +31 -0
- package/accordion-group/AccordionGroupContext.d.ts +3 -0
- package/accordion-group/AccordionGroupContext.js +8 -0
- package/accordion-group/types.d.ts +16 -17
- 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.js +64 -0
- package/action-icon/types.d.ts +26 -0
- package/alert/Alert.accessibility.test.js +95 -0
- package/alert/Alert.js +40 -127
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +29 -46
- package/alert/types.d.ts +5 -5
- package/badge/Badge.accessibility.test.js +129 -0
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +142 -40
- package/badge/Badge.stories.tsx +210 -0
- package/badge/Badge.test.js +30 -0
- package/badge/types.d.ts +52 -2
- package/bleed/Bleed.js +14 -55
- package/bleed/Bleed.stories.tsx +95 -95
- package/bleed/types.d.ts +26 -2
- package/box/Box.accessibility.test.js +33 -0
- package/box/Box.d.ts +1 -1
- package/box/Box.js +30 -81
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +2 -7
- package/box/types.d.ts +3 -14
- 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/bulleted-list/BulletedList.accessibility.test.js +119 -0
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +92 -0
- package/bulleted-list/BulletedList.stories.tsx +115 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.accessibility.test.js +127 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +63 -113
- package/button/Button.stories.tsx +151 -100
- package/button/Button.test.js +20 -17
- package/button/types.d.ts +12 -8
- package/card/Card.accessibility.test.js +36 -0
- package/card/Card.d.ts +1 -1
- package/card/Card.js +59 -102
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +11 -22
- package/card/types.d.ts +6 -11
- package/checkbox/Checkbox.accessibility.test.js +87 -0
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +143 -181
- package/checkbox/Checkbox.stories.tsx +166 -136
- package/checkbox/Checkbox.test.js +163 -29
- package/checkbox/types.d.ts +18 -6
- package/chip/Chip.accessibility.test.js +67 -0
- package/chip/Chip.js +45 -80
- package/chip/Chip.stories.tsx +107 -27
- package/chip/Chip.test.js +18 -33
- package/chip/types.d.ts +4 -4
- package/common/coreTokens.d.ts +237 -0
- package/common/coreTokens.js +184 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +6 -12
- package/common/variables.d.ts +1392 -0
- package/common/variables.js +1081 -1190
- 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/contextual-menu/ContextualMenu.accessibility.test.js +97 -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.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/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +214 -0
- package/date-input/DateInput.accessibility.test.js +228 -0
- package/date-input/DateInput.js +170 -306
- package/date-input/DateInput.stories.tsx +210 -56
- package/date-input/DateInput.test.js +708 -369
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +121 -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.accessibility.test.js +69 -0
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +56 -129
- package/dialog/Dialog.stories.tsx +326 -167
- package/dialog/Dialog.test.js +287 -20
- package/dialog/types.d.ts +18 -25
- 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.js +38 -0
- package/divider/types.d.ts +21 -0
- package/dropdown/Dropdown.accessibility.test.js +180 -0
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +233 -307
- package/dropdown/Dropdown.stories.tsx +235 -57
- package/dropdown/Dropdown.test.js +575 -165
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +63 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +71 -0
- package/dropdown/types.d.ts +35 -19
- package/file-input/FileInput.accessibility.test.js +160 -0
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +246 -393
- package/file-input/FileInput.stories.tsx +123 -12
- package/file-input/FileInput.test.js +292 -367
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +61 -120
- 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.accessibility.test.js +125 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +73 -191
- package/footer/Footer.stories.tsx +99 -21
- package/footer/Footer.test.js +33 -57
- package/footer/Icons.d.ts +3 -2
- package/footer/Icons.js +54 -23
- package/footer/types.d.ts +26 -27
- 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.accessibility.test.js +93 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +104 -218
- package/header/Header.stories.tsx +168 -63
- package/header/Header.test.js +31 -28
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +5 -15
- package/header/types.d.ts +7 -21
- package/heading/Heading.accessibility.test.js +33 -0
- package/heading/Heading.js +10 -32
- package/heading/Heading.test.js +71 -88
- package/heading/types.d.ts +7 -7
- 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.js +56 -0
- package/image/Image.d.ts +4 -0
- package/image/Image.js +70 -0
- package/image/Image.stories.tsx +129 -0
- package/image/types.d.ts +72 -0
- package/image/types.js +5 -0
- package/inset/Inset.js +14 -55
- package/inset/Inset.stories.tsx +37 -36
- package/inset/types.d.ts +26 -2
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +88 -182
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +7 -0
- package/layout/Icons.js +41 -48
- package/layout/types.d.ts +19 -35
- package/link/Link.accessibility.test.js +108 -0
- package/link/Link.d.ts +3 -2
- package/link/Link.js +65 -101
- package/link/Link.stories.tsx +157 -55
- package/link/Link.test.js +25 -53
- package/link/types.d.ts +15 -31
- package/main.d.ts +17 -13
- package/main.js +86 -101
- package/nav-tabs/NavTabs.accessibility.test.js +44 -0
- package/nav-tabs/NavTabs.d.ts +7 -0
- package/nav-tabs/NavTabs.js +93 -0
- package/nav-tabs/NavTabs.stories.tsx +279 -0
- package/nav-tabs/NavTabs.test.js +77 -0
- package/nav-tabs/NavTabsContext.d.ts +3 -0
- package/nav-tabs/NavTabsContext.js +8 -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.accessibility.test.js +228 -0
- package/number-input/NumberInput.js +47 -44
- package/number-input/NumberInput.stories.tsx +44 -28
- package/number-input/NumberInput.test.js +862 -381
- package/number-input/NumberInputContext.d.ts +3 -4
- package/number-input/NumberInputContext.js +3 -14
- package/number-input/types.d.ts +34 -15
- package/package.json +54 -53
- package/paginator/Paginator.accessibility.test.js +79 -0
- package/paginator/Paginator.js +46 -100
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +280 -211
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.accessibility.test.js +28 -0
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +22 -0
- package/paragraph/Paragraph.stories.tsx +27 -0
- package/password-input/PasswordInput.accessibility.test.js +153 -0
- package/password-input/PasswordInput.js +58 -124
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +162 -147
- package/password-input/types.d.ts +21 -17
- package/progress-bar/ProgressBar.accessibility.test.js +35 -0
- package/progress-bar/ProgressBar.js +68 -92
- package/progress-bar/ProgressBar.stories.tsx +93 -0
- package/progress-bar/ProgressBar.test.js +72 -44
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.accessibility.test.js +57 -0
- 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 +1 -1
- package/radio-group/Radio.js +59 -76
- package/radio-group/RadioGroup.accessibility.test.js +97 -0
- package/radio-group/RadioGroup.js +73 -116
- package/radio-group/RadioGroup.stories.tsx +135 -17
- package/radio-group/RadioGroup.test.js +529 -467
- package/radio-group/types.d.ts +86 -9
- package/resultset-table/Icons.d.ts +7 -0
- package/resultset-table/Icons.js +47 -0
- package/resultset-table/ResultsetTable.accessibility.test.js +285 -0
- package/resultset-table/ResultsetTable.d.ts +7 -0
- package/resultset-table/ResultsetTable.js +171 -0
- package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +168 -30
- package/resultset-table/ResultsetTable.test.js +381 -0
- package/{resultsetTable → resultset-table}/types.d.ts +44 -11
- package/resultset-table/types.js +5 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +155 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +89 -0
- package/select/Select.accessibility.test.js +228 -0
- package/select/Select.js +237 -504
- package/select/Select.stories.tsx +533 -196
- package/select/Select.test.js +1953 -1588
- package/select/types.d.ts +65 -26
- package/sidenav/Sidenav.accessibility.test.js +59 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +136 -71
- package/sidenav/Sidenav.stories.tsx +246 -151
- package/sidenav/Sidenav.test.js +26 -45
- package/sidenav/SidenavContext.d.ts +5 -0
- package/sidenav/SidenavContext.js +13 -0
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.accessibility.test.js +104 -0
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +149 -180
- package/slider/Slider.test.js +198 -73
- package/slider/types.d.ts +11 -3
- package/spinner/Spinner.accessibility.test.js +96 -0
- package/spinner/Spinner.js +34 -74
- package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +53 -27
- package/spinner/Spinner.test.js +26 -35
- package/spinner/types.d.ts +3 -3
- 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.js +25 -0
- package/status-light/types.d.ts +17 -0
- package/status-light/types.js +5 -0
- package/switch/Switch.accessibility.test.js +98 -0
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +149 -114
- package/switch/Switch.stories.tsx +56 -67
- package/switch/Switch.test.js +146 -39
- package/switch/types.d.ts +13 -5
- package/table/DropdownTheme.js +62 -0
- package/table/Table.accessibility.test.js +93 -0
- package/table/Table.d.ts +6 -2
- package/table/Table.js +78 -35
- package/table/Table.stories.tsx +663 -0
- package/table/Table.test.js +95 -8
- package/table/types.d.ts +34 -6
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +117 -0
- package/tabs/Tabs.accessibility.test.js +56 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +305 -145
- package/tabs/Tabs.stories.tsx +124 -14
- package/tabs/Tabs.test.js +220 -67
- package/tabs/types.d.ts +31 -17
- package/tag/Tag.accessibility.test.js +69 -0
- package/tag/Tag.js +42 -79
- package/tag/Tag.stories.tsx +24 -10
- package/tag/Tag.test.js +18 -37
- package/tag/types.d.ts +9 -9
- 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 +94 -0
- package/text-input/TextInput.accessibility.test.js +321 -0
- package/text-input/TextInput.js +332 -557
- package/text-input/TextInput.stories.tsx +282 -282
- package/text-input/TextInput.test.js +1442 -1377
- package/text-input/types.d.ts +70 -24
- package/textarea/Textarea.accessibility.test.js +155 -0
- package/textarea/Textarea.js +83 -134
- package/textarea/Textarea.stories.tsx +174 -0
- package/textarea/Textarea.test.js +168 -198
- package/textarea/types.d.ts +27 -16
- package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +94 -106
- package/toggle-group/ToggleGroup.stories.tsx +56 -11
- package/toggle-group/ToggleGroup.test.js +78 -66
- package/toggle-group/types.d.ts +36 -19
- package/typography/Typography.accessibility.test.js +339 -0
- 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 +1144 -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 +124 -0
- package/wizard/Wizard.accessibility.test.js +55 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +78 -120
- package/wizard/Wizard.stories.tsx +67 -19
- package/wizard/Wizard.test.js +73 -87
- package/wizard/types.d.ts +14 -10
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/card/ice-cream.jpg +0 -0
- package/common/OpenSans.css +0 -81
- package/common/RequiredComponent.js +0 -32
- 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/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/paginator/Icons.js +0 -66
- 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/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/resultsetTable/ResultsetTable.d.ts +0 -4
- package/resultsetTable/ResultsetTable.js +0 -254
- package/resultsetTable/ResultsetTable.test.js +0 -306
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -10
- package/slider/Slider.stories.tsx +0 -177
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -9
- package/table/Table.stories.jsx +0 -277
- 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 -157
- /package/{list → action-icon}/types.js +0 -0
- /package/{radio → breadcrumbs}/types.js +0 -0
- /package/{resultsetTable → bulleted-list}/types.js +0 -0
- /package/{row → container}/types.js +0 -0
- /package/{stack → contextual-menu}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → divider/types.js} +0 -0
|
@@ -3,9 +3,10 @@ import { userEvent, within } from "@storybook/testing-library";
|
|
|
3
3
|
import DxcToggleGroup from "./ToggleGroup";
|
|
4
4
|
import Title from "../../.storybook/components/Title";
|
|
5
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
import { HalstackProvider } from "../HalstackContext";
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
|
-
title: "
|
|
9
|
+
title: "Toggle Group",
|
|
9
10
|
component: DxcToggleGroup,
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -41,7 +42,7 @@ const options = [
|
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
44
|
value: 2,
|
|
44
|
-
label: "
|
|
45
|
+
label: "X",
|
|
45
46
|
},
|
|
46
47
|
{
|
|
47
48
|
value: 3,
|
|
@@ -51,15 +52,18 @@ const options = [
|
|
|
51
52
|
const optionsWithIcon = [
|
|
52
53
|
{
|
|
53
54
|
value: 1,
|
|
54
|
-
icon:
|
|
55
|
+
icon: "wifi",
|
|
56
|
+
title: "WiFi connection",
|
|
55
57
|
},
|
|
56
58
|
{
|
|
57
59
|
value: 2,
|
|
58
|
-
icon:
|
|
60
|
+
icon: "filled_lan",
|
|
61
|
+
title: "Ethernet connection",
|
|
59
62
|
},
|
|
60
63
|
{
|
|
61
64
|
value: 3,
|
|
62
|
-
icon:
|
|
65
|
+
icon: "5g",
|
|
66
|
+
title: "3G Mobile data connection",
|
|
63
67
|
},
|
|
64
68
|
];
|
|
65
69
|
const optionsWithIconAndLabel = [
|
|
@@ -86,9 +90,19 @@ const twoOptions = [
|
|
|
86
90
|
},
|
|
87
91
|
{
|
|
88
92
|
value: 2,
|
|
89
|
-
label: "
|
|
93
|
+
label: "X",
|
|
90
94
|
},
|
|
91
95
|
];
|
|
96
|
+
|
|
97
|
+
const opinionatedTheme = {
|
|
98
|
+
toggleGroup: {
|
|
99
|
+
selectedBaseColor: "#5f249f",
|
|
100
|
+
selectedFontColor: "#ffffff",
|
|
101
|
+
unselectedBaseColor: "#e6e6e6",
|
|
102
|
+
unselectedFontColor: "#000000",
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
92
106
|
export const Chromatic = () => (
|
|
93
107
|
<>
|
|
94
108
|
<ExampleContainer>
|
|
@@ -97,7 +111,7 @@ export const Chromatic = () => (
|
|
|
97
111
|
</ExampleContainer>
|
|
98
112
|
<ExampleContainer>
|
|
99
113
|
<Title title="Selected" theme="light" level={4} />
|
|
100
|
-
<DxcToggleGroup label="Selected" helperText="HelperText"
|
|
114
|
+
<DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
|
|
101
115
|
</ExampleContainer>
|
|
102
116
|
<ExampleContainer>
|
|
103
117
|
<Title title="Icons toggle group" theme="light" level={4} />
|
|
@@ -109,11 +123,11 @@ export const Chromatic = () => (
|
|
|
109
123
|
</ExampleContainer>
|
|
110
124
|
<ExampleContainer>
|
|
111
125
|
<Title title="Disabled" theme="light" level={4} />
|
|
112
|
-
<DxcToggleGroup label="Disabled"
|
|
126
|
+
<DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
|
|
113
127
|
</ExampleContainer>
|
|
114
128
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
115
129
|
<Title title="Hovered" theme="light" level={4} />
|
|
116
|
-
<DxcToggleGroup label="Hovered" options={twoOptions}
|
|
130
|
+
<DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
|
|
117
131
|
</ExampleContainer>
|
|
118
132
|
<ExampleContainer>
|
|
119
133
|
<Title title="Multiple toggleGroup" theme="light" level={4} />
|
|
@@ -121,7 +135,7 @@ export const Chromatic = () => (
|
|
|
121
135
|
label="Toggle group"
|
|
122
136
|
helperText="Please select one or more"
|
|
123
137
|
options={options}
|
|
124
|
-
|
|
138
|
+
defaultValue={[1, 3]}
|
|
125
139
|
multiple
|
|
126
140
|
></DxcToggleGroup>
|
|
127
141
|
</ExampleContainer>
|
|
@@ -154,6 +168,37 @@ export const Chromatic = () => (
|
|
|
154
168
|
<Title title="xxLarge" theme="light" level={4} />
|
|
155
169
|
<DxcToggleGroup label="xxLarge margin" options={options} margin="xxlarge" />
|
|
156
170
|
</ExampleContainer>
|
|
171
|
+
<Title title="Opinionated theme" theme="light" level={2} />
|
|
172
|
+
<ExampleContainer>
|
|
173
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
174
|
+
<Title title="Selected" theme="light" level={4} />
|
|
175
|
+
<DxcToggleGroup label="Selected" helperText="HelperText" defaultValue={2} options={options} />
|
|
176
|
+
</HalstackProvider>
|
|
177
|
+
</ExampleContainer>
|
|
178
|
+
<ExampleContainer>
|
|
179
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
180
|
+
<Title title="Icons & label toggle group" theme="light" level={4} />
|
|
181
|
+
<DxcToggleGroup label="Icons & label" options={optionsWithIconAndLabel} />
|
|
182
|
+
</HalstackProvider>
|
|
183
|
+
</ExampleContainer>
|
|
184
|
+
<ExampleContainer>
|
|
185
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
186
|
+
<Title title="Disabled" theme="light" level={4} />
|
|
187
|
+
<DxcToggleGroup label="Disabled" defaultValue={2} options={options} disabled />
|
|
188
|
+
</HalstackProvider>
|
|
189
|
+
</ExampleContainer>
|
|
190
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
191
|
+
<Title title="Hovered" theme="light" level={4} />
|
|
192
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
193
|
+
<DxcToggleGroup label="Hovered" options={twoOptions} defaultValue={2} />
|
|
194
|
+
</HalstackProvider>
|
|
195
|
+
</ExampleContainer>
|
|
196
|
+
<ExampleContainer pseudoState="pseudo-active">
|
|
197
|
+
<Title title="Actived" theme="light" level={4} />
|
|
198
|
+
<HalstackProvider theme={opinionatedTheme}>
|
|
199
|
+
<DxcToggleGroup label="Actived" options={twoOptions} defaultValue={2} />
|
|
200
|
+
</HalstackProvider>
|
|
201
|
+
</ExampleContainer>
|
|
157
202
|
</>
|
|
158
203
|
);
|
|
159
204
|
const OptionSelected = () => <DxcToggleGroup label="Toggle group" helperText="HelperText" options={options} />;
|
|
@@ -167,7 +212,7 @@ ToggleGroupSelectedActived.play = async ({ canvasElement }) => {
|
|
|
167
212
|
export const ToggleGroupUnselectedActived = OptionSelected.bind({});
|
|
168
213
|
ToggleGroupUnselectedActived.play = async ({ canvasElement }) => {
|
|
169
214
|
const canvas = within(canvasElement);
|
|
170
|
-
const option = canvas.getByText("
|
|
215
|
+
const option = canvas.getByText("X");
|
|
171
216
|
await userEvent.click(option);
|
|
172
217
|
userEvent.tab();
|
|
173
218
|
};
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
|
-
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup"));
|
|
10
|
-
|
|
6
|
+
var _ToggleGroup = _interopRequireDefault(require("./ToggleGroup.tsx"));
|
|
11
7
|
var options = [{
|
|
12
8
|
value: 1,
|
|
13
9
|
label: "Amazon"
|
|
@@ -24,12 +20,11 @@ var options = [{
|
|
|
24
20
|
describe("Toggle group component tests", function () {
|
|
25
21
|
test("Toggle group renders with correct labels", function () {
|
|
26
22
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
label: "Toggle group label",
|
|
24
|
+
helperText: "Toggle group helper text",
|
|
25
|
+
options: options
|
|
26
|
+
})),
|
|
27
|
+
getByText = _render.getByText;
|
|
33
28
|
expect(getByText("Toggle group label")).toBeTruthy();
|
|
34
29
|
expect(getByText("Toggle group helper text")).toBeTruthy();
|
|
35
30
|
expect(getByText("Amazon")).toBeTruthy();
|
|
@@ -37,89 +32,106 @@ describe("Toggle group component tests", function () {
|
|
|
37
32
|
expect(getByText("Apple")).toBeTruthy();
|
|
38
33
|
expect(getByText("Google")).toBeTruthy();
|
|
39
34
|
});
|
|
35
|
+
test("Toggle group renders with correct aria-label in only-icon scenario", function () {
|
|
36
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
37
|
+
label: "Toggle group label",
|
|
38
|
+
helperText: "Toggle group helper text",
|
|
39
|
+
options: [{
|
|
40
|
+
value: 1,
|
|
41
|
+
icon: "https://cdn.icon-icons.com/icons2/2645/PNG/512/mic_mute_icon_159965.png",
|
|
42
|
+
title: "Mute"
|
|
43
|
+
}]
|
|
44
|
+
})),
|
|
45
|
+
getByRole = _render2.getByRole;
|
|
46
|
+
expect(getByRole("button").getAttribute("aria-label")).toBe("Mute");
|
|
47
|
+
});
|
|
40
48
|
test("Uncontrolled toggle group calls correct function on change with value", function () {
|
|
41
49
|
var onChange = jest.fn();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
getByText = _render2.getByText;
|
|
48
|
-
|
|
50
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
51
|
+
options: options,
|
|
52
|
+
onChange: onChange
|
|
53
|
+
})),
|
|
54
|
+
getByText = _render3.getByText;
|
|
49
55
|
var option = getByText("Ebay");
|
|
50
|
-
|
|
51
56
|
_react2.fireEvent.click(option);
|
|
52
|
-
|
|
53
57
|
expect(onChange).toHaveBeenCalledWith(2);
|
|
54
58
|
});
|
|
55
59
|
test("Controlled toggle group calls correct function on change with value", function () {
|
|
56
60
|
var onChange = jest.fn();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
getByText = _render3.getByText;
|
|
64
|
-
|
|
61
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
62
|
+
options: options,
|
|
63
|
+
onChange: onChange,
|
|
64
|
+
value: 1
|
|
65
|
+
})),
|
|
66
|
+
getByText = _render4.getByText;
|
|
65
67
|
var option = getByText("Ebay");
|
|
66
|
-
|
|
67
68
|
_react2.fireEvent.click(option);
|
|
68
|
-
|
|
69
69
|
expect(onChange).toHaveBeenCalledWith(2);
|
|
70
70
|
});
|
|
71
71
|
test("Function on change is not called when disable", function () {
|
|
72
72
|
var onChange = jest.fn();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
getByText = _render4.getByText;
|
|
80
|
-
|
|
73
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
74
|
+
options: options,
|
|
75
|
+
onChange: onChange,
|
|
76
|
+
disabled: true
|
|
77
|
+
})),
|
|
78
|
+
getByText = _render5.getByText;
|
|
81
79
|
var option = getByText("Ebay");
|
|
82
|
-
|
|
83
80
|
_react2.fireEvent.click(option);
|
|
84
|
-
|
|
85
81
|
expect(onChange).toHaveBeenCalledTimes(0);
|
|
86
82
|
});
|
|
87
83
|
test("Uncontrolled multiple toggle group calls correct function on change with value when is multiple", function () {
|
|
88
84
|
var onChange = jest.fn();
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_react2.fireEvent.click(
|
|
100
|
-
|
|
101
|
-
expect(
|
|
85
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
86
|
+
options: options,
|
|
87
|
+
onChange: onChange,
|
|
88
|
+
multiple: true
|
|
89
|
+
})),
|
|
90
|
+
getAllByRole = _render6.getAllByRole;
|
|
91
|
+
var toggleOptions = getAllByRole("button");
|
|
92
|
+
_react2.fireEvent.click(toggleOptions[0]);
|
|
93
|
+
expect(onChange).toHaveBeenCalledWith([1]);
|
|
94
|
+
_react2.fireEvent.click(toggleOptions[1]);
|
|
95
|
+
_react2.fireEvent.click(toggleOptions[3]);
|
|
96
|
+
expect(onChange).toHaveBeenCalledWith([1, 2, 4]);
|
|
97
|
+
expect(toggleOptions[0].getAttribute("aria-pressed")).toBe("true");
|
|
98
|
+
expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
|
|
99
|
+
expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
|
|
102
100
|
});
|
|
103
101
|
test("Controlled multiple toggle returns always same values", function () {
|
|
104
102
|
var onChange = jest.fn();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
getByText = _render6.getByText;
|
|
113
|
-
|
|
103
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
104
|
+
options: options,
|
|
105
|
+
onChange: onChange,
|
|
106
|
+
value: [1],
|
|
107
|
+
multiple: true
|
|
108
|
+
})),
|
|
109
|
+
getByText = _render7.getByText;
|
|
114
110
|
var option = getByText("Ebay");
|
|
115
|
-
|
|
116
111
|
_react2.fireEvent.click(option);
|
|
117
|
-
|
|
118
112
|
expect(onChange).toHaveBeenCalledWith([1, 2]);
|
|
119
113
|
var option2 = getByText("Google");
|
|
120
|
-
|
|
121
114
|
_react2.fireEvent.click(option2);
|
|
122
|
-
|
|
123
115
|
expect(onChange).toHaveBeenNthCalledWith(2, [1, 4]);
|
|
124
116
|
});
|
|
117
|
+
test("Single selection: Renders with correct default value", function () {
|
|
118
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
119
|
+
options: options,
|
|
120
|
+
defaultValue: 2
|
|
121
|
+
})),
|
|
122
|
+
getAllByRole = _render8.getAllByRole;
|
|
123
|
+
var toggleOptions = getAllByRole("button");
|
|
124
|
+
expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
|
|
125
|
+
});
|
|
126
|
+
test("Multiple selection: Renders with correct default value", function () {
|
|
127
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ToggleGroup["default"], {
|
|
128
|
+
options: options,
|
|
129
|
+
defaultValue: [2, 4],
|
|
130
|
+
multiple: true
|
|
131
|
+
})),
|
|
132
|
+
getAllByRole = _render9.getAllByRole;
|
|
133
|
+
var toggleOptions = getAllByRole("button");
|
|
134
|
+
expect(toggleOptions[1].getAttribute("aria-pressed")).toBe("true");
|
|
135
|
+
expect(toggleOptions[3].getAttribute("aria-pressed")).toBe("true");
|
|
136
|
+
});
|
|
125
137
|
});
|
package/toggle-group/types.d.ts
CHANGED
|
@@ -1,40 +1,49 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
3
|
+
type Margin = {
|
|
4
4
|
top?: Space;
|
|
5
5
|
bottom?: Space;
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Number with the option inner value.
|
|
13
|
-
*/
|
|
14
|
-
value: number;
|
|
15
|
-
};
|
|
16
|
-
declare type OptionIcon = OptionCommons & {
|
|
9
|
+
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
+
type OptionIcon = {
|
|
17
11
|
/**
|
|
18
12
|
* String with the option display value.
|
|
19
13
|
*/
|
|
20
|
-
label?:
|
|
14
|
+
label?: never;
|
|
21
15
|
/**
|
|
22
|
-
*
|
|
16
|
+
* Material Symbols icon or SVG element. Icon and label can't be used at same time.
|
|
23
17
|
*/
|
|
24
18
|
icon: string | SVG;
|
|
19
|
+
/**
|
|
20
|
+
* Value for the HTML properties title and aria-label.
|
|
21
|
+
* When a label is defined, this prop can not be use.
|
|
22
|
+
*/
|
|
23
|
+
title: string;
|
|
25
24
|
};
|
|
26
|
-
|
|
25
|
+
export type OptionLabel = {
|
|
27
26
|
/**
|
|
28
27
|
* String with the option display value.
|
|
29
28
|
*/
|
|
30
29
|
label: string;
|
|
31
30
|
/**
|
|
32
|
-
*
|
|
31
|
+
* Material Symbols icon or SVG element. Icon and label can't be used at same time.
|
|
33
32
|
*/
|
|
34
33
|
icon?: string | SVG;
|
|
34
|
+
/**
|
|
35
|
+
* Value for the HTML properties title and aria-label.
|
|
36
|
+
* When a label is defined, this prop can not be use.
|
|
37
|
+
*/
|
|
38
|
+
title?: never;
|
|
35
39
|
};
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
type Option = {
|
|
41
|
+
/**
|
|
42
|
+
* Number with the option inner value.
|
|
43
|
+
*/
|
|
44
|
+
value: number;
|
|
45
|
+
} & (OptionIcon | OptionLabel);
|
|
46
|
+
type CommonProps = {
|
|
38
47
|
/**
|
|
39
48
|
* Text to be placed above the component.
|
|
40
49
|
*/
|
|
@@ -61,11 +70,15 @@ declare type CommonProps = {
|
|
|
61
70
|
*/
|
|
62
71
|
tabIndex?: number;
|
|
63
72
|
};
|
|
64
|
-
|
|
73
|
+
type SingleSelectionToggleGroup = CommonProps & {
|
|
65
74
|
/**
|
|
66
75
|
* If true, the toggle group will support multiple selection. In that case, value must be an array of numbers with the keys of the selected values.
|
|
67
76
|
*/
|
|
68
77
|
multiple?: false;
|
|
78
|
+
/**
|
|
79
|
+
* The key of the initially selected value.
|
|
80
|
+
*/
|
|
81
|
+
defaultValue?: number;
|
|
69
82
|
/**
|
|
70
83
|
* The key of the selected value. If the component allows multiple selection, value must be an array.
|
|
71
84
|
* If undefined, the component will be uncontrolled and the value will be managed internally by the component.
|
|
@@ -77,11 +90,15 @@ declare type SingleSelectionToggle = CommonProps & {
|
|
|
77
90
|
*/
|
|
78
91
|
onChange?: (optionIndex: number) => void;
|
|
79
92
|
};
|
|
80
|
-
|
|
93
|
+
type MultipleSelectionToggleGroup = CommonProps & {
|
|
81
94
|
/**
|
|
82
95
|
* If true, the toggle group will support multiple selection. In that case, value must be an array of numbers with the keys of the selected values.
|
|
83
96
|
*/
|
|
84
97
|
multiple: true;
|
|
98
|
+
/**
|
|
99
|
+
* The array of keys with the initially selected values.
|
|
100
|
+
*/
|
|
101
|
+
defaultValue?: number[];
|
|
85
102
|
/**
|
|
86
103
|
* An array with the keys of the selected values.
|
|
87
104
|
* If undefined, the component will be uncontrolled and the value will be managed internally by the component.
|
|
@@ -93,5 +110,5 @@ declare type MultipleSelectionToggle = CommonProps & {
|
|
|
93
110
|
*/
|
|
94
111
|
onChange?: (optionIndex: number[]) => void;
|
|
95
112
|
};
|
|
96
|
-
|
|
113
|
+
type Props = SingleSelectionToggleGroup | MultipleSelectionToggleGroup;
|
|
97
114
|
export default Props;
|