carbon-react 106.6.2 → 106.6.5

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 (92) hide show
  1. package/esm/__spec_helper__/expect.d.ts +8 -1
  2. package/esm/__spec_helper__/expect.js +1 -5
  3. package/esm/__spec_helper__/test-utils.d.ts +71 -33
  4. package/esm/__spec_helper__/test-utils.js +63 -65
  5. package/esm/components/action-popover/action-popover-context.d.ts +7 -2
  6. package/esm/components/action-popover/action-popover-context.js +1 -1
  7. package/esm/components/action-popover/action-popover-divider/action-popover-divider.component.d.ts +1 -1
  8. package/esm/components/action-popover/action-popover-item/action-popover-item.component.d.ts +28 -41
  9. package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +99 -118
  10. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.d.ts +35 -2
  11. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +42 -53
  12. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +20 -18
  13. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +13 -5
  14. package/esm/components/action-popover/action-popover-test.stories.js +76 -0
  15. package/esm/components/action-popover/action-popover.component.d.ts +30 -53
  16. package/esm/components/action-popover/action-popover.component.js +205 -67
  17. package/esm/components/action-popover/action-popover.style.d.ts +17 -11
  18. package/esm/components/action-popover/action-popover.style.js +20 -26
  19. package/esm/components/action-popover/index.d.ts +9 -5
  20. package/esm/components/button-bar/button-bar-test.stories.js +122 -0
  21. package/esm/components/button-bar/button-bar.component.d.ts +12 -15
  22. package/esm/components/button-bar/button-bar.component.js +331 -33
  23. package/esm/components/button-bar/button-bar.config.d.ts +2 -2
  24. package/esm/components/button-bar/button-bar.style.d.ts +4 -4
  25. package/esm/components/button-bar/button-bar.style.js +18 -33
  26. package/esm/components/button-bar/index.d.ts +2 -1
  27. package/esm/components/heading/heading.component.d.ts +7 -47
  28. package/esm/components/heading/heading.component.js +1 -48
  29. package/esm/components/link/link.component.js +1 -5
  30. package/esm/components/menu/__internal__/spec-helper/index.js +2 -1
  31. package/esm/components/menu/__internal__/submenu/submenu.component.js +21 -4
  32. package/esm/components/menu/menu.component.js +2 -1
  33. package/esm/components/menu/scrollable-block/scrollable-block.component.js +4 -2
  34. package/esm/components/modal/modal.component.js +3 -60
  35. package/esm/components/toast/toast.component.js +3 -13
  36. package/esm/hooks/__internal__/useModalManager/index.d.ts +1 -0
  37. package/esm/hooks/__internal__/useModalManager/index.js +1 -0
  38. package/esm/hooks/__internal__/useModalManager/useModalManager.d.ts +3 -0
  39. package/esm/hooks/__internal__/useModalManager/useModalManager.js +66 -0
  40. package/lib/__spec_helper__/expect.d.ts +8 -1
  41. package/lib/__spec_helper__/expect.js +2 -4
  42. package/lib/__spec_helper__/test-utils.d.ts +71 -33
  43. package/lib/__spec_helper__/test-utils.js +63 -65
  44. package/lib/components/action-popover/action-popover-context.d.ts +7 -2
  45. package/lib/components/action-popover/action-popover-context.js +1 -1
  46. package/lib/components/action-popover/action-popover-divider/action-popover-divider.component.d.ts +1 -1
  47. package/lib/components/action-popover/action-popover-item/action-popover-item.component.d.ts +28 -41
  48. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +100 -119
  49. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.d.ts +35 -2
  50. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +44 -55
  51. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +20 -18
  52. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.js +13 -5
  53. package/lib/components/action-popover/action-popover-test.stories.js +95 -0
  54. package/lib/components/action-popover/action-popover.component.d.ts +30 -53
  55. package/lib/components/action-popover/action-popover.component.js +206 -71
  56. package/lib/components/action-popover/action-popover.style.d.ts +17 -11
  57. package/lib/components/action-popover/action-popover.style.js +21 -28
  58. package/lib/components/action-popover/index.d.ts +9 -5
  59. package/lib/components/button-bar/button-bar-test.stories.js +145 -0
  60. package/lib/components/button-bar/button-bar.component.d.ts +12 -15
  61. package/lib/components/button-bar/button-bar.component.js +336 -35
  62. package/lib/components/button-bar/button-bar.config.d.ts +2 -2
  63. package/lib/components/button-bar/button-bar.style.d.ts +4 -4
  64. package/lib/components/button-bar/button-bar.style.js +18 -35
  65. package/lib/components/button-bar/index.d.ts +2 -1
  66. package/lib/components/heading/heading.component.d.ts +7 -47
  67. package/lib/components/heading/heading.component.js +1 -48
  68. package/lib/components/link/link.component.js +1 -5
  69. package/lib/components/menu/__internal__/spec-helper/index.js +2 -1
  70. package/lib/components/menu/__internal__/submenu/submenu.component.js +21 -4
  71. package/lib/components/menu/menu.component.js +2 -1
  72. package/lib/components/menu/scrollable-block/scrollable-block.component.js +4 -2
  73. package/lib/components/modal/modal.component.js +3 -62
  74. package/lib/components/toast/toast.component.js +4 -17
  75. package/lib/hooks/__internal__/useModalManager/index.d.ts +1 -0
  76. package/lib/hooks/__internal__/useModalManager/index.js +15 -0
  77. package/lib/hooks/__internal__/useModalManager/package.json +6 -0
  78. package/lib/hooks/__internal__/useModalManager/useModalManager.d.ts +3 -0
  79. package/lib/hooks/__internal__/useModalManager/useModalManager.js +79 -0
  80. package/package.json +5 -1
  81. package/esm/components/action-popover/action-popover-divider/action-popover-divider.d.ts +0 -12
  82. package/esm/components/action-popover/action-popover-item/action-popover-item.d.ts +0 -26
  83. package/esm/components/action-popover/action-popover-menu/action-popover-menu.d.ts +0 -33
  84. package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.d.ts +0 -13
  85. package/esm/components/action-popover/action-popover.d.ts +0 -39
  86. package/esm/components/button-bar/button-bar.d.ts +0 -24
  87. package/lib/components/action-popover/action-popover-divider/action-popover-divider.d.ts +0 -12
  88. package/lib/components/action-popover/action-popover-item/action-popover-item.d.ts +0 -26
  89. package/lib/components/action-popover/action-popover-menu/action-popover-menu.d.ts +0 -33
  90. package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.d.ts +0 -13
  91. package/lib/components/action-popover/action-popover.d.ts +0 -39
  92. package/lib/components/button-bar/button-bar.d.ts +0 -24
@@ -0,0 +1,76 @@
1
+ import React from "react";
2
+ import { action } from "@storybook/addon-actions";
3
+ import { ActionPopover, ActionPopoverDivider, ActionPopoverItem, ActionPopoverMenu } from ".";
4
+ import { FlatTable, FlatTableHead, FlatTableBody, FlatTableRow, FlatTableHeader, FlatTableCell } from "../flat-table";
5
+ export default {
6
+ title: "Action Popover/Test",
7
+ parameters: {
8
+ info: {
9
+ disable: true
10
+ },
11
+ chromatic: {
12
+ disable: true
13
+ }
14
+ }
15
+ };
16
+ export const Default = () => {
17
+ const submenu = /*#__PURE__*/React.createElement(ActionPopoverMenu, null, /*#__PURE__*/React.createElement(ActionPopoverItem, {
18
+ onClick: action("sub menu 1")
19
+ }, "Sub Menu 1"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
20
+ onClick: action("sub menu 2")
21
+ }, "Sub Menu 2"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
22
+ disabled: true,
23
+ onClick: action("sub menu 3")
24
+ }, "Sub Menu 3"));
25
+ const submenuWithIcons = /*#__PURE__*/React.createElement(ActionPopoverMenu, null, /*#__PURE__*/React.createElement(ActionPopoverItem, {
26
+ icon: "graph",
27
+ onClick: action("sub menu 1")
28
+ }, "Sub Menu 1"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
29
+ icon: "add",
30
+ onClick: action("sub menu 2")
31
+ }, "Sub Menu 2"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
32
+ icon: "print",
33
+ disabled: true,
34
+ onClick: action("sub menu 3")
35
+ }, "Sub Menu 3"));
36
+ return /*#__PURE__*/React.createElement("div", {
37
+ style: {
38
+ marginTop: "40px",
39
+ height: "275px"
40
+ }
41
+ }, /*#__PURE__*/React.createElement(FlatTable, {
42
+ isZebra: true
43
+ }, /*#__PURE__*/React.createElement(FlatTableHead, null, /*#__PURE__*/React.createElement(FlatTableRow, null, /*#__PURE__*/React.createElement(FlatTableHeader, null, "First Name"), /*#__PURE__*/React.createElement(FlatTableHeader, null, "Last Name"), /*#__PURE__*/React.createElement(FlatTableHeader, null, "\xA0"))), /*#__PURE__*/React.createElement(FlatTableBody, null, /*#__PURE__*/React.createElement(FlatTableRow, null, /*#__PURE__*/React.createElement(FlatTableCell, null, "John"), /*#__PURE__*/React.createElement(FlatTableCell, null, "Doe"), /*#__PURE__*/React.createElement(FlatTableCell, null, /*#__PURE__*/React.createElement(ActionPopover, {
44
+ onOpen: action("popover opened"),
45
+ onClose: action("popover closed")
46
+ }, /*#__PURE__*/React.createElement(ActionPopoverItem, {
47
+ disabled: true,
48
+ icon: "graph",
49
+ submenu: submenu,
50
+ onClick: action("email")
51
+ }, "Business"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
52
+ icon: "email",
53
+ onClick: action("email")
54
+ }, "Email Invoice"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
55
+ icon: "print",
56
+ onClick: action("print"),
57
+ submenu: submenu
58
+ }, "Print Invoice"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
59
+ icon: "pdf",
60
+ submenu: submenu,
61
+ onClick: action("pdf")
62
+ }, "Download PDF"), /*#__PURE__*/React.createElement(ActionPopoverItem, {
63
+ icon: "csv",
64
+ onClick: action("csv")
65
+ }, "Download CSV"), /*#__PURE__*/React.createElement(ActionPopoverDivider, null), /*#__PURE__*/React.createElement(ActionPopoverItem, {
66
+ icon: "delete",
67
+ onClick: action("delete")
68
+ }, "Delete")))), /*#__PURE__*/React.createElement(FlatTableRow, null, /*#__PURE__*/React.createElement(FlatTableCell, null, "Jane"), /*#__PURE__*/React.createElement(FlatTableCell, null, "Smith"), /*#__PURE__*/React.createElement(FlatTableCell, null, /*#__PURE__*/React.createElement(ActionPopover, null, /*#__PURE__*/React.createElement(ActionPopoverItem, {
69
+ icon: "csv",
70
+ onClick: action("csv")
71
+ }, "Download CSV")))), /*#__PURE__*/React.createElement(FlatTableRow, null, /*#__PURE__*/React.createElement(FlatTableCell, null, "Bob"), /*#__PURE__*/React.createElement(FlatTableCell, null, "Jones"), /*#__PURE__*/React.createElement(FlatTableCell, null, /*#__PURE__*/React.createElement(ActionPopover, null, /*#__PURE__*/React.createElement(ActionPopoverItem, {
72
+ icon: "csv",
73
+ submenu: submenuWithIcons,
74
+ onClick: action("csv")
75
+ }, "Download CSV")))))));
76
+ };
@@ -1,55 +1,32 @@
1
- export default ActionPopover;
2
- declare function ActionPopover({ children, id, onOpen, onClose, rightAlignMenu, renderButton, placement, horizontalAlignment, ...rest }: {
3
- [x: string]: any;
4
- children: any;
5
- id: any;
6
- onOpen: any;
7
- onClose: any;
8
- rightAlignMenu: any;
9
- renderButton: any;
10
- placement?: string | undefined;
11
- horizontalAlignment: any;
12
- }): JSX.Element;
13
- declare namespace ActionPopover {
14
- const propTypes: {
15
- /** Unique ID */
16
- id: PropTypes.Requireable<string>;
17
- /** Callback to be called on menu open */
18
- onOpen: PropTypes.Requireable<(...args: any[]) => any>;
19
- /** Callback to be called on menu close */
20
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
21
- /** Boolean to control whether menu should align to right */
22
- rightAlignMenu: PropTypes.Requireable<boolean>;
23
- /** Children for popover component */
24
- children(props: any, propName: any, componentName: any): undefined;
25
- /** Render a custom menu button to override default ellipsis icon */
26
- renderButton: PropTypes.Requireable<(...args: any[]) => any>;
27
- /** Horizontal alignment of menu items content */
28
- horizontalAlignment: PropTypes.Requireable<string>;
29
- /** Set whether the menu should open above or below the button */
30
- placement: PropTypes.Requireable<string>;
31
- marginBottom?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
32
- margin?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
33
- m?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
34
- marginLeft?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
35
- ml?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
36
- marginRight?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
37
- mr?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
38
- marginTop?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
39
- mt?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
40
- mb?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
41
- marginX?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
42
- mx?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
43
- marginY?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
44
- my?: import("styled-system").ResponsiveValue<string | number | symbol, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ interface RenderButtonProps {
4
+ tabIndex: number;
5
+ "data-element": string;
6
+ ariaAttributes: {
7
+ "aria-haspopup": string;
8
+ "aria-label": string;
9
+ "aria-controls": string;
10
+ "aria-expanded": string;
45
11
  };
46
- namespace defaultProps {
47
- export const id: null;
48
- export { onOpen };
49
- export { onClose };
50
- export const horizontalAlignment: string;
51
- }
52
12
  }
53
- import PropTypes from "prop-types";
54
- declare function onOpen(): void;
55
- declare function onClose(): void;
13
+ export interface ActionPopoverProps extends MarginProps {
14
+ /** Children for popover component */
15
+ children?: React.ReactNode;
16
+ /** Horizontal alignment of menu items content */
17
+ horizontalAlignment?: "left" | "right";
18
+ /** Unique ID */
19
+ id?: string;
20
+ /** Callback to be called on menu open */
21
+ onOpen?: () => void;
22
+ /** Callback to be called on menu close */
23
+ onClose?: () => void;
24
+ /** Set whether the menu should open above or below the button */
25
+ placement?: "bottom" | "top";
26
+ /** Render a custom menu button to override default ellipsis icon */
27
+ renderButton?: (buttonProps: RenderButtonProps) => React.ReactNode;
28
+ /** Boolean to control whether menu should align to right */
29
+ rightAlignMenu?: boolean;
30
+ }
31
+ export declare const ActionPopover: ({ children, id, onOpen, onClose, rightAlignMenu, renderButton, placement, horizontalAlignment, ...rest }: ActionPopoverProps) => JSX.Element;
32
+ export default ActionPopover;
@@ -2,10 +2,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useState, useCallback, useMemo, useEffect, useRef } from "react";
4
4
  import PropTypes from "prop-types";
5
- import styledSystemPropTypes from "@styled-system/prop-types";
5
+ import invariant from "invariant";
6
6
  import { MenuButton, ButtonIcon, StyledButtonIcon } from "./action-popover.style";
7
7
  import Events from "../../__internal__/utils/helpers/events";
8
- import { filterStyledSystemMarginProps } from "../../style/utils";
9
8
  import Popover from "../../__internal__/popover";
10
9
  import createGuid from "../../__internal__/utils/helpers/guid";
11
10
  import useLocale from "../../hooks/__internal__/useLocale";
@@ -13,28 +12,44 @@ import ActionPopoverMenu from "./action-popover-menu/action-popover-menu.compone
13
12
  import ActionPopoverItem from "./action-popover-item/action-popover-item.component";
14
13
  import ActionPopoverDivider from "./action-popover-divider/action-popover-divider.component";
15
14
  import ActionPopoverContext from "./action-popover-context";
16
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
15
+
16
+ const onOpenDefault = () => {};
17
+
18
+ const onCloseDefault = () => {};
17
19
 
18
20
  const ActionPopover = ({
19
21
  children,
20
22
  id,
21
- onOpen,
22
- onClose,
23
+ onOpen = onOpenDefault,
24
+ onClose = onCloseDefault,
23
25
  rightAlignMenu,
24
26
  renderButton,
25
27
  placement = "bottom",
26
- horizontalAlignment,
28
+ horizontalAlignment = "left",
27
29
  ...rest
28
30
  }) => {
29
31
  const l = useLocale();
30
32
  const [isOpen, setOpenState] = useState(false);
31
33
  const [focusIndex, setFocusIndex] = useState(0);
32
34
  const [guid] = useState(createGuid());
33
- const buttonRef = useRef();
34
- const menu = useRef();
35
+ const buttonRef = useRef(null);
36
+ const menu = useRef(null);
35
37
  const itemCount = useMemo(() => {
36
- return React.Children.toArray(children).filter(child => child.type === ActionPopoverItem).length;
38
+ return React.Children.toArray(children).filter(child => {
39
+ return /*#__PURE__*/React.isValidElement(child) && child.type === ActionPopoverItem;
40
+ }).length;
41
+ }, [children]);
42
+ const hasProperChildren = useMemo(() => {
43
+ const incorrectChild = React.Children.toArray(children).find(child => {
44
+ if (! /*#__PURE__*/React.isValidElement(child)) {
45
+ return true;
46
+ }
47
+
48
+ return child.type !== ActionPopoverItem && child.type !== ActionPopoverDivider;
49
+ });
50
+ return !incorrectChild;
37
51
  }, [children]);
52
+ invariant(hasProperChildren, `ActionPopover only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`);
38
53
  const mappedPlacement = useMemo(() => {
39
54
  if (placement === "top" && !rightAlignMenu) {
40
55
  return "top-end";
@@ -61,6 +76,12 @@ const ActionPopover = ({
61
76
 
62
77
  setOpenState(value);
63
78
  }, [isOpen, onOpen, onClose]);
79
+ const focusButton = useCallback(() => {
80
+ var _buttonRef$current;
81
+
82
+ const button = (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.querySelector("[data-element='action-popover-button']");
83
+ button === null || button === void 0 ? void 0 : button.focus();
84
+ }, []);
64
85
  const onButtonClick = useCallback(e => {
65
86
  e.stopPropagation();
66
87
  const isOpening = !isOpen;
@@ -68,9 +89,9 @@ const ActionPopover = ({
68
89
 
69
90
  if (!isOpening) {
70
91
  // Closing the menu should focus the MenuButton
71
- buttonRef.current.querySelector("[data-component='action-popover-button']").focus();
92
+ focusButton();
72
93
  }
73
- }, [isOpen, setOpen]); // Keyboard commands implemented as recommended by WAI-ARIA best practices
94
+ }, [isOpen, setOpen, focusButton]); // Keyboard commands implemented as recommended by WAI-ARIA best practices
74
95
  // https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions.html
75
96
 
76
97
  const onButtonKeyDown = useCallback(e => {
@@ -86,7 +107,6 @@ const ActionPopover = ({
86
107
  setOpen(true);
87
108
  }
88
109
  }, [itemCount, setOpen]);
89
- const focusButton = useCallback(() => buttonRef.current.querySelector("[data-component='action-popover-button']").focus(), []);
90
110
  useEffect(() => {
91
111
  const handler = ({
92
112
  target
@@ -94,7 +114,10 @@ const ActionPopover = ({
94
114
  // If the event didn't came from part of this component, close the menu.
95
115
  // There will be multiple document click listeners but we cant prevent propagation because it will interfere with
96
116
  // other instances on the same page
97
- if (!buttonRef.current.contains(target) && menu.current && !menu.current.contains(target)) {
117
+ const isInMenu = menu.current && menu.current.contains(target);
118
+ const isInButton = buttonRef.current && buttonRef.current.contains(target);
119
+
120
+ if (!isInMenu && !isInButton) {
98
121
  setOpen(false);
99
122
  }
100
123
  };
@@ -113,13 +136,13 @@ const ActionPopover = ({
113
136
  const menuButton = menuID => {
114
137
  if (renderButton) {
115
138
  return renderButton({
116
- tabIndex: isOpen ? "-1" : "0",
117
- "data-component": "action-popover-button",
139
+ tabIndex: isOpen ? -1 : 0,
140
+ "data-element": "action-popover-button",
118
141
  ariaAttributes: {
119
142
  "aria-haspopup": "true",
120
143
  "aria-label": l.actionPopover.ariaLabel(),
121
144
  "aria-controls": menuID,
122
- "aria-expanded": isOpen
145
+ "aria-expanded": `${isOpen}`
123
146
  }
124
147
  });
125
148
  }
@@ -130,8 +153,8 @@ const ActionPopover = ({
130
153
  "aria-label": l.actionPopover.ariaLabel(),
131
154
  "aria-controls": menuID,
132
155
  "aria-expanded": isOpen,
133
- tabIndex: isOpen ? "-1" : "0",
134
- "data-component": "action-popover-button"
156
+ tabIndex: isOpen ? -1 : 0,
157
+ "data-element": "action-popover-button"
135
158
  }, /*#__PURE__*/React.createElement(ButtonIcon, {
136
159
  type: "ellipsis_vertical"
137
160
  }));
@@ -174,54 +197,169 @@ const ActionPopover = ({
174
197
  }, menuProps), children))));
175
198
  };
176
199
 
177
- ActionPopover.propTypes = { ...marginPropTypes,
178
-
179
- /** Unique ID */
180
- id: PropTypes.string,
181
-
182
- /** Callback to be called on menu open */
183
- onOpen: PropTypes.func,
184
-
185
- /** Callback to be called on menu close */
186
- onClose: PropTypes.func,
187
-
188
- /** Boolean to control whether menu should align to right */
189
- rightAlignMenu: PropTypes.bool,
190
-
191
- /** Children for popover component */
192
- children(props, propName, componentName) {
193
- let error;
194
- const prop = props[propName];
195
- React.Children.forEach(prop, child => {
196
- if (child === null) {
197
- return;
198
- }
199
-
200
- if (![ActionPopoverItem.displayName, ActionPopoverDivider.displayName].includes(child.type.displayName)) {
201
- error = new Error(`\`${componentName}\` only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`);
202
- }
203
- });
204
- return error;
205
- },
206
-
207
- /** Render a custom menu button to override default ellipsis icon */
208
- renderButton: PropTypes.func,
209
-
210
- /** Horizontal alignment of menu items content */
211
- horizontalAlignment: PropTypes.oneOf(["left", "right"]),
212
-
213
- /** Set whether the menu should open above or below the button */
214
- placement: PropTypes.oneOf(["top", "bottom"])
215
- };
216
-
217
- const onOpen = () => {};
218
-
219
- const onClose = () => {};
220
-
221
- ActionPopover.defaultProps = {
222
- id: null,
223
- onOpen,
224
- onClose,
225
- horizontalAlignment: "left"
200
+ ActionPopover.propTypes = {
201
+ "children": PropTypes.node,
202
+ "horizontalAlignment": PropTypes.oneOf(["left", "right"]),
203
+ "id": PropTypes.string,
204
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
205
+ "__@toStringTag": PropTypes.string.isRequired,
206
+ "description": PropTypes.string,
207
+ "toString": PropTypes.func.isRequired,
208
+ "valueOf": PropTypes.func.isRequired
209
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
210
+ "__@toStringTag": PropTypes.string.isRequired,
211
+ "description": PropTypes.string,
212
+ "toString": PropTypes.func.isRequired,
213
+ "valueOf": PropTypes.func.isRequired
214
+ }), PropTypes.string]),
215
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
216
+ "__@toStringTag": PropTypes.string.isRequired,
217
+ "description": PropTypes.string,
218
+ "toString": PropTypes.func.isRequired,
219
+ "valueOf": PropTypes.func.isRequired
220
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
221
+ "__@toStringTag": PropTypes.string.isRequired,
222
+ "description": PropTypes.string,
223
+ "toString": PropTypes.func.isRequired,
224
+ "valueOf": PropTypes.func.isRequired
225
+ }), PropTypes.string]),
226
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
227
+ "__@toStringTag": PropTypes.string.isRequired,
228
+ "description": PropTypes.string,
229
+ "toString": PropTypes.func.isRequired,
230
+ "valueOf": PropTypes.func.isRequired
231
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
232
+ "__@toStringTag": PropTypes.string.isRequired,
233
+ "description": PropTypes.string,
234
+ "toString": PropTypes.func.isRequired,
235
+ "valueOf": PropTypes.func.isRequired
236
+ }), PropTypes.string]),
237
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
238
+ "__@toStringTag": PropTypes.string.isRequired,
239
+ "description": PropTypes.string,
240
+ "toString": PropTypes.func.isRequired,
241
+ "valueOf": PropTypes.func.isRequired
242
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
243
+ "__@toStringTag": PropTypes.string.isRequired,
244
+ "description": PropTypes.string,
245
+ "toString": PropTypes.func.isRequired,
246
+ "valueOf": PropTypes.func.isRequired
247
+ }), PropTypes.string]),
248
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
249
+ "__@toStringTag": PropTypes.string.isRequired,
250
+ "description": PropTypes.string,
251
+ "toString": PropTypes.func.isRequired,
252
+ "valueOf": PropTypes.func.isRequired
253
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
254
+ "__@toStringTag": PropTypes.string.isRequired,
255
+ "description": PropTypes.string,
256
+ "toString": PropTypes.func.isRequired,
257
+ "valueOf": PropTypes.func.isRequired
258
+ }), PropTypes.string]),
259
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
260
+ "__@toStringTag": PropTypes.string.isRequired,
261
+ "description": PropTypes.string,
262
+ "toString": PropTypes.func.isRequired,
263
+ "valueOf": PropTypes.func.isRequired
264
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
265
+ "__@toStringTag": PropTypes.string.isRequired,
266
+ "description": PropTypes.string,
267
+ "toString": PropTypes.func.isRequired,
268
+ "valueOf": PropTypes.func.isRequired
269
+ }), PropTypes.string]),
270
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
271
+ "__@toStringTag": PropTypes.string.isRequired,
272
+ "description": PropTypes.string,
273
+ "toString": PropTypes.func.isRequired,
274
+ "valueOf": PropTypes.func.isRequired
275
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
276
+ "__@toStringTag": PropTypes.string.isRequired,
277
+ "description": PropTypes.string,
278
+ "toString": PropTypes.func.isRequired,
279
+ "valueOf": PropTypes.func.isRequired
280
+ }), PropTypes.string]),
281
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
282
+ "__@toStringTag": PropTypes.string.isRequired,
283
+ "description": PropTypes.string,
284
+ "toString": PropTypes.func.isRequired,
285
+ "valueOf": PropTypes.func.isRequired
286
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
287
+ "__@toStringTag": PropTypes.string.isRequired,
288
+ "description": PropTypes.string,
289
+ "toString": PropTypes.func.isRequired,
290
+ "valueOf": PropTypes.func.isRequired
291
+ }), PropTypes.string]),
292
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
293
+ "__@toStringTag": PropTypes.string.isRequired,
294
+ "description": PropTypes.string,
295
+ "toString": PropTypes.func.isRequired,
296
+ "valueOf": PropTypes.func.isRequired
297
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
298
+ "__@toStringTag": PropTypes.string.isRequired,
299
+ "description": PropTypes.string,
300
+ "toString": PropTypes.func.isRequired,
301
+ "valueOf": PropTypes.func.isRequired
302
+ }), PropTypes.string]),
303
+ "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
304
+ "__@toStringTag": PropTypes.string.isRequired,
305
+ "description": PropTypes.string,
306
+ "toString": PropTypes.func.isRequired,
307
+ "valueOf": PropTypes.func.isRequired
308
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
309
+ "__@toStringTag": PropTypes.string.isRequired,
310
+ "description": PropTypes.string,
311
+ "toString": PropTypes.func.isRequired,
312
+ "valueOf": PropTypes.func.isRequired
313
+ }), PropTypes.string]),
314
+ "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
315
+ "__@toStringTag": PropTypes.string.isRequired,
316
+ "description": PropTypes.string,
317
+ "toString": PropTypes.func.isRequired,
318
+ "valueOf": PropTypes.func.isRequired
319
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
320
+ "__@toStringTag": PropTypes.string.isRequired,
321
+ "description": PropTypes.string,
322
+ "toString": PropTypes.func.isRequired,
323
+ "valueOf": PropTypes.func.isRequired
324
+ }), PropTypes.string]),
325
+ "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
326
+ "__@toStringTag": PropTypes.string.isRequired,
327
+ "description": PropTypes.string,
328
+ "toString": PropTypes.func.isRequired,
329
+ "valueOf": PropTypes.func.isRequired
330
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
331
+ "__@toStringTag": PropTypes.string.isRequired,
332
+ "description": PropTypes.string,
333
+ "toString": PropTypes.func.isRequired,
334
+ "valueOf": PropTypes.func.isRequired
335
+ }), PropTypes.string]),
336
+ "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
337
+ "__@toStringTag": PropTypes.string.isRequired,
338
+ "description": PropTypes.string,
339
+ "toString": PropTypes.func.isRequired,
340
+ "valueOf": PropTypes.func.isRequired
341
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
342
+ "__@toStringTag": PropTypes.string.isRequired,
343
+ "description": PropTypes.string,
344
+ "toString": PropTypes.func.isRequired,
345
+ "valueOf": PropTypes.func.isRequired
346
+ }), PropTypes.string]),
347
+ "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
348
+ "__@toStringTag": PropTypes.string.isRequired,
349
+ "description": PropTypes.string,
350
+ "toString": PropTypes.func.isRequired,
351
+ "valueOf": PropTypes.func.isRequired
352
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
353
+ "__@toStringTag": PropTypes.string.isRequired,
354
+ "description": PropTypes.string,
355
+ "toString": PropTypes.func.isRequired,
356
+ "valueOf": PropTypes.func.isRequired
357
+ }), PropTypes.string]),
358
+ "onClose": PropTypes.func,
359
+ "onOpen": PropTypes.func,
360
+ "placement": PropTypes.oneOf(["bottom", "top"]),
361
+ "renderButton": PropTypes.func,
362
+ "rightAlignMenu": PropTypes.bool
226
363
  };
364
+ export { ActionPopover };
227
365
  export default ActionPopover;
@@ -1,13 +1,19 @@
1
- export const Menu: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export function MenuItemFactory(button: any): import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
- export const MenuButton: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export const ButtonIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
5
- export const StyledButtonIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
6
- export const MenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
7
- export const MenuItemDivider: import("styled-components").StyledComponent<"div", any, {
1
+ import Icon from "../icon";
2
+ declare const Menu: import("styled-components").StyledComponent<"div", any, {
3
+ isOpen?: boolean | undefined;
4
+ }, never>;
5
+ declare type StyledMenuItemProps = {
6
+ isDisabled: boolean;
7
+ horizontalAlignment: "left" | "right";
8
+ };
9
+ declare const StyledMenuItem: import("styled-components").StyledComponent<"button", any, StyledMenuItemProps, never>;
10
+ declare const MenuItemDivider: import("styled-components").StyledComponent<"div", any, {
8
11
  "data-element": string;
9
12
  }, "data-element">;
10
- export const SubMenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
11
- export const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
12
- export const StyledMenuItem: import("styled-components").StyledComponent<"button", any, {}, never>;
13
- import Icon from "../icon";
13
+ declare const MenuButton: import("styled-components").StyledComponent<"div", any, {}, never>;
14
+ declare const ButtonIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
15
+ declare const StyledButtonIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
16
+ declare const MenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
17
+ declare const SubMenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
18
+ declare const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
19
+ export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem, };
@@ -20,12 +20,7 @@ const Menu = styled.div`
20
20
  const StyledMenuItem = styled.button`
21
21
  text-decoration: none;
22
22
  background-color: var(--colorsActionMajorYang100);
23
- `;
24
-
25
- const MenuItemFactory = button => styled(button)`
26
- cursor: ${({
27
- disabled
28
- }) => disabled ? "not-allowed" : "pointer"};
23
+ cursor: pointer;
29
24
  box-sizing: border-box;
30
25
  padding: 0 var(--spacing150);
31
26
  position: relative;
@@ -36,43 +31,42 @@ const MenuItemFactory = button => styled(button)`
36
31
  align-items: center;
37
32
  border: none;
38
33
  width: 100%;
39
- color: ${({
40
- disabled
41
- }) => disabled ? "var(--colorsUtilityYin030)" : "var(--colorsUtilityYin090)"};
34
+ color: var(--colorsUtilityYin090);
42
35
  font-size: 14px;
43
36
  font-weight: 700;
44
37
  justify-content: ${({
45
38
  horizontalAlignment
46
39
  }) => horizontalAlignment === "left" ? "flex-start" : "flex-end"};
47
- &:focus,
48
- &:hover {
49
- ${({
50
- disabled
51
- }) => !disabled && css`
52
- background-color: var(--colorsUtilityMajor025);
53
- `}
54
- }
40
+
55
41
  &:focus {
56
42
  outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
57
43
  z-index: 1;
58
44
  }
45
+
59
46
  ${({
60
- disabled
61
- }) => !disabled && css`
47
+ isDisabled
48
+ }) => isDisabled && css`
49
+ color: var(--colorsUtilityYin030);
50
+ cursor: not-allowed;
51
+
62
52
  && ${StyledIcon} {
63
- cursor: pointer;
53
+ cursor: not-allowed;
54
+ color: var(--colorsUtilityYin030);
64
55
  }
65
56
  `}
57
+
66
58
  ${({
67
- disabled
68
- }) => disabled && css`
59
+ isDisabled
60
+ }) => !isDisabled && css`
61
+ &:focus,
62
+ &:hover {
63
+ background-color: var(--colorsUtilityMajor025);
64
+ }
69
65
  && ${StyledIcon} {
70
- cursor: not-allowed;
71
- color: var(--colorsUtilityYin030);
66
+ cursor: pointer;
72
67
  }
73
68
  `}
74
69
  `;
75
-
76
70
  const MenuItemDivider = styled.div.attrs({
77
71
  "data-element": "action-popover-divider"
78
72
  })`
@@ -138,4 +132,4 @@ const MenuButtonOverrideWrapper = styled.div`
138
132
  }
139
133
  }
140
134
  `;
141
- export { Menu, MenuItemFactory, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem };
135
+ export { Menu, MenuButton, ButtonIcon, StyledButtonIcon, MenuItemIcon, MenuItemDivider, SubMenuItemIcon, MenuButtonOverrideWrapper, StyledMenuItem };
@@ -1,5 +1,9 @@
1
- export { default as ActionPopover } from "./action-popover";
2
- export { default as ActionPopoverMenu } from "./action-popover-menu/action-popover-menu";
3
- export { default as ActionPopoverItem } from "./action-popover-item/action-popover-item";
4
- export { default as ActionPopoverMenuButton } from "./action-popover-menu-button";
5
- export { default as ActionPopoverDivider } from "./action-popover-divider/action-popover-divider";
1
+ export { default as ActionPopover } from "./action-popover.component";
2
+ export type { ActionPopoverProps } from "./action-popover.component";
3
+ export { default as ActionPopoverMenu } from "./action-popover-menu/action-popover-menu.component";
4
+ export type { ActionPopoverMenuProps } from "./action-popover-menu/action-popover-menu.component";
5
+ export { default as ActionPopoverItem } from "./action-popover-item/action-popover-item.component";
6
+ export type { ActionPopoverItemProps } from "./action-popover-item/action-popover-item.component";
7
+ export { default as ActionPopoverMenuButton } from "./action-popover-menu-button/action-popover-menu-button.component";
8
+ export type { ActionPopoverMenuButtonProps } from "./action-popover-menu-button/action-popover-menu-button.component";
9
+ export { default as ActionPopoverDivider } from "./action-popover-divider/action-popover-divider.component";