@atlaskit/table 0.1.0
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 +7 -0
- package/LICENSE.md +13 -0
- package/README.md +83 -0
- package/constellation/index/examples.mdx +19 -0
- package/constellation/index/props.mdx +32 -0
- package/dist/cjs/body.js +105 -0
- package/dist/cjs/head-cell.js +42 -0
- package/dist/cjs/hooks/selection-provider.js +52 -0
- package/dist/cjs/hooks/use-row-id.js +26 -0
- package/dist/cjs/hooks/use-selectable.js +183 -0
- package/dist/cjs/hooks/use-sorting.js +59 -0
- package/dist/cjs/hooks/use-table-body.js +28 -0
- package/dist/cjs/hooks/use-table.js +56 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/row.js +70 -0
- package/dist/cjs/selectable-cell.js +53 -0
- package/dist/cjs/sortable-column.js +129 -0
- package/dist/cjs/table.js +60 -0
- package/dist/cjs/thead.js +73 -0
- package/dist/cjs/ui/base-cell.js +72 -0
- package/dist/cjs/ui/bulk-action-overlay.js +39 -0
- package/dist/cjs/ui/index.js +69 -0
- package/dist/cjs/ui/selectable-cell.js +39 -0
- package/dist/cjs/ui/table.js +31 -0
- package/dist/cjs/ui/tbody.js +38 -0
- package/dist/cjs/ui/td.js +38 -0
- package/dist/cjs/ui/th.js +40 -0
- package/dist/cjs/ui/thead.js +40 -0
- package/dist/cjs/ui/tr.js +68 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/body.js +66 -0
- package/dist/es2019/head-cell.js +31 -0
- package/dist/es2019/hooks/selection-provider.js +33 -0
- package/dist/es2019/hooks/use-row-id.js +13 -0
- package/dist/es2019/hooks/use-selectable.js +158 -0
- package/dist/es2019/hooks/use-sorting.js +37 -0
- package/dist/es2019/hooks/use-table-body.js +13 -0
- package/dist/es2019/hooks/use-table.js +34 -0
- package/dist/es2019/index.js +7 -0
- package/dist/es2019/row.js +41 -0
- package/dist/es2019/selectable-cell.js +25 -0
- package/dist/es2019/sortable-column.js +109 -0
- package/dist/es2019/table.js +38 -0
- package/dist/es2019/thead.js +46 -0
- package/dist/es2019/ui/base-cell.js +54 -0
- package/dist/es2019/ui/bulk-action-overlay.js +27 -0
- package/dist/es2019/ui/index.js +11 -0
- package/dist/es2019/ui/selectable-cell.js +28 -0
- package/dist/es2019/ui/table.js +22 -0
- package/dist/es2019/ui/tbody.js +26 -0
- package/dist/es2019/ui/td.js +21 -0
- package/dist/es2019/ui/th.js +26 -0
- package/dist/es2019/ui/thead.js +31 -0
- package/dist/es2019/ui/tr.js +55 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/body.js +84 -0
- package/dist/esm/head-cell.js +31 -0
- package/dist/esm/hooks/selection-provider.js +32 -0
- package/dist/esm/hooks/use-row-id.js +15 -0
- package/dist/esm/hooks/use-selectable.js +171 -0
- package/dist/esm/hooks/use-sorting.js +46 -0
- package/dist/esm/hooks/use-table-body.js +13 -0
- package/dist/esm/hooks/use-table.js +36 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/row.js +46 -0
- package/dist/esm/selectable-cell.js +31 -0
- package/dist/esm/sortable-column.js +114 -0
- package/dist/esm/table.js +39 -0
- package/dist/esm/thead.js +51 -0
- package/dist/esm/ui/base-cell.js +58 -0
- package/dist/esm/ui/bulk-action-overlay.js +28 -0
- package/dist/esm/ui/index.js +11 -0
- package/dist/esm/ui/selectable-cell.js +28 -0
- package/dist/esm/ui/table.js +21 -0
- package/dist/esm/ui/tbody.js +27 -0
- package/dist/esm/ui/td.js +26 -0
- package/dist/esm/ui/th.js +28 -0
- package/dist/esm/ui/thead.js +30 -0
- package/dist/esm/ui/tr.js +55 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/body.d.ts +15 -0
- package/dist/types/head-cell.d.ts +10 -0
- package/dist/types/hooks/selection-provider.d.ts +25 -0
- package/dist/types/hooks/use-row-id.d.ts +10 -0
- package/dist/types/hooks/use-selectable.d.ts +14 -0
- package/dist/types/hooks/use-sorting.d.ts +6 -0
- package/dist/types/hooks/use-table-body.d.ts +7 -0
- package/dist/types/hooks/use-table.d.ts +21 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/row.d.ts +14 -0
- package/dist/types/selectable-cell.d.ts +3 -0
- package/dist/types/sortable-column.d.ts +17 -0
- package/dist/types/table.d.ts +26 -0
- package/dist/types/thead.d.ts +7 -0
- package/dist/types/ui/base-cell.d.ts +30 -0
- package/dist/types/ui/bulk-action-overlay.d.ts +8 -0
- package/dist/types/ui/index.d.ts +11 -0
- package/dist/types/ui/selectable-cell.d.ts +10 -0
- package/dist/types/ui/table.d.ts +23 -0
- package/dist/types/ui/tbody.d.ts +8 -0
- package/dist/types/ui/td.d.ts +11 -0
- package/dist/types/ui/th.d.ts +11 -0
- package/dist/types/ui/thead.d.ts +10 -0
- package/dist/types/ui/tr.d.ts +16 -0
- package/package.json +101 -0
- package/primitives/package.json +15 -0
- package/report.api.md +139 -0
- package/tmp/api-report-tmp.d.ts +99 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* eslint-disable @atlassian/tangerine/import/entry-points */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import Box from '@atlaskit/ds-explorations/box';
|
|
7
|
+
import Inline from '@atlaskit/ds-explorations/inline';
|
|
8
|
+
var alignMap = {
|
|
9
|
+
text: 'flexStart',
|
|
10
|
+
number: 'flexEnd',
|
|
11
|
+
icon: 'center'
|
|
12
|
+
};
|
|
13
|
+
var baseResetStyles = css({
|
|
14
|
+
display: 'table-cell',
|
|
15
|
+
verticalAlign: 'middle',
|
|
16
|
+
'&:first-of-type': {
|
|
17
|
+
paddingLeft: "var(--ds-space-100, 8px)"
|
|
18
|
+
},
|
|
19
|
+
'&:last-of-type': {
|
|
20
|
+
paddingRight: "var(--ds-space-100, 8px)"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* __BaseCell__
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*
|
|
28
|
+
* Basic cell element.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export var BaseCell = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
32
|
+
var testId = _ref.testId,
|
|
33
|
+
as = _ref.as,
|
|
34
|
+
children = _ref.children,
|
|
35
|
+
_ref$align = _ref.align,
|
|
36
|
+
align = _ref$align === void 0 ? 'text' : _ref$align,
|
|
37
|
+
_ref$paddingBlock = _ref.paddingBlock,
|
|
38
|
+
paddingBlock = _ref$paddingBlock === void 0 ? 'scale.100' : _ref$paddingBlock,
|
|
39
|
+
_ref$paddingInline = _ref.paddingInline,
|
|
40
|
+
paddingInline = _ref$paddingInline === void 0 ? 'scale.200' : _ref$paddingInline,
|
|
41
|
+
backgroundColor = _ref.backgroundColor,
|
|
42
|
+
scope = _ref.scope,
|
|
43
|
+
className = _ref.className;
|
|
44
|
+
return jsx(Box, {
|
|
45
|
+
css: baseResetStyles,
|
|
46
|
+
ref: ref,
|
|
47
|
+
scope: scope,
|
|
48
|
+
backgroundColor: backgroundColor,
|
|
49
|
+
paddingBlock: paddingBlock,
|
|
50
|
+
paddingInline: paddingInline,
|
|
51
|
+
as: as,
|
|
52
|
+
testId: testId,
|
|
53
|
+
className: className
|
|
54
|
+
}, jsx(Inline, {
|
|
55
|
+
justifyContent: alignMap[align],
|
|
56
|
+
gap: "scale.0"
|
|
57
|
+
}, children));
|
|
58
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import { UNSAFE_Box as Box, UNSAFE_Inline as Inline } from '@atlaskit/ds-explorations';
|
|
4
|
+
var overlayStyles = css({
|
|
5
|
+
top: 0,
|
|
6
|
+
right: 0,
|
|
7
|
+
bottom: 0,
|
|
8
|
+
left: 32
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* __Bulk action overlay__
|
|
12
|
+
*
|
|
13
|
+
* A bulk action overlay is used to conditionally render when a user makes a row selection
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export var BulkActionOverlay = function BulkActionOverlay(_ref) {
|
|
17
|
+
var children = _ref.children;
|
|
18
|
+
return jsx(Box, {
|
|
19
|
+
as: "th",
|
|
20
|
+
position: "absolute",
|
|
21
|
+
paddingInline: "scale.100",
|
|
22
|
+
backgroundColor: "elevation.surface",
|
|
23
|
+
css: overlayStyles
|
|
24
|
+
}, jsx(Inline, {
|
|
25
|
+
gap: "scale.300",
|
|
26
|
+
alignItems: "center"
|
|
27
|
+
}, children));
|
|
28
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File exposes the HTML table primitives for use
|
|
3
|
+
*/
|
|
4
|
+
export { Table } from './table';
|
|
5
|
+
export { TBody } from './tbody';
|
|
6
|
+
export { TR } from './tr';
|
|
7
|
+
export { TD } from './td';
|
|
8
|
+
export { TH } from './th';
|
|
9
|
+
export { SelectableCell } from './selectable-cell';
|
|
10
|
+
export { THead } from './thead';
|
|
11
|
+
export { BulkActionOverlay } from './bulk-action-overlay';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import { BaseCell } from './base-cell';
|
|
4
|
+
var spacingStyles = css({
|
|
5
|
+
width: 32,
|
|
6
|
+
padding: "var(--ds-space-0, 0px)",
|
|
7
|
+
paddingLeft: "var(--ds-space-100, 8px)",
|
|
8
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
9
|
+
'& + *': {
|
|
10
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage-spacing
|
|
11
|
+
paddingLeft: '8px !important'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* __Selectable cell__
|
|
16
|
+
*
|
|
17
|
+
* A selectable cell primitive designed to be used for light weight composition.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export var SelectableCell = function SelectableCell(_ref) {
|
|
21
|
+
var children = _ref.children,
|
|
22
|
+
_ref$as = _ref.as,
|
|
23
|
+
as = _ref$as === void 0 ? 'td' : _ref$as;
|
|
24
|
+
return jsx(BaseCell, {
|
|
25
|
+
as: as,
|
|
26
|
+
css: spacingStyles
|
|
27
|
+
}, children);
|
|
28
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* __Table__
|
|
6
|
+
*
|
|
7
|
+
* A primitive table container. Applies the HTML native element with no other styling.
|
|
8
|
+
*
|
|
9
|
+
* - [Examples](https://atlassian.design/components/table/examples)
|
|
10
|
+
*
|
|
11
|
+
* @primitive
|
|
12
|
+
* @see https://hello.atlassian.net/wiki/spaces/DST/pages/1947062524/Dynamic+table+2.0+implementation+spec
|
|
13
|
+
*/
|
|
14
|
+
export var Table = function Table(_ref) {
|
|
15
|
+
var children = _ref.children,
|
|
16
|
+
testId = _ref.testId,
|
|
17
|
+
summary = _ref.summary;
|
|
18
|
+
return jsx("table", {
|
|
19
|
+
"data-testid": testId
|
|
20
|
+
}, summary && jsx("caption", null, summary), children);
|
|
21
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/react/no-clone-element */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
5
|
+
var bodyStyles = css({
|
|
6
|
+
position: 'relative',
|
|
7
|
+
border: 'none',
|
|
8
|
+
'&:after': {
|
|
9
|
+
position: 'absolute',
|
|
10
|
+
boxShadow: "inset 0 -2px 0 0 ".concat("var(--ds-border, #eee)"),
|
|
11
|
+
content: "''",
|
|
12
|
+
inset: 0,
|
|
13
|
+
pointerEvents: 'none'
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* __TBody__
|
|
18
|
+
* @primitive
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export var TBody = function TBody(_ref) {
|
|
22
|
+
var children = _ref.children;
|
|
23
|
+
return jsx("tbody", {
|
|
24
|
+
css: bodyStyles
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
27
|
+
export default TBody;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["testId"];
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import { jsx } from '@emotion/react';
|
|
7
|
+
import { BaseCell } from './base-cell';
|
|
8
|
+
/**
|
|
9
|
+
* __Cell__
|
|
10
|
+
*
|
|
11
|
+
* A data cell.
|
|
12
|
+
*
|
|
13
|
+
* @primitive
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export var TD = function TD(_ref) {
|
|
17
|
+
var testId = _ref.testId,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
|
|
20
|
+
return (// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
21
|
+
jsx(BaseCell, _extends({
|
|
22
|
+
as: "td",
|
|
23
|
+
testId: testId
|
|
24
|
+
}, props))
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BaseCell } from './base-cell';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* __Head cell__
|
|
6
|
+
*
|
|
7
|
+
* A head cell.
|
|
8
|
+
*
|
|
9
|
+
* @primitive
|
|
10
|
+
*/
|
|
11
|
+
export var TH = function TH(_ref) {
|
|
12
|
+
var children = _ref.children,
|
|
13
|
+
testId = _ref.testId,
|
|
14
|
+
align = _ref.align,
|
|
15
|
+
scope = _ref.scope,
|
|
16
|
+
backgroundColor = _ref.backgroundColor;
|
|
17
|
+
return (
|
|
18
|
+
/*#__PURE__*/
|
|
19
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
20
|
+
React.createElement(BaseCell, {
|
|
21
|
+
as: "th",
|
|
22
|
+
testId: testId,
|
|
23
|
+
align: align,
|
|
24
|
+
scope: scope,
|
|
25
|
+
backgroundColor: backgroundColor
|
|
26
|
+
}, children)
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
var baseStyles = css({
|
|
4
|
+
position: 'sticky',
|
|
5
|
+
zIndex: 1,
|
|
6
|
+
backgroundColor: "var(--ds-surface, white)",
|
|
7
|
+
border: 'none',
|
|
8
|
+
inset: 0,
|
|
9
|
+
'&:after': {
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
boxShadow: "inset 0 -2px 0 0 ".concat("var(--ds-border, #eee)"),
|
|
12
|
+
content: "''",
|
|
13
|
+
inset: 0,
|
|
14
|
+
pointerEvents: 'none'
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* __THead__
|
|
19
|
+
*
|
|
20
|
+
* A primitive table head container. Applies the HTML native element with minimal styling.
|
|
21
|
+
*
|
|
22
|
+
* @primitive
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export var THead = function THead(_ref) {
|
|
26
|
+
var children = _ref.children;
|
|
27
|
+
return jsx("thead", {
|
|
28
|
+
css: baseStyles
|
|
29
|
+
}, children);
|
|
30
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
4
|
+
var baseStyles = css({
|
|
5
|
+
height: 48,
|
|
6
|
+
position: 'relative',
|
|
7
|
+
border: 'none',
|
|
8
|
+
borderImageWidth: 0,
|
|
9
|
+
borderSpacing: 0
|
|
10
|
+
});
|
|
11
|
+
var selectedStyles = css({
|
|
12
|
+
backgroundColor: "var(--ds-background-selected, #DEEBFF88)",
|
|
13
|
+
'&:hover': {
|
|
14
|
+
backgroundColor: "var(--ds-background-selected-hovered, #DEEBFF)" // B50
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var bodyRowStyles = css({
|
|
19
|
+
'&:hover': {
|
|
20
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #f8f8f8)"
|
|
21
|
+
},
|
|
22
|
+
'&:focus-visible::after': {
|
|
23
|
+
boxShadow: 'none'
|
|
24
|
+
},
|
|
25
|
+
'&:after': {
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
boxShadow: "inset 0 -1px 0 0 ".concat("var(--ds-border, #eee)"),
|
|
28
|
+
content: "''",
|
|
29
|
+
inset: 0,
|
|
30
|
+
pointerEvents: 'none'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* __Row__
|
|
36
|
+
*
|
|
37
|
+
* A row primitive.
|
|
38
|
+
*
|
|
39
|
+
* - [Examples](https://atlassian.design/components/table/examples)
|
|
40
|
+
*/
|
|
41
|
+
export var TR = function TR(_ref) {
|
|
42
|
+
var children = _ref.children,
|
|
43
|
+
testId = _ref.testId,
|
|
44
|
+
isSelected = _ref.isSelected,
|
|
45
|
+
_ref$isBodyRow = _ref.isBodyRow,
|
|
46
|
+
isBodyRow = _ref$isBodyRow === void 0 ? true : _ref$isBodyRow;
|
|
47
|
+
return jsx(FocusRing, {
|
|
48
|
+
isInset: true
|
|
49
|
+
}, jsx("tr", {
|
|
50
|
+
tabIndex: -1,
|
|
51
|
+
"aria-selected": isSelected,
|
|
52
|
+
"data-testid": testId,
|
|
53
|
+
css: [baseStyles, isBodyRow && bodyRowStyles, isSelected && selectedStyles]
|
|
54
|
+
}, children));
|
|
55
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
declare type BodyProps<Item extends object> = {
|
|
5
|
+
rows: Item[];
|
|
6
|
+
children: (row: Item) => ReactElement;
|
|
7
|
+
} | {
|
|
8
|
+
rows?: never;
|
|
9
|
+
children: ReactElement[] | ReactElement;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* __Table body__
|
|
13
|
+
*/
|
|
14
|
+
declare function TBody<ObjectType extends object>({ rows, children, }: BodyProps<ObjectType>): jsx.JSX.Element;
|
|
15
|
+
export default TBody;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* __Selection provider__
|
|
4
|
+
*
|
|
5
|
+
* A selection provider injects selection specific state into the table.
|
|
6
|
+
*
|
|
7
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
8
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
9
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
10
|
+
*/
|
|
11
|
+
declare const SelectionProvider: FC;
|
|
12
|
+
export declare const useSelection: () => readonly [{
|
|
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
|
+
}];
|
|
25
|
+
export default SelectionProvider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare function useSelectable(): readonly [{
|
|
2
|
+
checked: number[];
|
|
3
|
+
allChecked: boolean;
|
|
4
|
+
anyChecked: boolean;
|
|
5
|
+
maxChecked: number;
|
|
6
|
+
selectionStart: number;
|
|
7
|
+
previousSelection: number[];
|
|
8
|
+
}, {
|
|
9
|
+
readonly setAll: () => void;
|
|
10
|
+
readonly removeAll: () => void;
|
|
11
|
+
readonly toggleSelection: (id: number, shiftHeld: boolean) => void;
|
|
12
|
+
readonly setMax: (max: number) => void;
|
|
13
|
+
}];
|
|
14
|
+
export default useSelectable;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SortDirection, SortKey } from './use-table';
|
|
2
|
+
export declare const useSorting: <ItemType extends object>(sortKey: SortKey<keyof ItemType>) => {
|
|
3
|
+
sortKey: "unset" | keyof ItemType;
|
|
4
|
+
sortDirection: SortDirection | undefined;
|
|
5
|
+
setSortState: (key: SortKey<keyof ItemType>) => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type SortDirection = 'ascending' | 'descending';
|
|
3
|
+
export declare type SortKey<Key extends string | symbol | number> = Key | 'unset';
|
|
4
|
+
export declare type TableContext<T, K extends keyof T = keyof T> = {
|
|
5
|
+
isSelectable?: boolean;
|
|
6
|
+
sortKey: SortKey<K>;
|
|
7
|
+
sortDirection?: SortDirection;
|
|
8
|
+
setSortState: (key: SortKey<K>) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* __Table state provider__
|
|
12
|
+
*
|
|
13
|
+
* The table context provides the data required for more complex functionality.
|
|
14
|
+
*
|
|
15
|
+
* - [Examples](https://atlassian.design/components/table/examples)
|
|
16
|
+
*/
|
|
17
|
+
export declare function TableProvider<T extends object>({ children, state, }: {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
state: TableContext<T>;
|
|
20
|
+
}): JSX.Element;
|
|
21
|
+
export declare const useTable: <TableItem extends object>() => TableContext<TableItem, keyof TableItem>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default } from './table';
|
|
2
|
+
export { default as TBody } from './body';
|
|
3
|
+
export { default as Row } from './row';
|
|
4
|
+
export { TD as Cell } from './ui';
|
|
5
|
+
export { default as HeadCell } from './head-cell';
|
|
6
|
+
export { default as SortableColumn } from './sortable-column';
|
|
7
|
+
export { default as THead } from './thead';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
export declare type RowProps = {
|
|
4
|
+
testId?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* __Row__
|
|
8
|
+
*
|
|
9
|
+
* A table row.
|
|
10
|
+
*
|
|
11
|
+
* - [Examples](https://atlassian.design/components/table/examples)
|
|
12
|
+
*/
|
|
13
|
+
declare const Row: FC<RowProps>;
|
|
14
|
+
export default Row;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
export interface CellProps {
|
|
4
|
+
/**
|
|
5
|
+
* Unique key used for sorting table data by this column
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
testId?: string;
|
|
9
|
+
onClick?: React.MouseEventHandler;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* __SortableColumn__
|
|
13
|
+
*
|
|
14
|
+
* SortableColumn is used in place of the default Column when sorting is desired.
|
|
15
|
+
*/
|
|
16
|
+
declare const SortableColumn: FC<CellProps>;
|
|
17
|
+
export default SortableColumn;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { SortKey } from './hooks/use-table';
|
|
5
|
+
export declare type TableProps<ItemType extends object = {}> = {
|
|
6
|
+
testId?: string;
|
|
7
|
+
/**
|
|
8
|
+
* default sort key to be applied. If unspecified will use default ordering
|
|
9
|
+
*/
|
|
10
|
+
sortKey?: SortKey<keyof ItemType>;
|
|
11
|
+
children: ReactElement[] | ReactElement;
|
|
12
|
+
} & ({
|
|
13
|
+
isSelectable: true;
|
|
14
|
+
defaultSelected?: number;
|
|
15
|
+
} | {
|
|
16
|
+
isSelectable?: false;
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* __Table__
|
|
20
|
+
*
|
|
21
|
+
* A data table is used to display dynamic data.
|
|
22
|
+
*
|
|
23
|
+
* - [Examples](https://atlassian.design/components/table/examples)
|
|
24
|
+
*/
|
|
25
|
+
declare function Table<ItemType extends object = object>({ children, isSelectable, sortKey, testId, }: TableProps<ItemType>): jsx.JSX.Element;
|
|
26
|
+
export default Table;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { BoxProps } from '@atlaskit/ds-explorations/box';
|
|
4
|
+
export declare type BaseCellProps = {
|
|
5
|
+
align?: keyof typeof alignMap;
|
|
6
|
+
as?: 'td' | 'th';
|
|
7
|
+
scope?: 'col' | 'row';
|
|
8
|
+
testId?: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
} & Pick<BoxProps, 'paddingBlock' | 'paddingInline' | 'backgroundColor' | 'className'>;
|
|
11
|
+
declare const alignMap: {
|
|
12
|
+
readonly text: "flexStart";
|
|
13
|
+
readonly number: "flexEnd";
|
|
14
|
+
readonly icon: "center";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* __BaseCell__
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*
|
|
21
|
+
* Basic cell element.
|
|
22
|
+
*/
|
|
23
|
+
export declare const BaseCell: import("react").ForwardRefExoticComponent<{
|
|
24
|
+
align?: "number" | "text" | "icon" | undefined;
|
|
25
|
+
as?: "td" | "th" | undefined;
|
|
26
|
+
scope?: "col" | "row" | undefined;
|
|
27
|
+
testId?: string | undefined;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
} & Pick<BoxProps<"div">, "className" | "backgroundColor" | "paddingBlock" | "paddingInline"> & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File exposes the HTML table primitives for use
|
|
3
|
+
*/
|
|
4
|
+
export { Table } from './table';
|
|
5
|
+
export { TBody } from './tbody';
|
|
6
|
+
export { TR } from './tr';
|
|
7
|
+
export { TD } from './td';
|
|
8
|
+
export { TH } from './th';
|
|
9
|
+
export { SelectableCell } from './selectable-cell';
|
|
10
|
+
export { THead } from './thead';
|
|
11
|
+
export { BulkActionOverlay } from './bulk-action-overlay';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
declare type TableProps = {
|
|
4
|
+
testId?: string;
|
|
5
|
+
/**
|
|
6
|
+
* Accessible description of the table data.
|
|
7
|
+
*
|
|
8
|
+
* @see https://www.w3.org/WAI/EO/Drafts/tutorials/tables/summary/
|
|
9
|
+
*/
|
|
10
|
+
summary?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* __Table__
|
|
14
|
+
*
|
|
15
|
+
* A primitive table container. Applies the HTML native element with no other styling.
|
|
16
|
+
*
|
|
17
|
+
* - [Examples](https://atlassian.design/components/table/examples)
|
|
18
|
+
*
|
|
19
|
+
* @primitive
|
|
20
|
+
* @see https://hello.atlassian.net/wiki/spaces/DST/pages/1947062524/Dynamic+table+2.0+implementation+spec
|
|
21
|
+
*/
|
|
22
|
+
export declare const Table: FC<TableProps>;
|
|
23
|
+
export {};
|