@dxc-technology/halstack-react 0.0.0-59b9187 → 0.0.0-5a4d834
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.js +1 -1
- package/HalstackContext.d.ts +41 -3
- package/HalstackContext.js +28 -18
- package/accordion/Accordion.accessibility.test.d.ts +1 -0
- package/accordion/Accordion.accessibility.test.js +4 -4
- package/accordion/Accordion.js +6 -9
- package/accordion/Accordion.stories.tsx +4 -14
- package/accordion/Accordion.test.d.ts +1 -0
- package/accordion/Accordion.test.js +3 -3
- package/accordion-group/AccordionGroup.accessibility.test.d.ts +1 -0
- package/accordion-group/AccordionGroup.accessibility.test.js +11 -17
- package/accordion-group/AccordionGroup.js +1 -1
- 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 +1 -1
- package/action-icon/ActionIcon.accessibility.test.d.ts +1 -0
- package/action-icon/ActionIcon.accessibility.test.js +4 -4
- package/action-icon/ActionIcon.test.d.ts +1 -0
- package/action-icon/ActionIcon.test.js +1 -1
- package/alert/Alert.accessibility.test.d.ts +1 -0
- package/alert/Alert.accessibility.test.js +6 -6
- package/alert/Alert.js +7 -4
- 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 +5 -5
- package/badge/Badge.test.d.ts +1 -0
- package/badge/Badge.test.js +2 -2
- package/bar-chart/BarChart.d.ts +4 -0
- package/bar-chart/BarChart.js +152 -0
- package/bar-chart/BarChart.stories.tsx +281 -0
- package/bar-chart/BarChart.test.d.ts +1 -0
- package/bar-chart/BarChart.test.js +194 -0
- package/bar-chart/theme.d.ts +3 -0
- package/bar-chart/theme.js +31 -0
- package/bar-chart/types.d.ts +137 -0
- package/bar-chart/types.js +5 -0
- package/bleed/Bleed.stories.tsx +0 -1
- package/box/Box.accessibility.test.d.ts +1 -0
- package/box/Box.accessibility.test.js +3 -3
- package/box/Box.js +1 -1
- 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 +168 -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 +40 -0
- package/breadcrumbs/types.js +5 -0
- package/bulleted-list/BulletedList.accessibility.test.d.ts +1 -0
- package/bulleted-list/BulletedList.accessibility.test.js +18 -6
- package/bulleted-list/BulletedList.js +1 -1
- package/button/Button.accessibility.test.d.ts +1 -0
- package/button/Button.accessibility.test.js +6 -6
- package/button/Button.js +1 -1
- package/button/Button.stories.tsx +3 -3
- package/button/Button.test.d.ts +1 -0
- package/button/Button.test.js +1 -1
- package/card/Card.accessibility.test.d.ts +1 -0
- package/card/Card.accessibility.test.js +3 -3
- package/card/Card.js +3 -2
- package/card/Card.stories.tsx +1 -1
- 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 +5 -5
- package/checkbox/Checkbox.js +10 -13
- 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 +4 -4
- package/chip/Chip.js +3 -1
- package/chip/Chip.stories.tsx +1 -1
- package/chip/Chip.test.d.ts +1 -0
- package/chip/Chip.test.js +1 -1
- package/common/coreTokens.d.ts +0 -1
- package/common/coreTokens.js +3 -4
- package/common/variables.d.ts +47 -3
- package/common/variables.js +109 -71
- package/container/Container.stories.tsx +3 -3
- package/container/types.d.ts +113 -11
- package/contextual-menu/ContextualMenu.accessibility.test.d.ts +1 -0
- package/contextual-menu/ContextualMenu.accessibility.test.js +15 -3
- package/contextual-menu/ContextualMenu.d.ts +3 -5
- package/contextual-menu/ContextualMenu.js +118 -53
- package/contextual-menu/ContextualMenu.stories.tsx +124 -75
- package/contextual-menu/ContextualMenu.test.d.ts +1 -0
- package/contextual-menu/ContextualMenu.test.js +200 -24
- 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 +88 -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 +54 -11
- package/date-input/Calendar.js +47 -31
- package/date-input/DateInput.accessibility.test.d.ts +1 -0
- package/date-input/DateInput.accessibility.test.js +24 -11
- package/date-input/DateInput.js +27 -21
- package/date-input/DateInput.stories.tsx +18 -12
- package/date-input/DateInput.test.d.ts +1 -0
- package/date-input/DateInput.test.js +39 -39
- package/date-input/DatePicker.js +1 -1
- package/date-input/YearPicker.js +10 -5
- package/dialog/Dialog.accessibility.test.d.ts +1 -0
- package/dialog/Dialog.accessibility.test.js +5 -5
- package/dialog/Dialog.js +3 -2
- package/dialog/Dialog.stories.tsx +8 -4
- package/dialog/Dialog.test.d.ts +1 -0
- package/dialog/Dialog.test.js +111 -48
- package/divider/Divider.accessibility.test.d.ts +1 -0
- package/divider/Divider.accessibility.test.js +2 -2
- package/divider/Divider.stories.tsx +2 -1
- package/divider/Divider.test.d.ts +1 -0
- package/dropdown/Dropdown.accessibility.test.d.ts +1 -0
- package/dropdown/Dropdown.accessibility.test.js +12 -9
- package/dropdown/Dropdown.js +19 -37
- package/dropdown/Dropdown.stories.tsx +11 -11
- package/dropdown/Dropdown.test.d.ts +1 -0
- package/dropdown/Dropdown.test.js +101 -72
- package/dropdown/DropdownMenu.js +4 -4
- package/dropdown/DropdownMenuItem.js +2 -1
- package/file-input/FileInput.accessibility.test.d.ts +1 -0
- package/file-input/FileInput.accessibility.test.js +30 -23
- package/file-input/FileInput.js +3 -8
- package/file-input/FileInput.test.d.ts +1 -0
- package/file-input/FileInput.test.js +44 -22
- package/file-input/FileItem.js +7 -3
- package/file-input/types.d.ts +0 -4
- package/footer/Footer.accessibility.test.d.ts +1 -0
- package/footer/Footer.accessibility.test.js +13 -5
- package/footer/Footer.js +1 -1
- package/footer/Footer.stories.tsx +12 -0
- package/footer/Footer.test.d.ts +1 -0
- package/footer/Footer.test.js +1 -1
- package/footer/Icons.js +2 -30
- package/grid/Grid.stories.tsx +3 -1
- package/header/Header.accessibility.test.d.ts +1 -0
- package/header/Header.accessibility.test.js +16 -6
- package/header/Header.js +3 -2
- package/header/Header.stories.tsx +17 -1
- package/header/Header.test.d.ts +1 -0
- package/header/Header.test.js +1 -1
- package/header/Icons.js +1 -6
- package/heading/Heading.accessibility.test.d.ts +1 -0
- package/heading/Heading.accessibility.test.js +3 -3
- 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 +2 -2
- package/icon/Icon.js +1 -1
- package/icon/Icon.stories.tsx +1 -1
- package/image/Image.accessibility.test.d.ts +1 -0
- package/image/Image.accessibility.test.js +3 -3
- package/image/Image.js +1 -1
- package/layout/ApplicationLayout.js +4 -4
- package/link/Link.accessibility.test.d.ts +1 -0
- package/link/Link.accessibility.test.js +8 -12
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +2 -2
- package/link/Link.test.d.ts +1 -0
- package/link/Link.test.js +1 -1
- package/main.d.ts +3 -1
- package/main.js +15 -1
- package/nav-tabs/NavTabs.accessibility.test.d.ts +1 -0
- package/nav-tabs/NavTabs.accessibility.test.js +3 -3
- package/nav-tabs/NavTabs.js +19 -4
- package/nav-tabs/NavTabs.stories.tsx +18 -3
- package/nav-tabs/NavTabs.test.d.ts +1 -0
- package/nav-tabs/NavTabs.test.js +9 -7
- package/nav-tabs/Tab.js +7 -7
- package/number-input/NumberInput.accessibility.test.d.ts +1 -0
- package/number-input/NumberInput.accessibility.test.js +9 -10
- package/number-input/NumberInput.js +6 -3
- package/number-input/NumberInput.stories.tsx +11 -16
- package/number-input/NumberInput.test.d.ts +1 -0
- package/number-input/NumberInput.test.js +6 -7
- package/package.json +27 -21
- package/paginator/Paginator.accessibility.test.d.ts +1 -0
- package/paginator/Paginator.accessibility.test.js +4 -5
- package/paginator/Paginator.js +9 -5
- package/paginator/Paginator.test.d.ts +1 -0
- package/paginator/Paginator.test.js +2 -3
- package/paragraph/Paragraph.accessibility.test.d.ts +1 -0
- package/paragraph/Paragraph.accessibility.test.js +2 -2
- package/password-input/PasswordInput.accessibility.test.d.ts +1 -0
- package/password-input/PasswordInput.accessibility.test.js +7 -8
- package/password-input/PasswordInput.js +11 -7
- package/password-input/PasswordInput.stories.tsx +10 -1
- package/password-input/PasswordInput.test.d.ts +1 -0
- package/password-input/PasswordInput.test.js +6 -7
- package/progress-bar/ProgressBar.accessibility.test.d.ts +1 -0
- package/progress-bar/ProgressBar.accessibility.test.js +3 -3
- package/progress-bar/ProgressBar.js +6 -4
- 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 +2 -2
- 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 +4 -4
- package/radio-group/RadioGroup.js +14 -16
- 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 +16 -6
- package/resultset-table/ResultsetTable.js +41 -13
- package/resultset-table/ResultsetTable.stories.tsx +14 -2
- package/resultset-table/ResultsetTable.test.d.ts +1 -0
- package/resultset-table/ResultsetTable.test.js +103 -34
- package/resultset-table/types.d.ts +4 -3
- package/select/Listbox.d.ts +3 -3
- package/select/Listbox.js +29 -27
- package/select/Option.d.ts +3 -3
- package/select/Option.js +13 -8
- package/select/Select.accessibility.test.d.ts +1 -0
- package/select/Select.accessibility.test.js +18 -8
- package/select/Select.js +75 -190
- package/select/Select.stories.tsx +41 -20
- package/select/Select.test.d.ts +1 -0
- package/select/Select.test.js +42 -150
- package/select/selectUtils.d.ts +41 -0
- package/select/selectUtils.js +129 -0
- package/sidenav/Sidenav.accessibility.test.d.ts +1 -0
- package/sidenav/Sidenav.accessibility.test.js +3 -3
- package/sidenav/Sidenav.js +1 -1
- package/sidenav/Sidenav.stories.tsx +1 -1
- package/sidenav/Sidenav.test.d.ts +1 -0
- package/sidenav/Sidenav.test.js +1 -1
- package/slider/Slider.accessibility.test.d.ts +1 -0
- package/slider/Slider.accessibility.test.js +5 -6
- package/slider/Slider.js +11 -13
- package/slider/Slider.stories.tsx +180 -0
- package/slider/Slider.test.d.ts +1 -0
- package/slider/Slider.test.js +13 -11
- package/spinner/Spinner.accessibility.test.d.ts +1 -0
- package/spinner/Spinner.accessibility.test.js +6 -6
- package/spinner/Spinner.d.ts +1 -1
- package/spinner/Spinner.js +32 -47
- 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 +8 -8
- package/status-light/StatusLight.test.d.ts +1 -0
- package/status-light/StatusLight.test.js +1 -1
- package/switch/Switch.accessibility.test.d.ts +1 -0
- package/switch/Switch.accessibility.test.js +14 -5
- package/switch/Switch.js +6 -9
- package/switch/Switch.stories.tsx +12 -0
- package/switch/Switch.test.d.ts +1 -0
- package/switch/Switch.test.js +1 -1
- package/table/Table.accessibility.test.d.ts +1 -0
- package/table/Table.accessibility.test.js +16 -6
- package/table/Table.js +1 -1
- package/table/Table.stories.tsx +13 -1
- package/table/Table.test.d.ts +1 -0
- package/table/Table.test.js +2 -4
- package/tabs/Tab.js +1 -1
- package/tabs/Tabs.accessibility.test.d.ts +1 -0
- package/tabs/Tabs.accessibility.test.js +3 -3
- package/tabs/Tabs.js +1 -1
- package/tabs/Tabs.stories.tsx +7 -1
- package/tabs/Tabs.test.d.ts +1 -0
- package/tabs/Tabs.test.js +1 -1
- package/tag/Tag.accessibility.test.d.ts +1 -0
- package/tag/Tag.accessibility.test.js +4 -4
- package/tag/Tag.js +1 -1
- package/tag/Tag.stories.tsx +1 -1
- package/tag/Tag.test.d.ts +1 -0
- package/tag/Tag.test.js +1 -1
- package/text-input/Suggestion.js +1 -1
- package/text-input/Suggestions.js +14 -6
- package/text-input/TextInput.accessibility.test.d.ts +1 -0
- package/text-input/TextInput.accessibility.test.js +11 -12
- package/text-input/TextInput.js +49 -68
- package/text-input/TextInput.stories.tsx +19 -7
- package/text-input/TextInput.test.d.ts +1 -0
- package/text-input/TextInput.test.js +2 -3
- package/textarea/Textarea.accessibility.test.d.ts +1 -0
- package/textarea/Textarea.accessibility.test.js +7 -7
- package/textarea/Textarea.js +14 -13
- 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 +5 -5
- package/toggle-group/ToggleGroup.js +6 -9
- package/toggle-group/ToggleGroup.stories.tsx +1 -1
- package/toggle-group/ToggleGroup.test.d.ts +1 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/tooltip/Tooltip.accessibility.test.d.ts +1 -0
- package/tooltip/Tooltip.accessibility.test.js +144 -0
- package/tooltip/Tooltip.d.ts +4 -0
- package/tooltip/Tooltip.js +50 -0
- package/tooltip/Tooltip.stories.tsx +111 -0
- package/tooltip/Tooltip.test.d.ts +1 -0
- package/tooltip/Tooltip.test.js +112 -0
- package/tooltip/types.d.ts +16 -0
- package/tooltip/types.js +5 -0
- package/typography/Typography.accessibility.test.d.ts +1 -0
- package/typography/Typography.accessibility.test.js +12 -12
- package/typography/Typography.stories.tsx +1 -3
- package/typography/Typography.test.js +23 -0
- package/useTheme.d.ts +30 -3
- package/useTranslatedLabels.d.ts +11 -0
- package/utils/BaseTypography.js +45 -41
- package/utils/FocusLock.js +3 -2
- package/utils/useWidth.d.ts +2 -0
- package/utils/useWidth.js +30 -0
- package/wizard/Wizard.accessibility.test.d.ts +1 -0
- package/wizard/Wizard.accessibility.test.js +3 -3
- package/wizard/Wizard.js +1 -9
- package/wizard/Wizard.stories.tsx +1 -1
- package/wizard/Wizard.test.d.ts +1 -0
- package/wizard/Wizard.test.js +1 -1
- package/contextual-menu/MenuItemAction.d.ts +0 -4
- package/contextual-menu/MenuItemAction.js +0 -46
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { userEvent, within } from "@storybook/
|
|
2
|
+
import { userEvent, within } from "@storybook/test";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
5
|
import DxcSelect from "./Select";
|
|
@@ -7,10 +7,23 @@ import Listbox from "./Listbox";
|
|
|
7
7
|
import { ThemeProvider } from "styled-components";
|
|
8
8
|
import useTheme from "../useTheme";
|
|
9
9
|
import { HalstackProvider } from "../HalstackContext";
|
|
10
|
+
import { disabledRules } from "../../test/accessibility/rules/specific/select/disabledRules";
|
|
11
|
+
import preview from "../../.storybook/preview";
|
|
12
|
+
import DxcFlex from "../flex/Flex";
|
|
10
13
|
|
|
11
14
|
export default {
|
|
12
15
|
title: "Select",
|
|
13
16
|
component: DxcSelect,
|
|
17
|
+
parameters: {
|
|
18
|
+
a11y: {
|
|
19
|
+
config: {
|
|
20
|
+
rules: [
|
|
21
|
+
...disabledRules.map((ruleId) => ({ id: ruleId, reviewOnFail: true })),
|
|
22
|
+
...preview?.parameters?.a11y?.config?.rules,
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
14
27
|
};
|
|
15
28
|
|
|
16
29
|
const one_option = [{ label: "Option 01", value: "1" }];
|
|
@@ -293,6 +306,14 @@ const Select = () => (
|
|
|
293
306
|
<Title title="Fillparent size" theme="light" level={4} />
|
|
294
307
|
<DxcSelect label="Fillparent" options={single_options} size="fillParent" />
|
|
295
308
|
</ExampleContainer>
|
|
309
|
+
<ExampleContainer>
|
|
310
|
+
<Title title="Different sizes inside a flex" theme="light" level={4} />
|
|
311
|
+
<DxcFlex justifyContent="space-between" gap="1rem">
|
|
312
|
+
<DxcSelect label="fillParent" size="fillParent" options={single_options} />
|
|
313
|
+
<DxcSelect label="medium" size="medium" options={single_options} />
|
|
314
|
+
<DxcSelect label="large" size="large" options={single_options} />
|
|
315
|
+
</DxcFlex>
|
|
316
|
+
</ExampleContainer>
|
|
296
317
|
<Title title="Margins" theme="light" level={2} />
|
|
297
318
|
<ExampleContainer>
|
|
298
319
|
<Title title="xxsmall margin" theme="light" level={4} />
|
|
@@ -390,7 +411,7 @@ const Select = () => (
|
|
|
390
411
|
);
|
|
391
412
|
|
|
392
413
|
const SelectListbox = () => {
|
|
393
|
-
const colorsTheme
|
|
414
|
+
const colorsTheme = useTheme();
|
|
394
415
|
|
|
395
416
|
return (
|
|
396
417
|
<>
|
|
@@ -426,7 +447,7 @@ const SelectListbox = () => {
|
|
|
426
447
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
427
448
|
<Title title="Hovered option" theme="light" level={4} />
|
|
428
449
|
<Listbox
|
|
429
|
-
id="
|
|
450
|
+
id="x8"
|
|
430
451
|
currentValue=""
|
|
431
452
|
options={one_option}
|
|
432
453
|
visualFocusIndex={-1}
|
|
@@ -442,7 +463,7 @@ const SelectListbox = () => {
|
|
|
442
463
|
<ExampleContainer pseudoState="pseudo-active">
|
|
443
464
|
<Title title="Active option" theme="light" level={4} />
|
|
444
465
|
<Listbox
|
|
445
|
-
id="
|
|
466
|
+
id="x9"
|
|
446
467
|
currentValue=""
|
|
447
468
|
options={one_option}
|
|
448
469
|
visualFocusIndex={-1}
|
|
@@ -458,7 +479,7 @@ const SelectListbox = () => {
|
|
|
458
479
|
<ExampleContainer>
|
|
459
480
|
<Title title="Focused option" theme="light" level={4} />
|
|
460
481
|
<Listbox
|
|
461
|
-
id="
|
|
482
|
+
id="x10"
|
|
462
483
|
currentValue=""
|
|
463
484
|
options={one_option}
|
|
464
485
|
visualFocusIndex={0}
|
|
@@ -474,7 +495,7 @@ const SelectListbox = () => {
|
|
|
474
495
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
475
496
|
<Title title="Hovered selected option" theme="light" level={4} />
|
|
476
497
|
<Listbox
|
|
477
|
-
id="
|
|
498
|
+
id="x11"
|
|
478
499
|
currentValue="1"
|
|
479
500
|
options={single_options}
|
|
480
501
|
visualFocusIndex={-1}
|
|
@@ -490,7 +511,7 @@ const SelectListbox = () => {
|
|
|
490
511
|
<ExampleContainer pseudoState="pseudo-active">
|
|
491
512
|
<Title title="Active selected option" theme="light" level={4} />
|
|
492
513
|
<Listbox
|
|
493
|
-
id="
|
|
514
|
+
id="x12"
|
|
494
515
|
currentValue="2"
|
|
495
516
|
options={single_options}
|
|
496
517
|
visualFocusIndex={0}
|
|
@@ -507,7 +528,7 @@ const SelectListbox = () => {
|
|
|
507
528
|
<ExampleContainer>
|
|
508
529
|
<Title title="Icons (SVGs)" theme="light" level={4} />
|
|
509
530
|
<Listbox
|
|
510
|
-
id="
|
|
531
|
+
id="x13"
|
|
511
532
|
currentValue="3"
|
|
512
533
|
options={icon_options}
|
|
513
534
|
visualFocusIndex={-1}
|
|
@@ -523,8 +544,8 @@ const SelectListbox = () => {
|
|
|
523
544
|
<ExampleContainer>
|
|
524
545
|
<Title title="Grouped icons (Material Symbols)" theme="light" level={4} />
|
|
525
546
|
<Listbox
|
|
526
|
-
id="
|
|
527
|
-
currentValue={
|
|
547
|
+
id="x14"
|
|
548
|
+
currentValue={"4"}
|
|
528
549
|
options={icon_options_grouped_material}
|
|
529
550
|
visualFocusIndex={-1}
|
|
530
551
|
lastOptionIndex={3}
|
|
@@ -539,8 +560,8 @@ const SelectListbox = () => {
|
|
|
539
560
|
<ExampleContainer>
|
|
540
561
|
<Title title="Grouped icons (Material)" theme="light" level={4} />
|
|
541
562
|
<Listbox
|
|
542
|
-
id="
|
|
543
|
-
currentValue={["
|
|
563
|
+
id="x15"
|
|
564
|
+
currentValue={["car", "motorcycle", "train"]}
|
|
544
565
|
options={options_material}
|
|
545
566
|
visualFocusIndex={-1}
|
|
546
567
|
lastOptionIndex={6}
|
|
@@ -559,7 +580,7 @@ const SelectListbox = () => {
|
|
|
559
580
|
<Title title="Hovered option" theme="light" level={4} />
|
|
560
581
|
<HalstackProvider theme={opinionatedTheme}>
|
|
561
582
|
<Listbox
|
|
562
|
-
id="
|
|
583
|
+
id="x16"
|
|
563
584
|
currentValue=""
|
|
564
585
|
options={one_option}
|
|
565
586
|
visualFocusIndex={-1}
|
|
@@ -577,7 +598,7 @@ const SelectListbox = () => {
|
|
|
577
598
|
<Title title="Active option" theme="light" level={4} />{" "}
|
|
578
599
|
<HalstackProvider theme={opinionatedTheme}>
|
|
579
600
|
<Listbox
|
|
580
|
-
id="
|
|
601
|
+
id="x17"
|
|
581
602
|
currentValue=""
|
|
582
603
|
options={one_option}
|
|
583
604
|
visualFocusIndex={-1}
|
|
@@ -595,7 +616,7 @@ const SelectListbox = () => {
|
|
|
595
616
|
<Title title="Focused option" theme="light" level={4} />{" "}
|
|
596
617
|
<HalstackProvider theme={opinionatedTheme}>
|
|
597
618
|
<Listbox
|
|
598
|
-
id="
|
|
619
|
+
id="x18"
|
|
599
620
|
currentValue=""
|
|
600
621
|
options={one_option}
|
|
601
622
|
visualFocusIndex={0}
|
|
@@ -613,7 +634,7 @@ const SelectListbox = () => {
|
|
|
613
634
|
<Title title="Hovered selected option" theme="light" level={4} />{" "}
|
|
614
635
|
<HalstackProvider theme={opinionatedTheme}>
|
|
615
636
|
<Listbox
|
|
616
|
-
id="
|
|
637
|
+
id="x19"
|
|
617
638
|
currentValue="1"
|
|
618
639
|
options={single_options}
|
|
619
640
|
visualFocusIndex={-1}
|
|
@@ -631,7 +652,7 @@ const SelectListbox = () => {
|
|
|
631
652
|
<Title title="Active selected option" theme="light" level={4} />{" "}
|
|
632
653
|
<HalstackProvider theme={opinionatedTheme}>
|
|
633
654
|
<Listbox
|
|
634
|
-
id="
|
|
655
|
+
id="x20"
|
|
635
656
|
currentValue="2"
|
|
636
657
|
options={single_options}
|
|
637
658
|
visualFocusIndex={0}
|
|
@@ -650,7 +671,7 @@ const SelectListbox = () => {
|
|
|
650
671
|
<Title title="Icons (SVGs)" theme="light" level={4} />{" "}
|
|
651
672
|
<HalstackProvider theme={opinionatedTheme}>
|
|
652
673
|
<Listbox
|
|
653
|
-
id="
|
|
674
|
+
id="x21"
|
|
654
675
|
currentValue="3"
|
|
655
676
|
options={icon_options}
|
|
656
677
|
visualFocusIndex={-1}
|
|
@@ -728,7 +749,7 @@ const MultipleSelect = () => (
|
|
|
728
749
|
</>
|
|
729
750
|
);
|
|
730
751
|
|
|
731
|
-
const
|
|
752
|
+
const MultipleSelectOpinionated = () => (
|
|
732
753
|
<ExampleContainer expanded>
|
|
733
754
|
<Title title="Multiple select" theme="light" level={4} />
|
|
734
755
|
<HalstackProvider theme={opinionatedTheme}>
|
|
@@ -886,7 +907,7 @@ MultipleOptionsDisplayed.play = async ({ canvasElement }) => {
|
|
|
886
907
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
887
908
|
};
|
|
888
909
|
|
|
889
|
-
export const MultipleOptionsDisplayedOpinionated =
|
|
910
|
+
export const MultipleOptionsDisplayedOpinionated = MultipleSelectOpinionated.bind({});
|
|
890
911
|
MultipleOptionsDisplayedOpinionated.play = async ({ canvasElement }) => {
|
|
891
912
|
const canvas = within(canvasElement);
|
|
892
913
|
await userEvent.click(canvas.getAllByRole("combobox")[0]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/select/Select.test.js
CHANGED
|
@@ -8,7 +8,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _react2 = require("@testing-library/react");
|
|
10
10
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
11
|
-
var _Select = _interopRequireDefault(require("./Select
|
|
11
|
+
var _Select = _interopRequireDefault(require("./Select"));
|
|
12
12
|
// Mocking DOMRect for Radix Primitive Popover
|
|
13
13
|
global.globalThis = global;
|
|
14
14
|
global.DOMRect = {
|
|
@@ -27,7 +27,7 @@ global.ResizeObserver = /*#__PURE__*/function () {
|
|
|
27
27
|
function ResizeObserver() {
|
|
28
28
|
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
29
29
|
}
|
|
30
|
-
(0, _createClass2["default"])(ResizeObserver, [{
|
|
30
|
+
return (0, _createClass2["default"])(ResizeObserver, [{
|
|
31
31
|
key: "observe",
|
|
32
32
|
value: function observe() {}
|
|
33
33
|
}, {
|
|
@@ -37,7 +37,6 @@ global.ResizeObserver = /*#__PURE__*/function () {
|
|
|
37
37
|
key: "disconnect",
|
|
38
38
|
value: function disconnect() {}
|
|
39
39
|
}]);
|
|
40
|
-
return ResizeObserver;
|
|
41
40
|
}();
|
|
42
41
|
var singleOptions = [{
|
|
43
42
|
label: "Option 01",
|
|
@@ -100,70 +99,6 @@ var singleOptions = [{
|
|
|
100
99
|
label: "Option 20",
|
|
101
100
|
value: "20"
|
|
102
101
|
}];
|
|
103
|
-
var svgIconOptions = [{
|
|
104
|
-
label: "3G Mobile",
|
|
105
|
-
value: "1",
|
|
106
|
-
icon: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
107
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
108
|
-
height: "24px",
|
|
109
|
-
viewBox: "0 0 24 24",
|
|
110
|
-
width: "24px",
|
|
111
|
-
fill: "currentColor"
|
|
112
|
-
}, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
113
|
-
d: "M0,0h24v24H0V0z",
|
|
114
|
-
fill: "none"
|
|
115
|
-
})), /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
116
|
-
d: "M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z"
|
|
117
|
-
}))))
|
|
118
|
-
}, {
|
|
119
|
-
label: "Ethernet",
|
|
120
|
-
value: "2",
|
|
121
|
-
icon: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
122
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
123
|
-
height: "24px",
|
|
124
|
-
viewBox: "0 0 24 24",
|
|
125
|
-
width: "24px",
|
|
126
|
-
fill: "currentColor"
|
|
127
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
128
|
-
d: "M0 0h24v24H0V0z",
|
|
129
|
-
fill: "none"
|
|
130
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
131
|
-
d: "M7.77 6.76L6.23 5.48.82 12l5.41 6.52 1.54-1.28L3.42 12l4.35-5.24zM7 13h2v-2H7v2zm10-2h-2v2h2v-2zm-6 2h2v-2h-2v2zm6.77-7.52l-1.54 1.28L20.58 12l-4.35 5.24 1.54 1.28L23.18 12l-5.41-6.52z"
|
|
132
|
-
}))
|
|
133
|
-
}, {
|
|
134
|
-
label: "Wi-fi",
|
|
135
|
-
value: "3",
|
|
136
|
-
icon: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
137
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
138
|
-
height: "24px",
|
|
139
|
-
viewBox: "0 0 24 24",
|
|
140
|
-
width: "24px",
|
|
141
|
-
fill: "currentColor"
|
|
142
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
143
|
-
d: "M0 0h24v24H0V0zm0 0h24v24H0V0z",
|
|
144
|
-
fill: "none"
|
|
145
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
146
|
-
d: "M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z"
|
|
147
|
-
}))
|
|
148
|
-
}, {
|
|
149
|
-
label: "Settings backup restore (just for previous configuration)",
|
|
150
|
-
value: "4",
|
|
151
|
-
icon: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
152
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
153
|
-
height: "24px",
|
|
154
|
-
viewBox: "0 0 24 24",
|
|
155
|
-
width: "24px",
|
|
156
|
-
fill: "currentColor"
|
|
157
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
158
|
-
d: "M0 0h24v24H0V0z",
|
|
159
|
-
fill: "none"
|
|
160
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
161
|
-
d: "M14 12c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2zm-2-9c-4.97 0-9 4.03-9 9H0l4 4 4-4H5c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.51 0-2.91-.49-4.06-1.3l-1.42 1.44C8.04 20.3 9.94 21 12 21c4.97 0 9-4.03 9-9s-4.03-9-9-9z"
|
|
162
|
-
}))
|
|
163
|
-
}, {
|
|
164
|
-
label: "Regular",
|
|
165
|
-
value: "Regular"
|
|
166
|
-
}];
|
|
167
102
|
var groupOptions = [{
|
|
168
103
|
label: "Colores",
|
|
169
104
|
options: [{
|
|
@@ -228,41 +163,6 @@ var groupOptions = [{
|
|
|
228
163
|
value: "ebro"
|
|
229
164
|
}]
|
|
230
165
|
}];
|
|
231
|
-
var groupedIconOptions = [{
|
|
232
|
-
label: "Transport",
|
|
233
|
-
options: [{
|
|
234
|
-
label: "Electric Car",
|
|
235
|
-
value: "car",
|
|
236
|
-
icon: "electric_car"
|
|
237
|
-
}, {
|
|
238
|
-
label: "Motorcycle",
|
|
239
|
-
value: "motorcycle",
|
|
240
|
-
icon: "Motorcycle"
|
|
241
|
-
}, {
|
|
242
|
-
label: "Train",
|
|
243
|
-
value: "train",
|
|
244
|
-
icon: "train"
|
|
245
|
-
}, {
|
|
246
|
-
label: "Bike",
|
|
247
|
-
value: "bike",
|
|
248
|
-
icon: "pedal_bike"
|
|
249
|
-
}]
|
|
250
|
-
}, {
|
|
251
|
-
label: "Entertainment",
|
|
252
|
-
options: [{
|
|
253
|
-
label: "Movie",
|
|
254
|
-
value: "movie",
|
|
255
|
-
icon: "movie"
|
|
256
|
-
}, {
|
|
257
|
-
label: "Music",
|
|
258
|
-
value: "music",
|
|
259
|
-
icon: "music_note"
|
|
260
|
-
}, {
|
|
261
|
-
label: "Games",
|
|
262
|
-
value: "games",
|
|
263
|
-
icon: "joystick"
|
|
264
|
-
}]
|
|
265
|
-
}];
|
|
266
166
|
describe("Select component tests", function () {
|
|
267
167
|
test("When clicking the label, the focus goes to the select", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
268
168
|
var _render, getByText, getByRole, select, label;
|
|
@@ -272,7 +172,8 @@ describe("Select component tests", function () {
|
|
|
272
172
|
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
273
173
|
label: "test-select-label",
|
|
274
174
|
helperText: "test-select-helper-text",
|
|
275
|
-
placeholder: "Example text"
|
|
175
|
+
placeholder: "Example text",
|
|
176
|
+
options: singleOptions
|
|
276
177
|
})), getByText = _render.getByText, getByRole = _render.getByRole;
|
|
277
178
|
select = getByRole("combobox");
|
|
278
179
|
label = getByText("test-select-label");
|
|
@@ -289,7 +190,8 @@ describe("Select component tests", function () {
|
|
|
289
190
|
test("Renders with correct aria attributes when is in error state", function () {
|
|
290
191
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
291
192
|
label: "Error label",
|
|
292
|
-
error: "Error message."
|
|
193
|
+
error: "Error message.",
|
|
194
|
+
options: singleOptions
|
|
293
195
|
})),
|
|
294
196
|
getByText = _render2.getByText,
|
|
295
197
|
getByRole = _render2.getByRole;
|
|
@@ -382,15 +284,12 @@ describe("Select component tests", function () {
|
|
|
382
284
|
_context4.next = 8;
|
|
383
285
|
return _userEvent["default"].click(select);
|
|
384
286
|
case 8:
|
|
385
|
-
|
|
386
|
-
expect(getAllByRole("option")[1].getAttribute("aria-selected")).toBe("true");
|
|
387
|
-
expect(getAllByRole("option")[5].getAttribute("aria-selected")).toBe("true");
|
|
388
|
-
_context4.next = 13;
|
|
287
|
+
_context4.next = 10;
|
|
389
288
|
return _userEvent["default"].click(getAllByRole("option")[2]);
|
|
390
|
-
case
|
|
289
|
+
case 10:
|
|
391
290
|
expect(getByText("Option 02, Option 03, Option 04, Option 06")).toBeTruthy();
|
|
392
291
|
expect(submitInput.value).toBe("4,2,6,3");
|
|
393
|
-
case
|
|
292
|
+
case 12:
|
|
394
293
|
case "end":
|
|
395
294
|
return _context4.stop();
|
|
396
295
|
}
|
|
@@ -481,6 +380,7 @@ describe("Select component tests", function () {
|
|
|
481
380
|
label: "test-select-label",
|
|
482
381
|
value: ["1", "2"],
|
|
483
382
|
options: singleOptions,
|
|
383
|
+
multiple: true,
|
|
484
384
|
disabled: true
|
|
485
385
|
})), getByRole = _render8.getByRole, queryByRole = _render8.queryByRole;
|
|
486
386
|
select = getByRole("combobox");
|
|
@@ -1320,10 +1220,8 @@ describe("Select component tests", function () {
|
|
|
1320
1220
|
});
|
|
1321
1221
|
expect(queryByRole("listbox")).toBeTruthy();
|
|
1322
1222
|
expect(getByText("Option 11, Option 19")).toBeTruthy();
|
|
1323
|
-
expect(getAllByRole("option")[10].getAttribute("aria-selected")).toBe("true");
|
|
1324
|
-
expect(getAllByRole("option")[18].getAttribute("aria-selected")).toBe("true");
|
|
1325
1223
|
expect(submitInput.value).toBe("11,19");
|
|
1326
|
-
case
|
|
1224
|
+
case 19:
|
|
1327
1225
|
case "end":
|
|
1328
1226
|
return _context30.stop();
|
|
1329
1227
|
}
|
|
@@ -1399,15 +1297,14 @@ describe("Select component tests", function () {
|
|
|
1399
1297
|
return _userEvent["default"].click(select);
|
|
1400
1298
|
case 6:
|
|
1401
1299
|
expect(getAllByText("Choose an option").length).toBe(1);
|
|
1402
|
-
|
|
1403
|
-
_context32.next = 10;
|
|
1300
|
+
_context32.next = 9;
|
|
1404
1301
|
return _userEvent["default"].click(getAllByRole("option")[0]);
|
|
1405
|
-
case
|
|
1302
|
+
case 9:
|
|
1406
1303
|
expect(onChange).toHaveBeenCalledWith({
|
|
1407
1304
|
value: ["1"]
|
|
1408
1305
|
});
|
|
1409
1306
|
expect(getAllByText("Option 01").length).toBe(2);
|
|
1410
|
-
case
|
|
1307
|
+
case 11:
|
|
1411
1308
|
case "end":
|
|
1412
1309
|
return _context32.stop();
|
|
1413
1310
|
}
|
|
@@ -1566,7 +1463,7 @@ describe("Select component tests", function () {
|
|
|
1566
1463
|
_context35.next = 4;
|
|
1567
1464
|
return _userEvent["default"].click(select);
|
|
1568
1465
|
case 4:
|
|
1569
|
-
listbox = getByRole("
|
|
1466
|
+
listbox = getByRole("list");
|
|
1570
1467
|
expect(listbox).toBeTruthy();
|
|
1571
1468
|
expect(select.getAttribute("aria-expanded")).toBe("true");
|
|
1572
1469
|
expect(getByText("Colores")).toBeTruthy();
|
|
@@ -1574,7 +1471,7 @@ describe("Select component tests", function () {
|
|
|
1574
1471
|
expect(getByText("Negro")).toBeTruthy();
|
|
1575
1472
|
expect(getByText("Ciudades españolas")).toBeTruthy();
|
|
1576
1473
|
expect(getByText("Madrid")).toBeTruthy();
|
|
1577
|
-
groups = getAllByRole("
|
|
1474
|
+
groups = getAllByRole("listbox");
|
|
1578
1475
|
expect(groups.length).toBe(3);
|
|
1579
1476
|
groupLabels = getAllByRole("presentation");
|
|
1580
1477
|
expect(groups[0].getAttribute("aria-labelledby")).toBe(groupLabels[0].id);
|
|
@@ -1584,7 +1481,7 @@ describe("Select component tests", function () {
|
|
|
1584
1481
|
_context35.next = 21;
|
|
1585
1482
|
return _userEvent["default"].click(select);
|
|
1586
1483
|
case 21:
|
|
1587
|
-
expect(queryByRole("
|
|
1484
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1588
1485
|
expect(select.getAttribute("aria-expanded")).toBe("false");
|
|
1589
1486
|
case 23:
|
|
1590
1487
|
case "end":
|
|
@@ -1608,7 +1505,7 @@ describe("Select component tests", function () {
|
|
|
1608
1505
|
_context36.next = 4;
|
|
1609
1506
|
return _userEvent["default"].click(select);
|
|
1610
1507
|
case 4:
|
|
1611
|
-
expect(queryByRole("
|
|
1508
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1612
1509
|
expect(select.getAttribute("aria-expanded")).toBe("false");
|
|
1613
1510
|
case 6:
|
|
1614
1511
|
case "end":
|
|
@@ -1639,7 +1536,7 @@ describe("Select component tests", function () {
|
|
|
1639
1536
|
expect(onChange).toHaveBeenCalledWith({
|
|
1640
1537
|
value: "oviedo"
|
|
1641
1538
|
});
|
|
1642
|
-
expect(queryByRole("
|
|
1539
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1643
1540
|
expect(getByText("Oviedo")).toBeTruthy();
|
|
1644
1541
|
_context37.next = 13;
|
|
1645
1542
|
return _userEvent["default"].click(select);
|
|
@@ -1755,7 +1652,7 @@ describe("Select component tests", function () {
|
|
|
1755
1652
|
keyCode: 38,
|
|
1756
1653
|
charCode: 38
|
|
1757
1654
|
});
|
|
1758
|
-
expect(queryByRole("
|
|
1655
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
1759
1656
|
expect(select.getAttribute("aria-activedescendant")).toBe("option-17");
|
|
1760
1657
|
});
|
|
1761
1658
|
test("Grouped Options: Arrow up key - Puts the focus in last option when the first one is visually focused", function () {
|
|
@@ -1778,7 +1675,7 @@ describe("Select component tests", function () {
|
|
|
1778
1675
|
keyCode: 38,
|
|
1779
1676
|
charCode: 38
|
|
1780
1677
|
});
|
|
1781
|
-
expect(queryByRole("
|
|
1678
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
1782
1679
|
expect(select.getAttribute("aria-activedescendant")).toBe("option-17");
|
|
1783
1680
|
});
|
|
1784
1681
|
test("Grouped Options: Arrow down key - Opens the listbox and visually focus the first option", function () {
|
|
@@ -1795,7 +1692,7 @@ describe("Select component tests", function () {
|
|
|
1795
1692
|
keyCode: 40,
|
|
1796
1693
|
charCode: 40
|
|
1797
1694
|
});
|
|
1798
|
-
expect(queryByRole("
|
|
1695
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
1799
1696
|
expect(select.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
1800
1697
|
});
|
|
1801
1698
|
test("Grouped Options: Arrow down key - Puts the focus in the first option when the last one is visually focused", function () {
|
|
@@ -1818,7 +1715,7 @@ describe("Select component tests", function () {
|
|
|
1818
1715
|
keyCode: 40,
|
|
1819
1716
|
charCode: 40
|
|
1820
1717
|
});
|
|
1821
|
-
expect(queryByRole("
|
|
1718
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
1822
1719
|
expect(select.getAttribute("aria-activedescendant")).toBe("option-0");
|
|
1823
1720
|
});
|
|
1824
1721
|
test("Grouped Options: Enter key - Selects the visually focused option and closes the listbox", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee40() {
|
|
@@ -1867,7 +1764,7 @@ describe("Select component tests", function () {
|
|
|
1867
1764
|
expect(onChange).toHaveBeenCalledWith({
|
|
1868
1765
|
value: "ebro"
|
|
1869
1766
|
});
|
|
1870
|
-
expect(queryByRole("
|
|
1767
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1871
1768
|
expect(getByText("Ebro")).toBeTruthy();
|
|
1872
1769
|
_context40.next = 13;
|
|
1873
1770
|
return _userEvent["default"].click(select);
|
|
@@ -1896,29 +1793,28 @@ describe("Select component tests", function () {
|
|
|
1896
1793
|
_context41.next = 6;
|
|
1897
1794
|
return _userEvent["default"].click(select);
|
|
1898
1795
|
case 6:
|
|
1899
|
-
expect(getByRole("
|
|
1796
|
+
expect(getByRole("list")).toBeTruthy();
|
|
1900
1797
|
_context41.next = 9;
|
|
1901
1798
|
return _userEvent["default"].type(searchInput, "ro");
|
|
1902
1799
|
case 9:
|
|
1903
|
-
expect(getAllByRole("group").length).toBe(2);
|
|
1904
1800
|
expect(getAllByRole("presentation").length).toBe(2);
|
|
1905
1801
|
expect(getAllByRole("option").length).toBe(5);
|
|
1906
1802
|
expect(getByText("Colores")).toBeTruthy();
|
|
1907
1803
|
expect(getByText("Ríos españoles")).toBeTruthy();
|
|
1908
|
-
_context41.next =
|
|
1804
|
+
_context41.next = 15;
|
|
1909
1805
|
return _userEvent["default"].click(getAllByRole("option")[4]);
|
|
1910
|
-
case
|
|
1806
|
+
case 15:
|
|
1911
1807
|
expect(onChange).toHaveBeenCalledWith({
|
|
1912
1808
|
value: "ebro"
|
|
1913
1809
|
});
|
|
1914
|
-
expect(queryByRole("
|
|
1810
|
+
expect(queryByRole("list")).toBeFalsy();
|
|
1915
1811
|
expect(getByText("Ebro")).toBeTruthy();
|
|
1916
1812
|
expect(searchInput.value).toBe("");
|
|
1917
|
-
_context41.next =
|
|
1813
|
+
_context41.next = 21;
|
|
1918
1814
|
return _userEvent["default"].click(select);
|
|
1919
|
-
case
|
|
1815
|
+
case 21:
|
|
1920
1816
|
expect(getAllByRole("option")[17].getAttribute("aria-selected")).toBe("true");
|
|
1921
|
-
case
|
|
1817
|
+
case 22:
|
|
1922
1818
|
case "end":
|
|
1923
1819
|
return _context41.stop();
|
|
1924
1820
|
}
|
|
@@ -1941,7 +1837,7 @@ describe("Select component tests", function () {
|
|
|
1941
1837
|
_context42.next = 6;
|
|
1942
1838
|
return _userEvent["default"].click(select);
|
|
1943
1839
|
case 6:
|
|
1944
|
-
expect(getByRole("
|
|
1840
|
+
expect(getByRole("list")).toBeTruthy();
|
|
1945
1841
|
_context42.next = 9;
|
|
1946
1842
|
return _userEvent["default"].type(searchInput, "very long string");
|
|
1947
1843
|
case 9:
|
|
@@ -1970,14 +1866,13 @@ describe("Select component tests", function () {
|
|
|
1970
1866
|
_context43.next = 6;
|
|
1971
1867
|
return _userEvent["default"].click(select);
|
|
1972
1868
|
case 6:
|
|
1973
|
-
|
|
1974
|
-
_context43.next = 9;
|
|
1869
|
+
_context43.next = 8;
|
|
1975
1870
|
return _userEvent["default"].click(getAllByRole("option")[10]);
|
|
1976
|
-
case
|
|
1871
|
+
case 8:
|
|
1977
1872
|
expect(onChange).toHaveBeenCalledWith({
|
|
1978
1873
|
value: ["bilbao"]
|
|
1979
1874
|
});
|
|
1980
|
-
expect(queryByRole("
|
|
1875
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
1981
1876
|
expect(getAllByText("Bilbao").length).toBe(2);
|
|
1982
1877
|
_react2.fireEvent.keyDown(select, {
|
|
1983
1878
|
key: "ArrowUp",
|
|
@@ -2000,12 +1895,10 @@ describe("Select component tests", function () {
|
|
|
2000
1895
|
expect(onChange).toHaveBeenCalledWith({
|
|
2001
1896
|
value: ["bilbao", "guadalquivir"]
|
|
2002
1897
|
});
|
|
2003
|
-
expect(queryByRole("
|
|
1898
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
2004
1899
|
expect(getByText("Bilbao, Guadalquivir")).toBeTruthy();
|
|
2005
|
-
expect(getAllByRole("option")[10].getAttribute("aria-selected")).toBe("true");
|
|
2006
|
-
expect(getAllByRole("option")[16].getAttribute("aria-selected")).toBe("true");
|
|
2007
1900
|
expect(submitInput.value).toBe("bilbao,guadalquivir");
|
|
2008
|
-
case
|
|
1901
|
+
case 18:
|
|
2009
1902
|
case "end":
|
|
2010
1903
|
return _context43.stop();
|
|
2011
1904
|
}
|
|
@@ -2042,7 +1935,7 @@ describe("Select component tests", function () {
|
|
|
2042
1935
|
expect(onChange).toHaveBeenCalledWith({
|
|
2043
1936
|
value: ["blanco", "oviedo", "duero", "ebro"]
|
|
2044
1937
|
});
|
|
2045
|
-
expect(queryByRole("
|
|
1938
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
2046
1939
|
expect(getByText("Blanco, Oviedo, Duero, Ebro")).toBeTruthy();
|
|
2047
1940
|
expect(getByText("4", {
|
|
2048
1941
|
exact: true
|
|
@@ -2050,7 +1943,7 @@ describe("Select component tests", function () {
|
|
|
2050
1943
|
_context44.next = 19;
|
|
2051
1944
|
return _userEvent["default"].click(getByTitle("Clear selection"));
|
|
2052
1945
|
case 19:
|
|
2053
|
-
expect(queryByRole("
|
|
1946
|
+
expect(queryByRole("list")).toBeTruthy();
|
|
2054
1947
|
expect(queryByText("Blanco, Oviedo, Duero, Ebro")).toBeFalsy();
|
|
2055
1948
|
expect(queryByText("4")).toBeFalsy();
|
|
2056
1949
|
expect(queryByTitle("Clear selection")).toBeFalsy();
|
|
@@ -2080,15 +1973,14 @@ describe("Select component tests", function () {
|
|
|
2080
1973
|
return _userEvent["default"].click(select);
|
|
2081
1974
|
case 6:
|
|
2082
1975
|
expect(getAllByText("Choose an option").length).toBe(1);
|
|
2083
|
-
|
|
2084
|
-
_context45.next = 10;
|
|
1976
|
+
_context45.next = 9;
|
|
2085
1977
|
return _userEvent["default"].click(getAllByRole("option")[0]);
|
|
2086
|
-
case
|
|
1978
|
+
case 9:
|
|
2087
1979
|
expect(onChange).toHaveBeenCalledWith({
|
|
2088
1980
|
value: ["azul"]
|
|
2089
1981
|
});
|
|
2090
1982
|
expect(getAllByText("Azul").length).toBe(2);
|
|
2091
|
-
case
|
|
1983
|
+
case 11:
|
|
2092
1984
|
case "end":
|
|
2093
1985
|
return _context45.stop();
|
|
2094
1986
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Option, OptionGroup } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Check if the value is not optional and is empty.
|
|
4
|
+
*/
|
|
5
|
+
declare const notOptionalCheck: (value: string | string[], multiple: boolean, optional: boolean) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the option is a group.
|
|
8
|
+
*/
|
|
9
|
+
declare const isOptionGroup: (option: Option | OptionGroup) => option is OptionGroup;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the options are an array of groups.
|
|
12
|
+
*/
|
|
13
|
+
declare const isArrayOfOptionGroups: (options: Option[] | OptionGroup[]) => options is OptionGroup[];
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the groups have options.
|
|
16
|
+
*/
|
|
17
|
+
declare const groupsHaveOptions: (options: Option[] | OptionGroup[]) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the listbox can be opened.
|
|
20
|
+
*/
|
|
21
|
+
declare const canOpenListbox: (options: Option[] | OptionGroup[], disabled: boolean) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Filters the options by the search value.
|
|
24
|
+
*/
|
|
25
|
+
declare const filterOptionsBySearchValue: (options: Option[] | OptionGroup[], searchValue: string) => Option[] | OptionGroup[];
|
|
26
|
+
/**
|
|
27
|
+
* Returns the index of the last option, depending on several conditions.
|
|
28
|
+
*/
|
|
29
|
+
declare const getLastOptionIndex: (options: Option[] | OptionGroup[], filteredOptions: Option[] | OptionGroup[], searchable: boolean, optional: boolean, multiple: boolean) => number;
|
|
30
|
+
/**
|
|
31
|
+
* Return the current selection.
|
|
32
|
+
*/
|
|
33
|
+
declare const getSelectedOption: (value: string | string[], options: Option[] | OptionGroup[], multiple: boolean, optional: boolean, optionalItem: Option) => {
|
|
34
|
+
selectedOption: Option | Option[];
|
|
35
|
+
singleSelectionIndex: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Return the label or labels of the selected option(s) for the internal input.
|
|
39
|
+
*/
|
|
40
|
+
declare const getSelectedOptionLabel: (placeholder: string, selectedOption: Option | Option[]) => string;
|
|
41
|
+
export { isOptionGroup, isArrayOfOptionGroups, notOptionalCheck, groupsHaveOptions, canOpenListbox as canOpenOptions, filterOptionsBySearchValue, getLastOptionIndex, getSelectedOption, getSelectedOptionLabel, };
|