@dxc-technology/halstack-react 0.0.0-c9c1158 → 0.0.0-c9efd3e

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.
Files changed (216) hide show
  1. package/BackgroundColorContext.d.ts +1 -10
  2. package/BackgroundColorContext.js +2 -7
  3. package/HalstackContext.d.ts +29 -133
  4. package/HalstackContext.js +1 -1
  5. package/accordion/Accordion.accessibility.test.js +71 -0
  6. package/accordion/Accordion.js +10 -26
  7. package/accordion/Accordion.stories.tsx +4 -36
  8. package/accordion/types.d.ts +1 -1
  9. package/accordion-group/AccordionGroup.accessibility.test.js +88 -0
  10. package/accordion-group/AccordionGroup.d.ts +2 -3
  11. package/accordion-group/AccordionGroup.js +3 -3
  12. package/accordion-group/AccordionGroupAccordion.js +2 -2
  13. package/accordion-group/AccordionGroupContext.d.ts +3 -0
  14. package/accordion-group/AccordionGroupContext.js +8 -0
  15. package/accordion-group/types.d.ts +1 -1
  16. package/action-icon/ActionIcon.accessibility.test.js +63 -0
  17. package/action-icon/ActionIcon.d.ts +4 -0
  18. package/action-icon/ActionIcon.js +48 -0
  19. package/action-icon/ActionIcon.stories.tsx +41 -0
  20. package/action-icon/ActionIcon.test.js +64 -0
  21. package/action-icon/types.d.ts +26 -0
  22. package/action-icon/types.js +5 -0
  23. package/alert/Alert.accessibility.test.js +95 -0
  24. package/alert/Alert.js +15 -72
  25. package/badge/Badge.accessibility.test.js +129 -0
  26. package/badge/Badge.d.ts +1 -1
  27. package/badge/Badge.js +141 -28
  28. package/badge/Badge.stories.tsx +210 -0
  29. package/badge/Badge.test.js +30 -0
  30. package/badge/types.d.ts +52 -3
  31. package/box/Box.accessibility.test.js +33 -0
  32. package/box/Box.js +1 -4
  33. package/bulleted-list/BulletedList.accessibility.test.js +107 -0
  34. package/bulleted-list/BulletedList.js +15 -22
  35. package/bulleted-list/BulletedList.stories.tsx +1 -2
  36. package/button/Button.accessibility.test.js +127 -0
  37. package/button/Button.js +15 -15
  38. package/button/Button.stories.tsx +32 -51
  39. package/button/Button.test.js +3 -1
  40. package/button/types.d.ts +1 -1
  41. package/card/Card.accessibility.test.js +36 -0
  42. package/checkbox/Checkbox.accessibility.test.js +87 -0
  43. package/checkbox/Checkbox.js +26 -31
  44. package/chip/Chip.accessibility.test.js +67 -0
  45. package/chip/Chip.js +8 -5
  46. package/chip/Chip.stories.tsx +5 -24
  47. package/chip/Chip.test.js +4 -4
  48. package/common/coreTokens.d.ts +1 -1
  49. package/common/coreTokens.js +3 -3
  50. package/common/variables.d.ts +29 -133
  51. package/common/variables.js +38 -142
  52. package/container/Container.js +3 -7
  53. package/container/Container.stories.tsx +10 -25
  54. package/contextual-menu/ContextualMenu.accessibility.test.js +86 -0
  55. package/contextual-menu/ContextualMenu.d.ts +7 -0
  56. package/contextual-menu/ContextualMenu.js +71 -0
  57. package/contextual-menu/ContextualMenu.stories.tsx +182 -0
  58. package/contextual-menu/ContextualMenu.test.js +71 -0
  59. package/contextual-menu/MenuItemAction.d.ts +4 -0
  60. package/contextual-menu/MenuItemAction.js +46 -0
  61. package/contextual-menu/types.d.ts +22 -0
  62. package/contextual-menu/types.js +5 -0
  63. package/date-input/DateInput.accessibility.test.js +216 -0
  64. package/date-input/types.d.ts +2 -2
  65. package/dialog/Dialog.accessibility.test.js +69 -0
  66. package/dialog/Dialog.js +2 -5
  67. package/dialog/Dialog.stories.tsx +170 -0
  68. package/dialog/Dialog.test.js +1 -1
  69. package/divider/Divider.accessibility.test.js +33 -0
  70. package/divider/Divider.d.ts +4 -0
  71. package/divider/Divider.js +36 -0
  72. package/divider/Divider.stories.tsx +223 -0
  73. package/divider/Divider.test.js +38 -0
  74. package/divider/types.d.ts +21 -0
  75. package/divider/types.js +5 -0
  76. package/dropdown/Dropdown.accessibility.test.js +180 -0
  77. package/dropdown/Dropdown.js +21 -36
  78. package/dropdown/Dropdown.stories.tsx +5 -16
  79. package/dropdown/DropdownMenuItem.js +6 -3
  80. package/dropdown/types.d.ts +3 -5
  81. package/file-input/FileInput.accessibility.test.js +160 -0
  82. package/file-input/FileInput.js +3 -39
  83. package/file-input/FileInput.test.js +7 -84
  84. package/file-input/FileItem.js +13 -27
  85. package/footer/Footer.accessibility.test.js +117 -0
  86. package/footer/Footer.d.ts +1 -1
  87. package/footer/Footer.js +36 -31
  88. package/footer/Footer.stories.tsx +46 -2
  89. package/footer/Icons.d.ts +1 -0
  90. package/footer/Icons.js +65 -1
  91. package/footer/types.d.ts +8 -8
  92. package/header/Header.accessibility.test.js +84 -0
  93. package/header/Header.js +18 -40
  94. package/header/types.d.ts +4 -3
  95. package/heading/Heading.accessibility.test.js +33 -0
  96. package/icon/Icon.accessibility.test.js +30 -0
  97. package/icon/Icon.d.ts +4 -0
  98. package/icon/Icon.js +33 -0
  99. package/icon/Icon.stories.tsx +28 -0
  100. package/icon/types.d.ts +4 -0
  101. package/icon/types.js +5 -0
  102. package/image/Image.accessibility.test.js +56 -0
  103. package/image/Image.stories.tsx +3 -1
  104. package/layout/ApplicationLayout.d.ts +1 -1
  105. package/layout/ApplicationLayout.js +1 -1
  106. package/layout/Icons.js +0 -2
  107. package/link/Link.accessibility.test.js +112 -0
  108. package/link/Link.js +7 -5
  109. package/link/Link.stories.tsx +2 -2
  110. package/link/types.d.ts +1 -1
  111. package/main.d.ts +5 -3
  112. package/main.js +22 -8
  113. package/nav-tabs/NavTabs.accessibility.test.js +52 -0
  114. package/nav-tabs/NavTabs.d.ts +1 -2
  115. package/nav-tabs/NavTabs.js +9 -6
  116. package/nav-tabs/NavTabs.stories.tsx +6 -4
  117. package/nav-tabs/NavTabs.test.js +3 -2
  118. package/nav-tabs/NavTabsContext.d.ts +3 -0
  119. package/nav-tabs/NavTabsContext.js +8 -0
  120. package/nav-tabs/Tab.js +8 -7
  121. package/number-input/NumberInput.accessibility.test.js +228 -0
  122. package/number-input/NumberInput.d.ts +0 -7
  123. package/number-input/NumberInput.js +24 -5
  124. package/number-input/NumberInput.test.js +165 -6
  125. package/number-input/NumberInputContext.d.ts +3 -0
  126. package/number-input/NumberInputContext.js +8 -0
  127. package/number-input/types.d.ts +6 -0
  128. package/package.json +12 -12
  129. package/paginator/Paginator.accessibility.test.js +79 -0
  130. package/paginator/Paginator.js +1 -4
  131. package/paragraph/Paragraph.accessibility.test.js +28 -0
  132. package/paragraph/Paragraph.js +2 -7
  133. package/password-input/PasswordInput.accessibility.test.js +153 -0
  134. package/password-input/PasswordInput.stories.tsx +0 -1
  135. package/progress-bar/ProgressBar.accessibility.test.js +35 -0
  136. package/progress-bar/ProgressBar.js +5 -11
  137. package/quick-nav/QuickNav.accessibility.test.js +57 -0
  138. package/radio-group/RadioGroup.accessibility.test.js +97 -0
  139. package/radio-group/RadioGroup.js +1 -1
  140. package/resultset-table/ResultsetTable.accessibility.test.js +274 -0
  141. package/resultset-table/ResultsetTable.d.ts +4 -1
  142. package/resultset-table/ResultsetTable.js +23 -12
  143. package/resultset-table/ResultsetTable.stories.tsx +106 -5
  144. package/resultset-table/ResultsetTable.test.js +76 -0
  145. package/resultset-table/types.d.ts +40 -7
  146. package/select/Option.js +8 -1
  147. package/select/Select.accessibility.test.js +217 -0
  148. package/select/Select.js +35 -27
  149. package/select/Select.stories.tsx +0 -1
  150. package/select/Select.test.js +498 -462
  151. package/select/types.d.ts +2 -2
  152. package/sidenav/Sidenav.accessibility.test.js +59 -0
  153. package/sidenav/Sidenav.js +20 -18
  154. package/sidenav/Sidenav.stories.tsx +4 -9
  155. package/sidenav/types.d.ts +2 -2
  156. package/slider/Slider.accessibility.test.js +104 -0
  157. package/slider/Slider.js +37 -46
  158. package/spinner/Spinner.accessibility.test.js +96 -0
  159. package/spinner/Spinner.js +6 -14
  160. package/status-light/StatusLight.accessibility.test.js +157 -0
  161. package/status-light/StatusLight.d.ts +4 -0
  162. package/status-light/StatusLight.js +51 -0
  163. package/status-light/StatusLight.stories.tsx +74 -0
  164. package/status-light/StatusLight.test.js +25 -0
  165. package/status-light/types.d.ts +17 -0
  166. package/status-light/types.js +5 -0
  167. package/switch/Switch.accessibility.test.js +89 -0
  168. package/switch/Switch.js +23 -28
  169. package/table/DropdownTheme.js +62 -0
  170. package/table/Table.accessibility.test.js +82 -0
  171. package/table/Table.d.ts +6 -2
  172. package/table/Table.js +73 -11
  173. package/table/Table.stories.tsx +297 -2
  174. package/table/Table.test.js +92 -0
  175. package/table/types.d.ts +28 -0
  176. package/tabs/Tab.js +7 -4
  177. package/tabs/Tabs.accessibility.test.js +56 -0
  178. package/tabs/Tabs.js +4 -5
  179. package/tabs/Tabs.stories.tsx +1 -1
  180. package/tag/Tag.accessibility.test.js +69 -0
  181. package/tag/Tag.js +6 -6
  182. package/tag/Tag.stories.tsx +4 -7
  183. package/tag/Tag.test.js +4 -12
  184. package/tag/types.d.ts +2 -2
  185. package/text-input/Suggestions.js +7 -10
  186. package/text-input/TextInput.accessibility.test.js +321 -0
  187. package/text-input/TextInput.js +77 -102
  188. package/text-input/TextInput.stories.tsx +1 -1
  189. package/text-input/TextInput.test.js +96 -79
  190. package/textarea/Textarea.accessibility.test.js +155 -0
  191. package/textarea/Textarea.js +10 -16
  192. package/textarea/Textarea.stories.tsx +0 -1
  193. package/toggle-group/ToggleGroup.accessibility.test.js +107 -0
  194. package/toggle-group/ToggleGroup.js +1 -4
  195. package/typography/Typography.accessibility.test.js +339 -0
  196. package/useTheme.d.ts +29 -133
  197. package/utils/FocusLock.js +15 -5
  198. package/wizard/Wizard.accessibility.test.js +55 -0
  199. package/wizard/types.d.ts +1 -1
  200. package/common/OpenSans.css +0 -69
  201. package/common/fonts/OpenSans-Bold.ttf +0 -0
  202. package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  203. package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  204. package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  205. package/common/fonts/OpenSans-Italic.ttf +0 -0
  206. package/common/fonts/OpenSans-Light.ttf +0 -0
  207. package/common/fonts/OpenSans-LightItalic.ttf +0 -0
  208. package/common/fonts/OpenSans-Regular.ttf +0 -0
  209. package/common/fonts/OpenSans-SemiBold.ttf +0 -0
  210. package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  211. package/sidenav/Icons.d.ts +0 -7
  212. package/sidenav/Icons.js +0 -47
  213. package/text-input/Icons.d.ts +0 -8
  214. package/text-input/Icons.js +0 -56
  215. /package/{layout → sidenav}/SidenavContext.d.ts +0 -0
  216. /package/{layout → sidenav}/SidenavContext.js +0 -0
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
  import DxcResultsetTable from "./ResultsetTable";
3
- import DxcButton from "../button/Button";
4
3
  import Title from "../../.storybook/components/Title";
5
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
6
5
  import { userEvent, within } from "@storybook/testing-library";
7
6
  import styled from "styled-components";
7
+ import { HalstackProvider } from "../HalstackContext";
8
8
 
9
9
  export default {
10
10
  title: "Resultset Table",
@@ -13,7 +13,7 @@ export default {
13
13
 
14
14
  const deleteIcon = (
15
15
  <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
16
- <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
16
+ <path fill="currentColor" d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
17
17
  <path d="M0 0h24v24H0z" fill="none" />
18
18
  </svg>
19
19
  );
@@ -29,17 +29,77 @@ const rows = [
29
29
  [{ displayValue: "006" }, { displayValue: "Cris" }, { displayValue: "Paris" }],
30
30
  ];
31
31
 
32
+ const advancedTheme = {
33
+ table: {
34
+ actionIconColor: "#1B75BB",
35
+ hoverActionIconColor: "#1B75BB",
36
+ activeActionIconColor: "#1B75BB",
37
+ focusActionIconColor: "#1B75BB",
38
+ disabledActionIconColor: "#666666",
39
+ hoverButtonBackgroundColor: "#cccccc",
40
+ },
41
+ };
42
+
43
+ const actions = [
44
+ {
45
+ title: "icon",
46
+ onClick: (value?) => {
47
+ console.log(value);
48
+ },
49
+ options: [
50
+ {
51
+ value: "1",
52
+ label: "Amazon with a very long text",
53
+ },
54
+ {
55
+ value: "2",
56
+ label: "Ebay",
57
+ },
58
+ {
59
+ value: "3",
60
+ label: "Apple",
61
+ },
62
+ ],
63
+ },
64
+ {
65
+ icon: "filled_edit",
66
+ title: "icon",
67
+ onClick: () => {},
68
+ },
69
+ {
70
+ icon: deleteIcon,
71
+ title: "icon",
72
+ onClick: () => {},
73
+ disabled: true,
74
+ },
75
+ {
76
+ icon: deleteIcon,
77
+ title: "icon",
78
+ onClick: () => {},
79
+ },
80
+ ];
81
+
32
82
  const rowsIcon = [
33
83
  [
34
84
  { displayValue: "001", sortValue: "001" },
35
85
  { displayValue: "Peter" },
36
- { displayValue: <DxcButton icon={deleteIcon} /> },
86
+ {
87
+ displayValue: <DxcResultsetTable.ActionsCell actions={actions} />,
88
+ },
89
+ ],
90
+ [
91
+ { displayValue: "002", sortValue: "002" },
92
+ { displayValue: "Louis" },
93
+ {
94
+ displayValue: <DxcResultsetTable.ActionsCell actions={actions} />,
95
+ },
37
96
  ],
38
- [{ displayValue: "002", sortValue: "002" }, { displayValue: "Louis" }, { displayValue: "" }],
39
97
  [
40
98
  { displayValue: "003", sortValue: "003" },
41
99
  { displayValue: "Mark" },
42
- { displayValue: <DxcButton icon={deleteIcon} /> },
100
+ {
101
+ displayValue: <DxcResultsetTable.ActionsCell actions={actions} />,
102
+ },
43
103
  ],
44
104
  ];
45
105
 
@@ -200,12 +260,35 @@ export const Chromatic = () => (
200
260
  <Title title="Scroll resultset table" theme="light" level={4} />
201
261
  <DxcResultsetTable columns={longColumns} rows={longRows} />
202
262
  </ExampleContainer>
263
+ <ExampleContainer>
264
+ <Title title="Without paginator" theme="light" level={4} />
265
+ <DxcResultsetTable columns={columns} rows={rows} hidePaginator />
266
+ </ExampleContainer>
203
267
  <ExampleContainer>
204
268
  <SmallContainer>
205
269
  <Title title="Small container and text overflow" theme="light" level={4} />
206
270
  <DxcResultsetTable columns={columnsSortable} rows={longValues} />
207
271
  </SmallContainer>
208
272
  </ExampleContainer>
273
+ <ExampleContainer>
274
+ <Title title="Reduced sortable table" theme="light" level={4} />
275
+ <DxcResultsetTable columns={columnsSortable} rows={rowsSortable} mode="reduced" />
276
+ </ExampleContainer>
277
+ {/* PENDING SMALL ICON VERSION */}
278
+ <ExampleContainer>
279
+ <Title title="Reduced with items per page option" theme="light" level={4} />
280
+ <DxcResultsetTable columns={columns} rows={rows} itemsPerPage={2} itemsPerPageOptions={[2, 3]} mode="reduced" />
281
+ </ExampleContainer>
282
+ <ExampleContainer>
283
+ <Title title="Reduced scroll resultset table" theme="light" level={4} />
284
+ <DxcResultsetTable columns={longColumns} rows={longRows} mode="reduced" />
285
+ </ExampleContainer>
286
+ <ExampleContainer>
287
+ <SmallContainer>
288
+ <Title title="Reduced small container and text overflow" theme="light" level={4} />
289
+ <DxcResultsetTable columns={columnsSortable} rows={longValues} mode="reduced" />
290
+ </SmallContainer>
291
+ </ExampleContainer>
209
292
  <Title title="Margins" theme="light" level={2} />
210
293
  <ExampleContainer>
211
294
  <Title title="Xxsmall" theme="light" level={4} />
@@ -298,3 +381,21 @@ LastPage.play = async ({ canvasElement }) => {
298
381
  const nextButton = canvas.getAllByRole("button")[3];
299
382
  await userEvent.click(nextButton);
300
383
  };
384
+
385
+ const ResultsetActionsCellDropdown = () => (
386
+ <ExampleContainer>
387
+ <Title title="Dropdown Action" theme="light" level={4} />
388
+ <DxcResultsetTable columns={columns} rows={rowsIcon} itemsPerPage={2} />
389
+ <Title title="Custom theme actions cell" theme="light" level={4} />
390
+ <HalstackProvider advancedTheme={advancedTheme}>
391
+ <DxcResultsetTable columns={columns} rows={rowsIcon} itemsPerPage={2} />
392
+ </HalstackProvider>
393
+ </ExampleContainer>
394
+ );
395
+
396
+ export const DropdownAction = ResultsetActionsCellDropdown.bind({});
397
+ DropdownAction.play = async ({ canvasElement }) => {
398
+ const canvas = within(canvasElement);
399
+ const dropdown = canvas.getAllByRole("button")[5];
400
+ await userEvent.click(dropdown);
401
+ };
@@ -39,6 +39,18 @@ global.ResizeObserver = /*#__PURE__*/function () {
39
39
  }]);
40
40
  return ResizeObserver;
41
41
  }();
42
+ var icon = /*#__PURE__*/_react["default"].createElement("svg", {
43
+ xmlns: "http://www.w3.org/2000/svg",
44
+ height: "24px",
45
+ viewBox: "0 0 24 24",
46
+ width: "24px",
47
+ fill: "currentColor"
48
+ }, /*#__PURE__*/_react["default"].createElement("path", {
49
+ d: "M0 0h24v24H0V0zm0 0h24v24H0V0z",
50
+ fill: "none"
51
+ }), /*#__PURE__*/_react["default"].createElement("path", {
52
+ d: "M1 9l2 2c4.97-4.97 13.03-4.97 18 0l2-2C16.93 2.93 7.08 2.93 1 9zm8 8l3 3 3-3c-1.65-1.66-4.34-1.66-6 0zm-4-4l2 2c2.76-2.76 7.24-2.76 10 0l2-2C15.14 9.14 8.87 9.14 5 13z"
53
+ }));
42
54
  var columns = [{
43
55
  displayValue: "Id",
44
56
  isSortable: false
@@ -302,4 +314,68 @@ describe("Resultset table component tests", function () {
302
314
  _react2.fireEvent.click(lastButton);
303
315
  expect(getAllByRole("row").length - 1).toEqual(1);
304
316
  });
317
+ test("Resultset table may not use the paginator", function () {
318
+ var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
319
+ columns: columns,
320
+ rows: rows,
321
+ hidePaginator: true
322
+ })),
323
+ getAllByRole = _render8.getAllByRole;
324
+ var nextButton = getAllByRole("button")[3];
325
+ expect(nextButton).not.toBeTruthy();
326
+ });
327
+ test("Resultset table with ActionsCell", function () {
328
+ var onSelectOption = jest.fn();
329
+ var onClick = jest.fn();
330
+ var actions = [{
331
+ icon: icon,
332
+ title: "icon1",
333
+ onClick: onSelectOption,
334
+ options: [{
335
+ value: "1",
336
+ label: "Amazon"
337
+ }, {
338
+ value: "2",
339
+ label: "Ebay"
340
+ }, {
341
+ value: "3",
342
+ label: "Aliexpress"
343
+ }]
344
+ }, {
345
+ icon: icon,
346
+ title: "icon2",
347
+ onClick: onClick
348
+ }];
349
+ var actionRows = [[{
350
+ displayValue: "001",
351
+ sortValue: "001"
352
+ }, {
353
+ displayValue: "Peter",
354
+ sortValue: "Peter"
355
+ }, {
356
+ displayValue: /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"].ActionsCell, {
357
+ actions: actions
358
+ }),
359
+ sortValue: "Actions"
360
+ }]];
361
+ var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_ResultsetTable["default"], {
362
+ columns: columns,
363
+ rows: actionRows,
364
+ itemsPerPage: 3
365
+ })),
366
+ getAllByRole = _render9.getAllByRole,
367
+ getByRole = _render9.getByRole,
368
+ getByText = _render9.getByText;
369
+ var dropdown = getAllByRole("button")[2];
370
+ (0, _react2.act)(function () {
371
+ _userEvent["default"].click(dropdown);
372
+ });
373
+ expect(getByRole("menu")).toBeTruthy();
374
+ var option = getByText("Aliexpress");
375
+ _userEvent["default"].click(option);
376
+ expect(onSelectOption).toHaveBeenCalledWith("3");
377
+ var action = getAllByRole("button")[1];
378
+ _userEvent["default"].click(action);
379
+ expect(onClick).toHaveBeenCalled();
380
+ });
305
381
  });
@@ -16,7 +16,7 @@ export type Column = {
16
16
  */
17
17
  isSortable?: boolean;
18
18
  };
19
- type Row = {
19
+ export type Row = {
20
20
  /**
21
21
  * Value to be displayed in the cell.
22
22
  */
@@ -27,7 +27,7 @@ type Row = {
27
27
  */
28
28
  sortValue?: string;
29
29
  };
30
- type Props = {
30
+ type CommonProps = {
31
31
  /**
32
32
  * An array of objects representing the columns of the table.
33
33
  */
@@ -37,6 +37,24 @@ type Props = {
37
37
  * as many objects as columns in the table.
38
38
  */
39
39
  rows: Row[][];
40
+ /**
41
+ * Size of the margin to be applied to the component. You can pass an object with 'top',
42
+ * 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
43
+ */
44
+ margin?: Space | Margin;
45
+ /**
46
+ * Value of the tabindex attribute applied to the sortable icon.
47
+ */
48
+ tabIndex?: number;
49
+ /**
50
+ * Determines the visual style and layout
51
+ * - "default": The default mode with big spacing
52
+ * - "reduced": A reduced mode with minimal spacing for dense tables
53
+ */
54
+ mode?: "default" | "reduced";
55
+ };
56
+ type PaginatedProps = CommonProps & {
57
+ hidePaginator?: false;
40
58
  /**
41
59
  * If true, a select component for navigation between pages will be displayed.
42
60
  */
@@ -54,14 +72,29 @@ type Props = {
54
72
  * option. The value selected will be passed as a parameter.
55
73
  */
56
74
  itemsPerPageFunction?: (value: number) => void;
75
+ };
76
+ type NonPaginatedProps = CommonProps & {
57
77
  /**
58
- * Size of the margin to be applied to the component. You can pass an object with 'top',
59
- * 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
78
+ * If true, paginator will not be displayed.
60
79
  */
61
- margin?: Space | Margin;
80
+ hidePaginator: true;
62
81
  /**
63
- * Value of the tabindex attribute applied to the sortable icon.
82
+ * If true, a select component for navigation between pages will be displayed.
64
83
  */
65
- tabIndex?: number;
84
+ showGoToPage?: never;
85
+ /**
86
+ * Number of items per page.
87
+ */
88
+ itemsPerPage?: never;
89
+ /**
90
+ * An array of numbers representing the items per page options.
91
+ */
92
+ itemsPerPageOptions?: never;
93
+ /**
94
+ * This function will be called when the user selects an item per page
95
+ * option. The value selected will be passed as a parameter.
96
+ */
97
+ itemsPerPageFunction?: never;
66
98
  };
99
+ type Props = PaginatedProps | NonPaginatedProps;
67
100
  export default Props;
package/select/Option.js CHANGED
@@ -21,6 +21,11 @@ var Option = function Option(_ref) {
21
21
  isGroupedOption = _ref$isGroupedOption === void 0 ? false : _ref$isGroupedOption,
22
22
  isLastOption = _ref.isLastOption,
23
23
  isSelected = _ref.isSelected;
24
+ var handleOnMouseEnter = function handleOnMouseEnter(event) {
25
+ var label = event.currentTarget;
26
+ var optionElement = document.getElementById(id);
27
+ if (optionElement.title === "" && label.scrollWidth > label.clientWidth) optionElement.title = option.label;
28
+ };
24
29
  return /*#__PURE__*/_react["default"].createElement(OptionItem, {
25
30
  id: id,
26
31
  onClick: function onClick() {
@@ -49,7 +54,9 @@ var Option = function Option(_ref) {
49
54
  grouped: isGroupedOption,
50
55
  hasIcon: option.icon ? true : false,
51
56
  multiple: multiple
52
- }, /*#__PURE__*/_react["default"].createElement(OptionLabel, null, option.label), !multiple && isSelected && /*#__PURE__*/_react["default"].createElement(OptionSelectedIndicator, null, _Icons["default"].selected))));
57
+ }, /*#__PURE__*/_react["default"].createElement(OptionLabel, {
58
+ onMouseEnter: handleOnMouseEnter
59
+ }, option.label), !multiple && isSelected && /*#__PURE__*/_react["default"].createElement(OptionSelectedIndicator, null, _Icons["default"].selected))));
53
60
  };
54
61
  var OptionItem = _styledComponents["default"].li(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n padding: 0 0.5rem;\n box-shadow: inset 0 0 0 2px transparent;\n ", "\n ", ";\n line-height: 1.715em;\n cursor: pointer;\n\n &:hover {\n ", ";\n }\n &:active {\n ", ";\n }\n"])), function (props) {
55
62
  return props.visualFocused && "box-shadow: inset 0 0 0 2px ".concat(props.theme.focusListOptionBorderColor, ";");
@@ -0,0 +1,217 @@
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 _jestAxe = require("jest-axe");
11
+ var _Select = _interopRequireDefault(require("./Select.tsx"));
12
+ var _Flex = _interopRequireDefault(require("../flex/Flex.tsx"));
13
+ var iconSVG = /*#__PURE__*/_react["default"].createElement("svg", {
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ height: "24px",
16
+ viewBox: "0 0 24 24",
17
+ width: "24px",
18
+ fill: "currentColor"
19
+ }, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
20
+ d: "M0,0h24v24H0V0z",
21
+ fill: "none"
22
+ })), /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("g", null, /*#__PURE__*/_react["default"].createElement("path", {
23
+ d: "M3,7v2h5v2H4v2h4v2H3v2h5c1.1,0,2-0.9,2-2v-1.5c0-0.83-0.67-1.5-1.5-1.5c0.83,0,1.5-0.67,1.5-1.5V9c0-1.1-0.9-2-2-2H3z M21,11v4c0,1.1-0.9,2-2,2h-5c-1.1,0-2-0.9-2-2V9c0-1.1,0.9-2,2-2h5c1.1,0,2,0.9,2,2h-7v6h5v-2h-2.5v-2H21z"
24
+ }))));
25
+ var group_options = [{
26
+ label: "Group 001",
27
+ options: [{
28
+ label: "Option 001",
29
+ value: "1"
30
+ }, {
31
+ label: "Option 002",
32
+ value: "2"
33
+ }, {
34
+ label: "Option 003",
35
+ value: "3"
36
+ }]
37
+ }, {
38
+ label: "Group 002",
39
+ options: [{
40
+ label: "Option 004",
41
+ value: "4"
42
+ }, {
43
+ label: "Option 005",
44
+ value: "5"
45
+ }, {
46
+ label: "Option 006",
47
+ value: "6"
48
+ }]
49
+ }, {
50
+ label: "Group 003",
51
+ options: [{
52
+ label: "Option 007",
53
+ value: "7"
54
+ }, {
55
+ label: "Option 008",
56
+ value: "8"
57
+ }, {
58
+ label: "Option 009",
59
+ value: "9"
60
+ }]
61
+ }, {
62
+ label: "Group 004",
63
+ options: [{
64
+ label: "Option 010",
65
+ value: "10"
66
+ }, {
67
+ label: "Option 011",
68
+ value: "11"
69
+ }, {
70
+ label: "Option 012",
71
+ value: "12"
72
+ }]
73
+ }, {
74
+ label: "Group 005",
75
+ options: [{
76
+ label: "Option 013",
77
+ value: "13"
78
+ }, {
79
+ label: "Option 014",
80
+ value: "14"
81
+ }, {
82
+ label: "Option 015",
83
+ value: "15"
84
+ }]
85
+ }];
86
+ var single_options = [{
87
+ label: "Option 01",
88
+ value: "1",
89
+ icon: iconSVG
90
+ }, {
91
+ label: "Option 02",
92
+ value: "2",
93
+ icon: iconSVG
94
+ }, {
95
+ label: "Option 03",
96
+ value: "3",
97
+ icon: iconSVG
98
+ }, {
99
+ label: "Option 04",
100
+ value: "4",
101
+ icon: iconSVG
102
+ }];
103
+
104
+ // Mocking DOMRect for Radix Primitive Popover
105
+ global.globalThis = global;
106
+ global.DOMRect = {
107
+ fromRect: function fromRect() {
108
+ return {
109
+ top: 0,
110
+ left: 0,
111
+ bottom: 0,
112
+ right: 0,
113
+ width: 0,
114
+ height: 0
115
+ };
116
+ }
117
+ };
118
+ global.ResizeObserver = /*#__PURE__*/function () {
119
+ function ResizeObserver() {
120
+ (0, _classCallCheck2["default"])(this, ResizeObserver);
121
+ }
122
+ (0, _createClass2["default"])(ResizeObserver, [{
123
+ key: "observe",
124
+ value: function observe() {}
125
+ }, {
126
+ key: "unobserve",
127
+ value: function unobserve() {}
128
+ }, {
129
+ key: "disconnect",
130
+ value: function disconnect() {}
131
+ }]);
132
+ return ResizeObserver;
133
+ }();
134
+ describe("Select component accessibility tests", function () {
135
+ it("Should not have basic accessibility issues", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
136
+ var _render, baseElement, results;
137
+ return _regenerator["default"].wrap(function _callee$(_context) {
138
+ while (1) switch (_context.prev = _context.next) {
139
+ case 0:
140
+ // baseElement is needed when using React Portals
141
+ _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
142
+ label: "test-select-label",
143
+ helperText: "test-select-helper-text",
144
+ placeholder: "Example text",
145
+ options: single_options,
146
+ defaultValue: 1,
147
+ margin: "medium",
148
+ name: "Name",
149
+ size: "medium",
150
+ searchable: true
151
+ }), /*#__PURE__*/_react["default"].createElement(_Select["default"], {
152
+ label: "test-select-label",
153
+ helperText: "test-select-helper-text",
154
+ placeholder: "Example text",
155
+ options: single_options,
156
+ defaultValue: ["4", "2", "6"],
157
+ margin: "medium",
158
+ name: "Name",
159
+ size: "medium",
160
+ searchable: true,
161
+ multiple: true,
162
+ optional: true
163
+ }))), baseElement = _render.baseElement;
164
+ _context.next = 3;
165
+ return (0, _jestAxe.axe)(baseElement);
166
+ case 3:
167
+ results = _context.sent;
168
+ expect(results).toHaveNoViolations();
169
+ case 5:
170
+ case "end":
171
+ return _context.stop();
172
+ }
173
+ }, _callee);
174
+ })));
175
+ it("Should not have basic accessibility issues for group mode", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
176
+ var _render2, baseElement, results;
177
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
178
+ while (1) switch (_context2.prev = _context2.next) {
179
+ case 0:
180
+ // baseElement is needed when using React Portals
181
+ _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Flex["default"], null, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
182
+ label: "test-select-label",
183
+ helperText: "test-select-helper-text",
184
+ placeholder: "Example text",
185
+ options: group_options,
186
+ defaultValue: ["4", "2", "6"],
187
+ error: "Error",
188
+ margin: "medium",
189
+ name: "Name",
190
+ size: "medium",
191
+ searchable: true,
192
+ multiple: true
193
+ }), /*#__PURE__*/_react["default"].createElement(_Select["default"], {
194
+ label: "test-select-label",
195
+ helperText: "test-select-helper-text",
196
+ placeholder: "Example text",
197
+ options: group_options,
198
+ defaultValue: ["4", "2", "6"],
199
+ margin: "medium",
200
+ name: "Name",
201
+ size: "medium",
202
+ searchable: true,
203
+ multiple: true,
204
+ disabled: true
205
+ }))), baseElement = _render2.baseElement;
206
+ _context2.next = 3;
207
+ return (0, _jestAxe.axe)(baseElement);
208
+ case 3:
209
+ results = _context2.sent;
210
+ expect(results).toHaveNoViolations();
211
+ case 5:
212
+ case "end":
213
+ return _context2.stop();
214
+ }
215
+ }, _callee2);
216
+ })));
217
+ });