carbon-react 109.0.2 → 109.1.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 (66) hide show
  1. package/esm/__internal__/focus-trap/focus-trap.component.js +8 -11
  2. package/esm/__internal__/label/label.component.d.ts +1 -1
  3. package/esm/__internal__/label/label.component.js +2 -2
  4. package/esm/components/checkbox/checkbox-group.component.js +0 -5
  5. package/esm/components/checkbox/checkbox-group.d.ts +0 -2
  6. package/esm/components/checkbox/checkbox.component.js +1 -3
  7. package/esm/components/date/date.component.js +4 -7
  8. package/esm/components/flat-table/sort/sort.component.js +2 -1
  9. package/esm/components/flat-table/sort/sort.style.js +0 -1
  10. package/esm/components/help/help.component.d.ts +43 -0
  11. package/esm/components/help/help.component.js +194 -84
  12. package/esm/components/help/help.config.d.ts +1 -0
  13. package/esm/components/help/help.style.d.ts +4 -1
  14. package/esm/components/help/index.d.ts +2 -1
  15. package/esm/components/inline-inputs/inline-inputs.component.d.ts +5 -9
  16. package/esm/components/inline-inputs/inline-inputs.component.js +14 -2
  17. package/esm/components/inline-inputs/inline-inputs.style.d.ts +18 -3
  18. package/esm/components/inline-inputs/inline-inputs.style.js +6 -2
  19. package/esm/components/menu/__internal__/submenu/submenu.component.js +4 -6
  20. package/esm/components/multi-action-button/multi-action-button.component.js +4 -13
  21. package/esm/components/popover-container/popover-container.component.d.ts +1 -1
  22. package/esm/components/popover-container/popover-container.component.js +5 -9
  23. package/esm/components/split-button/split-button.component.js +4 -11
  24. package/esm/hooks/__internal__/useClickAwayListener/index.d.ts +1 -0
  25. package/esm/hooks/__internal__/useClickAwayListener/index.js +1 -0
  26. package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +3 -0
  27. package/esm/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +23 -0
  28. package/lib/__internal__/focus-trap/focus-trap.component.js +8 -11
  29. package/lib/__internal__/label/label.component.d.ts +1 -1
  30. package/lib/__internal__/label/label.component.js +2 -2
  31. package/lib/components/checkbox/checkbox-group.component.js +0 -5
  32. package/lib/components/checkbox/checkbox-group.d.ts +0 -2
  33. package/lib/components/checkbox/checkbox.component.js +1 -3
  34. package/lib/components/date/date.component.js +4 -7
  35. package/lib/components/flat-table/sort/sort.component.js +2 -1
  36. package/lib/components/flat-table/sort/sort.style.js +0 -1
  37. package/lib/components/help/help.component.d.ts +43 -0
  38. package/lib/components/help/help.component.js +194 -87
  39. package/lib/components/help/help.config.d.ts +1 -0
  40. package/lib/components/help/help.style.d.ts +4 -1
  41. package/lib/components/help/index.d.ts +2 -1
  42. package/lib/components/inline-inputs/inline-inputs.component.d.ts +5 -9
  43. package/lib/components/inline-inputs/inline-inputs.component.js +15 -2
  44. package/lib/components/inline-inputs/inline-inputs.style.d.ts +18 -3
  45. package/lib/components/inline-inputs/inline-inputs.style.js +6 -2
  46. package/lib/components/menu/__internal__/submenu/submenu.component.js +4 -6
  47. package/lib/components/multi-action-button/multi-action-button.component.js +5 -13
  48. package/lib/components/popover-container/popover-container.component.d.ts +1 -1
  49. package/lib/components/popover-container/popover-container.component.js +5 -9
  50. package/lib/components/split-button/split-button.component.js +5 -11
  51. package/lib/hooks/__internal__/useClickAwayListener/index.d.ts +1 -0
  52. package/lib/{__internal__/click-away-wrapper → hooks/__internal__/useClickAwayListener}/index.js +2 -2
  53. package/lib/hooks/__internal__/useClickAwayListener/package.json +6 -0
  54. package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.d.ts +3 -0
  55. package/lib/hooks/__internal__/useClickAwayListener/useClickAwayListener.js +33 -0
  56. package/package.json +1 -1
  57. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +0 -12
  58. package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.js +0 -43
  59. package/esm/__internal__/click-away-wrapper/index.d.ts +0 -2
  60. package/esm/__internal__/click-away-wrapper/index.js +0 -1
  61. package/esm/components/help/help.d.ts +0 -41
  62. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +0 -12
  63. package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.js +0 -59
  64. package/lib/__internal__/click-away-wrapper/index.d.ts +0 -2
  65. package/lib/__internal__/click-away-wrapper/package.json +0 -6
  66. package/lib/components/help/help.d.ts +0 -41
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
3
3
  import Label from "../../__internal__/label";
4
4
  import StyledInlineInputs, { StyledContentContainer, StyledInlineInput } from "./inline-inputs.style";
5
5
  import createGuid from "../../__internal__/utils/helpers/guid";
6
+ import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
6
7
  export const InlineInputsContext = /*#__PURE__*/React.createContext({});
7
8
 
8
9
  const columnWrapper = (children, gutter, labelId) => {
@@ -19,21 +20,29 @@ const columnWrapper = (children, gutter, labelId) => {
19
20
  };
20
21
 
21
22
  const InlineInputs = ({
23
+ adaptiveLabelBreakpoint,
22
24
  label,
23
25
  htmlFor,
24
26
  children = null,
25
27
  className = "",
26
28
  gutter = "none",
27
29
  inputWidth,
30
+ labelInline = true,
28
31
  labelWidth
29
32
  }) => {
30
33
  const labelId = useRef(createGuid());
34
+ const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
35
+ let inlineLabel = labelInline;
36
+
37
+ if (adaptiveLabelBreakpoint) {
38
+ inlineLabel = largeScreen;
39
+ }
31
40
 
32
41
  function renderLabel() {
33
42
  if (!label) return null;
34
43
  return /*#__PURE__*/React.createElement(Label, {
35
44
  labelId: labelId.current,
36
- inline: true,
45
+ inline: inlineLabel,
37
46
  htmlFor: htmlFor
38
47
  }, label);
39
48
  }
@@ -42,7 +51,8 @@ const InlineInputs = ({
42
51
  gutter: gutter,
43
52
  "data-component": "inline-inputs",
44
53
  className: className,
45
- labelWidth: labelWidth
54
+ labelWidth: labelWidth,
55
+ labelInline: inlineLabel
46
56
  }, renderLabel(), /*#__PURE__*/React.createElement(StyledContentContainer, {
47
57
  gutter: gutter,
48
58
  "data-element": "inline-inputs-container",
@@ -51,12 +61,14 @@ const InlineInputs = ({
51
61
  };
52
62
 
53
63
  InlineInputs.propTypes = {
64
+ "adaptiveLabelBreakpoint": PropTypes.number,
54
65
  "children": PropTypes.node,
55
66
  "className": PropTypes.string,
56
67
  "gutter": PropTypes.oneOf(["extra-large", "extra-small", "large", "medium-large", "medium-small", "medium", "none", "small"]),
57
68
  "htmlFor": PropTypes.string,
58
69
  "inputWidth": PropTypes.number,
59
70
  "label": PropTypes.string,
71
+ "labelInline": PropTypes.bool,
60
72
  "labelWidth": PropTypes.number
61
73
  };
62
74
  InlineInputs.displayName = "InlineInputs";
@@ -1,6 +1,21 @@
1
1
  import { InlineInputsProps } from "./inline-inputs.component";
2
- declare const StyledInlineInput: import("styled-components").StyledComponent<"div", any, Pick<InlineInputsProps, "gutter">, never>;
3
- declare const StyledContentContainer: import("styled-components").StyledComponent<"div", any, Pick<InlineInputsProps, "inputWidth" | "gutter">, never>;
4
- declare const StyledInlineInputs: import("styled-components").StyledComponent<"div", any, Pick<InlineInputsProps, "gutter" | "labelWidth">, never>;
2
+ declare type GutterOptions = "none" | "extra-small" | "small" | "medium-small" | "medium" | "medium-large" | "large" | "extra-large";
3
+ interface StyledInlineInputProps {
4
+ /** Gutter prop gets passed down to Row component if false gutter value is "none" */
5
+ gutter?: GutterOptions;
6
+ }
7
+ export interface StyledContentContainerProps extends StyledInlineInputProps {
8
+ /** Width of the inline inputs container in percentage */
9
+ inputWidth?: number;
10
+ }
11
+ export interface StyledInlineInputsProps extends StyledInlineInputProps {
12
+ /** Width of a label in percentage */
13
+ labelWidth?: number;
14
+ /** @ignore @private */
15
+ labelInline?: boolean;
16
+ }
17
+ declare const StyledInlineInput: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
18
+ declare const StyledContentContainer: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
19
+ declare const StyledInlineInputs: import("styled-components").StyledComponent<"div", any, InlineInputsProps, never>;
5
20
  export { StyledContentContainer, StyledInlineInput };
6
21
  export default StyledInlineInputs;
@@ -42,12 +42,16 @@ const StyledContentContainer = styled.div`
42
42
  `}
43
43
  `;
44
44
  const StyledInlineInputs = styled.div`
45
- display: flex;
45
+ display: ${({
46
+ labelInline
47
+ }) => labelInline ? `flex` : `block`};
46
48
  align-items: center;
47
49
 
48
50
  ${StyledLabelContainer} {
49
51
  width: auto;
50
- margin-bottom: 0;
52
+ margin-bottom: ${({
53
+ labelInline
54
+ }) => labelInline ? `0px` : `8px`};
51
55
  padding-right: 16px;
52
56
  flex: 0 0 ${({
53
57
  labelWidth
@@ -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 */
@@ -7,7 +7,7 @@ import { PopoverContainerWrapperStyle, PopoverContainerHeaderStyle, PopoverConta
7
7
  import Icon from "../icon";
8
8
  import createGuid from "../../__internal__/utils/helpers/guid";
9
9
  import { filterStyledSystemPaddingProps } from "../../style/utils";
10
- import ClickAwayWrapper from "../../__internal__/click-away-wrapper";
10
+ import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
11
11
 
12
12
  const renderOpen = ({
13
13
  tabIndex,
@@ -118,19 +118,15 @@ const PopoverContainer = ({
118
118
  onClick: handleCloseButtonClick,
119
119
  ref: closeButtonRef,
120
120
  "aria-label": closeButtonAriaLabel
121
- }; // TODO: Assign proper type after ClickAwayWrapper has been refactored
122
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
121
+ };
123
122
 
124
123
  const handleClickAway = e => {
125
124
  if (!isControlled) setIsOpenInternal(false);
126
125
  if (onClose) onClose(e);
127
126
  };
128
127
 
129
- return /*#__PURE__*/React.createElement(ClickAwayWrapper, {
130
- targets: [ref],
131
- handleClickAway: handleClickAway,
132
- eventTypeId: "mousedown"
133
- }, /*#__PURE__*/React.createElement(PopoverContainerWrapperStyle, {
128
+ useClickAwayListener([ref], handleClickAway, "mousedown");
129
+ return /*#__PURE__*/React.createElement(PopoverContainerWrapperStyle, {
134
130
  "data-component": "popover-container",
135
131
  role: "region",
136
132
  "aria-labelledby": popoverContainerId,
@@ -158,7 +154,7 @@ const PopoverContainer = ({
158
154
  }, filterStyledSystemPaddingProps(rest)), /*#__PURE__*/React.createElement(PopoverContainerHeaderStyle, null, /*#__PURE__*/React.createElement(PopoverContainerTitleStyle, {
159
155
  id: popoverContainerId,
160
156
  "data-element": "popover-container-title"
161
- }, title), renderCloseComponent(renderCloseComponentProps)), children))));
157
+ }, title), renderCloseComponent(renderCloseComponentProps)), children)));
162
158
  };
163
159
 
164
160
  PopoverContainer.propTypes = {
@@ -4,6 +4,7 @@ import React, { useRef, useState, useContext, useCallback, useEffect } from "rea
4
4
  import { ThemeContext } from "styled-components";
5
5
  import PropTypes from "prop-types";
6
6
  import styledSystemPropTypes from "@styled-system/prop-types";
7
+ import useClickAwayListener from "../../hooks/__internal__/useClickAwayListener";
7
8
  import Icon from "../icon";
8
9
  import Button, { ButtonWithForwardRef } from "../button";
9
10
  import StyledSplitButton from "./split-button.style";
@@ -49,13 +50,6 @@ const SplitButton = ({
49
50
  if (isToggleButtonFocused.current) return;
50
51
  setShowAdditionalButtons(false);
51
52
  }, []);
52
- const handleClickOutside = useCallback(({
53
- target
54
- }) => {
55
- if (!splitButtonNode.current.contains(target) && buttonContainer.current && !buttonContainer.current.contains(target)) {
56
- hideButtons();
57
- }
58
- }, [hideButtons]);
59
53
  const handleKeyDown = useCallback(ev => {
60
54
  const numOfChildren = children.length - 1;
61
55
  const currentIndex = additionalButtons.current.findIndex(node => node.current === document.activeElement);
@@ -88,19 +82,17 @@ const SplitButton = ({
88
82
  const addListeners = useCallback(() => {
89
83
  /* istanbul ignore else */
90
84
  if (!listening.current) {
91
- document.addEventListener("click", handleClickOutside);
92
85
  document.addEventListener("keydown", handleKeyDown);
93
86
  listening.current = true;
94
87
  }
95
- }, [handleKeyDown, handleClickOutside]);
88
+ }, [handleKeyDown]);
96
89
  const removeListeners = useCallback(() => {
97
90
  /* istanbul ignore else */
98
91
  if (listening.current) {
99
- document.removeEventListener("click", handleClickOutside);
100
92
  document.removeEventListener("keydown", handleKeyDown);
101
93
  listening.current = false;
102
94
  }
103
- }, [handleKeyDown, handleClickOutside]);
95
+ }, [handleKeyDown]);
104
96
  useEffect(() => {
105
97
  if (showAdditionalButtons) {
106
98
  addListeners();
@@ -260,6 +252,7 @@ const SplitButton = ({
260
252
  }, childrenWithProps()));
261
253
  }
262
254
 
255
+ useClickAwayListener([splitButtonNode], hideButtons);
263
256
  return /*#__PURE__*/React.createElement(StyledSplitButton, _extends({
264
257
  "aria-haspopup": "true",
265
258
  onMouseLeave: hideButtons,
@@ -0,0 +1 @@
1
+ export { default } from "./useClickAwayListener";
@@ -0,0 +1 @@
1
+ export { default } from "./useClickAwayListener";
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const _default: (targets: React.RefObject<HTMLElement>[], handleClickAway: (ev: Event) => void, eventTypeId?: "mousedown" | "click") => void;
3
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { useEffect, useRef } from "react";
2
+ export default ((targets, handleClickAway, eventTypeId = "click") => {
3
+ const targetsRef = useRef(targets);
4
+ targetsRef.current = targets;
5
+ useEffect(() => {
6
+ const fnClickAway = ev => {
7
+ const clickedElements = targetsRef.current.filter(targetRef => {
8
+ var _targetRef$current;
9
+
10
+ return (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.contains(ev === null || ev === void 0 ? void 0 : ev.target);
11
+ });
12
+
13
+ if (!(clickedElements !== null && clickedElements !== void 0 && clickedElements.length)) {
14
+ handleClickAway(ev);
15
+ }
16
+ };
17
+
18
+ document.addEventListener(eventTypeId, fnClickAway);
19
+ return function cleanup() {
20
+ document.removeEventListener(eventTypeId, fnClickAway);
21
+ };
22
+ }, [handleClickAway, eventTypeId]);
23
+ });
@@ -126,12 +126,6 @@ const FocusTrap = ({
126
126
  setCurrentFocusedElement(element);
127
127
  }
128
128
  }, [focusableElements]);
129
- (0, _react.useEffect)(() => {
130
- document.addEventListener("focusin", updateCurrentFocusedElement);
131
- return () => {
132
- document.removeEventListener("focusin", updateCurrentFocusedElement);
133
- };
134
- }, [updateCurrentFocusedElement]);
135
129
  const refocusTrap = (0, _react.useCallback)(() => {
136
130
  var _wrapperRef$current;
137
131
 
@@ -165,13 +159,16 @@ const FocusTrap = ({
165
159
  }
166
160
  };
167
161
 
168
- const focusProps = {
169
- tabIndex,
170
- onBlur
171
- }; // passes focusProps if no tabindex has been explicitly set on the wrapper
162
+ const focusProps = hasNoTabIndex => ({ ...(hasNoTabIndex && {
163
+ tabIndex,
164
+ onBlur
165
+ }),
166
+ onFocus: updateCurrentFocusedElement
167
+ }); // passes focusProps, sets tabIndex and onBlur if no tabIndex has been expicitly set on child
168
+
172
169
 
173
170
  const clonedChildren = _react.default.Children.map(children, child => {
174
- return child.props.tabIndex === undefined ? /*#__PURE__*/_react.default.cloneElement(child, focusProps) : child;
171
+ return /*#__PURE__*/_react.default.cloneElement(child, focusProps(child.props.tabIndex === undefined));
175
172
  });
176
173
 
177
174
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -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 */
@@ -117,7 +117,7 @@ const Label = ({
117
117
 
118
118
  return help && /*#__PURE__*/_react.default.createElement(_iconWrapper.default, wrapperProps, /*#__PURE__*/_react.default.createElement(_help.default, {
119
119
  tooltipId: tooltipId,
120
- tabIndex: helpTabIndex,
120
+ tabIndex: Number(helpTabIndex),
121
121
  type: helpIcon,
122
122
  isFocused: isFocused
123
123
  }, help));
@@ -149,7 +149,7 @@ Label.propTypes = {
149
149
  "error": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
150
150
  "help": _propTypes.default.node,
151
151
  "helpIcon": _propTypes.default.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"]),
152
- "helpTabIndex": _propTypes.default.string,
152
+ "helpTabIndex": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
153
153
  "htmlFor": _propTypes.default.string,
154
154
  "info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
155
155
  "inline": _propTypes.default.bool,
@@ -34,7 +34,6 @@ exports.CheckboxGroupContext = CheckboxGroupContext;
34
34
  const CheckboxGroup = props => {
35
35
  const {
36
36
  children,
37
- groupName,
38
37
  legend,
39
38
  error,
40
39
  warning,
@@ -65,7 +64,6 @@ const CheckboxGroup = props => {
65
64
  legendInline: legendInline
66
65
  }, /*#__PURE__*/_react.default.createElement(CheckboxGroupContext.Provider, {
67
66
  value: {
68
- inputName: groupName,
69
67
  error: !!error,
70
68
  warning: !!warning,
71
69
  info: !!info
@@ -95,9 +93,6 @@ CheckboxGroup.propTypes = {
95
93
  /** The Checkboxes to be rendered in the group */
96
94
  children: _propTypes.default.node.isRequired,
97
95
 
98
- /** Specifies the name prop to be applied to each button in the group */
99
- groupName: _propTypes.default.string.isRequired,
100
-
101
96
  /** Indicate that error has occurred
102
97
  Pass string to display icon, tooltip and red border
103
98
  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 */
@@ -74,8 +74,7 @@ const Checkbox = ({
74
74
  const {
75
75
  error: contextError,
76
76
  warning: contextWarning,
77
- info: contextInfo,
78
- inputName
77
+ info: contextInfo
79
78
  } = (0, _react.useContext)(_checkboxGroup.CheckboxGroupContext);
80
79
  const inputProps = {
81
80
  onClick,
@@ -103,7 +102,6 @@ const Checkbox = ({
103
102
  inputWidth,
104
103
  labelWidth,
105
104
  tooltipPosition,
106
- inputName,
107
105
  ...props
108
106
  };
109
107
  return /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
@@ -29,7 +29,7 @@ var _datePicker = _interopRequireDefault(require("./__internal__/date-picker"));
29
29
 
30
30
  var _dateRange = _interopRequireDefault(require("../date-range/date-range.context"));
31
31
 
32
- var _clickAwayWrapper = _interopRequireDefault(require("../../__internal__/click-away-wrapper"));
32
+ var _useClickAwayListener = _interopRequireDefault(require("../../hooks/__internal__/useClickAwayListener"));
33
33
 
34
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
35
 
@@ -303,11 +303,8 @@ const DateInput = ({
303
303
  }
304
304
  };
305
305
 
306
- return /*#__PURE__*/_react.default.createElement(_clickAwayWrapper.default, {
307
- handleClickAway: handleClickAway,
308
- eventTypeId: "mousedown",
309
- targets: [parentRef, pickerRef]
310
- }, /*#__PURE__*/_react.default.createElement(_date.default, _extends({
306
+ (0, _useClickAwayListener.default)([parentRef, pickerRef], handleClickAway, "mousedown");
307
+ return /*#__PURE__*/_react.default.createElement(_date.default, _extends({
311
308
  ref: wrapperRef,
312
309
  role: "presentation",
313
310
  size: size,
@@ -347,7 +344,7 @@ const DateInput = ({
347
344
  ref: pickerRef,
348
345
  pickerMouseDown: handlePickerMouseDown,
349
346
  open: open
350
- })));
347
+ }));
351
348
  };
352
349
 
353
350
  DateInput.propTypes = { ..._textbox.default.propTypes,
@@ -51,7 +51,8 @@ const Sort = ({
51
51
  sortType: sortType,
52
52
  "aria-labelledby": id.current
53
53
  }, children, sortType && /*#__PURE__*/_react.default.createElement(_icon.default, {
54
- type: sortType === "ascending" ? "sort_up" : "sort_down"
54
+ type: sortType === "ascending" ? "sort_up" : "sort_down",
55
+ color: "--colorsUtilityMajor200"
55
56
  })), !sortType && /*#__PURE__*/_react.default.createElement(_sort.StyledSpaceHolder, null));
56
57
  };
57
58
 
@@ -23,7 +23,6 @@ const StyledSort = _styledComponents.default.div`
23
23
  width: 16px;
24
24
  height: 16px;
25
25
  padding-left: 6px;
26
- color: var(--colorsUtilityMajor200);
27
26
  }
28
27
 
29
28
  :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;