@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,69 @@
|
|
|
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 _Chip = _interopRequireDefault(require("./Chip"));
|
|
10
|
+
var iconSVG = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
11
|
+
version: "1.1",
|
|
12
|
+
x: "0px",
|
|
13
|
+
y: "0px",
|
|
14
|
+
width: "438.536px",
|
|
15
|
+
height: "438.536px",
|
|
16
|
+
viewBox: "0 0 438.536 438.536",
|
|
17
|
+
fill: "currentColor"
|
|
18
|
+
}, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
|
|
19
|
+
d: "M414.41,24.123C398.333,8.042,378.963,0,356.315,0H82.228C59.58,0,40.21,8.042,24.126,24.123\nC8.045,40.207,0.003,59.576,0.003,82.225v274.084c0,22.647,8.042,42.018,24.123,58.102c16.084,16.084,35.454,24.126,58.102,24.126\nh274.084c22.648,0,42.018-8.042,58.095-24.126c16.084-16.084,24.126-35.454,24.126-58.102V82.225\nC438.532,59.576,430.49,40.204,414.41,24.123z M373.155,225.548h-49.963V406.84h-74.802V225.548H210.99V163.02h37.401v-37.402\nc0-26.838,6.283-47.107,18.843-60.813c12.559-13.706,33.304-20.555,62.242-20.555h49.963v62.526h-31.401\nc-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.119h56.534L373.155,225.548z"
|
|
20
|
+
})));
|
|
21
|
+
describe("Chip component accessibility tests", function () {
|
|
22
|
+
it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
23
|
+
var _render, container, results;
|
|
24
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
28
|
+
margin: "small",
|
|
29
|
+
prefixIcon: iconSVG,
|
|
30
|
+
onClickPrefix: function onClickPrefix() {},
|
|
31
|
+
suffixIcon: iconSVG,
|
|
32
|
+
label: "Chip"
|
|
33
|
+
})), container = _render.container;
|
|
34
|
+
_context.next = 3;
|
|
35
|
+
return (0, _axeHelper.axe)(container);
|
|
36
|
+
case 3:
|
|
37
|
+
results = _context.sent;
|
|
38
|
+
expect(results).toHaveNoViolations();
|
|
39
|
+
case 5:
|
|
40
|
+
case "end":
|
|
41
|
+
return _context.stop();
|
|
42
|
+
}
|
|
43
|
+
}, _callee);
|
|
44
|
+
})));
|
|
45
|
+
it("Should not have basic accessibility issues for disabled mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
46
|
+
var _render2, container, results;
|
|
47
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
48
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
49
|
+
case 0:
|
|
50
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
51
|
+
margin: "small",
|
|
52
|
+
prefixIcon: iconSVG,
|
|
53
|
+
onClickPrefix: function onClickPrefix() {},
|
|
54
|
+
suffixIcon: iconSVG,
|
|
55
|
+
label: "Chip",
|
|
56
|
+
disabled: true
|
|
57
|
+
})), container = _render2.container;
|
|
58
|
+
_context2.next = 3;
|
|
59
|
+
return (0, _axeHelper.axe)(container);
|
|
60
|
+
case 3:
|
|
61
|
+
results = _context2.sent;
|
|
62
|
+
expect(results).toHaveNoViolations();
|
|
63
|
+
case 5:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context2.stop();
|
|
66
|
+
}
|
|
67
|
+
}, _callee2);
|
|
68
|
+
})));
|
|
69
|
+
});
|
package/chip/Chip.js
CHANGED
|
@@ -13,9 +13,10 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
13
13
|
var _variables = require("../common/variables");
|
|
14
14
|
var _utils = require("../common/utils");
|
|
15
15
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
16
|
+
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
16
17
|
var _templateObject, _templateObject2, _templateObject3;
|
|
17
18
|
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); }
|
|
18
|
-
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 &&
|
|
19
|
+
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; }
|
|
19
20
|
var DxcChip = function DxcChip(_ref) {
|
|
20
21
|
var label = _ref.label,
|
|
21
22
|
suffixIcon = _ref.suffixIcon,
|
|
@@ -30,41 +31,36 @@ var DxcChip = function DxcChip(_ref) {
|
|
|
30
31
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
31
32
|
theme: colorsTheme.chip
|
|
32
33
|
}, /*#__PURE__*/_react["default"].createElement(Chip, {
|
|
33
|
-
disabled: disabled,
|
|
34
34
|
margin: margin
|
|
35
35
|
}, prefixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
36
36
|
role: typeof onClickPrefix === "function" ? "button" : undefined,
|
|
37
|
+
"aria-label": typeof onClickPrefix === "function" ? "Prefix Action" : undefined,
|
|
37
38
|
disabled: disabled,
|
|
38
39
|
interactuable: typeof onClickPrefix === "function" && !disabled,
|
|
39
40
|
tabIndex: typeof onClickPrefix === "function" && !disabled ? tabIndex : -1,
|
|
40
|
-
onClick:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
src: prefixIcon
|
|
45
|
-
}) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
46
|
-
disabled: disabled
|
|
47
|
-
}, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
41
|
+
onClick: onClickPrefix
|
|
42
|
+
}, typeof prefixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
43
|
+
icon: prefixIcon
|
|
44
|
+
}) : prefixIcon), label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label), suffixIcon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
48
45
|
role: typeof onClickSuffix === "function" ? "button" : undefined,
|
|
46
|
+
"aria-label": typeof onClickSuffix === "function" ? "Suffix Action" : undefined,
|
|
49
47
|
disabled: disabled,
|
|
50
48
|
interactuable: typeof onClickSuffix === "function" && !disabled,
|
|
51
49
|
tabIndex: typeof onClickSuffix === "function" && !disabled ? tabIndex : -1,
|
|
52
|
-
onClick:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
56
|
-
src: suffixIcon
|
|
50
|
+
onClick: onClickSuffix
|
|
51
|
+
}, typeof suffixIcon === "string" ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
52
|
+
icon: suffixIcon
|
|
57
53
|
}) : suffixIcon)));
|
|
58
54
|
};
|
|
59
55
|
var calculateWidth = function calculateWidth(margin) {
|
|
60
56
|
return "calc(100% - ".concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
61
57
|
};
|
|
62
|
-
var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n
|
|
58
|
+
var Chip = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: ", ";\n min-height: 40px;\n max-width: ", ";\n background-color: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
63
59
|
return props.theme.iconSpacing;
|
|
64
60
|
}, function (props) {
|
|
65
61
|
return calculateWidth(props.margin);
|
|
66
62
|
}, function (props) {
|
|
67
|
-
return props.
|
|
63
|
+
return props.theme.backgroundColor;
|
|
68
64
|
}, function (props) {
|
|
69
65
|
return props.theme.borderRadius;
|
|
70
66
|
}, function (props) {
|
|
@@ -91,9 +87,6 @@ var Chip = _styledComponents["default"].div(_templateObject || (_templateObject
|
|
|
91
87
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
92
88
|
}, function (props) {
|
|
93
89
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
94
|
-
}, function (_ref2) {
|
|
95
|
-
var disabled = _ref2.disabled;
|
|
96
|
-
return disabled && "not-allowed";
|
|
97
90
|
});
|
|
98
91
|
var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-weight: ", ";\n font-style: ", ";\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n"])), function (props) {
|
|
99
92
|
return props.theme.fontSize;
|
|
@@ -104,18 +97,19 @@ var LabelContainer = _styledComponents["default"].span(_templateObject2 || (_tem
|
|
|
104
97
|
}, function (props) {
|
|
105
98
|
return props.theme.fontStyle;
|
|
106
99
|
}, function (props) {
|
|
107
|
-
return props.
|
|
100
|
+
return props.theme.fontColor;
|
|
108
101
|
});
|
|
109
|
-
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n ", "
|
|
110
|
-
return props.disabled ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
111
|
-
}, function (
|
|
112
|
-
|
|
113
|
-
return interactuable && "cursor: pointer;";
|
|
102
|
+
var IconContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n border-radius: 0.25rem;\n color: ", ";\n cursor: ", ";\n ", "\n\n font-size: ", ";\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
103
|
+
return props.disabled && (props.onClick || props.onClick) ? props.theme.disabledIconColor : props.theme.iconColor;
|
|
104
|
+
}, function (props) {
|
|
105
|
+
return props.disabled && (props.onClick || props.onClick) ? "not-allowed" : props.interactuable ? "pointer" : "";
|
|
114
106
|
}, function (props) {
|
|
115
107
|
return props.interactuable && "\n &:hover {\n color: ".concat(props.theme.hoverIconColor, ";\n }\n &:focus,\n &:focus-visible {\n outline: ").concat(props.theme.focusBorderThickness, " ").concat(props.theme.focusBorderStyle, " ").concat(props.theme.focusColor, ";\n }\n &:active {\n color: ").concat(props.theme.activeIconColor, ";\n }\n ");
|
|
116
108
|
}, function (props) {
|
|
117
109
|
return props.theme.iconSize;
|
|
118
110
|
}, function (props) {
|
|
119
111
|
return props.theme.iconSize;
|
|
112
|
+
}, function (props) {
|
|
113
|
+
return props.theme.iconSize;
|
|
120
114
|
});
|
|
121
115
|
var _default = exports["default"] = DxcChip;
|
package/chip/Chip.stories.tsx
CHANGED
|
@@ -13,7 +13,6 @@ export default {
|
|
|
13
13
|
const iconSVG = (
|
|
14
14
|
<svg
|
|
15
15
|
version="1.1"
|
|
16
|
-
id="Capa_1"
|
|
17
16
|
x="0px"
|
|
18
17
|
y="0px"
|
|
19
18
|
width="438.536px"
|
|
@@ -34,12 +33,6 @@ c-10.663,0-17.467,1.853-20.417,5.568c-2.949,3.711-4.428,10.23-4.428,19.558v31.11
|
|
|
34
33
|
</svg>
|
|
35
34
|
);
|
|
36
35
|
|
|
37
|
-
const smallIconSVG = (
|
|
38
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" height="20" width="20">
|
|
39
|
-
<path d="m10 17-1.042-.938q-2.083-1.854-3.437-3.177-1.354-1.323-2.136-2.354Q2.604 9.5 2.302 8.646 2 7.792 2 6.896q0-1.854 1.271-3.125T6.396 2.5q1.021 0 1.979.438.958.437 1.625 1.229.667-.792 1.625-1.229.958-.438 1.979-.438 1.854 0 3.125 1.271T18 6.896q0 .896-.292 1.729-.291.833-1.073 1.854-.781 1.021-2.145 2.365-1.365 1.344-3.49 3.26Zm0-2.021q1.938-1.729 3.188-2.948 1.25-1.219 1.989-2.125.74-.906 1.031-1.614.292-.709.292-1.396 0-1.229-.833-2.063Q14.833 4 13.604 4q-.729 0-1.364.302-.636.302-1.094.844L10.417 6h-.834l-.729-.854q-.458-.542-1.114-.844Q7.083 4 6.396 4q-1.229 0-2.063.833-.833.834-.833 2.063 0 .687.271 1.364.271.678.989 1.573.719.896 1.98 2.125Q8 13.188 10 14.979Zm0-5.5Z" />
|
|
40
|
-
</svg>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
36
|
const opinionatedTheme = {
|
|
44
37
|
chip: {
|
|
45
38
|
baseColor: "#e6e6e6",
|
|
@@ -51,42 +44,79 @@ const opinionatedTheme = {
|
|
|
51
44
|
export const Chromatic = () => (
|
|
52
45
|
<>
|
|
53
46
|
<ExampleContainer>
|
|
54
|
-
<Title title="
|
|
55
|
-
<DxcChip label="Default
|
|
47
|
+
<Title title="Default" theme="light" level={4} />
|
|
48
|
+
<DxcChip label="Default" />
|
|
49
|
+
</ExampleContainer>
|
|
50
|
+
<ExampleContainer>
|
|
51
|
+
<Title title="With prefix (SVG)" theme="light" level={4} />
|
|
52
|
+
<DxcChip label="Prefix" prefixIcon={iconSVG} />
|
|
56
53
|
</ExampleContainer>
|
|
57
54
|
<ExampleContainer>
|
|
58
|
-
<Title title="
|
|
59
|
-
<DxcChip label="
|
|
55
|
+
<Title title="With action prefix (SVG)" theme="light" level={4} />
|
|
56
|
+
<DxcChip label="Action prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
|
|
57
|
+
</ExampleContainer>
|
|
58
|
+
<ExampleContainer>
|
|
59
|
+
<Title title="Disabled action prefix (SVG)" theme="light" level={4} />
|
|
60
|
+
<DxcChip label="Disabled action prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} disabled />
|
|
61
|
+
</ExampleContainer>
|
|
62
|
+
<ExampleContainer>
|
|
63
|
+
<Title title="With suffix (Material icon)" theme="light" level={4} />
|
|
64
|
+
<DxcChip label="Suffix" suffixIcon="filled_check_circle" />
|
|
65
|
+
</ExampleContainer>
|
|
66
|
+
<ExampleContainer>
|
|
67
|
+
<Title title="With action suffix (Material icon)" theme="light" level={4} />
|
|
68
|
+
<DxcChip label="Action suffix" suffixIcon="filled_check_circle" onClickSuffix={() => {}} />
|
|
69
|
+
</ExampleContainer>
|
|
70
|
+
<ExampleContainer>
|
|
71
|
+
<Title title="Action prefix and suffix" theme="light" level={4} />
|
|
72
|
+
<DxcChip
|
|
73
|
+
label="Action prefix and suffix"
|
|
74
|
+
prefixIcon="filled_check_circle"
|
|
75
|
+
onClickPrefix={() => {}}
|
|
76
|
+
suffixIcon={iconSVG}
|
|
77
|
+
/>
|
|
78
|
+
</ExampleContainer>
|
|
79
|
+
<ExampleContainer>
|
|
80
|
+
<Title title="Prefix and action suffix" theme="light" level={4} />
|
|
81
|
+
<DxcChip
|
|
82
|
+
label="Prefix and action suffix"
|
|
83
|
+
prefixIcon="filled_check_circle"
|
|
84
|
+
suffixIcon={iconSVG}
|
|
85
|
+
onClickSuffix={() => {}}
|
|
86
|
+
/>
|
|
60
87
|
</ExampleContainer>
|
|
61
88
|
<ExampleContainer>
|
|
62
|
-
<Title title="
|
|
63
|
-
<DxcChip label="
|
|
89
|
+
<Title title="Disabled action suffix (Material icon)" theme="light" level={4} />
|
|
90
|
+
<DxcChip label="Disabled action suffix" suffixIcon="filled_check_circle" onClickSuffix={() => {}} disabled />
|
|
64
91
|
</ExampleContainer>
|
|
65
92
|
<ExampleContainer>
|
|
66
|
-
<Title title="
|
|
93
|
+
<Title title="Disabled action prefix and suffix" theme="light" level={4} />
|
|
67
94
|
<DxcChip
|
|
68
|
-
label="
|
|
95
|
+
label="Disabled action prefix"
|
|
96
|
+
disabled
|
|
69
97
|
prefixIcon={iconSVG}
|
|
70
|
-
|
|
98
|
+
onClickPrefix={() => {}}
|
|
99
|
+
suffixIcon="filled_check_circle"
|
|
71
100
|
/>
|
|
72
101
|
</ExampleContainer>
|
|
73
102
|
<ExampleContainer>
|
|
74
|
-
<Title title="
|
|
103
|
+
<Title title="Prefix and disabled action suffix" theme="light" level={4} />
|
|
75
104
|
<DxcChip
|
|
76
|
-
label="Disabled"
|
|
105
|
+
label="Disabled action suffix"
|
|
77
106
|
disabled
|
|
78
107
|
prefixIcon={iconSVG}
|
|
79
|
-
suffixIcon="
|
|
108
|
+
suffixIcon="filled_check_circle"
|
|
109
|
+
onClickSuffix={() => {}}
|
|
80
110
|
/>
|
|
81
111
|
</ExampleContainer>
|
|
82
112
|
<ExampleContainer>
|
|
83
|
-
<Title title="
|
|
113
|
+
<Title title="With ellipsis" theme="light" level={4} />
|
|
84
114
|
<div style={{ width: "200px" }}>
|
|
85
115
|
<DxcChip label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasd fg ssssssssssss ssss" />
|
|
86
116
|
</div>
|
|
87
117
|
</ExampleContainer>
|
|
88
118
|
<ExampleContainer>
|
|
89
|
-
<Title title="
|
|
119
|
+
<Title title="With ellipsis and suffix" theme="light" level={4} />
|
|
90
120
|
<div style={{ width: "200px" }}>
|
|
91
121
|
<DxcChip
|
|
92
122
|
suffixIcon={iconSVG}
|
|
@@ -95,7 +125,7 @@ export const Chromatic = () => (
|
|
|
95
125
|
</div>
|
|
96
126
|
</ExampleContainer>
|
|
97
127
|
<ExampleContainer>
|
|
98
|
-
<Title title="
|
|
128
|
+
<Title title="With ellipsis and prefix" theme="light" level={4} />
|
|
99
129
|
<div style={{ width: "200px" }}>
|
|
100
130
|
<DxcChip
|
|
101
131
|
prefixIcon={iconSVG}
|
|
@@ -104,10 +134,11 @@ export const Chromatic = () => (
|
|
|
104
134
|
</div>
|
|
105
135
|
</ExampleContainer>
|
|
106
136
|
<ExampleContainer>
|
|
107
|
-
<Title title="
|
|
137
|
+
<Title title="With ellipsis, action prefix and suffix" theme="light" level={4} />
|
|
108
138
|
<div style={{ width: "200px" }}>
|
|
109
139
|
<DxcChip
|
|
110
140
|
prefixIcon={iconSVG}
|
|
141
|
+
onClickPrefix={() => {}}
|
|
111
142
|
suffixIcon={iconSVG}
|
|
112
143
|
label="With ellipsis asdfasdf asdf asdfasdf asdf asdfasdf asdfasdf asdf asdf adfasrfasf afsdg afgasfg asdf asdf asdf asdf asdf asdf asdf afdg asfg asdfg asdf asdf asdf asdfasdf asd fas df asd asdf asdf asdfasdf"
|
|
113
144
|
/>
|
|
@@ -144,62 +175,48 @@ export const Chromatic = () => (
|
|
|
144
175
|
</ExampleContainer>
|
|
145
176
|
<Title title="Opinionated theme" theme="light" level={2} />
|
|
146
177
|
<ExampleContainer>
|
|
147
|
-
<Title title="
|
|
178
|
+
<Title title="With prefix and suffix" theme="light" level={4} />
|
|
148
179
|
<HalstackProvider theme={opinionatedTheme}>
|
|
149
|
-
<DxcChip
|
|
150
|
-
label="Chip"
|
|
151
|
-
prefixIcon={iconSVG}
|
|
152
|
-
suffixIcon="https://upload.wikimedia.org/wikipedia/commons/e/e0/Check_green_icon.svg"
|
|
153
|
-
/>
|
|
180
|
+
<DxcChip label="Chip" prefixIcon={iconSVG} onClickPrefix={() => {}} suffixIcon="filled_check_circle" />
|
|
154
181
|
</HalstackProvider>
|
|
155
182
|
</ExampleContainer>
|
|
156
183
|
<ExampleContainer>
|
|
157
|
-
<Title title="
|
|
184
|
+
<Title title="With prefix and suffix" theme="light" level={4} />
|
|
158
185
|
<HalstackProvider theme={opinionatedTheme}>
|
|
159
186
|
<DxcChip
|
|
160
|
-
label="
|
|
187
|
+
label="Disabled"
|
|
161
188
|
disabled
|
|
162
189
|
prefixIcon={iconSVG}
|
|
163
|
-
suffixIcon="
|
|
190
|
+
suffixIcon="filled_check_circle"
|
|
191
|
+
onClickSuffix={() => {}}
|
|
164
192
|
/>
|
|
165
193
|
</HalstackProvider>
|
|
166
194
|
</ExampleContainer>
|
|
167
195
|
<ExampleContainer pseudoState="pseudo-hover">
|
|
168
196
|
<Title title="Hovered" theme="light" level={4} />
|
|
169
197
|
<HalstackProvider theme={opinionatedTheme}>
|
|
170
|
-
<DxcChip
|
|
171
|
-
label="Chip"
|
|
172
|
-
prefixIcon={iconSVG}
|
|
173
|
-
suffixIcon={iconSVG}
|
|
174
|
-
onClickPrefix={() => {}}
|
|
175
|
-
onClickSuffix={() => {}}
|
|
176
|
-
/>
|
|
198
|
+
<DxcChip label="Chip" prefixIcon={iconSVG} suffixIcon={iconSVG} onClickPrefix={() => {}} />
|
|
177
199
|
</HalstackProvider>
|
|
178
200
|
</ExampleContainer>
|
|
179
201
|
<ExampleContainer pseudoState="pseudo-active">
|
|
180
202
|
<Title title="Actived" theme="light" level={4} />
|
|
181
203
|
<HalstackProvider theme={opinionatedTheme}>
|
|
182
|
-
<DxcChip
|
|
183
|
-
label="Chip"
|
|
184
|
-
prefixIcon={iconSVG}
|
|
185
|
-
suffixIcon={iconSVG}
|
|
186
|
-
onClickPrefix={() => {}}
|
|
187
|
-
onClickSuffix={() => {}}
|
|
188
|
-
/>
|
|
204
|
+
<DxcChip label="Chip" prefixIcon={iconSVG} suffixIcon={iconSVG} onClickPrefix={() => {}} />
|
|
189
205
|
</HalstackProvider>
|
|
190
206
|
</ExampleContainer>
|
|
191
207
|
</>
|
|
192
208
|
);
|
|
209
|
+
|
|
193
210
|
const ChipPrefixFocused = () => (
|
|
194
211
|
<ExampleContainer>
|
|
195
|
-
<Title title="
|
|
196
|
-
<DxcChip label="
|
|
212
|
+
<Title title="With prefix" theme="light" level={4} />
|
|
213
|
+
<DxcChip label="Prefix" prefixIcon={iconSVG} onClickPrefix={() => {}} />
|
|
197
214
|
</ExampleContainer>
|
|
198
215
|
);
|
|
199
216
|
const ChipSuffixFocused = () => (
|
|
200
217
|
<ExampleContainer>
|
|
201
|
-
<Title title="
|
|
202
|
-
<DxcChip label="
|
|
218
|
+
<Title title="With suffix" theme="light" level={4} />
|
|
219
|
+
<DxcChip label="Suffix" suffixIcon="filled_delete" onClickSuffix={() => {}} />
|
|
203
220
|
</ExampleContainer>
|
|
204
221
|
);
|
|
205
222
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/chip/Chip.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 _Chip = _interopRequireDefault(require("./Chip
|
|
6
|
+
var _Chip = _interopRequireDefault(require("./Chip"));
|
|
7
7
|
describe("Chip component tests", function () {
|
|
8
8
|
test("Chip renders with correct text", function () {
|
|
9
9
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
@@ -16,26 +16,26 @@ describe("Chip component tests", function () {
|
|
|
16
16
|
var onClick = jest.fn();
|
|
17
17
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
18
18
|
label: "Chip",
|
|
19
|
-
prefixIcon: "
|
|
19
|
+
prefixIcon: "nutrition",
|
|
20
20
|
onClickPrefix: onClick
|
|
21
21
|
})),
|
|
22
22
|
getByText = _render2.getByText,
|
|
23
23
|
getByRole = _render2.getByRole;
|
|
24
24
|
expect(getByText("Chip")).toBeTruthy();
|
|
25
|
-
_react2.fireEvent.click(getByRole("
|
|
25
|
+
_react2.fireEvent.click(getByRole("button"));
|
|
26
26
|
expect(onClick).toHaveBeenCalled();
|
|
27
27
|
});
|
|
28
28
|
test("Calls correct function when clicking on suffix icon", function () {
|
|
29
29
|
var onClick = jest.fn();
|
|
30
30
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
31
31
|
label: "Chip",
|
|
32
|
-
suffixIcon: "
|
|
32
|
+
suffixIcon: "nutrition",
|
|
33
33
|
onClickSuffix: onClick
|
|
34
34
|
})),
|
|
35
35
|
getByText = _render3.getByText,
|
|
36
36
|
getByRole = _render3.getByRole;
|
|
37
37
|
expect(getByText("Chip")).toBeTruthy();
|
|
38
|
-
_react2.fireEvent.click(getByRole("
|
|
38
|
+
_react2.fireEvent.click(getByRole("button"));
|
|
39
39
|
expect(onClick).toHaveBeenCalled();
|
|
40
40
|
});
|
|
41
41
|
});
|
package/chip/types.d.ts
CHANGED
|
@@ -7,31 +7,53 @@ type Margin = {
|
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
9
|
type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
|
-
type
|
|
10
|
+
type Icon = string | SVG;
|
|
11
|
+
type PrefixIconProps = {
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Element or path used as icon to be placed before the chip label.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
prefixIcon: Icon;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* This function will be called when the prefix is clicked.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
onClickPrefix: () => void;
|
|
19
20
|
/**
|
|
20
|
-
* Element or path used as icon to be placed
|
|
21
|
+
* Element or path used as icon to be placed after the chip label.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
suffixIcon?: Icon;
|
|
23
24
|
/**
|
|
24
25
|
* This function will be called when the suffix is clicked.
|
|
25
26
|
*/
|
|
26
|
-
onClickSuffix?:
|
|
27
|
+
onClickSuffix?: never;
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
+
* If true, the action icon will be disabled.
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
prefixIcon?: Icon;
|
|
34
|
+
onClickPrefix?: never;
|
|
35
|
+
suffixIcon?: never;
|
|
36
|
+
onClickSuffix?: never;
|
|
37
|
+
disabled?: never;
|
|
38
|
+
};
|
|
39
|
+
type SuffixIconProps = {
|
|
40
|
+
suffixIcon: Icon;
|
|
41
|
+
onClickSuffix: () => void;
|
|
42
|
+
prefixIcon?: Icon;
|
|
43
|
+
onClickPrefix?: never;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
} | {
|
|
46
|
+
suffixIcon?: Icon;
|
|
47
|
+
onClickSuffix?: never;
|
|
48
|
+
prefixIcon?: never;
|
|
49
|
+
onClickPrefix?: never;
|
|
50
|
+
disabled?: never;
|
|
51
|
+
};
|
|
52
|
+
type CommonProps = {
|
|
31
53
|
/**
|
|
32
|
-
*
|
|
54
|
+
* Text to be placed on the chip.
|
|
33
55
|
*/
|
|
34
|
-
|
|
56
|
+
label?: string;
|
|
35
57
|
/**
|
|
36
58
|
* Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
|
|
37
59
|
* You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
|
@@ -42,4 +64,5 @@ type Props = {
|
|
|
42
64
|
*/
|
|
43
65
|
tabIndex?: number;
|
|
44
66
|
};
|
|
67
|
+
type Props = (PrefixIconProps | SuffixIconProps) & CommonProps;
|
|
45
68
|
export default Props;
|
package/common/coreTokens.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Halstack Color Palette
|
|
3
|
+
* @link https://developer.dxc.com/halstack/next/principles/color/#color-tokens-core-color-tokens
|
|
4
|
+
*/
|
|
5
|
+
declare const CoreColorTokens: {
|
|
3
6
|
color_black: string;
|
|
4
7
|
color_white: string;
|
|
5
8
|
color_transparent: string;
|
|
@@ -83,6 +86,11 @@ declare const CORE_TOKENS: {
|
|
|
83
86
|
color_orange_700: string;
|
|
84
87
|
color_orange_800: string;
|
|
85
88
|
color_orange_900: string;
|
|
89
|
+
};
|
|
90
|
+
export declare const getCoreColorToken: (key: CoreColorTokens) => string;
|
|
91
|
+
export type CoreColorTokens = keyof typeof CoreColorTokens;
|
|
92
|
+
declare const CoreTokens: {
|
|
93
|
+
inherit: string;
|
|
86
94
|
type_sans: string;
|
|
87
95
|
type_scale_root: string;
|
|
88
96
|
type_scale_08: string;
|
|
@@ -116,6 +124,17 @@ declare const CORE_TOKENS: {
|
|
|
116
124
|
type_leading_normal: string;
|
|
117
125
|
type_leading_loose_01: string;
|
|
118
126
|
type_leading_loose_02: string;
|
|
127
|
+
border_width_0: string;
|
|
128
|
+
border_width_1: string;
|
|
129
|
+
border_width_2: string;
|
|
130
|
+
border_width_4: string;
|
|
131
|
+
border_radius_none: string;
|
|
132
|
+
border_radius_small: string;
|
|
133
|
+
border_radius_medium: string;
|
|
134
|
+
border_radius_large: string;
|
|
135
|
+
border_solid: string;
|
|
136
|
+
border_dashed: string;
|
|
137
|
+
border_none: string;
|
|
119
138
|
spacing_0: string;
|
|
120
139
|
spacing_2: string;
|
|
121
140
|
spacing_4: string;
|
|
@@ -131,16 +150,88 @@ declare const CORE_TOKENS: {
|
|
|
131
150
|
spacing_80: string;
|
|
132
151
|
spacing_96: string;
|
|
133
152
|
spacing_112: string;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
color_black: string;
|
|
154
|
+
color_white: string;
|
|
155
|
+
color_transparent: string;
|
|
156
|
+
color_grey_50: string;
|
|
157
|
+
color_grey_100: string;
|
|
158
|
+
color_grey_200: string;
|
|
159
|
+
color_grey_300: string;
|
|
160
|
+
color_grey_400: string;
|
|
161
|
+
color_grey_500: string;
|
|
162
|
+
color_grey_600: string;
|
|
163
|
+
color_grey_700: string;
|
|
164
|
+
color_grey_800: string;
|
|
165
|
+
color_grey_900: string;
|
|
166
|
+
color_grey_50_a: string;
|
|
167
|
+
color_grey_100_a: string;
|
|
168
|
+
color_grey_200_a: string;
|
|
169
|
+
color_grey_300_a: string;
|
|
170
|
+
color_grey_400_a: string;
|
|
171
|
+
color_grey_500_a: string;
|
|
172
|
+
color_grey_600_a: string;
|
|
173
|
+
color_grey_700_a: string;
|
|
174
|
+
color_grey_800_a: string;
|
|
175
|
+
color_grey_900_a: string;
|
|
176
|
+
color_purple_50: string;
|
|
177
|
+
color_purple_100: string;
|
|
178
|
+
color_purple_200: string;
|
|
179
|
+
color_purple_300: string;
|
|
180
|
+
color_purple_400: string;
|
|
181
|
+
color_purple_500: string;
|
|
182
|
+
color_purple_600: string;
|
|
183
|
+
color_purple_700: string;
|
|
184
|
+
color_purple_800: string;
|
|
185
|
+
color_purple_900: string;
|
|
186
|
+
color_blue_50: string;
|
|
187
|
+
color_blue_100: string;
|
|
188
|
+
color_blue_200: string;
|
|
189
|
+
color_blue_300: string;
|
|
190
|
+
color_blue_400: string;
|
|
191
|
+
color_blue_500: string;
|
|
192
|
+
color_blue_600: string;
|
|
193
|
+
color_blue_700: string;
|
|
194
|
+
color_blue_800: string;
|
|
195
|
+
color_blue_900: string;
|
|
196
|
+
color_red_50: string;
|
|
197
|
+
color_red_100: string;
|
|
198
|
+
color_red_200: string;
|
|
199
|
+
color_red_300: string;
|
|
200
|
+
color_red_400: string;
|
|
201
|
+
color_red_500: string;
|
|
202
|
+
color_red_600: string;
|
|
203
|
+
color_red_700: string;
|
|
204
|
+
color_red_800: string;
|
|
205
|
+
color_red_900: string;
|
|
206
|
+
color_green_50: string;
|
|
207
|
+
color_green_100: string;
|
|
208
|
+
color_green_200: string;
|
|
209
|
+
color_green_300: string;
|
|
210
|
+
color_green_400: string;
|
|
211
|
+
color_green_500: string;
|
|
212
|
+
color_green_600: string;
|
|
213
|
+
color_green_700: string;
|
|
214
|
+
color_green_800: string;
|
|
215
|
+
color_green_900: string;
|
|
216
|
+
color_yellow_50: string;
|
|
217
|
+
color_yellow_100: string;
|
|
218
|
+
color_yellow_200: string;
|
|
219
|
+
color_yellow_300: string;
|
|
220
|
+
color_yellow_400: string;
|
|
221
|
+
color_yellow_500: string;
|
|
222
|
+
color_yellow_600: string;
|
|
223
|
+
color_yellow_700: string;
|
|
224
|
+
color_yellow_800: string;
|
|
225
|
+
color_yellow_900: string;
|
|
226
|
+
color_orange_50: string;
|
|
227
|
+
color_orange_100: string;
|
|
228
|
+
color_orange_200: string;
|
|
229
|
+
color_orange_300: string;
|
|
230
|
+
color_orange_400: string;
|
|
231
|
+
color_orange_500: string;
|
|
232
|
+
color_orange_600: string;
|
|
233
|
+
color_orange_700: string;
|
|
234
|
+
color_orange_800: string;
|
|
235
|
+
color_orange_900: string;
|
|
145
236
|
};
|
|
146
|
-
export default
|
|
237
|
+
export default CoreTokens;
|