carbon-react 119.6.4 → 119.7.1
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.
- package/esm/__internal__/fieldset/fieldset.component.js +6 -2
- package/esm/components/checkbox/checkbox.component.js +6 -1
- package/esm/components/checkbox/checkbox.style.d.ts +1 -0
- package/esm/components/checkbox/checkbox.style.js +4 -1
- package/esm/components/dialog/dialog.component.js +4 -6
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +4 -6
- package/esm/components/radio-button/radio-button-group.component.d.ts +2 -0
- package/esm/components/radio-button/radio-button-group.component.js +56 -4
- package/esm/components/radio-button/radio-button-group.style.d.ts +1 -0
- package/esm/components/radio-button/radio-button-group.style.js +6 -0
- package/esm/components/radio-button/radio-button.component.js +28 -10
- package/esm/components/sidebar/sidebar.component.js +4 -6
- package/esm/components/textbox/textbox.style.d.ts +1 -0
- package/esm/components/textbox/textbox.style.js +3 -2
- package/esm/components/toast/toast.component.js +5 -2
- package/esm/hooks/__internal__/useModalAria/index.d.ts +1 -0
- package/esm/hooks/__internal__/useModalAria/index.js +1 -0
- package/esm/hooks/__internal__/useModalAria/useModalAria.d.ts +2 -0
- package/esm/hooks/__internal__/useModalAria/useModalAria.js +45 -0
- package/lib/__internal__/fieldset/fieldset.component.js +8 -2
- package/lib/components/checkbox/checkbox.component.js +6 -1
- package/lib/components/checkbox/checkbox.style.d.ts +1 -0
- package/lib/components/checkbox/checkbox.style.js +4 -1
- package/lib/components/dialog/dialog.component.js +3 -5
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +3 -5
- package/lib/components/radio-button/radio-button-group.component.d.ts +2 -0
- package/lib/components/radio-button/radio-button-group.component.js +58 -4
- package/lib/components/radio-button/radio-button-group.style.d.ts +1 -0
- package/lib/components/radio-button/radio-button-group.style.js +8 -1
- package/lib/components/radio-button/radio-button.component.js +27 -9
- package/lib/components/sidebar/sidebar.component.js +3 -5
- package/lib/components/textbox/textbox.style.d.ts +1 -0
- package/lib/components/textbox/textbox.style.js +3 -2
- package/lib/components/toast/toast.component.js +5 -2
- package/lib/hooks/__internal__/useModalAria/index.d.ts +1 -0
- package/lib/hooks/__internal__/useModalAria/index.js +13 -0
- package/lib/hooks/__internal__/useModalAria/package.json +6 -0
- package/lib/hooks/__internal__/useModalAria/useModalAria.d.ts +2 -0
- package/lib/hooks/__internal__/useModalAria/useModalAria.js +52 -0
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
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 from "react";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { StyledFieldset, StyledLegend, StyledLegendContent } from "./fieldset.style";
|
|
5
5
|
import ValidationIcon from "../validations/validation-icon.component";
|
|
6
|
+
import { NewValidationContext } from "../../components/carbon-provider/carbon-provider.component";
|
|
6
7
|
import { InputGroupBehaviour, InputGroupContext } from "../input-behaviour";
|
|
7
8
|
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
8
9
|
const Fieldset = _ref => {
|
|
@@ -20,6 +21,9 @@ const Fieldset = _ref => {
|
|
|
20
21
|
blockGroupBehaviour,
|
|
21
22
|
...rest
|
|
22
23
|
} = _ref;
|
|
24
|
+
const {
|
|
25
|
+
validationRedesignOptIn
|
|
26
|
+
} = useContext(NewValidationContext);
|
|
23
27
|
const marginProps = useFormSpacing(rest);
|
|
24
28
|
return /*#__PURE__*/React.createElement(InputGroupBehaviour, {
|
|
25
29
|
blockGroupBehaviour: blockGroupBehaviour
|
|
@@ -39,7 +43,7 @@ const Fieldset = _ref => {
|
|
|
39
43
|
rightPadding: legendSpacing
|
|
40
44
|
}, /*#__PURE__*/React.createElement(StyledLegendContent, {
|
|
41
45
|
isRequired: isRequired
|
|
42
|
-
}, legend, /*#__PURE__*/React.createElement(ValidationIcon, {
|
|
46
|
+
}, legend, !validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationIcon, {
|
|
43
47
|
error: error,
|
|
44
48
|
warning: warning,
|
|
45
49
|
info: info,
|
|
@@ -9,6 +9,7 @@ import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
|
9
9
|
import { CheckboxGroupContext } from "./checkbox-group.component";
|
|
10
10
|
import Logger from "../../__internal__/utils/logger";
|
|
11
11
|
import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
|
|
12
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
12
13
|
let deprecateInputRefWarnTriggered = false;
|
|
13
14
|
let deprecateUncontrolledWarnTriggered = false;
|
|
14
15
|
const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
@@ -47,6 +48,9 @@ const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
47
48
|
inputRef,
|
|
48
49
|
...rest
|
|
49
50
|
} = _ref;
|
|
51
|
+
const {
|
|
52
|
+
validationRedesignOptIn
|
|
53
|
+
} = useContext(NewValidationContext);
|
|
50
54
|
const largeScreen = useIsAboveBreakpoint(adaptiveSpacingBreakpoint);
|
|
51
55
|
const adaptiveSpacingSmallScreen = !!(adaptiveSpacingBreakpoint && !largeScreen);
|
|
52
56
|
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
@@ -110,7 +114,8 @@ const Checkbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
110
114
|
info: contextInfo || info,
|
|
111
115
|
fieldHelpInline: fieldHelpInline,
|
|
112
116
|
reverse: reverse,
|
|
113
|
-
size: size
|
|
117
|
+
size: size,
|
|
118
|
+
applyNewValidation: validationRedesignOptIn
|
|
114
119
|
}, marginProps), /*#__PURE__*/React.createElement(CheckableInput, inputProps, /*#__PURE__*/React.createElement(CheckboxSvg, null))));
|
|
115
120
|
});
|
|
116
121
|
Checkbox.propTypes = {
|
|
@@ -8,6 +8,7 @@ export interface StyledCheckboxProps extends ValidationProps, MarginProps {
|
|
|
8
8
|
labelSpacing?: 1 | 2;
|
|
9
9
|
reverse?: boolean;
|
|
10
10
|
adaptiveSpacingSmallScreen?: boolean;
|
|
11
|
+
applyNewValidation?: boolean;
|
|
11
12
|
}
|
|
12
13
|
declare const StyledCheckbox: import("styled-components").StyledComponent<"div", any, StyledCheckboxProps, never>;
|
|
13
14
|
export default StyledCheckbox;
|
|
@@ -20,7 +20,8 @@ const StyledCheckbox = styled.div`
|
|
|
20
20
|
inputWidth,
|
|
21
21
|
reverse,
|
|
22
22
|
size,
|
|
23
|
-
adaptiveSpacingSmallScreen
|
|
23
|
+
adaptiveSpacingSmallScreen,
|
|
24
|
+
applyNewValidation
|
|
24
25
|
} = _ref;
|
|
25
26
|
return css`
|
|
26
27
|
${adaptiveSpacingSmallScreen && "margin-left: 0;"}
|
|
@@ -41,6 +42,8 @@ const StyledCheckbox = styled.div`
|
|
|
41
42
|
${info && `border: 1px solid var(--colorsSemanticInfo500);`}
|
|
42
43
|
${warning && `border: 1px solid var(--colorsSemanticCaution500);`}
|
|
43
44
|
${error && `border: 2px solid var(--colorsSemanticNegative500);`}
|
|
45
|
+
|
|
46
|
+
${warning && applyNewValidation && `border: 1px solid var(--colorsUtilityMajor300);`}
|
|
44
47
|
`}
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -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, { useRef, useEffect, useLayoutEffect, useCallback
|
|
2
|
+
import React, { useRef, useEffect, useLayoutEffect, useCallback } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
5
5
|
import Modal from "../modal";
|
|
@@ -12,7 +12,7 @@ import IconButton from "../icon-button";
|
|
|
12
12
|
import Icon from "../icon";
|
|
13
13
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
14
14
|
import useIsStickyFooterForm from "../../hooks/__internal__/useIsStickyFooterForm";
|
|
15
|
-
import
|
|
15
|
+
import useModalAria from "../../hooks/__internal__/useModalAria/useModalAria";
|
|
16
16
|
const PADDING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
17
17
|
export const Dialog = _ref => {
|
|
18
18
|
let {
|
|
@@ -49,9 +49,7 @@ export const Dialog = _ref => {
|
|
|
49
49
|
current: subtitleId
|
|
50
50
|
} = useRef(createGuid());
|
|
51
51
|
const hasStickyFooter = useIsStickyFooterForm(children);
|
|
52
|
-
const
|
|
53
|
-
topModal
|
|
54
|
-
} = useContext(TopModalContext);
|
|
52
|
+
const isTopModal = useModalAria(dialogRef);
|
|
55
53
|
const centerDialog = useCallback(() => {
|
|
56
54
|
/* istanbul ignore if */
|
|
57
55
|
if (!dialogRef.current) {
|
|
@@ -162,7 +160,7 @@ export const Dialog = _ref => {
|
|
|
162
160
|
isOpen: open,
|
|
163
161
|
additionalWrapperRefs: focusableContainers
|
|
164
162
|
}, /*#__PURE__*/React.createElement(StyledDialog, _extends({
|
|
165
|
-
"aria-modal":
|
|
163
|
+
"aria-modal": isTopModal ? true : undefined,
|
|
166
164
|
ref: dialogRef,
|
|
167
165
|
topMargin: TOP_MARGIN
|
|
168
166
|
}, dialogProps, {
|
|
@@ -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, { useRef
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import createGuid from "../../__internal__/utils/helpers/guid";
|
|
5
5
|
import Modal from "../modal";
|
|
@@ -12,7 +12,7 @@ import IconButton from "../icon-button";
|
|
|
12
12
|
import Icon from "../icon";
|
|
13
13
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
14
14
|
import useIsStickyFooterForm from "../../hooks/__internal__/useIsStickyFooterForm";
|
|
15
|
-
import
|
|
15
|
+
import useModalAria from "../../hooks/__internal__/useModalAria/useModalAria";
|
|
16
16
|
export const DialogFullScreen = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -48,9 +48,7 @@ export const DialogFullScreen = _ref => {
|
|
|
48
48
|
current: subtitleId
|
|
49
49
|
} = useRef(createGuid());
|
|
50
50
|
const hasStickyFooter = useIsStickyFooterForm(children);
|
|
51
|
-
const
|
|
52
|
-
topModal
|
|
53
|
-
} = useContext(TopModalContext);
|
|
51
|
+
const isTopModal = useModalAria(dialogRef);
|
|
54
52
|
const closeIcon = () => {
|
|
55
53
|
if (!showCloseIcon || !onCancel) return null;
|
|
56
54
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
@@ -96,7 +94,7 @@ export const DialogFullScreen = _ref => {
|
|
|
96
94
|
additionalWrapperRefs: focusableContainers,
|
|
97
95
|
focusableSelectors: focusableSelectors
|
|
98
96
|
}, /*#__PURE__*/React.createElement(StyledDialogFullScreen, _extends({
|
|
99
|
-
"aria-modal": role === "dialog" &&
|
|
97
|
+
"aria-modal": role === "dialog" && isTopModal ? true : undefined
|
|
100
98
|
}, ariaProps, {
|
|
101
99
|
ref: dialogRef,
|
|
102
100
|
"data-element": "dialog-full-screen",
|
|
@@ -14,6 +14,8 @@ export interface RadioButtonGroupProps extends ValidationProps, MarginProps {
|
|
|
14
14
|
labelSpacing?: 1 | 2;
|
|
15
15
|
/** The content for the RadioGroup Legend */
|
|
16
16
|
legend?: string;
|
|
17
|
+
/** The content for the hint text of the RadioGroup Legend */
|
|
18
|
+
legendHelp?: string;
|
|
17
19
|
/** Text alignment of legend when inline */
|
|
18
20
|
legendAlign?: "left" | "right";
|
|
19
21
|
/** When true, legend is placed in line with the radiobuttons */
|
|
@@ -1,20 +1,25 @@
|
|
|
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 from "react";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
5
5
|
import Fieldset from "../../__internal__/fieldset";
|
|
6
|
-
import RadioButtonGroupStyle from "./radio-button-group.style";
|
|
6
|
+
import RadioButtonGroupStyle, { StyledHintText } from "./radio-button-group.style";
|
|
7
7
|
import RadioButtonMapper from "../../__internal__/radio-button-mapper/radio-button-mapper.component";
|
|
8
8
|
import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
|
|
9
9
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
10
10
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
11
11
|
import Logger from "../../__internal__/utils/logger";
|
|
12
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
13
|
+
import ValidationMessage from "../../__internal__/validation-message/validation-message.component";
|
|
14
|
+
import Box from "../../components/box";
|
|
15
|
+
import { ErrorBorder } from "../../components/textbox/textbox.style";
|
|
12
16
|
let deprecateUncontrolledWarnTriggered = false;
|
|
13
17
|
export const RadioButtonGroup = props => {
|
|
14
18
|
const {
|
|
15
19
|
children,
|
|
16
20
|
name,
|
|
17
21
|
legend,
|
|
22
|
+
legendHelp,
|
|
18
23
|
error,
|
|
19
24
|
warning,
|
|
20
25
|
info,
|
|
@@ -32,6 +37,9 @@ export const RadioButtonGroup = props => {
|
|
|
32
37
|
required,
|
|
33
38
|
tooltipPosition
|
|
34
39
|
} = props;
|
|
40
|
+
const {
|
|
41
|
+
validationRedesignOptIn
|
|
42
|
+
} = useContext(NewValidationContext);
|
|
35
43
|
if (!deprecateUncontrolledWarnTriggered && !onChange) {
|
|
36
44
|
deprecateUncontrolledWarnTriggered = true;
|
|
37
45
|
Logger.deprecate("Uncontrolled behaviour in `Radio Button` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
|
|
@@ -47,7 +55,51 @@ export const RadioButtonGroup = props => {
|
|
|
47
55
|
if (adaptiveSpacingBreakpoint && !isAboveSpacingBreakpoint) {
|
|
48
56
|
marginLeft = undefined;
|
|
49
57
|
}
|
|
50
|
-
return /*#__PURE__*/React.createElement(
|
|
58
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, validationRedesignOptIn ? /*#__PURE__*/React.createElement(Fieldset, _extends({
|
|
59
|
+
legend: legend,
|
|
60
|
+
error: error,
|
|
61
|
+
warning: warning,
|
|
62
|
+
info: info,
|
|
63
|
+
inline: inlineLegend,
|
|
64
|
+
legendWidth: legendWidth,
|
|
65
|
+
legendAlign: legendAlign,
|
|
66
|
+
legendSpacing: legendSpacing,
|
|
67
|
+
isRequired: required
|
|
68
|
+
}, tagComponent("radiogroup", props), marginProps, {
|
|
69
|
+
ml: marginLeft,
|
|
70
|
+
blockGroupBehaviour: !(error || warning)
|
|
71
|
+
}), legendHelp && /*#__PURE__*/React.createElement(StyledHintText, null, legendHelp), /*#__PURE__*/React.createElement(Box, {
|
|
72
|
+
position: "relative"
|
|
73
|
+
}, /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
74
|
+
error: error,
|
|
75
|
+
warning: warning
|
|
76
|
+
}), (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
77
|
+
inline: inline,
|
|
78
|
+
warning: !!(!error && warning)
|
|
79
|
+
}), /*#__PURE__*/React.createElement(RadioButtonGroupStyle, {
|
|
80
|
+
"data-component": "radio-button-group",
|
|
81
|
+
role: "radiogroup",
|
|
82
|
+
inline: inline,
|
|
83
|
+
legendInline: inlineLegend
|
|
84
|
+
}, /*#__PURE__*/React.createElement(RadioButtonMapper, {
|
|
85
|
+
name: name,
|
|
86
|
+
onBlur: onBlur,
|
|
87
|
+
onChange: onChange,
|
|
88
|
+
value: value
|
|
89
|
+
}, React.Children.map(children, child => {
|
|
90
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
91
|
+
return child;
|
|
92
|
+
}
|
|
93
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
94
|
+
inline,
|
|
95
|
+
labelSpacing,
|
|
96
|
+
error: !!error,
|
|
97
|
+
warning: !!warning,
|
|
98
|
+
info: !!info,
|
|
99
|
+
required,
|
|
100
|
+
...child.props
|
|
101
|
+
});
|
|
102
|
+
}))))) : /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
51
103
|
tooltipPosition: tooltipPosition
|
|
52
104
|
}, /*#__PURE__*/React.createElement(Fieldset, _extends({
|
|
53
105
|
legend: legend,
|
|
@@ -85,7 +137,7 @@ export const RadioButtonGroup = props => {
|
|
|
85
137
|
required,
|
|
86
138
|
...child.props
|
|
87
139
|
});
|
|
88
|
-
})))));
|
|
140
|
+
}))))));
|
|
89
141
|
};
|
|
90
142
|
RadioButtonGroup.displayName = "RadioButtonGroup";
|
|
91
143
|
export default RadioButtonGroup;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
+
export const StyledHintText = styled.div`
|
|
3
|
+
margin-top: -4px;
|
|
4
|
+
margin-bottom: 8px;
|
|
5
|
+
color: var(--colorsUtilityYin055);
|
|
6
|
+
font-size: 14px;
|
|
7
|
+
`;
|
|
2
8
|
const RadioButtonGroupStyle = styled.div`
|
|
3
9
|
${_ref => {
|
|
4
10
|
let {
|
|
@@ -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 } from "react";
|
|
2
|
+
import React, { useCallback, useContext } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import invariant from "invariant";
|
|
5
5
|
import RadioButtonStyle from "./radio-button.style";
|
|
@@ -8,6 +8,7 @@ import RadioButtonSvg from "./radio-button-svg.component";
|
|
|
8
8
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
9
9
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
10
10
|
import Logger from "../../__internal__/utils/logger";
|
|
11
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
11
12
|
let deprecateInputRefWarnTriggered = false;
|
|
12
13
|
const RadioButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
13
14
|
let {
|
|
@@ -43,6 +44,9 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
43
44
|
inputRef,
|
|
44
45
|
...props
|
|
45
46
|
} = _ref;
|
|
47
|
+
const {
|
|
48
|
+
validationRedesignOptIn
|
|
49
|
+
} = useContext(NewValidationContext);
|
|
46
50
|
const marginProps = filterStyledSystemMarginProps(props);
|
|
47
51
|
const handleChange = useCallback(event => {
|
|
48
52
|
/* istanbul ignore else */
|
|
@@ -57,17 +61,24 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
57
61
|
deprecateInputRefWarnTriggered = true;
|
|
58
62
|
Logger.deprecate("The `inputRef` prop in `RadioButton` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
59
63
|
}
|
|
60
|
-
const
|
|
64
|
+
const validationProps = {
|
|
61
65
|
disabled,
|
|
62
|
-
fieldHelpInline,
|
|
63
66
|
inputWidth,
|
|
64
|
-
labelSpacing,
|
|
65
67
|
error,
|
|
66
68
|
warning,
|
|
67
69
|
info
|
|
68
70
|
};
|
|
71
|
+
const commonProps = {
|
|
72
|
+
...validationProps,
|
|
73
|
+
fieldHelpInline,
|
|
74
|
+
labelSpacing
|
|
75
|
+
};
|
|
69
76
|
const inputProps = {
|
|
70
|
-
...
|
|
77
|
+
...(validationRedesignOptIn ? {
|
|
78
|
+
...validationProps
|
|
79
|
+
} : {
|
|
80
|
+
...commonProps
|
|
81
|
+
}),
|
|
71
82
|
autoFocus,
|
|
72
83
|
checked,
|
|
73
84
|
fieldHelp,
|
|
@@ -94,17 +105,24 @@ const RadioButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
94
105
|
...props
|
|
95
106
|
};
|
|
96
107
|
!!props.children ? process.env.NODE_ENV !== "production" ? invariant(false, "This component is meant to be used as a self-closing tag. " + "You should probably use the label prop instead.") : invariant(false) : void 0;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
tooltipPosition: tooltipPosition
|
|
100
|
-
}, /*#__PURE__*/React.createElement(RadioButtonStyle, _extends({
|
|
108
|
+
const componentToRender = /*#__PURE__*/React.createElement(RadioButtonStyle, _extends({
|
|
109
|
+
applyNewValidation: validationRedesignOptIn,
|
|
101
110
|
"data-component": dataComponent,
|
|
102
111
|
"data-role": dataRole,
|
|
103
112
|
"data-element": dataElement,
|
|
104
113
|
inline: inline,
|
|
105
114
|
reverse: reverse,
|
|
106
115
|
size: size
|
|
107
|
-
},
|
|
116
|
+
}, validationRedesignOptIn ? {
|
|
117
|
+
...validationProps
|
|
118
|
+
} : {
|
|
119
|
+
...commonProps,
|
|
120
|
+
fieldHelp
|
|
121
|
+
}, marginProps), /*#__PURE__*/React.createElement(CheckableInput, inputProps, /*#__PURE__*/React.createElement(RadioButtonSvg, null)));
|
|
122
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, validationRedesignOptIn ? componentToRender : /*#__PURE__*/React.createElement(TooltipProvider, {
|
|
123
|
+
helpAriaLabel: helpAriaLabel,
|
|
124
|
+
tooltipPosition: tooltipPosition
|
|
125
|
+
}, componentToRender));
|
|
108
126
|
});
|
|
109
127
|
RadioButton.propTypes = {
|
|
110
128
|
"about": PropTypes.string,
|
|
@@ -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,
|
|
2
|
+
import React, { useCallback, useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import Modal from "../modal";
|
|
5
5
|
import StyledSidebar from "./sidebar.style";
|
|
@@ -12,7 +12,7 @@ import createGuid from "../../__internal__/utils/helpers/guid";
|
|
|
12
12
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
13
13
|
import { filterStyledSystemPaddingProps } from "../../style/utils";
|
|
14
14
|
import useIsStickyFooterForm from "../../hooks/__internal__/useIsStickyFooterForm";
|
|
15
|
-
import
|
|
15
|
+
import useModalAria from "../../hooks/__internal__/useModalAria/useModalAria";
|
|
16
16
|
|
|
17
17
|
// TODO FE-5408 will investigate why React.RefObject<T> produces a failed prop type when current = null
|
|
18
18
|
|
|
@@ -52,9 +52,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
52
52
|
if (typeof ref === "object") ref.current = reference;
|
|
53
53
|
if (typeof ref === "function") ref(reference);
|
|
54
54
|
}, [ref]);
|
|
55
|
-
const
|
|
56
|
-
topModal
|
|
57
|
-
} = useContext(TopModalContext);
|
|
55
|
+
const isTopModal = useModalAria(sidebarRef);
|
|
58
56
|
const closeIcon = () => {
|
|
59
57
|
if (!onCancel) return null;
|
|
60
58
|
return /*#__PURE__*/React.createElement(IconButton, {
|
|
@@ -71,7 +69,7 @@ const Sidebar = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
71
69
|
"data-role": rest["data-role"]
|
|
72
70
|
};
|
|
73
71
|
const sidebar = /*#__PURE__*/React.createElement(StyledSidebar, _extends({
|
|
74
|
-
"aria-modal": !enableBackgroundUI &&
|
|
72
|
+
"aria-modal": !enableBackgroundUI && isTopModal,
|
|
75
73
|
"aria-describedby": ariaDescribedBy,
|
|
76
74
|
"aria-label": ariaLabel,
|
|
77
75
|
"aria-labelledby": !ariaLabelledBy && !ariaLabel ? headerId : ariaLabelledBy,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const ErrorBorder: import("styled-components").StyledComponent<"span", any, {
|
|
2
2
|
warning: boolean;
|
|
3
|
+
inline?: boolean | undefined;
|
|
3
4
|
}, never>;
|
|
4
5
|
declare const StyledInputHint: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
5
6
|
declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -2,7 +2,8 @@ import styled, { css } from "styled-components";
|
|
|
2
2
|
const ErrorBorder = styled.span`
|
|
3
3
|
${_ref => {
|
|
4
4
|
let {
|
|
5
|
-
warning
|
|
5
|
+
warning,
|
|
6
|
+
inline
|
|
6
7
|
} = _ref;
|
|
7
8
|
return css`
|
|
8
9
|
position: absolute;
|
|
@@ -10,7 +11,7 @@ const ErrorBorder = styled.span`
|
|
|
10
11
|
width: 2px;
|
|
11
12
|
background-color: ${warning ? "var(--colorsSemanticCaution500)" : "var(--colorsSemanticNegative500)"};
|
|
12
13
|
left: -12px;
|
|
13
|
-
bottom: 0px;
|
|
14
|
+
bottom: ${inline ? "10px" : "0px"};
|
|
14
15
|
top: 0px;
|
|
15
16
|
`;
|
|
16
17
|
}}
|
|
@@ -58,8 +58,11 @@ const Toast = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
if (!disableAutoFocus) {
|
|
60
60
|
if (open) {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
// setTimeout needed as otherwise this runs before the ref is populated
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
focusedElementBeforeOpening.current = document.activeElement;
|
|
64
|
+
toastContentNodeRef.current?.focus();
|
|
65
|
+
}, 0);
|
|
63
66
|
} else if (focusedElementBeforeOpening.current) {
|
|
64
67
|
focusedElementBeforeOpening.current.focus();
|
|
65
68
|
focusedElementBeforeOpening.current = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./useModalAria";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./useModalAria";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useContext, useEffect } from "react";
|
|
2
|
+
import TopModalContext from "../../../components/carbon-provider/top-modal-context";
|
|
3
|
+
export default function useModalAria(containerRef) {
|
|
4
|
+
const {
|
|
5
|
+
topModal
|
|
6
|
+
} = useContext(TopModalContext);
|
|
7
|
+
const isTopModal = topModal?.contains(containerRef.current);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const originalValues = [];
|
|
10
|
+
const hideNonTopModalElements = rootElement => {
|
|
11
|
+
if (!rootElement.contains(topModal)) {
|
|
12
|
+
originalValues.push({
|
|
13
|
+
element: rootElement,
|
|
14
|
+
"aria-hidden": rootElement.getAttribute("aria-hidden"),
|
|
15
|
+
inert: rootElement.getAttribute("inert")
|
|
16
|
+
});
|
|
17
|
+
rootElement.setAttribute("aria-hidden", "true");
|
|
18
|
+
rootElement.setAttribute("inert", "");
|
|
19
|
+
} else if (rootElement !== topModal) {
|
|
20
|
+
Array.from(rootElement.children).forEach(hideNonTopModalElements);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
if (isTopModal) {
|
|
24
|
+
hideNonTopModalElements(document.body);
|
|
25
|
+
}
|
|
26
|
+
return () => originalValues.forEach(_ref => {
|
|
27
|
+
let {
|
|
28
|
+
element,
|
|
29
|
+
"aria-hidden": ariaHidden,
|
|
30
|
+
inert
|
|
31
|
+
} = _ref;
|
|
32
|
+
if (ariaHidden === null) {
|
|
33
|
+
element.removeAttribute("aria-hidden");
|
|
34
|
+
} else {
|
|
35
|
+
element.setAttribute("aria-hidden", ariaHidden);
|
|
36
|
+
}
|
|
37
|
+
if (inert === null) {
|
|
38
|
+
element.removeAttribute("inert");
|
|
39
|
+
} else {
|
|
40
|
+
element.setAttribute("inert", inert);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}, [topModal, isTopModal]);
|
|
44
|
+
return isTopModal;
|
|
45
|
+
}
|
|
@@ -4,13 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _fieldset = require("./fieldset.style");
|
|
10
10
|
var _validationIcon = _interopRequireDefault(require("../validations/validation-icon.component"));
|
|
11
|
+
var _carbonProvider = require("../../components/carbon-provider/carbon-provider.component");
|
|
11
12
|
var _inputBehaviour = require("../input-behaviour");
|
|
12
13
|
var _useFormSpacing = _interopRequireDefault(require("../../hooks/__internal__/useFormSpacing"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
14
17
|
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); }
|
|
15
18
|
const Fieldset = _ref => {
|
|
16
19
|
let {
|
|
@@ -27,6 +30,9 @@ const Fieldset = _ref => {
|
|
|
27
30
|
blockGroupBehaviour,
|
|
28
31
|
...rest
|
|
29
32
|
} = _ref;
|
|
33
|
+
const {
|
|
34
|
+
validationRedesignOptIn
|
|
35
|
+
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
30
36
|
const marginProps = (0, _useFormSpacing.default)(rest);
|
|
31
37
|
return /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputGroupBehaviour, {
|
|
32
38
|
blockGroupBehaviour: blockGroupBehaviour
|
|
@@ -46,7 +52,7 @@ const Fieldset = _ref => {
|
|
|
46
52
|
rightPadding: legendSpacing
|
|
47
53
|
}, /*#__PURE__*/_react.default.createElement(_fieldset.StyledLegendContent, {
|
|
48
54
|
isRequired: isRequired
|
|
49
|
-
}, legend, /*#__PURE__*/_react.default.createElement(_validationIcon.default, {
|
|
55
|
+
}, legend, !validationRedesignOptIn && /*#__PURE__*/_react.default.createElement(_validationIcon.default, {
|
|
50
56
|
error: error,
|
|
51
57
|
warning: warning,
|
|
52
58
|
info: info,
|
|
@@ -14,6 +14,7 @@ var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
|
14
14
|
var _checkboxGroup = require("./checkbox-group.component");
|
|
15
15
|
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
16
16
|
var _useFormSpacing = _interopRequireDefault(require("../../hooks/__internal__/useFormSpacing"));
|
|
17
|
+
var _carbonProvider = require("../carbon-provider/carbon-provider.component");
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
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); }
|
|
19
20
|
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; }
|
|
@@ -56,6 +57,9 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
56
57
|
inputRef,
|
|
57
58
|
...rest
|
|
58
59
|
} = _ref;
|
|
60
|
+
const {
|
|
61
|
+
validationRedesignOptIn
|
|
62
|
+
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
59
63
|
const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveSpacingBreakpoint);
|
|
60
64
|
const adaptiveSpacingSmallScreen = !!(adaptiveSpacingBreakpoint && !largeScreen);
|
|
61
65
|
const checkboxGroupContext = (0, _react.useContext)(_checkboxGroup.CheckboxGroupContext);
|
|
@@ -119,7 +123,8 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
119
123
|
info: contextInfo || info,
|
|
120
124
|
fieldHelpInline: fieldHelpInline,
|
|
121
125
|
reverse: reverse,
|
|
122
|
-
size: size
|
|
126
|
+
size: size,
|
|
127
|
+
applyNewValidation: validationRedesignOptIn
|
|
123
128
|
}, marginProps), /*#__PURE__*/_react.default.createElement(_checkableInput.default, inputProps, /*#__PURE__*/_react.default.createElement(_checkboxSvg.default, null))));
|
|
124
129
|
});
|
|
125
130
|
exports.Checkbox = Checkbox;
|
|
@@ -8,6 +8,7 @@ export interface StyledCheckboxProps extends ValidationProps, MarginProps {
|
|
|
8
8
|
labelSpacing?: 1 | 2;
|
|
9
9
|
reverse?: boolean;
|
|
10
10
|
adaptiveSpacingSmallScreen?: boolean;
|
|
11
|
+
applyNewValidation?: boolean;
|
|
11
12
|
}
|
|
12
13
|
declare const StyledCheckbox: import("styled-components").StyledComponent<"div", any, StyledCheckboxProps, never>;
|
|
13
14
|
export default StyledCheckbox;
|
|
@@ -29,7 +29,8 @@ const StyledCheckbox = _styledComponents.default.div`
|
|
|
29
29
|
inputWidth,
|
|
30
30
|
reverse,
|
|
31
31
|
size,
|
|
32
|
-
adaptiveSpacingSmallScreen
|
|
32
|
+
adaptiveSpacingSmallScreen,
|
|
33
|
+
applyNewValidation
|
|
33
34
|
} = _ref;
|
|
34
35
|
return (0, _styledComponents.css)`
|
|
35
36
|
${adaptiveSpacingSmallScreen && "margin-left: 0;"}
|
|
@@ -50,6 +51,8 @@ const StyledCheckbox = _styledComponents.default.div`
|
|
|
50
51
|
${info && `border: 1px solid var(--colorsSemanticInfo500);`}
|
|
51
52
|
${warning && `border: 1px solid var(--colorsSemanticCaution500);`}
|
|
52
53
|
${error && `border: 2px solid var(--colorsSemanticNegative500);`}
|
|
54
|
+
|
|
55
|
+
${warning && applyNewValidation && `border: 1px solid var(--colorsUtilityMajor300);`}
|
|
53
56
|
`}
|
|
54
57
|
}
|
|
55
58
|
|
|
@@ -17,7 +17,7 @@ var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
|
17
17
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
18
18
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
19
19
|
var _useIsStickyFooterForm = _interopRequireDefault(require("../../hooks/__internal__/useIsStickyFooterForm"));
|
|
20
|
-
var
|
|
20
|
+
var _useModalAria = _interopRequireDefault(require("../../hooks/__internal__/useModalAria/useModalAria"));
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
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); }
|
|
23
23
|
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; }
|
|
@@ -58,9 +58,7 @@ const Dialog = _ref => {
|
|
|
58
58
|
current: subtitleId
|
|
59
59
|
} = (0, _react.useRef)((0, _guid.default)());
|
|
60
60
|
const hasStickyFooter = (0, _useIsStickyFooterForm.default)(children);
|
|
61
|
-
const
|
|
62
|
-
topModal
|
|
63
|
-
} = (0, _react.useContext)(_topModalContext.default);
|
|
61
|
+
const isTopModal = (0, _useModalAria.default)(dialogRef);
|
|
64
62
|
const centerDialog = (0, _react.useCallback)(() => {
|
|
65
63
|
/* istanbul ignore if */
|
|
66
64
|
if (!dialogRef.current) {
|
|
@@ -171,7 +169,7 @@ const Dialog = _ref => {
|
|
|
171
169
|
isOpen: open,
|
|
172
170
|
additionalWrapperRefs: focusableContainers
|
|
173
171
|
}, /*#__PURE__*/_react.default.createElement(_dialog.StyledDialog, _extends({
|
|
174
|
-
"aria-modal":
|
|
172
|
+
"aria-modal": isTopModal ? true : undefined,
|
|
175
173
|
ref: dialogRef,
|
|
176
174
|
topMargin: _dialog2.TOP_MARGIN
|
|
177
175
|
}, dialogProps, {
|
|
@@ -17,7 +17,7 @@ var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
|
17
17
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
18
18
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
19
19
|
var _useIsStickyFooterForm = _interopRequireDefault(require("../../hooks/__internal__/useIsStickyFooterForm"));
|
|
20
|
-
var
|
|
20
|
+
var _useModalAria = _interopRequireDefault(require("../../hooks/__internal__/useModalAria/useModalAria"));
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
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); }
|
|
23
23
|
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; }
|
|
@@ -57,9 +57,7 @@ const DialogFullScreen = _ref => {
|
|
|
57
57
|
current: subtitleId
|
|
58
58
|
} = (0, _react.useRef)((0, _guid.default)());
|
|
59
59
|
const hasStickyFooter = (0, _useIsStickyFooterForm.default)(children);
|
|
60
|
-
const
|
|
61
|
-
topModal
|
|
62
|
-
} = (0, _react.useContext)(_topModalContext.default);
|
|
60
|
+
const isTopModal = (0, _useModalAria.default)(dialogRef);
|
|
63
61
|
const closeIcon = () => {
|
|
64
62
|
if (!showCloseIcon || !onCancel) return null;
|
|
65
63
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
@@ -105,7 +103,7 @@ const DialogFullScreen = _ref => {
|
|
|
105
103
|
additionalWrapperRefs: focusableContainers,
|
|
106
104
|
focusableSelectors: focusableSelectors
|
|
107
105
|
}, /*#__PURE__*/_react.default.createElement(_dialogFullScreen.default, _extends({
|
|
108
|
-
"aria-modal": role === "dialog" &&
|
|
106
|
+
"aria-modal": role === "dialog" && isTopModal ? true : undefined
|
|
109
107
|
}, ariaProps, {
|
|
110
108
|
ref: dialogRef,
|
|
111
109
|
"data-element": "dialog-full-screen",
|
|
@@ -14,6 +14,8 @@ export interface RadioButtonGroupProps extends ValidationProps, MarginProps {
|
|
|
14
14
|
labelSpacing?: 1 | 2;
|
|
15
15
|
/** The content for the RadioGroup Legend */
|
|
16
16
|
legend?: string;
|
|
17
|
+
/** The content for the hint text of the RadioGroup Legend */
|
|
18
|
+
legendHelp?: string;
|
|
17
19
|
/** Text alignment of legend when inline */
|
|
18
20
|
legendAlign?: "left" | "right";
|
|
19
21
|
/** When true, legend is placed in line with the radiobuttons */
|
|
@@ -4,17 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.RadioButtonGroup = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
|
|
10
10
|
var _fieldset = _interopRequireDefault(require("../../__internal__/fieldset"));
|
|
11
|
-
var _radioButtonGroup =
|
|
11
|
+
var _radioButtonGroup = _interopRequireWildcard(require("./radio-button-group.style"));
|
|
12
12
|
var _radioButtonMapper = _interopRequireDefault(require("../../__internal__/radio-button-mapper/radio-button-mapper.component"));
|
|
13
13
|
var _useIsAboveBreakpoint = _interopRequireDefault(require("../../hooks/__internal__/useIsAboveBreakpoint"));
|
|
14
14
|
var _utils = require("../../style/utils");
|
|
15
15
|
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
16
16
|
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
17
|
+
var _carbonProvider = require("../carbon-provider/carbon-provider.component");
|
|
18
|
+
var _validationMessage = _interopRequireDefault(require("../../__internal__/validation-message/validation-message.component"));
|
|
19
|
+
var _box = _interopRequireDefault(require("../../components/box"));
|
|
20
|
+
var _textbox = require("../../components/textbox/textbox.style");
|
|
17
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
18
24
|
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); }
|
|
19
25
|
let deprecateUncontrolledWarnTriggered = false;
|
|
20
26
|
const RadioButtonGroup = props => {
|
|
@@ -22,6 +28,7 @@ const RadioButtonGroup = props => {
|
|
|
22
28
|
children,
|
|
23
29
|
name,
|
|
24
30
|
legend,
|
|
31
|
+
legendHelp,
|
|
25
32
|
error,
|
|
26
33
|
warning,
|
|
27
34
|
info,
|
|
@@ -39,6 +46,9 @@ const RadioButtonGroup = props => {
|
|
|
39
46
|
required,
|
|
40
47
|
tooltipPosition
|
|
41
48
|
} = props;
|
|
49
|
+
const {
|
|
50
|
+
validationRedesignOptIn
|
|
51
|
+
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
42
52
|
if (!deprecateUncontrolledWarnTriggered && !onChange) {
|
|
43
53
|
deprecateUncontrolledWarnTriggered = true;
|
|
44
54
|
_logger.default.deprecate("Uncontrolled behaviour in `Radio Button` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
|
|
@@ -54,7 +64,51 @@ const RadioButtonGroup = props => {
|
|
|
54
64
|
if (adaptiveSpacingBreakpoint && !isAboveSpacingBreakpoint) {
|
|
55
65
|
marginLeft = undefined;
|
|
56
66
|
}
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_fieldset.default, _extends({
|
|
68
|
+
legend: legend,
|
|
69
|
+
error: error,
|
|
70
|
+
warning: warning,
|
|
71
|
+
info: info,
|
|
72
|
+
inline: inlineLegend,
|
|
73
|
+
legendWidth: legendWidth,
|
|
74
|
+
legendAlign: legendAlign,
|
|
75
|
+
legendSpacing: legendSpacing,
|
|
76
|
+
isRequired: required
|
|
77
|
+
}, (0, _tags.default)("radiogroup", props), marginProps, {
|
|
78
|
+
ml: marginLeft,
|
|
79
|
+
blockGroupBehaviour: !(error || warning)
|
|
80
|
+
}), legendHelp && /*#__PURE__*/_react.default.createElement(_radioButtonGroup.StyledHintText, null, legendHelp), /*#__PURE__*/_react.default.createElement(_box.default, {
|
|
81
|
+
position: "relative"
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
|
|
83
|
+
error: error,
|
|
84
|
+
warning: warning
|
|
85
|
+
}), (error || warning) && /*#__PURE__*/_react.default.createElement(_textbox.ErrorBorder, {
|
|
86
|
+
inline: inline,
|
|
87
|
+
warning: !!(!error && warning)
|
|
88
|
+
}), /*#__PURE__*/_react.default.createElement(_radioButtonGroup.default, {
|
|
89
|
+
"data-component": "radio-button-group",
|
|
90
|
+
role: "radiogroup",
|
|
91
|
+
inline: inline,
|
|
92
|
+
legendInline: inlineLegend
|
|
93
|
+
}, /*#__PURE__*/_react.default.createElement(_radioButtonMapper.default, {
|
|
94
|
+
name: name,
|
|
95
|
+
onBlur: onBlur,
|
|
96
|
+
onChange: onChange,
|
|
97
|
+
value: value
|
|
98
|
+
}, _react.default.Children.map(children, child => {
|
|
99
|
+
if (! /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
100
|
+
return child;
|
|
101
|
+
}
|
|
102
|
+
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
103
|
+
inline,
|
|
104
|
+
labelSpacing,
|
|
105
|
+
error: !!error,
|
|
106
|
+
warning: !!warning,
|
|
107
|
+
info: !!info,
|
|
108
|
+
required,
|
|
109
|
+
...child.props
|
|
110
|
+
});
|
|
111
|
+
}))))) : /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
58
112
|
tooltipPosition: tooltipPosition
|
|
59
113
|
}, /*#__PURE__*/_react.default.createElement(_fieldset.default, _extends({
|
|
60
114
|
legend: legend,
|
|
@@ -92,7 +146,7 @@ const RadioButtonGroup = props => {
|
|
|
92
146
|
required,
|
|
93
147
|
...child.props
|
|
94
148
|
});
|
|
95
|
-
})))));
|
|
149
|
+
}))))));
|
|
96
150
|
};
|
|
97
151
|
exports.RadioButtonGroup = RadioButtonGroup;
|
|
98
152
|
RadioButtonGroup.displayName = "RadioButtonGroup";
|
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.StyledHintText = 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; }
|
|
10
|
+
const StyledHintText = _styledComponents.default.div`
|
|
11
|
+
margin-top: -4px;
|
|
12
|
+
margin-bottom: 8px;
|
|
13
|
+
color: var(--colorsUtilityYin055);
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
`;
|
|
16
|
+
exports.StyledHintText = StyledHintText;
|
|
10
17
|
const RadioButtonGroupStyle = _styledComponents.default.div`
|
|
11
18
|
${_ref => {
|
|
12
19
|
let {
|
|
@@ -13,6 +13,7 @@ var _radioButtonSvg = _interopRequireDefault(require("./radio-button-svg.compone
|
|
|
13
13
|
var _utils = require("../../style/utils");
|
|
14
14
|
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
15
15
|
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
16
|
+
var _carbonProvider = require("../carbon-provider/carbon-provider.component");
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
18
|
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); }
|
|
18
19
|
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; }
|
|
@@ -52,6 +53,9 @@ const RadioButton = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
52
53
|
inputRef,
|
|
53
54
|
...props
|
|
54
55
|
} = _ref;
|
|
56
|
+
const {
|
|
57
|
+
validationRedesignOptIn
|
|
58
|
+
} = (0, _react.useContext)(_carbonProvider.NewValidationContext);
|
|
55
59
|
const marginProps = (0, _utils.filterStyledSystemMarginProps)(props);
|
|
56
60
|
const handleChange = (0, _react.useCallback)(event => {
|
|
57
61
|
/* istanbul ignore else */
|
|
@@ -66,17 +70,24 @@ const RadioButton = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
66
70
|
deprecateInputRefWarnTriggered = true;
|
|
67
71
|
_logger.default.deprecate("The `inputRef` prop in `RadioButton` component is deprecated and will soon be removed. Please use `ref` instead.");
|
|
68
72
|
}
|
|
69
|
-
const
|
|
73
|
+
const validationProps = {
|
|
70
74
|
disabled,
|
|
71
|
-
fieldHelpInline,
|
|
72
75
|
inputWidth,
|
|
73
|
-
labelSpacing,
|
|
74
76
|
error,
|
|
75
77
|
warning,
|
|
76
78
|
info
|
|
77
79
|
};
|
|
80
|
+
const commonProps = {
|
|
81
|
+
...validationProps,
|
|
82
|
+
fieldHelpInline,
|
|
83
|
+
labelSpacing
|
|
84
|
+
};
|
|
78
85
|
const inputProps = {
|
|
79
|
-
...
|
|
86
|
+
...(validationRedesignOptIn ? {
|
|
87
|
+
...validationProps
|
|
88
|
+
} : {
|
|
89
|
+
...commonProps
|
|
90
|
+
}),
|
|
80
91
|
autoFocus,
|
|
81
92
|
checked,
|
|
82
93
|
fieldHelp,
|
|
@@ -103,17 +114,24 @@ const RadioButton = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
103
114
|
...props
|
|
104
115
|
};
|
|
105
116
|
!!props.children ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "This component is meant to be used as a self-closing tag. " + "You should probably use the label prop instead.") : (0, _invariant.default)(false) : void 0;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
tooltipPosition: tooltipPosition
|
|
109
|
-
}, /*#__PURE__*/_react.default.createElement(_radioButton.default, _extends({
|
|
117
|
+
const componentToRender = /*#__PURE__*/_react.default.createElement(_radioButton.default, _extends({
|
|
118
|
+
applyNewValidation: validationRedesignOptIn,
|
|
110
119
|
"data-component": dataComponent,
|
|
111
120
|
"data-role": dataRole,
|
|
112
121
|
"data-element": dataElement,
|
|
113
122
|
inline: inline,
|
|
114
123
|
reverse: reverse,
|
|
115
124
|
size: size
|
|
116
|
-
},
|
|
125
|
+
}, validationRedesignOptIn ? {
|
|
126
|
+
...validationProps
|
|
127
|
+
} : {
|
|
128
|
+
...commonProps,
|
|
129
|
+
fieldHelp
|
|
130
|
+
}, marginProps), /*#__PURE__*/_react.default.createElement(_checkableInput.default, inputProps, /*#__PURE__*/_react.default.createElement(_radioButtonSvg.default, null)));
|
|
131
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, validationRedesignOptIn ? componentToRender : /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
|
|
132
|
+
helpAriaLabel: helpAriaLabel,
|
|
133
|
+
tooltipPosition: tooltipPosition
|
|
134
|
+
}, componentToRender));
|
|
117
135
|
});
|
|
118
136
|
exports.RadioButton = RadioButton;
|
|
119
137
|
RadioButton.propTypes = {
|
|
@@ -17,7 +17,7 @@ var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/gui
|
|
|
17
17
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
18
18
|
var _utils = require("../../style/utils");
|
|
19
19
|
var _useIsStickyFooterForm = _interopRequireDefault(require("../../hooks/__internal__/useIsStickyFooterForm"));
|
|
20
|
-
var
|
|
20
|
+
var _useModalAria = _interopRequireDefault(require("../../hooks/__internal__/useModalAria/useModalAria"));
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
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); }
|
|
23
23
|
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; }
|
|
@@ -61,9 +61,7 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
61
61
|
if (typeof ref === "object") ref.current = reference;
|
|
62
62
|
if (typeof ref === "function") ref(reference);
|
|
63
63
|
}, [ref]);
|
|
64
|
-
const
|
|
65
|
-
topModal
|
|
66
|
-
} = (0, _react.useContext)(_topModalContext.default);
|
|
64
|
+
const isTopModal = (0, _useModalAria.default)(sidebarRef);
|
|
67
65
|
const closeIcon = () => {
|
|
68
66
|
if (!onCancel) return null;
|
|
69
67
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
@@ -80,7 +78,7 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
80
78
|
"data-role": rest["data-role"]
|
|
81
79
|
};
|
|
82
80
|
const sidebar = /*#__PURE__*/_react.default.createElement(_sidebar.default, _extends({
|
|
83
|
-
"aria-modal": !enableBackgroundUI &&
|
|
81
|
+
"aria-modal": !enableBackgroundUI && isTopModal,
|
|
84
82
|
"aria-describedby": ariaDescribedBy,
|
|
85
83
|
"aria-label": ariaLabel,
|
|
86
84
|
"aria-labelledby": !ariaLabelledBy && !ariaLabel ? headerId : ariaLabelledBy,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const ErrorBorder: import("styled-components").StyledComponent<"span", any, {
|
|
2
2
|
warning: boolean;
|
|
3
|
+
inline?: boolean | undefined;
|
|
3
4
|
}, never>;
|
|
4
5
|
declare const StyledInputHint: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
5
6
|
declare const StyledHintText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -10,7 +10,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
10
10
|
const ErrorBorder = _styledComponents.default.span`
|
|
11
11
|
${_ref => {
|
|
12
12
|
let {
|
|
13
|
-
warning
|
|
13
|
+
warning,
|
|
14
|
+
inline
|
|
14
15
|
} = _ref;
|
|
15
16
|
return (0, _styledComponents.css)`
|
|
16
17
|
position: absolute;
|
|
@@ -18,7 +19,7 @@ const ErrorBorder = _styledComponents.default.span`
|
|
|
18
19
|
width: 2px;
|
|
19
20
|
background-color: ${warning ? "var(--colorsSemanticCaution500)" : "var(--colorsSemanticNegative500)"};
|
|
20
21
|
left: -12px;
|
|
21
|
-
bottom: 0px;
|
|
22
|
+
bottom: ${inline ? "10px" : "0px"};
|
|
22
23
|
top: 0px;
|
|
23
24
|
`;
|
|
24
25
|
}}
|
|
@@ -67,8 +67,11 @@ const Toast = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
67
67
|
(0, _react.useEffect)(() => {
|
|
68
68
|
if (!disableAutoFocus) {
|
|
69
69
|
if (open) {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
// setTimeout needed as otherwise this runs before the ref is populated
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
focusedElementBeforeOpening.current = document.activeElement;
|
|
73
|
+
toastContentNodeRef.current?.focus();
|
|
74
|
+
}, 0);
|
|
72
75
|
} else if (focusedElementBeforeOpening.current) {
|
|
73
76
|
focusedElementBeforeOpening.current.focus();
|
|
74
77
|
focusedElementBeforeOpening.current = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./useModalAria";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useModalAria.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _useModalAria = _interopRequireDefault(require("./useModalAria"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useModalAria;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _topModalContext = _interopRequireDefault(require("../../../components/carbon-provider/top-modal-context"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function useModalAria(containerRef) {
|
|
11
|
+
const {
|
|
12
|
+
topModal
|
|
13
|
+
} = (0, _react.useContext)(_topModalContext.default);
|
|
14
|
+
const isTopModal = topModal?.contains(containerRef.current);
|
|
15
|
+
(0, _react.useEffect)(() => {
|
|
16
|
+
const originalValues = [];
|
|
17
|
+
const hideNonTopModalElements = rootElement => {
|
|
18
|
+
if (!rootElement.contains(topModal)) {
|
|
19
|
+
originalValues.push({
|
|
20
|
+
element: rootElement,
|
|
21
|
+
"aria-hidden": rootElement.getAttribute("aria-hidden"),
|
|
22
|
+
inert: rootElement.getAttribute("inert")
|
|
23
|
+
});
|
|
24
|
+
rootElement.setAttribute("aria-hidden", "true");
|
|
25
|
+
rootElement.setAttribute("inert", "");
|
|
26
|
+
} else if (rootElement !== topModal) {
|
|
27
|
+
Array.from(rootElement.children).forEach(hideNonTopModalElements);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if (isTopModal) {
|
|
31
|
+
hideNonTopModalElements(document.body);
|
|
32
|
+
}
|
|
33
|
+
return () => originalValues.forEach(_ref => {
|
|
34
|
+
let {
|
|
35
|
+
element,
|
|
36
|
+
"aria-hidden": ariaHidden,
|
|
37
|
+
inert
|
|
38
|
+
} = _ref;
|
|
39
|
+
if (ariaHidden === null) {
|
|
40
|
+
element.removeAttribute("aria-hidden");
|
|
41
|
+
} else {
|
|
42
|
+
element.setAttribute("aria-hidden", ariaHidden);
|
|
43
|
+
}
|
|
44
|
+
if (inert === null) {
|
|
45
|
+
element.removeAttribute("inert");
|
|
46
|
+
} else {
|
|
47
|
+
element.setAttribute("inert", inert);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}, [topModal, isTopModal]);
|
|
51
|
+
return isTopModal;
|
|
52
|
+
}
|