@atlaskit/dynamic-table 14.2.3 → 14.4.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 +39 -0
- package/dist/cjs/components/Body.js +2 -2
- package/dist/cjs/components/LoadingContainer.js +1 -1
- package/dist/cjs/components/LoadingContainerAdvanced.js +4 -4
- package/dist/cjs/components/Stateful.js +5 -3
- package/dist/cjs/components/Stateless.js +6 -4
- package/dist/cjs/components/TableHead.js +1 -1
- package/dist/cjs/components/TableHeadCell.js +18 -48
- package/dist/cjs/components/TableRow.js +4 -1
- package/dist/cjs/components/managedPagination.js +1 -1
- package/dist/cjs/components/rankable/Body.js +2 -2
- package/dist/cjs/components/rankable/TableCell.js +5 -5
- package/dist/cjs/components/rankable/TableHeadCell.js +3 -5
- package/dist/cjs/components/rankable/TableRow.js +5 -5
- package/dist/cjs/hoc/withDimensions.js +3 -5
- package/dist/cjs/hoc/withSortedPageRows.js +4 -6
- package/dist/cjs/styled/DynamicTable.js +80 -50
- package/dist/cjs/styled/EmptyBody.js +23 -28
- package/dist/cjs/styled/LoadingContainer.js +41 -36
- package/dist/cjs/styled/LoadingContainerAdvanced.js +42 -36
- package/dist/cjs/styled/TableCell.js +21 -15
- package/dist/cjs/styled/TableHead.js +157 -45
- package/dist/cjs/styled/TableRow.js +36 -42
- package/dist/cjs/styled/constants.js +33 -118
- package/dist/cjs/styled/rankable/RowPlaceholder.js +11 -12
- package/dist/cjs/styled/rankable/TableCell.js +18 -27
- package/dist/cjs/styled/rankable/TableRow.js +32 -54
- package/dist/cjs/theme.js +33 -20
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/Body.js +1 -1
- package/dist/es2019/components/LoadingContainerAdvanced.js +2 -4
- package/dist/es2019/components/Stateful.js +4 -2
- package/dist/es2019/components/Stateless.js +5 -3
- package/dist/es2019/components/TableHeadCell.js +18 -22
- package/dist/es2019/components/TableRow.js +4 -1
- package/dist/es2019/components/rankable/Body.js +1 -1
- package/dist/es2019/components/rankable/TableCell.js +4 -4
- package/dist/es2019/components/rankable/TableHeadCell.js +1 -3
- package/dist/es2019/components/rankable/TableRow.js +3 -3
- package/dist/es2019/hoc/withDimensions.js +2 -4
- package/dist/es2019/hoc/withSortedPageRows.js +2 -4
- package/dist/es2019/styled/DynamicTable.js +75 -27
- package/dist/es2019/styled/EmptyBody.js +21 -11
- package/dist/es2019/styled/LoadingContainer.js +39 -18
- package/dist/es2019/styled/LoadingContainerAdvanced.js +38 -20
- package/dist/es2019/styled/TableCell.js +20 -5
- package/dist/es2019/styled/TableHead.js +160 -33
- package/dist/es2019/styled/TableRow.js +34 -20
- package/dist/es2019/styled/constants.js +30 -88
- package/dist/es2019/styled/rankable/RowPlaceholder.js +10 -4
- package/dist/es2019/styled/rankable/TableCell.js +16 -9
- package/dist/es2019/styled/rankable/TableRow.js +32 -24
- package/dist/es2019/theme.js +25 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/Body.js +2 -2
- package/dist/esm/components/LoadingContainer.js +1 -1
- package/dist/esm/components/LoadingContainerAdvanced.js +4 -4
- package/dist/esm/components/Stateful.js +5 -3
- package/dist/esm/components/Stateless.js +6 -4
- package/dist/esm/components/TableHead.js +1 -1
- package/dist/esm/components/TableHeadCell.js +19 -47
- package/dist/esm/components/TableRow.js +4 -1
- package/dist/esm/components/managedPagination.js +1 -1
- package/dist/esm/components/rankable/Body.js +2 -2
- package/dist/esm/components/rankable/TableCell.js +5 -5
- package/dist/esm/components/rankable/TableHeadCell.js +3 -5
- package/dist/esm/components/rankable/TableRow.js +5 -5
- package/dist/esm/hoc/withDimensions.js +3 -5
- package/dist/esm/hoc/withSortedPageRows.js +4 -6
- package/dist/esm/styled/DynamicTable.js +75 -46
- package/dist/esm/styled/EmptyBody.js +23 -26
- package/dist/esm/styled/LoadingContainer.js +40 -36
- package/dist/esm/styled/LoadingContainerAdvanced.js +41 -35
- package/dist/esm/styled/TableCell.js +21 -15
- package/dist/esm/styled/TableHead.js +152 -41
- package/dist/esm/styled/TableRow.js +38 -42
- package/dist/esm/styled/constants.js +28 -108
- package/dist/esm/styled/rankable/RowPlaceholder.js +12 -14
- package/dist/esm/styled/rankable/TableCell.js +18 -27
- package/dist/esm/styled/rankable/TableRow.js +33 -54
- package/dist/esm/theme.js +25 -18
- package/dist/esm/version.json +1 -1
- package/dist/types/components/Body.d.ts +22 -22
- package/dist/types/components/LoadingContainerAdvanced.d.ts +2 -2
- package/dist/types/components/Stateless.d.ts +3 -3
- package/dist/types/components/TableHeadCell.d.ts +4 -9
- package/dist/types/components/rankable/Body.d.ts +22 -22
- package/dist/types/components/rankable/TableHeadCell.d.ts +1 -1
- package/dist/types/components/rankable/TableRow.d.ts +3 -3
- package/dist/types/hoc/withDimensions.d.ts +2 -2
- package/dist/types/hoc/withSortedPageRows.d.ts +20 -20
- package/dist/types/styled/DynamicTable.d.ts +13 -6
- package/dist/types/styled/EmptyBody.d.ts +4 -3
- package/dist/types/styled/LoadingContainer.d.ts +8 -7
- package/dist/types/styled/LoadingContainerAdvanced.d.ts +5 -4
- package/dist/types/styled/TableCell.d.ts +3 -2
- package/dist/types/styled/TableHead.d.ts +8 -5
- package/dist/types/styled/TableRow.d.ts +7 -4
- package/dist/types/styled/constants.d.ts +13 -10
- package/dist/types/styled/rankable/RowPlaceholder.d.ts +3 -2
- package/dist/types/styled/rankable/TableCell.d.ts +8 -6
- package/dist/types/styled/rankable/TableRow.d.ts +9 -6
- package/dist/types/theme.d.ts +15 -9
- package/dist/types/types.d.ts +18 -6
- package/package.json +15 -9
|
@@ -13,7 +13,7 @@ export class RankableTableRow extends React.Component {
|
|
|
13
13
|
_defineProperty(this, "innerRef", innerRefFn => ref => {
|
|
14
14
|
innerRefFn(ref);
|
|
15
15
|
|
|
16
|
-
if (this.props.innerRef) {
|
|
16
|
+
if (typeof this.props.innerRef === 'function') {
|
|
17
17
|
this.props.innerRef(ref);
|
|
18
18
|
}
|
|
19
19
|
});
|
|
@@ -43,11 +43,11 @@ export class RankableTableRow extends React.Component {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return /*#__PURE__*/React.createElement(Draggable, {
|
|
46
|
-
draggableId: key ||
|
|
46
|
+
draggableId: key || rowIndex.toString(),
|
|
47
47
|
index: rowIndex,
|
|
48
48
|
isDragDisabled: isRankingDisabled
|
|
49
49
|
}, (provided, snapshot) => /*#__PURE__*/React.createElement(RankableTableBodyRow, _extends({}, restRowProps, provided.dragHandleProps, provided.draggableProps, {
|
|
50
|
-
|
|
50
|
+
ref: this.innerRef(provided.innerRef),
|
|
51
51
|
style: { ...provided.draggableProps.style,
|
|
52
52
|
...inlineStyles
|
|
53
53
|
},
|
|
@@ -3,9 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
// Compute height and width of wrapped component before ranking
|
|
5
5
|
export default function withDimensions(WrappedComponent) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return _temp = class WithDimensions extends React.Component {
|
|
6
|
+
return class WithDimensions extends React.Component {
|
|
9
7
|
constructor(...args) {
|
|
10
8
|
super(...args);
|
|
11
9
|
|
|
@@ -65,5 +63,5 @@ export default function withDimensions(WrappedComponent) {
|
|
|
65
63
|
}, this.props));
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
}
|
|
66
|
+
};
|
|
69
67
|
}
|
|
@@ -85,9 +85,7 @@ const getSortedRows = (head, rows, sortKey, sortOrder) => {
|
|
|
85
85
|
|
|
86
86
|
// get one page of data in table, sorting all rows previously
|
|
87
87
|
export default function withSortedPageRows(WrappedComponent) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return _temp = class WithSortedPageRows extends React.Component {
|
|
88
|
+
return class WithSortedPageRows extends React.Component {
|
|
91
89
|
constructor(...args) {
|
|
92
90
|
super(...args);
|
|
93
91
|
|
|
@@ -151,5 +149,5 @@ export default function withSortedPageRows(WrappedComponent) {
|
|
|
151
149
|
}, restProps));
|
|
152
150
|
}
|
|
153
151
|
|
|
154
|
-
}
|
|
152
|
+
};
|
|
155
153
|
}
|
|
@@ -1,31 +1,79 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
6
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
7
|
+
import { gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
8
|
+
import { row } from '../theme';
|
|
9
|
+
const gridSize = getGridSize();
|
|
10
|
+
// CSS vars for table row
|
|
11
|
+
// these are declared here to avoid being re-declared in each table row
|
|
12
|
+
export const tableRowCSSVars = {
|
|
13
|
+
CSS_VAR_HOVER_BACKGROUND: '--local-dynamic-table-hover-bg',
|
|
14
|
+
CSS_VAR_HIGHLIGHTED_BACKGROUND: '--local-dynamic-table-highlighted-bg',
|
|
15
|
+
CSS_VAR_HOVER_HIGHLIGHTED_BACKGROUND: '--local-dynamic-table-hover-highlighted-bg',
|
|
16
|
+
CSS_VAR_ROW_FOCUS_OUTLINE: '--local-dynamic-table-row-focus-outline'
|
|
17
|
+
};
|
|
18
|
+
const fixedSizeTableStyles = css({
|
|
19
|
+
tableLayout: 'fixed'
|
|
20
|
+
});
|
|
21
|
+
const tableStyles = css({
|
|
22
|
+
borderCollapse: 'collapse',
|
|
23
|
+
width: '100%'
|
|
24
|
+
});
|
|
25
|
+
export const Table = /*#__PURE__*/forwardRef(({
|
|
26
|
+
isFixedSize,
|
|
27
|
+
children,
|
|
28
|
+
...rest
|
|
29
|
+
}, ref) => {
|
|
30
|
+
const theme = useGlobalTheme();
|
|
31
|
+
return jsx("table", _extends({
|
|
32
|
+
style: {
|
|
33
|
+
[tableRowCSSVars.CSS_VAR_HOVER_BACKGROUND]: row.hoverBackground({
|
|
34
|
+
theme
|
|
35
|
+
}),
|
|
36
|
+
[tableRowCSSVars.CSS_VAR_HIGHLIGHTED_BACKGROUND]: row.highlightedBackground({
|
|
37
|
+
theme
|
|
38
|
+
}),
|
|
39
|
+
[tableRowCSSVars.CSS_VAR_HOVER_HIGHLIGHTED_BACKGROUND]: row.hoverHighlightedBackground({
|
|
40
|
+
theme
|
|
41
|
+
}),
|
|
42
|
+
[tableRowCSSVars.CSS_VAR_ROW_FOCUS_OUTLINE]: row.focusOutline({
|
|
43
|
+
theme
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
css: [tableStyles, isFixedSize && fixedSizeTableStyles],
|
|
47
|
+
ref: ref
|
|
48
|
+
}, rest), children);
|
|
49
|
+
});
|
|
50
|
+
const captionStyles = css({
|
|
51
|
+
fontSize: '1.42857143em',
|
|
52
|
+
|
|
15
53
|
/* there is a bug in Safari: if element which creates a new stacking context
|
|
16
54
|
is a child of a table, table caption re-renders in bad wrong position
|
|
17
55
|
https://stackoverflow.com/questions/44009186/safari-bug-translating-table-row-group-using-gsap-make-caption-jump-to-bottom
|
|
18
56
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
57
|
+
willChange: 'transform',
|
|
58
|
+
fontStyle: 'inherit',
|
|
59
|
+
fontWeight: 500,
|
|
60
|
+
letterSpacing: '-0.008em',
|
|
61
|
+
lineHeight: 1.2,
|
|
62
|
+
marginBottom: `${gridSize}px`,
|
|
63
|
+
marginTop: `${gridSize * 3.5}px`,
|
|
64
|
+
textAlign: 'left'
|
|
65
|
+
});
|
|
66
|
+
export const Caption = ({
|
|
67
|
+
children
|
|
68
|
+
}) => jsx("caption", {
|
|
69
|
+
css: captionStyles
|
|
70
|
+
}, children);
|
|
71
|
+
const paginationWrapperStyles = css({
|
|
72
|
+
display: 'flex',
|
|
73
|
+
justifyContent: 'center'
|
|
74
|
+
});
|
|
75
|
+
export const PaginationWrapper = ({
|
|
76
|
+
children
|
|
77
|
+
}) => jsx("div", {
|
|
78
|
+
css: paginationWrapperStyles
|
|
79
|
+
}, children);
|
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
2
3
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const fixedHeightStyles = css({
|
|
5
|
+
height: `${gridSize() * 18}px`
|
|
6
|
+
});
|
|
7
|
+
export const EmptyViewWithFixedHeight = ({
|
|
8
|
+
children
|
|
9
|
+
}) => jsx("div", {
|
|
10
|
+
css: fixedHeightStyles
|
|
11
|
+
}, children);
|
|
12
|
+
const emptyViewContainerStyles = css({
|
|
13
|
+
margin: 'auto',
|
|
14
|
+
padding: '10px',
|
|
15
|
+
textAlign: 'center',
|
|
16
|
+
width: '50%'
|
|
17
|
+
});
|
|
18
|
+
export const EmptyViewContainer = ({
|
|
19
|
+
children
|
|
20
|
+
}) => jsx("div", {
|
|
21
|
+
css: emptyViewContainerStyles
|
|
22
|
+
}, children);
|
|
@@ -1,18 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
const CSS_VAR_CONTENTS_OPACITY = '--contents-opacity';
|
|
4
|
+
const containerStyles = css({
|
|
5
|
+
position: 'relative'
|
|
6
|
+
});
|
|
7
|
+
export const Container = ({
|
|
8
|
+
children
|
|
9
|
+
}) => jsx("div", {
|
|
10
|
+
css: containerStyles
|
|
11
|
+
}, children);
|
|
12
|
+
const contentsContainerStyles = css({
|
|
13
|
+
pointerEvents: 'none',
|
|
14
|
+
opacity: `var(${CSS_VAR_CONTENTS_OPACITY})`
|
|
15
|
+
});
|
|
16
|
+
export const ContentsContainer = ({
|
|
17
|
+
contentsOpacity,
|
|
18
|
+
children
|
|
19
|
+
}) => jsx("div", {
|
|
20
|
+
style: {
|
|
21
|
+
[CSS_VAR_CONTENTS_OPACITY]: contentsOpacity
|
|
22
|
+
},
|
|
23
|
+
css: [contentsContainerStyles]
|
|
24
|
+
}, children);
|
|
25
|
+
const spinnerContainerStyles = css({
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
top: 0,
|
|
28
|
+
right: 0,
|
|
29
|
+
bottom: 0,
|
|
30
|
+
left: 0,
|
|
31
|
+
display: 'flex',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center'
|
|
34
|
+
});
|
|
35
|
+
export const SpinnerContainer = ({
|
|
36
|
+
children
|
|
37
|
+
}) => jsx("div", {
|
|
38
|
+
css: spinnerContainerStyles
|
|
39
|
+
}, children);
|
|
@@ -1,21 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
2
6
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
position: relative
|
|
6
|
-
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
const containerStyles = css({
|
|
8
|
+
marginBottom: `${gridSize() * 3}px`,
|
|
9
|
+
position: 'relative'
|
|
10
|
+
});
|
|
11
|
+
export const Container = props => jsx("div", _extends({
|
|
12
|
+
css: containerStyles
|
|
13
|
+
}, props));
|
|
14
|
+
const spinnerBackdropStyles = css({
|
|
15
|
+
pointerEvents: 'none',
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
top: 0,
|
|
18
|
+
right: 0,
|
|
19
|
+
bottom: 0,
|
|
20
|
+
left: 0,
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center'
|
|
24
|
+
});
|
|
25
|
+
export const SpinnerBackdrop = ({
|
|
26
|
+
children
|
|
27
|
+
}) => jsx("div", {
|
|
28
|
+
css: spinnerBackdropStyles
|
|
29
|
+
}, children);
|
|
30
|
+
const spinnerContainerStyles = css({
|
|
31
|
+
position: 'relative',
|
|
32
|
+
top: 0
|
|
33
|
+
});
|
|
34
|
+
export const SpinnerContainer = /*#__PURE__*/forwardRef(({
|
|
35
|
+
children
|
|
36
|
+
}, ref) => jsx("div", {
|
|
37
|
+
css: spinnerContainerStyles,
|
|
38
|
+
ref: ref
|
|
39
|
+
}, children));
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { jsx } from '@emotion/core';
|
|
5
|
+
import { cellStyles, fixedSizeTruncateStyles, getTruncationStyleVars, overflowTruncateStyles, truncationWidthStyles } from './constants';
|
|
6
|
+
export const TableBodyCell = ({
|
|
7
|
+
width,
|
|
8
|
+
isFixedSize,
|
|
9
|
+
shouldTruncate,
|
|
10
|
+
innerRef,
|
|
11
|
+
...props
|
|
12
|
+
}) => jsx("td", _extends({
|
|
13
|
+
style: getTruncationStyleVars({
|
|
14
|
+
width
|
|
15
|
+
}),
|
|
16
|
+
css: [truncationWidthStyles, isFixedSize && shouldTruncate && fixedSizeTruncateStyles, isFixedSize && overflowTruncateStyles, cellStyles] // HOC withDimensions complains about the types but it is working fine
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
,
|
|
19
|
+
ref: innerRef
|
|
20
|
+
}, props));
|
|
@@ -1,34 +1,161 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
${
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
6
|
+
import { B100, N30A } from '@atlaskit/theme/colors';
|
|
7
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
8
|
+
import { gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
9
|
+
import { token } from '@atlaskit/tokens';
|
|
10
|
+
import { ASC, DESC } from '../internal/constants';
|
|
11
|
+
import { arrow, head, MSThemeColors } from '../theme';
|
|
12
|
+
import { cellStyles, fixedSizeTruncateStyles, getTruncationStyleVars, overflowTruncateStyles, truncationWidthStyles } from './constants';
|
|
13
|
+
const gridSize = getGridSize();
|
|
14
|
+
const CSS_VAR_TEXT_COLOR = '--local-dynamic-table-text-color';
|
|
15
|
+
const rankingStyles = css({
|
|
16
|
+
display: 'block'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const getHeadStyles = theme => css({
|
|
20
|
+
borderBottom: `2px solid ${token('color.border.neutral', head.borderColor({
|
|
21
|
+
theme
|
|
22
|
+
}))}`
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const Head = ({
|
|
26
|
+
isRanking,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
const theme = useGlobalTheme();
|
|
30
|
+
return jsx("thead", _extends({
|
|
31
|
+
css: [getHeadStyles(theme), isRanking && rankingStyles]
|
|
32
|
+
}, props));
|
|
33
|
+
};
|
|
34
|
+
const headCellStyles = css([cellStyles, {
|
|
35
|
+
border: 'none',
|
|
36
|
+
boxSizing: 'border-box',
|
|
37
|
+
fontSize: '12px',
|
|
38
|
+
fontWeight: 600,
|
|
39
|
+
position: 'relative',
|
|
40
|
+
textAlign: 'left',
|
|
41
|
+
verticalAlign: 'top',
|
|
42
|
+
color: token('color.text.lowEmphasis', `var(${CSS_VAR_TEXT_COLOR})`),
|
|
43
|
+
'&:focus': {
|
|
44
|
+
outline: `solid 2px ${token('color.border.focus', B100)}`
|
|
33
45
|
}
|
|
34
|
-
|
|
46
|
+
}]); // this needs to be made static: https://product-fabric.atlassian.net/browse/DSP-2011
|
|
47
|
+
|
|
48
|
+
export const getArrowStyles = (isSortable, sortOrder, theme) => {
|
|
49
|
+
if (!isSortable) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const pseudoBaseStyles = {
|
|
54
|
+
border: '3px solid transparent',
|
|
55
|
+
display: 'block',
|
|
56
|
+
height: 0,
|
|
57
|
+
right: `-${gridSize}px`,
|
|
58
|
+
width: 0,
|
|
59
|
+
'@media (forced-colors: active)': {
|
|
60
|
+
border: `3px solid ${MSThemeColors.Background}`
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return css({
|
|
64
|
+
'& > span': {
|
|
65
|
+
position: 'relative',
|
|
66
|
+
'&::before': { ...pseudoBaseStyles,
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
borderBottom: `3px solid ${sortOrder === ASC ? arrow.selectedColor({
|
|
69
|
+
theme
|
|
70
|
+
}) : arrow.defaultColor({
|
|
71
|
+
theme
|
|
72
|
+
})}`,
|
|
73
|
+
bottom: '8px',
|
|
74
|
+
content: '""'
|
|
75
|
+
},
|
|
76
|
+
'&::after': { ...pseudoBaseStyles,
|
|
77
|
+
position: 'absolute',
|
|
78
|
+
borderTop: `3px solid ${sortOrder === DESC ? arrow.selectedColor({
|
|
79
|
+
theme
|
|
80
|
+
}) : arrow.defaultColor({
|
|
81
|
+
theme
|
|
82
|
+
})}`,
|
|
83
|
+
bottom: 0,
|
|
84
|
+
content: '""'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
'&:hover > span': {
|
|
88
|
+
'&::before': {
|
|
89
|
+
borderBottom: `3px solid
|
|
90
|
+
${sortOrder === ASC ? arrow.selectedColor({
|
|
91
|
+
theme
|
|
92
|
+
}) : arrow.hoverColor({
|
|
93
|
+
theme
|
|
94
|
+
})}`
|
|
95
|
+
},
|
|
96
|
+
'&::after': {
|
|
97
|
+
borderTop: `3px solid
|
|
98
|
+
${sortOrder === DESC ? arrow.selectedColor({
|
|
99
|
+
theme
|
|
100
|
+
}) : arrow.hoverColor({
|
|
101
|
+
theme
|
|
102
|
+
})}`
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
'@media (forced-colors: active)': {
|
|
106
|
+
'& > span': {
|
|
107
|
+
'&::before': {
|
|
108
|
+
borderBottom: `3px solid
|
|
109
|
+
${sortOrder === ASC ? MSThemeColors.SelectedBackground : MSThemeColors.Text}`
|
|
110
|
+
},
|
|
111
|
+
'&::after': {
|
|
112
|
+
borderTop: `3px solid
|
|
113
|
+
${sortOrder === DESC ? MSThemeColors.SelectedBackground : MSThemeColors.Text}`
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
'&:hover > span': {
|
|
117
|
+
'&::before': {
|
|
118
|
+
borderBottom: `3px solid
|
|
119
|
+
${sortOrder === ASC ? MSThemeColors.SelectedBackground : MSThemeColors.Text}`
|
|
120
|
+
},
|
|
121
|
+
'&::after': {
|
|
122
|
+
borderTop: `3px solid
|
|
123
|
+
${sortOrder === DESC ? MSThemeColors.SelectedBackground : MSThemeColors.Text}`
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const onClickStyles = css({
|
|
130
|
+
'&:hover': {
|
|
131
|
+
cursor: 'pointer',
|
|
132
|
+
backgroundColor: token('color.background.subtleNeutral.hover', N30A)
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
export const HeadCell = /*#__PURE__*/forwardRef(({
|
|
136
|
+
width,
|
|
137
|
+
children,
|
|
138
|
+
isSortable,
|
|
139
|
+
sortOrder,
|
|
140
|
+
isFixedSize,
|
|
141
|
+
shouldTruncate,
|
|
142
|
+
onClick,
|
|
143
|
+
style,
|
|
144
|
+
...rest
|
|
145
|
+
}, ref) => {
|
|
146
|
+
const theme = useGlobalTheme();
|
|
147
|
+
const mergedStyles = { ...style,
|
|
148
|
+
...(width && getTruncationStyleVars({
|
|
149
|
+
width
|
|
150
|
+
})),
|
|
151
|
+
[CSS_VAR_TEXT_COLOR]: head.textColor({
|
|
152
|
+
theme
|
|
153
|
+
})
|
|
154
|
+
};
|
|
155
|
+
return jsx("th", _extends({
|
|
156
|
+
style: mergedStyles,
|
|
157
|
+
css: [headCellStyles, onClick && onClickStyles, truncationWidthStyles, isFixedSize && shouldTruncate && fixedSizeTruncateStyles, isFixedSize && overflowTruncateStyles, getArrowStyles(isSortable, sortOrder, theme)],
|
|
158
|
+
onClick: onClick,
|
|
159
|
+
ref: ref
|
|
160
|
+
}, rest), children);
|
|
161
|
+
});
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { row } from '../theme';
|
|
3
|
-
const outlineWidth = '2px';
|
|
4
|
-
export const TableBodyRow = styled.tr`
|
|
5
|
-
${({
|
|
6
|
-
isHighlighted
|
|
7
|
-
}) => isHighlighted && css`
|
|
8
|
-
background-color: ${row.highlightedBackground};
|
|
9
|
-
`}
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
6
|
+
import { token } from '@atlaskit/tokens';
|
|
7
|
+
import { tableRowCSSVars as cssVars } from './DynamicTable';
|
|
8
|
+
const rowStyles = css({
|
|
9
|
+
'&:focus': {
|
|
10
|
+
outline: `2px solid ${token('color.border.focus', `var(${cssVars.CSS_VAR_HOVER_BACKGROUND})`)}`,
|
|
11
|
+
outlineOffset: `-2px`
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
});
|
|
14
|
+
const rowBackgroundStyles = css({
|
|
15
|
+
'&:hover': {
|
|
16
|
+
backgroundColor: token('color.background.transparentNeutral.hover', `var(${cssVars.CSS_VAR_HOVER_BACKGROUND})`)
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const rowHighlightedBackgroundStyles = css({
|
|
20
|
+
backgroundColor: token('color.background.selected.resting', `var(${cssVars.CSS_VAR_HIGHLIGHTED_BACKGROUND})`),
|
|
21
|
+
'&:hover': {
|
|
22
|
+
backgroundColor: token('color.background.selected.hover', `var(${cssVars.CSS_VAR_HOVER_HIGHLIGHTED_BACKGROUND})`)
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
});
|
|
25
|
+
export const TableBodyRow = /*#__PURE__*/forwardRef(({
|
|
26
|
+
isHighlighted,
|
|
27
|
+
children,
|
|
28
|
+
style,
|
|
29
|
+
...rest
|
|
30
|
+
}, ref) => {
|
|
31
|
+
return jsx("tr", _extends({
|
|
32
|
+
style: style,
|
|
33
|
+
css: [rowStyles, isHighlighted ? rowHighlightedBackgroundStyles : rowBackgroundStyles]
|
|
34
|
+
}, rest, {
|
|
35
|
+
ref: ref
|
|
36
|
+
}), children);
|
|
37
|
+
});
|