@dxc-technology/halstack-react 0.0.0-59b9187 → 0.0.0-5a4d834
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BackgroundColorContext.js +1 -1
- package/HalstackContext.d.ts +41 -3
- package/HalstackContext.js +28 -18
- package/accordion/Accordion.accessibility.test.d.ts +1 -0
- package/accordion/Accordion.accessibility.test.js +4 -4
- package/accordion/Accordion.js +6 -9
- package/accordion/Accordion.stories.tsx +4 -14
- package/accordion/Accordion.test.d.ts +1 -0
- package/accordion/Accordion.test.js +3 -3
- package/accordion-group/AccordionGroup.accessibility.test.d.ts +1 -0
- package/accordion-group/AccordionGroup.accessibility.test.js +11 -17
- package/accordion-group/AccordionGroup.js +1 -1
- package/accordion-group/AccordionGroup.stories.tsx +23 -23
- package/accordion-group/AccordionGroup.test.d.ts +1 -0
- package/accordion-group/AccordionGroup.test.js +5 -9
- package/accordion-group/AccordionGroupAccordion.js +1 -1
- package/action-icon/ActionIcon.accessibility.test.d.ts +1 -0
- package/action-icon/ActionIcon.accessibility.test.js +4 -4
- package/action-icon/ActionIcon.test.d.ts +1 -0
- package/action-icon/ActionIcon.test.js +1 -1
- package/alert/Alert.accessibility.test.d.ts +1 -0
- package/alert/Alert.accessibility.test.js +6 -6
- package/alert/Alert.js +7 -4
- package/alert/Alert.test.d.ts +1 -0
- package/alert/Alert.test.js +1 -1
- package/badge/Badge.accessibility.test.d.ts +1 -0
- package/badge/Badge.accessibility.test.js +5 -5
- package/badge/Badge.test.d.ts +1 -0
- package/badge/Badge.test.js +2 -2
- package/bar-chart/BarChart.d.ts +4 -0
- package/bar-chart/BarChart.js +152 -0
- package/bar-chart/BarChart.stories.tsx +281 -0
- package/bar-chart/BarChart.test.d.ts +1 -0
- package/bar-chart/BarChart.test.js +194 -0
- package/bar-chart/theme.d.ts +3 -0
- package/bar-chart/theme.js +31 -0
- package/bar-chart/types.d.ts +137 -0
- package/bar-chart/types.js +5 -0
- package/bleed/Bleed.stories.tsx +0 -1
- package/box/Box.accessibility.test.d.ts +1 -0
- package/box/Box.accessibility.test.js +3 -3
- package/box/Box.js +1 -1
- package/box/Box.test.d.ts +1 -0
- package/box/Box.test.js +1 -1
- package/breadcrumbs/Breadcrumbs.accessibility.test.d.ts +1 -0
- package/breadcrumbs/Breadcrumbs.accessibility.test.js +96 -0
- package/breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/breadcrumbs/Breadcrumbs.js +79 -0
- package/breadcrumbs/Breadcrumbs.stories.tsx +194 -0
- package/breadcrumbs/Breadcrumbs.test.d.ts +1 -0
- package/breadcrumbs/Breadcrumbs.test.js +168 -0
- package/breadcrumbs/Item.d.ts +4 -0
- package/breadcrumbs/Item.js +52 -0
- package/breadcrumbs/dropdownTheme.d.ts +53 -0
- package/breadcrumbs/dropdownTheme.js +62 -0
- package/breadcrumbs/types.d.ts +40 -0
- package/breadcrumbs/types.js +5 -0
- package/bulleted-list/BulletedList.accessibility.test.d.ts +1 -0
- package/bulleted-list/BulletedList.accessibility.test.js +18 -6
- package/bulleted-list/BulletedList.js +1 -1
- package/button/Button.accessibility.test.d.ts +1 -0
- package/button/Button.accessibility.test.js +6 -6
- package/button/Button.js +1 -1
- package/button/Button.stories.tsx +3 -3
- package/button/Button.test.d.ts +1 -0
- package/button/Button.test.js +1 -1
- package/card/Card.accessibility.test.d.ts +1 -0
- package/card/Card.accessibility.test.js +3 -3
- package/card/Card.js +3 -2
- package/card/Card.stories.tsx +1 -1
- package/card/Card.test.d.ts +1 -0
- package/card/Card.test.js +1 -1
- package/checkbox/Checkbox.accessibility.test.d.ts +1 -0
- package/checkbox/Checkbox.accessibility.test.js +5 -5
- package/checkbox/Checkbox.js +10 -13
- package/checkbox/Checkbox.test.d.ts +1 -0
- package/checkbox/Checkbox.test.js +1 -1
- package/chip/Chip.accessibility.test.d.ts +1 -0
- package/chip/Chip.accessibility.test.js +4 -4
- package/chip/Chip.js +3 -1
- package/chip/Chip.stories.tsx +1 -1
- package/chip/Chip.test.d.ts +1 -0
- package/chip/Chip.test.js +1 -1
- package/common/coreTokens.d.ts +0 -1
- package/common/coreTokens.js +3 -4
- package/common/variables.d.ts +47 -3
- package/common/variables.js +109 -71
- package/container/Container.stories.tsx +3 -3
- package/container/types.d.ts +113 -11
- package/contextual-menu/ContextualMenu.accessibility.test.d.ts +1 -0
- package/contextual-menu/ContextualMenu.accessibility.test.js +15 -3
- package/contextual-menu/ContextualMenu.d.ts +3 -5
- package/contextual-menu/ContextualMenu.js +118 -53
- package/contextual-menu/ContextualMenu.stories.tsx +124 -75
- package/contextual-menu/ContextualMenu.test.d.ts +1 -0
- package/contextual-menu/ContextualMenu.test.js +200 -24
- package/contextual-menu/GroupItem.d.ts +4 -0
- package/contextual-menu/GroupItem.js +67 -0
- package/contextual-menu/ItemAction.d.ts +4 -0
- package/contextual-menu/ItemAction.js +88 -0
- package/contextual-menu/MenuItem.d.ts +4 -0
- package/contextual-menu/MenuItem.js +29 -0
- package/contextual-menu/SingleItem.d.ts +4 -0
- package/contextual-menu/SingleItem.js +38 -0
- package/contextual-menu/types.d.ts +54 -11
- package/date-input/Calendar.js +47 -31
- package/date-input/DateInput.accessibility.test.d.ts +1 -0
- package/date-input/DateInput.accessibility.test.js +24 -11
- package/date-input/DateInput.js +27 -21
- package/date-input/DateInput.stories.tsx +18 -12
- package/date-input/DateInput.test.d.ts +1 -0
- package/date-input/DateInput.test.js +39 -39
- package/date-input/DatePicker.js +1 -1
- package/date-input/YearPicker.js +10 -5
- package/dialog/Dialog.accessibility.test.d.ts +1 -0
- package/dialog/Dialog.accessibility.test.js +5 -5
- package/dialog/Dialog.js +3 -2
- package/dialog/Dialog.stories.tsx +8 -4
- package/dialog/Dialog.test.d.ts +1 -0
- package/dialog/Dialog.test.js +111 -48
- package/divider/Divider.accessibility.test.d.ts +1 -0
- package/divider/Divider.accessibility.test.js +2 -2
- package/divider/Divider.stories.tsx +2 -1
- package/divider/Divider.test.d.ts +1 -0
- package/dropdown/Dropdown.accessibility.test.d.ts +1 -0
- package/dropdown/Dropdown.accessibility.test.js +12 -9
- package/dropdown/Dropdown.js +19 -37
- package/dropdown/Dropdown.stories.tsx +11 -11
- package/dropdown/Dropdown.test.d.ts +1 -0
- package/dropdown/Dropdown.test.js +101 -72
- package/dropdown/DropdownMenu.js +4 -4
- package/dropdown/DropdownMenuItem.js +2 -1
- package/file-input/FileInput.accessibility.test.d.ts +1 -0
- package/file-input/FileInput.accessibility.test.js +30 -23
- package/file-input/FileInput.js +3 -8
- package/file-input/FileInput.test.d.ts +1 -0
- package/file-input/FileInput.test.js +44 -22
- package/file-input/FileItem.js +7 -3
- package/file-input/types.d.ts +0 -4
- package/footer/Footer.accessibility.test.d.ts +1 -0
- package/footer/Footer.accessibility.test.js +13 -5
- package/footer/Footer.js +1 -1
- package/footer/Footer.stories.tsx +12 -0
- package/footer/Footer.test.d.ts +1 -0
- package/footer/Footer.test.js +1 -1
- package/footer/Icons.js +2 -30
- package/grid/Grid.stories.tsx +3 -1
- package/header/Header.accessibility.test.d.ts +1 -0
- package/header/Header.accessibility.test.js +16 -6
- package/header/Header.js +3 -2
- package/header/Header.stories.tsx +17 -1
- package/header/Header.test.d.ts +1 -0
- package/header/Header.test.js +1 -1
- package/header/Icons.js +1 -6
- package/heading/Heading.accessibility.test.d.ts +1 -0
- package/heading/Heading.accessibility.test.js +3 -3
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.d.ts +1 -0
- package/heading/Heading.test.js +1 -14
- package/icon/Icon.accessibility.test.d.ts +1 -0
- package/icon/Icon.accessibility.test.js +2 -2
- package/icon/Icon.js +1 -1
- package/icon/Icon.stories.tsx +1 -1
- package/image/Image.accessibility.test.d.ts +1 -0
- package/image/Image.accessibility.test.js +3 -3
- package/image/Image.js +1 -1
- package/layout/ApplicationLayout.js +4 -4
- package/link/Link.accessibility.test.d.ts +1 -0
- package/link/Link.accessibility.test.js +8 -12
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +2 -2
- package/link/Link.test.d.ts +1 -0
- package/link/Link.test.js +1 -1
- package/main.d.ts +3 -1
- package/main.js +15 -1
- package/nav-tabs/NavTabs.accessibility.test.d.ts +1 -0
- package/nav-tabs/NavTabs.accessibility.test.js +3 -3
- package/nav-tabs/NavTabs.js +19 -4
- package/nav-tabs/NavTabs.stories.tsx +18 -3
- package/nav-tabs/NavTabs.test.d.ts +1 -0
- package/nav-tabs/NavTabs.test.js +9 -7
- package/nav-tabs/Tab.js +7 -7
- package/number-input/NumberInput.accessibility.test.d.ts +1 -0
- package/number-input/NumberInput.accessibility.test.js +9 -10
- package/number-input/NumberInput.js +6 -3
- package/number-input/NumberInput.stories.tsx +11 -16
- package/number-input/NumberInput.test.d.ts +1 -0
- package/number-input/NumberInput.test.js +6 -7
- package/package.json +27 -21
- package/paginator/Paginator.accessibility.test.d.ts +1 -0
- package/paginator/Paginator.accessibility.test.js +4 -5
- package/paginator/Paginator.js +9 -5
- package/paginator/Paginator.test.d.ts +1 -0
- package/paginator/Paginator.test.js +2 -3
- package/paragraph/Paragraph.accessibility.test.d.ts +1 -0
- package/paragraph/Paragraph.accessibility.test.js +2 -2
- package/password-input/PasswordInput.accessibility.test.d.ts +1 -0
- package/password-input/PasswordInput.accessibility.test.js +7 -8
- package/password-input/PasswordInput.js +11 -7
- package/password-input/PasswordInput.stories.tsx +10 -1
- package/password-input/PasswordInput.test.d.ts +1 -0
- package/password-input/PasswordInput.test.js +6 -7
- package/progress-bar/ProgressBar.accessibility.test.d.ts +1 -0
- package/progress-bar/ProgressBar.accessibility.test.js +3 -3
- package/progress-bar/ProgressBar.js +6 -4
- package/progress-bar/ProgressBar.test.d.ts +1 -0
- package/progress-bar/ProgressBar.test.js +1 -1
- package/quick-nav/QuickNav.accessibility.test.d.ts +1 -0
- package/quick-nav/QuickNav.accessibility.test.js +2 -2
- package/quick-nav/QuickNav.js +1 -1
- package/radio-group/Radio.js +6 -9
- package/radio-group/RadioGroup.accessibility.test.d.ts +1 -0
- package/radio-group/RadioGroup.accessibility.test.js +4 -4
- package/radio-group/RadioGroup.js +14 -16
- package/radio-group/RadioGroup.test.d.ts +1 -0
- package/radio-group/RadioGroup.test.js +3 -5
- package/resultset-table/ResultsetTable.accessibility.test.d.ts +1 -0
- package/resultset-table/ResultsetTable.accessibility.test.js +16 -6
- package/resultset-table/ResultsetTable.js +41 -13
- package/resultset-table/ResultsetTable.stories.tsx +14 -2
- package/resultset-table/ResultsetTable.test.d.ts +1 -0
- package/resultset-table/ResultsetTable.test.js +103 -34
- package/resultset-table/types.d.ts +4 -3
- package/select/Listbox.d.ts +3 -3
- package/select/Listbox.js +29 -27
- package/select/Option.d.ts +3 -3
- package/select/Option.js +13 -8
- package/select/Select.accessibility.test.d.ts +1 -0
- package/select/Select.accessibility.test.js +18 -8
- package/select/Select.js +75 -190
- package/select/Select.stories.tsx +41 -20
- package/select/Select.test.d.ts +1 -0
- package/select/Select.test.js +42 -150
- package/select/selectUtils.d.ts +41 -0
- package/select/selectUtils.js +129 -0
- package/sidenav/Sidenav.accessibility.test.d.ts +1 -0
- package/sidenav/Sidenav.accessibility.test.js +3 -3
- package/sidenav/Sidenav.js +1 -1
- package/sidenav/Sidenav.stories.tsx +1 -1
- package/sidenav/Sidenav.test.d.ts +1 -0
- package/sidenav/Sidenav.test.js +1 -1
- package/slider/Slider.accessibility.test.d.ts +1 -0
- package/slider/Slider.accessibility.test.js +5 -6
- package/slider/Slider.js +11 -13
- package/slider/Slider.stories.tsx +180 -0
- package/slider/Slider.test.d.ts +1 -0
- package/slider/Slider.test.js +13 -11
- package/spinner/Spinner.accessibility.test.d.ts +1 -0
- package/spinner/Spinner.accessibility.test.js +6 -6
- package/spinner/Spinner.d.ts +1 -1
- package/spinner/Spinner.js +32 -47
- package/spinner/Spinner.test.d.ts +1 -0
- package/spinner/Spinner.test.js +1 -1
- package/status-light/StatusLight.accessibility.test.d.ts +1 -0
- package/status-light/StatusLight.accessibility.test.js +8 -8
- package/status-light/StatusLight.test.d.ts +1 -0
- package/status-light/StatusLight.test.js +1 -1
- package/switch/Switch.accessibility.test.d.ts +1 -0
- package/switch/Switch.accessibility.test.js +14 -5
- package/switch/Switch.js +6 -9
- package/switch/Switch.stories.tsx +12 -0
- package/switch/Switch.test.d.ts +1 -0
- package/switch/Switch.test.js +1 -1
- package/table/Table.accessibility.test.d.ts +1 -0
- package/table/Table.accessibility.test.js +16 -6
- package/table/Table.js +1 -1
- package/table/Table.stories.tsx +13 -1
- package/table/Table.test.d.ts +1 -0
- package/table/Table.test.js +2 -4
- package/tabs/Tab.js +1 -1
- package/tabs/Tabs.accessibility.test.d.ts +1 -0
- package/tabs/Tabs.accessibility.test.js +3 -3
- package/tabs/Tabs.js +1 -1
- package/tabs/Tabs.stories.tsx +7 -1
- package/tabs/Tabs.test.d.ts +1 -0
- package/tabs/Tabs.test.js +1 -1
- package/tag/Tag.accessibility.test.d.ts +1 -0
- package/tag/Tag.accessibility.test.js +4 -4
- package/tag/Tag.js +1 -1
- package/tag/Tag.stories.tsx +1 -1
- package/tag/Tag.test.d.ts +1 -0
- package/tag/Tag.test.js +1 -1
- package/text-input/Suggestion.js +1 -1
- package/text-input/Suggestions.js +14 -6
- package/text-input/TextInput.accessibility.test.d.ts +1 -0
- package/text-input/TextInput.accessibility.test.js +11 -12
- package/text-input/TextInput.js +49 -68
- package/text-input/TextInput.stories.tsx +19 -7
- package/text-input/TextInput.test.d.ts +1 -0
- package/text-input/TextInput.test.js +2 -3
- package/textarea/Textarea.accessibility.test.d.ts +1 -0
- package/textarea/Textarea.accessibility.test.js +7 -7
- package/textarea/Textarea.js +14 -13
- package/textarea/Textarea.test.d.ts +1 -0
- package/textarea/Textarea.test.js +1 -1
- package/toggle-group/ToggleGroup.accessibility.test.d.ts +1 -0
- package/toggle-group/ToggleGroup.accessibility.test.js +5 -5
- package/toggle-group/ToggleGroup.js +6 -9
- package/toggle-group/ToggleGroup.stories.tsx +1 -1
- package/toggle-group/ToggleGroup.test.d.ts +1 -0
- package/toggle-group/ToggleGroup.test.js +1 -1
- package/tooltip/Tooltip.accessibility.test.d.ts +1 -0
- package/tooltip/Tooltip.accessibility.test.js +144 -0
- package/tooltip/Tooltip.d.ts +4 -0
- package/tooltip/Tooltip.js +50 -0
- package/tooltip/Tooltip.stories.tsx +111 -0
- package/tooltip/Tooltip.test.d.ts +1 -0
- package/tooltip/Tooltip.test.js +112 -0
- package/tooltip/types.d.ts +16 -0
- package/tooltip/types.js +5 -0
- package/typography/Typography.accessibility.test.d.ts +1 -0
- package/typography/Typography.accessibility.test.js +12 -12
- package/typography/Typography.stories.tsx +1 -3
- package/typography/Typography.test.js +23 -0
- package/useTheme.d.ts +30 -3
- package/useTranslatedLabels.d.ts +11 -0
- package/utils/BaseTypography.js +45 -41
- package/utils/FocusLock.js +3 -2
- package/utils/useWidth.d.ts +2 -0
- package/utils/useWidth.js +30 -0
- package/wizard/Wizard.accessibility.test.d.ts +1 -0
- package/wizard/Wizard.accessibility.test.js +3 -3
- package/wizard/Wizard.js +1 -9
- package/wizard/Wizard.stories.tsx +1 -1
- package/wizard/Wizard.test.d.ts +1 -0
- package/wizard/Wizard.test.js +1 -1
- package/contextual-menu/MenuItemAction.d.ts +0 -4
- package/contextual-menu/MenuItemAction.js +0 -46
|
@@ -7,8 +7,19 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
7
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _react2 = require("@testing-library/react");
|
|
10
|
-
var
|
|
11
|
-
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable
|
|
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
|
+
};
|
|
12
23
|
var deleteIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
13
24
|
xmlns: "http://www.w3.org/2000/svg",
|
|
14
25
|
height: "24",
|
|
@@ -40,7 +51,7 @@ global.ResizeObserver = /*#__PURE__*/function () {
|
|
|
40
51
|
function ResizeObserver() {
|
|
41
52
|
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
42
53
|
}
|
|
43
|
-
(0, _createClass2["default"])(ResizeObserver, [{
|
|
54
|
+
return (0, _createClass2["default"])(ResizeObserver, [{
|
|
44
55
|
key: "observe",
|
|
45
56
|
value: function observe() {}
|
|
46
57
|
}, {
|
|
@@ -50,7 +61,6 @@ global.ResizeObserver = /*#__PURE__*/function () {
|
|
|
50
61
|
key: "disconnect",
|
|
51
62
|
value: function disconnect() {}
|
|
52
63
|
}]);
|
|
53
|
-
return ResizeObserver;
|
|
54
64
|
}();
|
|
55
65
|
var actions = [{
|
|
56
66
|
title: "icon",
|
|
@@ -236,7 +246,7 @@ describe("Resultset Table input component accessibility tests", function () {
|
|
|
236
246
|
showGoToPage: true
|
|
237
247
|
})), container = _render.container;
|
|
238
248
|
_context.next = 3;
|
|
239
|
-
return (0,
|
|
249
|
+
return (0, _axeHelper.axe)(container, disabledRules);
|
|
240
250
|
case 3:
|
|
241
251
|
results = _context.sent;
|
|
242
252
|
expect(results).toHaveNoViolations();
|
|
@@ -261,7 +271,7 @@ describe("Resultset Table input component accessibility tests", function () {
|
|
|
261
271
|
showGoToPage: true
|
|
262
272
|
})), container = _render2.container;
|
|
263
273
|
_context2.next = 3;
|
|
264
|
-
return (0,
|
|
274
|
+
return (0, _axeHelper.axe)(container, disabledRules);
|
|
265
275
|
case 3:
|
|
266
276
|
results = _context2.sent;
|
|
267
277
|
expect(results).toHaveNoViolations();
|
|
@@ -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,6 +50,17 @@ 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,
|
|
@@ -76,6 +90,10 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
76
90
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
77
91
|
sortOrder = _useState6[0],
|
|
78
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]);
|
|
79
97
|
var minItemsPerPageIndex = (0, _react.useMemo)(function () {
|
|
80
98
|
return getMinItemsPerPageIndex(page, itemsPerPage, page);
|
|
81
99
|
}, [itemsPerPage, page]);
|
|
@@ -83,8 +101,8 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
83
101
|
return getMaxItemsPerPageIndex(minItemsPerPageIndex, itemsPerPage, rows, page);
|
|
84
102
|
}, [itemsPerPage, minItemsPerPageIndex, page, rows]);
|
|
85
103
|
var sortedResultset = (0, _react.useMemo)(function () {
|
|
86
|
-
return sortColumnIndex !== -1 ? sortArray(sortColumnIndex, sortOrder,
|
|
87
|
-
}, [sortColumnIndex, sortOrder,
|
|
104
|
+
return sortColumnIndex !== -1 ? sortArray(sortColumnIndex, sortOrder, rowsWithIds) : rowsWithIds;
|
|
105
|
+
}, [sortColumnIndex, sortOrder, rowsWithIds]);
|
|
88
106
|
var filteredResultset = (0, _react.useMemo)(function () {
|
|
89
107
|
return sortedResultset && sortedResultset.slice(minItemsPerPageIndex, maxItemsPerPageIndex + 1);
|
|
90
108
|
}, [sortedResultset, minItemsPerPageIndex, maxItemsPerPageIndex]);
|
|
@@ -98,9 +116,18 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
98
116
|
};
|
|
99
117
|
(0, _react.useEffect)(function () {
|
|
100
118
|
if (!hidePaginator) {
|
|
101
|
-
rows.length
|
|
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;
|
|
102
129
|
}
|
|
103
|
-
}, [rows]);
|
|
130
|
+
}, [rows.length]);
|
|
104
131
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
105
132
|
theme: colorsTheme.table
|
|
106
133
|
}, /*#__PURE__*/_react["default"].createElement(DxcResultsetTableContainer, {
|
|
@@ -119,12 +146,13 @@ var DxcResultsetTable = function DxcResultsetTable(_ref) {
|
|
|
119
146
|
},
|
|
120
147
|
tabIndex: column.isSortable ? tabIndex : -1,
|
|
121
148
|
isSortable: column.isSortable,
|
|
122
|
-
mode: mode
|
|
149
|
+
mode: mode,
|
|
150
|
+
"aria-label": column.isSortable ? "Sort column" : undefined
|
|
123
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)));
|
|
124
|
-
}))), /*#__PURE__*/_react["default"].createElement("tbody", null, filteredResultset.map(function (
|
|
152
|
+
}))), /*#__PURE__*/_react["default"].createElement("tbody", null, filteredResultset.map(function (row) {
|
|
125
153
|
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
126
|
-
key: "resultSetTableCell_".concat(
|
|
127
|
-
}, cells.map(function (cellContent, cellIndex) {
|
|
154
|
+
key: "resultSetTableCell_".concat(row.id)
|
|
155
|
+
}, row.cells.map(function (cellContent, cellIndex) {
|
|
128
156
|
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
129
157
|
key: "resultSetTableCellContent_".concat(cellIndex)
|
|
130
158
|
}, cellContent.displayValue);
|
|
@@ -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 = (
|
|
@@ -397,5 +409,5 @@ export const DropdownAction = ResultsetActionsCellDropdown.bind({});
|
|
|
397
409
|
DropdownAction.play = async ({ canvasElement }) => {
|
|
398
410
|
const canvas = within(canvasElement);
|
|
399
411
|
const dropdown = canvas.getAllByRole("button")[5];
|
|
400
|
-
|
|
412
|
+
userEvent.click(dropdown);
|
|
401
413
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,7 +8,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _react2 = require("@testing-library/react");
|
|
10
10
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
11
|
-
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable
|
|
11
|
+
var _ResultsetTable = _interopRequireDefault(require("./ResultsetTable"));
|
|
12
|
+
var _Checkbox = _interopRequireDefault(require("../checkbox/Checkbox"));
|
|
12
13
|
// Mocking DOMRect for Radix Primitive Popover
|
|
13
14
|
global.globalThis = global;
|
|
14
15
|
global.DOMRect = {
|
|
@@ -27,7 +28,7 @@ global.ResizeObserver = /*#__PURE__*/function () {
|
|
|
27
28
|
function ResizeObserver() {
|
|
28
29
|
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
29
30
|
}
|
|
30
|
-
(0, _createClass2["default"])(ResizeObserver, [{
|
|
31
|
+
return (0, _createClass2["default"])(ResizeObserver, [{
|
|
31
32
|
key: "observe",
|
|
32
33
|
value: function observe() {}
|
|
33
34
|
}, {
|
|
@@ -37,7 +38,6 @@ global.ResizeObserver = /*#__PURE__*/function () {
|
|
|
37
38
|
key: "disconnect",
|
|
38
39
|
value: function disconnect() {}
|
|
39
40
|
}]);
|
|
40
|
-
return ResizeObserver;
|
|
41
41
|
}();
|
|
42
42
|
var icon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
43
43
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -152,36 +152,55 @@ var rows = [[{
|
|
|
152
152
|
displayValue: "Barcelona",
|
|
153
153
|
sortValue: "Barcelona"
|
|
154
154
|
}]];
|
|
155
|
-
var
|
|
156
|
-
displayValue: "
|
|
157
|
-
|
|
155
|
+
var columnsWithCheckbox = [{
|
|
156
|
+
displayValue: "Id",
|
|
157
|
+
isSortable: true
|
|
158
|
+
}, {
|
|
159
|
+
displayValue: "Checkbox",
|
|
160
|
+
isSortable: false
|
|
161
|
+
}, {
|
|
162
|
+
displayValue: "Name",
|
|
163
|
+
isSortable: false
|
|
164
|
+
}, {
|
|
165
|
+
displayValue: "City",
|
|
166
|
+
isSortable: false
|
|
167
|
+
}];
|
|
168
|
+
var rowsWithCheckbox = [[{
|
|
169
|
+
displayValue: "001",
|
|
170
|
+
sortValue: "001"
|
|
171
|
+
}, {
|
|
172
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
173
|
+
size: "fillParent",
|
|
174
|
+
defaultChecked: true
|
|
175
|
+
})
|
|
158
176
|
}, {
|
|
159
|
-
displayValue: "
|
|
160
|
-
sortValue: "OtherValue"
|
|
177
|
+
displayValue: "Peter"
|
|
161
178
|
}, {
|
|
162
|
-
displayValue: "
|
|
163
|
-
sortValue: "OtherValue"
|
|
179
|
+
displayValue: "Miami"
|
|
164
180
|
}], [{
|
|
165
|
-
displayValue: "
|
|
166
|
-
sortValue: "
|
|
181
|
+
displayValue: "002",
|
|
182
|
+
sortValue: "002"
|
|
167
183
|
}, {
|
|
168
|
-
displayValue: "
|
|
169
|
-
|
|
184
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
185
|
+
size: "fillParent"
|
|
186
|
+
})
|
|
170
187
|
}, {
|
|
171
|
-
displayValue: "
|
|
172
|
-
sortValue: "OtherValue"
|
|
188
|
+
displayValue: "Louis"
|
|
173
189
|
}, {
|
|
174
|
-
displayValue: ""
|
|
190
|
+
displayValue: "London"
|
|
175
191
|
}], [{
|
|
176
|
-
displayValue: "
|
|
177
|
-
sortValue: "
|
|
192
|
+
displayValue: "003",
|
|
193
|
+
sortValue: "003"
|
|
194
|
+
}, {
|
|
195
|
+
displayValue: /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], {
|
|
196
|
+
size: "fillParent"
|
|
197
|
+
})
|
|
178
198
|
}, {
|
|
179
|
-
displayValue: "
|
|
180
|
-
sortValue: "OtherValue"
|
|
199
|
+
displayValue: "Lana"
|
|
181
200
|
}, {
|
|
182
|
-
displayValue: "
|
|
183
|
-
sortValue: "OtherValue"
|
|
201
|
+
displayValue: "Amsterdam"
|
|
184
202
|
}]];
|
|
203
|
+
var rows2 = [].concat(rows).slice(0, -1);
|
|
185
204
|
describe("Resultset table component tests", function () {
|
|
186
205
|
test("Resultset table rendered correctly", function () {
|
|
187
206
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
@@ -285,42 +304,93 @@ describe("Resultset table component tests", function () {
|
|
|
285
304
|
expect(component.queryByText("Tina")).toBeTruthy();
|
|
286
305
|
expect(component.queryByText("Cosmin")).not.toBeTruthy();
|
|
287
306
|
});
|
|
288
|
-
test("Resultset table
|
|
307
|
+
test("Resultset table should go one page back when removing the last page data", function () {
|
|
289
308
|
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
290
309
|
columns: columns,
|
|
291
310
|
rows: rows,
|
|
292
311
|
itemsPerPage: 3
|
|
293
312
|
})),
|
|
313
|
+
getAllByRole = _render6.getAllByRole,
|
|
294
314
|
queryByText = _render6.queryByText,
|
|
295
315
|
rerender = _render6.rerender;
|
|
316
|
+
expect(queryByText("1 to 3 of 10")).toBeTruthy();
|
|
317
|
+
var lastButton = getAllByRole("button")[4];
|
|
296
318
|
expect(queryByText("Peter")).toBeTruthy();
|
|
319
|
+
_react2.fireEvent.click(lastButton);
|
|
320
|
+
expect(queryByText("10 to 10 of 10")).toBeTruthy();
|
|
297
321
|
rerender( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
298
322
|
columns: columns,
|
|
299
323
|
rows: rows2,
|
|
300
324
|
itemsPerPage: 3
|
|
301
325
|
}));
|
|
302
|
-
expect(queryByText("
|
|
326
|
+
expect(queryByText("7 to 9 of 9")).toBeTruthy();
|
|
303
327
|
});
|
|
304
|
-
test("Resultset table
|
|
328
|
+
test("Resultset table shouldn't go one page back when there is data left in the last page", function () {
|
|
305
329
|
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
330
|
+
columns: columns,
|
|
331
|
+
rows: rows,
|
|
332
|
+
itemsPerPage: 2
|
|
333
|
+
})),
|
|
334
|
+
getAllByRole = _render7.getAllByRole,
|
|
335
|
+
queryByText = _render7.queryByText,
|
|
336
|
+
rerender = _render7.rerender;
|
|
337
|
+
expect(queryByText("1 to 2 of 10")).toBeTruthy();
|
|
338
|
+
var lastButton = getAllByRole("button")[4];
|
|
339
|
+
expect(queryByText("Peter")).toBeTruthy();
|
|
340
|
+
_react2.fireEvent.click(lastButton);
|
|
341
|
+
expect(queryByText("9 to 10 of 10")).toBeTruthy();
|
|
342
|
+
rerender( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
343
|
+
columns: columns,
|
|
344
|
+
rows: rows2,
|
|
345
|
+
itemsPerPage: 2
|
|
346
|
+
}));
|
|
347
|
+
expect(queryByText("9 to 9 of 9")).toBeTruthy();
|
|
348
|
+
});
|
|
349
|
+
test("Resultset table uncontrolled components maintain its value when sorting", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
350
|
+
var _render8, getAllByRole, columnHeader, sortButton;
|
|
351
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
352
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
353
|
+
case 0:
|
|
354
|
+
_render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
355
|
+
columns: columnsWithCheckbox,
|
|
356
|
+
rows: rowsWithCheckbox,
|
|
357
|
+
itemsPerPage: 3
|
|
358
|
+
})), getAllByRole = _render8.getAllByRole;
|
|
359
|
+
columnHeader = getAllByRole("columnheader")[0];
|
|
360
|
+
sortButton = getAllByRole("button")[0];
|
|
361
|
+
expect(getAllByRole("checkbox")[0].getAttribute("aria-checked")).toBe("true");
|
|
362
|
+
expect(columnHeader.getAttribute("aria-sort")).toBe("none");
|
|
363
|
+
_react2.fireEvent.click(sortButton);
|
|
364
|
+
expect(columnHeader.getAttribute("aria-sort")).toBe("ascending");
|
|
365
|
+
_react2.fireEvent.click(sortButton);
|
|
366
|
+
expect(columnHeader.getAttribute("aria-sort")).toBe("descending");
|
|
367
|
+
expect(getAllByRole("checkbox")[0].getAttribute("aria-checked")).toBe("false");
|
|
368
|
+
case 10:
|
|
369
|
+
case "end":
|
|
370
|
+
return _context2.stop();
|
|
371
|
+
}
|
|
372
|
+
}, _callee2);
|
|
373
|
+
})));
|
|
374
|
+
test("Resultset table change itemsPerPage should go to first page", function () {
|
|
375
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
306
376
|
columns: columns,
|
|
307
377
|
rows: rows,
|
|
308
378
|
itemsPerPage: 3,
|
|
309
379
|
itemsPerPageOptions: [2, 3]
|
|
310
380
|
})),
|
|
311
|
-
getAllByRole =
|
|
381
|
+
getAllByRole = _render9.getAllByRole;
|
|
312
382
|
var lastButton = getAllByRole("button")[4];
|
|
313
383
|
expect(getAllByRole("row").length - 1).toEqual(3);
|
|
314
384
|
_react2.fireEvent.click(lastButton);
|
|
315
385
|
expect(getAllByRole("row").length - 1).toEqual(1);
|
|
316
386
|
});
|
|
317
387
|
test("Resultset table may not use the paginator", function () {
|
|
318
|
-
var
|
|
388
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
319
389
|
columns: columns,
|
|
320
390
|
rows: rows,
|
|
321
391
|
hidePaginator: true
|
|
322
392
|
})),
|
|
323
|
-
getAllByRole =
|
|
393
|
+
getAllByRole = _render10.getAllByRole;
|
|
324
394
|
var nextButton = getAllByRole("button")[3];
|
|
325
395
|
expect(nextButton).not.toBeTruthy();
|
|
326
396
|
});
|
|
@@ -328,7 +398,6 @@ describe("Resultset table component tests", function () {
|
|
|
328
398
|
var onSelectOption = jest.fn();
|
|
329
399
|
var onClick = jest.fn();
|
|
330
400
|
var actions = [{
|
|
331
|
-
icon: icon,
|
|
332
401
|
title: "icon1",
|
|
333
402
|
onClick: onSelectOption,
|
|
334
403
|
options: [{
|
|
@@ -358,14 +427,14 @@ describe("Resultset table component tests", function () {
|
|
|
358
427
|
}),
|
|
359
428
|
sortValue: "Actions"
|
|
360
429
|
}]];
|
|
361
|
-
var
|
|
430
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
|
|
362
431
|
columns: columns,
|
|
363
432
|
rows: actionRows,
|
|
364
433
|
itemsPerPage: 3
|
|
365
434
|
})),
|
|
366
|
-
getAllByRole =
|
|
367
|
-
getByRole =
|
|
368
|
-
getByText =
|
|
435
|
+
getAllByRole = _render11.getAllByRole,
|
|
436
|
+
getByRole = _render11.getByRole,
|
|
437
|
+
getByText = _render11.getByText;
|
|
369
438
|
var dropdown = getAllByRole("button")[2];
|
|
370
439
|
(0, _react2.act)(function () {
|
|
371
440
|
_userEvent["default"].click(dropdown);
|
|
@@ -16,7 +16,7 @@ export type Column = {
|
|
|
16
16
|
*/
|
|
17
17
|
isSortable?: boolean;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type Cell = {
|
|
20
20
|
/**
|
|
21
21
|
* Value to be displayed in the cell.
|
|
22
22
|
*/
|
|
@@ -25,8 +25,9 @@ export type Row = {
|
|
|
25
25
|
* Value to be used when sorting the table by that
|
|
26
26
|
* column. If not indicated displayValue will be used for sorting.
|
|
27
27
|
*/
|
|
28
|
-
sortValue?: string;
|
|
28
|
+
sortValue?: string | number | Date;
|
|
29
29
|
};
|
|
30
|
+
export type Row = Cell[];
|
|
30
31
|
type CommonProps = {
|
|
31
32
|
/**
|
|
32
33
|
* An array of objects representing the columns of the table.
|
|
@@ -36,7 +37,7 @@ type CommonProps = {
|
|
|
36
37
|
* An array of objects representing the rows of the table, you will have
|
|
37
38
|
* as many objects as columns in the table.
|
|
38
39
|
*/
|
|
39
|
-
rows: Row[]
|
|
40
|
+
rows: Row[];
|
|
40
41
|
/**
|
|
41
42
|
* Size of the margin to be applied to the component. You can pass an object with 'top',
|
|
42
43
|
* 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
|
package/select/Listbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ListboxProps } from "./types";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const Listbox: ({ id, currentValue, options, visualFocusIndex, lastOptionIndex, multiple, optional, optionalItem, searchable, handleOptionOnClick, styles, }: ListboxProps) => JSX.Element;
|
|
4
|
+
export default Listbox;
|
package/select/Listbox.js
CHANGED
|
@@ -12,15 +12,10 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
12
12
|
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
13
13
|
var _Option = _interopRequireDefault(require("./Option"));
|
|
14
14
|
var _Icon = _interopRequireDefault(require("../icon/Icon"));
|
|
15
|
-
var
|
|
15
|
+
var _selectUtils = require("./selectUtils");
|
|
16
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
16
17
|
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); }
|
|
17
|
-
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 &&
|
|
18
|
-
var groupsHaveOptions = function groupsHaveOptions(options) {
|
|
19
|
-
return options !== null && options !== void 0 && options[0].options ? options.some(function (groupOption) {
|
|
20
|
-
var _groupOption$options;
|
|
21
|
-
return ((_groupOption$options = groupOption.options) === null || _groupOption$options === void 0 ? void 0 : _groupOption$options.length) > 0;
|
|
22
|
-
}) : true;
|
|
23
|
-
};
|
|
18
|
+
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; }
|
|
24
19
|
var Listbox = function Listbox(_ref) {
|
|
25
20
|
var id = _ref.id,
|
|
26
21
|
currentValue = _ref.currentValue,
|
|
@@ -37,21 +32,24 @@ var Listbox = function Listbox(_ref) {
|
|
|
37
32
|
var listboxRef = (0, _react.useRef)(null);
|
|
38
33
|
var globalIndex = optional && !multiple ? 0 : -1;
|
|
39
34
|
var mapOptionFunc = function mapOptionFunc(option, mapIndex) {
|
|
35
|
+
var groupId = "".concat(id, "-group-").concat(mapIndex);
|
|
40
36
|
if (option.options) {
|
|
41
|
-
var groupId = "group-".concat(mapIndex);
|
|
42
37
|
return option.options.length > 0 && /*#__PURE__*/_react["default"].createElement("li", {
|
|
43
|
-
key:
|
|
44
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
45
|
-
role: "
|
|
46
|
-
"aria-labelledby": groupId
|
|
38
|
+
key: groupId
|
|
39
|
+
}, /*#__PURE__*/_react["default"].createElement("ul", {
|
|
40
|
+
role: "listbox",
|
|
41
|
+
"aria-labelledby": groupId,
|
|
42
|
+
style: {
|
|
43
|
+
padding: 0
|
|
44
|
+
}
|
|
47
45
|
}, /*#__PURE__*/_react["default"].createElement(GroupLabel, {
|
|
48
46
|
role: "presentation",
|
|
49
47
|
id: groupId
|
|
50
48
|
}, option.label), option.options.map(function (singleOption) {
|
|
51
49
|
globalIndex++;
|
|
52
50
|
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
53
|
-
key: "option-".concat(singleOption.value),
|
|
54
|
-
id: "option-".concat(globalIndex),
|
|
51
|
+
key: "".concat(id, "-option-").concat(singleOption.value),
|
|
52
|
+
id: "".concat(id, "-option-").concat(globalIndex),
|
|
55
53
|
option: singleOption,
|
|
56
54
|
onClick: handleOptionOnClick,
|
|
57
55
|
multiple: multiple,
|
|
@@ -64,8 +62,8 @@ var Listbox = function Listbox(_ref) {
|
|
|
64
62
|
} else {
|
|
65
63
|
globalIndex++;
|
|
66
64
|
return /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
67
|
-
key: "option-".concat(option.value),
|
|
68
|
-
id: "option-".concat(globalIndex),
|
|
65
|
+
key: "".concat(id, "-option-").concat(option.value),
|
|
66
|
+
id: "".concat(id, "-option-").concat(globalIndex),
|
|
69
67
|
option: option,
|
|
70
68
|
onClick: handleOptionOnClick,
|
|
71
69
|
multiple: multiple,
|
|
@@ -93,6 +91,10 @@ var Listbox = function Listbox(_ref) {
|
|
|
93
91
|
inline: "start"
|
|
94
92
|
});
|
|
95
93
|
}, [visualFocusIndex]);
|
|
94
|
+
var hasOptionGroups = options.some(function (option) {
|
|
95
|
+
var _option$options;
|
|
96
|
+
return ((_option$options = option.options) === null || _option$options === void 0 ? void 0 : _option$options.length) > 0;
|
|
97
|
+
});
|
|
96
98
|
return /*#__PURE__*/_react["default"].createElement(ListboxContainer, {
|
|
97
99
|
id: id,
|
|
98
100
|
onClick: function onClick(event) {
|
|
@@ -102,14 +104,15 @@ var Listbox = function Listbox(_ref) {
|
|
|
102
104
|
event.preventDefault();
|
|
103
105
|
},
|
|
104
106
|
ref: listboxRef,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
"aria-multiselectable": !hasOptionGroups ? multiple : undefined,
|
|
108
|
+
style: styles,
|
|
109
|
+
role: hasOptionGroups ? "list" : "listbox",
|
|
110
|
+
"aria-label": "List of options"
|
|
111
|
+
}, searchable && (options.length === 0 || !(0, _selectUtils.groupsHaveOptions)(options)) ? /*#__PURE__*/_react["default"].createElement(OptionsSystemMessage, null, /*#__PURE__*/_react["default"].createElement(NoMatchesFoundIcon, null, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
109
112
|
icon: "search_off"
|
|
110
113
|
})), translatedLabels.select.noMatchesErrorMessage) : optional && !multiple && /*#__PURE__*/_react["default"].createElement(_Option["default"], {
|
|
111
|
-
key: "option-".concat(optionalItem.value),
|
|
112
|
-
id: "
|
|
114
|
+
key: "".concat(id, "-option-").concat(optionalItem.value),
|
|
115
|
+
id: "".concat(id, "-option-", 0),
|
|
113
116
|
option: optionalItem,
|
|
114
117
|
onClick: handleOptionOnClick,
|
|
115
118
|
multiple: multiple,
|
|
@@ -119,7 +122,7 @@ var Listbox = function Listbox(_ref) {
|
|
|
119
122
|
isSelected: multiple ? currentValue.includes(optionalItem.value) : currentValue === optionalItem.value
|
|
120
123
|
}), options.map(mapOptionFunc));
|
|
121
124
|
};
|
|
122
|
-
var ListboxContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n max-height: 304px;\n overflow-y: auto;\n margin: 0;\n padding: 0.25rem 0;\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n
|
|
125
|
+
var ListboxContainer = _styledComponents["default"].ul(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n max-height: 304px;\n overflow-y: auto;\n margin: 0;\n padding: 0.25rem 0;\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 24px;\n cursor: default;\n"])), function (props) {
|
|
123
126
|
return props.theme.listDialogBackgroundColor;
|
|
124
127
|
}, function (props) {
|
|
125
128
|
return props.theme.listDialogBorderColor;
|
|
@@ -138,8 +141,7 @@ var OptionsSystemMessage = _styledComponents["default"].span(_templateObject2 ||
|
|
|
138
141
|
return props.theme.systemMessageFontColor;
|
|
139
142
|
});
|
|
140
143
|
var NoMatchesFoundIcon = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n height: 16px;\n width: 16px;\n padding: 4px;\n margin-right: 0.25rem;\n font-size: 16px;\n"])));
|
|
141
|
-
var
|
|
142
|
-
var GroupLabel = _styledComponents["default"].li(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n padding: 4px 16px;\n font-weight: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
144
|
+
var GroupLabel = _styledComponents["default"].li(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n padding: 4px 16px;\n font-weight: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
143
145
|
return props.theme.listGroupLabelFontWeight;
|
|
144
146
|
});
|
|
145
|
-
var _default = exports["default"] =
|
|
147
|
+
var _default = exports["default"] = Listbox;
|
package/select/Option.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { OptionProps } from "../select/types";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const Option: ({ id, option, onClick, multiple, visualFocused, isGroupedOption, isLastOption, isSelected, }: OptionProps) => JSX.Element;
|
|
4
|
+
export default Option;
|