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,31 @@
1
+ import React, { createContext, useState, useCallback } from "react";
2
+ import useResizeObserver from "../../hooks/__internal__/useResizeObserver/useResizeObserver";
3
+ const FixedNavigationBarContext = /*#__PURE__*/createContext({});
4
+ export const FixedNavigationBarContextProvider = _ref => {
5
+ let {
6
+ position,
7
+ orientation,
8
+ offset,
9
+ children,
10
+ navbarElement
11
+ } = _ref;
12
+ const [navbarHeight, setNavbarHeight] = useState(navbarElement?.offsetHeight);
13
+ const updateHeight = useCallback(() => setNavbarHeight(navbarElement?.offsetHeight), [navbarElement]);
14
+ useResizeObserver({
15
+ current: navbarElement
16
+ }, updateHeight);
17
+ let submenuMaxHeight;
18
+ if (position === "fixed") {
19
+ if (orientation === "top" && navbarHeight !== undefined) {
20
+ submenuMaxHeight = `calc(100vh - ${navbarHeight}px - ${offset})`;
21
+ } else if (orientation === "bottom") {
22
+ submenuMaxHeight = offset;
23
+ }
24
+ }
25
+ return /*#__PURE__*/React.createElement(FixedNavigationBarContext.Provider, {
26
+ value: {
27
+ submenuMaxHeight
28
+ }
29
+ }, children);
30
+ };
31
+ export default FixedNavigationBarContext;
@@ -18,6 +18,8 @@ export interface NavigationBarProps extends PaddingProps, FlexboxProps {
18
18
  offset?: string;
19
19
  /** Defines whether the navigation bar should be positioned top or bottom */
20
20
  orientation?: Orientation;
21
+ /** @private @ignore set to true only when rendering the GlobalHeader component */
22
+ isGlobal?: boolean;
21
23
  }
22
- export declare const NavigationBar: ({ navigationType, isLoading, children, ariaLabel, position, offset, orientation, ...props }: NavigationBarProps) => JSX.Element;
24
+ export declare const NavigationBar: ({ navigationType, isLoading, children, ariaLabel, position, offset, orientation, isGlobal, ...props }: NavigationBarProps) => JSX.Element;
23
25
  export default NavigationBar;
@@ -1,7 +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
- import React from "react";
2
+ import React, { useState } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import StyledNavigationBar from "./navigation-bar.style";
5
+ import { FixedNavigationBarContextProvider } from "./fixed-navigation-bar.context";
5
6
  const NavigationBar = _ref => {
6
7
  let {
7
8
  navigationType = "light",
@@ -11,17 +12,27 @@ const NavigationBar = _ref => {
11
12
  position,
12
13
  offset = "0",
13
14
  orientation,
15
+ isGlobal,
14
16
  ...props
15
17
  } = _ref;
18
+ const [navbarElement, setNavbarElement] = useState(null);
16
19
  return /*#__PURE__*/React.createElement(StyledNavigationBar, _extends({
17
20
  role: "navigation",
18
- "aria-label": ariaLabel,
19
- navigationType: navigationType,
20
- "data-component": "navigation-bar",
21
- position: position,
22
- offset: offset,
23
- orientation: orientation
24
- }, props), !isLoading && children);
21
+ "data-component": isGlobal ? "global-header" : "navigation-bar",
22
+ "aria-label": isGlobal ? "Global Header" : ariaLabel,
23
+ navigationType: isGlobal ? "black" : navigationType,
24
+ orientation: isGlobal ? "top" : orientation,
25
+ offset: isGlobal ? "0px" : offset,
26
+ position: isGlobal ? "fixed" : position
27
+ }, props, {
28
+ isGlobal: isGlobal,
29
+ ref: setNavbarElement
30
+ }), /*#__PURE__*/React.createElement(FixedNavigationBarContextProvider, {
31
+ orientation: isGlobal ? "top" : orientation,
32
+ offset: isGlobal ? "0px" : offset,
33
+ position: isGlobal ? "fixed" : position,
34
+ navbarElement: navbarElement
35
+ }, !isLoading && children));
25
36
  };
26
37
  NavigationBar.propTypes = {
27
38
  "alignContent": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "baseline", "center", "end", "flex-end", "flex-start", "inherit", "initial", "normal", "revert", "space-around", "space-between", "space-evenly", "start", "stretch", "unset"]), PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "baseline", "center", "end", "flex-end", "flex-start", "inherit", "initial", "normal", "revert", "space-around", "space-between", "space-evenly", "start", "stretch", "unset", null]), PropTypes.shape({
@@ -563,6 +574,7 @@ NavigationBar.propTypes = {
563
574
  "valueOf": PropTypes.func.isRequired
564
575
  })]),
565
576
  "flexWrap": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert", "unset", "wrap-reverse", "wrap"]), PropTypes.arrayOf(PropTypes.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert", "unset", "wrap-reverse", "wrap", null])), PropTypes.object]),
577
+ "isGlobal": PropTypes.bool,
566
578
  "isLoading": PropTypes.bool,
567
579
  "justifyContent": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "center", "end", "flex-end", "flex-start", "inherit", "initial", "left", "normal", "revert", "right", "space-around", "space-between", "space-evenly", "start", "stretch", "unset"]), PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "center", "end", "flex-end", "flex-start", "inherit", "initial", "left", "normal", "revert", "right", "space-around", "space-between", "space-evenly", "start", "stretch", "unset", null]), PropTypes.shape({
568
580
  "__@iterator": PropTypes.func.isRequired,
@@ -9,6 +9,8 @@ export declare type StyledNavigationBarProps = PaddingProps & FlexboxProps & {
9
9
  offset?: string;
10
10
  /** Defines whether the navigation bar should be positioned top or bottom */
11
11
  orientation?: Orientation;
12
+ /** set to true only when rendering the GlobalHeader component */
13
+ isGlobal?: boolean;
12
14
  };
13
15
  declare const StyledNavigationBar: import("styled-components").StyledComponent<"nav", any, PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
14
16
  /** Color scheme of navigation component */
@@ -19,5 +21,7 @@ declare const StyledNavigationBar: import("styled-components").StyledComponent<"
19
21
  offset?: string | undefined;
20
22
  /** Defines whether the navigation bar should be positioned top or bottom */
21
23
  orientation?: Orientation | undefined;
24
+ /** set to true only when rendering the GlobalHeader component */
25
+ isGlobal?: boolean | undefined;
22
26
  }, never>;
23
27
  export default StyledNavigationBar;
@@ -55,11 +55,12 @@ const StyledNavigationBar = styled.nav`
55
55
  ${_ref2 => {
56
56
  let {
57
57
  navigationType,
58
- theme
58
+ theme,
59
+ isGlobal
59
60
  } = _ref2;
60
61
  return css`
61
62
  min-height: 40px;
62
- z-index: ${theme.zIndex.nav};
63
+ z-index: ${isGlobal ? theme.zIndex.globalNav : theme.zIndex.nav};
63
64
 
64
65
  ${navigationType === "light" && css`
65
66
  background-color: var(--colorsComponentsMenuSpringStandard500);
@@ -8,11 +8,26 @@ const setupResizeObserverMock = () => {
8
8
  if (!window) {
9
9
  return;
10
10
  }
11
- window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(() => ({
12
- disconnect: jest.fn(),
13
- observe: jest.fn(),
14
- unobserve: jest.fn()
15
- }));
11
+ window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(callback => {
12
+ let hasCalledCallback = false;
13
+ const observer = {
14
+ disconnect: jest.fn(),
15
+ // observe mock needs to actually call the callback straight away, as this is what a real ResizeObserver does
16
+ // and this behaviour is needed for the FixedNavigationBarContextProvider to work properly.
17
+ // Note that we must only call the callback once per ResizeObserver instance, to avoid stack overflows in
18
+ // react-virtual.
19
+ observe: jest.fn(target => {
20
+ if (!hasCalledCallback) {
21
+ hasCalledCallback = true;
22
+ callback([{
23
+ target
24
+ }], observer);
25
+ }
26
+ }),
27
+ unobserve: jest.fn()
28
+ };
29
+ return observer;
30
+ });
16
31
  };
17
32
  var _default = setupResizeObserverMock;
18
33
  exports.default = _default;
@@ -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;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.FlatTableBody = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -17,9 +17,10 @@ const FlatTableBody = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
17
17
  ref: ref
18
18
  }, rest), children);
19
19
  });
20
+ exports.FlatTableBody = FlatTableBody;
20
21
  FlatTableBody.propTypes = {
21
- /** Array of FlatTableRow. */
22
- children: _propTypes.default.node.isRequired
22
+ "children": _propTypes.default.node
23
23
  };
24
+ FlatTableBody.displayName = "FlatTableBody";
24
25
  var _default = FlatTableBody;
25
26
  exports.default = _default;
@@ -1,2 +1,2 @@
1
- export { default } from "./flat-table-body";
2
- export * from "./flat-table-body";
1
+ export { default } from "./flat-table-body.component";
2
+ export type { FlatTableBodyProps } from "./flat-table-body.component";
@@ -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;
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.FlatTableBodyDraggable = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
9
  var _reactDnd = require("react-dnd");
9
10
  var _reactDndHtml5Backend = require("react-dnd-html5-backend");
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _icon = _interopRequireDefault(require("../../icon/icon.style"));
12
12
  var _flatTableBodyDraggable = _interopRequireDefault(require("./flat-table-body-draggable.style"));
13
13
  var _flatTableCell = _interopRequireDefault(require("../flat-table-cell/flat-table-cell.component"));
@@ -29,7 +29,7 @@ const DropTarget = _ref => {
29
29
  },
30
30
  drop() {
31
31
  setIsDragging(false);
32
- getOrder();
32
+ getOrder?.();
33
33
  }
34
34
  });
35
35
  return /*#__PURE__*/_react.default.createElement(_flatTableBodyDraggable.default, _extends({
@@ -38,10 +38,6 @@ const DropTarget = _ref => {
38
38
  isDragging: isDragging
39
39
  }, rest), children);
40
40
  };
41
- DropTarget.propTypes = {
42
- children: _propTypes.default.node.isRequired,
43
- getOrder: _propTypes.default.func
44
- };
45
41
  const FlatTableBodyDraggable = _ref2 => {
46
42
  let {
47
43
  children,
@@ -58,7 +54,7 @@ const FlatTableBodyDraggable = _ref2 => {
58
54
  }
59
55
  }, [children]);
60
56
  const findItem = id => {
61
- const draggableItem = draggableItems.filter(item => `${item.props.id}` === id)[0];
57
+ const draggableItem = draggableItems.filter(item => /*#__PURE__*/_react.default.isValidElement(item) && `${item.props.id}` === id)[0];
62
58
  return {
63
59
  draggableItem,
64
60
  index: draggableItems.indexOf(draggableItem)
@@ -79,14 +75,14 @@ const FlatTableBodyDraggable = _ref2 => {
79
75
  if (!getOrder) {
80
76
  return;
81
77
  }
82
- const draggableItemIds = draggableItems.map(draggableItem => draggableItem.props.id);
78
+ const draggableItemIds = draggableItems.map(draggableItem => /*#__PURE__*/_react.default.isValidElement(draggableItem) && draggableItem.props.id);
83
79
  getOrder(draggableItemIds);
84
80
  };
85
81
  return /*#__PURE__*/_react.default.createElement(_reactDnd.DndProvider, {
86
82
  backend: _reactDndHtml5Backend.HTML5Backend
87
83
  }, /*#__PURE__*/_react.default.createElement(DropTarget, _extends({
88
84
  getOrder: getItemsId
89
- }, rest), draggableItems.map(item => /*#__PURE__*/_react.default.cloneElement(item, {
85
+ }, rest), draggableItems.map(item => /*#__PURE__*/_react.default.isValidElement(item) && /*#__PURE__*/_react.default.cloneElement(item, {
90
86
  id: `${item.props.id}`,
91
87
  moveItem,
92
88
  findItem,
@@ -97,11 +93,6 @@ const FlatTableBodyDraggable = _ref2 => {
97
93
  type: "drag"
98
94
  })), item.props.children]))));
99
95
  };
100
- FlatTableBodyDraggable.propTypes = {
101
- /** Callback fired when order is changed */
102
- getOrder: _propTypes.default.func,
103
- /** Array of FlatTableRow. */
104
- children: _propTypes.default.node.isRequired
105
- };
96
+ exports.FlatTableBodyDraggable = FlatTableBodyDraggable;
106
97
  var _default = FlatTableBodyDraggable;
107
98
  exports.default = _default;
@@ -0,0 +1,4 @@
1
+ declare const StyledFlatTableBodyDraggable: import("styled-components").StyledComponent<"tbody", any, {
2
+ isDragging: boolean;
3
+ }, never>;
4
+ export default StyledFlatTableBodyDraggable;
@@ -1,2 +1,2 @@
1
- export { default } from "./flat-table-body-draggable";
2
- export * from "./flat-table-body-draggable";
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;
@@ -3,12 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.FlatTableCell = 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 _flatTableCell = require("./flat-table-cell.style");
11
- var _utils = require("../../../style/utils");
12
10
  var _icon = _interopRequireDefault(require("../../icon"));
13
11
  var _flatTable = require("../flat-table.component");
14
12
  var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
@@ -16,13 +14,10 @@ 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 FlatTableCell = _ref => {
21
18
  let {
22
19
  align = "left",
23
20
  children,
24
- colspan,
25
- rowspan,
26
21
  pl,
27
22
  expandable = false,
28
23
  onClick,
@@ -34,6 +29,8 @@ const FlatTableCell = _ref => {
34
29
  width,
35
30
  truncate = false,
36
31
  title,
32
+ colspan,
33
+ rowspan,
37
34
  ...rest
38
35
  } = _ref;
39
36
  const ref = (0, _react.useRef)(null);
@@ -58,8 +55,6 @@ const FlatTableCell = _ref => {
58
55
  ref: ref,
59
56
  align: align,
60
57
  "data-element": "flat-table-cell",
61
- colSpan: colspan,
62
- rowSpan: rowspan,
63
58
  pl: pl,
64
59
  onClick: expandable && onClick ? onClick : undefined,
65
60
  tabIndex: expandable && onClick ? tabIndex : undefined,
@@ -68,6 +63,10 @@ const FlatTableCell = _ref => {
68
63
  isTruncated: truncate,
69
64
  expandable: expandable,
70
65
  id: id.current
66
+ }, colspan !== undefined && {
67
+ colSpan: Number(colspan)
68
+ }, rowspan !== undefined && {
69
+ rowSpan: Number(rowspan)
71
70
  }, rest), /*#__PURE__*/_react.default.createElement(_flatTableCell.StyledCellContent, {
72
71
  title: truncate && !title && typeof children === "string" ? children : title,
73
72
  expandable: expandable
@@ -77,67 +76,7 @@ const FlatTableCell = _ref => {
77
76
  mr: "8px"
78
77
  }), children));
79
78
  };
80
- FlatTableCell.propTypes = {
81
- /** Styled system padding props */
82
- ...paddingPropTypes,
83
- /** Content alignment */
84
- align: _propTypes.default.oneOf(["center", "left", "right"]),
85
- /** Cell content */
86
- children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]),
87
- /** Number of columns that a cell should span */
88
- colspan: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
89
- /** Number of rows that a cell should span */
90
- rowspan: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
91
- /** Column width, pass a number to set a fixed width in pixels */
92
- width: _propTypes.default.number,
93
- /** Truncate cell content and add ellipsis to any text that overflows */
94
- truncate: _propTypes.default.bool,
95
- /** Title text to display if cell content truncates */
96
- title: _propTypes.default.string,
97
- /**
98
- * @private
99
- * @ignore
100
- */
101
- expandable: _propTypes.default.bool,
102
- /**
103
- * @private
104
- * @ignore
105
- */
106
- onClick: _propTypes.default.func,
107
- /**
108
- * @private
109
- * @ignore
110
- */
111
- onKeyDown: _propTypes.default.func,
112
- /**
113
- * @private
114
- * @ignore
115
- * Sets the left position when sticky column found
116
- */
117
- leftPosition: _propTypes.default.number,
118
- /**
119
- * @private
120
- * @ignore
121
- * Sets the right position when sticky column found
122
- */
123
- rightPosition: _propTypes.default.number,
124
- /**
125
- * @private
126
- * @ignore
127
- * Index of cell within row
128
- */
129
- cellIndex: _propTypes.default.number,
130
- /**
131
- * @private
132
- * @ignore
133
- * Callback to report the offsetWidth
134
- */
135
- reportCellWidth: _propTypes.default.func,
136
- /** Sets a custom vertical right border */
137
- verticalBorder: _propTypes.default.oneOf(["small", "medium", "large"]),
138
- /** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
139
- verticalBorderColor: _propTypes.default.string
140
- };
79
+ exports.FlatTableCell = FlatTableCell;
141
80
  FlatTableCell.displayName = "FlatTableCell";
142
81
  var _default = FlatTableCell;
143
82
  exports.default = _default;
@@ -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 * from "./flat-table-cell";
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;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.FlatTableCheckbox = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _flatTableCheckbox = _interopRequireDefault(require("./flat-table-checkbox.style"));
@@ -61,44 +61,7 @@ const FlatTableCheckbox = _ref => {
61
61
  onKeyDown: handleKeyDown
62
62
  }));
63
63
  };
64
- FlatTableCheckbox.propTypes = {
65
- /** Prop to polymorphically render either a 'th' or 'td' element */
66
- as: _propTypes.default.oneOf(["td", "th"]),
67
- /** Prop to set checked prop on Checkbox */
68
- checked: _propTypes.default.bool,
69
- /** Callback to be called onChange in Checkbox */
70
- onChange: _propTypes.default.func,
71
- /** Callback function to be called when click event received */
72
- onClick: _propTypes.default.func,
73
- /** Whether to render the checkbox or not, defaults to true */
74
- selectable: _propTypes.default.bool,
75
- /** The id of the element that labels the input */
76
- ariaLabelledBy: _propTypes.default.string,
77
- /**
78
- * @private
79
- * @ignore
80
- * Sets the left position when sticky column found
81
- */
82
- leftPosition: _propTypes.default.number,
83
- /**
84
- * @private
85
- * @ignore
86
- * Sets the right position when sticky column found
87
- */
88
- rightPosition: _propTypes.default.number,
89
- /**
90
- * @private
91
- * @ignore
92
- * Index of cell within row
93
- */
94
- cellIndex: _propTypes.default.number,
95
- /**
96
- * @private
97
- * @ignore
98
- * Callback to report the offsetWidth
99
- */
100
- reportCellWidth: _propTypes.default.func
101
- };
64
+ exports.FlatTableCheckbox = FlatTableCheckbox;
102
65
  FlatTableCheckbox.displayName = "FlatTableCheckbox";
103
66
  var _default = FlatTableCheckbox;
104
67
  exports.default = _default;
@@ -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;