carbon-react 119.4.0 → 119.4.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/__spec_helper__/mock-resize-observer.js +20 -5
- package/esm/__spec_helper__/test-utils.d.ts +1 -1
- package/esm/components/flat-table/cell-sizes.style.d.ts +28 -0
- package/esm/components/flat-table/flat-table-body/flat-table-body.component.d.ts +7 -0
- package/esm/components/flat-table/flat-table-body/flat-table-body.component.js +3 -2
- package/esm/components/flat-table/flat-table-body/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +9 -0
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +6 -16
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +4 -0
- package/esm/components/flat-table/flat-table-body-draggable/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +69 -0
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +7 -69
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +10 -0
- package/esm/components/flat-table/flat-table-cell/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +45 -0
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -39
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +6 -0
- package/esm/components/flat-table/flat-table-checkbox/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.d.ts +7 -0
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.js +8 -13
- package/esm/components/flat-table/flat-table-head/flat-table-head.style.d.ts +2 -0
- package/esm/components/flat-table/flat-table-head/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table-header/flat-table-header-utils.d.ts +3 -0
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.d.ts +55 -0
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +7 -49
- package/esm/components/flat-table/flat-table-header/flat-table-header.style.d.ts +10 -0
- package/esm/components/flat-table/flat-table-header/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +18 -0
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +13 -19
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.d.ts +56 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +43 -67
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.d.ts +18 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +2 -3
- package/esm/components/flat-table/flat-table-row/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +71 -0
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +9 -51
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +6 -0
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +7 -7
- package/esm/components/flat-table/flat-table-row-header/index.d.ts +2 -2
- package/esm/components/flat-table/flat-table.component.d.ts +42 -0
- package/esm/components/flat-table/flat-table.component.js +51 -92
- package/esm/components/flat-table/flat-table.config.d.ts +2 -0
- package/esm/components/flat-table/flat-table.style.d.ts +15 -0
- package/esm/components/flat-table/flat-table.style.js +36 -59
- package/esm/components/flat-table/index.d.ts +22 -13
- package/esm/components/flat-table/sort/index.d.ts +2 -2
- package/esm/components/flat-table/sort/sort.component.d.ts +11 -0
- package/esm/components/flat-table/sort/sort.component.js +1 -10
- package/esm/components/flat-table/sort/sort.style.d.ts +4 -0
- package/esm/components/global-header/global-header.component.js +6 -29
- package/esm/components/menu/__internal__/submenu/submenu.component.js +6 -1
- package/esm/components/menu/__internal__/submenu/submenu.style.d.ts +1 -0
- package/esm/components/menu/__internal__/submenu/submenu.style.js +4 -1
- package/esm/components/navigation-bar/fixed-navigation-bar.context.d.ts +11 -0
- package/esm/components/navigation-bar/fixed-navigation-bar.context.js +31 -0
- package/esm/components/navigation-bar/navigation-bar.component.d.ts +3 -1
- package/esm/components/navigation-bar/navigation-bar.component.js +20 -8
- package/esm/components/navigation-bar/navigation-bar.style.d.ts +4 -0
- package/esm/components/navigation-bar/navigation-bar.style.js +3 -2
- package/lib/__spec_helper__/mock-resize-observer.js +20 -5
- package/lib/__spec_helper__/test-utils.d.ts +1 -1
- package/lib/components/flat-table/cell-sizes.style.d.ts +28 -0
- package/lib/components/flat-table/flat-table-body/flat-table-body.component.d.ts +7 -0
- package/lib/components/flat-table/flat-table-body/flat-table-body.component.js +4 -3
- package/lib/components/flat-table/flat-table-body/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +9 -0
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +7 -16
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +4 -0
- package/lib/components/flat-table/flat-table-body-draggable/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +69 -0
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +8 -69
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +10 -0
- package/lib/components/flat-table/flat-table-cell/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +45 -0
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +2 -39
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +6 -0
- package/lib/components/flat-table/flat-table-checkbox/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.d.ts +7 -0
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +8 -12
- package/lib/components/flat-table/flat-table-head/flat-table-head.style.d.ts +2 -0
- package/lib/components/flat-table/flat-table-head/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table-header/flat-table-header-utils.d.ts +3 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.d.ts +55 -0
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +8 -49
- package/lib/components/flat-table/flat-table-header/flat-table-header.style.d.ts +10 -0
- package/lib/components/flat-table/flat-table-header/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +18 -0
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +14 -20
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.d.ts +56 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +44 -68
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.d.ts +18 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +2 -3
- package/lib/components/flat-table/flat-table-row/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +71 -0
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +10 -51
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +6 -0
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +7 -7
- package/lib/components/flat-table/flat-table-row-header/index.d.ts +2 -2
- package/lib/components/flat-table/flat-table.component.d.ts +42 -0
- package/lib/components/flat-table/flat-table.component.js +51 -91
- package/lib/components/flat-table/flat-table.config.d.ts +2 -0
- package/lib/components/flat-table/flat-table.style.d.ts +15 -0
- package/lib/components/flat-table/flat-table.style.js +36 -59
- package/lib/components/flat-table/index.d.ts +22 -13
- package/lib/components/flat-table/sort/index.d.ts +2 -2
- package/lib/components/flat-table/sort/sort.component.d.ts +11 -0
- package/lib/components/flat-table/sort/sort.component.js +1 -10
- package/lib/components/flat-table/sort/sort.style.d.ts +4 -0
- package/lib/components/global-header/global-header.component.js +6 -31
- package/lib/components/menu/__internal__/submenu/submenu.component.js +6 -1
- package/lib/components/menu/__internal__/submenu/submenu.style.d.ts +1 -0
- package/lib/components/menu/__internal__/submenu/submenu.style.js +4 -1
- package/lib/components/navigation-bar/fixed-navigation-bar.context.d.ts +11 -0
- package/lib/components/navigation-bar/fixed-navigation-bar.context.js +42 -0
- package/lib/components/navigation-bar/navigation-bar.component.d.ts +3 -1
- package/lib/components/navigation-bar/navigation-bar.component.js +22 -8
- package/lib/components/navigation-bar/navigation-bar.style.d.ts +4 -0
- package/lib/components/navigation-bar/navigation-bar.style.js +3 -2
- package/package.json +1 -1
- package/esm/components/flat-table/flat-table-body/flat-table-body.d.ts +0 -10
- package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.d.ts +0 -14
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.d.ts +0 -28
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.d.ts +0 -20
- package/esm/components/flat-table/flat-table-head/flat-table-head.d.ts +0 -10
- package/esm/components/flat-table/flat-table-header/flat-table-header.d.ts +0 -27
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.d.ts +0 -20
- package/esm/components/flat-table/flat-table-row/flat-table-row.d.ts +0 -31
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +0 -28
- package/esm/components/flat-table/flat-table.d.ts +0 -37
- package/esm/components/flat-table/sort/sort.d.ts +0 -14
- package/lib/components/flat-table/flat-table-body/flat-table-body.d.ts +0 -10
- package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.d.ts +0 -14
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.d.ts +0 -28
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.d.ts +0 -20
- package/lib/components/flat-table/flat-table-head/flat-table-head.d.ts +0 -10
- package/lib/components/flat-table/flat-table-header/flat-table-header.d.ts +0 -27
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.d.ts +0 -20
- package/lib/components/flat-table/flat-table-row/flat-table-row.d.ts +0 -31
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +0 -28
- package/lib/components/flat-table/flat-table.d.ts +0 -37
- package/lib/components/flat-table/sort/sort.d.ts +0 -14
|
@@ -2,10 +2,25 @@ const setupResizeObserverMock = () => {
|
|
|
2
2
|
if (!window) {
|
|
3
3
|
return;
|
|
4
4
|
}
|
|
5
|
-
window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(callback => {
|
|
6
|
+
let hasCalledCallback = false;
|
|
7
|
+
const observer = {
|
|
8
|
+
disconnect: jest.fn(),
|
|
9
|
+
// observe mock needs to actually call the callback straight away, as this is what a real ResizeObserver does
|
|
10
|
+
// and this behaviour is needed for the FixedNavigationBarContextProvider to work properly.
|
|
11
|
+
// Note that we must only call the callback once per ResizeObserver instance, to avoid stack overflows in
|
|
12
|
+
// react-virtual.
|
|
13
|
+
observe: jest.fn(target => {
|
|
14
|
+
if (!hasCalledCallback) {
|
|
15
|
+
hasCalledCallback = true;
|
|
16
|
+
callback([{
|
|
17
|
+
target
|
|
18
|
+
}], observer);
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
unobserve: jest.fn()
|
|
22
|
+
};
|
|
23
|
+
return observer;
|
|
24
|
+
});
|
|
10
25
|
};
|
|
11
26
|
export default setupResizeObserverMock;
|
|
@@ -6,7 +6,7 @@ import { mockMatchMedia } from "./mock-match-media";
|
|
|
6
6
|
declare const toCSSCase: (str: string) => string;
|
|
7
7
|
declare const assertStyleMatch: <Props>(styleSpec: {
|
|
8
8
|
[key: string]: string | number | undefined;
|
|
9
|
-
}, component: ReactWrapper<Props, {}, import("react").Component<{}, {}, any>> | ShallowWrapper<Props, {}, import("react").Component<{}, {}, any>> | ReactTestRendererJSON | ReactTestRendererJSON[] | null, opts?: jest.Options) => void;
|
|
9
|
+
}, component: HTMLElement | ReactWrapper<Props, {}, import("react").Component<{}, {}, any>> | ShallowWrapper<Props, {}, import("react").Component<{}, {}, any>> | ReactTestRendererJSON | ReactTestRendererJSON[] | null, opts?: jest.Options) => void;
|
|
10
10
|
declare const makeArrayKeys: (n: number) => number[];
|
|
11
11
|
declare const keyboard: Record<string, () => void>;
|
|
12
12
|
declare const simulate: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
compact: {
|
|
3
|
+
height: string;
|
|
4
|
+
fontSize: string;
|
|
5
|
+
paddingSize: string;
|
|
6
|
+
};
|
|
7
|
+
small: {
|
|
8
|
+
height: string;
|
|
9
|
+
fontSize: string;
|
|
10
|
+
paddingSize: string;
|
|
11
|
+
};
|
|
12
|
+
medium: {
|
|
13
|
+
height: string;
|
|
14
|
+
fontSize: string;
|
|
15
|
+
paddingSize: string;
|
|
16
|
+
};
|
|
17
|
+
large: {
|
|
18
|
+
height: string;
|
|
19
|
+
fontSize: string;
|
|
20
|
+
paddingSize: string;
|
|
21
|
+
};
|
|
22
|
+
extraLarge: {
|
|
23
|
+
height: string;
|
|
24
|
+
fontSize: string;
|
|
25
|
+
paddingSize: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface FlatTableBodyProps {
|
|
3
|
+
/** Array of FlatTableRow. */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const FlatTableBody: React.ForwardRefExoticComponent<FlatTableBodyProps & React.RefAttributes<HTMLTableSectionElement>>;
|
|
7
|
+
export default FlatTableBody;
|
|
@@ -11,7 +11,8 @@ const FlatTableBody = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
11
11
|
}, rest), children);
|
|
12
12
|
});
|
|
13
13
|
FlatTableBody.propTypes = {
|
|
14
|
-
|
|
15
|
-
children: PropTypes.node.isRequired
|
|
14
|
+
"children": PropTypes.node
|
|
16
15
|
};
|
|
16
|
+
export { FlatTableBody };
|
|
17
|
+
FlatTableBody.displayName = "FlatTableBody";
|
|
17
18
|
export default FlatTableBody;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./flat-table-body";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./flat-table-body.component";
|
|
2
|
+
export type { FlatTableBodyProps } from "./flat-table-body.component";
|
package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface FlatTableBodyDraggableProps {
|
|
3
|
+
/** Array of FlatTableRow. */
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
/** Callback fired when order is changed */
|
|
6
|
+
getOrder?: (draggableItemIds?: number[]) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const FlatTableBodyDraggable: ({ children, getOrder, ...rest }: FlatTableBodyDraggableProps) => React.JSX.Element;
|
|
9
|
+
export default FlatTableBodyDraggable;
|
package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
import React, { useEffect, useState, useRef } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
3
4
|
import { useDrop, DndProvider } from "react-dnd";
|
|
4
5
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
5
|
-
import PropTypes from "prop-types";
|
|
6
6
|
import StyledIcon from "../../icon/icon.style";
|
|
7
7
|
import StyledFlatTableBodyDraggable from "./flat-table-body-draggable.style";
|
|
8
8
|
import FlatTableCell from "../flat-table-cell/flat-table-cell.component";
|
|
@@ -20,7 +20,7 @@ const DropTarget = _ref => {
|
|
|
20
20
|
},
|
|
21
21
|
drop() {
|
|
22
22
|
setIsDragging(false);
|
|
23
|
-
getOrder();
|
|
23
|
+
getOrder?.();
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
return /*#__PURE__*/React.createElement(StyledFlatTableBodyDraggable, _extends({
|
|
@@ -29,11 +29,7 @@ const DropTarget = _ref => {
|
|
|
29
29
|
isDragging: isDragging
|
|
30
30
|
}, rest), children);
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
children: PropTypes.node.isRequired,
|
|
34
|
-
getOrder: PropTypes.func
|
|
35
|
-
};
|
|
36
|
-
const FlatTableBodyDraggable = _ref2 => {
|
|
32
|
+
export const FlatTableBodyDraggable = _ref2 => {
|
|
37
33
|
let {
|
|
38
34
|
children,
|
|
39
35
|
getOrder,
|
|
@@ -49,7 +45,7 @@ const FlatTableBodyDraggable = _ref2 => {
|
|
|
49
45
|
}
|
|
50
46
|
}, [children]);
|
|
51
47
|
const findItem = id => {
|
|
52
|
-
const draggableItem = draggableItems.filter(item => `${item.props.id}` === id)[0];
|
|
48
|
+
const draggableItem = draggableItems.filter(item => /*#__PURE__*/React.isValidElement(item) && `${item.props.id}` === id)[0];
|
|
53
49
|
return {
|
|
54
50
|
draggableItem,
|
|
55
51
|
index: draggableItems.indexOf(draggableItem)
|
|
@@ -70,14 +66,14 @@ const FlatTableBodyDraggable = _ref2 => {
|
|
|
70
66
|
if (!getOrder) {
|
|
71
67
|
return;
|
|
72
68
|
}
|
|
73
|
-
const draggableItemIds = draggableItems.map(draggableItem => draggableItem.props.id);
|
|
69
|
+
const draggableItemIds = draggableItems.map(draggableItem => /*#__PURE__*/React.isValidElement(draggableItem) && draggableItem.props.id);
|
|
74
70
|
getOrder(draggableItemIds);
|
|
75
71
|
};
|
|
76
72
|
return /*#__PURE__*/React.createElement(DndProvider, {
|
|
77
73
|
backend: HTML5Backend
|
|
78
74
|
}, /*#__PURE__*/React.createElement(DropTarget, _extends({
|
|
79
75
|
getOrder: getItemsId
|
|
80
|
-
}, rest), draggableItems.map(item => /*#__PURE__*/React.cloneElement(item, {
|
|
76
|
+
}, rest), draggableItems.map(item => /*#__PURE__*/React.isValidElement(item) && /*#__PURE__*/React.cloneElement(item, {
|
|
81
77
|
id: `${item.props.id}`,
|
|
82
78
|
moveItem,
|
|
83
79
|
findItem,
|
|
@@ -88,10 +84,4 @@ const FlatTableBodyDraggable = _ref2 => {
|
|
|
88
84
|
type: "drag"
|
|
89
85
|
})), item.props.children]))));
|
|
90
86
|
};
|
|
91
|
-
FlatTableBodyDraggable.propTypes = {
|
|
92
|
-
/** Callback fired when order is changed */
|
|
93
|
-
getOrder: PropTypes.func,
|
|
94
|
-
/** Array of FlatTableRow. */
|
|
95
|
-
children: PropTypes.node.isRequired
|
|
96
|
-
};
|
|
97
87
|
export default FlatTableBodyDraggable;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./flat-table-body-draggable";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./flat-table-body-draggable.component";
|
|
2
|
+
export type { FlatTableBodyDraggableProps } from "./flat-table-body-draggable.component";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PaddingProps } from "styled-system";
|
|
3
|
+
import { TableBorderSize, TableCellAlign } from "..";
|
|
4
|
+
export interface FlatTableCellProps extends PaddingProps {
|
|
5
|
+
/** Content alignment */
|
|
6
|
+
align?: TableCellAlign;
|
|
7
|
+
/** Cell content */
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** Number of columns that a cell should span */
|
|
10
|
+
colspan?: number | string;
|
|
11
|
+
/** Number of rows that a cell should span */
|
|
12
|
+
rowspan?: number | string;
|
|
13
|
+
/** Column width, pass a number to set a fixed width in pixels */
|
|
14
|
+
width?: number;
|
|
15
|
+
/** Truncate cell content and add ellipsis to any text that overflows */
|
|
16
|
+
truncate?: boolean;
|
|
17
|
+
/** Title text to display if cell content truncates */
|
|
18
|
+
title?: string;
|
|
19
|
+
/** Sets a custom vertical right border */
|
|
20
|
+
verticalBorder?: TableBorderSize;
|
|
21
|
+
/** Sets the color of the right border */
|
|
22
|
+
verticalBorderColor?: string;
|
|
23
|
+
/** Sets an id string on the DOM element */
|
|
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
|
+
}
|
|
65
|
+
export declare const FlatTableCell: {
|
|
66
|
+
({ align, children, pl, expandable, onClick, onKeyDown, reportCellWidth, cellIndex, leftPosition, rightPosition, width, truncate, title, colspan, rowspan, ...rest }: FlatTableCellProps): React.JSX.Element;
|
|
67
|
+
displayName: string;
|
|
68
|
+
};
|
|
69
|
+
export default FlatTableCell;
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
import React, { useLayoutEffect, useRef, useState, useEffect, useContext } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
5
4
|
import { StyledFlatTableCell, StyledCellContent } from "./flat-table-cell.style";
|
|
6
|
-
import { filterStyledSystemPaddingProps } from "../../../style/utils";
|
|
7
5
|
import Icon from "../../icon";
|
|
8
6
|
import { FlatTableThemeContext } from "../flat-table.component";
|
|
9
7
|
import guid from "../../../__internal__/utils/helpers/guid";
|
|
10
|
-
const
|
|
11
|
-
const FlatTableCell = _ref => {
|
|
8
|
+
export const FlatTableCell = _ref => {
|
|
12
9
|
let {
|
|
13
10
|
align = "left",
|
|
14
11
|
children,
|
|
15
|
-
colspan,
|
|
16
|
-
rowspan,
|
|
17
12
|
pl,
|
|
18
13
|
expandable = false,
|
|
19
14
|
onClick,
|
|
@@ -25,6 +20,8 @@ const FlatTableCell = _ref => {
|
|
|
25
20
|
width,
|
|
26
21
|
truncate = false,
|
|
27
22
|
title,
|
|
23
|
+
colspan,
|
|
24
|
+
rowspan,
|
|
28
25
|
...rest
|
|
29
26
|
} = _ref;
|
|
30
27
|
const ref = useRef(null);
|
|
@@ -49,8 +46,6 @@ const FlatTableCell = _ref => {
|
|
|
49
46
|
ref: ref,
|
|
50
47
|
align: align,
|
|
51
48
|
"data-element": "flat-table-cell",
|
|
52
|
-
colSpan: colspan,
|
|
53
|
-
rowSpan: rowspan,
|
|
54
49
|
pl: pl,
|
|
55
50
|
onClick: expandable && onClick ? onClick : undefined,
|
|
56
51
|
tabIndex: expandable && onClick ? tabIndex : undefined,
|
|
@@ -59,6 +54,10 @@ const FlatTableCell = _ref => {
|
|
|
59
54
|
isTruncated: truncate,
|
|
60
55
|
expandable: expandable,
|
|
61
56
|
id: id.current
|
|
57
|
+
}, colspan !== undefined && {
|
|
58
|
+
colSpan: Number(colspan)
|
|
59
|
+
}, rowspan !== undefined && {
|
|
60
|
+
rowSpan: Number(rowspan)
|
|
62
61
|
}, rest), /*#__PURE__*/React.createElement(StyledCellContent, {
|
|
63
62
|
title: truncate && !title && typeof children === "string" ? children : title,
|
|
64
63
|
expandable: expandable
|
|
@@ -68,66 +67,5 @@ const FlatTableCell = _ref => {
|
|
|
68
67
|
mr: "8px"
|
|
69
68
|
}), children));
|
|
70
69
|
};
|
|
71
|
-
FlatTableCell.propTypes = {
|
|
72
|
-
/** Styled system padding props */
|
|
73
|
-
...paddingPropTypes,
|
|
74
|
-
/** Content alignment */
|
|
75
|
-
align: PropTypes.oneOf(["center", "left", "right"]),
|
|
76
|
-
/** Cell content */
|
|
77
|
-
children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
78
|
-
/** Number of columns that a cell should span */
|
|
79
|
-
colspan: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
80
|
-
/** Number of rows that a cell should span */
|
|
81
|
-
rowspan: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
82
|
-
/** Column width, pass a number to set a fixed width in pixels */
|
|
83
|
-
width: PropTypes.number,
|
|
84
|
-
/** Truncate cell content and add ellipsis to any text that overflows */
|
|
85
|
-
truncate: PropTypes.bool,
|
|
86
|
-
/** Title text to display if cell content truncates */
|
|
87
|
-
title: PropTypes.string,
|
|
88
|
-
/**
|
|
89
|
-
* @private
|
|
90
|
-
* @ignore
|
|
91
|
-
*/
|
|
92
|
-
expandable: PropTypes.bool,
|
|
93
|
-
/**
|
|
94
|
-
* @private
|
|
95
|
-
* @ignore
|
|
96
|
-
*/
|
|
97
|
-
onClick: PropTypes.func,
|
|
98
|
-
/**
|
|
99
|
-
* @private
|
|
100
|
-
* @ignore
|
|
101
|
-
*/
|
|
102
|
-
onKeyDown: PropTypes.func,
|
|
103
|
-
/**
|
|
104
|
-
* @private
|
|
105
|
-
* @ignore
|
|
106
|
-
* Sets the left position when sticky column found
|
|
107
|
-
*/
|
|
108
|
-
leftPosition: PropTypes.number,
|
|
109
|
-
/**
|
|
110
|
-
* @private
|
|
111
|
-
* @ignore
|
|
112
|
-
* Sets the right position when sticky column found
|
|
113
|
-
*/
|
|
114
|
-
rightPosition: PropTypes.number,
|
|
115
|
-
/**
|
|
116
|
-
* @private
|
|
117
|
-
* @ignore
|
|
118
|
-
* Index of cell within row
|
|
119
|
-
*/
|
|
120
|
-
cellIndex: PropTypes.number,
|
|
121
|
-
/**
|
|
122
|
-
* @private
|
|
123
|
-
* @ignore
|
|
124
|
-
* Callback to report the offsetWidth
|
|
125
|
-
*/
|
|
126
|
-
reportCellWidth: PropTypes.func,
|
|
127
|
-
/** Sets a custom vertical right border */
|
|
128
|
-
verticalBorder: PropTypes.oneOf(["small", "medium", "large"]),
|
|
129
|
-
/** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
|
|
130
|
-
verticalBorderColor: PropTypes.string
|
|
131
|
-
};
|
|
132
70
|
FlatTableCell.displayName = "FlatTableCell";
|
|
133
71
|
export default FlatTableCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PaddingProps } from "styled-system";
|
|
2
|
+
import { FlatTableCellProps } from "./flat-table-cell.component";
|
|
3
|
+
interface StyledFlatTableCellProps extends Pick<FlatTableCellProps, "align" | "leftPosition" | "rightPosition" | "expandable" | "verticalBorder" | "verticalBorderColor">, PaddingProps {
|
|
4
|
+
makeCellSticky: boolean;
|
|
5
|
+
colWidth?: number;
|
|
6
|
+
isTruncated: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const StyledFlatTableCell: import("styled-components").StyledComponent<"td", any, StyledFlatTableCellProps, never>;
|
|
9
|
+
declare const StyledCellContent: import("styled-components").StyledComponent<"div", any, Pick<FlatTableCellProps, "expandable">, never>;
|
|
10
|
+
export { StyledFlatTableCell, StyledCellContent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./flat-table-cell";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./flat-table-cell.component";
|
|
2
|
+
export type { FlatTableCellProps } from "./flat-table-cell.component";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags";
|
|
3
|
+
export interface FlatTableCheckboxProps extends TagProps {
|
|
4
|
+
/** Prop to polymorphically render either a 'th' or 'td' element */
|
|
5
|
+
as?: "td" | "th";
|
|
6
|
+
/** Prop to set checked prop on Checkbox */
|
|
7
|
+
checked?: boolean;
|
|
8
|
+
/** Callback to be called onChange in Checkbox */
|
|
9
|
+
onChange?: (ev: React.ChangeEvent<HTMLElement>) => void;
|
|
10
|
+
/** Whether to render the checkbox or not, defaults to true */
|
|
11
|
+
selectable?: boolean;
|
|
12
|
+
/** Callback function to be called when click event received */
|
|
13
|
+
onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
14
|
+
/** The id of the element that labels the input */
|
|
15
|
+
ariaLabelledBy?: string;
|
|
16
|
+
/**
|
|
17
|
+
* @private
|
|
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;
|
|
40
|
+
}
|
|
41
|
+
export declare const FlatTableCheckbox: {
|
|
42
|
+
({ as, checked, onChange, selectable, onClick, leftPosition, rightPosition, cellIndex, reportCellWidth, ariaLabelledBy, ...rest }: FlatTableCheckboxProps): React.JSX.Element;
|
|
43
|
+
displayName: string;
|
|
44
|
+
};
|
|
45
|
+
export default FlatTableCheckbox;
|
|
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
|
|
|
4
4
|
import StyledFlatTableCheckbox from "./flat-table-checkbox.style";
|
|
5
5
|
import { Checkbox } from "../../checkbox";
|
|
6
6
|
import Events from "../../../__internal__/utils/helpers/events/events";
|
|
7
|
-
const FlatTableCheckbox = _ref => {
|
|
7
|
+
export const FlatTableCheckbox = _ref => {
|
|
8
8
|
let {
|
|
9
9
|
as = "td",
|
|
10
10
|
checked,
|
|
@@ -52,43 +52,5 @@ const FlatTableCheckbox = _ref => {
|
|
|
52
52
|
onKeyDown: handleKeyDown
|
|
53
53
|
}));
|
|
54
54
|
};
|
|
55
|
-
FlatTableCheckbox.propTypes = {
|
|
56
|
-
/** Prop to polymorphically render either a 'th' or 'td' element */
|
|
57
|
-
as: PropTypes.oneOf(["td", "th"]),
|
|
58
|
-
/** Prop to set checked prop on Checkbox */
|
|
59
|
-
checked: PropTypes.bool,
|
|
60
|
-
/** Callback to be called onChange in Checkbox */
|
|
61
|
-
onChange: PropTypes.func,
|
|
62
|
-
/** Callback function to be called when click event received */
|
|
63
|
-
onClick: PropTypes.func,
|
|
64
|
-
/** Whether to render the checkbox or not, defaults to true */
|
|
65
|
-
selectable: PropTypes.bool,
|
|
66
|
-
/** The id of the element that labels the input */
|
|
67
|
-
ariaLabelledBy: PropTypes.string,
|
|
68
|
-
/**
|
|
69
|
-
* @private
|
|
70
|
-
* @ignore
|
|
71
|
-
* Sets the left position when sticky column found
|
|
72
|
-
*/
|
|
73
|
-
leftPosition: PropTypes.number,
|
|
74
|
-
/**
|
|
75
|
-
* @private
|
|
76
|
-
* @ignore
|
|
77
|
-
* Sets the right position when sticky column found
|
|
78
|
-
*/
|
|
79
|
-
rightPosition: PropTypes.number,
|
|
80
|
-
/**
|
|
81
|
-
* @private
|
|
82
|
-
* @ignore
|
|
83
|
-
* Index of cell within row
|
|
84
|
-
*/
|
|
85
|
-
cellIndex: PropTypes.number,
|
|
86
|
-
/**
|
|
87
|
-
* @private
|
|
88
|
-
* @ignore
|
|
89
|
-
* Callback to report the offsetWidth
|
|
90
|
-
*/
|
|
91
|
-
reportCellWidth: PropTypes.func
|
|
92
|
-
};
|
|
93
55
|
FlatTableCheckbox.displayName = "FlatTableCheckbox";
|
|
94
56
|
export default FlatTableCheckbox;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FlatTableCheckboxProps } from "./flat-table-checkbox.component";
|
|
2
|
+
interface StyledFlatTableCheckboxProps extends Pick<FlatTableCheckboxProps, "as" | "leftPosition" | "rightPosition"> {
|
|
3
|
+
makeCellSticky: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const StyledFlatTableCheckbox: import("styled-components").StyledComponent<"td", any, StyledFlatTableCheckboxProps, never>;
|
|
6
|
+
export default StyledFlatTableCheckbox;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./flat-table-checkbox";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./flat-table-checkbox.component";
|
|
2
|
+
export type { FlatTableCheckboxProps } from "./flat-table-checkbox.component";
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import StyledFlatTableHead from "./flat-table-head.style";
|
|
4
4
|
import FlatTableRowHeader from "../flat-table-row-header";
|
|
5
5
|
const getRefs = length => Array.from({
|
|
6
6
|
length
|
|
7
7
|
}, () => /*#__PURE__*/React.createRef());
|
|
8
|
-
const FlatTableHead = _ref => {
|
|
8
|
+
export const FlatTableHead = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
children,
|
|
11
11
|
...rest
|
|
12
12
|
} = _ref;
|
|
13
13
|
const [rowHeights, setRowHeights] = useState([]);
|
|
14
|
-
const refs = getRefs(React.Children.count(children));
|
|
14
|
+
const refs = useRef(getRefs(React.Children.count(children)));
|
|
15
15
|
let hasFlatTableRowHeader;
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
if (React.Children.count(children) > 1) {
|
|
18
|
-
setRowHeights(refs.map(ref => ref.current
|
|
18
|
+
setRowHeights(refs.current.map(ref => ref.current?.clientHeight || 0));
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
}, []);
|
|
20
|
+
}, [children]);
|
|
22
21
|
if (React.Children.count(children) === 1) {
|
|
23
22
|
return /*#__PURE__*/React.createElement(StyledFlatTableHead, rest, children);
|
|
24
23
|
}
|
|
@@ -27,16 +26,12 @@ const FlatTableHead = _ref => {
|
|
|
27
26
|
This is only needed when the preceding row has rowSpans applied,
|
|
28
27
|
as in any other use case the rows will all have FlatTableRowHeaders */
|
|
29
28
|
const previousRowHasHeader = !!hasFlatTableRowHeader;
|
|
30
|
-
hasFlatTableRowHeader = React.Children.toArray(child.props.children).find(c => c.type === FlatTableRowHeader);
|
|
31
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
32
|
-
...child.props,
|
|
29
|
+
hasFlatTableRowHeader = /*#__PURE__*/React.isValidElement(child) && !!React.Children.toArray(child.props.children).find(c => /*#__PURE__*/React.isValidElement(c) && c.type.displayName === FlatTableRowHeader.displayName);
|
|
30
|
+
return /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.cloneElement(child, {
|
|
33
31
|
stickyOffset: rowHeights.slice(0, index).reduce((a, b) => a + b, 0),
|
|
34
|
-
ref: refs[index],
|
|
32
|
+
ref: refs.current[index],
|
|
35
33
|
applyBorderLeft: previousRowHasHeader && !hasFlatTableRowHeader
|
|
36
34
|
});
|
|
37
35
|
}));
|
|
38
36
|
};
|
|
39
|
-
FlatTableHead.propTypes = {
|
|
40
|
-
children: PropTypes.node.isRequired
|
|
41
|
-
};
|
|
42
37
|
export default FlatTableHead;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./flat-table-head";
|
|
2
|
-
export
|
|
1
|
+
export { default } from "./flat-table-head.component";
|
|
2
|
+
export type { FlatTableHeadProps } from "./flat-table-head.component";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { FlatTableProps } from "..";
|
|
2
|
+
declare const getAlternativeBackgroundColor: (colorTheme: FlatTableProps["colorTheme"]) => "var(--colorsActionMinor100)" | "var(--colorsUtilityYang100)" | "var(--colorsUtilityMajor025)" | "var(--colorsActionMinor550)";
|
|
3
|
+
export default getAlternativeBackgroundColor;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PaddingProps } from "styled-system";
|
|
3
|
+
import { TableBorderSize, TableCellAlign } from "..";
|
|
4
|
+
export interface FlatTableHeaderProps extends PaddingProps {
|
|
5
|
+
/** Content alignment */
|
|
6
|
+
align?: TableCellAlign;
|
|
7
|
+
/** If true sets alternative background color */
|
|
8
|
+
alternativeBgColor?: boolean;
|
|
9
|
+
/** Header content */
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** Number of columns that a header cell should span */
|
|
12
|
+
colspan?: number | string;
|
|
13
|
+
/** Number of rows that a header cell should span */
|
|
14
|
+
rowspan?: number | string;
|
|
15
|
+
/** Sets a custom vertical right border */
|
|
16
|
+
verticalBorder?: TableBorderSize;
|
|
17
|
+
/** Sets the color of the right border */
|
|
18
|
+
verticalBorderColor?: string;
|
|
19
|
+
/** Column width, pass a number to set a fixed width in pixels */
|
|
20
|
+
width?: number;
|
|
21
|
+
/** Sets an id string on the DOM element */
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
* @ignore
|
|
26
|
+
* Sets the left position when sticky column found
|
|
27
|
+
*/
|
|
28
|
+
leftPosition?: number;
|
|
29
|
+
/**
|
|
30
|
+
* @private
|
|
31
|
+
* @ignore
|
|
32
|
+
* Sets the right position when sticky column found
|
|
33
|
+
*/
|
|
34
|
+
rightPosition?: number;
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
* @ignore
|
|
38
|
+
* Index of cell within row
|
|
39
|
+
*/
|
|
40
|
+
cellIndex?: number;
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
* @ignore
|
|
44
|
+
* Callback to report the offsetWidth
|
|
45
|
+
*/
|
|
46
|
+
reportCellWidth?: (offset: number, index?: number) => void;
|
|
47
|
+
}
|
|
48
|
+
export declare const FlatTableHeader: {
|
|
49
|
+
({ align, children, colspan, rowspan, width, py, px, reportCellWidth, cellIndex, leftPosition, rightPosition, ...rest }: FlatTableHeaderProps): React.JSX.Element;
|
|
50
|
+
defaultProps: {
|
|
51
|
+
align: string;
|
|
52
|
+
};
|
|
53
|
+
displayName: string;
|
|
54
|
+
};
|
|
55
|
+
export default FlatTableHeader;
|