@atlaskit/table 0.1.0 → 0.1.2
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/CHANGELOG.md +12 -0
- package/constellation/index/examples.mdx +1 -1
- package/constellation/index/props.mdx +6 -21
- package/dist/cjs/body.js +18 -25
- package/dist/cjs/hooks/selection-provider.js +2 -11
- package/dist/cjs/hooks/use-selectable.js +15 -26
- package/dist/cjs/hooks/use-sorting.js +10 -1
- package/dist/cjs/hooks/use-table.js +4 -1
- package/dist/cjs/row.js +14 -12
- package/dist/cjs/selectable-cell.js +8 -5
- package/dist/cjs/sortable-column.js +15 -39
- package/dist/cjs/table.js +15 -8
- package/dist/cjs/thead.js +6 -5
- package/dist/cjs/ui/base-cell.js +5 -1
- package/dist/cjs/ui/index.js +9 -1
- package/dist/cjs/ui/sort-icon.js +56 -0
- package/dist/cjs/ui/th.js +3 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/body.js +14 -25
- package/dist/es2019/hooks/selection-provider.js +2 -9
- package/dist/es2019/hooks/use-selectable.js +2 -8
- package/dist/es2019/hooks/use-sorting.js +10 -1
- package/dist/es2019/hooks/use-table.js +2 -1
- package/dist/es2019/row.js +16 -12
- package/dist/es2019/selectable-cell.js +7 -5
- package/dist/es2019/sortable-column.js +8 -31
- package/dist/es2019/table.js +11 -7
- package/dist/es2019/thead.js +5 -3
- package/dist/es2019/ui/base-cell.js +5 -1
- package/dist/es2019/ui/index.js +2 -1
- package/dist/es2019/ui/sort-icon.js +42 -0
- package/dist/es2019/ui/th.js +3 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/body.js +18 -27
- package/dist/esm/hooks/selection-provider.js +2 -9
- package/dist/esm/hooks/use-selectable.js +13 -25
- package/dist/esm/hooks/use-sorting.js +10 -1
- package/dist/esm/hooks/use-table.js +4 -1
- package/dist/esm/row.js +14 -12
- package/dist/esm/selectable-cell.js +9 -6
- package/dist/esm/sortable-column.js +10 -33
- package/dist/esm/table.js +11 -5
- package/dist/esm/thead.js +5 -4
- package/dist/esm/ui/base-cell.js +5 -1
- package/dist/esm/ui/index.js +2 -1
- package/dist/esm/ui/sort-icon.js +41 -0
- package/dist/esm/ui/th.js +3 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/body.d.ts +1 -1
- package/dist/types/hooks/selection-provider.d.ts +11 -14
- package/dist/types/hooks/use-selectable.d.ts +31 -7
- package/dist/types/hooks/use-sorting.d.ts +1 -0
- package/dist/types/hooks/use-table.d.ts +1 -0
- package/dist/types/row.d.ts +4 -0
- package/dist/types/sortable-column.d.ts +4 -0
- package/dist/types/table.d.ts +4 -0
- package/dist/types/ui/base-cell.d.ts +44 -0
- package/dist/types/ui/index.d.ts +1 -0
- package/dist/types/ui/sort-icon.d.ts +10 -0
- package/dist/types/ui/table.d.ts +5 -1
- package/dist/types/ui/tr.d.ts +10 -0
- package/extract-react-types/cell.tsx +3 -0
- package/extract-react-types/row.tsx +8 -0
- package/extract-react-types/table.tsx +8 -0
- package/package.json +6 -4
- package/report.api.md +1 -1
- package/tmp/api-report-tmp.d.ts +1 -1
package/dist/esm/row.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo } from 'react';
|
|
4
|
+
import { memo, useMemo } from 'react';
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import { useSelection } from './hooks/selection-provider';
|
|
7
7
|
import { useRowId } from './hooks/use-row-id';
|
|
@@ -23,24 +23,26 @@ var Row = /*#__PURE__*/memo(function (_ref) {
|
|
|
23
23
|
// To ensure valid nesting
|
|
24
24
|
useTableBody(); // to access table state
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _useTable = useTable(),
|
|
27
|
+
isSelectable = _useTable.isSelectable;
|
|
27
28
|
|
|
28
29
|
var _useSelection = useSelection(),
|
|
29
30
|
_useSelection2 = _slicedToArray(_useSelection, 1),
|
|
30
|
-
|
|
31
|
+
_useSelection2$ = _useSelection2[0],
|
|
32
|
+
allChecked = _useSelection2$.allChecked,
|
|
33
|
+
checked = _useSelection2$.checked;
|
|
31
34
|
|
|
32
35
|
var rowId = useRowId();
|
|
36
|
+
var isSelected = useMemo(function () {
|
|
37
|
+
if (!isSelectable) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
testId: testId
|
|
37
|
-
}, children);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var isChecked = selectionState.allChecked || selectionState.checked.includes(rowId);
|
|
41
|
+
return allChecked || checked.includes(rowId);
|
|
42
|
+
}, [allChecked, checked, isSelectable, rowId]);
|
|
41
43
|
return jsx(Primitives.TR, {
|
|
42
|
-
isSelected:
|
|
44
|
+
isSelected: isSelected,
|
|
43
45
|
testId: testId
|
|
44
|
-
}, jsx(SelectableCell, null), children);
|
|
46
|
+
}, isSelectable && jsx(SelectableCell, null), children);
|
|
45
47
|
});
|
|
46
48
|
export default Row;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useCallback } from 'react';
|
|
4
|
+
import { memo, useCallback, useMemo } from 'react';
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import Checkbox from '@atlaskit/checkbox';
|
|
7
7
|
import { useSelection } from './hooks/selection-provider';
|
|
@@ -11,15 +11,18 @@ import * as Primitives from './ui';
|
|
|
11
11
|
var SelectableCell = function SelectableCell() {
|
|
12
12
|
var _useSelection = useSelection(),
|
|
13
13
|
_useSelection2 = _slicedToArray(_useSelection, 2),
|
|
14
|
-
|
|
14
|
+
_useSelection2$ = _useSelection2[0],
|
|
15
|
+
allChecked = _useSelection2$.allChecked,
|
|
16
|
+
checked = _useSelection2$.checked,
|
|
15
17
|
toggleSelection = _useSelection2[1].toggleSelection;
|
|
16
18
|
|
|
17
19
|
var idx = useRowId();
|
|
18
|
-
var isChecked =
|
|
20
|
+
var isChecked = useMemo(function () {
|
|
21
|
+
return allChecked || checked.includes(idx);
|
|
22
|
+
}, [allChecked, checked, idx]);
|
|
19
23
|
var onChange = useCallback(function (e) {
|
|
20
|
-
return toggleSelection(idx, e.nativeEvent.shiftKey);
|
|
21
|
-
},
|
|
22
|
-
[idx]);
|
|
24
|
+
return toggleSelection === null || toggleSelection === void 0 ? void 0 : toggleSelection(idx, e.nativeEvent.shiftKey);
|
|
25
|
+
}, [idx, toggleSelection]);
|
|
23
26
|
return jsx(Primitives.SelectableCell, {
|
|
24
27
|
as: "td"
|
|
25
28
|
}, jsx(Checkbox, {
|
|
@@ -5,13 +5,12 @@ var _excluded = ["name", "testId", "onClick", "children"];
|
|
|
5
5
|
/* eslint-disable no-unused-vars */
|
|
6
6
|
|
|
7
7
|
/** @jsx jsx */
|
|
8
|
+
import { useCallback } from 'react';
|
|
8
9
|
import { css, jsx } from '@emotion/react';
|
|
9
10
|
import Button from '@atlaskit/button';
|
|
10
|
-
import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
|
|
11
|
-
import ArrowUpIcon from '@atlaskit/icon/glyph/arrow-up';
|
|
12
11
|
import Tooltip from '@atlaskit/tooltip';
|
|
13
12
|
import { useTable } from './hooks/use-table';
|
|
14
|
-
import { TH } from './ui';
|
|
13
|
+
import { SortIcon, TH } from './ui';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* TODO these need to be i18n supported
|
|
@@ -64,31 +63,10 @@ var SortableColumn = function SortableColumn(_ref) {
|
|
|
64
63
|
return sortingMessages.unsorted.string;
|
|
65
64
|
};
|
|
66
65
|
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return undefined;
|
|
72
|
-
|
|
73
|
-
case 'ascending':
|
|
74
|
-
return jsx(ArrowUpIcon, {
|
|
75
|
-
size: "small",
|
|
76
|
-
label: "",
|
|
77
|
-
primaryColor: "inherit"
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
case 'descending':
|
|
81
|
-
return jsx(ArrowDownIcon, {
|
|
82
|
-
size: "small",
|
|
83
|
-
label: "",
|
|
84
|
-
primaryColor: "inherit"
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return undefined;
|
|
90
|
-
};
|
|
91
|
-
|
|
66
|
+
var updateSortState = useCallback( // @ts-expect-error: TODO: Our `name` typing is off; refer to `SortKey`
|
|
67
|
+
function () {
|
|
68
|
+
return setSortState(name);
|
|
69
|
+
}, [setSortState, name]);
|
|
92
70
|
return (// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
93
71
|
jsx(TH, _extends({
|
|
94
72
|
testId: testId
|
|
@@ -99,12 +77,11 @@ var SortableColumn = function SortableColumn(_ref) {
|
|
|
99
77
|
return jsx(Button, _extends({
|
|
100
78
|
spacing: "compact",
|
|
101
79
|
appearance: "subtle",
|
|
102
|
-
iconAfter:
|
|
80
|
+
iconAfter: jsx(SortIcon, {
|
|
81
|
+
name: name
|
|
82
|
+
})
|
|
103
83
|
}, tooltipProps, {
|
|
104
|
-
|
|
105
|
-
onClick: function onClick() {
|
|
106
|
-
return setSortState(name);
|
|
107
|
-
},
|
|
84
|
+
onClick: updateSortState,
|
|
108
85
|
css: overrideStyles
|
|
109
86
|
}), children);
|
|
110
87
|
}))
|
package/dist/esm/table.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
import { useMemo } from 'react';
|
|
2
3
|
import { jsx } from '@emotion/react';
|
|
3
4
|
import SelectionProvider from './hooks/selection-provider';
|
|
4
5
|
import { useSorting } from './hooks/use-sorting';
|
|
@@ -22,15 +23,20 @@ function Table(_ref) {
|
|
|
22
23
|
var _useSorting = useSorting(sortKey),
|
|
23
24
|
localSortKey = _useSorting.sortKey,
|
|
24
25
|
sortDirection = _useSorting.sortDirection,
|
|
25
|
-
setSortState = _useSorting.setSortState
|
|
26
|
+
setSortState = _useSorting.setSortState,
|
|
27
|
+
sortFn = _useSorting.sortFn;
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
var tableProviderState = useMemo(function () {
|
|
30
|
+
return {
|
|
29
31
|
isSelectable: isSelectable,
|
|
30
32
|
sortKey: localSortKey,
|
|
31
33
|
sortDirection: sortDirection,
|
|
32
|
-
setSortState: setSortState
|
|
33
|
-
|
|
34
|
+
setSortState: setSortState,
|
|
35
|
+
sortFn: sortFn
|
|
36
|
+
};
|
|
37
|
+
}, [isSelectable, localSortKey, setSortState, sortDirection, sortFn]);
|
|
38
|
+
return jsx(TableProvider, {
|
|
39
|
+
state: tableProviderState
|
|
34
40
|
}, jsx(Primitives.Table, {
|
|
35
41
|
testId: testId
|
|
36
42
|
}, isSelectable ? jsx(SelectionProvider, null, children) : children));
|
package/dist/esm/thead.js
CHANGED
|
@@ -12,7 +12,9 @@ import * as Primitives from './ui';
|
|
|
12
12
|
var THead = function THead(_ref) {
|
|
13
13
|
var actions = _ref.actions,
|
|
14
14
|
children = _ref.children;
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
var _useTable = useTable(),
|
|
17
|
+
isSelectable = _useTable.isSelectable;
|
|
16
18
|
|
|
17
19
|
var _useSelection = useSelection(),
|
|
18
20
|
_useSelection2 = _slicedToArray(_useSelection, 2),
|
|
@@ -21,14 +23,13 @@ var THead = function THead(_ref) {
|
|
|
21
23
|
setAll = _useSelection2$.setAll,
|
|
22
24
|
removeAll = _useSelection2$.removeAll;
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!table.isSelectable) {
|
|
26
|
+
if (!isSelectable) {
|
|
27
27
|
return jsx(Primitives.THead, null, jsx(Primitives.TR, {
|
|
28
28
|
isBodyRow: false
|
|
29
29
|
}, children));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
var isChecked = state.allChecked || state.anyChecked;
|
|
32
33
|
return jsx(Primitives.THead, null, jsx(Primitives.TR, {
|
|
33
34
|
isBodyRow: false
|
|
34
35
|
}, jsx(Primitives.SelectableCell, {
|
package/dist/esm/ui/base-cell.js
CHANGED
|
@@ -40,6 +40,7 @@ export var BaseCell = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
40
40
|
paddingInline = _ref$paddingInline === void 0 ? 'scale.200' : _ref$paddingInline,
|
|
41
41
|
backgroundColor = _ref.backgroundColor,
|
|
42
42
|
scope = _ref.scope,
|
|
43
|
+
width = _ref.width,
|
|
43
44
|
className = _ref.className;
|
|
44
45
|
return jsx(Box, {
|
|
45
46
|
css: baseResetStyles,
|
|
@@ -50,7 +51,10 @@ export var BaseCell = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
50
51
|
paddingInline: paddingInline,
|
|
51
52
|
as: as,
|
|
52
53
|
testId: testId,
|
|
53
|
-
className: className
|
|
54
|
+
className: className,
|
|
55
|
+
UNSAFE_style: width ? {
|
|
56
|
+
width: width
|
|
57
|
+
} : undefined
|
|
54
58
|
}, jsx(Inline, {
|
|
55
59
|
justifyContent: alignMap[align],
|
|
56
60
|
gap: "scale.0"
|
package/dist/esm/ui/index.js
CHANGED
|
@@ -8,4 +8,5 @@ export { TD } from './td';
|
|
|
8
8
|
export { TH } from './th';
|
|
9
9
|
export { SelectableCell } from './selectable-cell';
|
|
10
10
|
export { THead } from './thead';
|
|
11
|
-
export { BulkActionOverlay } from './bulk-action-overlay';
|
|
11
|
+
export { BulkActionOverlay } from './bulk-action-overlay';
|
|
12
|
+
export { SortIcon } from './sort-icon';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
|
+
import ArrowDownIcon from '@atlaskit/icon/glyph/arrow-down';
|
|
7
|
+
import ArrowUpIcon from '@atlaskit/icon/glyph/arrow-up';
|
|
8
|
+
import { useTable } from '../hooks/use-table';
|
|
9
|
+
/**
|
|
10
|
+
* __SortIcon__
|
|
11
|
+
*
|
|
12
|
+
* SortIcon is used to display the sort state in our SortableColumn.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export var SortIcon = /*#__PURE__*/memo(function (_ref) {
|
|
16
|
+
var name = _ref.name;
|
|
17
|
+
|
|
18
|
+
var _useTable = useTable(),
|
|
19
|
+
sortKey = _useTable.sortKey,
|
|
20
|
+
sortDirection = _useTable.sortDirection;
|
|
21
|
+
|
|
22
|
+
if (sortKey === name) {
|
|
23
|
+
switch (sortDirection) {
|
|
24
|
+
case 'ascending':
|
|
25
|
+
return jsx(ArrowUpIcon, {
|
|
26
|
+
size: "small",
|
|
27
|
+
label: "",
|
|
28
|
+
primaryColor: "inherit"
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
case 'descending':
|
|
32
|
+
return jsx(ArrowDownIcon, {
|
|
33
|
+
size: "small",
|
|
34
|
+
label: "",
|
|
35
|
+
primaryColor: "inherit"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
});
|
package/dist/esm/ui/th.js
CHANGED
|
@@ -13,7 +13,8 @@ export var TH = function TH(_ref) {
|
|
|
13
13
|
testId = _ref.testId,
|
|
14
14
|
align = _ref.align,
|
|
15
15
|
scope = _ref.scope,
|
|
16
|
-
backgroundColor = _ref.backgroundColor
|
|
16
|
+
backgroundColor = _ref.backgroundColor,
|
|
17
|
+
width = _ref.width;
|
|
17
18
|
return (
|
|
18
19
|
/*#__PURE__*/
|
|
19
20
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
@@ -22,6 +23,7 @@ export var TH = function TH(_ref) {
|
|
|
22
23
|
testId: testId,
|
|
23
24
|
align: align,
|
|
24
25
|
scope: scope,
|
|
26
|
+
width: width,
|
|
25
27
|
backgroundColor: backgroundColor
|
|
26
28
|
}, children)
|
|
27
29
|
);
|
package/dist/esm/version.json
CHANGED
package/dist/types/body.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
declare type BodyProps<Item extends object> = {
|
|
4
|
+
export declare type BodyProps<Item extends object> = {
|
|
5
5
|
rows: Item[];
|
|
6
6
|
children: (row: Item) => ReactElement;
|
|
7
7
|
} | {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { SelectableActions, SelectableState } from './use-selectable';
|
|
3
|
+
declare type SelectionContext = [
|
|
4
|
+
SelectableState,
|
|
5
|
+
/**
|
|
6
|
+
* Context actions will be undefined without a `SelectionProvider` mounted.
|
|
7
|
+
*/
|
|
8
|
+
SelectableActions | Partial<SelectableActions>
|
|
9
|
+
];
|
|
10
|
+
declare const SelectionContext: React.Context<SelectionContext>;
|
|
2
11
|
/**
|
|
3
12
|
* __Selection provider__
|
|
4
13
|
*
|
|
@@ -9,17 +18,5 @@ import { FC } from 'react';
|
|
|
9
18
|
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
10
19
|
*/
|
|
11
20
|
declare const SelectionProvider: FC;
|
|
12
|
-
export declare const useSelection: () =>
|
|
13
|
-
checked: number[];
|
|
14
|
-
allChecked: boolean;
|
|
15
|
-
anyChecked: boolean;
|
|
16
|
-
maxChecked: number;
|
|
17
|
-
selectionStart: number;
|
|
18
|
-
previousSelection: number[];
|
|
19
|
-
}, {
|
|
20
|
-
readonly setAll: () => void;
|
|
21
|
-
readonly removeAll: () => void;
|
|
22
|
-
readonly toggleSelection: (id: number, shiftHeld: boolean) => void;
|
|
23
|
-
readonly setMax: (max: number) => void;
|
|
24
|
-
}];
|
|
21
|
+
export declare const useSelection: () => SelectionContext;
|
|
25
22
|
export default SelectionProvider;
|
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
declare
|
|
1
|
+
export declare type SelectableState = {
|
|
2
|
+
/**
|
|
3
|
+
* The localised ids that have been checked.
|
|
4
|
+
*/
|
|
2
5
|
checked: number[];
|
|
6
|
+
/**
|
|
7
|
+
* Whether all list items are checked.
|
|
8
|
+
*/
|
|
3
9
|
allChecked: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether any single row item is checked.
|
|
12
|
+
*/
|
|
4
13
|
anyChecked: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Equal to the data length of the table, i.e. the maximum number of checked items.
|
|
16
|
+
*/
|
|
5
17
|
maxChecked: number;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates where a selection begins, i.e. the last selection where the Shift key was **not pressed**
|
|
20
|
+
*/
|
|
6
21
|
selectionStart: number;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates the most recent selection range where the Shift key was pressed.
|
|
24
|
+
* This provides the ability to uncheck ids that are not part of a new selection range, but were in the previous selection range,
|
|
25
|
+
* mimicking behaviour such as that in macOS
|
|
26
|
+
* e.g. [2, 3, 4] indicates ids from 2 to 4 were selected the last time the Shift key was pressed.
|
|
27
|
+
*/
|
|
7
28
|
previousSelection: number[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
29
|
+
};
|
|
30
|
+
export declare type SelectableActions = {
|
|
31
|
+
setAll: () => void;
|
|
32
|
+
removeAll: () => void;
|
|
33
|
+
toggleSelection: (id: number, shiftHeld: boolean) => void;
|
|
34
|
+
setMax: (max: number) => void;
|
|
35
|
+
};
|
|
36
|
+
export declare const defaultSelectableState: SelectableState;
|
|
37
|
+
declare function useSelectable(): [SelectableState, SelectableActions];
|
|
14
38
|
export default useSelectable;
|
|
@@ -3,4 +3,5 @@ export declare const useSorting: <ItemType extends object>(sortKey: SortKey<keyo
|
|
|
3
3
|
sortKey: "unset" | keyof ItemType;
|
|
4
4
|
sortDirection: SortDirection | undefined;
|
|
5
5
|
setSortState: (key: SortKey<keyof ItemType>) => void;
|
|
6
|
+
sortFn: (rowA: ItemType, rowB: ItemType) => number;
|
|
6
7
|
};
|
package/dist/types/row.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
export declare type RowProps = {
|
|
4
|
+
/**
|
|
5
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
6
|
+
* in the rendered code, serving as a hook for automated tests.
|
|
7
|
+
*/
|
|
4
8
|
testId?: string;
|
|
5
9
|
};
|
|
6
10
|
/**
|
|
@@ -5,6 +5,10 @@ export interface CellProps {
|
|
|
5
5
|
* Unique key used for sorting table data by this column
|
|
6
6
|
*/
|
|
7
7
|
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
10
|
+
* in the rendered code, serving as a hook for automated tests.
|
|
11
|
+
*/
|
|
8
12
|
testId?: string;
|
|
9
13
|
onClick?: React.MouseEventHandler;
|
|
10
14
|
}
|
package/dist/types/table.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { ReactElement } from 'react';
|
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { SortKey } from './hooks/use-table';
|
|
5
5
|
export declare type TableProps<ItemType extends object = {}> = {
|
|
6
|
+
/**
|
|
7
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
8
|
+
* in the rendered code, serving as a hook for automated tests.
|
|
9
|
+
*/
|
|
6
10
|
testId?: string;
|
|
7
11
|
/**
|
|
8
12
|
* default sort key to be applied. If unspecified will use default ordering
|
|
@@ -2,10 +2,32 @@
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { BoxProps } from '@atlaskit/ds-explorations/box';
|
|
4
4
|
export declare type BaseCellProps = {
|
|
5
|
+
/**
|
|
6
|
+
* A percentage of pixel width of the table to apply to a column.
|
|
7
|
+
*/
|
|
8
|
+
width?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Horizontal alignment of content.
|
|
11
|
+
*/
|
|
5
12
|
align?: keyof typeof alignMap;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the cell should render as a `td` or `th` element.
|
|
15
|
+
*/
|
|
6
16
|
as?: 'td' | 'th';
|
|
17
|
+
/**
|
|
18
|
+
* Same behavior as the HTML attribute.
|
|
19
|
+
*
|
|
20
|
+
* @see 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope'
|
|
21
|
+
*/
|
|
7
22
|
scope?: 'col' | 'row';
|
|
23
|
+
/**
|
|
24
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
25
|
+
* in the rendered code, serving as a hook for automated tests.
|
|
26
|
+
*/
|
|
8
27
|
testId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Content of the cell.
|
|
30
|
+
*/
|
|
9
31
|
children?: ReactNode;
|
|
10
32
|
} & Pick<BoxProps, 'paddingBlock' | 'paddingInline' | 'backgroundColor' | 'className'>;
|
|
11
33
|
declare const alignMap: {
|
|
@@ -21,10 +43,32 @@ declare const alignMap: {
|
|
|
21
43
|
* Basic cell element.
|
|
22
44
|
*/
|
|
23
45
|
export declare const BaseCell: import("react").ForwardRefExoticComponent<{
|
|
46
|
+
/**
|
|
47
|
+
* A percentage of pixel width of the table to apply to a column.
|
|
48
|
+
*/
|
|
49
|
+
width?: string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Horizontal alignment of content.
|
|
52
|
+
*/
|
|
24
53
|
align?: "number" | "text" | "icon" | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the cell should render as a `td` or `th` element.
|
|
56
|
+
*/
|
|
25
57
|
as?: "td" | "th" | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Same behavior as the HTML attribute.
|
|
60
|
+
*
|
|
61
|
+
* @see 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#attr-scope'
|
|
62
|
+
*/
|
|
26
63
|
scope?: "col" | "row" | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
66
|
+
* in the rendered code, serving as a hook for automated tests.
|
|
67
|
+
*/
|
|
27
68
|
testId?: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Content of the cell.
|
|
71
|
+
*/
|
|
28
72
|
children?: ReactNode;
|
|
29
73
|
} & Pick<BoxProps<"div">, "className" | "backgroundColor" | "paddingBlock" | "paddingInline"> & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
30
74
|
export {};
|
package/dist/types/ui/index.d.ts
CHANGED
package/dist/types/ui/table.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
declare type TableProps = {
|
|
4
|
+
/**
|
|
5
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
6
|
+
* in the rendered code, serving as a hook for automated tests.
|
|
7
|
+
*/
|
|
4
8
|
testId?: string;
|
|
5
9
|
/**
|
|
6
10
|
* Accessible description of the table data.
|
|
7
11
|
*
|
|
8
|
-
* @see https://www.w3.org/WAI/EO/Drafts/tutorials/tables/summary/
|
|
12
|
+
* @see 'https://www.w3.org/WAI/EO/Drafts/tutorials/tables/summary/'
|
|
9
13
|
*/
|
|
10
14
|
summary?: string;
|
|
11
15
|
};
|
package/dist/types/ui/tr.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
interface TRProps {
|
|
4
|
+
/**
|
|
5
|
+
* A `testId` prop is a unique string that appears as a data attribute `data-testid`
|
|
6
|
+
* in the rendered code, serving as a hook for automated tests.
|
|
7
|
+
*/
|
|
4
8
|
testId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* If the row has programatic selection applied.
|
|
11
|
+
*/
|
|
5
12
|
isSelected?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Adjust the behavior of the element depending on whether the row is in the `THead` or in the `TBody`.
|
|
15
|
+
*/
|
|
6
16
|
isBodyRow?: boolean;
|
|
7
17
|
}
|
|
8
18
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/table",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A table is used to display data.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
"website": {
|
|
16
16
|
"name": "Table",
|
|
17
17
|
"category": "Components",
|
|
18
|
-
"
|
|
18
|
+
"status": {
|
|
19
|
+
"type": "alpha"
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
},
|
|
21
23
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
@@ -30,9 +32,9 @@
|
|
|
30
32
|
"./primitives": "./src/ui/index.tsx"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
|
-
"@atlaskit/button": "^16.
|
|
35
|
+
"@atlaskit/button": "^16.5.0",
|
|
34
36
|
"@atlaskit/checkbox": "^12.4.1",
|
|
35
|
-
"@atlaskit/ds-explorations": "^1.
|
|
37
|
+
"@atlaskit/ds-explorations": "^1.6.0",
|
|
36
38
|
"@atlaskit/ds-lib": "^2.1.2",
|
|
37
39
|
"@atlaskit/focus-ring": "^1.2.1",
|
|
38
40
|
"@atlaskit/icon": "^21.11.2",
|
package/report.api.md
CHANGED
|
@@ -30,6 +30,7 @@ const alignMap: {
|
|
|
30
30
|
|
|
31
31
|
// @public (undocumented)
|
|
32
32
|
type BaseCellProps = {
|
|
33
|
+
width?: string;
|
|
33
34
|
align?: keyof typeof alignMap;
|
|
34
35
|
as?: 'td' | 'th';
|
|
35
36
|
scope?: 'col' | 'row';
|
|
@@ -59,7 +60,6 @@ interface CellProps {
|
|
|
59
60
|
name: string;
|
|
60
61
|
// (undocumented)
|
|
61
62
|
onClick?: React.MouseEventHandler;
|
|
62
|
-
// (undocumented)
|
|
63
63
|
testId?: string;
|
|
64
64
|
}
|
|
65
65
|
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ const alignMap: {
|
|
|
19
19
|
|
|
20
20
|
// @public (undocumented)
|
|
21
21
|
type BaseCellProps = {
|
|
22
|
+
width?: string;
|
|
22
23
|
align?: keyof typeof alignMap;
|
|
23
24
|
as?: 'td' | 'th';
|
|
24
25
|
scope?: 'col' | 'row';
|
|
@@ -43,7 +44,6 @@ interface CellProps {
|
|
|
43
44
|
name: string;
|
|
44
45
|
// (undocumented)
|
|
45
46
|
onClick?: React.MouseEventHandler;
|
|
46
|
-
// (undocumented)
|
|
47
47
|
testId?: string;
|
|
48
48
|
}
|
|
49
49
|
|