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
@@ -12,10 +12,10 @@ const StyledFlatTableRowHeader = styled.th`
12
12
  let {
13
13
  align,
14
14
  theme,
15
- colWidth,
15
+ width,
16
16
  leftPosition,
17
17
  rightPosition,
18
- isTruncated,
18
+ truncate,
19
19
  expandable,
20
20
  verticalBorder,
21
21
  verticalBorderColor,
@@ -35,22 +35,22 @@ const StyledFlatTableRowHeader = styled.th`
35
35
  padding: 0;
36
36
  z-index: ${baseTheme.zIndex.overlay};
37
37
 
38
- ${colWidth && css`
39
- width: ${colWidth}px;
38
+ ${width && css`
39
+ width: ${width}px;
40
40
  `}
41
41
 
42
42
  &&&& {
43
43
  > div {
44
44
  box-sizing: border-box;
45
45
 
46
- ${isTruncated && css`
46
+ ${truncate && css`
47
47
  text-overflow: ellipsis;
48
48
  overflow: hidden;
49
49
  white-space: nowrap;
50
50
  `}
51
51
 
52
- ${colWidth && css`
53
- width: ${colWidth}px;
52
+ ${width && css`
53
+ width: ${width}px;
54
54
  `}
55
55
 
56
56
  ${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;
@@ -1,27 +1,24 @@
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
- import React, { useLayoutEffect, useRef, useState } from "react";
2
+ import React, { useLayoutEffect, useRef, useState, useContext } from "react";
3
3
  import PropTypes from "prop-types";
4
- import styledSystemPropTypes from "@styled-system/prop-types";
5
4
  import { StyledFlatTableWrapper, StyledFlatTable, StyledFlatTableFooter, StyledTableContainer } from "./flat-table.style";
6
5
  import { DrawerSidebarContext } from "../drawer";
7
- import { filterStyledSystemMarginProps } from "../../style/utils";
8
6
  import Events from "../../__internal__/utils/helpers/events/events";
9
7
  export const FlatTableThemeContext = /*#__PURE__*/React.createContext({
10
8
  setSelectedId: () => {}
11
9
  });
12
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
13
10
  const FOCUSABLE_ROW_AND_CELL_QUERY = "tbody tr, tbody tr td, tbody tr th";
14
- const FlatTable = _ref => {
11
+ export const FlatTable = _ref => {
15
12
  let {
16
13
  caption,
17
14
  children,
18
15
  hasStickyHead,
19
- colorTheme,
16
+ colorTheme = "dark",
20
17
  footer,
21
18
  hasStickyFooter = false,
22
19
  height,
23
20
  isZebra,
24
- size,
21
+ size = "medium",
25
22
  hasMaxHeight = false,
26
23
  ariaDescribedby,
27
24
  minHeight,
@@ -40,17 +37,18 @@ const FlatTable = _ref => {
40
37
  const tableStylingProps = {
41
38
  caption,
42
39
  isZebra,
43
- size
40
+ size,
41
+ "aria-describedby": ariaDescribedby
44
42
  };
45
- if (ariaDescribedby) {
46
- tableStylingProps["aria-describedby"] = ariaDescribedby;
47
- }
43
+ const {
44
+ isInSidebar
45
+ } = useContext(DrawerSidebarContext);
48
46
  useLayoutEffect(() => {
49
47
  const findRow = (rows, isFirstCol) => rows.find((row, index) => {
50
48
  const cells = Array.from(row.querySelectorAll("td, th"));
51
49
  const cell = isFirstCol ? cells.shift() : cells.pop();
52
50
  const rowSpan = cell?.getAttribute("rowspan");
53
- return rowSpan >= index + 1;
51
+ return rowSpan && Number(rowSpan) >= index + 1;
54
52
  });
55
53
 
56
54
  /* istanbul ignore else */
@@ -136,85 +134,46 @@ const FlatTable = _ref => {
136
134
  setSelectedId(focusableArray[0]?.getAttribute("id") || "");
137
135
  }
138
136
  }, [selectedId]);
139
- return /*#__PURE__*/React.createElement(DrawerSidebarContext.Consumer, null, _ref2 => {
140
- let {
141
- isInSidebar
142
- } = _ref2;
143
- return /*#__PURE__*/React.createElement(StyledFlatTableWrapper, _extends({
144
- ref: wrapperRef,
145
- "data-component": "flat-table-wrapper",
146
- isInSidebar: isInSidebar,
147
- hasStickyHead: hasStickyHead,
148
- colorTheme: colorTheme,
149
- minHeight: minHeight,
150
- overflowY: !isInSidebar && (hasStickyHead || hasStickyFooter) ? "auto" : undefined,
151
- height: addDefaultHeight && !hasMaxHeight ? "99%" : height,
152
- maxHeight: hasMaxHeight ? "100%" : undefined,
153
- display: "flex",
154
- flexDirection: "column",
155
- justifyContent: hasStickyFooter || height ? "space-between" : undefined,
156
- tabIndex: "0",
157
- role: "region",
158
- overflowX: width ? "hidden" : undefined,
159
- width: width,
160
- hasStickyFooter: hasStickyFooter,
161
- hasVerticalScrollbar: hasVerticalScrollbar,
162
- hasHorizontalScrollbar: hasHorizontalScrollbar,
163
- hasFooter: !!footer,
164
- firstColRowSpanIndex: firstColRowSpanIndex,
165
- lastColRowSpanIndex: lastColRowSpanIndex,
166
- onKeyDown: handleKeyDown
167
- }, rest), /*#__PURE__*/React.createElement(StyledTableContainer, {
168
- overflowX: overflowX,
169
- width: width
170
- }, /*#__PURE__*/React.createElement(StyledFlatTable, _extends({
171
- ref: tableRef,
172
- "data-component": "flat-table"
173
- }, tableStylingProps), caption ? /*#__PURE__*/React.createElement("caption", null, caption) : null, /*#__PURE__*/React.createElement(FlatTableThemeContext.Provider, {
174
- value: {
175
- colorTheme,
176
- size,
177
- setSelectedId,
178
- selectedId
179
- }
180
- }, children))), footer && /*#__PURE__*/React.createElement(StyledFlatTableFooter, {
181
- hasStickyFooter: hasStickyFooter
182
- }, footer));
183
- });
184
- };
185
- FlatTable.propTypes = {
186
- ...marginPropTypes,
187
- /** The HTML id of the element that contains a description of this table. */
188
- ariaDescribedby: PropTypes.string,
189
- /** A string to render as the table's caption */
190
- caption: PropTypes.string,
191
- /** FlatTableHead and FlatTableBody */
192
- children: PropTypes.node.isRequired,
193
- /** If true, the header does not scroll with the content */
194
- hasStickyHead: PropTypes.bool,
195
- /** `FlatTable` color theme */
196
- colorTheme: PropTypes.oneOf(["light", "transparent-base", "transparent-white", "dark"]),
197
- /** Content to be rendered at the foot of the table */
198
- footer: PropTypes.node,
199
- /** If true, the header does not scroll with the content */
200
- hasStickyFooter: PropTypes.bool,
201
- /** Set the height of the table. String can be any valid CSS string, numbers will be converted to pixels. */
202
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
203
- /** Set the min-height of the table. A string can be any valid CSS string, numbers will be converted to pixels. */
204
- minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
205
- /** Toggles the zebra striping for the table rows */
206
- isZebra: PropTypes.bool,
207
- /** Used to define the tables size Renders as: 'compact', 'small', 'medium', 'large' and 'extraLarge' */
208
- size: PropTypes.oneOf(["compact", "small", "medium", "large", "extraLarge"]),
209
- /** Applies max-height of 100% to FlatTable if true */
210
- hasMaxHeight: PropTypes.bool,
211
- /** Set the overflow X of the table wrapper. Any valid CSS string */
212
- overflowX: PropTypes.string,
213
- /** Width of the table. Any valid CSS string */
214
- width: PropTypes.string
215
- };
216
- FlatTable.defaultProps = {
217
- colorTheme: "dark",
218
- size: "medium"
137
+ return /*#__PURE__*/React.createElement(StyledFlatTableWrapper, _extends({
138
+ ref: wrapperRef,
139
+ "data-component": "flat-table-wrapper",
140
+ isInSidebar: isInSidebar,
141
+ hasStickyHead: hasStickyHead,
142
+ colorTheme: colorTheme,
143
+ minHeight: minHeight,
144
+ overflowY: !isInSidebar && (hasStickyHead || hasStickyFooter) ? "auto" : undefined,
145
+ height: addDefaultHeight && !hasMaxHeight ? "99%" : height,
146
+ maxHeight: hasMaxHeight ? "100%" : undefined,
147
+ display: "flex",
148
+ flexDirection: "column",
149
+ justifyContent: hasStickyFooter || height ? "space-between" : undefined,
150
+ tabIndex: 0,
151
+ role: "region",
152
+ overflowX: width ? "hidden" : undefined,
153
+ width: width,
154
+ hasStickyFooter: hasStickyFooter,
155
+ hasVerticalScrollbar: hasVerticalScrollbar,
156
+ hasHorizontalScrollbar: hasHorizontalScrollbar,
157
+ footer: !!footer,
158
+ firstColRowSpanIndex: firstColRowSpanIndex,
159
+ lastColRowSpanIndex: lastColRowSpanIndex,
160
+ onKeyDown: handleKeyDown
161
+ }, rest), /*#__PURE__*/React.createElement(StyledTableContainer, {
162
+ overflowX: overflowX,
163
+ width: width
164
+ }, /*#__PURE__*/React.createElement(StyledFlatTable, _extends({
165
+ ref: tableRef,
166
+ "data-component": "flat-table"
167
+ }, tableStylingProps), caption ? /*#__PURE__*/React.createElement("caption", null, caption) : null, /*#__PURE__*/React.createElement(FlatTableThemeContext.Provider, {
168
+ value: {
169
+ colorTheme,
170
+ size,
171
+ setSelectedId,
172
+ selectedId
173
+ }
174
+ }, children))), footer && /*#__PURE__*/React.createElement(StyledFlatTableFooter, {
175
+ hasStickyFooter: hasStickyFooter
176
+ }, footer));
219
177
  };
178
+ FlatTable.displayName = "FlatTable";
220
179
  export default FlatTable;
@@ -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, };
@@ -99,9 +99,6 @@ const StyledFlatTable = styled.table`
99
99
  `;
100
100
  }}
101
101
  `;
102
- StyledFlatTable.defaultProps = {
103
- size: "medium"
104
- };
105
102
  const StyledFlatTableWrapper = styled(Box)`
106
103
  border-top-left-radius: var(--borderRadius100);
107
104
  border-top-right-radius: var(--borderRadius100);
@@ -301,9 +298,9 @@ const StyledFlatTableWrapper = styled(Box)`
301
298
 
302
299
  ${_ref14 => {
303
300
  let {
304
- hasFooter
301
+ footer
305
302
  } = _ref14;
306
- return hasFooter && css`
303
+ return footer && css`
307
304
  tr:last-child:focus {
308
305
  :after {
309
306
  border-bottom-left-radius: var(--borderRadius000);
@@ -314,65 +311,45 @@ const StyledFlatTableWrapper = styled(Box)`
314
311
 
315
312
  ${_ref15 => {
316
313
  let {
317
- hasFooter
314
+ footer,
315
+ firstColRowSpanIndex,
316
+ lastColRowSpanIndex,
317
+ hasHorizontalScrollbar,
318
+ hasVerticalScrollbar
318
319
  } = _ref15;
319
- return !hasFooter && css`
320
+ return !footer && css`
320
321
  tbody {
321
- ${_ref16 => {
322
- let {
323
- firstColRowSpanIndex
324
- } = _ref16;
325
- return firstColRowSpanIndex >= 0 && css`
326
- ${StyledFlatTableRow}:nth-of-type(${firstColRowSpanIndex + 1}) {
327
- th:first-child,
328
- td:first-child {
329
- border-bottom-left-radius: var(--borderRadius100);
330
- }
322
+ ${firstColRowSpanIndex >= 0 && css`
323
+ ${StyledFlatTableRow}:nth-of-type(${firstColRowSpanIndex + 1}) {
324
+ th:first-child,
325
+ td:first-child {
326
+ border-bottom-left-radius: var(--borderRadius100);
331
327
  }
332
- `;
333
- }}
328
+ }
329
+ `}
334
330
 
335
- ${_ref17 => {
336
- let {
337
- lastColRowSpanIndex,
338
- hasHorizontalScrollbar
339
- } = _ref17;
340
- return lastColRowSpanIndex >= 0 && !hasHorizontalScrollbar && css`
341
- ${StyledFlatTableRow}:nth-of-type(${lastColRowSpanIndex + 1}) {
342
- th:last-child,
343
- td:last-child {
344
- border-bottom-right-radius: var(--borderRadius100);
345
- }
331
+ ${lastColRowSpanIndex >= 0 && !hasHorizontalScrollbar && css`
332
+ ${StyledFlatTableRow}:nth-of-type(${lastColRowSpanIndex + 1}) {
333
+ th:last-child,
334
+ td:last-child {
335
+ border-bottom-right-radius: var(--borderRadius100);
346
336
  }
347
- `;
348
- }}
337
+ }
338
+ `}
349
339
 
350
340
  ${StyledFlatTableRow}:last-of-type {
351
- ${_ref18 => {
352
- let {
353
- hasHorizontalScrollbar,
354
- firstColRowSpanIndex
355
- } = _ref18;
356
- return !hasHorizontalScrollbar && firstColRowSpanIndex === -1 && css`
357
- th:first-child,
358
- td:first-child {
359
- border-bottom-left-radius: var(--borderRadius100);
360
- }
361
- `;
362
- }}
363
- ${_ref19 => {
364
- let {
365
- hasVerticalScrollbar,
366
- hasHorizontalScrollbar,
367
- lastColRowSpanIndex
368
- } = _ref19;
369
- return !hasVerticalScrollbar && !hasHorizontalScrollbar && lastColRowSpanIndex === -1 && css`
370
- th:last-child,
371
- td:last-child {
372
- border-bottom-right-radius: var(--borderRadius100);
373
- }
374
- `;
375
- }}
341
+ ${!hasHorizontalScrollbar && firstColRowSpanIndex === -1 && css`
342
+ th:first-child,
343
+ td:first-child {
344
+ border-bottom-left-radius: var(--borderRadius100);
345
+ }
346
+ `}
347
+ ${!hasVerticalScrollbar && !hasHorizontalScrollbar && lastColRowSpanIndex === -1 && css`
348
+ th:last-child,
349
+ td:last-child {
350
+ border-bottom-right-radius: var(--borderRadius100);
351
+ }
352
+ `}
376
353
  }
377
354
  }
378
355
  `;
@@ -382,11 +359,11 @@ StyledFlatTableWrapper.defaultProps = {
382
359
  theme: baseTheme
383
360
  };
384
361
  const StyledFlatTableFooter = styled.div`
385
- ${_ref20 => {
362
+ ${_ref16 => {
386
363
  let {
387
364
  hasStickyFooter,
388
365
  theme
389
- } = _ref20;
366
+ } = _ref16;
390
367
  return hasStickyFooter && css`
391
368
  position: sticky;
392
369
  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";
@@ -1,2 +1,2 @@
1
- export { default } from "./sort";
2
- export * from "./sort";
1
+ export { default } from "./sort.component";
2
+ export type { SortProps } from "./sort.component";
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ export interface SortProps {
3
+ /** if `asc` it will show `sort_up` icon, if `desc` it will show `sort_down` */
4
+ sortType?: "ascending" | "descending" | false;
5
+ /** Callback fired when the `FlatTableSortHeader` is clicked */
6
+ onClick?: () => void;
7
+ /** Sets the content of `FlatTableSortHeader` */
8
+ children?: React.ReactNode;
9
+ }
10
+ declare const Sort: ({ children, onClick, sortType }: SortProps) => React.JSX.Element;
11
+ export default Sort;
@@ -14,7 +14,7 @@ const Sort = _ref => {
14
14
  const onKeyDown = e => {
15
15
  if (Event.isEnterOrSpaceKey(e)) {
16
16
  e.preventDefault();
17
- return onClick();
17
+ return onClick?.();
18
18
  }
19
19
  return null;
20
20
  };
@@ -22,7 +22,6 @@ const Sort = _ref => {
22
22
  hidden: true,
23
23
  id: id.current
24
24
  }, children, sortType ? `, sort type ${sortType}` : ", sortable"), /*#__PURE__*/React.createElement(StyledSort, {
25
- type: "button",
26
25
  role: "button",
27
26
  onKeyDown: onKeyDown,
28
27
  tabIndex: 0,
@@ -34,12 +33,4 @@ const Sort = _ref => {
34
33
  color: "--colorsUtilityMajor200"
35
34
  })), !sortType && /*#__PURE__*/React.createElement(StyledSpaceHolder, null));
36
35
  };
37
- Sort.propTypes = {
38
- /** if `asc` it will show `sort_up` icon, if `desc` it will show `sort_down` */
39
- sortType: PropTypes.oneOf(["ascending", "descending", false]),
40
- /** Callback fired when the `FlatTableSortHeader` is clicked */
41
- onClick: PropTypes.func,
42
- /** The content of `FlatTableSortHeader` */
43
- children: PropTypes.node
44
- };
45
36
  export default Sort;
@@ -0,0 +1,4 @@
1
+ import { SortProps } from "./sort.component";
2
+ declare const StyledSort: import("styled-components").StyledComponent<"div", any, Pick<SortProps, "sortType">, never>;
3
+ declare const StyledSpaceHolder: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export { StyledSort, StyledSpaceHolder };
@@ -1,27 +1,9 @@
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 from "react";
3
3
  import PropTypes from "prop-types";
4
- import styled, { css } from "styled-components";
5
- import { baseTheme } from "../../style/themes";
6
- import StyledNavigationBar from "../navigation-bar/navigation-bar.style";
4
+ import styled from "styled-components";
7
5
  import Box from "../box";
8
- const StyledGlobalHeader = styled(StyledNavigationBar).attrs(_ref => {
9
- let {
10
- theme
11
- } = _ref;
12
- return {
13
- theme: theme || /* istanbul ignore next */baseTheme
14
- };
15
- })`
16
- ${_ref2 => {
17
- let {
18
- theme
19
- } = _ref2;
20
- return css`
21
- z-index: ${theme.zIndex.globalNav};
22
- `;
23
- }}
24
- `;
6
+ import NavigationBar from "../navigation-bar";
25
7
  const StyledLogo = styled(Box)`
26
8
  display: flex;
27
9
  align-items: center;
@@ -42,19 +24,14 @@ const StyledLogo = styled(Box)`
42
24
  margin-left: var(--spacing500);
43
25
  }
44
26
  `;
45
- const GlobalHeader = _ref3 => {
27
+ const GlobalHeader = _ref => {
46
28
  let {
47
29
  children,
48
30
  logo,
49
31
  ...rest
50
- } = _ref3;
51
- return /*#__PURE__*/React.createElement(StyledGlobalHeader, _extends({
52
- "aria-label": "Global Header",
53
- "data-component": "global-header",
54
- navigationType: "black",
55
- orientation: "top",
56
- offset: "0px",
57
- position: "fixed"
32
+ } = _ref;
33
+ return /*#__PURE__*/React.createElement(NavigationBar, _extends({
34
+ isGlobal: true
58
35
  }, rest), logo && /*#__PURE__*/React.createElement(StyledLogo, {
59
36
  "data-element": "global-header-logo-wrapper"
60
37
  }, logo), children);
@@ -11,6 +11,7 @@ import useClickAwayListener from "../../../../hooks/__internal__/useClickAwayLis
11
11
  import guid from "../../../../__internal__/utils/helpers/guid";
12
12
  import { SCROLLABLE_BLOCK, SCROLLABLE_BLOCK_PARENT, BLOCK_INDEX_SELECTOR, ALL_CHILDREN_SELECTOR } from "../locators";
13
13
  import useStableCallback from "../../../../hooks/__internal__/useStableCallback/useStableCallback";
14
+ import FixedNavigationBarContext from "../../../navigation-bar/fixed-navigation-bar.context";
14
15
  const Submenu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
15
16
  let {
16
17
  children,
@@ -46,6 +47,9 @@ const Submenu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
46
47
  const shiftTabPressed = useRef(false);
47
48
  const focusFirstMenuItemOnOpen = useRef(false);
48
49
  const numberOfChildren = submenuItemIds.length;
50
+ const {
51
+ submenuMaxHeight
52
+ } = useContext(FixedNavigationBarContext);
49
53
  const onSubmenuOpen = useStableCallback(onSubmenuOpenProp);
50
54
  const blockIndex = useMemo(() => {
51
55
  const items = submenuRef.current?.querySelectorAll(BLOCK_INDEX_SELECTOR);
@@ -282,7 +286,8 @@ const Submenu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
282
286
  submenuDirection: submenuDirection,
283
287
  variant: variant,
284
288
  menuType: menuType,
285
- role: blockIndex === 0 ? "presentation" : "list"
289
+ role: blockIndex === 0 ? "presentation" : "list",
290
+ maxHeight: submenuMaxHeight
286
291
  }, /*#__PURE__*/React.createElement(SubmenuContext.Provider, {
287
292
  value: {
288
293
  submenuFocusId,
@@ -10,6 +10,7 @@ interface StyledSubmenuWrapperProps extends SharedStyleProps {
10
10
  }
11
11
  interface StyledSubmenuProps extends SharedStyleProps, Pick<SubmenuProps, "variant"> {
12
12
  submenuDirection?: string;
13
+ maxHeight?: string;
13
14
  }
14
15
  declare const StyledSubmenuWrapper: import("styled-components").StyledComponent<"div", any, StyledSubmenuWrapperProps, never>;
15
16
  declare const StyledSubmenu: import("styled-components").StyledComponent<"ul", any, StyledSubmenuProps, never>;
@@ -45,7 +45,8 @@ const StyledSubmenu = styled.ul`
45
45
  menuType,
46
46
  submenuDirection,
47
47
  variant,
48
- inFullscreenView
48
+ inFullscreenView,
49
+ maxHeight
49
50
  } = _ref3;
50
51
  return css`
51
52
  ${!inFullscreenView && menuType && css`
@@ -69,6 +70,8 @@ const StyledSubmenu = styled.ul`
69
70
  ${!inFullscreenView && css`
70
71
  border-bottom-right-radius: var(--borderRadius100);
71
72
  border-bottom-left-radius: var(--borderRadius100);
73
+ overflow-y: auto;
74
+ ${maxHeight && `max-height: ${maxHeight};`}
72
75
 
73
76
  ${StyledMenuItem}:last-child a,
74
77
  ${StyledMenuItem}:last-child button,
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { NavigationBarProps } from ".";
3
+ declare type FixedNavigationBarContextProps = {
4
+ submenuMaxHeight?: string;
5
+ };
6
+ declare const FixedNavigationBarContext: React.Context<FixedNavigationBarContextProps>;
7
+ export interface FixedNavigationBarContextProviderProps extends Pick<NavigationBarProps, "position" | "orientation" | "offset" | "children"> {
8
+ navbarElement: HTMLElement | null;
9
+ }
10
+ export declare const FixedNavigationBarContextProvider: ({ position, orientation, offset, children, navbarElement, }: FixedNavigationBarContextProviderProps) => React.JSX.Element;
11
+ export default FixedNavigationBarContext;