carbon-react 123.0.0 → 123.1.0

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 (23) hide show
  1. package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +2 -0
  2. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +56 -16
  3. package/esm/components/action-popover/action-popover.component.js +2 -2
  4. package/esm/components/action-popover/action-popover.style.js +8 -0
  5. package/esm/components/carousel/carousel.component.js +6 -0
  6. package/esm/components/textarea/textarea.component.d.ts +4 -1
  7. package/esm/components/textarea/textarea.component.js +3 -3
  8. package/esm/components/textbox/textbox.component.d.ts +4 -1
  9. package/esm/components/textbox/textbox.component.js +3 -3
  10. package/esm/components/textbox/textbox.style.d.ts +1 -2
  11. package/esm/components/textbox/textbox.style.js +2 -10
  12. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -0
  13. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +55 -15
  14. package/lib/components/action-popover/action-popover.component.js +2 -2
  15. package/lib/components/action-popover/action-popover.style.js +8 -0
  16. package/lib/components/carousel/carousel.component.js +6 -0
  17. package/lib/components/textarea/textarea.component.d.ts +4 -1
  18. package/lib/components/textarea/textarea.component.js +2 -2
  19. package/lib/components/textbox/textbox.component.d.ts +4 -1
  20. package/lib/components/textbox/textbox.component.js +2 -2
  21. package/lib/components/textbox/textbox.style.d.ts +1 -2
  22. package/lib/components/textbox/textbox.style.js +2 -11
  23. package/package.json +1 -1
@@ -110,6 +110,8 @@ export const ActionPopoverItem = ({
110
110
  alignSubmenu();
111
111
  }
112
112
  }, [alignSubmenu, submenu]);
113
+
114
+ // focuses item on opening of actionPopover submenu
113
115
  useEffect(() => {
114
116
  if (focusItem) {
115
117
  ref.current?.focus();
@@ -1,5 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React, { useCallback, useMemo, useContext, useState } from "react";
2
+ import React, { useCallback, useMemo, useContext, useState, useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import invariant from "invariant";
5
5
  import { Menu } from "../action-popover.style";
@@ -32,7 +32,7 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
32
32
  if (! /*#__PURE__*/React.isValidElement(child)) {
33
33
  return true;
34
34
  }
35
- return child.type !== ActionPopoverItem && child.type !== ActionPopoverDivider;
35
+ return child.type.displayName !== ActionPopoverItem.displayName && child.type.displayName !== ActionPopoverDivider.displayName;
36
36
  });
37
37
  return !incorrectChild;
38
38
  }, [children]);
@@ -42,42 +42,82 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
42
42
  return /*#__PURE__*/React.isValidElement(child) && child.type === ActionPopoverItem;
43
43
  });
44
44
  }, [children]);
45
+ const isItemDisabled = useCallback(value => {
46
+ const item = items[value];
47
+ // The invariant will be triggered before this else path can be explored, hence the ignore else.
48
+ // istanbul ignore else
49
+ return /*#__PURE__*/React.isValidElement(item) && item.props.disabled;
50
+ }, [items]);
51
+ const firstFocusableItem = items.findIndex((_, index) => !isItemDisabled(index));
52
+
53
+ // FIX-ME: FE-6248
54
+ // Once we no longer support Node 16, this function can be removed and `findLastIndex()` can be used in it's place.
55
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex
56
+ function findLastFocusableItem() {
57
+ let lastFocusableItem = -1;
58
+ for (let i = items.length - 1; i >= 0; i--) {
59
+ if (!isItemDisabled(i)) {
60
+ lastFocusableItem = i;
61
+ break;
62
+ }
63
+ }
64
+ return lastFocusableItem;
65
+ }
66
+ const lastFocusableItem = findLastFocusableItem();
67
+ useEffect(() => {
68
+ if (isOpen && firstFocusableItem !== -1) setFocusIndex(firstFocusableItem);
69
+ }, [isOpen, firstFocusableItem, setFocusIndex]);
45
70
  const onKeyDown = useCallback(e => {
46
71
  if (Events.isTabKey(e)) {
47
72
  e.preventDefault();
48
- // TAB: close menu and allow focus to change to next focusable element
73
+ // TAB: close menu and allow focus to change to the next focusable element
49
74
  focusButton();
50
75
  setOpen(false);
51
76
  } else if (Events.isDownKey(e)) {
52
- // DOWN: focus next item or first
77
+ // DOWN: focus on the next item or first non-disabled item
53
78
  e.preventDefault();
54
79
  e.stopPropagation();
55
- const indexValue = focusIndex < items.length - 1 ? focusIndex + 1 : 0;
80
+ let indexValue = focusIndex + 1;
81
+ while (indexValue < items.length && isItemDisabled(indexValue)) {
82
+ indexValue += 1;
83
+ }
84
+ if (indexValue >= items.length) {
85
+ indexValue = firstFocusableItem;
86
+ }
56
87
  setFocusIndex(indexValue);
57
88
  } else if (Events.isUpKey(e)) {
58
- // UP: focus previous item or last
89
+ // UP: focus on the previous item or last non-disabled item
59
90
  e.preventDefault();
60
91
  e.stopPropagation();
61
- const indexValue = focusIndex > 0 ? focusIndex - 1 : items.length - 1;
92
+ let indexValue = focusIndex - 1;
93
+ while (indexValue >= firstFocusableItem && isItemDisabled(indexValue)) {
94
+ indexValue -= 1;
95
+ }
96
+ if (indexValue < firstFocusableItem) {
97
+ indexValue = lastFocusableItem;
98
+ }
62
99
  setFocusIndex(indexValue);
63
100
  } else if (Events.isHomeKey(e)) {
64
- // HOME: focus first item
101
+ // HOME: focus on the first non-disabled item
65
102
  e.preventDefault();
66
103
  e.stopPropagation();
67
- setFocusIndex(0);
104
+ const indexValue = firstFocusableItem;
105
+ setFocusIndex(indexValue);
68
106
  } else if (Events.isEndKey(e)) {
69
- // END: focus last item
107
+ // END: focus on the last non-disabled item
70
108
  e.preventDefault();
71
109
  e.stopPropagation();
72
- setFocusIndex(items.length - 1);
110
+ const indexValue = lastFocusableItem;
111
+ setFocusIndex(indexValue);
73
112
  } else if (e.key.length === 1) {
74
- // any printable character: focus the next item on the list that starts with that character
75
- // selection should wrap to the start of the list
113
+ // Any printable character: focus on the next non-disabled item on the list that starts with that character
114
+ // Selection should wrap to the start of the list
76
115
  e.stopPropagation();
77
116
  let firstMatch;
78
117
  let nextMatch;
79
- React.Children.forEach(items, (child, index) => {
80
- if ( /*#__PURE__*/React.isValidElement(child) && child.props.children.toLowerCase().startsWith(e.key.toLowerCase())) {
118
+ items.forEach((item, index) => {
119
+ if ( /*#__PURE__*/React.isValidElement(item) && !isItemDisabled(index) && item.props.children.toLowerCase().startsWith(e.key.toLowerCase())) {
120
+ // istanbul ignore else
81
121
  if (firstMatch === undefined) {
82
122
  firstMatch = index;
83
123
  }
@@ -92,7 +132,7 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
92
132
  setFocusIndex(firstMatch);
93
133
  }
94
134
  }
95
- }, [focusButton, setOpen, focusIndex, items, setFocusIndex]);
135
+ }, [focusButton, setOpen, focusIndex, items, isItemDisabled, setFocusIndex, firstFocusableItem, lastFocusableItem]);
96
136
  const [childHasSubmenu, setChildHasSubmenu] = useState(false);
97
137
  const [childHasIcon, setChildHasIcon] = useState(false);
98
138
  const [currentSubmenuPosition, setCurrentSubmenuPosition] = useState(submenuPosition);
@@ -118,8 +118,8 @@ export const ActionPopover = ({
118
118
  // There will be multiple document click listeners but we cant prevent propagation because it will interfere with
119
119
  // other instances on the same page
120
120
 
121
- const isInMenu = menu.current && menu.current.contains(target);
122
- const isInButton = buttonRef.current && buttonRef.current.contains(target);
121
+ const isInMenu = menu?.current?.contains(target);
122
+ const isInButton = buttonRef?.current?.contains(target);
123
123
  if (!isInMenu && !isInButton) {
124
124
  setOpen(false);
125
125
  }
@@ -131,6 +131,14 @@ const StyledMenuItem = styled.button`
131
131
  cursor: not-allowed;
132
132
  color: var(--colorsUtilityYin030);
133
133
  }
134
+
135
+ :focus {
136
+ border: none;
137
+ outline: none;
138
+ -webkit-appearance: none;
139
+ -webkit-box-shadow: none;
140
+ box-shadow: none;
141
+ }
134
142
  `}
135
143
 
136
144
  ${({
@@ -1,9 +1,11 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import React, { useCallback, useEffect, useRef, useState, useMemo } from "react";
3
3
  import PropTypes from "prop-types";
4
+ import Logger from "../../__internal__/utils/logger";
4
5
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
5
6
  import { CarouselPreviousButtonWrapperStyle, CarouselNextButtonWrapperStyle, CarouselButtonStyle, CarouselStyledIconRight, CarouselStyledIconLeft, CarouselSelectorWrapperStyle, CarouselSelectorInputWrapperStyle, CarouselSelectorInputStyle, CarouselSelectorLabelStyle, CarouselWrapperStyle, CarouselSliderWrapper } from "./carousel.style";
6
7
  import guid from "../../__internal__/utils/helpers/guid";
8
+ let deprecateWarnTriggered = false;
7
9
  const NEXT = "next";
8
10
  const PREVIOUS = "previous";
9
11
  export const Carousel = ({
@@ -17,6 +19,10 @@ export const Carousel = ({
17
19
  slideIndex,
18
20
  ...props
19
21
  }) => {
22
+ if (!deprecateWarnTriggered) {
23
+ deprecateWarnTriggered = true;
24
+ Logger.deprecate("The Carousel component is deprecated and will soon be removed.");
25
+ }
20
26
  const [selectedSlideIndex, setSelectedSlideIndex] = useState(Number(slideIndex) || Number(initialSlideIndex));
21
27
  const transitionDirection = useRef(NEXT);
22
28
  const lastSlideIndexProp = useRef(slideIndex);
@@ -59,7 +59,10 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
59
59
  label?: string;
60
60
  /** Inline label alignment */
61
61
  labelAlign?: "left" | "right";
62
- /** Text applied to label help tooltip */
62
+ /** [Legacy] Text applied to label help tooltip. When opted into new design validations
63
+ * it will render as a hint above the input, unless an `inputHint`
64
+ * prop is also passed
65
+ */
63
66
  labelHelp?: React.ReactNode;
64
67
  /** When true, label is placed in line an input */
65
68
  labelInline?: boolean;
@@ -12,7 +12,7 @@ import StyledTextarea, { MIN_HEIGHT } from "./textarea.style";
12
12
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
13
13
  import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
14
14
  import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
15
- import { ErrorBorder, StyledHintText, StyledInputHint } from "../textbox/textbox.style";
15
+ import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
16
16
  import ValidationMessage from "../../__internal__/validation-message";
17
17
  import Box from "../box";
18
18
  import Logger from "../../__internal__/utils/logger";
@@ -215,10 +215,10 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
215
215
  useValidationIcon: computeLabelPropValues(validationOnLabel),
216
216
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
217
217
  validationRedesignOptIn: validationRedesignOptIn
218
- }, inputHint ? /*#__PURE__*/React.createElement(StyledInputHint, {
218
+ }, (inputHint || labelHelp && validationRedesignOptIn) && /*#__PURE__*/React.createElement(StyledHintText, {
219
219
  id: inputHintId,
220
220
  "data-element": "input-hint"
221
- }, inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
221
+ }, inputHint || labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
222
222
  position: "relative"
223
223
  }, /*#__PURE__*/React.createElement(ValidationMessage, {
224
224
  error: error,
@@ -52,7 +52,10 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
52
52
  label?: string;
53
53
  /** Inline label alignment */
54
54
  labelAlign?: "left" | "right";
55
- /** A message that the Help component will display */
55
+ /** [Legacy] Text applied to label help tooltip. When opted into new design validations
56
+ * it will render as a hint above the input, unless an `inputHint`
57
+ * prop is also passed
58
+ */
56
59
  labelHelp?: React.ReactNode;
57
60
  /** When true label is inline */
58
61
  labelInline?: boolean;
@@ -11,7 +11,7 @@ import StyledPrefix from "./__internal__/prefix.style";
11
11
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
12
12
  import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
13
13
  import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility/useInputAccessibility";
14
- import { ErrorBorder, StyledInputHint, StyledHintText } from "./textbox.style";
14
+ import { ErrorBorder, StyledHintText } from "./textbox.style";
15
15
  import ValidationMessage from "../../__internal__/validation-message";
16
16
  import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
17
17
  import NumeralDateContext from "../numeral-date/numeral-date-context";
@@ -193,10 +193,10 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
193
193
  "data-element": dataElement,
194
194
  validationIconId: validationRedesignOptIn ? undefined : validationId,
195
195
  validationRedesignOptIn: validationRedesignOptIn
196
- }, filterStyledSystemMarginProps(props)), inputHint ? /*#__PURE__*/React.createElement(StyledInputHint, {
196
+ }, filterStyledSystemMarginProps(props)), (inputHint || labelHelp && validationRedesignOptIn) && /*#__PURE__*/React.createElement(StyledHintText, {
197
197
  id: inputHintId,
198
198
  "data-element": "input-hint"
199
- }, inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
199
+ }, inputHint || labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
200
200
  position: "relative"
201
201
  }, /*#__PURE__*/React.createElement(ValidationMessage, {
202
202
  error: error,
@@ -2,6 +2,5 @@ declare const ErrorBorder: import("styled-components").StyledComponent<"span", a
2
2
  warning: boolean;
3
3
  inline?: boolean | undefined;
4
4
  }, never>;
5
- declare const StyledInputHint: import("styled-components").StyledComponent<"p", any, {}, never>;
6
5
  declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
7
- export { StyledHintText, ErrorBorder, StyledInputHint };
6
+ export { StyledHintText, ErrorBorder };
@@ -13,22 +13,14 @@ const ErrorBorder = styled.span`
13
13
  top: 0px;
14
14
  `}
15
15
  `;
16
- const StyledInputHint = styled.p`
16
+ const StyledHintText = styled.div`
17
17
  ::after {
18
18
  content: " ";
19
19
  }
20
20
 
21
- display: block;
22
- flex: 1;
23
- margin-top: -3px;
24
- margin-bottom: 8px;
25
- color: var(--colorsUtilityYin055);
26
- white-space: pre-wrap;
27
- `;
28
- const StyledHintText = styled.div`
29
21
  margin-top: 0px;
30
22
  margin-bottom: 8px;
31
23
  color: var(--colorsUtilityYin055);
32
24
  font-size: 14px;
33
25
  `;
34
- export { StyledHintText, ErrorBorder, StyledInputHint };
26
+ export { StyledHintText, ErrorBorder };
@@ -119,6 +119,8 @@ const ActionPopoverItem = ({
119
119
  alignSubmenu();
120
120
  }
121
121
  }, [alignSubmenu, submenu]);
122
+
123
+ // focuses item on opening of actionPopover submenu
122
124
  (0, _react.useEffect)(() => {
123
125
  if (focusItem) {
124
126
  ref.current?.focus();
@@ -41,7 +41,7 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
41
41
  if (! /*#__PURE__*/_react.default.isValidElement(child)) {
42
42
  return true;
43
43
  }
44
- return child.type !== _actionPopoverItem.default && child.type !== _actionPopoverDivider.default;
44
+ return child.type.displayName !== _actionPopoverItem.default.displayName && child.type.displayName !== _actionPopoverDivider.default.displayName;
45
45
  });
46
46
  return !incorrectChild;
47
47
  }, [children]);
@@ -51,42 +51,82 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
51
51
  return /*#__PURE__*/_react.default.isValidElement(child) && child.type === _actionPopoverItem.default;
52
52
  });
53
53
  }, [children]);
54
+ const isItemDisabled = (0, _react.useCallback)(value => {
55
+ const item = items[value];
56
+ // The invariant will be triggered before this else path can be explored, hence the ignore else.
57
+ // istanbul ignore else
58
+ return /*#__PURE__*/_react.default.isValidElement(item) && item.props.disabled;
59
+ }, [items]);
60
+ const firstFocusableItem = items.findIndex((_, index) => !isItemDisabled(index));
61
+
62
+ // FIX-ME: FE-6248
63
+ // Once we no longer support Node 16, this function can be removed and `findLastIndex()` can be used in it's place.
64
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex
65
+ function findLastFocusableItem() {
66
+ let lastFocusableItem = -1;
67
+ for (let i = items.length - 1; i >= 0; i--) {
68
+ if (!isItemDisabled(i)) {
69
+ lastFocusableItem = i;
70
+ break;
71
+ }
72
+ }
73
+ return lastFocusableItem;
74
+ }
75
+ const lastFocusableItem = findLastFocusableItem();
76
+ (0, _react.useEffect)(() => {
77
+ if (isOpen && firstFocusableItem !== -1) setFocusIndex(firstFocusableItem);
78
+ }, [isOpen, firstFocusableItem, setFocusIndex]);
54
79
  const onKeyDown = (0, _react.useCallback)(e => {
55
80
  if (_events.default.isTabKey(e)) {
56
81
  e.preventDefault();
57
- // TAB: close menu and allow focus to change to next focusable element
82
+ // TAB: close menu and allow focus to change to the next focusable element
58
83
  focusButton();
59
84
  setOpen(false);
60
85
  } else if (_events.default.isDownKey(e)) {
61
- // DOWN: focus next item or first
86
+ // DOWN: focus on the next item or first non-disabled item
62
87
  e.preventDefault();
63
88
  e.stopPropagation();
64
- const indexValue = focusIndex < items.length - 1 ? focusIndex + 1 : 0;
89
+ let indexValue = focusIndex + 1;
90
+ while (indexValue < items.length && isItemDisabled(indexValue)) {
91
+ indexValue += 1;
92
+ }
93
+ if (indexValue >= items.length) {
94
+ indexValue = firstFocusableItem;
95
+ }
65
96
  setFocusIndex(indexValue);
66
97
  } else if (_events.default.isUpKey(e)) {
67
- // UP: focus previous item or last
98
+ // UP: focus on the previous item or last non-disabled item
68
99
  e.preventDefault();
69
100
  e.stopPropagation();
70
- const indexValue = focusIndex > 0 ? focusIndex - 1 : items.length - 1;
101
+ let indexValue = focusIndex - 1;
102
+ while (indexValue >= firstFocusableItem && isItemDisabled(indexValue)) {
103
+ indexValue -= 1;
104
+ }
105
+ if (indexValue < firstFocusableItem) {
106
+ indexValue = lastFocusableItem;
107
+ }
71
108
  setFocusIndex(indexValue);
72
109
  } else if (_events.default.isHomeKey(e)) {
73
- // HOME: focus first item
110
+ // HOME: focus on the first non-disabled item
74
111
  e.preventDefault();
75
112
  e.stopPropagation();
76
- setFocusIndex(0);
113
+ const indexValue = firstFocusableItem;
114
+ setFocusIndex(indexValue);
77
115
  } else if (_events.default.isEndKey(e)) {
78
- // END: focus last item
116
+ // END: focus on the last non-disabled item
79
117
  e.preventDefault();
80
118
  e.stopPropagation();
81
- setFocusIndex(items.length - 1);
119
+ const indexValue = lastFocusableItem;
120
+ setFocusIndex(indexValue);
82
121
  } else if (e.key.length === 1) {
83
- // any printable character: focus the next item on the list that starts with that character
84
- // selection should wrap to the start of the list
122
+ // Any printable character: focus on the next non-disabled item on the list that starts with that character
123
+ // Selection should wrap to the start of the list
85
124
  e.stopPropagation();
86
125
  let firstMatch;
87
126
  let nextMatch;
88
- _react.default.Children.forEach(items, (child, index) => {
89
- if ( /*#__PURE__*/_react.default.isValidElement(child) && child.props.children.toLowerCase().startsWith(e.key.toLowerCase())) {
127
+ items.forEach((item, index) => {
128
+ if ( /*#__PURE__*/_react.default.isValidElement(item) && !isItemDisabled(index) && item.props.children.toLowerCase().startsWith(e.key.toLowerCase())) {
129
+ // istanbul ignore else
90
130
  if (firstMatch === undefined) {
91
131
  firstMatch = index;
92
132
  }
@@ -101,7 +141,7 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
101
141
  setFocusIndex(firstMatch);
102
142
  }
103
143
  }
104
- }, [focusButton, setOpen, focusIndex, items, setFocusIndex]);
144
+ }, [focusButton, setOpen, focusIndex, items, isItemDisabled, setFocusIndex, firstFocusableItem, lastFocusableItem]);
105
145
  const [childHasSubmenu, setChildHasSubmenu] = (0, _react.useState)(false);
106
146
  const [childHasIcon, setChildHasIcon] = (0, _react.useState)(false);
107
147
  const [currentSubmenuPosition, setCurrentSubmenuPosition] = (0, _react.useState)(submenuPosition);
@@ -127,8 +127,8 @@ const ActionPopover = ({
127
127
  // There will be multiple document click listeners but we cant prevent propagation because it will interfere with
128
128
  // other instances on the same page
129
129
 
130
- const isInMenu = menu.current && menu.current.contains(target);
131
- const isInButton = buttonRef.current && buttonRef.current.contains(target);
130
+ const isInMenu = menu?.current?.contains(target);
131
+ const isInButton = buttonRef?.current?.contains(target);
132
132
  if (!isInMenu && !isInButton) {
133
133
  setOpen(false);
134
134
  }
@@ -143,6 +143,14 @@ const StyledMenuItem = _styledComponents.default.button`
143
143
  cursor: not-allowed;
144
144
  color: var(--colorsUtilityYin030);
145
145
  }
146
+
147
+ :focus {
148
+ border: none;
149
+ outline: none;
150
+ -webkit-appearance: none;
151
+ -webkit-box-shadow: none;
152
+ box-shadow: none;
153
+ }
146
154
  `}
147
155
 
148
156
  ${({
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = exports.Carousel = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
9
10
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
10
11
  var _carousel = require("./carousel.style");
11
12
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
@@ -13,6 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
16
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
+ let deprecateWarnTriggered = false;
16
18
  const NEXT = "next";
17
19
  const PREVIOUS = "previous";
18
20
  const Carousel = ({
@@ -26,6 +28,10 @@ const Carousel = ({
26
28
  slideIndex,
27
29
  ...props
28
30
  }) => {
31
+ if (!deprecateWarnTriggered) {
32
+ deprecateWarnTriggered = true;
33
+ _logger.default.deprecate("The Carousel component is deprecated and will soon be removed.");
34
+ }
29
35
  const [selectedSlideIndex, setSelectedSlideIndex] = (0, _react.useState)(Number(slideIndex) || Number(initialSlideIndex));
30
36
  const transitionDirection = (0, _react.useRef)(NEXT);
31
37
  const lastSlideIndexProp = (0, _react.useRef)(slideIndex);
@@ -59,7 +59,10 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
59
59
  label?: string;
60
60
  /** Inline label alignment */
61
61
  labelAlign?: "left" | "right";
62
- /** Text applied to label help tooltip */
62
+ /** [Legacy] Text applied to label help tooltip. When opted into new design validations
63
+ * it will render as a hint above the input, unless an `inputHint`
64
+ * prop is also passed
65
+ */
63
66
  labelHelp?: React.ReactNode;
64
67
  /** When true, label is placed in line an input */
65
68
  labelInline?: boolean;
@@ -224,10 +224,10 @@ const Textarea = /*#__PURE__*/_react.default.forwardRef(({
224
224
  useValidationIcon: computeLabelPropValues(validationOnLabel),
225
225
  adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
226
226
  validationRedesignOptIn: validationRedesignOptIn
227
- }, inputHint ? /*#__PURE__*/_react.default.createElement(_textbox.StyledInputHint, {
227
+ }, (inputHint || labelHelp && validationRedesignOptIn) && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, {
228
228
  id: inputHintId,
229
229
  "data-element": "input-hint"
230
- }, inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_box.default, {
230
+ }, inputHint || labelHelp), validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_box.default, {
231
231
  position: "relative"
232
232
  }, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
233
233
  error: error,
@@ -52,7 +52,10 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
52
52
  label?: string;
53
53
  /** Inline label alignment */
54
54
  labelAlign?: "left" | "right";
55
- /** A message that the Help component will display */
55
+ /** [Legacy] Text applied to label help tooltip. When opted into new design validations
56
+ * it will render as a hint above the input, unless an `inputHint`
57
+ * prop is also passed
58
+ */
56
59
  labelHelp?: React.ReactNode;
57
60
  /** When true label is inline */
58
61
  labelInline?: boolean;
@@ -202,10 +202,10 @@ const Textbox = /*#__PURE__*/_react.default.forwardRef(({
202
202
  "data-element": dataElement,
203
203
  validationIconId: validationRedesignOptIn ? undefined : validationId,
204
204
  validationRedesignOptIn: validationRedesignOptIn
205
- }, (0, _utils.filterStyledSystemMarginProps)(props)), inputHint ? /*#__PURE__*/_react.default.createElement(_textbox.StyledInputHint, {
205
+ }, (0, _utils.filterStyledSystemMarginProps)(props)), (inputHint || labelHelp && validationRedesignOptIn) && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, {
206
206
  id: inputHintId,
207
207
  "data-element": "input-hint"
208
- }, inputHint) : null, validationRedesignOptIn && labelHelp && /*#__PURE__*/_react.default.createElement(_textbox.StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_box.default, {
208
+ }, inputHint || labelHelp), validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_box.default, {
209
209
  position: "relative"
210
210
  }, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
211
211
  error: error,
@@ -2,6 +2,5 @@ declare const ErrorBorder: import("styled-components").StyledComponent<"span", a
2
2
  warning: boolean;
3
3
  inline?: boolean | undefined;
4
4
  }, never>;
5
- declare const StyledInputHint: import("styled-components").StyledComponent<"p", any, {}, never>;
6
5
  declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
7
- export { StyledHintText, ErrorBorder, StyledInputHint };
6
+ export { StyledHintText, ErrorBorder };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledInputHint = exports.StyledHintText = exports.ErrorBorder = void 0;
6
+ exports.StyledHintText = exports.ErrorBorder = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -22,20 +22,11 @@ const ErrorBorder = _styledComponents.default.span`
22
22
  `}
23
23
  `;
24
24
  exports.ErrorBorder = ErrorBorder;
25
- const StyledInputHint = _styledComponents.default.p`
25
+ const StyledHintText = _styledComponents.default.div`
26
26
  ::after {
27
27
  content: " ";
28
28
  }
29
29
 
30
- display: block;
31
- flex: 1;
32
- margin-top: -3px;
33
- margin-bottom: 8px;
34
- color: var(--colorsUtilityYin055);
35
- white-space: pre-wrap;
36
- `;
37
- exports.StyledInputHint = StyledInputHint;
38
- const StyledHintText = _styledComponents.default.div`
39
30
  margin-top: 0px;
40
31
  margin-bottom: 8px;
41
32
  color: var(--colorsUtilityYin055);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "123.0.0",
3
+ "version": "123.1.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",