carbon-react 109.2.2 → 109.3.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.
- package/esm/__internal__/field-help/field-help.component.d.ts +10 -0
- package/esm/__internal__/field-help/field-help.component.js +12 -16
- package/esm/__internal__/field-help/field-help.style.d.ts +8 -0
- package/esm/__internal__/field-help/field-help.style.js +2 -10
- package/esm/__internal__/field-help/index.d.ts +2 -1
- package/esm/__internal__/focus-trap/focus-trap-utils.d.ts +1 -2
- package/esm/__internal__/focus-trap/focus-trap-utils.js +57 -8
- package/esm/__internal__/focus-trap/focus-trap.component.js +35 -25
- package/esm/__internal__/validations/validation-icon.component.js +1 -1
- package/esm/__spec_helper__/index.d.ts +1 -0
- package/esm/__spec_helper__/index.js +4 -10
- package/esm/__spec_helper__/mock-match-media.d.ts +2 -2
- package/esm/__spec_helper__/mock-match-media.js +2 -2
- package/esm/__spec_helper__/mock-resize-observer.d.ts +2 -0
- package/esm/components/accordion/accordion-group/accordion-group.component.js +1 -1
- package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
- package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +3 -3
- package/esm/components/action-popover/action-popover.component.js +1 -1
- package/esm/components/alert/alert.component.js +9 -0
- package/esm/components/anchor-navigation/anchor-navigation.component.js +2 -2
- package/esm/components/button/button.component.js +2 -2
- package/esm/components/button-bar/button-bar.component.js +1 -1
- package/esm/components/decimal/decimal.component.js +3 -3
- package/esm/components/dialog/dialog.component.js +9 -2
- package/esm/components/dialog/dialog.d.ts +2 -0
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +9 -2
- package/esm/components/dialog-full-screen/dialog-full-screen.d.ts +2 -0
- package/esm/components/drawer/drawer.component.js +1 -1
- package/esm/components/icon/icon.component.js +1 -1
- package/esm/components/menu/__internal__/submenu/submenu.component.js +1 -0
- package/esm/components/note/note.component.js +6 -6
- package/esm/components/numeral-date/numeral-date.component.js +1 -1
- package/esm/components/search/search.component.js +1 -1
- package/esm/components/select/filterable-select/filterable-select.component.js +3 -3
- package/esm/components/select/multi-select/multi-select.component.js +2 -2
- package/esm/components/select/simple-select/simple-select.component.js +2 -2
- package/esm/components/sidebar/sidebar.component.js +9 -2
- package/esm/components/sidebar/sidebar.d.ts +2 -0
- package/esm/components/toast/toast.component.js +35 -9
- package/esm/components/toast/toast.d.ts +5 -1
- package/esm/components/tooltip/tooltip.component.js +1 -1
- package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +39 -37
- package/lib/__internal__/field-help/field-help.component.d.ts +10 -0
- package/lib/__internal__/field-help/field-help.component.js +12 -16
- package/lib/__internal__/field-help/field-help.style.d.ts +8 -0
- package/lib/__internal__/field-help/field-help.style.js +2 -13
- package/lib/__internal__/field-help/index.d.ts +2 -1
- package/lib/__internal__/focus-trap/focus-trap-utils.d.ts +1 -2
- package/lib/__internal__/focus-trap/focus-trap-utils.js +57 -10
- package/lib/__internal__/focus-trap/focus-trap.component.js +34 -24
- package/lib/__internal__/validations/validation-icon.component.js +1 -1
- package/lib/__spec_helper__/index.d.ts +1 -0
- package/lib/__spec_helper__/index.js +3 -10
- package/lib/__spec_helper__/mock-match-media.d.ts +2 -2
- package/lib/__spec_helper__/mock-match-media.js +4 -4
- package/lib/__spec_helper__/mock-resize-observer.d.ts +2 -0
- package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -1
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
- package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +3 -3
- package/lib/components/action-popover/action-popover.component.js +1 -1
- package/lib/components/alert/alert.component.js +9 -0
- package/lib/components/anchor-navigation/anchor-navigation.component.js +2 -2
- package/lib/components/button/button.component.js +2 -2
- package/lib/components/button-bar/button-bar.component.js +1 -1
- package/lib/components/decimal/decimal.component.js +3 -3
- package/lib/components/dialog/dialog.component.js +9 -2
- package/lib/components/dialog/dialog.d.ts +2 -0
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +9 -2
- package/lib/components/dialog-full-screen/dialog-full-screen.d.ts +2 -0
- package/lib/components/drawer/drawer.component.js +1 -1
- package/lib/components/icon/icon.component.js +1 -1
- package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -0
- package/lib/components/note/note.component.js +6 -6
- package/lib/components/numeral-date/numeral-date.component.js +1 -1
- package/lib/components/search/search.component.js +1 -1
- package/lib/components/select/filterable-select/filterable-select.component.js +3 -3
- package/lib/components/select/multi-select/multi-select.component.js +2 -2
- package/lib/components/select/simple-select/simple-select.component.js +2 -2
- package/lib/components/sidebar/sidebar.component.js +9 -2
- package/lib/components/sidebar/sidebar.d.ts +2 -0
- package/lib/components/toast/toast.component.js +35 -7
- package/lib/components/toast/toast.d.ts +5 -1
- package/lib/components/tooltip/tooltip.component.js +1 -1
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +38 -36
- package/package.json +19 -17
- package/scripts/{check_carbon_version.js → check_carbon_version/check_carbon_version.js} +10 -2
- package/scripts/{check_rfcs.js → check_rfcs/check_rfcs.js} +8 -1
- package/esm/__internal__/field-help/field-help.d.ts +0 -14
- package/lib/__internal__/field-help/field-help.d.ts +0 -14
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.mockMatchMedia = exports.
|
|
6
|
+
exports.mockMatchMedia = exports.setupMatchMediaMock = void 0;
|
|
7
7
|
let mocked = false;
|
|
8
8
|
let _matches = false;
|
|
9
9
|
const removeListener = jest.fn();
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const setupMatchMediaMock = () => {
|
|
12
12
|
if (!global.window) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
@@ -29,11 +29,11 @@ const setup = () => {
|
|
|
29
29
|
mocked = true;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
exports.
|
|
32
|
+
exports.setupMatchMediaMock = setupMatchMediaMock;
|
|
33
33
|
|
|
34
34
|
const mockMatchMedia = matches => {
|
|
35
35
|
if (!mocked) {
|
|
36
|
-
throw new Error("window.matchMedia has not been mocked. Did you call
|
|
36
|
+
throw new Error("window.matchMedia has not been mocked. Did you call setupMatchMediaMock()?");
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
_matches = matches;
|
|
@@ -38,7 +38,7 @@ const AccordionGroup = ({
|
|
|
38
38
|
|
|
39
39
|
return hasAccordionChildren;
|
|
40
40
|
}, [children]);
|
|
41
|
-
(0, _invariant.default)(
|
|
41
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `AccordionGroup accepts only children of type \`${_accordion.default.displayName}\`.`) : (0, _invariant.default)(false) : void 0;
|
|
42
42
|
const filteredChildren = (0, _react.useMemo)(() => _react.default.Children.toArray(children).filter(child => {
|
|
43
43
|
return /*#__PURE__*/_react.default.isValidElement(child);
|
|
44
44
|
}), [children]);
|
|
@@ -82,8 +82,8 @@ const ActionPopoverItem = ({
|
|
|
82
82
|
}) => {
|
|
83
83
|
const l = (0, _useLocale.default)();
|
|
84
84
|
const context = (0, _react.useContext)(_actionPopoverContext.default);
|
|
85
|
-
(0, _invariant.default)(
|
|
86
|
-
(
|
|
85
|
+
!context ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverItem must be used within an ActionPopover component") : (0, _invariant.default)(false) : void 0;
|
|
86
|
+
!( /*#__PURE__*/_react.default.isValidElement(submenu) ? submenu.type === _actionPopoverMenu.default : true) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverItem only accepts submenu of type `ActionPopoverMenu`") : (0, _invariant.default)(false) : void 0;
|
|
87
87
|
const {
|
|
88
88
|
setOpenPopover,
|
|
89
89
|
isOpenPopover,
|
|
@@ -42,11 +42,11 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
42
42
|
...rest
|
|
43
43
|
}, ref) => {
|
|
44
44
|
const context = (0, _react.useContext)(_actionPopoverContext.default);
|
|
45
|
-
(0, _invariant.default)(
|
|
45
|
+
!context ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverMenu must be used within an ActionPopover component") : (0, _invariant.default)(false) : void 0;
|
|
46
46
|
const {
|
|
47
47
|
focusButton
|
|
48
48
|
} = context;
|
|
49
|
-
(
|
|
49
|
+
!(setOpen && setFocusIndex && typeof focusIndex !== "undefined") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverMenu must be used within an ActionPopover or ActionPopoverItem component") : (0, _invariant.default)(false) : void 0;
|
|
50
50
|
const hasProperChildren = (0, _react.useMemo)(() => {
|
|
51
51
|
const incorrectChild = _react.default.Children.toArray(children).find(child => {
|
|
52
52
|
if (! /*#__PURE__*/_react.default.isValidElement(child)) {
|
|
@@ -58,7 +58,7 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
58
58
|
|
|
59
59
|
return !incorrectChild;
|
|
60
60
|
}, [children]);
|
|
61
|
-
(0, _invariant.default)(
|
|
61
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `ActionPopoverMenu only accepts children of type \`${_actionPopoverItem.default.displayName}\`` + ` and \`${_actionPopoverDivider.default.displayName}\`.`) : (0, _invariant.default)(false) : void 0;
|
|
62
62
|
const items = (0, _react.useMemo)(() => {
|
|
63
63
|
return _react.default.Children.toArray(children).filter(child => {
|
|
64
64
|
return /*#__PURE__*/_react.default.isValidElement(child) && child.type === _actionPopoverItem.default;
|
|
@@ -74,7 +74,7 @@ const ActionPopover = ({
|
|
|
74
74
|
|
|
75
75
|
return !incorrectChild;
|
|
76
76
|
}, [children]);
|
|
77
|
-
(0, _invariant.default)(
|
|
77
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `ActionPopover only accepts children of type \`${_actionPopoverItem.default.displayName}\`` + ` and \`${_actionPopoverDivider.default.displayName}\`.`) : (0, _invariant.default)(false) : void 0;
|
|
78
78
|
const mappedPlacement = (0, _react.useMemo)(() => {
|
|
79
79
|
if (placement === "top" && !rightAlignMenu) {
|
|
80
80
|
return "top-end";
|
|
@@ -42,6 +42,15 @@ Alert.propTypes = {
|
|
|
42
42
|
"disableEscKey": _propTypes.default.bool,
|
|
43
43
|
"disableFocusTrap": _propTypes.default.bool,
|
|
44
44
|
"enableBackgroundUI": _propTypes.default.bool,
|
|
45
|
+
"focusableContainers": _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
46
|
+
"current": function (props, propName) {
|
|
47
|
+
if (props[propName] == null) {
|
|
48
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
49
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
50
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})),
|
|
45
54
|
"focusFirstElement": _propTypes.default.shape({
|
|
46
55
|
"current": function (props, propName) {
|
|
47
56
|
if (props[propName] == null) {
|
|
@@ -34,7 +34,7 @@ const AnchorNavigation = ({
|
|
|
34
34
|
children,
|
|
35
35
|
stickyNavigation
|
|
36
36
|
}) => {
|
|
37
|
-
(0,
|
|
37
|
+
!(0, _reactIs.isFragment)(stickyNavigation) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.") : (0, _invariant.default)(false) : void 0;
|
|
38
38
|
const hasCorrectItemStructure = (0, _react.useMemo)(() => {
|
|
39
39
|
const incorrectChild = _react.default.Children.toArray(stickyNavigation.props.children).find(child => {
|
|
40
40
|
return ! /*#__PURE__*/_react.default.isValidElement(child) || child.type.displayName !== _anchorNavigationItem.default.displayName;
|
|
@@ -42,7 +42,7 @@ const AnchorNavigation = ({
|
|
|
42
42
|
|
|
43
43
|
return !incorrectChild;
|
|
44
44
|
}, [stickyNavigation]);
|
|
45
|
-
(0, _invariant.default)(
|
|
45
|
+
!hasCorrectItemStructure ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${_anchorNavigationItem.default.displayName}\``) : (0, _invariant.default)(false) : void 0;
|
|
46
46
|
const [selectedIndex, setSelectedIndex] = (0, _react.useState)(0);
|
|
47
47
|
const sectionRefs = (0, _react.useRef)(_react.default.Children.map(stickyNavigation.props.children, child => child.props.target));
|
|
48
48
|
const anchorRefs = (0, _react.useRef)(Array.from({
|
|
@@ -118,10 +118,10 @@ const Button = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
118
118
|
fullWidth = false,
|
|
119
119
|
...rest
|
|
120
120
|
}, ref) => {
|
|
121
|
-
(0, _invariant.default)(
|
|
121
|
+
!!!(children || iconType) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Either prop `iconType` must be defined or this node must have children.") : (0, _invariant.default)(false) : void 0;
|
|
122
122
|
|
|
123
123
|
if (subtext) {
|
|
124
|
-
(0, _invariant.default)(
|
|
124
|
+
!(size === "large") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "subtext prop has no effect unless the button is large.") : (0, _invariant.default)(false) : void 0;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
if (!deprecatedForwardRefWarnTriggered && forwardRef) {
|
|
@@ -43,7 +43,7 @@ const ButtonBar = ({
|
|
|
43
43
|
|
|
44
44
|
return !incorrectChild;
|
|
45
45
|
}, [children]);
|
|
46
|
-
(0, _invariant.default)(
|
|
46
|
+
!hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ButtonBar accepts only `Button` or `IconButton` elements.") : (0, _invariant.default)(false) : void 0;
|
|
47
47
|
|
|
48
48
|
const getBtnProps = child => {
|
|
49
49
|
var _child$props, _child$props2, _child$props2$childre, _child$props2$childre2;
|
|
@@ -52,10 +52,10 @@ const Decimal = ({
|
|
|
52
52
|
const emptyValue = allowEmptyValue ? "" : "0.00";
|
|
53
53
|
const getSafeValueProp = (0, _react.useCallback)(initialValue => {
|
|
54
54
|
// We're intentionally preventing the use of number values to help prevent any unintentional rounding issues
|
|
55
|
-
(
|
|
55
|
+
!(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Decimal `value` prop must be a string") : (0, _invariant.default)(false) : void 0;
|
|
56
56
|
|
|
57
57
|
if (initialValue && !allowEmptyValue) {
|
|
58
|
-
(0, _invariant.default)(
|
|
58
|
+
!(initialValue !== "") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Decimal `value` must not be an empty string. Please use `allowEmptyValue` or `0.00`") : (0, _invariant.default)(false) : void 0;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return initialValue;
|
|
@@ -185,7 +185,7 @@ const Decimal = ({
|
|
|
185
185
|
const prevControlledRef = (0, _react.useRef)();
|
|
186
186
|
(0, _react.useEffect)(() => {
|
|
187
187
|
const message = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
188
|
-
(0, _invariant.default)(
|
|
188
|
+
!(prevControlledRef.current !== isControlled) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, message) : (0, _invariant.default)(false) : void 0;
|
|
189
189
|
prevControlledRef.current = isControlled;
|
|
190
190
|
}, [isControlled]);
|
|
191
191
|
const prevValue = (0, _usePrevious.default)(value);
|
|
@@ -55,6 +55,7 @@ const Dialog = ({
|
|
|
55
55
|
help,
|
|
56
56
|
role = "dialog",
|
|
57
57
|
contentPadding = {},
|
|
58
|
+
focusableContainers,
|
|
58
59
|
...rest
|
|
59
60
|
}) => {
|
|
60
61
|
const locale = (0, _useLocale.default)();
|
|
@@ -180,7 +181,8 @@ const Dialog = ({
|
|
|
180
181
|
focusFirstElement: focusFirstElement,
|
|
181
182
|
bespokeTrap: bespokeFocusTrap,
|
|
182
183
|
wrapperRef: dialogRef,
|
|
183
|
-
isOpen: open
|
|
184
|
+
isOpen: open,
|
|
185
|
+
additionalWrapperRefs: focusableContainers
|
|
184
186
|
}, /*#__PURE__*/_react.default.createElement(_dialog.DialogStyle, _extends({
|
|
185
187
|
"aria-modal": true,
|
|
186
188
|
ref: dialogRef,
|
|
@@ -271,7 +273,12 @@ Dialog.propTypes = {
|
|
|
271
273
|
p: _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
|
|
272
274
|
px: _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
|
|
273
275
|
py: _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
|
|
274
|
-
})
|
|
276
|
+
}),
|
|
277
|
+
|
|
278
|
+
/** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
|
|
279
|
+
focusableContainers: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
280
|
+
current: _propTypes.default.any
|
|
281
|
+
}))
|
|
275
282
|
};
|
|
276
283
|
Dialog.defaultProps = {
|
|
277
284
|
size: "medium",
|
|
@@ -59,6 +59,8 @@ export interface DialogProps extends ModalProps {
|
|
|
59
59
|
role?: string;
|
|
60
60
|
/** Padding to be set on the Dialog content */
|
|
61
61
|
contentPadding?: ContentPaddingInterface;
|
|
62
|
+
/** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
|
|
63
|
+
focusableContainers?: React.MutableRefObject<HTMLElement>[];
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
declare function Dialog(props: DialogProps): JSX.Element;
|
|
@@ -56,6 +56,7 @@ const DialogFullScreen = ({
|
|
|
56
56
|
contentRef,
|
|
57
57
|
help,
|
|
58
58
|
role = "dialog",
|
|
59
|
+
focusableContainers,
|
|
59
60
|
...rest
|
|
60
61
|
}) => {
|
|
61
62
|
const locale = (0, _useLocale.default)();
|
|
@@ -110,7 +111,8 @@ const DialogFullScreen = ({
|
|
|
110
111
|
autoFocus: !disableAutoFocus,
|
|
111
112
|
focusFirstElement: focusFirstElement,
|
|
112
113
|
wrapperRef: dialogRef,
|
|
113
|
-
isOpen: open
|
|
114
|
+
isOpen: open,
|
|
115
|
+
additionalWrapperRefs: focusableContainers
|
|
114
116
|
}, /*#__PURE__*/_react.default.createElement(_dialogFullScreen.default, _extends({
|
|
115
117
|
"aria-modal": role === "dialog" ? true : undefined
|
|
116
118
|
}, ariaProps, {
|
|
@@ -194,7 +196,12 @@ DialogFullScreen.propTypes = {
|
|
|
194
196
|
})]),
|
|
195
197
|
|
|
196
198
|
/** The ARIA role to be applied to the DialogFullscreen container */
|
|
197
|
-
role: _propTypes.default.string
|
|
199
|
+
role: _propTypes.default.string,
|
|
200
|
+
|
|
201
|
+
/** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
|
|
202
|
+
focusableContainers: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
203
|
+
current: _propTypes.default.any
|
|
204
|
+
}))
|
|
198
205
|
};
|
|
199
206
|
var _default = DialogFullScreen;
|
|
200
207
|
exports.default = _default;
|
|
@@ -41,6 +41,8 @@ export interface DialogFullScreenProps extends ModalProps {
|
|
|
41
41
|
title?: React.ReactNode;
|
|
42
42
|
/** The ARIA role to be applied to the DialogFullscreen container */
|
|
43
43
|
role?: string;
|
|
44
|
+
/** an optional array of refs to containers whose content should also be reachable by tabbing from the dialog */
|
|
45
|
+
focusableContainers?: React.MutableRefObject<HTMLElement>[];
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
declare function DialogFullScreen(props: DialogFullScreenProps): JSX.Element;
|
|
@@ -93,7 +93,7 @@ const Drawer = ({
|
|
|
93
93
|
const previousValue = (0, _usePrevious.default)(expanded);
|
|
94
94
|
(0, _react.useEffect)(() => {
|
|
95
95
|
const message = "Drawer should not switch from uncontrolled to controlled" + " (or vice versa). Decide between using a controlled or uncontrolled Drawer element" + " for the lifetime of the component";
|
|
96
|
-
(
|
|
96
|
+
!(isControlled.current === (expanded !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, message) : (0, _invariant.default)(false) : void 0;
|
|
97
97
|
|
|
98
98
|
if (isControlled.current && previousValue !== expanded) {
|
|
99
99
|
setIsExpanded(expanded);
|
|
@@ -58,7 +58,7 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
58
58
|
const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => _iconConfig.ICON_TOOLTIP_POSITIONS.includes(override));
|
|
59
59
|
|
|
60
60
|
if (tooltipFlipOverrides) {
|
|
61
|
-
(0, _invariant.default)(
|
|
61
|
+
!flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The tooltipFlipOverrides prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const isInteractive = !!tooltipMessage && !disabled;
|
|
@@ -242,6 +242,7 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
242
242
|
menuType: menuContext.menuType,
|
|
243
243
|
asPassiveItem: asPassiveItem
|
|
244
244
|
}, /*#__PURE__*/_react.default.createElement(_menuItem.default, _extends({}, rest, {
|
|
245
|
+
onClick: onClick,
|
|
245
246
|
className: className,
|
|
246
247
|
menuType: menuContext.menuType,
|
|
247
248
|
ref: ref,
|
|
@@ -45,12 +45,12 @@ const Note = ({
|
|
|
45
45
|
onLinkAdded,
|
|
46
46
|
...rest
|
|
47
47
|
}) => {
|
|
48
|
-
(0, _invariant.default)(
|
|
49
|
-
(0, _invariant.default)(
|
|
50
|
-
(0, _invariant.default)(
|
|
51
|
-
(
|
|
52
|
-
(
|
|
53
|
-
(
|
|
48
|
+
!(width > 0) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> width must be greater than 0") : (0, _invariant.default)(false) : void 0;
|
|
49
|
+
!createdDate ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> createdDate is required") : (0, _invariant.default)(false) : void 0;
|
|
50
|
+
!noteContent ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> noteContent is required") : (0, _invariant.default)(false) : void 0;
|
|
51
|
+
!(!status || status.text) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> status.text is required") : (0, _invariant.default)(false) : void 0;
|
|
52
|
+
!(!status || status.timeStamp) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> status.timeStamp is required") : (0, _invariant.default)(false) : void 0;
|
|
53
|
+
!(!inlineControl || inlineControl.type === _actionPopover.ActionPopover) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> inlineControl must be an instance of <ActionPopover>") : (0, _invariant.default)(false) : void 0;
|
|
54
54
|
|
|
55
55
|
const renderStatus = () => {
|
|
56
56
|
if (!status) {
|
|
@@ -108,7 +108,7 @@ const NumeralDate = ({
|
|
|
108
108
|
const [internalMessages, setInternalMessages] = (0, _react.useState)({});
|
|
109
109
|
(0, _react.useEffect)(() => {
|
|
110
110
|
const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
111
|
-
(
|
|
111
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
|
|
112
112
|
}, [value]);
|
|
113
113
|
const validationMessages = {
|
|
114
114
|
dd: l.numeralDate.validation.day(),
|
|
@@ -57,7 +57,7 @@ const Search = ({
|
|
|
57
57
|
}) => {
|
|
58
58
|
const isControlled = value !== undefined;
|
|
59
59
|
const initialValue = isControlled ? value : defaultValue;
|
|
60
|
-
(
|
|
60
|
+
!(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "This component has no initial value") : (0, _invariant.default)(false) : void 0;
|
|
61
61
|
const [searchValue, setSearchValue] = (0, _react.useState)(initialValue);
|
|
62
62
|
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
63
63
|
const [searchIsActive, setSearchIsActive] = (0, _react.useState)(initialValue.length >= threshold);
|
|
@@ -193,8 +193,8 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
193
193
|
(0, _react.useEffect)(() => {
|
|
194
194
|
const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
195
195
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
196
|
-
(
|
|
197
|
-
(
|
|
196
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
|
|
197
|
+
!(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onChangeMissingMessage) : (0, _invariant.default)(false) : void 0;
|
|
198
198
|
|
|
199
199
|
if (isControlled.current) {
|
|
200
200
|
setSelectedValue(prevValue => {
|
|
@@ -228,7 +228,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
228
228
|
(0, _react.useEffect)(() => {
|
|
229
229
|
const hasListActionButton = listActionButton !== undefined;
|
|
230
230
|
const onListActionMissingMessage = "onListAction prop required when using listActionButton prop";
|
|
231
|
-
(
|
|
231
|
+
!(!hasListActionButton || hasListActionButton && onListAction) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onListActionMissingMessage) : (0, _invariant.default)(false) : void 0;
|
|
232
232
|
}, [listActionButton, onListAction]);
|
|
233
233
|
(0, _react.useEffect)(() => {
|
|
234
234
|
if (isControlled.current) {
|
|
@@ -229,8 +229,8 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
229
229
|
(0, _react.useEffect)(() => {
|
|
230
230
|
const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
231
231
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
232
|
-
(
|
|
233
|
-
(
|
|
232
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
|
|
233
|
+
!(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onChangeMissingMessage) : (0, _invariant.default)(false) : void 0;
|
|
234
234
|
|
|
235
235
|
if (isControlled.current) {
|
|
236
236
|
setSelectedValue(value);
|
|
@@ -174,8 +174,8 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
174
174
|
(0, _react.useEffect)(() => {
|
|
175
175
|
const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
|
|
176
176
|
const onChangeMissingMessage = "onChange prop required when using a controlled input element";
|
|
177
|
-
(
|
|
178
|
-
(
|
|
177
|
+
!(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
|
|
178
|
+
!(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onChangeMissingMessage) : (0, _invariant.default)(false) : void 0;
|
|
179
179
|
|
|
180
180
|
if (isControlled.current) {
|
|
181
181
|
setSelectedValue(value);
|
|
@@ -54,6 +54,7 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
54
54
|
children,
|
|
55
55
|
onCancel,
|
|
56
56
|
role = "dialog",
|
|
57
|
+
focusableContainers,
|
|
57
58
|
...rest
|
|
58
59
|
}, ref) => {
|
|
59
60
|
const locale = (0, _useLocale.default)();
|
|
@@ -114,7 +115,8 @@ const Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
114
115
|
className: "carbon-sidebar"
|
|
115
116
|
}, componentTags), enableBackgroundUI ? sidebar : /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
|
|
116
117
|
wrapperRef: sidebarRef,
|
|
117
|
-
isOpen: open
|
|
118
|
+
isOpen: open,
|
|
119
|
+
additionalWrapperRefs: focusableContainers
|
|
118
120
|
}, sidebar));
|
|
119
121
|
});
|
|
120
122
|
|
|
@@ -153,7 +155,12 @@ Sidebar.propTypes = {
|
|
|
153
155
|
header: _propTypes.default.node,
|
|
154
156
|
|
|
155
157
|
/** The ARIA role to be applied to the container */
|
|
156
|
-
role: _propTypes.default.string
|
|
158
|
+
role: _propTypes.default.string,
|
|
159
|
+
|
|
160
|
+
/** an optional array of refs to containers whose content should also be reachable by tabbing from the sidebar */
|
|
161
|
+
focusableContainers: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
162
|
+
current: _propTypes.default.any
|
|
163
|
+
}))
|
|
157
164
|
};
|
|
158
165
|
Sidebar.defaultProps = {
|
|
159
166
|
position: "right",
|
|
@@ -42,6 +42,8 @@ export interface SidebarProps {
|
|
|
42
42
|
| "medium-large"
|
|
43
43
|
| "large"
|
|
44
44
|
| "extra-large";
|
|
45
|
+
/** an optional array of refs to containers whose content should also be reachable by tabbing from the sidebar */
|
|
46
|
+
focusableContainers?: React.MutableRefObject<HTMLElement>[];
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
declare const SidebarContext: React.Context<SidebarContextProps>;
|
|
@@ -35,7 +35,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
35
35
|
|
|
36
36
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
37
37
|
|
|
38
|
-
const Toast = ({
|
|
38
|
+
const Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
39
39
|
children,
|
|
40
40
|
className,
|
|
41
41
|
id,
|
|
@@ -46,12 +46,16 @@ const Toast = ({
|
|
|
46
46
|
targetPortalId,
|
|
47
47
|
timeout,
|
|
48
48
|
variant,
|
|
49
|
+
disableAutoFocus,
|
|
49
50
|
...restProps
|
|
50
|
-
}) => {
|
|
51
|
+
}, ref) => {
|
|
51
52
|
const locale = (0, _useLocale.default)();
|
|
52
53
|
const toastRef = (0, _react.useRef)();
|
|
53
54
|
const timer = (0, _react.useRef)();
|
|
54
55
|
const toastContentNodeRef = (0, _react.useRef)();
|
|
56
|
+
const closeIconRef = (0, _react.useRef)();
|
|
57
|
+
const focusedElementBeforeOpening = (0, _react.useRef)();
|
|
58
|
+
const refToPass = ref || toastRef;
|
|
55
59
|
const componentClasses = (0, _react.useMemo)(() => {
|
|
56
60
|
return (0, _classnames.default)(className);
|
|
57
61
|
}, [className]);
|
|
@@ -61,7 +65,7 @@ const Toast = ({
|
|
|
61
65
|
onDismiss(ev);
|
|
62
66
|
}
|
|
63
67
|
}, [onDismiss]);
|
|
64
|
-
(0, _useModalManager.default)(open, dismissToast,
|
|
68
|
+
(0, _useModalManager.default)(open, dismissToast, refToPass);
|
|
65
69
|
(0, _react.useEffect)(() => {
|
|
66
70
|
clearTimeout(timer.current);
|
|
67
71
|
|
|
@@ -71,13 +75,34 @@ const Toast = ({
|
|
|
71
75
|
|
|
72
76
|
timer.current = setTimeout(() => onDismiss(), timeout);
|
|
73
77
|
}, [onDismiss, open, timeout]);
|
|
78
|
+
(0, _react.useEffect)(() => {
|
|
79
|
+
if (onDismiss && !disableAutoFocus) {
|
|
80
|
+
if (open) {
|
|
81
|
+
var _closeIconRef$current;
|
|
82
|
+
|
|
83
|
+
focusedElementBeforeOpening.current = document.activeElement;
|
|
84
|
+
(_closeIconRef$current = closeIconRef.current) === null || _closeIconRef$current === void 0 ? void 0 : _closeIconRef$current.focus();
|
|
85
|
+
} else if (focusedElementBeforeOpening.current) {
|
|
86
|
+
focusedElementBeforeOpening.current.focus();
|
|
87
|
+
focusedElementBeforeOpening.current = undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, [open, onDismiss, disableAutoFocus]);
|
|
91
|
+
(0, _react.useEffect)(() => {
|
|
92
|
+
return () => {
|
|
93
|
+
if (focusedElementBeforeOpening.current) {
|
|
94
|
+
focusedElementBeforeOpening.current.focus();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
74
98
|
|
|
75
99
|
function renderCloseIcon() {
|
|
76
100
|
if (!onDismiss) return null;
|
|
77
101
|
return /*#__PURE__*/_react.default.createElement(_iconButton.default, {
|
|
78
102
|
"aria-label": locale.toast.ariaLabels.close(),
|
|
79
103
|
"data-element": "close",
|
|
80
|
-
onAction: onDismiss
|
|
104
|
+
onAction: onDismiss,
|
|
105
|
+
ref: closeIconRef
|
|
81
106
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
82
107
|
type: "close"
|
|
83
108
|
}));
|
|
@@ -119,9 +144,9 @@ const Toast = ({
|
|
|
119
144
|
isCenter: isCenter
|
|
120
145
|
}, /*#__PURE__*/_react.default.createElement(_toast.ToastWrapper, {
|
|
121
146
|
isCenter: isCenter,
|
|
122
|
-
ref:
|
|
147
|
+
ref: refToPass
|
|
123
148
|
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, renderToastContent())));
|
|
124
|
-
};
|
|
149
|
+
});
|
|
125
150
|
|
|
126
151
|
Toast.propTypes = {
|
|
127
152
|
/** Customizes the appearance in the DLS theme */
|
|
@@ -155,7 +180,10 @@ Toast.propTypes = {
|
|
|
155
180
|
targetPortalId: _propTypes.default.string,
|
|
156
181
|
|
|
157
182
|
/** Maximum toast width */
|
|
158
|
-
maxWidth: _propTypes.default.string
|
|
183
|
+
maxWidth: _propTypes.default.string,
|
|
184
|
+
|
|
185
|
+
/** Disables auto focus functionality when the Toast has a close icon */
|
|
186
|
+
disableAutoFocus: _propTypes.default.bool
|
|
159
187
|
};
|
|
160
188
|
var _default = Toast;
|
|
161
189
|
exports.default = _default;
|
|
@@ -25,8 +25,12 @@ export interface ToastPropTypes {
|
|
|
25
25
|
targetPortalId?: string;
|
|
26
26
|
/** Maximum toast width */
|
|
27
27
|
maxWidth?: string;
|
|
28
|
+
/** Disables auto focus functionality when the Toast has a close icon */
|
|
29
|
+
disableAutoFocus?: boolean;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
declare
|
|
32
|
+
declare function Toast(
|
|
33
|
+
props: ToastPropTypes & React.RefAttributes<HTMLDivElement>
|
|
34
|
+
): JSX.Element;
|
|
31
35
|
|
|
32
36
|
export default Toast;
|
|
@@ -49,7 +49,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
49
49
|
...rest
|
|
50
50
|
}, ref) => {
|
|
51
51
|
const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => _tooltip2.TOOLTIP_POSITIONS.includes(placement));
|
|
52
|
-
(0, _invariant.default)(
|
|
52
|
+
!isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
|
|
53
53
|
|
|
54
54
|
const tooltip = (attrs, content) => {
|
|
55
55
|
const currentPosition = attrs["data-placement"] || position;
|