carbon-react 110.5.1 → 110.5.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/esm/components/flat-table/flat-table-header/flat-table-header-utils.js +18 -0
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +6 -1
- package/esm/components/flat-table/flat-table-header/flat-table-header.style.js +7 -5
- package/lib/components/flat-table/flat-table-header/flat-table-header-utils.js +26 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +6 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.style.js +10 -5
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const getAlternativeBackgroundColor = colorTheme => {
|
|
2
|
+
switch (colorTheme) {
|
|
3
|
+
case "light":
|
|
4
|
+
return "var(--colorsActionMinor100)";
|
|
5
|
+
|
|
6
|
+
case "transparent-base":
|
|
7
|
+
return "var(--colorsUtilityMajor025)";
|
|
8
|
+
|
|
9
|
+
case "transparent-white":
|
|
10
|
+
return "var(--colorsUtilityYang100)";
|
|
11
|
+
// default theme is "dark"
|
|
12
|
+
|
|
13
|
+
default:
|
|
14
|
+
return "var(--colorsActionMinor550)";
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default getAlternativeBackgroundColor;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React, { useLayoutEffect, useRef } from "react";
|
|
3
|
+
import React, { useLayoutEffect, useRef, useContext } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
6
|
import StyledFlatTableHeader from "./flat-table-header.style";
|
|
7
7
|
import { filterStyledSystemPaddingProps } from "../../../style/utils";
|
|
8
|
+
import { FlatTableThemeContext } from "../flat-table.component";
|
|
8
9
|
const paddingPropTypes = filterStyledSystemPaddingProps(styledSystemPropTypes.space);
|
|
9
10
|
|
|
10
11
|
const FlatTableHeader = ({
|
|
@@ -21,6 +22,9 @@ const FlatTableHeader = ({
|
|
|
21
22
|
...rest
|
|
22
23
|
}) => {
|
|
23
24
|
const ref = useRef(null);
|
|
25
|
+
const {
|
|
26
|
+
colorTheme
|
|
27
|
+
} = useContext(FlatTableThemeContext);
|
|
24
28
|
useLayoutEffect(() => {
|
|
25
29
|
if (ref.current && reportCellWidth) {
|
|
26
30
|
reportCellWidth(ref.current.offsetWidth, cellIndex);
|
|
@@ -31,6 +35,7 @@ const FlatTableHeader = ({
|
|
|
31
35
|
leftPosition: leftPosition || 0,
|
|
32
36
|
makeCellSticky: !!reportCellWidth,
|
|
33
37
|
align: align,
|
|
38
|
+
colorTheme: colorTheme,
|
|
34
39
|
"data-element": "flat-table-header",
|
|
35
40
|
colSpan: colspan,
|
|
36
41
|
rowSpan: rowspan,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { padding } from "styled-system";
|
|
3
|
+
import getAlternativeBackgroundColor from "./flat-table-header-utils";
|
|
3
4
|
const verticalBorderSizes = {
|
|
4
5
|
small: "1px",
|
|
5
6
|
medium: "2px",
|
|
@@ -12,7 +13,8 @@ const StyledFlatTableHeader = styled.th`
|
|
|
12
13
|
colWidth,
|
|
13
14
|
leftPosition,
|
|
14
15
|
makeCellSticky,
|
|
15
|
-
verticalBorder
|
|
16
|
+
verticalBorder,
|
|
17
|
+
colorTheme
|
|
16
18
|
}) => css`
|
|
17
19
|
background-color: transparent;
|
|
18
20
|
border-width: 0;
|
|
@@ -47,11 +49,11 @@ const StyledFlatTableHeader = styled.th`
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
${alternativeBgColor && css`
|
|
50
|
-
&&&:first-child {
|
|
51
|
-
border-left: 1px solid var(--colorsActionMinor550);
|
|
52
|
-
}
|
|
53
52
|
&&& {
|
|
54
|
-
background-color:
|
|
53
|
+
background-color: ${getAlternativeBackgroundColor(colorTheme)};
|
|
54
|
+
}
|
|
55
|
+
&&&:first-child {
|
|
56
|
+
border-left: unset;
|
|
55
57
|
}
|
|
56
58
|
`};
|
|
57
59
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
const getAlternativeBackgroundColor = colorTheme => {
|
|
9
|
+
switch (colorTheme) {
|
|
10
|
+
case "light":
|
|
11
|
+
return "var(--colorsActionMinor100)";
|
|
12
|
+
|
|
13
|
+
case "transparent-base":
|
|
14
|
+
return "var(--colorsUtilityMajor025)";
|
|
15
|
+
|
|
16
|
+
case "transparent-white":
|
|
17
|
+
return "var(--colorsUtilityYang100)";
|
|
18
|
+
// default theme is "dark"
|
|
19
|
+
|
|
20
|
+
default:
|
|
21
|
+
return "var(--colorsActionMinor550)";
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var _default = getAlternativeBackgroundColor;
|
|
26
|
+
exports.default = _default;
|
|
@@ -15,6 +15,8 @@ var _flatTableHeader = _interopRequireDefault(require("./flat-table-header.style
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../../../style/utils");
|
|
17
17
|
|
|
18
|
+
var _flatTable = require("../flat-table.component");
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -39,6 +41,9 @@ const FlatTableHeader = ({
|
|
|
39
41
|
...rest
|
|
40
42
|
}) => {
|
|
41
43
|
const ref = (0, _react.useRef)(null);
|
|
44
|
+
const {
|
|
45
|
+
colorTheme
|
|
46
|
+
} = (0, _react.useContext)(_flatTable.FlatTableThemeContext);
|
|
42
47
|
(0, _react.useLayoutEffect)(() => {
|
|
43
48
|
if (ref.current && reportCellWidth) {
|
|
44
49
|
reportCellWidth(ref.current.offsetWidth, cellIndex);
|
|
@@ -49,6 +54,7 @@ const FlatTableHeader = ({
|
|
|
49
54
|
leftPosition: leftPosition || 0,
|
|
50
55
|
makeCellSticky: !!reportCellWidth,
|
|
51
56
|
align: align,
|
|
57
|
+
colorTheme: colorTheme,
|
|
52
58
|
"data-element": "flat-table-header",
|
|
53
59
|
colSpan: colspan,
|
|
54
60
|
rowSpan: rowspan,
|
|
@@ -9,6 +9,10 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
9
9
|
|
|
10
10
|
var _styledSystem = require("styled-system");
|
|
11
11
|
|
|
12
|
+
var _flatTableHeaderUtils = _interopRequireDefault(require("./flat-table-header-utils"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
12
16
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
13
17
|
|
|
14
18
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -25,7 +29,8 @@ const StyledFlatTableHeader = _styledComponents.default.th`
|
|
|
25
29
|
colWidth,
|
|
26
30
|
leftPosition,
|
|
27
31
|
makeCellSticky,
|
|
28
|
-
verticalBorder
|
|
32
|
+
verticalBorder,
|
|
33
|
+
colorTheme
|
|
29
34
|
}) => (0, _styledComponents.css)`
|
|
30
35
|
background-color: transparent;
|
|
31
36
|
border-width: 0;
|
|
@@ -60,11 +65,11 @@ const StyledFlatTableHeader = _styledComponents.default.th`
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
${alternativeBgColor && (0, _styledComponents.css)`
|
|
63
|
-
&&&:first-child {
|
|
64
|
-
border-left: 1px solid var(--colorsActionMinor550);
|
|
65
|
-
}
|
|
66
68
|
&&& {
|
|
67
|
-
background-color:
|
|
69
|
+
background-color: ${(0, _flatTableHeaderUtils.default)(colorTheme)};
|
|
70
|
+
}
|
|
71
|
+
&&&:first-child {
|
|
72
|
+
border-left: unset;
|
|
68
73
|
}
|
|
69
74
|
`};
|
|
70
75
|
|