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.
Files changed (141) hide show
  1. package/esm/__spec_helper__/mock-resize-observer.js +20 -5
  2. package/esm/__spec_helper__/test-utils.d.ts +1 -1
  3. package/esm/components/flat-table/cell-sizes.style.d.ts +28 -0
  4. package/esm/components/flat-table/flat-table-body/flat-table-body.component.d.ts +7 -0
  5. package/esm/components/flat-table/flat-table-body/flat-table-body.component.js +3 -2
  6. package/esm/components/flat-table/flat-table-body/index.d.ts +2 -2
  7. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +9 -0
  8. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +6 -16
  9. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +4 -0
  10. package/esm/components/flat-table/flat-table-body-draggable/index.d.ts +2 -2
  11. package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +69 -0
  12. package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +7 -69
  13. package/esm/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +10 -0
  14. package/esm/components/flat-table/flat-table-cell/index.d.ts +2 -2
  15. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +45 -0
  16. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +1 -39
  17. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +6 -0
  18. package/esm/components/flat-table/flat-table-checkbox/index.d.ts +2 -2
  19. package/esm/components/flat-table/flat-table-head/flat-table-head.component.d.ts +7 -0
  20. package/esm/components/flat-table/flat-table-head/flat-table-head.component.js +8 -13
  21. package/esm/components/flat-table/flat-table-head/flat-table-head.style.d.ts +2 -0
  22. package/esm/components/flat-table/flat-table-head/index.d.ts +2 -2
  23. package/esm/components/flat-table/flat-table-header/flat-table-header-utils.d.ts +3 -0
  24. package/esm/components/flat-table/flat-table-header/flat-table-header.component.d.ts +55 -0
  25. package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +7 -49
  26. package/esm/components/flat-table/flat-table-header/flat-table-header.style.d.ts +10 -0
  27. package/esm/components/flat-table/flat-table-header/index.d.ts +2 -2
  28. package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +18 -0
  29. package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +13 -19
  30. package/esm/components/flat-table/flat-table-row/flat-table-row.component.d.ts +56 -0
  31. package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +43 -67
  32. package/esm/components/flat-table/flat-table-row/flat-table-row.style.d.ts +18 -0
  33. package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +2 -3
  34. package/esm/components/flat-table/flat-table-row/index.d.ts +2 -2
  35. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +71 -0
  36. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +9 -51
  37. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +6 -0
  38. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +7 -7
  39. package/esm/components/flat-table/flat-table-row-header/index.d.ts +2 -2
  40. package/esm/components/flat-table/flat-table.component.d.ts +42 -0
  41. package/esm/components/flat-table/flat-table.component.js +51 -92
  42. package/esm/components/flat-table/flat-table.config.d.ts +2 -0
  43. package/esm/components/flat-table/flat-table.style.d.ts +15 -0
  44. package/esm/components/flat-table/flat-table.style.js +36 -59
  45. package/esm/components/flat-table/index.d.ts +22 -13
  46. package/esm/components/flat-table/sort/index.d.ts +2 -2
  47. package/esm/components/flat-table/sort/sort.component.d.ts +11 -0
  48. package/esm/components/flat-table/sort/sort.component.js +1 -10
  49. package/esm/components/flat-table/sort/sort.style.d.ts +4 -0
  50. package/esm/components/global-header/global-header.component.js +6 -29
  51. package/esm/components/menu/__internal__/submenu/submenu.component.js +6 -1
  52. package/esm/components/menu/__internal__/submenu/submenu.style.d.ts +1 -0
  53. package/esm/components/menu/__internal__/submenu/submenu.style.js +4 -1
  54. package/esm/components/navigation-bar/fixed-navigation-bar.context.d.ts +11 -0
  55. package/esm/components/navigation-bar/fixed-navigation-bar.context.js +31 -0
  56. package/esm/components/navigation-bar/navigation-bar.component.d.ts +3 -1
  57. package/esm/components/navigation-bar/navigation-bar.component.js +20 -8
  58. package/esm/components/navigation-bar/navigation-bar.style.d.ts +4 -0
  59. package/esm/components/navigation-bar/navigation-bar.style.js +3 -2
  60. package/lib/__spec_helper__/mock-resize-observer.js +20 -5
  61. package/lib/__spec_helper__/test-utils.d.ts +1 -1
  62. package/lib/components/flat-table/cell-sizes.style.d.ts +28 -0
  63. package/lib/components/flat-table/flat-table-body/flat-table-body.component.d.ts +7 -0
  64. package/lib/components/flat-table/flat-table-body/flat-table-body.component.js +4 -3
  65. package/lib/components/flat-table/flat-table-body/index.d.ts +2 -2
  66. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.d.ts +9 -0
  67. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +7 -16
  68. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.style.d.ts +4 -0
  69. package/lib/components/flat-table/flat-table-body-draggable/index.d.ts +2 -2
  70. package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +69 -0
  71. package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +8 -69
  72. package/lib/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +10 -0
  73. package/lib/components/flat-table/flat-table-cell/index.d.ts +2 -2
  74. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +45 -0
  75. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +2 -39
  76. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +6 -0
  77. package/lib/components/flat-table/flat-table-checkbox/index.d.ts +2 -2
  78. package/lib/components/flat-table/flat-table-head/flat-table-head.component.d.ts +7 -0
  79. package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +8 -12
  80. package/lib/components/flat-table/flat-table-head/flat-table-head.style.d.ts +2 -0
  81. package/lib/components/flat-table/flat-table-head/index.d.ts +2 -2
  82. package/lib/components/flat-table/flat-table-header/flat-table-header-utils.d.ts +3 -0
  83. package/lib/components/flat-table/flat-table-header/flat-table-header.component.d.ts +55 -0
  84. package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +8 -49
  85. package/lib/components/flat-table/flat-table-header/flat-table-header.style.d.ts +10 -0
  86. package/lib/components/flat-table/flat-table-header/index.d.ts +2 -2
  87. package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +18 -0
  88. package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +14 -20
  89. package/lib/components/flat-table/flat-table-row/flat-table-row.component.d.ts +56 -0
  90. package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +44 -68
  91. package/lib/components/flat-table/flat-table-row/flat-table-row.style.d.ts +18 -0
  92. package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +2 -3
  93. package/lib/components/flat-table/flat-table-row/index.d.ts +2 -2
  94. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +71 -0
  95. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +10 -51
  96. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +6 -0
  97. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +7 -7
  98. package/lib/components/flat-table/flat-table-row-header/index.d.ts +2 -2
  99. package/lib/components/flat-table/flat-table.component.d.ts +42 -0
  100. package/lib/components/flat-table/flat-table.component.js +51 -91
  101. package/lib/components/flat-table/flat-table.config.d.ts +2 -0
  102. package/lib/components/flat-table/flat-table.style.d.ts +15 -0
  103. package/lib/components/flat-table/flat-table.style.js +36 -59
  104. package/lib/components/flat-table/index.d.ts +22 -13
  105. package/lib/components/flat-table/sort/index.d.ts +2 -2
  106. package/lib/components/flat-table/sort/sort.component.d.ts +11 -0
  107. package/lib/components/flat-table/sort/sort.component.js +1 -10
  108. package/lib/components/flat-table/sort/sort.style.d.ts +4 -0
  109. package/lib/components/global-header/global-header.component.js +6 -31
  110. package/lib/components/menu/__internal__/submenu/submenu.component.js +6 -1
  111. package/lib/components/menu/__internal__/submenu/submenu.style.d.ts +1 -0
  112. package/lib/components/menu/__internal__/submenu/submenu.style.js +4 -1
  113. package/lib/components/navigation-bar/fixed-navigation-bar.context.d.ts +11 -0
  114. package/lib/components/navigation-bar/fixed-navigation-bar.context.js +42 -0
  115. package/lib/components/navigation-bar/navigation-bar.component.d.ts +3 -1
  116. package/lib/components/navigation-bar/navigation-bar.component.js +22 -8
  117. package/lib/components/navigation-bar/navigation-bar.style.d.ts +4 -0
  118. package/lib/components/navigation-bar/navigation-bar.style.js +3 -2
  119. package/package.json +1 -1
  120. package/esm/components/flat-table/flat-table-body/flat-table-body.d.ts +0 -10
  121. package/esm/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.d.ts +0 -14
  122. package/esm/components/flat-table/flat-table-cell/flat-table-cell.d.ts +0 -28
  123. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.d.ts +0 -20
  124. package/esm/components/flat-table/flat-table-head/flat-table-head.d.ts +0 -10
  125. package/esm/components/flat-table/flat-table-header/flat-table-header.d.ts +0 -27
  126. package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.d.ts +0 -20
  127. package/esm/components/flat-table/flat-table-row/flat-table-row.d.ts +0 -31
  128. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +0 -28
  129. package/esm/components/flat-table/flat-table.d.ts +0 -37
  130. package/esm/components/flat-table/sort/sort.d.ts +0 -14
  131. package/lib/components/flat-table/flat-table-body/flat-table-body.d.ts +0 -10
  132. package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.d.ts +0 -14
  133. package/lib/components/flat-table/flat-table-cell/flat-table-cell.d.ts +0 -28
  134. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.d.ts +0 -20
  135. package/lib/components/flat-table/flat-table-head/flat-table-head.d.ts +0 -10
  136. package/lib/components/flat-table/flat-table-header/flat-table-header.d.ts +0 -27
  137. package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.d.ts +0 -20
  138. package/lib/components/flat-table/flat-table-row/flat-table-row.d.ts +0 -31
  139. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +0 -28
  140. package/lib/components/flat-table/flat-table.d.ts +0 -37
  141. package/lib/components/flat-table/sort/sort.d.ts +0 -14
@@ -0,0 +1,71 @@
1
+ import React from "react";
2
+ import { PaddingProps } from "styled-system";
3
+ import { TableBorderSize, TableCellAlign } from "..";
4
+ export interface FlatTableRowHeaderProps extends PaddingProps {
5
+ /** Content alignment */
6
+ align?: TableCellAlign;
7
+ /** RowHeader content */
8
+ children?: React.ReactNode;
9
+ /** Column width, pass a number to set a fixed width in pixels */
10
+ width?: number;
11
+ /** Truncate cell content and add ellipsis to any text that overflows */
12
+ truncate?: boolean;
13
+ /** Title text to display if cell content truncates */
14
+ title?: string;
15
+ /** Sets a custom vertical right border */
16
+ verticalBorder?: TableBorderSize;
17
+ /** Sets the color of the right border */
18
+ verticalBorderColor?: string;
19
+ /** Defines whether the column should be sticky on the left or right hand side of the Table */
20
+ stickyAlignment?: "left" | "right";
21
+ /** Number of columns that a header cell should span */
22
+ colspan?: number | string;
23
+ /** Number of rows that a header cell should span */
24
+ rowspan?: number | string;
25
+ /** Sets an id string on the DOM element */
26
+ id?: string;
27
+ /**
28
+ * @private
29
+ * @ignore
30
+ */
31
+ expandable?: boolean;
32
+ /**
33
+ * @private
34
+ * @ignore
35
+ */
36
+ onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
37
+ /**
38
+ * @private
39
+ * @ignore
40
+ */
41
+ onKeyDown?: (ev: React.KeyboardEvent<HTMLElement>) => void;
42
+ /**
43
+ * @private
44
+ * @ignore
45
+ * Sets the left position when sticky column found
46
+ */
47
+ leftPosition?: number;
48
+ /**
49
+ * @private
50
+ * @ignore
51
+ * Sets the right position when sticky column found
52
+ */
53
+ rightPosition?: number;
54
+ /**
55
+ * @private
56
+ * @ignore
57
+ * Index of cell within row
58
+ */
59
+ cellIndex?: number;
60
+ /**
61
+ * @private
62
+ * @ignore
63
+ * Callback to report the offsetWidth
64
+ */
65
+ reportCellWidth?: (offset: number, index?: number) => void;
66
+ }
67
+ export declare const FlatTableRowHeader: {
68
+ ({ align, children, width, py, px, expandable, onClick, onKeyDown, leftPosition, rightPosition, truncate, title, stickyAlignment, colspan, rowspan, ...rest }: FlatTableRowHeaderProps): React.JSX.Element;
69
+ displayName: string;
70
+ };
71
+ export default FlatTableRowHeader;
@@ -3,11 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.FlatTableRowHeader = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
10
- var _utils = require("../../../style/utils");
11
9
  var _icon = _interopRequireDefault(require("../../icon"));
12
10
  var _flatTableRowHeader = require("./flat-table-row-header.style");
13
11
  var _flatTable = require("../flat-table.component");
@@ -16,7 +14,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
16
14
  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); }
17
15
  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
16
  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); }
19
- const paddingPropTypes = (0, _utils.filterStyledSystemPaddingProps)(_propTypes2.default.space);
20
17
  const FlatTableRowHeader = _ref => {
21
18
  let {
22
19
  align = "left",
@@ -32,6 +29,8 @@ const FlatTableRowHeader = _ref => {
32
29
  truncate,
33
30
  title,
34
31
  stickyAlignment = "left",
32
+ colspan,
33
+ rowspan,
35
34
  ...rest
36
35
  } = _ref;
37
36
  const id = (0, _react.useRef)((0, _guid.default)());
@@ -53,16 +52,20 @@ const FlatTableRowHeader = _ref => {
53
52
  rightPosition: stickyAlignment === "right" ? rightPosition || 0 : undefined,
54
53
  align: align,
55
54
  "data-element": "flat-table-row-header",
56
- colWidth: width,
55
+ width: width,
57
56
  py: py || "10px",
58
57
  px: px || 3,
59
58
  onClick: handleOnClick,
60
59
  tabIndex: expandable && onClick ? tabIndex : undefined,
61
60
  onKeyDown: handleOnKeyDown,
62
- isTruncated: truncate,
61
+ truncate: truncate,
63
62
  expandable: expandable,
64
63
  stickyAlignment: stickyAlignment,
65
64
  id: id.current
65
+ }, colspan !== undefined && {
66
+ colSpan: Number(colspan)
67
+ }, rowspan !== undefined && {
68
+ rowSpan: Number(rowspan)
66
69
  }, rest), /*#__PURE__*/_react.default.createElement(_flatTableRowHeader.StyledFlatTableRowHeaderContent, {
67
70
  title: truncate && !title && typeof children === "string" ? children : title,
68
71
  expandable: expandable
@@ -72,51 +75,7 @@ const FlatTableRowHeader = _ref => {
72
75
  mr: "8px"
73
76
  }), children));
74
77
  };
75
- FlatTableRowHeader.propTypes = {
76
- /** Styled system padding props */
77
- ...paddingPropTypes,
78
- /** Content alignment */
79
- align: _propTypes.default.oneOf(["center", "left", "right"]),
80
- /** RowHeader content */
81
- children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]),
82
- /** Column width, pass a number to set a fixed width in pixels */
83
- width: _propTypes.default.number,
84
- /** Truncate cell content and add ellipsis to any text that overflows */
85
- truncate: _propTypes.default.bool,
86
- /** Title text to display if cell content truncates */
87
- title: _propTypes.default.string,
88
- /**
89
- * @private
90
- * @ignore
91
- */
92
- expandable: _propTypes.default.bool,
93
- /**
94
- * @private
95
- * @ignore
96
- */
97
- onClick: _propTypes.default.func,
98
- /**
99
- * @private
100
- * @ignore
101
- */
102
- onKeyDown: _propTypes.default.func,
103
- /** Sets a custom vertical right border */
104
- verticalBorder: _propTypes.default.oneOf(["small", "medium", "large"]),
105
- /** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
106
- verticalBorderColor: _propTypes.default.string,
107
- /** Defines whether the column should be sticky on the left or right hand side of the Table */
108
- stickyAlignment: _propTypes.default.oneOf(["left", "right"]),
109
- /**
110
- * @private
111
- * @ignore
112
- */
113
- leftPosition: _propTypes.default.number,
114
- /**
115
- * @private
116
- * @ignore
117
- */
118
- rightPosition: _propTypes.default.number
119
- };
78
+ exports.FlatTableRowHeader = FlatTableRowHeader;
120
79
  FlatTableRowHeader.displayName = "FlatTableRowHeader";
121
80
  var _default = FlatTableRowHeader;
122
81
  exports.default = _default;
@@ -0,0 +1,6 @@
1
+ import { FlatTableRowHeaderProps } from "./flat-table-row-header.component";
2
+ declare const StyledFlatTableRowHeader: import("styled-components").StyledComponent<"th", any, FlatTableRowHeaderProps, never>;
3
+ declare const StyledFlatTableRowHeaderContent: import("styled-components").StyledComponent<"div", any, {
4
+ expandable?: boolean | undefined;
5
+ }, never>;
6
+ export { StyledFlatTableRowHeader, StyledFlatTableRowHeaderContent };
@@ -21,10 +21,10 @@ const StyledFlatTableRowHeader = _styledComponents.default.th`
21
21
  let {
22
22
  align,
23
23
  theme,
24
- colWidth,
24
+ width,
25
25
  leftPosition,
26
26
  rightPosition,
27
- isTruncated,
27
+ truncate,
28
28
  expandable,
29
29
  verticalBorder,
30
30
  verticalBorderColor,
@@ -44,22 +44,22 @@ const StyledFlatTableRowHeader = _styledComponents.default.th`
44
44
  padding: 0;
45
45
  z-index: ${_base.default.zIndex.overlay};
46
46
 
47
- ${colWidth && (0, _styledComponents.css)`
48
- width: ${colWidth}px;
47
+ ${width && (0, _styledComponents.css)`
48
+ width: ${width}px;
49
49
  `}
50
50
 
51
51
  &&&& {
52
52
  > div {
53
53
  box-sizing: border-box;
54
54
 
55
- ${isTruncated && (0, _styledComponents.css)`
55
+ ${truncate && (0, _styledComponents.css)`
56
56
  text-overflow: ellipsis;
57
57
  overflow: hidden;
58
58
  white-space: nowrap;
59
59
  `}
60
60
 
61
- ${colWidth && (0, _styledComponents.css)`
62
- width: ${colWidth}px;
61
+ ${width && (0, _styledComponents.css)`
62
+ width: ${width}px;
63
63
  `}
64
64
 
65
65
  ${_styledSystem.padding}
@@ -1,2 +1,2 @@
1
- export { default } from "./flat-table-row-header";
2
- export * from "./flat-table-row-header";
1
+ export { default } from "./flat-table-row-header.component";
2
+ export type { FlatTableRowHeaderProps } from "./flat-table-row-header.component";
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ export interface FlatTableProps extends MarginProps {
4
+ /** The HTML id of the element that contains a description of this table. */
5
+ ariaDescribedby?: string;
6
+ /** A string to render as the table's caption */
7
+ caption?: string;
8
+ /** FlatTableHead and FlatTableBody */
9
+ children: React.ReactNode;
10
+ /** `FlatTable` color theme */
11
+ colorTheme?: "light" | "transparent-base" | "transparent-white" | "dark";
12
+ /** Content to be rendered at the foot of the table */
13
+ footer?: React.ReactNode;
14
+ /** If true, the header does not scroll with the content */
15
+ hasStickyFooter?: boolean;
16
+ /** If true, the header does not scroll with the content */
17
+ hasStickyHead?: boolean;
18
+ /** Set the height of the table. String can be any valid CSS string, numbers will be converted to pixels. */
19
+ height?: string | number;
20
+ /** Set the min-height of the table. String can be any valid CSS string, numbers will be converted to pixels. */
21
+ minHeight?: string | number;
22
+ /** Toggles the zebra striping for the table rows */
23
+ isZebra?: boolean;
24
+ /** Used to define the tables size Renders as: 'compact', 'small', 'medium', 'large' and 'extraLarge' */
25
+ size?: "compact" | "small" | "medium" | "large" | "extraLarge";
26
+ /** Applies max-height of 100% to FlatTable if true */
27
+ hasMaxHeight?: boolean;
28
+ /** Set the overflow X of the table wrapper. Any valid CSS string */
29
+ overflowX?: string;
30
+ /** Width of the table. Any valid CSS string */
31
+ width?: string;
32
+ }
33
+ export interface FlatTableThemeContextProps extends Pick<FlatTableProps, "colorTheme" | "size"> {
34
+ selectedId?: string;
35
+ setSelectedId: (id: string) => void;
36
+ }
37
+ export declare const FlatTableThemeContext: React.Context<FlatTableThemeContextProps>;
38
+ export declare const FlatTable: {
39
+ ({ caption, children, hasStickyHead, colorTheme, footer, hasStickyFooter, height, isZebra, size, hasMaxHeight, ariaDescribedby, minHeight, overflowX, width, ...rest }: FlatTableProps): React.JSX.Element;
40
+ displayName: string;
41
+ };
42
+ export default FlatTable;
@@ -3,13 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.FlatTableThemeContext = void 0;
6
+ exports.default = exports.FlatTableThemeContext = exports.FlatTable = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
10
9
  var _flatTable = require("./flat-table.style");
11
10
  var _drawer = require("../drawer");
12
- var _utils = require("../../style/utils");
13
11
  var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events/events"));
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
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); }
@@ -19,19 +17,18 @@ const FlatTableThemeContext = /*#__PURE__*/_react.default.createContext({
19
17
  setSelectedId: () => {}
20
18
  });
21
19
  exports.FlatTableThemeContext = FlatTableThemeContext;
22
- const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
23
20
  const FOCUSABLE_ROW_AND_CELL_QUERY = "tbody tr, tbody tr td, tbody tr th";
24
21
  const FlatTable = _ref => {
25
22
  let {
26
23
  caption,
27
24
  children,
28
25
  hasStickyHead,
29
- colorTheme,
26
+ colorTheme = "dark",
30
27
  footer,
31
28
  hasStickyFooter = false,
32
29
  height,
33
30
  isZebra,
34
- size,
31
+ size = "medium",
35
32
  hasMaxHeight = false,
36
33
  ariaDescribedby,
37
34
  minHeight,
@@ -50,17 +47,18 @@ const FlatTable = _ref => {
50
47
  const tableStylingProps = {
51
48
  caption,
52
49
  isZebra,
53
- size
50
+ size,
51
+ "aria-describedby": ariaDescribedby
54
52
  };
55
- if (ariaDescribedby) {
56
- tableStylingProps["aria-describedby"] = ariaDescribedby;
57
- }
53
+ const {
54
+ isInSidebar
55
+ } = (0, _react.useContext)(_drawer.DrawerSidebarContext);
58
56
  (0, _react.useLayoutEffect)(() => {
59
57
  const findRow = (rows, isFirstCol) => rows.find((row, index) => {
60
58
  const cells = Array.from(row.querySelectorAll("td, th"));
61
59
  const cell = isFirstCol ? cells.shift() : cells.pop();
62
60
  const rowSpan = cell?.getAttribute("rowspan");
63
- return rowSpan >= index + 1;
61
+ return rowSpan && Number(rowSpan) >= index + 1;
64
62
  });
65
63
 
66
64
  /* istanbul ignore else */
@@ -146,86 +144,48 @@ const FlatTable = _ref => {
146
144
  setSelectedId(focusableArray[0]?.getAttribute("id") || "");
147
145
  }
148
146
  }, [selectedId]);
149
- return /*#__PURE__*/_react.default.createElement(_drawer.DrawerSidebarContext.Consumer, null, _ref2 => {
150
- let {
151
- isInSidebar
152
- } = _ref2;
153
- return /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableWrapper, _extends({
154
- ref: wrapperRef,
155
- "data-component": "flat-table-wrapper",
156
- isInSidebar: isInSidebar,
157
- hasStickyHead: hasStickyHead,
158
- colorTheme: colorTheme,
159
- minHeight: minHeight,
160
- overflowY: !isInSidebar && (hasStickyHead || hasStickyFooter) ? "auto" : undefined,
161
- height: addDefaultHeight && !hasMaxHeight ? "99%" : height,
162
- maxHeight: hasMaxHeight ? "100%" : undefined,
163
- display: "flex",
164
- flexDirection: "column",
165
- justifyContent: hasStickyFooter || height ? "space-between" : undefined,
166
- tabIndex: "0",
167
- role: "region",
168
- overflowX: width ? "hidden" : undefined,
169
- width: width,
170
- hasStickyFooter: hasStickyFooter,
171
- hasVerticalScrollbar: hasVerticalScrollbar,
172
- hasHorizontalScrollbar: hasHorizontalScrollbar,
173
- hasFooter: !!footer,
174
- firstColRowSpanIndex: firstColRowSpanIndex,
175
- lastColRowSpanIndex: lastColRowSpanIndex,
176
- onKeyDown: handleKeyDown
177
- }, rest), /*#__PURE__*/_react.default.createElement(_flatTable.StyledTableContainer, {
178
- overflowX: overflowX,
179
- width: width
180
- }, /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTable, _extends({
181
- ref: tableRef,
182
- "data-component": "flat-table"
183
- }, tableStylingProps), caption ? /*#__PURE__*/_react.default.createElement("caption", null, caption) : null, /*#__PURE__*/_react.default.createElement(FlatTableThemeContext.Provider, {
184
- value: {
185
- colorTheme,
186
- size,
187
- setSelectedId,
188
- selectedId
189
- }
190
- }, children))), footer && /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableFooter, {
191
- hasStickyFooter: hasStickyFooter
192
- }, footer));
193
- });
194
- };
195
- FlatTable.propTypes = {
196
- ...marginPropTypes,
197
- /** The HTML id of the element that contains a description of this table. */
198
- ariaDescribedby: _propTypes.default.string,
199
- /** A string to render as the table's caption */
200
- caption: _propTypes.default.string,
201
- /** FlatTableHead and FlatTableBody */
202
- children: _propTypes.default.node.isRequired,
203
- /** If true, the header does not scroll with the content */
204
- hasStickyHead: _propTypes.default.bool,
205
- /** `FlatTable` color theme */
206
- colorTheme: _propTypes.default.oneOf(["light", "transparent-base", "transparent-white", "dark"]),
207
- /** Content to be rendered at the foot of the table */
208
- footer: _propTypes.default.node,
209
- /** If true, the header does not scroll with the content */
210
- hasStickyFooter: _propTypes.default.bool,
211
- /** Set the height of the table. String can be any valid CSS string, numbers will be converted to pixels. */
212
- height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
213
- /** Set the min-height of the table. A string can be any valid CSS string, numbers will be converted to pixels. */
214
- minHeight: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
215
- /** Toggles the zebra striping for the table rows */
216
- isZebra: _propTypes.default.bool,
217
- /** Used to define the tables size Renders as: 'compact', 'small', 'medium', 'large' and 'extraLarge' */
218
- size: _propTypes.default.oneOf(["compact", "small", "medium", "large", "extraLarge"]),
219
- /** Applies max-height of 100% to FlatTable if true */
220
- hasMaxHeight: _propTypes.default.bool,
221
- /** Set the overflow X of the table wrapper. Any valid CSS string */
222
- overflowX: _propTypes.default.string,
223
- /** Width of the table. Any valid CSS string */
224
- width: _propTypes.default.string
225
- };
226
- FlatTable.defaultProps = {
227
- colorTheme: "dark",
228
- size: "medium"
147
+ return /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableWrapper, _extends({
148
+ ref: wrapperRef,
149
+ "data-component": "flat-table-wrapper",
150
+ isInSidebar: isInSidebar,
151
+ hasStickyHead: hasStickyHead,
152
+ colorTheme: colorTheme,
153
+ minHeight: minHeight,
154
+ overflowY: !isInSidebar && (hasStickyHead || hasStickyFooter) ? "auto" : undefined,
155
+ height: addDefaultHeight && !hasMaxHeight ? "99%" : height,
156
+ maxHeight: hasMaxHeight ? "100%" : undefined,
157
+ display: "flex",
158
+ flexDirection: "column",
159
+ justifyContent: hasStickyFooter || height ? "space-between" : undefined,
160
+ tabIndex: 0,
161
+ role: "region",
162
+ overflowX: width ? "hidden" : undefined,
163
+ width: width,
164
+ hasStickyFooter: hasStickyFooter,
165
+ hasVerticalScrollbar: hasVerticalScrollbar,
166
+ hasHorizontalScrollbar: hasHorizontalScrollbar,
167
+ footer: !!footer,
168
+ firstColRowSpanIndex: firstColRowSpanIndex,
169
+ lastColRowSpanIndex: lastColRowSpanIndex,
170
+ onKeyDown: handleKeyDown
171
+ }, rest), /*#__PURE__*/_react.default.createElement(_flatTable.StyledTableContainer, {
172
+ overflowX: overflowX,
173
+ width: width
174
+ }, /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTable, _extends({
175
+ ref: tableRef,
176
+ "data-component": "flat-table"
177
+ }, tableStylingProps), caption ? /*#__PURE__*/_react.default.createElement("caption", null, caption) : null, /*#__PURE__*/_react.default.createElement(FlatTableThemeContext.Provider, {
178
+ value: {
179
+ colorTheme,
180
+ size,
181
+ setSelectedId,
182
+ selectedId
183
+ }
184
+ }, children))), footer && /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableFooter, {
185
+ hasStickyFooter: hasStickyFooter
186
+ }, footer));
229
187
  };
188
+ exports.FlatTable = FlatTable;
189
+ FlatTable.displayName = "FlatTable";
230
190
  var _default = FlatTable;
231
191
  exports.default = _default;
@@ -0,0 +1,2 @@
1
+ export declare const FLAT_TABLE_THEMES: readonly ["light", "dark", "transparent-base", "transparent-white"];
2
+ export declare const FLAT_TABLE_SIZES: readonly ["compact", "small", "medium", "large"];
@@ -0,0 +1,15 @@
1
+ import { FlatTableProps } from "./flat-table.component";
2
+ import { DrawerSidebarContextProps } from "../drawer";
3
+ declare const StyledTableContainer: import("styled-components").StyledComponent<"div", any, Pick<FlatTableProps, "width" | "overflowX">, never>;
4
+ declare const StyledFlatTable: import("styled-components").StyledComponent<"table", any, Pick<FlatTableProps, "caption" | "isZebra"> & {
5
+ size: NonNullable<FlatTableProps["size"]>;
6
+ }, never>;
7
+ interface StyledFlatTableWrapperProps extends Pick<FlatTableProps, "hasStickyFooter" | "colorTheme" | "hasStickyHead" | "footer">, Partial<DrawerSidebarContextProps> {
8
+ hasHorizontalScrollbar: boolean;
9
+ hasVerticalScrollbar: boolean;
10
+ lastColRowSpanIndex: number;
11
+ firstColRowSpanIndex: number;
12
+ }
13
+ declare const StyledFlatTableWrapper: import("styled-components").StyledComponent<"div", any, import("../box").BoxProps & StyledFlatTableWrapperProps, never>;
14
+ declare const StyledFlatTableFooter: import("styled-components").StyledComponent<"div", any, Pick<FlatTableProps, "hasStickyFooter">, never>;
15
+ export { StyledFlatTableWrapper, StyledFlatTable, StyledFlatTableFooter, StyledTableContainer, };
@@ -110,9 +110,6 @@ const StyledFlatTable = _styledComponents.default.table`
110
110
  }}
111
111
  `;
112
112
  exports.StyledFlatTable = StyledFlatTable;
113
- StyledFlatTable.defaultProps = {
114
- size: "medium"
115
- };
116
113
  const StyledFlatTableWrapper = (0, _styledComponents.default)(_box.default)`
117
114
  border-top-left-radius: var(--borderRadius100);
118
115
  border-top-right-radius: var(--borderRadius100);
@@ -312,9 +309,9 @@ const StyledFlatTableWrapper = (0, _styledComponents.default)(_box.default)`
312
309
 
313
310
  ${_ref14 => {
314
311
  let {
315
- hasFooter
312
+ footer
316
313
  } = _ref14;
317
- return hasFooter && (0, _styledComponents.css)`
314
+ return footer && (0, _styledComponents.css)`
318
315
  tr:last-child:focus {
319
316
  :after {
320
317
  border-bottom-left-radius: var(--borderRadius000);
@@ -325,65 +322,45 @@ const StyledFlatTableWrapper = (0, _styledComponents.default)(_box.default)`
325
322
 
326
323
  ${_ref15 => {
327
324
  let {
328
- hasFooter
325
+ footer,
326
+ firstColRowSpanIndex,
327
+ lastColRowSpanIndex,
328
+ hasHorizontalScrollbar,
329
+ hasVerticalScrollbar
329
330
  } = _ref15;
330
- return !hasFooter && (0, _styledComponents.css)`
331
+ return !footer && (0, _styledComponents.css)`
331
332
  tbody {
332
- ${_ref16 => {
333
- let {
334
- firstColRowSpanIndex
335
- } = _ref16;
336
- return firstColRowSpanIndex >= 0 && (0, _styledComponents.css)`
337
- ${_flatTableRow.default}:nth-of-type(${firstColRowSpanIndex + 1}) {
338
- th:first-child,
339
- td:first-child {
340
- border-bottom-left-radius: var(--borderRadius100);
341
- }
333
+ ${firstColRowSpanIndex >= 0 && (0, _styledComponents.css)`
334
+ ${_flatTableRow.default}:nth-of-type(${firstColRowSpanIndex + 1}) {
335
+ th:first-child,
336
+ td:first-child {
337
+ border-bottom-left-radius: var(--borderRadius100);
342
338
  }
343
- `;
344
- }}
339
+ }
340
+ `}
345
341
 
346
- ${_ref17 => {
347
- let {
348
- lastColRowSpanIndex,
349
- hasHorizontalScrollbar
350
- } = _ref17;
351
- return lastColRowSpanIndex >= 0 && !hasHorizontalScrollbar && (0, _styledComponents.css)`
352
- ${_flatTableRow.default}:nth-of-type(${lastColRowSpanIndex + 1}) {
353
- th:last-child,
354
- td:last-child {
355
- border-bottom-right-radius: var(--borderRadius100);
356
- }
342
+ ${lastColRowSpanIndex >= 0 && !hasHorizontalScrollbar && (0, _styledComponents.css)`
343
+ ${_flatTableRow.default}:nth-of-type(${lastColRowSpanIndex + 1}) {
344
+ th:last-child,
345
+ td:last-child {
346
+ border-bottom-right-radius: var(--borderRadius100);
357
347
  }
358
- `;
359
- }}
348
+ }
349
+ `}
360
350
 
361
351
  ${_flatTableRow.default}:last-of-type {
362
- ${_ref18 => {
363
- let {
364
- hasHorizontalScrollbar,
365
- firstColRowSpanIndex
366
- } = _ref18;
367
- return !hasHorizontalScrollbar && firstColRowSpanIndex === -1 && (0, _styledComponents.css)`
368
- th:first-child,
369
- td:first-child {
370
- border-bottom-left-radius: var(--borderRadius100);
371
- }
372
- `;
373
- }}
374
- ${_ref19 => {
375
- let {
376
- hasVerticalScrollbar,
377
- hasHorizontalScrollbar,
378
- lastColRowSpanIndex
379
- } = _ref19;
380
- return !hasVerticalScrollbar && !hasHorizontalScrollbar && lastColRowSpanIndex === -1 && (0, _styledComponents.css)`
381
- th:last-child,
382
- td:last-child {
383
- border-bottom-right-radius: var(--borderRadius100);
384
- }
385
- `;
386
- }}
352
+ ${!hasHorizontalScrollbar && firstColRowSpanIndex === -1 && (0, _styledComponents.css)`
353
+ th:first-child,
354
+ td:first-child {
355
+ border-bottom-left-radius: var(--borderRadius100);
356
+ }
357
+ `}
358
+ ${!hasVerticalScrollbar && !hasHorizontalScrollbar && lastColRowSpanIndex === -1 && (0, _styledComponents.css)`
359
+ th:last-child,
360
+ td:last-child {
361
+ border-bottom-right-radius: var(--borderRadius100);
362
+ }
363
+ `}
387
364
  }
388
365
  }
389
366
  `;
@@ -394,11 +371,11 @@ StyledFlatTableWrapper.defaultProps = {
394
371
  theme: _themes.baseTheme
395
372
  };
396
373
  const StyledFlatTableFooter = _styledComponents.default.div`
397
- ${_ref20 => {
374
+ ${_ref16 => {
398
375
  let {
399
376
  hasStickyFooter,
400
377
  theme
401
- } = _ref20;
378
+ } = _ref16;
402
379
  return hasStickyFooter && (0, _styledComponents.css)`
403
380
  position: sticky;
404
381
  bottom: 0px;
@@ -1,13 +1,22 @@
1
- export type TableBorderSize = "small" | "medium" | "large";
2
-
3
- export { default as FlatTable } from "./flat-table";
4
- export { default as FlatTableHead } from "./flat-table-head";
5
- export { default as FlatTableHeader } from "./flat-table-header";
6
- export { default as FlatTableBody } from "./flat-table-body";
7
- export { default as FlatTableBodyDraggable } from "./flat-table-body-draggable";
8
- export { default as FlatTableRow } from "./flat-table-row";
9
- export { default as FlatTableRowHeader } from "./flat-table-row-header";
10
- export { default as FlatTableCell } from "./flat-table-cell";
11
- export { default as FlatTableCheckbox } from "./flat-table-checkbox";
12
- export { default as Sort } from "./sort";
13
- export * from "./flat-table";
1
+ export { default as FlatTable } from "./flat-table.component";
2
+ export { default as FlatTableHead } from "./flat-table-head/flat-table-head.component";
3
+ export { default as FlatTableHeader } from "./flat-table-header/flat-table-header.component";
4
+ export { default as FlatTableBody } from "./flat-table-body/flat-table-body.component";
5
+ export { default as FlatTableRow } from "./flat-table-row/flat-table-row.component";
6
+ export { default as FlatTableRowHeader } from "./flat-table-row-header/flat-table-row-header.component";
7
+ export { default as FlatTableCell } from "./flat-table-cell/flat-table-cell.component";
8
+ export { default as FlatTableCheckbox } from "./flat-table-checkbox/flat-table-checkbox.component";
9
+ export { default as FlatTableBodyDraggable } from "./flat-table-body-draggable/flat-table-body-draggable.component";
10
+ export { default as Sort } from "./sort/sort.component";
11
+ export declare type TableBorderSize = "small" | "medium" | "large";
12
+ export declare type TableCellAlign = "left" | "center" | "right";
13
+ export type { FlatTableProps } from "./flat-table.component";
14
+ export type { FlatTableHeadProps } from "./flat-table-head";
15
+ export type { FlatTableHeaderProps } from "./flat-table-header";
16
+ export type { FlatTableBodyProps } from "./flat-table-body";
17
+ export type { FlatTableBodyDraggableProps } from "./flat-table-body-draggable";
18
+ export type { FlatTableRowProps } from "./flat-table-row";
19
+ export type { FlatTableRowHeaderProps } from "./flat-table-row-header";
20
+ export type { FlatTableCellProps } from "./flat-table-cell";
21
+ export type { FlatTableCheckboxProps } from "./flat-table-checkbox";
22
+ export type { SortProps } from "./sort";