@atlaskit/table 0.2.1 → 0.2.3

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 (80) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/body.js +16 -35
  3. package/dist/cjs/head-cell.js +5 -11
  4. package/dist/cjs/hooks/selection-provider.js +1 -9
  5. package/dist/cjs/hooks/use-row-id.js +2 -5
  6. package/dist/cjs/hooks/use-selectable.js +13 -29
  7. package/dist/cjs/hooks/use-sorting.js +6 -17
  8. package/dist/cjs/hooks/use-table-body.js +1 -7
  9. package/dist/cjs/hooks/use-table.js +4 -13
  10. package/dist/cjs/index.js +0 -8
  11. package/dist/cjs/row.js +8 -25
  12. package/dist/cjs/selectable-cell.js +9 -21
  13. package/dist/cjs/sortable-column.js +33 -44
  14. package/dist/cjs/table.js +8 -22
  15. package/dist/cjs/thead.js +12 -29
  16. package/dist/cjs/ui/base-cell.js +17 -21
  17. package/dist/cjs/ui/bulk-action-overlay.js +2 -5
  18. package/dist/cjs/ui/index.js +0 -9
  19. package/dist/cjs/ui/selectable-cell.js +4 -7
  20. package/dist/cjs/ui/sort-icon.js +2 -14
  21. package/dist/cjs/ui/table.js +2 -5
  22. package/dist/cjs/ui/tbody.js +2 -5
  23. package/dist/cjs/ui/td.js +3 -10
  24. package/dist/cjs/ui/th.js +8 -11
  25. package/dist/cjs/ui/thead.js +2 -4
  26. package/dist/cjs/ui/tr.js +6 -11
  27. package/dist/cjs/version.json +1 -1
  28. package/dist/es2019/body.js +11 -8
  29. package/dist/es2019/head-cell.js +2 -3
  30. package/dist/es2019/hooks/selection-provider.js +1 -2
  31. package/dist/es2019/hooks/use-row-id.js +2 -2
  32. package/dist/es2019/hooks/use-selectable.js +4 -13
  33. package/dist/es2019/hooks/use-sorting.js +0 -4
  34. package/dist/es2019/hooks/use-table-body.js +1 -1
  35. package/dist/es2019/hooks/use-table.js +3 -4
  36. package/dist/es2019/row.js +2 -4
  37. package/dist/es2019/selectable-cell.js +3 -3
  38. package/dist/es2019/sortable-column.js +24 -26
  39. package/dist/es2019/table.js +0 -2
  40. package/dist/es2019/thead.js +5 -8
  41. package/dist/es2019/ui/base-cell.js +5 -4
  42. package/dist/es2019/ui/bulk-action-overlay.js +2 -1
  43. package/dist/es2019/ui/selectable-cell.js +2 -1
  44. package/dist/es2019/ui/sort-icon.js +1 -5
  45. package/dist/es2019/ui/table.js +1 -1
  46. package/dist/es2019/ui/tbody.js +2 -2
  47. package/dist/es2019/ui/td.js +4 -3
  48. package/dist/es2019/ui/th.js +4 -3
  49. package/dist/es2019/ui/thead.js +2 -1
  50. package/dist/es2019/ui/tr.js +2 -2
  51. package/dist/es2019/version.json +1 -1
  52. package/dist/esm/body.js +16 -21
  53. package/dist/esm/head-cell.js +7 -8
  54. package/dist/esm/hooks/selection-provider.js +1 -2
  55. package/dist/esm/hooks/use-row-id.js +2 -2
  56. package/dist/esm/hooks/use-selectable.js +13 -25
  57. package/dist/esm/hooks/use-sorting.js +6 -12
  58. package/dist/esm/hooks/use-table-body.js +1 -1
  59. package/dist/esm/hooks/use-table.js +4 -5
  60. package/dist/esm/row.js +8 -13
  61. package/dist/esm/selectable-cell.js +8 -10
  62. package/dist/esm/sortable-column.js +33 -36
  63. package/dist/esm/table.js +8 -12
  64. package/dist/esm/thead.js +12 -18
  65. package/dist/esm/ui/base-cell.js +16 -15
  66. package/dist/esm/ui/bulk-action-overlay.js +2 -1
  67. package/dist/esm/ui/selectable-cell.js +4 -3
  68. package/dist/esm/ui/sort-icon.js +3 -8
  69. package/dist/esm/ui/table.js +3 -3
  70. package/dist/esm/ui/tbody.js +2 -2
  71. package/dist/esm/ui/td.js +5 -5
  72. package/dist/esm/ui/th.js +8 -7
  73. package/dist/esm/ui/thead.js +2 -1
  74. package/dist/esm/ui/tr.js +6 -6
  75. package/dist/esm/version.json +1 -1
  76. package/dist/types/ui/base-cell.d.ts +7 -1
  77. package/dist/types/ui/th.d.ts +6 -2
  78. package/package.json +9 -6
  79. package/constellation/index/examples.mdx +0 -19
  80. package/constellation/index/props.mdx +0 -17
package/dist/cjs/ui/th.js CHANGED
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.TH = void 0;
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
-
12
9
  var _baseCell = require("./base-cell");
13
-
14
10
  /**
15
11
  * __Head cell__
16
12
  *
@@ -20,11 +16,12 @@ var _baseCell = require("./base-cell");
20
16
  */
21
17
  var TH = function TH(_ref) {
22
18
  var children = _ref.children,
23
- testId = _ref.testId,
24
- align = _ref.align,
25
- scope = _ref.scope,
26
- backgroundColor = _ref.backgroundColor,
27
- width = _ref.width;
19
+ testId = _ref.testId,
20
+ align = _ref.align,
21
+ scope = _ref.scope,
22
+ backgroundColor = _ref.backgroundColor,
23
+ width = _ref.width,
24
+ sortDirection = _ref.sortDirection;
28
25
  return (
29
26
  /*#__PURE__*/
30
27
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
@@ -34,9 +31,9 @@ var TH = function TH(_ref) {
34
31
  align: align,
35
32
  scope: scope,
36
33
  width: width,
37
- backgroundColor: backgroundColor
34
+ backgroundColor: backgroundColor,
35
+ sortDirection: sortDirection
38
36
  }, children)
39
37
  );
40
38
  };
41
-
42
39
  exports.TH = TH;
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.THead = void 0;
7
-
8
7
  var _react = require("@emotion/react");
9
-
10
8
  /** @jsx jsx */
9
+
11
10
  var baseStyles = (0, _react.css)({
12
11
  position: 'sticky',
13
12
  zIndex: 1,
@@ -17,6 +16,7 @@ var baseStyles = (0, _react.css)({
17
16
  borderTop: '2px solid transparent',
18
17
  inset: 0
19
18
  });
19
+
20
20
  /**
21
21
  * __THead__
22
22
  *
@@ -24,12 +24,10 @@ var baseStyles = (0, _react.css)({
24
24
  *
25
25
  * @primitive
26
26
  */
27
-
28
27
  var THead = function THead(_ref) {
29
28
  var children = _ref.children;
30
29
  return (0, _react.jsx)("thead", {
31
30
  css: baseStyles
32
31
  }, children);
33
32
  };
34
-
35
33
  exports.THead = THead;
package/dist/cjs/ui/tr.js CHANGED
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.TR = void 0;
9
-
10
8
  var _react = require("@emotion/react");
11
-
12
9
  var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
13
-
14
10
  /** @jsx jsx */
11
+
15
12
  var baseStyles = (0, _react.css)({
16
13
  height: 48,
17
14
  position: 'relative',
@@ -23,9 +20,9 @@ var selectedStyles = (0, _react.css)({
23
20
  backgroundColor: "var(--ds-background-selected, #DEEBFF88)",
24
21
  '&:hover': {
25
22
  backgroundColor: "var(--ds-background-selected-hovered, #DEEBFF)" // B50
26
-
27
23
  }
28
24
  });
25
+
29
26
  var bodyRowStyles = (0, _react.css)({
30
27
  borderBottom: "1px solid ".concat("var(--ds-border, #eee)"),
31
28
  '&:hover': {
@@ -35,7 +32,6 @@ var bodyRowStyles = (0, _react.css)({
35
32
  boxShadow: 'none'
36
33
  }
37
34
  });
38
-
39
35
  /**
40
36
  * __Row__
41
37
  *
@@ -45,10 +41,10 @@ var bodyRowStyles = (0, _react.css)({
45
41
  */
46
42
  var TR = function TR(_ref) {
47
43
  var children = _ref.children,
48
- testId = _ref.testId,
49
- isSelected = _ref.isSelected,
50
- _ref$isBodyRow = _ref.isBodyRow,
51
- isBodyRow = _ref$isBodyRow === void 0 ? true : _ref$isBodyRow;
44
+ testId = _ref.testId,
45
+ isSelected = _ref.isSelected,
46
+ _ref$isBodyRow = _ref.isBodyRow,
47
+ isBodyRow = _ref$isBodyRow === void 0 ? true : _ref$isBodyRow;
52
48
  return (0, _react.jsx)(_focusRing.default, {
53
49
  isInset: true
54
50
  }, (0, _react.jsx)("tr", {
@@ -58,5 +54,4 @@ var TR = function TR(_ref) {
58
54
  css: [baseStyles, isBodyRow && bodyRowStyles, isSelected && selectedStyles]
59
55
  }, children));
60
56
  };
61
-
62
57
  exports.TR = TR;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/table",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable @repo/internal/react/no-clone-element */
2
-
3
2
  /** @jsx jsx */
4
3
  import { Children, useEffect, useMemo } from 'react';
5
4
  import { jsx } from '@emotion/react';
@@ -8,7 +7,6 @@ import { RowProvider } from './hooks/use-row-id';
8
7
  import { useTable } from './hooks/use-table';
9
8
  import { TableBodyProvider } from './hooks/use-table-body';
10
9
  import * as Primitives from './ui';
11
-
12
10
  /**
13
11
  * __Table body__
14
12
  */
@@ -22,19 +20,24 @@ function TBody({
22
20
  const [_state, {
23
21
  removeAll,
24
22
  setMax
25
- }] = useSelection(); // TODO: this seems like something the user should control or opt into.
23
+ }] = useSelection();
26
24
 
25
+ // TODO: this seems like something the user should control or opt into.
27
26
  useEffect(() => {
28
- removeAll === null || removeAll === void 0 ? void 0 : removeAll(); // eslint-disable-next-line react-hooks/exhaustive-deps -- When the rows change, we [currently] want to call removeAll.
27
+ removeAll === null || removeAll === void 0 ? void 0 : removeAll();
28
+
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- When the rows change, we [currently] want to call removeAll.
29
30
  }, [rows]);
30
31
  const childrenCount = Children.count(children);
31
- const rowsLength = rows === null || rows === void 0 ? void 0 : rows.length; // Set data length (via setMax) whenever data changes
32
+ const rowsLength = rows === null || rows === void 0 ? void 0 : rows.length;
32
33
 
34
+ // Set data length (via setMax) whenever data changes
33
35
  useEffect(() => {
34
36
  const numRows = rowsLength !== null && rowsLength !== void 0 ? rowsLength : childrenCount;
35
37
  setMax === null || setMax === void 0 ? void 0 : setMax(numRows);
36
38
  }, [rowsLength, childrenCount, setMax]);
37
- const sortedRows = useMemo(() => rows === null || rows === void 0 ? void 0 : rows.map((row, idx) => ({ ...row,
39
+ const sortedRows = useMemo(() => rows === null || rows === void 0 ? void 0 : rows.map((row, idx) => ({
40
+ ...row,
38
41
  idx
39
42
  })).sort(sortFn), [rows, sortFn]);
40
43
  return jsx(TableBodyProvider, {
@@ -45,11 +48,11 @@ function TBody({
45
48
  }) => jsx(RowProvider, {
46
49
  key: idx,
47
50
  value: idx
48
- }, // @ts-expect-error
51
+ },
52
+ // @ts-expect-error
49
53
  children(row))) : Children.map(children, (row, idx) => jsx(RowProvider, {
50
54
  key: idx,
51
55
  value: idx
52
56
  }, row))));
53
57
  }
54
-
55
58
  export default TBody;
@@ -1,15 +1,15 @@
1
1
  /* eslint-disable no-unused-vars */
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { jsx } from '@emotion/react';
5
5
  import { UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
6
6
  import { TH } from './ui/th';
7
+
7
8
  /**
8
9
  * __HeadCell__
9
10
  *
10
11
  * HeadCell element
11
12
  */
12
-
13
13
  const Column = ({
14
14
  children,
15
15
  align,
@@ -27,5 +27,4 @@ const Column = ({
27
27
  fontWeight: "medium"
28
28
  }, children));
29
29
  };
30
-
31
30
  export default Column;
@@ -1,6 +1,7 @@
1
1
  import React, { createContext, useContext } from 'react';
2
2
  import useSelectionReducer, { defaultSelectableState } from './use-selectable';
3
3
  const SelectionContext = /*#__PURE__*/createContext([defaultSelectableState, {}]);
4
+
4
5
  /**
5
6
  * __Selection provider__
6
7
  *
@@ -10,7 +11,6 @@ const SelectionContext = /*#__PURE__*/createContext([defaultSelectableState, {}]
10
11
  * - [Code](https://atlassian.design/components/{packageName}/code)
11
12
  * - [Usage](https://atlassian.design/components/{packageName}/usage)
12
13
  */
13
-
14
14
  const SelectionProvider = ({
15
15
  children
16
16
  }) => {
@@ -19,7 +19,6 @@ const SelectionProvider = ({
19
19
  value: reducer
20
20
  }, children);
21
21
  };
22
-
23
22
  export const useSelection = () => {
24
23
  return useContext(SelectionContext);
25
24
  };
@@ -1,13 +1,13 @@
1
1
  import { createContext, useContext } from 'react';
2
2
  const RowContext = /*#__PURE__*/createContext(undefined);
3
+
3
4
  /**
4
5
  * @internal
5
6
  */
6
-
7
7
  export const useRowId = () => useContext(RowContext);
8
+
8
9
  /**
9
10
  * __Row provider__
10
11
  * @internal
11
12
  */
12
-
13
13
  export const RowProvider = RowContext.Provider;
@@ -7,24 +7,21 @@ export const defaultSelectableState = {
7
7
  selectionStart: -1,
8
8
  previousSelection: []
9
9
  };
10
-
11
10
  const arrayFromRange = (from, to) => {
12
11
  let startIdx = from;
13
12
  let stopIdx = to;
14
13
  let increment = 1;
15
-
16
14
  if (from > to) {
17
15
  startIdx = to;
18
16
  stopIdx = from;
19
17
  increment = 0;
20
- } // Create an array with values between `from` and `to` - either ascending or descending
21
-
18
+ }
22
19
 
20
+ // Create an array with values between `from` and `to` - either ascending or descending
23
21
  return Array.from({
24
22
  length: stopIdx - startIdx
25
23
  }, (_, i) => startIdx + i + increment);
26
24
  };
27
-
28
25
  function reducer({
29
26
  checked,
30
27
  anyChecked,
@@ -44,17 +41,17 @@ function reducer({
44
41
  let updated = checked.slice();
45
42
  let newSelectionStart = selectionStart;
46
43
  let newPreviousSelection = previousSelection.slice();
47
-
48
44
  if (shiftHeld) {
49
45
  if (checked.length > 0) {
50
46
  const newIds = arrayFromRange(selectionStart, id); // create an array of the new ids
47
+
51
48
  // Uncheck ids from the previous selection.
52
49
  // This is done to maintain consistency with Shift-select behaviour elsewhere (e.g. macOS)
53
50
  // TODO: Code could be improved to only remove ids that are not included in the new range, avoiding needing to re-add them below
54
-
55
51
  updated = updated.filter(id => !previousSelection.includes(id));
56
52
  newIds.forEach(id => updated.indexOf(id) === -1 && updated.push(id) // If the new id is not already checked, check it
57
53
  );
54
+
58
55
  newPreviousSelection = newIds; // Maintain an array of the previous selection to allow for consistent Shift-select behaviour
59
56
  }
60
57
  } else {
@@ -67,7 +64,6 @@ function reducer({
67
64
  }
68
65
 
69
66
  newSelectionStart = id; // Reset selection start id to this non-shift-selected id
70
-
71
67
  newPreviousSelection = []; // Reset previous selection as it is no longer relevant once a new non-shift-selected id is added
72
68
  }
73
69
 
@@ -81,7 +77,6 @@ function reducer({
81
77
  previousSelection: newPreviousSelection
82
78
  };
83
79
  }
84
-
85
80
  case 'set_root':
86
81
  return {
87
82
  checked: action.value ? Array.from(Array(maxChecked).keys()) : [],
@@ -91,7 +86,6 @@ function reducer({
91
86
  selectionStart,
92
87
  previousSelection
93
88
  };
94
-
95
89
  case 'set_max':
96
90
  {
97
91
  const {
@@ -106,12 +100,10 @@ function reducer({
106
100
  previousSelection
107
101
  };
108
102
  }
109
-
110
103
  default:
111
104
  throw new Error();
112
105
  }
113
106
  }
114
-
115
107
  function useSelectable() {
116
108
  const [state, dispatch] = useReducer(reducer, defaultSelectableState);
117
109
  const toggleSelection = useCallback((id, shiftHeld) => {
@@ -148,5 +140,4 @@ function useSelectable() {
148
140
  setMax
149
141
  }];
150
142
  }
151
-
152
143
  export default useSelectable;
@@ -7,10 +7,8 @@ export const useSorting = sortKey => {
7
7
  switch (oldLocalSortDirection) {
8
8
  case undefined:
9
9
  return 'ascending';
10
-
11
10
  case 'ascending':
12
11
  return 'descending';
13
-
14
12
  case 'descending':
15
13
  return 'ascending';
16
14
  }
@@ -25,7 +23,6 @@ export const useSorting = sortKey => {
25
23
  } else {
26
24
  toggleSortDirection();
27
25
  }
28
-
29
26
  return localSortKey;
30
27
  });
31
28
  }, [toggleSortDirection]);
@@ -33,7 +30,6 @@ export const useSorting = sortKey => {
33
30
  if (localSortKey === 'unset') {
34
31
  return 0;
35
32
  }
36
-
37
33
  const ascendingComparator = rowA[localSortKey] < rowB[localSortKey] ? -1 : 1;
38
34
  return localSortDirection === 'ascending' ? ascendingComparator : -ascendingComparator;
39
35
  }, [localSortDirection, localSortKey]);
@@ -1,11 +1,11 @@
1
1
  import { createContext, useContext } from 'react';
2
2
  import invariant from 'tiny-invariant';
3
3
  const TableBodyContext = /*#__PURE__*/createContext(false);
4
+
4
5
  /**
5
6
  * __Table body provider__
6
7
  * Ensures correct nesting of table elements.
7
8
  */
8
-
9
9
  export const TableBodyProvider = TableBodyContext.Provider;
10
10
  export const useTableBody = () => {
11
11
  const hasTableBody = useContext(TableBodyContext);
@@ -1,6 +1,5 @@
1
1
  import React, { createContext, useContext } from 'react';
2
2
  import __noop from '@atlaskit/ds-lib/noop';
3
-
4
3
  function generateContext() {
5
4
  return /*#__PURE__*/createContext({
6
5
  isSelectable: false,
@@ -9,8 +8,8 @@ function generateContext() {
9
8
  sortFn: () => 0
10
9
  });
11
10
  }
12
-
13
11
  const TableContext = generateContext();
12
+
14
13
  /**
15
14
  * __Table state provider__
16
15
  *
@@ -18,7 +17,6 @@ const TableContext = generateContext();
18
17
  *
19
18
  * - [Examples](https://atlassian.design/components/table/examples)
20
19
  */
21
-
22
20
  export function TableProvider({
23
21
  children,
24
22
  state
@@ -31,5 +29,6 @@ export function TableProvider({
31
29
  }, children)
32
30
  );
33
31
  }
34
- export const useTable = () => // @ts-expect-error
32
+ export const useTable = () =>
33
+ // @ts-expect-error
35
34
  useContext(TableContext);
@@ -7,7 +7,6 @@ import { useTable } from './hooks/use-table';
7
7
  import { useTableBody } from './hooks/use-table-body';
8
8
  import SelectableCell from './selectable-cell';
9
9
  import * as Primitives from './ui';
10
-
11
10
  /**
12
11
  * __Row__
13
12
  *
@@ -20,8 +19,8 @@ const Row = /*#__PURE__*/memo(({
20
19
  testId
21
20
  }) => {
22
21
  // To ensure valid nesting
23
- useTableBody(); // to access table state
24
-
22
+ useTableBody();
23
+ // to access table state
25
24
  const {
26
25
  isSelectable
27
26
  } = useTable();
@@ -34,7 +33,6 @@ const Row = /*#__PURE__*/memo(({
34
33
  if (!isSelectable) {
35
34
  return undefined;
36
35
  }
37
-
38
36
  return allChecked || checked.includes(rowId);
39
37
  }, [allChecked, checked, isSelectable, rowId]);
40
38
  return jsx(Primitives.TR, {
@@ -2,10 +2,10 @@
2
2
  import { memo, useCallback, useMemo } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  import Checkbox from '@atlaskit/checkbox';
5
+ import VisuallyHidden from '@atlaskit/visually-hidden';
5
6
  import { useSelection } from './hooks/selection-provider';
6
7
  import { useRowId } from './hooks/use-row-id';
7
8
  import * as Primitives from './ui';
8
-
9
9
  const SelectableCell = () => {
10
10
  const [{
11
11
  allChecked,
@@ -20,8 +20,8 @@ const SelectableCell = () => {
20
20
  as: "td"
21
21
  }, jsx(Checkbox, {
22
22
  isChecked: isChecked,
23
- onChange: onChange
23
+ onChange: onChange,
24
+ label: jsx(VisuallyHidden, null, "Select row ", idx + 1)
24
25
  }));
25
26
  };
26
-
27
27
  export default /*#__PURE__*/memo(SelectableCell);
@@ -1,7 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /* eslint-disable no-unused-vars */
4
-
5
3
  /** @jsx jsx */
6
4
  import { useCallback } from 'react';
7
5
  import { css, jsx } from '@emotion/react';
@@ -9,7 +7,6 @@ import Button from '@atlaskit/button';
9
7
  import Tooltip from '@atlaskit/tooltip';
10
8
  import { useTable } from './hooks/use-table';
11
9
  import { SortIcon, TH } from './ui';
12
-
13
10
  /**
14
11
  * TODO these need to be i18n supported
15
12
  */
@@ -34,12 +31,12 @@ const overrideStyles = css({
34
31
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage-spacing
35
32
  paddingInline: `2px !important`
36
33
  });
34
+
37
35
  /**
38
36
  * __SortableColumn__
39
37
  *
40
38
  * SortableColumn is used in place of the default Column when sorting is desired.
41
39
  */
42
-
43
40
  const SortableColumn = ({
44
41
  name,
45
42
  testId,
@@ -52,35 +49,36 @@ const SortableColumn = ({
52
49
  sortDirection,
53
50
  setSortState
54
51
  } = useTable();
55
-
56
52
  const getSortMessage = () => {
57
53
  if (sortKey === name) {
58
54
  // TODO: Change message depending on data type (string/number)
59
55
  return sortingMessages[sortDirection || 'unsorted'].string;
60
56
  }
61
-
62
57
  return sortingMessages.unsorted.string;
63
58
  };
64
-
65
- const updateSortState = useCallback( // @ts-expect-error: TODO: Our `name` typing is off; refer to `SortKey`
59
+ const updateSortState = useCallback(
60
+ // @ts-expect-error: TODO: Our `name` typing is off; refer to `SortKey`
66
61
  () => setSortState(name), [setSortState, name]);
67
- return (// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
68
- jsx(TH, _extends({
69
- testId: testId
70
- }, other), jsx(Tooltip, {
71
- content: getSortMessage(),
72
- position: "top"
73
- }, tooltipProps => jsx(Button, _extends({
74
- spacing: "compact",
75
- appearance: "subtle",
76
- iconAfter: jsx(SortIcon, {
77
- name: name
78
- })
79
- }, tooltipProps, {
80
- onClick: updateSortState,
81
- css: overrideStyles
82
- }), children)))
83
- );
62
+ return jsx(TH, _extends({
63
+ testId: testId,
64
+ sortDirection: sortKey === name ? sortDirection : 'none'
65
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
66
+ }, other), jsx(Tooltip, {
67
+ content: getSortMessage(),
68
+ position: "top"
69
+ }, tooltipProps => jsx(Button, _extends({
70
+ testId: `${testId}--button`,
71
+ spacing: "compact",
72
+ appearance: "subtle",
73
+ iconAfter: jsx(SortIcon, {
74
+ name: name
75
+ })
76
+ }, tooltipProps, {
77
+ onClick: updateSortState,
78
+ css: overrideStyles
79
+ // TODO: i18n support for this attr
80
+ ,
81
+ "aria-roledescription": "Column sort button"
82
+ }), children)));
84
83
  };
85
-
86
84
  export default SortableColumn;
@@ -5,7 +5,6 @@ import SelectionProvider from './hooks/selection-provider';
5
5
  import { useSorting } from './hooks/use-sorting';
6
6
  import { TableProvider } from './hooks/use-table';
7
7
  import * as Primitives from './ui';
8
-
9
8
  /**
10
9
  * __Table__
11
10
  *
@@ -38,5 +37,4 @@ function Table({
38
37
  testId: testId
39
38
  }, isSelectable ? jsx(SelectionProvider, null, children) : children));
40
39
  }
41
-
42
40
  export default Table;
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { jsx } from '@emotion/react';
3
4
  import Checkbox from '@atlaskit/checkbox';
4
5
  import { UNSAFE_Inline as Inline, UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
@@ -6,7 +7,6 @@ import VisuallyHidden from '@atlaskit/visually-hidden';
6
7
  import { useSelection } from './hooks/selection-provider';
7
8
  import { useTable } from './hooks/use-table';
8
9
  import * as Primitives from './ui';
9
-
10
10
  const THead = ({
11
11
  actions,
12
12
  children
@@ -18,31 +18,28 @@ const THead = ({
18
18
  setAll,
19
19
  removeAll
20
20
  }] = useSelection();
21
-
22
21
  if (!isSelectable) {
23
22
  return jsx(Primitives.THead, null, jsx(Primitives.TR, {
24
23
  isBodyRow: false
25
24
  }, children));
26
25
  }
27
-
28
26
  const isChecked = state.allChecked || state.anyChecked;
29
27
  return jsx(Primitives.THead, null, jsx(Primitives.TR, {
30
28
  isBodyRow: false
31
29
  }, jsx(Primitives.SelectableCell, {
32
30
  as: "th"
33
31
  }, jsx(Checkbox, {
34
- "aria-labelledby": "select-all",
32
+ label: jsx(VisuallyHidden, {
33
+ id: "select-all"
34
+ }, "Select all rows"),
35
35
  onChange: isChecked ? removeAll : setAll,
36
36
  isChecked: isChecked,
37
37
  isIndeterminate: state.anyChecked && !state.allChecked
38
- }), jsx(VisuallyHidden, {
39
- id: "select-all"
40
- }, "Select all rows")), children, isChecked && jsx(Primitives.BulkActionOverlay, null, jsx(Text, {
38
+ })), children, isChecked && jsx(Primitives.BulkActionOverlay, null, jsx(Text, {
41
39
  color: "color.text",
42
40
  fontWeight: "medium"
43
41
  }, state.checked.length, " selected"), actions && jsx(Inline, {
44
42
  gap: "space.100"
45
43
  }, actions(state.checked)))));
46
44
  };
47
-
48
45
  export default THead;
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable @atlassian/tangerine/import/entry-points */
2
-
3
2
  /** @jsx jsx */
4
3
  import { forwardRef } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -20,6 +19,7 @@ const baseResetStyles = css({
20
19
  paddingRight: "var(--ds-space-100, 8px)"
21
20
  }
22
21
  });
22
+
23
23
  /**
24
24
  * __BaseCell__
25
25
  *
@@ -27,7 +27,6 @@ const baseResetStyles = css({
27
27
  *
28
28
  * Basic cell element.
29
29
  */
30
-
31
30
  export const BaseCell = /*#__PURE__*/forwardRef(({
32
31
  testId,
33
32
  as,
@@ -38,7 +37,8 @@ export const BaseCell = /*#__PURE__*/forwardRef(({
38
37
  backgroundColor,
39
38
  scope,
40
39
  width,
41
- className
40
+ className,
41
+ sortDirection
42
42
  }, ref) => jsx(Box, {
43
43
  css: baseResetStyles,
44
44
  ref: ref,
@@ -51,7 +51,8 @@ export const BaseCell = /*#__PURE__*/forwardRef(({
51
51
  className: className,
52
52
  UNSAFE_style: width ? {
53
53
  width
54
- } : undefined
54
+ } : undefined,
55
+ "aria-sort": sortDirection
55
56
  }, jsx(Inline, {
56
57
  justifyContent: alignMap[align],
57
58
  gap: "space.0"