carbon-react 109.1.0 → 109.1.3

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 (60) hide show
  1. package/esm/__internal__/label/label.component.d.ts +1 -1
  2. package/esm/__internal__/label/label.component.js +2 -2
  3. package/esm/components/checkbox/checkbox-group.component.js +0 -5
  4. package/esm/components/checkbox/checkbox-group.d.ts +0 -2
  5. package/esm/components/checkbox/checkbox.component.js +1 -3
  6. package/esm/components/date/date.component.js +4 -7
  7. package/esm/components/flat-table/sort/sort.component.js +2 -1
  8. package/esm/components/flat-table/sort/sort.style.js +0 -1
  9. package/esm/components/help/help.component.d.ts +43 -0
  10. package/esm/components/help/help.component.js +194 -84
  11. package/esm/components/help/help.config.d.ts +1 -0
  12. package/esm/components/help/help.style.d.ts +4 -1
  13. package/esm/components/help/index.d.ts +2 -1
  14. package/esm/components/menu/__internal__/submenu/submenu.component.js +4 -6
  15. package/esm/components/multi-action-button/multi-action-button.component.js +4 -13
  16. package/esm/components/popover-container/popover-container.component.d.ts +1 -1
  17. package/esm/components/popover-container/popover-container.component.js +29 -12
  18. package/esm/components/popover-container/popover-container.style.d.ts +0 -2
  19. package/esm/components/popover-container/popover-container.style.js +0 -8
  20. package/esm/components/split-button/split-button.component.js +4 -11
  21. package/esm/hooks/__internal__/useClickAwayListener/index.d.ts +1 -0
  22. package/esm/hooks/__internal__/useClickAwayListener/index.js +1 -0
  23. package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +3 -0
  24. package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +23 -0
  25. package/lib/__internal__/label/label.component.d.ts +1 -1
  26. package/lib/__internal__/label/label.component.js +2 -2
  27. package/lib/components/checkbox/checkbox-group.component.js +0 -5
  28. package/lib/components/checkbox/checkbox-group.d.ts +0 -2
  29. package/lib/components/checkbox/checkbox.component.js +1 -3
  30. package/lib/components/date/date.component.js +4 -7
  31. package/lib/components/flat-table/sort/sort.component.js +2 -1
  32. package/lib/components/flat-table/sort/sort.style.js +0 -1
  33. package/lib/components/help/help.component.d.ts +43 -0
  34. package/lib/components/help/help.component.js +194 -87
  35. package/lib/components/help/help.config.d.ts +1 -0
  36. package/lib/components/help/help.style.d.ts +4 -1
  37. package/lib/components/help/index.d.ts +2 -1
  38. package/lib/components/menu/__internal__/submenu/submenu.component.js +4 -6
  39. package/lib/components/multi-action-button/multi-action-button.component.js +5 -13
  40. package/lib/components/popover-container/popover-container.component.d.ts +1 -1
  41. package/lib/components/popover-container/popover-container.component.js +30 -12
  42. package/lib/components/popover-container/popover-container.style.d.ts +0 -2
  43. package/lib/components/popover-container/popover-container.style.js +0 -8
  44. package/lib/components/split-button/split-button.component.js +5 -11
  45. package/lib/hooks/__internal__/useClickAwayListener/index.d.ts +1 -0
  46. package/lib/{__internal__/click-away-wrapper → hooks/__internal__/useClickAwayListener}/index.js +2 -2
  47. package/lib/hooks/__internal__/useClickAwayListener/package.json +6 -0
  48. package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +3 -0
  49. package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +33 -0
  50. package/package.json +1 -1
  51. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +0 -12
  52. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.js +0 -43
  53. package/esm/__internal__/click-away-wrapper/index.d.ts +0 -2
  54. package/esm/__internal__/click-away-wrapper/index.js +0 -1
  55. package/esm/components/help/help.d.ts +0 -41
  56. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +0 -12
  57. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.js +0 -59
  58. package/lib/__internal__/click-away-wrapper/index.d.ts +0 -2
  59. package/lib/__internal__/click-away-wrapper/package.json +0 -6
  60. package/lib/components/help/help.d.ts +0 -41
@@ -10,7 +10,7 @@ export interface LabelProps extends ValidationProps, StyledLabelProps, StyledLab
10
10
  /** Icon type */
11
11
  helpIcon?: IconType;
12
12
  /** Overrides the default tabindex of the Help component */
13
- helpTabIndex?: string;
13
+ helpTabIndex?: number | string;
14
14
  /** A string that represents the ID of another form element */
15
15
  htmlFor?: string;
16
16
  /** The unique id of the label element */
@@ -98,7 +98,7 @@ const Label = ({
98
98
 
99
99
  return help && /*#__PURE__*/React.createElement(StyledIconWrapper, wrapperProps, /*#__PURE__*/React.createElement(Help, {
100
100
  tooltipId: tooltipId,
101
- tabIndex: helpTabIndex,
101
+ tabIndex: Number(helpTabIndex),
102
102
  type: helpIcon,
103
103
  isFocused: isFocused
104
104
  }, help));
@@ -129,7 +129,7 @@ Label.propTypes = {
129
129
  "error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
130
130
  "help": PropTypes.node,
131
131
  "helpIcon": PropTypes.oneOf(["add", "admin", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "arrow", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "go", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "piggy_bank", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "three_boxes", "tick_circle", "tick", "true_tick", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
132
- "helpTabIndex": PropTypes.string,
132
+ "helpTabIndex": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
133
133
  "htmlFor": PropTypes.string,
134
134
  "info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
135
135
  "inline": PropTypes.bool,
@@ -14,7 +14,6 @@ export const CheckboxGroupContext = /*#__PURE__*/React.createContext({});
14
14
  const CheckboxGroup = props => {
15
15
  const {
16
16
  children,
17
- groupName,
18
17
  legend,
19
18
  error,
20
19
  warning,
@@ -45,7 +44,6 @@ const CheckboxGroup = props => {
45
44
  legendInline: legendInline
46
45
  }, /*#__PURE__*/React.createElement(CheckboxGroupContext.Provider, {
47
46
  value: {
48
- inputName: groupName,
49
47
  error: !!error,
50
48
  warning: !!warning,
51
49
  info: !!info
@@ -75,9 +73,6 @@ CheckboxGroup.propTypes = {
75
73
  /** The Checkboxes to be rendered in the group */
76
74
  children: PropTypes.node.isRequired,
77
75
 
78
- /** Specifies the name prop to be applied to each button in the group */
79
- groupName: PropTypes.string.isRequired,
80
-
81
76
  /** Indicate that error has occurred
82
77
  Pass string to display icon, tooltip and red border
83
78
  Pass true boolean to only display red border */
@@ -15,8 +15,6 @@ interface CheckboxGroupProps extends ValidationProps, MarginProps {
15
15
  legendSpacing?: 1 | 2;
16
16
  /** The Checkboxes to be rendered in the group */
17
17
  children: React.ReactNode;
18
- /** Specifies the name prop to be applied to each button in the group */
19
- groupName: string;
20
18
  /** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
21
19
  labelSpacing?: 1 | 2;
22
20
  /** Flag to configure component as mandatory */
@@ -51,8 +51,7 @@ const Checkbox = ({
51
51
  const {
52
52
  error: contextError,
53
53
  warning: contextWarning,
54
- info: contextInfo,
55
- inputName
54
+ info: contextInfo
56
55
  } = useContext(CheckboxGroupContext);
57
56
  const inputProps = {
58
57
  onClick,
@@ -80,7 +79,6 @@ const Checkbox = ({
80
79
  inputWidth,
81
80
  labelWidth,
82
81
  tooltipPosition,
83
- inputName,
84
82
  ...props
85
83
  };
86
84
  return /*#__PURE__*/React.createElement(TooltipProvider, {
@@ -12,7 +12,7 @@ import StyledDateInput from "./date.style";
12
12
  import Textbox from "../textbox";
13
13
  import DatePicker from "./__internal__/date-picker";
14
14
  import DateRangeContext from "../date-range/date-range.context";
15
- import ClickAwayWrapper from "../../__internal__/click-away-wrapper";
15
+ import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
16
16
  const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
17
17
 
18
18
  const DateInput = ({
@@ -277,11 +277,8 @@ const DateInput = ({
277
277
  }
278
278
  };
279
279
 
280
- return /*#__PURE__*/React.createElement(ClickAwayWrapper, {
281
- handleClickAway: handleClickAway,
282
- eventTypeId: "mousedown",
283
- targets: [parentRef, pickerRef]
284
- }, /*#__PURE__*/React.createElement(StyledDateInput, _extends({
280
+ useClickAwayListener([parentRef, pickerRef], handleClickAway, "mousedown");
281
+ return /*#__PURE__*/React.createElement(StyledDateInput, _extends({
285
282
  ref: wrapperRef,
286
283
  role: "presentation",
287
284
  size: size,
@@ -321,7 +318,7 @@ const DateInput = ({
321
318
  ref: pickerRef,
322
319
  pickerMouseDown: handlePickerMouseDown,
323
320
  open: open
324
- })));
321
+ }));
325
322
  };
326
323
 
327
324
  DateInput.propTypes = { ...Textbox.propTypes,
@@ -33,7 +33,8 @@ const Sort = ({
33
33
  sortType: sortType,
34
34
  "aria-labelledby": id.current
35
35
  }, children, sortType && /*#__PURE__*/React.createElement(Icon, {
36
- type: sortType === "ascending" ? "sort_up" : "sort_down"
36
+ type: sortType === "ascending" ? "sort_up" : "sort_down",
37
+ color: "--colorsUtilityMajor200"
37
38
  })), !sortType && /*#__PURE__*/React.createElement(StyledSpaceHolder, null));
38
39
  };
39
40
 
@@ -12,7 +12,6 @@ const StyledSort = styled.div`
12
12
  width: 16px;
13
13
  height: 16px;
14
14
  padding-left: 6px;
15
- color: var(--colorsUtilityMajor200);
16
15
  }
17
16
 
18
17
  :hover {
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ import { IconType } from "../icon";
4
+ import { TooltipPositions } from "../tooltip/tooltip.config";
5
+ export interface HelpProps extends MarginProps {
6
+ /** Overrides the default 'as' attribute of the Help component */
7
+ as?: keyof JSX.IntrinsicElements;
8
+ /** Aria label */
9
+ ariaLabel?: string;
10
+ /** The message to be displayed within the tooltip */
11
+ children?: React.ReactNode;
12
+ /** [Legacy] A custom class name for the component. */
13
+ className?: string;
14
+ /** The unique id of the component (used with aria-describedby for accessibility) */
15
+ helpId?: string;
16
+ /** A path for the anchor */
17
+ href?: string;
18
+ /** A boolean received from IconWrapper */
19
+ isFocused?: boolean;
20
+ /** Overrides the default tabindex of the component */
21
+ tabIndex?: number;
22
+ /** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
23
+ tooltipBgColor?: string;
24
+ /** Override font color of the Tooltip, provide any color from palette or any valid css color value. */
25
+ tooltipFontColor?: string;
26
+ /** Overrides the default flip behaviour of the Tooltip,
27
+ * must be an array containing some or all of ["top", "bottom", "left", "right"]
28
+ * (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements)
29
+ */
30
+ tooltipFlipOverrides?: TooltipPositions[];
31
+ /** Id passed to the tooltip container, used for accessibility purposes */
32
+ tooltipId?: string;
33
+ /** Position of tooltip relative to target */
34
+ tooltipPosition?: TooltipPositions;
35
+ /** Help Icon type */
36
+ type?: IconType;
37
+ [key: string]: any;
38
+ }
39
+ export declare const Help: {
40
+ ({ as, ariaLabel, children, className, href, helpId, isFocused, tabIndex, tooltipBgColor, tooltipFontColor, tooltipFlipOverrides, tooltipId, tooltipPosition, type, ...rest }: HelpProps): JSX.Element;
41
+ displayName: string;
42
+ };
43
+ export default Help;
@@ -1,33 +1,30 @@
1
1
  function _extends() { _extends = Object.assign || 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
 
3
- import React, { useContext, useEffect, useState, useRef } from "react";
3
+ import React, { useContext, useEffect, useRef, useState } from "react";
4
4
  import PropTypes from "prop-types";
5
- import styledSystemPropTypes from "@styled-system/prop-types";
6
5
  import Icon from "../icon";
7
6
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
8
7
  import StyledHelp from "./help.style";
9
8
  import Events from "../../__internal__/utils/helpers/events";
10
9
  import { TooltipContext } from "../../__internal__/tooltip-provider";
11
10
  import { filterStyledSystemMarginProps } from "../../style/utils";
12
- import { HELP_POSITIONS } from "./help.config";
13
11
  import guid from "../../__internal__/utils/helpers/guid";
14
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
15
12
 
16
13
  const Help = ({
14
+ as,
15
+ ariaLabel = "help",
16
+ children,
17
17
  className,
18
18
  href,
19
19
  helpId,
20
- children,
21
- tabIndex,
22
- as,
23
- tooltipPosition,
24
20
  isFocused,
25
- type,
26
- tooltipId,
21
+ tabIndex = 0,
27
22
  tooltipBgColor,
28
23
  tooltipFontColor,
29
24
  tooltipFlipOverrides,
30
- ariaLabel = "help",
25
+ tooltipId,
26
+ tooltipPosition = "top",
27
+ type = "help",
31
28
  ...rest
32
29
  }) => {
33
30
  const defaultTooltipId = useRef(guid());
@@ -37,23 +34,25 @@ const Help = ({
37
34
  helpAriaLabel
38
35
  } = useContext(TooltipContext);
39
36
  useEffect(() => {
37
+ function handleKeyPress(ev) {
38
+ if (Events.isEscKey(ev)) {
39
+ var _helpElement$current;
40
+
41
+ helpElement === null || helpElement === void 0 ? void 0 : (_helpElement$current = helpElement.current) === null || _helpElement$current === void 0 ? void 0 : _helpElement$current.blur();
42
+ updateTooltipVisible(false);
43
+ }
44
+ }
45
+
40
46
  document.addEventListener("keydown", handleKeyPress);
41
47
  return function cleanup() {
42
48
  document.removeEventListener("keydown", handleKeyPress);
43
49
  };
44
50
  });
45
- const tagType = as || href && "a";
46
-
47
- function handleKeyPress(ev) {
48
- if (Events.isEscKey(ev)) {
49
- helpElement.current.blur();
50
- updateTooltipVisible(false);
51
- }
52
- }
51
+ const tagType = as || href && "a" || "div";
53
52
 
54
- function handleFocusBlur(bool) {
53
+ function handleFocusBlur(isVisible) {
55
54
  return () => {
56
- updateTooltipVisible(bool);
55
+ updateTooltipVisible(isVisible);
57
56
  };
58
57
  }
59
58
 
@@ -66,7 +65,9 @@ const Help = ({
66
65
  id: helpId,
67
66
  ref: helpElement,
68
67
  onClick: () => {
69
- helpElement.current.focus();
68
+ var _helpElement$current2;
69
+
70
+ helpElement === null || helpElement === void 0 ? void 0 : (_helpElement$current2 = helpElement.current) === null || _helpElement$current2 === void 0 ? void 0 : _helpElement$current2.focus();
70
71
  },
71
72
  onFocus: handleFocusBlur(true),
72
73
  onBlur: handleFocusBlur(false),
@@ -93,67 +94,176 @@ const Help = ({
93
94
  }));
94
95
  };
95
96
 
96
- Help.propTypes = { ...marginPropTypes,
97
-
98
- /** [Legacy] A custom class name for the component. */
99
- className: PropTypes.string,
100
-
101
- /** Message to display in tooltip */
102
- children: PropTypes.node,
103
-
104
- /** The unique id of the component */
105
- helpId: PropTypes.string,
106
-
107
- /** Overrides the default tabindex of the component */
108
- tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
109
-
110
- /** Overrides the default 'as' attribute of the Help component */
111
- as: PropTypes.string,
112
-
113
- /** Position of tooltip relative to target */
114
- tooltipPosition: PropTypes.oneOf(["bottom", "left", "right", "top"]),
115
-
116
- /** A path for the anchor */
117
- href: PropTypes.string,
118
-
119
- /** A boolean received from IconWrapper */
120
- isFocused: PropTypes.bool,
121
-
122
- /** <a href="https://brand.sage.com/d/NdbrveWvNheA/foundations#/icons/icons" target="_blank">List of supported icons</a>
123
- *
124
- * Icon to display, can be received from label component
125
- *
126
- */
127
- type: PropTypes.string,
128
-
129
- /** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
130
- tooltipBgColor: PropTypes.string,
131
-
132
- /** Override font color of the Tooltip, provide any color from palette or any valid css color value. */
133
- tooltipFontColor: PropTypes.string,
134
-
135
- /** Overrides the default flip behaviour of the Tooltip, must be an array containing some or all of ["top", "bottom", "left", "right"] (see https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements) */
136
- tooltipFlipOverrides: (props, propName, componentName) => {
137
- const prop = props[propName];
138
- const isValid = prop && Array.isArray(prop) && prop.every(placement => HELP_POSITIONS.includes(placement));
139
-
140
- if (!prop || isValid) {
141
- return null;
142
- }
143
-
144
- return new Error( // eslint-disable-next-line max-len
145
- `The \`${propName}\` prop supplied to \`${componentName}\` must be an array containing some or all of ["top", "bottom", "left", "right"].`);
146
- },
147
-
148
- /** Id passed to the tooltip container, used for accessibility purposes. */
149
- tooltipId: PropTypes.string,
150
-
151
- /** Aria label */
152
- ariaLabel: PropTypes.string
153
- };
154
- Help.defaultProps = {
155
- tooltipPosition: "top",
156
- tabIndex: 0,
157
- type: "help"
97
+ Help.propTypes = {
98
+ "ariaLabel": PropTypes.string,
99
+ "as": PropTypes.oneOf(["a", "abbr", "address", "animate", "animateMotion", "animateTransform", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "circle", "cite", "clipPath", "code", "col", "colgroup", "data", "datalist", "dd", "defs", "del", "desc", "details", "dfn", "dialog", "div", "dl", "dt", "ellipse", "em", "embed", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "fieldset", "figcaption", "figure", "filter", "footer", "foreignObject", "form", "g", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "line", "linearGradient", "link", "main", "map", "mark", "marker", "mask", "menu", "menuitem", "meta", "metadata", "meter", "mpath", "nav", "noindex", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "path", "pattern", "picture", "polygon", "polyline", "pre", "progress", "q", "radialGradient", "rect", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "slot", "small", "source", "span", "stop", "strong", "style", "sub", "summary", "sup", "svg", "switch", "symbol", "table", "tbody", "td", "template", "text", "textarea", "textPath", "tfoot", "th", "thead", "time", "title", "tr", "track", "tspan", "u", "ul", "use", "var", "video", "view", "wbr", "webview"]),
100
+ "children": PropTypes.node,
101
+ "className": PropTypes.string,
102
+ "helpId": PropTypes.string,
103
+ "href": PropTypes.string,
104
+ "isFocused": PropTypes.bool,
105
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
106
+ "__@toStringTag": PropTypes.string.isRequired,
107
+ "description": PropTypes.string,
108
+ "toString": PropTypes.func.isRequired,
109
+ "valueOf": PropTypes.func.isRequired
110
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
111
+ "__@toStringTag": PropTypes.string.isRequired,
112
+ "description": PropTypes.string,
113
+ "toString": PropTypes.func.isRequired,
114
+ "valueOf": PropTypes.func.isRequired
115
+ }), PropTypes.string]),
116
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
117
+ "__@toStringTag": PropTypes.string.isRequired,
118
+ "description": PropTypes.string,
119
+ "toString": PropTypes.func.isRequired,
120
+ "valueOf": PropTypes.func.isRequired
121
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
122
+ "__@toStringTag": PropTypes.string.isRequired,
123
+ "description": PropTypes.string,
124
+ "toString": PropTypes.func.isRequired,
125
+ "valueOf": PropTypes.func.isRequired
126
+ }), PropTypes.string]),
127
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
128
+ "__@toStringTag": PropTypes.string.isRequired,
129
+ "description": PropTypes.string,
130
+ "toString": PropTypes.func.isRequired,
131
+ "valueOf": PropTypes.func.isRequired
132
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
133
+ "__@toStringTag": PropTypes.string.isRequired,
134
+ "description": PropTypes.string,
135
+ "toString": PropTypes.func.isRequired,
136
+ "valueOf": PropTypes.func.isRequired
137
+ }), PropTypes.string]),
138
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
139
+ "__@toStringTag": PropTypes.string.isRequired,
140
+ "description": PropTypes.string,
141
+ "toString": PropTypes.func.isRequired,
142
+ "valueOf": PropTypes.func.isRequired
143
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
144
+ "__@toStringTag": PropTypes.string.isRequired,
145
+ "description": PropTypes.string,
146
+ "toString": PropTypes.func.isRequired,
147
+ "valueOf": PropTypes.func.isRequired
148
+ }), PropTypes.string]),
149
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
150
+ "__@toStringTag": PropTypes.string.isRequired,
151
+ "description": PropTypes.string,
152
+ "toString": PropTypes.func.isRequired,
153
+ "valueOf": PropTypes.func.isRequired
154
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
155
+ "__@toStringTag": PropTypes.string.isRequired,
156
+ "description": PropTypes.string,
157
+ "toString": PropTypes.func.isRequired,
158
+ "valueOf": PropTypes.func.isRequired
159
+ }), PropTypes.string]),
160
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
161
+ "__@toStringTag": PropTypes.string.isRequired,
162
+ "description": PropTypes.string,
163
+ "toString": PropTypes.func.isRequired,
164
+ "valueOf": PropTypes.func.isRequired
165
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
166
+ "__@toStringTag": PropTypes.string.isRequired,
167
+ "description": PropTypes.string,
168
+ "toString": PropTypes.func.isRequired,
169
+ "valueOf": PropTypes.func.isRequired
170
+ }), PropTypes.string]),
171
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
172
+ "__@toStringTag": PropTypes.string.isRequired,
173
+ "description": PropTypes.string,
174
+ "toString": PropTypes.func.isRequired,
175
+ "valueOf": PropTypes.func.isRequired
176
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
177
+ "__@toStringTag": PropTypes.string.isRequired,
178
+ "description": PropTypes.string,
179
+ "toString": PropTypes.func.isRequired,
180
+ "valueOf": PropTypes.func.isRequired
181
+ }), PropTypes.string]),
182
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
183
+ "__@toStringTag": PropTypes.string.isRequired,
184
+ "description": PropTypes.string,
185
+ "toString": PropTypes.func.isRequired,
186
+ "valueOf": PropTypes.func.isRequired
187
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
188
+ "__@toStringTag": PropTypes.string.isRequired,
189
+ "description": PropTypes.string,
190
+ "toString": PropTypes.func.isRequired,
191
+ "valueOf": PropTypes.func.isRequired
192
+ }), PropTypes.string]),
193
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
194
+ "__@toStringTag": PropTypes.string.isRequired,
195
+ "description": PropTypes.string,
196
+ "toString": PropTypes.func.isRequired,
197
+ "valueOf": PropTypes.func.isRequired
198
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
199
+ "__@toStringTag": PropTypes.string.isRequired,
200
+ "description": PropTypes.string,
201
+ "toString": PropTypes.func.isRequired,
202
+ "valueOf": PropTypes.func.isRequired
203
+ }), PropTypes.string]),
204
+ "ml": 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
+ "mr": 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
+ "mt": 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
+ "mx": 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
+ "my": 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
+ "tabIndex": PropTypes.number,
260
+ "tooltipBgColor": PropTypes.string,
261
+ "tooltipFlipOverrides": PropTypes.arrayOf(PropTypes.oneOf(["bottom", "left", "right", "top"])),
262
+ "tooltipFontColor": PropTypes.string,
263
+ "tooltipId": PropTypes.string,
264
+ "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
265
+ "type": PropTypes.oneOf(["add", "admin", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "arrow", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "go", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "piggy_bank", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "three_boxes", "tick_circle", "tick", "true_tick", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"])
158
266
  };
267
+ export { Help };
268
+ Help.displayName = "Help";
159
269
  export default Help;
@@ -0,0 +1 @@
1
+ export declare const HELP_POSITIONS: string[];
@@ -1,2 +1,5 @@
1
+ interface StyledHelpProps {
2
+ href?: string;
3
+ }
4
+ declare const StyledHelp: import("styled-components").StyledComponent<"div", any, StyledHelpProps, never>;
1
5
  export default StyledHelp;
2
- declare const StyledHelp: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1 +1,2 @@
1
- export { default } from "./help";
1
+ export { default } from "./help.component";
2
+ export type { HelpProps } from "./help.component";
@@ -12,7 +12,7 @@ import MenuItem from "../../menu-item";
12
12
  import { characterNavigation } from "../keyboard-navigation";
13
13
  import ScrollableBlock from "../../scrollable-block";
14
14
  import SubmenuContext from "./submenu.context";
15
- import ClickAwayWrapper from "../../../../__internal__/click-away-wrapper";
15
+ import useClickAwayListener from "../../../../hooks/__internal__/useClickAwayListener";
16
16
  const Submenu = /*#__PURE__*/React.forwardRef(({
17
17
  children,
18
18
  className,
@@ -205,6 +205,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
205
205
  } // eslint-disable-next-line react-hooks/exhaustive-deps
206
206
 
207
207
  }, [characterString]);
208
+ useClickAwayListener([submenuRef], handleClickAway);
208
209
 
209
210
  if (inFullscreenView) {
210
211
  return /*#__PURE__*/React.createElement(StyledSubmenuWrapper, {
@@ -238,10 +239,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
238
239
  }, child))));
239
240
  }
240
241
 
241
- return /*#__PURE__*/React.createElement(ClickAwayWrapper, {
242
- handleClickAway: handleClickAway,
243
- targets: [submenuRef]
244
- }, /*#__PURE__*/React.createElement(StyledSubmenuWrapper, {
242
+ return /*#__PURE__*/React.createElement(StyledSubmenuWrapper, {
245
243
  "data-component": "submenu-wrapper",
246
244
  onMouseOver: !clickToOpen ? () => openSubmenu() : undefined,
247
245
  onMouseLeave: () => closeSubmenu(),
@@ -279,7 +277,7 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
279
277
  updateFocusIndex: setSubmenuFocusIndex,
280
278
  itemIndex: child.type === MenuItem ? index : undefined
281
279
  }
282
- }, child)))));
280
+ }, child))));
283
281
  });
284
282
  Submenu.propTypes = {
285
283
  /** Children elements */
@@ -2,6 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React, { useCallback, useEffect, useState, useRef, useMemo } from "react";
4
4
  import PropTypes from "prop-types";
5
+ import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
5
6
  import { StyledMultiActionButton, StyledButtonChildrenContainer } from "./multi-action-button.style";
6
7
  import Button, { ButtonWithForwardRef } from "../button";
7
8
  import Events from "../../__internal__/utils/helpers/events";
@@ -105,31 +106,20 @@ const MultiActionButton = ({
105
106
  (_additionalButtons$cu = additionalButtons.current[nextIndex].current) === null || _additionalButtons$cu === void 0 ? void 0 : _additionalButtons$cu.focus();
106
107
  }
107
108
  }, [buttonChildren, hideButtons]);
108
- const handleClickOutside = useCallback(({
109
- target
110
- }) => {
111
- var _ref$current, _buttonContainer$curr;
112
-
113
- if (!((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains(target)) && !((_buttonContainer$curr = buttonContainer.current) !== null && _buttonContainer$curr !== void 0 && _buttonContainer$curr.contains(target))) {
114
- hideButtons();
115
- }
116
- }, [hideButtons]);
117
109
  const addListeners = useCallback(() => {
118
110
  /* istanbul ignore else */
119
111
  if (!listening.current) {
120
- document.addEventListener("click", handleClickOutside);
121
112
  document.addEventListener("keydown", handleKeyDown);
122
113
  listening.current = true;
123
114
  }
124
- }, [handleKeyDown, handleClickOutside]);
115
+ }, [handleKeyDown]);
125
116
  const removeListeners = useCallback(() => {
126
117
  /* istanbul ignore else */
127
118
  if (listening.current) {
128
- document.removeEventListener("click", handleClickOutside);
129
119
  document.removeEventListener("keydown", handleKeyDown);
130
120
  listening.current = false;
131
121
  }
132
- }, [handleKeyDown, handleClickOutside]);
122
+ }, [handleKeyDown]);
133
123
  useEffect(() => {
134
124
  if (showAdditionalButtons) {
135
125
  addListeners();
@@ -200,6 +190,7 @@ const MultiActionButton = ({
200
190
  ref: buttonContainer
201
191
  }, childrenWithProps()));
202
192
 
193
+ useClickAwayListener([ref], hideButtons);
203
194
  return /*#__PURE__*/React.createElement(StyledMultiActionButton, _extends({
204
195
  "aria-haspopup": "true",
205
196
  onMouseLeave: hideButtons,
@@ -36,7 +36,7 @@ export interface PopoverContainerProps extends PaddingProps {
36
36
  /** Sets the popover container dialog header name */
37
37
  title?: string;
38
38
  /** Callback fires when close icon clicked */
39
- onClose?: (ev: React.MouseEvent<HTMLElement>) => void;
39
+ onClose?: (ev: React.MouseEvent<HTMLElement> | Event) => void;
40
40
  /** if `true` the popover-container is open */
41
41
  open?: boolean;
42
42
  /** Callback fires when open component is clicked */