@dxc-technology/halstack-react 0.0.0-4e1277a → 0.0.0-4e3dbad
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 +42 -5
- package/HalstackContext.js +28 -18
- package/accordion/Accordion.accessibility.test.d.ts +1 -0
- package/accordion/Accordion.accessibility.test.js +71 -0
- package/accordion/Accordion.js +16 -30
- 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.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/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.js +4 -3
- package/action-icon/ActionIcon.stories.tsx +3 -3
- package/action-icon/ActionIcon.test.d.ts +1 -0
- package/action-icon/ActionIcon.test.js +1 -1
- package/action-icon/types.d.ts +1 -1
- package/alert/Alert.accessibility.test.d.ts +1 -0
- package/alert/Alert.accessibility.test.js +95 -0
- package/alert/Alert.js +21 -72
- 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.js +6 -4
- package/badge/Badge.stories.tsx +11 -11
- package/badge/Badge.test.d.ts +1 -0
- package/badge/Badge.test.js +2 -2
- package/badge/types.d.ts +1 -1
- 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 +118 -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 +33 -0
- 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 +119 -0
- package/bulleted-list/BulletedList.js +7 -4
- package/bulleted-list/BulletedList.stories.tsx +1 -1
- package/button/Button.accessibility.test.d.ts +1 -0
- package/button/Button.accessibility.test.js +127 -0
- package/button/Button.js +2 -2
- package/button/Button.stories.tsx +3 -4
- 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 +36 -0
- 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 +87 -0
- 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 +67 -0
- package/chip/Chip.js +11 -6
- package/chip/Chip.stories.tsx +6 -25
- package/chip/Chip.test.d.ts +1 -0
- package/chip/Chip.test.js +5 -5
- package/common/coreTokens.d.ts +0 -1
- package/common/coreTokens.js +3 -4
- package/common/variables.d.ts +48 -5
- package/common/variables.js +110 -73
- 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 +98 -0
- 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 +229 -0
- package/date-input/DateInput.js +28 -23
- 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 +13 -7
- package/date-input/YearPicker.js +10 -5
- package/dialog/Dialog.accessibility.test.d.ts +1 -0
- package/dialog/Dialog.accessibility.test.js +69 -0
- package/dialog/Dialog.js +9 -20
- package/dialog/Dialog.stories.tsx +8 -4
- package/dialog/Dialog.test.d.ts +1 -0
- package/dialog/Dialog.test.js +112 -49
- package/divider/Divider.accessibility.test.d.ts +1 -0
- package/divider/Divider.accessibility.test.js +33 -0
- 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 +183 -0
- package/dropdown/Dropdown.js +31 -66
- package/dropdown/Dropdown.stories.tsx +16 -27
- 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 +8 -4
- package/dropdown/types.d.ts +2 -4
- package/file-input/FileInput.accessibility.test.d.ts +1 -0
- package/file-input/FileInput.accessibility.test.js +167 -0
- package/file-input/FileInput.js +6 -47
- package/file-input/FileInput.test.d.ts +1 -0
- package/file-input/FileInput.test.js +51 -106
- package/file-input/FileItem.js +18 -28
- package/file-input/types.d.ts +0 -4
- package/footer/Footer.accessibility.test.d.ts +1 -0
- package/footer/Footer.accessibility.test.js +125 -0
- package/footer/Footer.js +8 -6
- package/footer/Footer.stories.tsx +40 -3
- package/footer/Footer.test.d.ts +1 -0
- package/footer/Footer.test.js +1 -1
- package/footer/Icons.js +2 -30
- package/footer/types.d.ts +1 -1
- package/grid/Grid.stories.tsx +3 -1
- package/header/Header.accessibility.test.d.ts +1 -0
- package/header/Header.accessibility.test.js +94 -0
- package/header/Header.js +12 -22
- 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 +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.js +1 -1
- package/icon/Icon.stories.tsx +6 -4
- package/image/Image.accessibility.test.d.ts +1 -0
- package/image/Image.accessibility.test.js +56 -0
- package/image/Image.js +1 -1
- package/layout/ApplicationLayout.js +9 -6
- 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 +3 -1
- package/main.js +15 -1
- package/nav-tabs/NavTabs.accessibility.test.d.ts +1 -0
- package/nav-tabs/NavTabs.accessibility.test.js +44 -0
- package/nav-tabs/NavTabs.js +19 -4
- package/nav-tabs/NavTabs.stories.tsx +41 -23
- package/nav-tabs/NavTabs.test.d.ts +1 -0
- package/nav-tabs/NavTabs.test.js +10 -9
- package/nav-tabs/Tab.js +17 -18
- 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 +227 -0
- 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 +34 -28
- package/paginator/Paginator.accessibility.test.d.ts +1 -0
- package/paginator/Paginator.accessibility.test.js +78 -0
- package/paginator/Paginator.js +13 -10
- 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 +28 -0
- package/password-input/PasswordInput.accessibility.test.d.ts +1 -0
- package/password-input/PasswordInput.accessibility.test.js +152 -0
- package/password-input/PasswordInput.js +11 -8
- 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 +35 -0
- 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 +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 +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 +284 -0
- package/resultset-table/ResultsetTable.d.ts +1 -1
- package/resultset-table/ResultsetTable.js +47 -15
- package/resultset-table/ResultsetTable.stories.tsx +19 -3
- package/resultset-table/ResultsetTable.test.d.ts +1 -0
- package/resultset-table/ResultsetTable.test.js +111 -32
- package/resultset-table/types.d.ts +41 -13
- package/select/Listbox.d.ts +3 -3
- package/select/Listbox.js +33 -29
- package/select/Option.d.ts +3 -3
- package/select/Option.js +21 -15
- package/select/Select.accessibility.test.d.ts +1 -0
- package/select/Select.accessibility.test.js +227 -0
- package/select/Select.js +85 -192
- package/select/Select.stories.tsx +74 -117
- package/select/Select.test.d.ts +1 -0
- package/select/Select.test.js +348 -550
- package/select/selectUtils.d.ts +41 -0
- package/select/selectUtils.js +129 -0
- package/select/types.d.ts +1 -1
- package/sidenav/Sidenav.accessibility.test.d.ts +1 -0
- package/sidenav/Sidenav.accessibility.test.js +59 -0
- package/sidenav/Sidenav.js +16 -12
- package/sidenav/Sidenav.stories.tsx +5 -10
- 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 +103 -0
- 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 +96 -0
- 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 +157 -0
- 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 +98 -0
- 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 +92 -0
- package/table/Table.js +2 -11
- package/table/Table.stories.tsx +15 -10
- package/table/Table.test.d.ts +1 -0
- package/table/Table.test.js +2 -4
- package/table/types.d.ts +1 -15
- package/tabs/Tab.js +6 -5
- package/tabs/Tabs.accessibility.test.d.ts +1 -0
- package/tabs/Tabs.accessibility.test.js +56 -0
- package/tabs/Tabs.js +9 -20
- package/tabs/Tabs.stories.tsx +7 -3
- 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 +5 -8
- 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 +17 -7
- package/text-input/TextInput.accessibility.test.d.ts +1 -0
- package/text-input/TextInput.accessibility.test.js +320 -0
- package/text-input/TextInput.js +56 -73
- package/text-input/TextInput.stories.tsx +20 -8
- 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 +155 -0
- 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 +107 -0
- package/toggle-group/ToggleGroup.js +10 -12
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- 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/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 +339 -0
- package/typography/Typography.stories.tsx +1 -3
- package/typography/Typography.test.js +23 -0
- package/useTheme.d.ts +31 -5
- 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 +55 -0
- package/wizard/Wizard.js +14 -25
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/Wizard.test.d.ts +1 -0
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +1 -1
- package/contextual-menu/MenuItemAction.d.ts +0 -4
- package/contextual-menu/MenuItemAction.js +0 -46
- 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
|
@@ -11,13 +11,12 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
14
|
-
var _uuid = require("uuid");
|
|
15
14
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
16
15
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
17
16
|
var _Radio = _interopRequireDefault(require("./Radio"));
|
|
18
17
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
19
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); }
|
|
20
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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" != _typeof(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; }
|
|
21
20
|
var getInitialFocusIndex = function getInitialFocusIndex(innerOptions, value) {
|
|
22
21
|
var initialSelectedOptionIndex = innerOptions.findIndex(function (option) {
|
|
23
22
|
return option.value === value;
|
|
@@ -46,19 +45,17 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
46
45
|
error = _ref.error,
|
|
47
46
|
_ref$tabIndex = _ref.tabIndex,
|
|
48
47
|
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
49
|
-
var
|
|
50
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
51
|
-
radioGroupId = _useState2[0];
|
|
48
|
+
var radioGroupId = "radio-group-".concat((0, _react.useId)());
|
|
52
49
|
var radioGroupLabelId = "label-".concat(radioGroupId);
|
|
53
50
|
var errorId = "error-".concat(radioGroupId);
|
|
54
|
-
var
|
|
51
|
+
var _useState = (0, _react.useState)(defaultValue),
|
|
52
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
53
|
+
innerValue = _useState2[0],
|
|
54
|
+
setInnerValue = _useState2[1];
|
|
55
|
+
var _useState3 = (0, _react.useState)(true),
|
|
55
56
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var _useState5 = (0, _react.useState)(true),
|
|
59
|
-
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
60
|
-
firstTimeFocus = _useState6[0],
|
|
61
|
-
setFirstTimeFocus = _useState6[1];
|
|
57
|
+
firstTimeFocus = _useState4[0],
|
|
58
|
+
setFirstTimeFocus = _useState4[1];
|
|
62
59
|
var colorsTheme = (0, _useTheme["default"])();
|
|
63
60
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
64
61
|
var innerOptions = (0, _react.useMemo)(function () {
|
|
@@ -68,10 +65,10 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
68
65
|
disabled: disabled
|
|
69
66
|
}]) : options;
|
|
70
67
|
}, [optional, options, optionalItemLabel, translatedLabels]);
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
currentFocusIndex =
|
|
74
|
-
setCurrentFocusIndex =
|
|
68
|
+
var _useState5 = (0, _react.useState)(getInitialFocusIndex(innerOptions, value !== null && value !== void 0 ? value : innerValue)),
|
|
69
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
70
|
+
currentFocusIndex = _useState6[0],
|
|
71
|
+
setCurrentFocusIndex = _useState6[1];
|
|
75
72
|
var handleOnChange = (0, _react.useCallback)(function (newValue) {
|
|
76
73
|
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
77
74
|
if (newValue !== currentValue && !readOnly) {
|
|
@@ -182,6 +179,7 @@ var DxcRadioGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref, re
|
|
|
182
179
|
});
|
|
183
180
|
})), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
184
181
|
id: errorId,
|
|
182
|
+
role: "alert",
|
|
185
183
|
"aria-live": error ? "assertive" : "off"
|
|
186
184
|
}, error)));
|
|
187
185
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,7 +6,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
6
6
|
var _react = _interopRequireDefault(require("react"));
|
|
7
7
|
var _react2 = require("@testing-library/react");
|
|
8
8
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
9
|
-
var _RadioGroup = _interopRequireDefault(require("./RadioGroup
|
|
9
|
+
var _RadioGroup = _interopRequireDefault(require("./RadioGroup"));
|
|
10
10
|
var options = [{
|
|
11
11
|
label: "Option 01",
|
|
12
12
|
value: "1"
|
|
@@ -55,12 +55,10 @@ describe("Radio Group component tests", function () {
|
|
|
55
55
|
})),
|
|
56
56
|
getByRole = _render.getByRole,
|
|
57
57
|
getAllByRole = _render.getAllByRole,
|
|
58
|
-
getByText = _render.getByText
|
|
59
|
-
container = _render.container;
|
|
58
|
+
getByText = _render.getByText;
|
|
60
59
|
var radioGroup = getByRole("radiogroup");
|
|
61
60
|
var radios = getAllByRole("radio");
|
|
62
|
-
var
|
|
63
|
-
var error = container.querySelector("#".concat(errorId));
|
|
61
|
+
var error = getByRole("alert");
|
|
64
62
|
expect(radioGroup.getAttribute("aria-disabled")).toBe("false");
|
|
65
63
|
expect(radioGroup.getAttribute("aria-labelledby")).toBe(getByText("test-radioGroup-label").id);
|
|
66
64
|
expect(radioGroup.getAttribute("aria-invalid")).toBe("false");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,284 @@
|
|
|
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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _react2 = require("@testing-library/react");
|
|
10
|
+
var _axeHelper = require("../../test/accessibility/axe-helper.js");
|
|
11
|
+
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable"));
|
|
12
|
+
var _disabledRules = require("../../test/accessibility/rules/specific/resultset-table/disabledRules.js");
|
|
13
|
+
// TODO: REMOVE
|
|
14
|
+
|
|
15
|
+
var disabledRules = {
|
|
16
|
+
rules: _disabledRules.disabledRules.reduce(function (rulesObj, rule) {
|
|
17
|
+
rulesObj[rule] = {
|
|
18
|
+
enabled: false
|
|
19
|
+
};
|
|
20
|
+
return rulesObj;
|
|
21
|
+
}, {})
|
|
22
|
+
};
|
|
23
|
+
var deleteIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
+
height: "24",
|
|
26
|
+
viewBox: "0 0 24 24",
|
|
27
|
+
width: "24"
|
|
28
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
29
|
+
fill: "currentColor",
|
|
30
|
+
d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
|
|
31
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
32
|
+
d: "M0 0h24v24H0z",
|
|
33
|
+
fill: "none"
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
37
|
+
global.globalThis = global;
|
|
38
|
+
global.DOMRect = {
|
|
39
|
+
fromRect: function fromRect() {
|
|
40
|
+
return {
|
|
41
|
+
top: 0,
|
|
42
|
+
left: 0,
|
|
43
|
+
bottom: 0,
|
|
44
|
+
right: 0,
|
|
45
|
+
width: 0,
|
|
46
|
+
height: 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
51
|
+
function ResizeObserver() {
|
|
52
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
53
|
+
}
|
|
54
|
+
return (0, _createClass2["default"])(ResizeObserver, [{
|
|
55
|
+
key: "observe",
|
|
56
|
+
value: function observe() {}
|
|
57
|
+
}, {
|
|
58
|
+
key: "unobserve",
|
|
59
|
+
value: function unobserve() {}
|
|
60
|
+
}, {
|
|
61
|
+
key: "disconnect",
|
|
62
|
+
value: function disconnect() {}
|
|
63
|
+
}]);
|
|
64
|
+
}();
|
|
65
|
+
var actions = [{
|
|
66
|
+
title: "icon",
|
|
67
|
+
onClick: function onClick() {},
|
|
68
|
+
options: [{
|
|
69
|
+
value: "1",
|
|
70
|
+
label: "Amazon with a very long text"
|
|
71
|
+
}, {
|
|
72
|
+
value: "2",
|
|
73
|
+
label: "Ebay"
|
|
74
|
+
}, {
|
|
75
|
+
value: "3",
|
|
76
|
+
label: "Apple"
|
|
77
|
+
}]
|
|
78
|
+
}, {
|
|
79
|
+
icon: "https://www.freepnglogos.com/uploads/facebook-logo-design-1.png",
|
|
80
|
+
title: "icon",
|
|
81
|
+
onClick: function onClick() {}
|
|
82
|
+
}, {
|
|
83
|
+
icon: deleteIcon,
|
|
84
|
+
title: "icon",
|
|
85
|
+
onClick: function onClick() {},
|
|
86
|
+
disabled: true
|
|
87
|
+
}, {
|
|
88
|
+
icon: deleteIcon,
|
|
89
|
+
title: "icon",
|
|
90
|
+
onClick: function onClick() {}
|
|
91
|
+
}];
|
|
92
|
+
var columns = [{
|
|
93
|
+
displayValue: "Id",
|
|
94
|
+
isSortable: false
|
|
95
|
+
}, {
|
|
96
|
+
displayValue: "Name",
|
|
97
|
+
isSortable: true
|
|
98
|
+
}, {
|
|
99
|
+
displayValue: "City",
|
|
100
|
+
isSortable: false
|
|
101
|
+
}];
|
|
102
|
+
var rows = [[{
|
|
103
|
+
displayValue: "001",
|
|
104
|
+
sortValue: "001"
|
|
105
|
+
}, {
|
|
106
|
+
displayValue: "Peter",
|
|
107
|
+
sortValue: "Peter"
|
|
108
|
+
}, {
|
|
109
|
+
displayValue: "Oviedo",
|
|
110
|
+
sortValue: "Oviedo"
|
|
111
|
+
}, {
|
|
112
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
113
|
+
actions: actions
|
|
114
|
+
})
|
|
115
|
+
}], [{
|
|
116
|
+
displayValue: "002",
|
|
117
|
+
sortValue: "002"
|
|
118
|
+
}, {
|
|
119
|
+
displayValue: "Louis",
|
|
120
|
+
sortValue: "Louis"
|
|
121
|
+
}, {
|
|
122
|
+
displayValue: "Oviedo",
|
|
123
|
+
sortValue: "Oviedo"
|
|
124
|
+
}, {
|
|
125
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
126
|
+
actions: actions
|
|
127
|
+
})
|
|
128
|
+
}], [{
|
|
129
|
+
displayValue: "003",
|
|
130
|
+
sortValue: "003"
|
|
131
|
+
}, {
|
|
132
|
+
displayValue: "Lana",
|
|
133
|
+
sortValue: "Lana"
|
|
134
|
+
}, {
|
|
135
|
+
displayValue: "Albacete",
|
|
136
|
+
sortValue: "Albacete"
|
|
137
|
+
}, {
|
|
138
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
139
|
+
actions: actions
|
|
140
|
+
})
|
|
141
|
+
}], [{
|
|
142
|
+
displayValue: "004",
|
|
143
|
+
sortValue: "004"
|
|
144
|
+
}, {
|
|
145
|
+
displayValue: "Rick",
|
|
146
|
+
sortValue: "Rick"
|
|
147
|
+
}, {
|
|
148
|
+
displayValue: "Albacete",
|
|
149
|
+
sortValue: "Albacete"
|
|
150
|
+
}, {
|
|
151
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
152
|
+
actions: actions
|
|
153
|
+
})
|
|
154
|
+
}], [{
|
|
155
|
+
displayValue: "005",
|
|
156
|
+
sortValue: "005"
|
|
157
|
+
}, {
|
|
158
|
+
displayValue: "Mark",
|
|
159
|
+
sortValue: "Mark"
|
|
160
|
+
}, {
|
|
161
|
+
displayValue: "Madrid",
|
|
162
|
+
sortValue: "Madrid"
|
|
163
|
+
}, {
|
|
164
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
165
|
+
actions: actions
|
|
166
|
+
})
|
|
167
|
+
}], [{
|
|
168
|
+
displayValue: "006",
|
|
169
|
+
sortValue: "006"
|
|
170
|
+
}, {
|
|
171
|
+
displayValue: "Cris",
|
|
172
|
+
sortValue: "Cris"
|
|
173
|
+
}, {
|
|
174
|
+
displayValue: "Barcelona",
|
|
175
|
+
sortValue: "Barcelona"
|
|
176
|
+
}, {
|
|
177
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
178
|
+
actions: actions
|
|
179
|
+
})
|
|
180
|
+
}], [{
|
|
181
|
+
displayValue: "007",
|
|
182
|
+
sortValue: "007"
|
|
183
|
+
}, {
|
|
184
|
+
displayValue: "Susan",
|
|
185
|
+
sortValue: "Susan"
|
|
186
|
+
}, {
|
|
187
|
+
displayValue: "Madrid",
|
|
188
|
+
sortValue: "Madrid"
|
|
189
|
+
}, {
|
|
190
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
191
|
+
actions: actions
|
|
192
|
+
})
|
|
193
|
+
}], [{
|
|
194
|
+
displayValue: "008",
|
|
195
|
+
sortValue: "008"
|
|
196
|
+
}, {
|
|
197
|
+
displayValue: "Tina",
|
|
198
|
+
sortValue: "Tina"
|
|
199
|
+
}, {
|
|
200
|
+
displayValue: "Barcelona",
|
|
201
|
+
sortValue: "Barcelona"
|
|
202
|
+
}, {
|
|
203
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
204
|
+
actions: actions
|
|
205
|
+
})
|
|
206
|
+
}], [{
|
|
207
|
+
displayValue: "009",
|
|
208
|
+
sortValue: "009"
|
|
209
|
+
}, {
|
|
210
|
+
displayValue: "Kevin",
|
|
211
|
+
sortValue: "Kevin"
|
|
212
|
+
}, {
|
|
213
|
+
displayValue: "Oviedo",
|
|
214
|
+
sortValue: "Oviedo"
|
|
215
|
+
}, {
|
|
216
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
217
|
+
actions: actions
|
|
218
|
+
})
|
|
219
|
+
}], [{
|
|
220
|
+
displayValue: "010",
|
|
221
|
+
sortValue: "010"
|
|
222
|
+
}, {
|
|
223
|
+
displayValue: "Cosmin",
|
|
224
|
+
sortValue: "Cosmin"
|
|
225
|
+
}, {
|
|
226
|
+
displayValue: "Barcelona",
|
|
227
|
+
sortValue: "Barcelona"
|
|
228
|
+
}, {
|
|
229
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
|
|
230
|
+
actions: actions
|
|
231
|
+
})
|
|
232
|
+
}]];
|
|
233
|
+
describe("Resultset Table input component accessibility tests", function () {
|
|
234
|
+
it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
235
|
+
var _render, container, results;
|
|
236
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
237
|
+
while (1) switch (_context.prev = _context.next) {
|
|
238
|
+
case 0:
|
|
239
|
+
_render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
240
|
+
columns: columns,
|
|
241
|
+
rows: rows,
|
|
242
|
+
itemsPerPage: 2,
|
|
243
|
+
margin: "medium",
|
|
244
|
+
mode: "default",
|
|
245
|
+
itemsPerPageOptions: [2, 3],
|
|
246
|
+
showGoToPage: true
|
|
247
|
+
})), container = _render.container;
|
|
248
|
+
_context.next = 3;
|
|
249
|
+
return (0, _axeHelper.axe)(container, disabledRules);
|
|
250
|
+
case 3:
|
|
251
|
+
results = _context.sent;
|
|
252
|
+
expect(results).toHaveNoViolations();
|
|
253
|
+
case 5:
|
|
254
|
+
case "end":
|
|
255
|
+
return _context.stop();
|
|
256
|
+
}
|
|
257
|
+
}, _callee);
|
|
258
|
+
})));
|
|
259
|
+
it("Should not have basic accessibility issues for reduced mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
260
|
+
var _render2, container, results;
|
|
261
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
262
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
263
|
+
case 0:
|
|
264
|
+
_render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
265
|
+
columns: columns,
|
|
266
|
+
rows: rows,
|
|
267
|
+
itemsPerPage: 2,
|
|
268
|
+
margin: "medium",
|
|
269
|
+
mode: "reduced",
|
|
270
|
+
itemsPerPageOptions: [2, 3],
|
|
271
|
+
showGoToPage: true
|
|
272
|
+
})), container = _render2.container;
|
|
273
|
+
_context2.next = 3;
|
|
274
|
+
return (0, _axeHelper.axe)(container, disabledRules);
|
|
275
|
+
case 3:
|
|
276
|
+
results = _context2.sent;
|
|
277
|
+
expect(results).toHaveNoViolations();
|
|
278
|
+
case 5:
|
|
279
|
+
case "end":
|
|
280
|
+
return _context2.stop();
|
|
281
|
+
}
|
|
282
|
+
}, _callee2);
|
|
283
|
+
})));
|
|
284
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import ResultsetTablePropsType from "./types";
|
|
3
3
|
declare const DxcResultsetTable: {
|
|
4
|
-
({ columns, rows, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, margin, tabIndex, mode, }: ResultsetTablePropsType): JSX.Element;
|
|
4
|
+
({ columns, rows, hidePaginator, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, margin, tabIndex, mode, }: ResultsetTablePropsType): JSX.Element;
|
|
5
5
|
ActionsCell: ({ actions }: import("../table/types").ActionCellsPropsType) => JSX.Element;
|
|
6
6
|
};
|
|
7
7
|
export default DxcResultsetTable;
|
|
@@ -20,18 +20,21 @@ var _utils = require("../common/utils");
|
|
|
20
20
|
var _coreTokens = _interopRequireDefault(require("../common/coreTokens"));
|
|
21
21
|
var _templateObject, _templateObject2, _templateObject3;
|
|
22
22
|
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); }
|
|
23
|
-
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 &&
|
|
23
|
+
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; }
|
|
24
24
|
var normalizeSortValue = function normalizeSortValue(sortValue) {
|
|
25
25
|
return typeof sortValue === "string" ? sortValue.toUpperCase() : sortValue;
|
|
26
26
|
};
|
|
27
|
+
var isDateType = function isDateType(value) {
|
|
28
|
+
return value instanceof Date;
|
|
29
|
+
};
|
|
27
30
|
var sortArray = function sortArray(index, order, resultset) {
|
|
28
31
|
return resultset.slice().sort(function (element1, element2) {
|
|
29
|
-
var sortValueA = normalizeSortValue(element1[index].sortValue || element1[index].displayValue);
|
|
30
|
-
var sortValueB = normalizeSortValue(element2[index].sortValue || element2[index].displayValue);
|
|
32
|
+
var sortValueA = normalizeSortValue(element1.cells[index].sortValue || element1[index].displayValue);
|
|
33
|
+
var sortValueB = normalizeSortValue(element2.cells[index].sortValue || element2[index].displayValue);
|
|
31
34
|
var comparison = 0;
|
|
32
|
-
if ((0, _typeof2["default"])(sortValueA) === "object") {
|
|
35
|
+
if ((0, _typeof2["default"])(sortValueA) === "object" && !isDateType(sortValueA)) {
|
|
33
36
|
comparison = -1;
|
|
34
|
-
} else if ((0, _typeof2["default"])(sortValueB) === "object") {
|
|
37
|
+
} else if ((0, _typeof2["default"])(sortValueB) === "object" && !isDateType(sortValueB)) {
|
|
35
38
|
comparison = 1;
|
|
36
39
|
} else if (sortValueA > sortValueB) {
|
|
37
40
|
comparison = 1;
|
|
@@ -47,9 +50,22 @@ var getMinItemsPerPageIndex = function getMinItemsPerPageIndex(currentPageIntern
|
|
|
47
50
|
var getMaxItemsPerPageIndex = function getMaxItemsPerPageIndex(minItemsPerPageIndex, itemsPerPage, resultset, page) {
|
|
48
51
|
return minItemsPerPageIndex + itemsPerPage > resultset.length ? resultset.length : itemsPerPage * page - 1;
|
|
49
52
|
};
|
|
53
|
+
var assignIdsToRows = function assignIdsToRows(resultset) {
|
|
54
|
+
if (resultset.length > 0) {
|
|
55
|
+
return resultset.map(function (row, index) {
|
|
56
|
+
return {
|
|
57
|
+
cells: row,
|
|
58
|
+
id: "row_".concat(index)
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return [];
|
|
63
|
+
};
|
|
50
64
|
var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
51
65
|
var columns = _ref.columns,
|
|
52
66
|
rows = _ref.rows,
|
|
67
|
+
_ref$hidePaginator = _ref.hidePaginator,
|
|
68
|
+
hidePaginator = _ref$hidePaginator === void 0 ? false : _ref$hidePaginator,
|
|
53
69
|
_ref$showGoToPage = _ref.showGoToPage,
|
|
54
70
|
showGoToPage = _ref$showGoToPage === void 0 ? true : _ref$showGoToPage,
|
|
55
71
|
_ref$itemsPerPage = _ref.itemsPerPage,
|
|
@@ -74,6 +90,10 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
74
90
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
75
91
|
sortOrder = _useState6[0],
|
|
76
92
|
changeSortOrder = _useState6[1];
|
|
93
|
+
var prevRowCountRef = (0, _react.useRef)(rows.length);
|
|
94
|
+
var rowsWithIds = (0, _react.useMemo)(function () {
|
|
95
|
+
return assignIdsToRows(rows);
|
|
96
|
+
}, [rows]);
|
|
77
97
|
var minItemsPerPageIndex = (0, _react.useMemo)(function () {
|
|
78
98
|
return getMinItemsPerPageIndex(page, itemsPerPage, page);
|
|
79
99
|
}, [itemsPerPage, page]);
|
|
@@ -81,8 +101,8 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
81
101
|
return getMaxItemsPerPageIndex(minItemsPerPageIndex, itemsPerPage, rows, page);
|
|
82
102
|
}, [itemsPerPage, minItemsPerPageIndex, page, rows]);
|
|
83
103
|
var sortedResultset = (0, _react.useMemo)(function () {
|
|
84
|
-
return sortColumnIndex !== -1 ? sortArray(sortColumnIndex, sortOrder,
|
|
85
|
-
}, [sortColumnIndex, sortOrder,
|
|
104
|
+
return sortColumnIndex !== -1 ? sortArray(sortColumnIndex, sortOrder, rowsWithIds) : rowsWithIds;
|
|
105
|
+
}, [sortColumnIndex, sortOrder, rowsWithIds]);
|
|
86
106
|
var filteredResultset = (0, _react.useMemo)(function () {
|
|
87
107
|
return sortedResultset && sortedResultset.slice(minItemsPerPageIndex, maxItemsPerPageIndex + 1);
|
|
88
108
|
}, [sortedResultset, minItemsPerPageIndex, maxItemsPerPageIndex]);
|
|
@@ -95,8 +115,19 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
95
115
|
changeSortOrder(sortColumnIndex === -1 || sortColumnIndex !== columnIndex ? "ascending" : sortOrder === "ascending" ? "descending" : "ascending");
|
|
96
116
|
};
|
|
97
117
|
(0, _react.useEffect)(function () {
|
|
98
|
-
|
|
99
|
-
|
|
118
|
+
if (!hidePaginator) {
|
|
119
|
+
if (rows.length === 0) {
|
|
120
|
+
changePage(0);
|
|
121
|
+
} else if (rows.length < prevRowCountRef.current) {
|
|
122
|
+
var lastPage = Math.ceil(rows.length / itemsPerPage);
|
|
123
|
+
var prevLastPage = Math.ceil(prevRowCountRef.current / itemsPerPage);
|
|
124
|
+
if (lastPage < prevLastPage) {
|
|
125
|
+
changePage(Math.min(lastPage, page));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
prevRowCountRef.current = rows.length;
|
|
129
|
+
}
|
|
130
|
+
}, [rows.length]);
|
|
100
131
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
101
132
|
theme: colorsTheme.table
|
|
102
133
|
}, /*#__PURE__*/_react["default"].createElement(DxcResultsetTableContainer, {
|
|
@@ -115,17 +146,18 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
115
146
|
},
|
|
116
147
|
tabIndex: column.isSortable ? tabIndex : -1,
|
|
117
148
|
isSortable: column.isSortable,
|
|
118
|
-
mode: mode
|
|
149
|
+
mode: mode,
|
|
150
|
+
"aria-label": column.isSortable ? "Sort column" : undefined
|
|
119
151
|
}, /*#__PURE__*/_react["default"].createElement("span", null, column.displayValue), column.isSortable && /*#__PURE__*/_react["default"].createElement(SortIcon, null, sortColumnIndex === index ? sortOrder === "ascending" ? _Icons["default"].arrowUp : _Icons["default"].arrowDown : _Icons["default"].bothArrows)));
|
|
120
|
-
}))), /*#__PURE__*/_react["default"].createElement("tbody", null, filteredResultset.map(function (
|
|
152
|
+
}))), /*#__PURE__*/_react["default"].createElement("tbody", null, filteredResultset.map(function (row) {
|
|
121
153
|
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
122
|
-
key: "resultSetTableCell_".concat(
|
|
123
|
-
}, cells.map(function (cellContent,
|
|
154
|
+
key: "resultSetTableCell_".concat(row.id)
|
|
155
|
+
}, row.cells.map(function (cellContent, cellIndex) {
|
|
124
156
|
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
125
|
-
key: "resultSetTableCellContent_".concat(
|
|
157
|
+
key: "resultSetTableCellContent_".concat(cellIndex)
|
|
126
158
|
}, cellContent.displayValue);
|
|
127
159
|
}));
|
|
128
|
-
}))), /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
160
|
+
}))), !hidePaginator && /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
129
161
|
totalItems: rows.length,
|
|
130
162
|
itemsPerPage: itemsPerPage,
|
|
131
163
|
itemsPerPageOptions: itemsPerPageOptions,
|
|
@@ -2,13 +2,25 @@ import React from "react";
|
|
|
2
2
|
import DxcResultsetTable from "./ResultsetTable";
|
|
3
3
|
import Title from "../../.storybook/components/Title";
|
|
4
4
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
5
|
-
import { userEvent, within } from "@storybook/
|
|
5
|
+
import { userEvent, within } from "@storybook/test";
|
|
6
6
|
import styled from "styled-components";
|
|
7
7
|
import { HalstackProvider } from "../HalstackContext";
|
|
8
|
+
import { disabledRules } from "../../test/accessibility/rules/specific/resultset-table/disabledRules";
|
|
9
|
+
import preview from "../../.storybook/preview";
|
|
8
10
|
|
|
9
11
|
export default {
|
|
10
12
|
title: "Resultset Table",
|
|
11
13
|
component: DxcResultsetTable,
|
|
14
|
+
parameters: {
|
|
15
|
+
a11y: {
|
|
16
|
+
config: {
|
|
17
|
+
rules: [
|
|
18
|
+
...disabledRules.map((ruleId) => ({ id: ruleId, reviewOnFail: true })),
|
|
19
|
+
...preview?.parameters?.a11y?.config?.rules,
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
12
24
|
};
|
|
13
25
|
|
|
14
26
|
const deleteIcon = (
|
|
@@ -62,7 +74,7 @@ const actions = [
|
|
|
62
74
|
],
|
|
63
75
|
},
|
|
64
76
|
{
|
|
65
|
-
icon: "
|
|
77
|
+
icon: "filled_edit",
|
|
66
78
|
title: "icon",
|
|
67
79
|
onClick: () => {},
|
|
68
80
|
},
|
|
@@ -260,6 +272,10 @@ export const Chromatic = () => (
|
|
|
260
272
|
<Title title="Scroll resultset table" theme="light" level={4} />
|
|
261
273
|
<DxcResultsetTable columns={longColumns} rows={longRows} />
|
|
262
274
|
</ExampleContainer>
|
|
275
|
+
<ExampleContainer>
|
|
276
|
+
<Title title="Without paginator" theme="light" level={4} />
|
|
277
|
+
<DxcResultsetTable columns={columns} rows={rows} hidePaginator />
|
|
278
|
+
</ExampleContainer>
|
|
263
279
|
<ExampleContainer>
|
|
264
280
|
<SmallContainer>
|
|
265
281
|
<Title title="Small container and text overflow" theme="light" level={4} />
|
|
@@ -393,5 +409,5 @@ export const DropdownAction = ResultsetActionsCellDropdown.bind({});
|
|
|
393
409
|
DropdownAction.play = async ({ canvasElement }) => {
|
|
394
410
|
const canvas = within(canvasElement);
|
|
395
411
|
const dropdown = canvas.getAllByRole("button")[5];
|
|
396
|
-
|
|
412
|
+
userEvent.click(dropdown);
|
|
397
413
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|