carbon-react 119.12.2 → 120.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/esm/__internal__/input/input-presentation.style.d.ts +1 -1
- package/esm/__spec_helper__/test-utils.d.ts +3 -2
- package/esm/__spec_helper__/test-utils.js +15 -1
- package/esm/components/box/box.component.d.ts +23 -6
- package/esm/components/box/box.component.js +3570 -103
- package/esm/components/box/box.style.d.ts +3 -0
- package/esm/components/box/box.style.js +112 -0
- package/esm/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/esm/components/drawer/drawer.style.d.ts +2 -1
- package/esm/components/duelling-picklist/picklist/picklist.style.js +4 -2
- package/esm/components/flat-table/__internal__/build-position-map.d.ts +2 -0
- package/esm/components/flat-table/__internal__/build-position-map.js +14 -0
- package/esm/components/flat-table/__internal__/index.d.ts +2 -0
- package/esm/components/flat-table/__internal__/index.js +2 -0
- package/esm/components/flat-table/__internal__/use-calculate-sticky-cells.d.ts +12 -0
- package/esm/components/flat-table/__internal__/use-calculate-sticky-cells.js +28 -0
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +2 -41
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +26 -25
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +7 -2
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +3 -25
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +21 -14
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +3 -1
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.d.ts +4 -0
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.js +21 -24
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.d.ts +2 -26
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +15 -13
- package/esm/components/flat-table/flat-table-header/flat-table-header.style.d.ts +3 -1
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +12 -0
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-context.js +6 -0
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +3 -1
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +17 -3
- package/esm/components/flat-table/flat-table-row/__internal__/sub-row-provider.d.ts +15 -0
- package/esm/components/flat-table/flat-table-row/__internal__/sub-row-provider.js +28 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.d.ts +1 -15
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +85 -74
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.d.ts +4 -1
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +1 -9
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +4 -42
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +33 -20
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +7 -1
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +5 -1
- package/esm/components/flat-table/flat-table.component.js +24 -7
- package/esm/components/flat-table/flat-table.style.js +2 -2
- package/esm/components/heading/heading.style.d.ts +4 -9
- package/esm/components/menu/menu-full-screen/menu-full-screen.style.js +2 -2
- package/esm/components/menu/scrollable-block/scrollable-block.style.js +2 -2
- package/esm/components/typography/typography.component.d.ts +25 -15
- package/esm/components/typography/typography.component.js +37 -184
- package/esm/components/typography/typography.style.d.ts +12 -0
- package/esm/components/typography/typography.style.js +190 -0
- package/esm/components/vertical-menu/vertical-menu.style.js +3 -3
- package/esm/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-flexbox-props.js +5 -0
- package/esm/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-grid-props.js +5 -0
- package/esm/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-layout-props.js +5 -0
- package/esm/style/utils/index.d.ts +4 -1
- package/esm/style/utils/index.js +4 -1
- package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
- package/lib/__spec_helper__/test-utils.d.ts +3 -2
- package/lib/__spec_helper__/test-utils.js +16 -1
- package/lib/components/box/box.component.d.ts +23 -6
- package/lib/components/box/box.component.js +3569 -105
- package/lib/components/box/box.style.d.ts +3 -0
- package/lib/components/box/box.style.js +122 -0
- package/lib/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/lib/components/drawer/drawer.style.d.ts +2 -1
- package/lib/components/duelling-picklist/picklist/picklist.style.js +2 -1
- package/lib/components/flat-table/__internal__/build-position-map.d.ts +2 -0
- package/lib/components/flat-table/__internal__/build-position-map.js +21 -0
- package/lib/components/flat-table/__internal__/index.d.ts +2 -0
- package/lib/components/flat-table/__internal__/index.js +20 -0
- package/lib/components/flat-table/__internal__/package.json +6 -0
- package/lib/components/flat-table/__internal__/use-calculate-sticky-cells.d.ts +12 -0
- package/lib/components/flat-table/__internal__/use-calculate-sticky-cells.js +36 -0
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +2 -41
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +25 -24
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +7 -2
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +3 -25
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +20 -13
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +3 -1
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.d.ts +4 -0
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +23 -25
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.d.ts +2 -26
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +14 -12
- package/lib/components/flat-table/flat-table-header/flat-table-header.style.d.ts +3 -1
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +12 -0
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-context.js +13 -0
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +3 -1
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +17 -3
- package/lib/components/flat-table/flat-table-row/__internal__/sub-row-provider.d.ts +15 -0
- package/lib/components/flat-table/flat-table-row/__internal__/sub-row-provider.js +38 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.d.ts +1 -15
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +84 -73
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.d.ts +4 -1
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +1 -9
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +4 -42
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +32 -19
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +7 -1
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +5 -1
- package/lib/components/flat-table/flat-table.component.js +24 -7
- package/lib/components/flat-table/flat-table.style.js +1 -1
- package/lib/components/heading/heading.style.d.ts +4 -9
- package/lib/components/menu/menu-full-screen/menu-full-screen.style.js +1 -1
- package/lib/components/menu/scrollable-block/scrollable-block.style.js +1 -1
- package/lib/components/typography/typography.component.d.ts +25 -15
- package/lib/components/typography/typography.component.js +39 -187
- package/lib/components/typography/typography.style.d.ts +12 -0
- package/lib/components/typography/typography.style.js +200 -0
- package/lib/components/vertical-menu/vertical-menu.style.js +1 -1
- package/lib/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-flexbox-props.js +14 -0
- package/lib/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-grid-props.js +14 -0
- package/lib/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-layout-props.js +14 -0
- package/lib/style/utils/index.d.ts +4 -1
- package/lib/style/utils/index.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
var _styledSystem = require("styled-system");
|
|
9
|
+
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
|
+
var _color = _interopRequireDefault(require("../../style/utils/color"));
|
|
11
|
+
var _box = _interopRequireDefault(require("./box.config"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
15
|
+
const calculatePosition = props => {
|
|
16
|
+
const {
|
|
17
|
+
position,
|
|
18
|
+
...rest
|
|
19
|
+
} = (0, _styledSystem.position)(props);
|
|
20
|
+
return {
|
|
21
|
+
position,
|
|
22
|
+
zIndex: ["sticky", "fixed"].includes(position) ? 1 : undefined,
|
|
23
|
+
...rest
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const StyledBox = _styledComponents.default.div`
|
|
27
|
+
${_styledSystem.space}
|
|
28
|
+
${_styledSystem.layout}
|
|
29
|
+
${_styledSystem.flexbox}
|
|
30
|
+
${_styledSystem.grid}
|
|
31
|
+
${calculatePosition}
|
|
32
|
+
|
|
33
|
+
${({
|
|
34
|
+
theme,
|
|
35
|
+
borderRadius = "borderRadius000"
|
|
36
|
+
}) => !theme.roundedCornersOptOut && (0, _styledComponents.css)`
|
|
37
|
+
border-radius: var(--${borderRadius});
|
|
38
|
+
`}
|
|
39
|
+
|
|
40
|
+
${({
|
|
41
|
+
color,
|
|
42
|
+
bg,
|
|
43
|
+
backgroundColor,
|
|
44
|
+
...rest
|
|
45
|
+
}) => (0, _color.default)({
|
|
46
|
+
color,
|
|
47
|
+
bg,
|
|
48
|
+
backgroundColor,
|
|
49
|
+
...rest
|
|
50
|
+
})}
|
|
51
|
+
|
|
52
|
+
${({
|
|
53
|
+
overflowWrap
|
|
54
|
+
}) => overflowWrap && (0, _styledComponents.css)`
|
|
55
|
+
overflow-wrap: ${overflowWrap};
|
|
56
|
+
`}
|
|
57
|
+
|
|
58
|
+
${({
|
|
59
|
+
height
|
|
60
|
+
}) => height && (0, _styledComponents.css)`
|
|
61
|
+
height: ${height};
|
|
62
|
+
`}
|
|
63
|
+
|
|
64
|
+
${({
|
|
65
|
+
width
|
|
66
|
+
}) => width && (0, _styledComponents.css)`
|
|
67
|
+
width: ${width};
|
|
68
|
+
`}
|
|
69
|
+
|
|
70
|
+
${({
|
|
71
|
+
scrollVariant
|
|
72
|
+
}) => scrollVariant && (0, _styledComponents.css)`
|
|
73
|
+
scrollbar-color: ${_box.default[scrollVariant].thumb}
|
|
74
|
+
${_box.default[scrollVariant].track};
|
|
75
|
+
|
|
76
|
+
&::-webkit-scrollbar {
|
|
77
|
+
width: 8px;
|
|
78
|
+
}
|
|
79
|
+
&::-webkit-scrollbar-track {
|
|
80
|
+
background-color: ${_box.default[scrollVariant].track};
|
|
81
|
+
}
|
|
82
|
+
&::-webkit-scrollbar-thumb {
|
|
83
|
+
background-color: ${_box.default[scrollVariant].thumb};
|
|
84
|
+
}
|
|
85
|
+
`}
|
|
86
|
+
|
|
87
|
+
${({
|
|
88
|
+
boxSizing
|
|
89
|
+
}) => boxSizing && (0, _styledComponents.css)`
|
|
90
|
+
box-sizing: ${boxSizing};
|
|
91
|
+
`}
|
|
92
|
+
|
|
93
|
+
${({
|
|
94
|
+
display,
|
|
95
|
+
gap,
|
|
96
|
+
columnGap,
|
|
97
|
+
rowGap
|
|
98
|
+
}) => (display === "flex" || display === "inline-flex" || display === "grid" || display === "inline-grid") && (0, _styledComponents.css)`
|
|
99
|
+
${gap !== undefined && (0, _styledComponents.css)`
|
|
100
|
+
gap: ${_box.default.gap(gap)};
|
|
101
|
+
`}
|
|
102
|
+
|
|
103
|
+
${columnGap !== undefined && (0, _styledComponents.css)`
|
|
104
|
+
column-gap: ${_box.default.gap(columnGap)};
|
|
105
|
+
`}
|
|
106
|
+
|
|
107
|
+
${rowGap !== undefined && (0, _styledComponents.css)`
|
|
108
|
+
row-gap: ${_box.default.gap(rowGap)};
|
|
109
|
+
`}
|
|
110
|
+
`};
|
|
111
|
+
|
|
112
|
+
${({
|
|
113
|
+
boxShadow
|
|
114
|
+
}) => boxShadow && (0, _styledComponents.css)`
|
|
115
|
+
box-shadow: var(--${boxShadow});
|
|
116
|
+
`}
|
|
117
|
+
`;
|
|
118
|
+
StyledBox.defaultProps = {
|
|
119
|
+
theme: _base.default
|
|
120
|
+
};
|
|
121
|
+
var _default = StyledBox;
|
|
122
|
+
exports.default = _default;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export interface StyledDismissibleBoxProps {
|
|
2
3
|
/** Flag to control whether the thicker left border highlight should be rendered */
|
|
3
4
|
hasBorderLeftHighlight?: boolean;
|
|
4
5
|
/** Set the base color variant */
|
|
5
6
|
variant?: "light" | "dark";
|
|
6
7
|
}
|
|
7
|
-
declare const StyledDismissibleBox: import("styled-components").StyledComponent<"
|
|
8
|
+
declare const StyledDismissibleBox: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../box").BoxProps & import("react").RefAttributes<HTMLDivElement>>, any, StyledDismissibleBoxProps, never>;
|
|
8
9
|
export { StyledDismissibleBox };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare const StyledSidebarHeader: import("styled-components").StyledComponent<"div", any, {
|
|
2
3
|
isExpanded?: boolean | undefined;
|
|
3
4
|
}, never>;
|
|
@@ -7,7 +8,7 @@ interface StyledDrawerSidebarProps {
|
|
|
7
8
|
isExpanded?: boolean;
|
|
8
9
|
hasControls: boolean;
|
|
9
10
|
}
|
|
10
|
-
declare const StyledDrawerSidebar: import("styled-components").StyledComponent<"
|
|
11
|
+
declare const StyledDrawerSidebar: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../box").BoxProps & import("react").RefAttributes<HTMLDivElement>>, any, StyledDrawerSidebarProps, never>;
|
|
11
12
|
interface StyledDrawerContentProps {
|
|
12
13
|
animationDuration?: string;
|
|
13
14
|
backgroundColor?: string;
|
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.StyledPicklist = exports.StyledEmptyContainer = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
|
-
var _box = _interopRequireDefault(require("../../box"));
|
|
8
|
+
var _box = _interopRequireDefault(require("../../box/box.style"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
// TODO: remove polymorphism when we revisit as part of ticket FE-6177
|
|
10
11
|
const StyledPicklist = (0, _styledComponents.default)(_box.default).attrs({
|
|
11
12
|
as: "ul"
|
|
12
13
|
})`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = (array, propertyName) => array.reduce((acc, _, index) => {
|
|
8
|
+
const currentId = array[index].getAttribute("id");
|
|
9
|
+
if (currentId) {
|
|
10
|
+
if (index === 0) {
|
|
11
|
+
acc[currentId] = 0;
|
|
12
|
+
} else {
|
|
13
|
+
const previousId = array[index - 1].getAttribute("id");
|
|
14
|
+
if (previousId) {
|
|
15
|
+
acc[currentId] = acc[previousId] + array[index - 1][propertyName];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
21
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "buildPositionMap", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _buildPositionMap.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useCalculateStickyCells", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _useCalculateStickyCells.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _useCalculateStickyCells = _interopRequireDefault(require("./use-calculate-sticky-cells"));
|
|
19
|
+
var _buildPositionMap = _interopRequireDefault(require("./build-position-map"));
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: (id: string) => {
|
|
3
|
+
expandable: boolean | undefined;
|
|
4
|
+
leftPosition: number;
|
|
5
|
+
rightPosition: number;
|
|
6
|
+
makeCellSticky: boolean;
|
|
7
|
+
onClick: ((ev?: import("react").MouseEvent<HTMLElement, MouseEvent> | undefined) => void) | undefined;
|
|
8
|
+
onKeyDown: ((ev: import("react").KeyboardEvent<HTMLElement>) => void) | undefined;
|
|
9
|
+
isFirstCell: boolean;
|
|
10
|
+
isExpandableCell: boolean | undefined;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _flatTableRowContext = _interopRequireDefault(require("../flat-table-row/__internal__/flat-table-row-context"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
var _default = id => {
|
|
11
|
+
const {
|
|
12
|
+
expandable,
|
|
13
|
+
firstCellId,
|
|
14
|
+
firstColumnExpandable,
|
|
15
|
+
leftPositions,
|
|
16
|
+
rightPositions,
|
|
17
|
+
onClick,
|
|
18
|
+
onKeyDown
|
|
19
|
+
} = (0, _react.useContext)(_flatTableRowContext.default);
|
|
20
|
+
const leftPosition = leftPositions[id];
|
|
21
|
+
const rightPosition = rightPositions[id];
|
|
22
|
+
const makeCellSticky = leftPosition !== undefined || rightPosition !== undefined;
|
|
23
|
+
const isFirstCell = id === firstCellId;
|
|
24
|
+
const isExpandableCell = expandable && isFirstCell && firstColumnExpandable;
|
|
25
|
+
return {
|
|
26
|
+
expandable,
|
|
27
|
+
leftPosition,
|
|
28
|
+
rightPosition,
|
|
29
|
+
makeCellSticky,
|
|
30
|
+
onClick,
|
|
31
|
+
onKeyDown,
|
|
32
|
+
isFirstCell,
|
|
33
|
+
isExpandableCell
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.default = _default;
|
|
@@ -20,50 +20,11 @@ export interface FlatTableCellProps extends PaddingProps {
|
|
|
20
20
|
verticalBorder?: TableBorderSize;
|
|
21
21
|
/** Sets the color of the right border */
|
|
22
22
|
verticalBorderColor?: string;
|
|
23
|
-
/** Sets an id string on the
|
|
23
|
+
/** Sets an id string on the element */
|
|
24
24
|
id?: string;
|
|
25
|
-
/**
|
|
26
|
-
* @private
|
|
27
|
-
* @ignore
|
|
28
|
-
*/
|
|
29
|
-
expandable?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* @private
|
|
32
|
-
* @ignore
|
|
33
|
-
*/
|
|
34
|
-
onClick?: () => void;
|
|
35
|
-
/**
|
|
36
|
-
* @private
|
|
37
|
-
* @ignore
|
|
38
|
-
*/
|
|
39
|
-
onKeyDown?: () => void;
|
|
40
|
-
/**
|
|
41
|
-
* @private
|
|
42
|
-
* @ignore
|
|
43
|
-
* Sets the left position when sticky column found
|
|
44
|
-
*/
|
|
45
|
-
leftPosition?: number;
|
|
46
|
-
/**
|
|
47
|
-
* @private
|
|
48
|
-
* @ignore
|
|
49
|
-
* Sets the right position when sticky column found
|
|
50
|
-
*/
|
|
51
|
-
rightPosition?: number;
|
|
52
|
-
/**
|
|
53
|
-
* @private
|
|
54
|
-
* @ignore
|
|
55
|
-
* Index of cell within row
|
|
56
|
-
*/
|
|
57
|
-
cellIndex?: number;
|
|
58
|
-
/**
|
|
59
|
-
* @private
|
|
60
|
-
* @ignore
|
|
61
|
-
* Callback to report the offsetWidth
|
|
62
|
-
*/
|
|
63
|
-
reportCellWidth?: (offset: number, index?: number) => void;
|
|
64
25
|
}
|
|
65
26
|
export declare const FlatTableCell: {
|
|
66
|
-
({ align, children, pl,
|
|
27
|
+
({ align, children, pl, width, truncate, title, colspan, rowspan, id, ...rest }: FlatTableCellProps): React.JSX.Element;
|
|
67
28
|
displayName: string;
|
|
68
29
|
};
|
|
69
30
|
export default FlatTableCell;
|
|
@@ -10,6 +10,7 @@ var _flatTableCell = require("./flat-table-cell.style");
|
|
|
10
10
|
var _icon = _interopRequireDefault(require("../../icon"));
|
|
11
11
|
var _flatTable = require("../flat-table.component");
|
|
12
12
|
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
13
|
+
var _useCalculateStickyCells = _interopRequireDefault(require("../__internal__/use-calculate-sticky-cells"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
@@ -18,58 +19,58 @@ const FlatTableCell = ({
|
|
|
18
19
|
align = "left",
|
|
19
20
|
children,
|
|
20
21
|
pl,
|
|
21
|
-
expandable = false,
|
|
22
|
-
onClick,
|
|
23
|
-
onKeyDown,
|
|
24
|
-
reportCellWidth,
|
|
25
|
-
cellIndex,
|
|
26
|
-
leftPosition,
|
|
27
|
-
rightPosition,
|
|
28
22
|
width,
|
|
29
23
|
truncate = false,
|
|
30
24
|
title,
|
|
31
25
|
colspan,
|
|
32
26
|
rowspan,
|
|
27
|
+
id,
|
|
33
28
|
...rest
|
|
34
29
|
}) => {
|
|
35
30
|
const ref = (0, _react.useRef)(null);
|
|
36
|
-
const
|
|
31
|
+
const internalId = (0, _react.useRef)(id || (0, _guid.default)());
|
|
37
32
|
const [tabIndex, setTabIndex] = (0, _react.useState)(-1);
|
|
38
33
|
const {
|
|
39
34
|
selectedId
|
|
40
35
|
} = (0, _react.useContext)(_flatTable.FlatTableThemeContext);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
const {
|
|
37
|
+
leftPosition,
|
|
38
|
+
rightPosition,
|
|
39
|
+
expandable,
|
|
40
|
+
onClick,
|
|
41
|
+
onKeyDown,
|
|
42
|
+
isFirstCell,
|
|
43
|
+
isExpandableCell,
|
|
44
|
+
makeCellSticky
|
|
45
|
+
} = (0, _useCalculateStickyCells.default)(internalId.current);
|
|
46
46
|
(0, _react.useEffect)(() => {
|
|
47
|
-
setTabIndex(selectedId ===
|
|
48
|
-
}, [selectedId]);
|
|
47
|
+
setTabIndex(isExpandableCell && selectedId === internalId.current ? 0 : -1);
|
|
48
|
+
}, [selectedId, isExpandableCell]);
|
|
49
49
|
return /*#__PURE__*/_react.default.createElement(_flatTableCell.StyledFlatTableCell, _extends({
|
|
50
50
|
leftPosition: leftPosition,
|
|
51
51
|
rightPosition: rightPosition,
|
|
52
|
-
makeCellSticky:
|
|
53
|
-
className:
|
|
52
|
+
makeCellSticky: makeCellSticky,
|
|
53
|
+
className: makeCellSticky ? "isSticky" : undefined,
|
|
54
54
|
ref: ref,
|
|
55
55
|
align: align,
|
|
56
56
|
"data-element": "flat-table-cell",
|
|
57
57
|
pl: pl,
|
|
58
|
-
onClick:
|
|
59
|
-
tabIndex:
|
|
60
|
-
onKeyDown:
|
|
58
|
+
onClick: isExpandableCell ? onClick : undefined,
|
|
59
|
+
tabIndex: isExpandableCell ? tabIndex : undefined,
|
|
60
|
+
onKeyDown: isExpandableCell ? onKeyDown : undefined,
|
|
61
61
|
colWidth: width,
|
|
62
62
|
isTruncated: truncate,
|
|
63
|
-
expandable: expandable
|
|
64
|
-
id: id.current
|
|
63
|
+
expandable: expandable
|
|
65
64
|
}, colspan !== undefined && {
|
|
66
65
|
colSpan: Number(colspan)
|
|
67
66
|
}, rowspan !== undefined && {
|
|
68
67
|
rowSpan: Number(rowspan)
|
|
69
|
-
}, rest
|
|
68
|
+
}, rest, {
|
|
69
|
+
id: internalId.current
|
|
70
|
+
}), /*#__PURE__*/_react.default.createElement(_flatTableCell.StyledCellContent, {
|
|
70
71
|
title: truncate && !title && typeof children === "string" ? children : title,
|
|
71
72
|
expandable: expandable
|
|
72
|
-
}, expandable && /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
73
|
+
}, expandable && isFirstCell && /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
73
74
|
type: "chevron_down_thick",
|
|
74
75
|
bgSize: "extra-small",
|
|
75
76
|
mr: "8px"
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { PaddingProps } from "styled-system";
|
|
2
2
|
import { FlatTableCellProps } from "./flat-table-cell.component";
|
|
3
|
-
interface StyledFlatTableCellProps extends Pick<FlatTableCellProps, "align" | "
|
|
3
|
+
interface StyledFlatTableCellProps extends Pick<FlatTableCellProps, "align" | "verticalBorder" | "verticalBorderColor">, PaddingProps {
|
|
4
4
|
makeCellSticky: boolean;
|
|
5
5
|
colWidth?: number;
|
|
6
6
|
isTruncated: boolean;
|
|
7
|
+
leftPosition: number;
|
|
8
|
+
rightPosition: number;
|
|
9
|
+
expandable?: boolean;
|
|
7
10
|
}
|
|
8
11
|
declare const StyledFlatTableCell: import("styled-components").StyledComponent<"td", any, StyledFlatTableCellProps, never>;
|
|
9
|
-
declare const StyledCellContent: import("styled-components").StyledComponent<"div", any,
|
|
12
|
+
declare const StyledCellContent: import("styled-components").StyledComponent<"div", any, {
|
|
13
|
+
expandable?: boolean | undefined;
|
|
14
|
+
}, never>;
|
|
10
15
|
export { StyledFlatTableCell, StyledCellContent };
|
|
@@ -13,33 +13,11 @@ export interface FlatTableCheckboxProps extends TagProps {
|
|
|
13
13
|
onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
14
14
|
/** The id of the element that labels the input */
|
|
15
15
|
ariaLabelledBy?: string;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
* @ignore
|
|
19
|
-
* Sets the left position when sticky column found
|
|
20
|
-
*/
|
|
21
|
-
leftPosition?: number;
|
|
22
|
-
/**
|
|
23
|
-
* @private
|
|
24
|
-
* @ignore
|
|
25
|
-
* Sets the right position when sticky column found
|
|
26
|
-
*/
|
|
27
|
-
rightPosition?: number;
|
|
28
|
-
/**
|
|
29
|
-
* @private
|
|
30
|
-
* @ignore
|
|
31
|
-
* Index of cell within row
|
|
32
|
-
*/
|
|
33
|
-
cellIndex?: number;
|
|
34
|
-
/**
|
|
35
|
-
* @private
|
|
36
|
-
* @ignore
|
|
37
|
-
* Callback to report the offsetWidth
|
|
38
|
-
*/
|
|
39
|
-
reportCellWidth?: (offset: number, index?: number) => void;
|
|
16
|
+
/** Sets an id string on the element */
|
|
17
|
+
id?: string;
|
|
40
18
|
}
|
|
41
19
|
export declare const FlatTableCheckbox: {
|
|
42
|
-
({ as, checked, onChange, selectable, onClick,
|
|
20
|
+
({ as, checked, onChange, selectable, onClick, ariaLabelledBy, id, ...rest }: FlatTableCheckboxProps): React.JSX.Element;
|
|
43
21
|
displayName: string;
|
|
44
22
|
};
|
|
45
23
|
export default FlatTableCheckbox;
|
|
@@ -9,6 +9,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _flatTableCheckbox = _interopRequireDefault(require("./flat-table-checkbox.style"));
|
|
10
10
|
var _checkbox = require("../../checkbox");
|
|
11
11
|
var _events = _interopRequireDefault(require("../../../__internal__/utils/helpers/events/events"));
|
|
12
|
+
var _tags = _interopRequireDefault(require("../../../__internal__/utils/helpers/tags"));
|
|
13
|
+
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
14
|
+
var _flatTableRowContext = _interopRequireDefault(require("../flat-table-row/__internal__/flat-table-row-context"));
|
|
12
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
@@ -19,19 +22,19 @@ const FlatTableCheckbox = ({
|
|
|
19
22
|
onChange,
|
|
20
23
|
selectable = true,
|
|
21
24
|
onClick,
|
|
22
|
-
leftPosition,
|
|
23
|
-
rightPosition,
|
|
24
|
-
cellIndex,
|
|
25
|
-
reportCellWidth,
|
|
26
25
|
ariaLabelledBy,
|
|
26
|
+
id,
|
|
27
27
|
...rest
|
|
28
28
|
}) => {
|
|
29
29
|
const ref = (0, _react.useRef)(null);
|
|
30
|
-
(0, _react.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
30
|
+
const internalId = (0, _react.useRef)(id || (0, _guid.default)());
|
|
31
|
+
const {
|
|
32
|
+
leftPositions,
|
|
33
|
+
rightPositions
|
|
34
|
+
} = (0, _react.useContext)(_flatTableRowContext.default);
|
|
35
|
+
const leftPosition = leftPositions[internalId.current];
|
|
36
|
+
const rightPosition = rightPositions[internalId.current];
|
|
37
|
+
const makeCellSticky = leftPosition !== undefined || rightPosition !== undefined;
|
|
35
38
|
const dataElement = `flat-table-checkbox-${as === "td" ? "cell" : "header"}`;
|
|
36
39
|
const handleClick = event => {
|
|
37
40
|
event.stopPropagation();
|
|
@@ -44,13 +47,17 @@ const FlatTableCheckbox = ({
|
|
|
44
47
|
};
|
|
45
48
|
return /*#__PURE__*/_react.default.createElement(_flatTableCheckbox.default, _extends({
|
|
46
49
|
ref: ref,
|
|
47
|
-
makeCellSticky:
|
|
48
|
-
className:
|
|
50
|
+
makeCellSticky: makeCellSticky,
|
|
51
|
+
className: makeCellSticky ? "isSticky" : undefined,
|
|
49
52
|
leftPosition: leftPosition,
|
|
50
53
|
rightPosition: rightPosition,
|
|
51
|
-
"data-element": dataElement,
|
|
52
54
|
as: as
|
|
53
|
-
},
|
|
55
|
+
}, (0, _tags.default)("flat-table-checkbox", {
|
|
56
|
+
"data-element": dataElement,
|
|
57
|
+
...rest
|
|
58
|
+
}), {
|
|
59
|
+
id: internalId.current
|
|
60
|
+
}), selectable && /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
54
61
|
checked: checked,
|
|
55
62
|
onChange: onChange,
|
|
56
63
|
name: "flat-table-checkbox",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FlatTableCheckboxProps } from "./flat-table-checkbox.component";
|
|
2
|
-
interface StyledFlatTableCheckboxProps extends Pick<FlatTableCheckboxProps, "as"
|
|
2
|
+
interface StyledFlatTableCheckboxProps extends Pick<FlatTableCheckboxProps, "as"> {
|
|
3
3
|
makeCellSticky: boolean;
|
|
4
|
+
leftPosition: number;
|
|
5
|
+
rightPosition: number;
|
|
4
6
|
}
|
|
5
7
|
declare const StyledFlatTableCheckbox: import("styled-components").StyledComponent<"td", any, StyledFlatTableCheckboxProps, never>;
|
|
6
8
|
export default StyledFlatTableCheckbox;
|
|
@@ -3,5 +3,9 @@ export interface FlatTableHeadProps {
|
|
|
3
3
|
/** Array of FlatTableRow. */
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
}
|
|
6
|
+
interface FlatTableHeadContextProps {
|
|
7
|
+
stickyOffsets: Record<string, number>;
|
|
8
|
+
}
|
|
9
|
+
export declare const FlatTableHeadContext: React.Context<FlatTableHeadContextProps>;
|
|
6
10
|
export declare const FlatTableHead: ({ children, ...rest }: FlatTableHeadProps) => React.JSX.Element;
|
|
7
11
|
export default FlatTableHead;
|
|
@@ -3,44 +3,42 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.FlatTableHead = void 0;
|
|
6
|
+
exports.default = exports.FlatTableHeadContext = exports.FlatTableHead = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _flatTableHead = _interopRequireDefault(require("./flat-table-head.style"));
|
|
10
|
-
var
|
|
10
|
+
var _internal__ = require("../__internal__");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
14
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
15
|
+
const FlatTableHeadContext = /*#__PURE__*/_react.default.createContext({
|
|
16
|
+
stickyOffsets: {}
|
|
17
|
+
});
|
|
18
|
+
exports.FlatTableHeadContext = FlatTableHeadContext;
|
|
17
19
|
const FlatTableHead = ({
|
|
18
20
|
children,
|
|
19
21
|
...rest
|
|
20
22
|
}) => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
let hasFlatTableRowHeader;
|
|
23
|
+
const ref = (0, _react.useRef)(null);
|
|
24
|
+
const [stickyOffsets, setStickyOffsets] = (0, _react.useState)({});
|
|
24
25
|
(0, _react.useEffect)(() => {
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const headerRows = ref.current?.querySelectorAll("tr");
|
|
27
|
+
|
|
28
|
+
/* istanbul ignore else */
|
|
29
|
+
if (headerRows) {
|
|
30
|
+
setStickyOffsets((0, _internal__.buildPositionMap)(Array.from(headerRows), "offsetHeight"));
|
|
31
|
+
} else {
|
|
32
|
+
setStickyOffsets({});
|
|
27
33
|
}
|
|
28
34
|
}, [children]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const previousRowHasHeader = !!hasFlatTableRowHeader;
|
|
37
|
-
hasFlatTableRowHeader = /*#__PURE__*/_react.default.isValidElement(child) && !!_react.default.Children.toArray(child.props.children).find(c => /*#__PURE__*/_react.default.isValidElement(c) && c.type.displayName === _flatTableRowHeader.default.displayName);
|
|
38
|
-
return /*#__PURE__*/_react.default.isValidElement(child) && /*#__PURE__*/_react.default.cloneElement(child, {
|
|
39
|
-
stickyOffset: rowHeights.slice(0, index).reduce((a, b) => a + b, 0),
|
|
40
|
-
ref: refs.current[index],
|
|
41
|
-
applyBorderLeft: previousRowHasHeader && !hasFlatTableRowHeader
|
|
42
|
-
});
|
|
43
|
-
}));
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_flatTableHead.default, _extends({
|
|
36
|
+
ref: ref
|
|
37
|
+
}, rest), /*#__PURE__*/_react.default.createElement(FlatTableHeadContext.Provider, {
|
|
38
|
+
value: {
|
|
39
|
+
stickyOffsets
|
|
40
|
+
}
|
|
41
|
+
}, children));
|
|
44
42
|
};
|
|
45
43
|
exports.FlatTableHead = FlatTableHead;
|
|
46
44
|
var _default = FlatTableHead;
|