@atlaskit/dynamic-table 14.3.2 → 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 +15 -0
- package/dist/cjs/components/LoadingContainerAdvanced.js +3 -3
- package/dist/cjs/components/Stateless.js +1 -1
- package/dist/cjs/components/TableHeadCell.js +18 -48
- package/dist/cjs/components/rankable/TableCell.js +4 -4
- package/dist/cjs/components/rankable/TableHeadCell.js +2 -4
- package/dist/cjs/components/rankable/TableRow.js +3 -3
- package/dist/cjs/styled/DynamicTable.js +80 -14
- package/dist/cjs/styled/EmptyBody.js +23 -8
- package/dist/cjs/styled/LoadingContainer.js +41 -8
- package/dist/cjs/styled/LoadingContainerAdvanced.js +42 -8
- package/dist/cjs/styled/TableCell.js +21 -7
- package/dist/cjs/styled/TableHead.js +161 -25
- package/dist/cjs/styled/TableRow.js +36 -18
- package/dist/cjs/styled/constants.js +33 -38
- package/dist/cjs/styled/rankable/RowPlaceholder.js +11 -4
- package/dist/cjs/styled/rankable/TableCell.js +18 -13
- package/dist/cjs/styled/rankable/TableRow.js +32 -20
- package/dist/cjs/theme.js +20 -18
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/LoadingContainerAdvanced.js +2 -4
- package/dist/es2019/components/Stateless.js +1 -1
- package/dist/es2019/components/TableHeadCell.js +18 -22
- 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/styled/DynamicTable.js +75 -26
- package/dist/es2019/styled/EmptyBody.js +21 -10
- 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 -115
- 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 +19 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/LoadingContainerAdvanced.js +3 -3
- package/dist/esm/components/Stateless.js +1 -1
- package/dist/esm/components/TableHeadCell.js +19 -47
- package/dist/esm/components/rankable/TableCell.js +4 -4
- package/dist/esm/components/rankable/TableHeadCell.js +2 -4
- package/dist/esm/components/rankable/TableRow.js +3 -3
- package/dist/esm/styled/DynamicTable.js +77 -9
- package/dist/esm/styled/EmptyBody.js +23 -7
- package/dist/esm/styled/LoadingContainer.js +40 -8
- package/dist/esm/styled/LoadingContainerAdvanced.js +41 -7
- package/dist/esm/styled/TableCell.js +21 -7
- package/dist/esm/styled/TableHead.js +160 -21
- package/dist/esm/styled/TableRow.js +36 -12
- package/dist/esm/styled/constants.js +28 -29
- package/dist/esm/styled/rankable/RowPlaceholder.js +11 -5
- package/dist/esm/styled/rankable/TableCell.js +18 -9
- package/dist/esm/styled/rankable/TableRow.js +31 -14
- package/dist/esm/theme.js +19 -18
- package/dist/esm/version.json +1 -1
- package/dist/types/components/Body.d.ts +21 -21
- 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 +21 -21
- 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 +9 -9
- package/dist/types/types.d.ts +2 -2
- package/package.json +9 -3
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { HeadCell } from '../styled/TableHead';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}), /*#__PURE__*/React.createElement("span", null, content));
|
|
20
|
-
}
|
|
5
|
+
const TableHeadCell = ({
|
|
6
|
+
content,
|
|
7
|
+
inlineStyles,
|
|
8
|
+
testId,
|
|
9
|
+
isRanking,
|
|
10
|
+
innerRef,
|
|
11
|
+
isSortable,
|
|
12
|
+
...rest
|
|
13
|
+
}) => {
|
|
14
|
+
return /*#__PURE__*/React.createElement(HeadCell, _extends({
|
|
15
|
+
style: inlineStyles,
|
|
16
|
+
"data-testid": testId && `${testId}--head--cell`,
|
|
17
|
+
ref: typeof innerRef !== 'string' ? innerRef : null // string refs must be discarded as LegacyRefs are not compatible with FC forwardRefs
|
|
21
18
|
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
19
|
+
}, rest, {
|
|
20
|
+
tabIndex: isSortable ? 0 : undefined,
|
|
21
|
+
isSortable: isSortable
|
|
22
|
+
}), /*#__PURE__*/React.createElement("span", null, content));
|
|
23
|
+
};
|
|
28
24
|
|
|
29
25
|
export default TableHeadCell;
|
|
@@ -10,8 +10,8 @@ export class RankableTableCell extends React.Component {
|
|
|
10
10
|
head,
|
|
11
11
|
isFixedSize,
|
|
12
12
|
isRanking,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
refWidth,
|
|
14
|
+
innerRef
|
|
15
15
|
} = this.props;
|
|
16
16
|
const {
|
|
17
17
|
content,
|
|
@@ -28,8 +28,8 @@ export class RankableTableCell extends React.Component {
|
|
|
28
28
|
width: width,
|
|
29
29
|
isRanking: isRanking,
|
|
30
30
|
style: inlineStyles,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
onKeyDown: e => e.stopPropagation(),
|
|
32
|
+
innerRef: innerRef
|
|
33
33
|
}), content);
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -10,13 +10,11 @@ class RankableTableHeadCell extends React.Component {
|
|
|
10
10
|
isRanking,
|
|
11
11
|
refHeight,
|
|
12
12
|
refWidth,
|
|
13
|
-
innerRef,
|
|
14
13
|
...restProps
|
|
15
14
|
} = this.props;
|
|
16
15
|
const inlineStyles = inlineStylesIfRanking(isRanking, refWidth);
|
|
17
16
|
return /*#__PURE__*/React.createElement(HeadCell, _extends({
|
|
18
|
-
inlineStyles: inlineStyles
|
|
19
|
-
innerRef: innerRef
|
|
17
|
+
inlineStyles: inlineStyles
|
|
20
18
|
}, restProps));
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -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
|
},
|
|
@@ -1,30 +1,79 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
|
|
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
|
+
|
|
14
53
|
/* there is a bug in Safari: if element which creates a new stacking context
|
|
15
54
|
is a child of a table, table caption re-renders in bad wrong position
|
|
16
55
|
https://stackoverflow.com/questions/44009186/safari-bug-translating-table-row-group-using-gsap-make-caption-jump-to-bottom
|
|
17
56
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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,11 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
2
3
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
|
-
|
|
4
|
-
height:
|
|
5
|
-
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
});
|