carbon-react 125.12.2 → 126.0.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 (31) hide show
  1. package/esm/__internal__/checkable-input/checkable-input.component.d.ts +0 -2
  2. package/esm/__internal__/checkable-input/checkable-input.component.js +0 -3
  3. package/esm/components/button-toggle/button-toggle-group/button-toggle-group.component.d.ts +1 -3
  4. package/esm/components/button-toggle/button-toggle-group/button-toggle-group.component.js +0 -2
  5. package/esm/components/checkbox/checkbox.component.d.ts +0 -2
  6. package/esm/components/checkbox/checkbox.component.js +0 -1
  7. package/esm/components/portal/portal.d.ts +7 -1
  8. package/esm/components/portal/portal.js +18 -2
  9. package/esm/components/radio-button/radio-button.component.d.ts +0 -2
  10. package/esm/components/radio-button/radio-button.component.js +0 -3
  11. package/esm/components/switch/switch.component.d.ts +0 -2
  12. package/esm/components/switch/switch.component.js +0 -1
  13. package/esm/components/time/__internal__/time-toggle/time-toggle.style.d.ts +1 -1
  14. package/esm/components/toast/toast.style.d.ts +1 -1
  15. package/esm/hooks/__internal__/useModalAria/useModalAria.js +12 -3
  16. package/lib/__internal__/checkable-input/checkable-input.component.d.ts +0 -2
  17. package/lib/__internal__/checkable-input/checkable-input.component.js +0 -3
  18. package/lib/components/button-toggle/button-toggle-group/button-toggle-group.component.d.ts +1 -3
  19. package/lib/components/button-toggle/button-toggle-group/button-toggle-group.component.js +0 -2
  20. package/lib/components/checkbox/checkbox.component.d.ts +0 -2
  21. package/lib/components/checkbox/checkbox.component.js +0 -1
  22. package/lib/components/portal/portal.d.ts +7 -1
  23. package/lib/components/portal/portal.js +18 -2
  24. package/lib/components/radio-button/radio-button.component.d.ts +0 -2
  25. package/lib/components/radio-button/radio-button.component.js +0 -3
  26. package/lib/components/switch/switch.component.d.ts +0 -2
  27. package/lib/components/switch/switch.component.js +0 -1
  28. package/lib/components/time/__internal__/time-toggle/time-toggle.style.d.ts +1 -1
  29. package/lib/components/toast/toast.style.d.ts +1 -1
  30. package/lib/hooks/__internal__/useModalAria/useModalAria.js +12 -3
  31. package/package.json +1 -1
@@ -43,8 +43,6 @@ export interface CheckableInputProps extends CommonCheckableInputProps {
43
43
  type: string;
44
44
  /** Value passed to the input */
45
45
  value?: string;
46
- /** Text alignment of the label */
47
- labelAlign?: "left" | "right";
48
46
  /** When true label is inline */
49
47
  labelInline?: boolean;
50
48
  }
@@ -23,7 +23,6 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
23
23
  value,
24
24
  inputWidth,
25
25
  label,
26
- labelAlign,
27
26
  labelHelp,
28
27
  labelInline = true,
29
28
  labelSpacing = 1,
@@ -65,7 +64,6 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
65
64
  id,
66
65
  info,
67
66
  label,
68
- labelAlign,
69
67
  labelHelp,
70
68
  labelHelpIcon: "info",
71
69
  labelId,
@@ -210,7 +208,6 @@ CheckableInput.propTypes = {
210
208
  "itemScope": PropTypes.bool,
211
209
  "itemType": PropTypes.string,
212
210
  "label": PropTypes.node,
213
- "labelAlign": PropTypes.oneOf(["left", "right"]),
214
211
  "labelHelp": PropTypes.node,
215
212
  "labelInline": PropTypes.bool,
216
213
  "labelSpacing": PropTypes.oneOf([1, 2]),
@@ -34,8 +34,6 @@ export interface ButtonToggleGroupProps extends MarginProps, TagProps {
34
34
  labelWidth?: number;
35
35
  /** If true all ButtonToggle children will flex to the full width of the ButtonToggleGroup parent */
36
36
  fullWidth?: boolean;
37
- /** The alignment for the text in the label. */
38
- labelAlign?: "left" | "right";
39
37
  /** Callback triggered by pressing one of the child buttons. Use with controlled components to set the value prop to the value argument */
40
38
  onChange?: (ev: React.MouseEvent<HTMLButtonElement>, value?: string, name?: string) => void;
41
39
  /** Determines which child button is selected when the component is used as a controlled component */
@@ -63,7 +61,7 @@ declare type ButtonToggleGroupContextType = {
63
61
  };
64
62
  export declare const ButtonToggleGroupContext: React.Context<ButtonToggleGroupContextType>;
65
63
  declare const ButtonToggleGroup: {
66
- ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, labelAlign, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: ButtonToggleGroupProps): React.JSX.Element;
64
+ ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: ButtonToggleGroupProps): React.JSX.Element;
67
65
  displayName: string;
68
66
  };
69
67
  export default ButtonToggleGroup;
@@ -32,7 +32,6 @@ const ButtonToggleGroup = ({
32
32
  fullWidth,
33
33
  labelInline,
34
34
  labelWidth,
35
- labelAlign,
36
35
  name,
37
36
  onChange,
38
37
  value,
@@ -119,7 +118,6 @@ const ButtonToggleGroup = ({
119
118
  fieldHelpInline: fieldHelpInline,
120
119
  labelInline: labelInline,
121
120
  labelWidth: labelWidth,
122
- labelAlign: labelAlign,
123
121
  labelId: labelId.current,
124
122
  "data-component": dataComponent,
125
123
  "data-role": dataRole,
@@ -14,8 +14,6 @@ export interface CheckboxProps extends CommonCheckableInputProps, MarginProps {
14
14
  "data-role"?: string;
15
15
  /** Aria label for rendered help component */
16
16
  helpAriaLabel?: string;
17
- /** Text alignment of the label */
18
- labelAlign?: "left" | "right";
19
17
  /** When true label is inline */
20
18
  labelInline?: boolean;
21
19
  /** Accepts a callback function which is triggered on click event */
@@ -230,7 +230,6 @@ Checkbox.propTypes = {
230
230
  "itemScope": PropTypes.bool,
231
231
  "itemType": PropTypes.string,
232
232
  "label": PropTypes.node,
233
- "labelAlign": PropTypes.oneOf(["left", "right"]),
234
233
  "labelHelp": PropTypes.node,
235
234
  "labelInline": PropTypes.bool,
236
235
  "labelSpacing": PropTypes.oneOf([1, 2]),
@@ -12,6 +12,12 @@ export interface PortalProps {
12
12
  id?: string;
13
13
  /** Callback function triggered when parent element is scrolled or window resized. */
14
14
  onReposition?: () => void;
15
+ /** A flag to ensure the portal content will remain interactive with by both mouse
16
+ * users and screenreader users, even if a modal is opened outside of or on top of
17
+ * the portal.
18
+ * To be used with caution.
19
+ */
20
+ inertOptOut?: boolean;
15
21
  }
16
- declare const Portal: ({ children, className, id, onReposition }: PortalProps) => React.JSX.Element;
22
+ declare const Portal: ({ children, className, id, onReposition, inertOptOut, }: PortalProps) => React.JSX.Element;
17
23
  export default Portal;
@@ -1,14 +1,26 @@
1
1
  import React, { useContext, useEffect, useMemo, useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
+ import styled, { css } from "styled-components";
3
4
  import guid from "../../__internal__/utils/helpers/guid";
4
5
  import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
5
6
  import StyledPortalEntrance from "./portal.style";
6
7
  export const PortalContext = /*#__PURE__*/React.createContext({});
8
+ const Container = styled.div`
9
+ ${({
10
+ theme
11
+ }) => css`
12
+ {
13
+ position: relative;
14
+ z-index: ${theme.zIndex.aboveAll};
15
+ }
16
+ `}
17
+ `;
7
18
  const Portal = ({
8
19
  children,
9
20
  className,
10
21
  id,
11
- onReposition
22
+ onReposition,
23
+ inertOptOut
12
24
  }) => {
13
25
  const [portalNode, setPortalNode] = useState(null);
14
26
  const uniqueId = useMemo(() => guid(), []);
@@ -51,6 +63,9 @@ const Portal = ({
51
63
  if (id !== undefined) {
52
64
  node.setAttribute("id", id);
53
65
  }
66
+ if (inertOptOut) {
67
+ node.setAttribute("data-not-inert", "true");
68
+ }
54
69
  setPortalNode(node);
55
70
  let mainNode = document.body;
56
71
  const rootDiv = document.getElementById("root");
@@ -64,8 +79,9 @@ const Portal = ({
64
79
  }
65
80
  return node;
66
81
  };
82
+ const portalContent = inertOptOut ? /*#__PURE__*/React.createElement(Container, null, children) : children;
67
83
  return /*#__PURE__*/React.createElement(StyledPortalEntrance, {
68
84
  "data-portal-entrance": uniqueId
69
- }, /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, children), getPortalContainer()));
85
+ }, /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, portalContent), getPortalContainer()));
70
86
  };
71
87
  export default Portal;
@@ -12,8 +12,6 @@ export interface RadioButtonProps extends CommonCheckableInputProps, MarginProps
12
12
  "data-element"?: string;
13
13
  /** Identifier used for testing purposes, applied to the root element of the component. */
14
14
  "data-role"?: string;
15
- /** Text alignment of the label */
16
- labelAlign?: "left" | "right";
17
15
  /** Accepts a callback function which is triggered on click event */
18
16
  onClick?: (ev: React.MouseEvent<HTMLInputElement>) => void;
19
17
  /** the value of the Radio Button, passed on form submit */
@@ -21,7 +21,6 @@ const RadioButton = /*#__PURE__*/React.forwardRef(({
21
21
  inputWidth,
22
22
  label,
23
23
  labelHelp,
24
- labelAlign,
25
24
  labelSpacing = 1,
26
25
  labelWidth,
27
26
  name,
@@ -85,7 +84,6 @@ const RadioButton = /*#__PURE__*/React.forwardRef(({
85
84
  onChange: handleChange,
86
85
  onBlur,
87
86
  onFocus,
88
- labelAlign,
89
87
  labelInline: true,
90
88
  labelWidth,
91
89
  label,
@@ -232,7 +230,6 @@ RadioButton.propTypes = {
232
230
  "itemScope": PropTypes.bool,
233
231
  "itemType": PropTypes.string,
234
232
  "label": PropTypes.node,
235
- "labelAlign": PropTypes.oneOf(["left", "right"]),
236
233
  "labelHelp": PropTypes.node,
237
234
  "labelSpacing": PropTypes.oneOf([1, 2]),
238
235
  "labelWidth": PropTypes.number,
@@ -12,8 +12,6 @@ export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
12
12
  adaptiveLabelBreakpoint?: number;
13
13
  /** Set the default value of the Switch if component is meant to be used as uncontrolled */
14
14
  defaultChecked?: boolean;
15
- /** Text alignment of the label */
16
- labelAlign?: "left" | "right";
17
15
  /** When true label is inline */
18
16
  labelInline?: boolean;
19
17
  /** Triggers loading animation */
@@ -280,7 +280,6 @@ Switch.propTypes = {
280
280
  "itemScope": PropTypes.bool,
281
281
  "itemType": PropTypes.string,
282
282
  "label": PropTypes.node,
283
- "labelAlign": PropTypes.oneOf(["left", "right"]),
284
283
  "labelHelp": PropTypes.node,
285
284
  "labelInline": PropTypes.bool,
286
285
  "labelSpacing": PropTypes.oneOf([1, 2]),
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  declare const _default: import("styled-components").StyledComponent<{
3
- ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, labelAlign, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: import("../../../button-toggle").ButtonToggleGroupProps): import("react").JSX.Element;
3
+ ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: import("../../../button-toggle").ButtonToggleGroupProps): import("react").JSX.Element;
4
4
  displayName: string;
5
5
  }, any, {
6
6
  disabled?: boolean | undefined;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import TypeIcon from "../message/type-icon/type-icon.style";
3
3
  import { MessageVariant } from "../message/message.component";
4
- declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
4
+ declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition, inertOptOut, }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
5
5
  align?: "left" | "right" | "center" | undefined;
6
6
  alignY?: "bottom" | "top" | "center" | undefined;
7
7
  isCenter?: boolean | undefined;
@@ -8,6 +8,10 @@ export default function useModalAria(containerRef) {
8
8
  useEffect(() => {
9
9
  const originalValues = [];
10
10
  const hideNonTopModalElements = rootElement => {
11
+ if (rootElement.dataset.notInert === "true") {
12
+ // stop recursing, and do nothing, if the container has the "data-not-inert" flag
13
+ return;
14
+ }
11
15
  if (!rootElement.contains(topModal)) {
12
16
  originalValues.push({
13
17
  element: rootElement,
@@ -17,13 +21,18 @@ export default function useModalAria(containerRef) {
17
21
  // need to manually call the blur event on any currently-focused element that might be inside the element
18
22
  // we're making inert, since Firefox fails to do this, which can result in the focus styles remaining on
19
23
  // an input that is no longer focused
20
- if (rootElement.contains(document.activeElement)) {
21
- document.activeElement?.blur();
24
+ if (rootElement.contains(document.activeElement) && document.activeElement instanceof HTMLElement) {
25
+ document.activeElement.blur();
22
26
  }
23
27
  rootElement.setAttribute("aria-hidden", "true");
24
28
  rootElement.setAttribute("inert", "");
25
29
  } else if (rootElement !== topModal) {
26
- Array.from(rootElement.children).forEach(hideNonTopModalElements);
30
+ Array.from(rootElement.children).forEach(node => {
31
+ // istanbul ignore else
32
+ if (node instanceof HTMLElement) {
33
+ hideNonTopModalElements(node);
34
+ }
35
+ });
27
36
  }
28
37
  };
29
38
  if (isTopModal) {
@@ -43,8 +43,6 @@ export interface CheckableInputProps extends CommonCheckableInputProps {
43
43
  type: string;
44
44
  /** Value passed to the input */
45
45
  value?: string;
46
- /** Text alignment of the label */
47
- labelAlign?: "left" | "right";
48
46
  /** When true label is inline */
49
47
  labelInline?: boolean;
50
48
  }
@@ -32,7 +32,6 @@ const CheckableInput = /*#__PURE__*/_react.default.forwardRef(({
32
32
  value,
33
33
  inputWidth,
34
34
  label,
35
- labelAlign,
36
35
  labelHelp,
37
36
  labelInline = true,
38
37
  labelSpacing = 1,
@@ -74,7 +73,6 @@ const CheckableInput = /*#__PURE__*/_react.default.forwardRef(({
74
73
  id,
75
74
  info,
76
75
  label,
77
- labelAlign,
78
76
  labelHelp,
79
77
  labelHelpIcon: "info",
80
78
  labelId,
@@ -219,7 +217,6 @@ CheckableInput.propTypes = {
219
217
  "itemScope": _propTypes.default.bool,
220
218
  "itemType": _propTypes.default.string,
221
219
  "label": _propTypes.default.node,
222
- "labelAlign": _propTypes.default.oneOf(["left", "right"]),
223
220
  "labelHelp": _propTypes.default.node,
224
221
  "labelInline": _propTypes.default.bool,
225
222
  "labelSpacing": _propTypes.default.oneOf([1, 2]),
@@ -34,8 +34,6 @@ export interface ButtonToggleGroupProps extends MarginProps, TagProps {
34
34
  labelWidth?: number;
35
35
  /** If true all ButtonToggle children will flex to the full width of the ButtonToggleGroup parent */
36
36
  fullWidth?: boolean;
37
- /** The alignment for the text in the label. */
38
- labelAlign?: "left" | "right";
39
37
  /** Callback triggered by pressing one of the child buttons. Use with controlled components to set the value prop to the value argument */
40
38
  onChange?: (ev: React.MouseEvent<HTMLButtonElement>, value?: string, name?: string) => void;
41
39
  /** Determines which child button is selected when the component is used as a controlled component */
@@ -63,7 +61,7 @@ declare type ButtonToggleGroupContextType = {
63
61
  };
64
62
  export declare const ButtonToggleGroupContext: React.Context<ButtonToggleGroupContextType>;
65
63
  declare const ButtonToggleGroup: {
66
- ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, labelAlign, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: ButtonToggleGroupProps): React.JSX.Element;
64
+ ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: ButtonToggleGroupProps): React.JSX.Element;
67
65
  displayName: string;
68
66
  };
69
67
  export default ButtonToggleGroup;
@@ -41,7 +41,6 @@ const ButtonToggleGroup = ({
41
41
  fullWidth,
42
42
  labelInline,
43
43
  labelWidth,
44
- labelAlign,
45
44
  name,
46
45
  onChange,
47
46
  value,
@@ -128,7 +127,6 @@ const ButtonToggleGroup = ({
128
127
  fieldHelpInline: fieldHelpInline,
129
128
  labelInline: labelInline,
130
129
  labelWidth: labelWidth,
131
- labelAlign: labelAlign,
132
130
  labelId: labelId.current,
133
131
  "data-component": dataComponent,
134
132
  "data-role": dataRole,
@@ -14,8 +14,6 @@ export interface CheckboxProps extends CommonCheckableInputProps, MarginProps {
14
14
  "data-role"?: string;
15
15
  /** Aria label for rendered help component */
16
16
  helpAriaLabel?: string;
17
- /** Text alignment of the label */
18
- labelAlign?: "left" | "right";
19
17
  /** When true label is inline */
20
18
  labelInline?: boolean;
21
19
  /** Accepts a callback function which is triggered on click event */
@@ -239,7 +239,6 @@ Checkbox.propTypes = {
239
239
  "itemScope": _propTypes.default.bool,
240
240
  "itemType": _propTypes.default.string,
241
241
  "label": _propTypes.default.node,
242
- "labelAlign": _propTypes.default.oneOf(["left", "right"]),
243
242
  "labelHelp": _propTypes.default.node,
244
243
  "labelInline": _propTypes.default.bool,
245
244
  "labelSpacing": _propTypes.default.oneOf([1, 2]),
@@ -12,6 +12,12 @@ export interface PortalProps {
12
12
  id?: string;
13
13
  /** Callback function triggered when parent element is scrolled or window resized. */
14
14
  onReposition?: () => void;
15
+ /** A flag to ensure the portal content will remain interactive with by both mouse
16
+ * users and screenreader users, even if a modal is opened outside of or on top of
17
+ * the portal.
18
+ * To be used with caution.
19
+ */
20
+ inertOptOut?: boolean;
15
21
  }
16
- declare const Portal: ({ children, className, id, onReposition }: PortalProps) => React.JSX.Element;
22
+ declare const Portal: ({ children, className, id, onReposition, inertOptOut, }: PortalProps) => React.JSX.Element;
17
23
  export default Portal;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = exports.PortalContext = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
10
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
10
11
  var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
11
12
  var _portal = _interopRequireDefault(require("./portal.style"));
@@ -13,11 +14,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
16
  const PortalContext = exports.PortalContext = /*#__PURE__*/_react.default.createContext({});
17
+ const Container = _styledComponents.default.div`
18
+ ${({
19
+ theme
20
+ }) => (0, _styledComponents.css)`
21
+ {
22
+ position: relative;
23
+ z-index: ${theme.zIndex.aboveAll};
24
+ }
25
+ `}
26
+ `;
16
27
  const Portal = ({
17
28
  children,
18
29
  className,
19
30
  id,
20
- onReposition
31
+ onReposition,
32
+ inertOptOut
21
33
  }) => {
22
34
  const [portalNode, setPortalNode] = (0, _react.useState)(null);
23
35
  const uniqueId = (0, _react.useMemo)(() => (0, _guid.default)(), []);
@@ -60,6 +72,9 @@ const Portal = ({
60
72
  if (id !== undefined) {
61
73
  node.setAttribute("id", id);
62
74
  }
75
+ if (inertOptOut) {
76
+ node.setAttribute("data-not-inert", "true");
77
+ }
63
78
  setPortalNode(node);
64
79
  let mainNode = document.body;
65
80
  const rootDiv = document.getElementById("root");
@@ -73,8 +88,9 @@ const Portal = ({
73
88
  }
74
89
  return node;
75
90
  };
91
+ const portalContent = inertOptOut ? /*#__PURE__*/_react.default.createElement(Container, null, children) : children;
76
92
  return /*#__PURE__*/_react.default.createElement(_portal.default, {
77
93
  "data-portal-entrance": uniqueId
78
- }, /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, children), getPortalContainer()));
94
+ }, /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, portalContent), getPortalContainer()));
79
95
  };
80
96
  var _default = exports.default = Portal;
@@ -12,8 +12,6 @@ export interface RadioButtonProps extends CommonCheckableInputProps, MarginProps
12
12
  "data-element"?: string;
13
13
  /** Identifier used for testing purposes, applied to the root element of the component. */
14
14
  "data-role"?: string;
15
- /** Text alignment of the label */
16
- labelAlign?: "left" | "right";
17
15
  /** Accepts a callback function which is triggered on click event */
18
16
  onClick?: (ev: React.MouseEvent<HTMLInputElement>) => void;
19
17
  /** the value of the Radio Button, passed on form submit */
@@ -30,7 +30,6 @@ const RadioButton = exports.RadioButton = /*#__PURE__*/_react.default.forwardRef
30
30
  inputWidth,
31
31
  label,
32
32
  labelHelp,
33
- labelAlign,
34
33
  labelSpacing = 1,
35
34
  labelWidth,
36
35
  name,
@@ -94,7 +93,6 @@ const RadioButton = exports.RadioButton = /*#__PURE__*/_react.default.forwardRef
94
93
  onChange: handleChange,
95
94
  onBlur,
96
95
  onFocus,
97
- labelAlign,
98
96
  labelInline: true,
99
97
  labelWidth,
100
98
  label,
@@ -241,7 +239,6 @@ RadioButton.propTypes = {
241
239
  "itemScope": _propTypes.default.bool,
242
240
  "itemType": _propTypes.default.string,
243
241
  "label": _propTypes.default.node,
244
- "labelAlign": _propTypes.default.oneOf(["left", "right"]),
245
242
  "labelHelp": _propTypes.default.node,
246
243
  "labelSpacing": _propTypes.default.oneOf([1, 2]),
247
244
  "labelWidth": _propTypes.default.number,
@@ -12,8 +12,6 @@ export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
12
12
  adaptiveLabelBreakpoint?: number;
13
13
  /** Set the default value of the Switch if component is meant to be used as uncontrolled */
14
14
  defaultChecked?: boolean;
15
- /** Text alignment of the label */
16
- labelAlign?: "left" | "right";
17
15
  /** When true label is inline */
18
16
  labelInline?: boolean;
19
17
  /** Triggers loading animation */
@@ -289,7 +289,6 @@ Switch.propTypes = {
289
289
  "itemScope": _propTypes.default.bool,
290
290
  "itemType": _propTypes.default.string,
291
291
  "label": _propTypes.default.node,
292
- "labelAlign": _propTypes.default.oneOf(["left", "right"]),
293
292
  "labelHelp": _propTypes.default.node,
294
293
  "labelInline": _propTypes.default.bool,
295
294
  "labelSpacing": _propTypes.default.oneOf([1, 2]),
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  declare const _default: import("styled-components").StyledComponent<{
3
- ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, labelAlign, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: import("../../../button-toggle").ButtonToggleGroupProps): import("react").JSX.Element;
3
+ ({ children, fieldHelp, fieldHelpInline, "aria-label": ariaLabel, label, labelHelp, labelSpacing, inputWidth, fullWidth, labelInline, labelWidth, name, onChange, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, id, allowDeselect, className, ...props }: import("../../../button-toggle").ButtonToggleGroupProps): import("react").JSX.Element;
4
4
  displayName: string;
5
5
  }, any, {
6
6
  disabled?: boolean | undefined;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import TypeIcon from "../message/type-icon/type-icon.style";
3
3
  import { MessageVariant } from "../message/message.component";
4
- declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
4
+ declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition, inertOptOut, }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
5
5
  align?: "left" | "right" | "center" | undefined;
6
6
  alignY?: "bottom" | "top" | "center" | undefined;
7
7
  isCenter?: boolean | undefined;
@@ -15,6 +15,10 @@ function useModalAria(containerRef) {
15
15
  (0, _react.useEffect)(() => {
16
16
  const originalValues = [];
17
17
  const hideNonTopModalElements = rootElement => {
18
+ if (rootElement.dataset.notInert === "true") {
19
+ // stop recursing, and do nothing, if the container has the "data-not-inert" flag
20
+ return;
21
+ }
18
22
  if (!rootElement.contains(topModal)) {
19
23
  originalValues.push({
20
24
  element: rootElement,
@@ -24,13 +28,18 @@ function useModalAria(containerRef) {
24
28
  // need to manually call the blur event on any currently-focused element that might be inside the element
25
29
  // we're making inert, since Firefox fails to do this, which can result in the focus styles remaining on
26
30
  // an input that is no longer focused
27
- if (rootElement.contains(document.activeElement)) {
28
- document.activeElement?.blur();
31
+ if (rootElement.contains(document.activeElement) && document.activeElement instanceof HTMLElement) {
32
+ document.activeElement.blur();
29
33
  }
30
34
  rootElement.setAttribute("aria-hidden", "true");
31
35
  rootElement.setAttribute("inert", "");
32
36
  } else if (rootElement !== topModal) {
33
- Array.from(rootElement.children).forEach(hideNonTopModalElements);
37
+ Array.from(rootElement.children).forEach(node => {
38
+ // istanbul ignore else
39
+ if (node instanceof HTMLElement) {
40
+ hideNonTopModalElements(node);
41
+ }
42
+ });
34
43
  }
35
44
  };
36
45
  if (isTopModal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "125.12.2",
3
+ "version": "126.0.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",